Re: [PATCH] soc: qcom: update config dependencies for QCOM_RPMPD

From: Viresh Kumar
Date: Tue Jan 22 2019 - 05:09:00 EST


On 22-01-19, 15:24, Rajendra Nayak wrote:
> I was doing some quick testing by adding the calls to of_genpd_remove_last() as
> suggested by Ulf for cleaning up the genpd registrations, and I run into this
> backtrace when the driver re-probes followed by a remove
>
> [ 59.204525] kobject ((____ptrval____)): tried to init an initialized object, something is seriously wr.
> [ 59.214262] CPU: 3 PID: 1600 Comm: sh Not tainted 5.0.0-rc1-00012-g0513915837c5-dirty #32
> [ 59.222500] Hardware name: Qualcomm Technologies, Inc. SDM845 MTP (DT)
> [ 59.229081] Call trace:
> [ 59.231574] dump_backtrace+0x0/0x148
> [ 59.235276] show_stack+0x14/0x20
> [ 59.238631] dump_stack+0x8c/0xac
> [ 59.241980] kobject_init+0x8c/0xa0
> [ 59.245506] device_initialize+0x34/0xc8
> [ 59.249474] pm_genpd_init+0x170/0x260
> [ 59.253261] rpmhpd_probe+0x194/0x2b0
> [ 59.256966] platform_drv_probe+0x4c/0xa8
> [ 59.261011] really_probe+0x1e4/0x2c8
> [ 59.264711] driver_probe_device+0x58/0x10
> [ 59.268927] bind_store+0xdc/0x178
> [ 59.272356] drv_attr_store+0x20/0x30
> [ 59.276061] sysfs_kf_write+0x48/0x58
> [ 59.279760] kernfs_fop_write+0xcc/0x1c8
> [ 59.283728] __vfs_write+0x34/0x170
> [ 59.287245] vfs_write+0xa8/0x1b8
> [ 59.290592] ksys_write+0x5c/0xc8
> [ 59.293941] __arm64_sys_write+0x14/0x20
> [ 59.297897] el0_svc_common+0xb4/0x118
> [ 59.301676] el0_svc_handler+0x2c/0x80
> [ 59.305455] el0_svc+0x8/0xc
>
> Viresh/Ulf, looks like we need some cleanup of whats done by device_initialize()
> in pm_genpd_init() to happen as part of the pm_genpd_remove()?

Yeah, we normally need to call put_device() for that. Maybe something like this:

diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 500de1dee967..d5b984f042ec 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -1812,6 +1812,7 @@ static int genpd_remove(struct generic_pm_domain *genpd)
genpd_unlock(genpd);
cancel_work_sync(&genpd->power_off_work);
kfree(genpd->free);
+ put_device(&genpd->dev);
pr_debug("%s: removed %s\n", __func__, genpd->name);

return 0;

--
viresh