* [PATCH] PM / devfreq: passive: Use non-devm notifiers @ 2019-08-08 16:54 ` Leonard Crestez 2019-08-13 4:23 ` Chanwoo Choi 0 siblings, 1 reply; 2+ messages in thread From: Leonard Crestez @ 2019-08-08 16:54 UTC (permalink / raw) To: MyungJoo Ham, Kyungmin Park, Chanwoo Choi Cc: Artur Świgoń, Saravana Kannan, Krzysztof Kozlowski, Alexandre Bailon, Lukasz Luba, Rafael J. Wysocki, Geert Uytterhoeven, Bartosz Golaszewski, Bjorn Andersson, Greg Kroah-Hartman, linux-pm, linux-arm-kernel The devfreq passive governor registers and unregisters devfreq transition notifiers on DEVFREQ_GOV_START/GOV_STOP using devm wrappers. If devfreq itself is registered with devm then a warning is triggered on rmmod from devm_devfreq_unregister_notifier. Call stack looks like this: devm_devfreq_unregister_notifier+0x30/0x40 devfreq_passive_event_handler+0x4c/0x88 devfreq_remove_device.part.8+0x6c/0x9c devm_devfreq_dev_release+0x18/0x20 release_nodes+0x1b0/0x220 devres_release_all+0x78/0x84 device_release_driver_internal+0x100/0x1c0 driver_detach+0x4c/0x90 bus_remove_driver+0x7c/0xd0 driver_unregister+0x2c/0x58 platform_driver_unregister+0x10/0x18 imx_devfreq_platdrv_exit+0x14/0xd40 [imx_devfreq] This happens because devres_release_all will first remove all the nodes into a separate todo list so the nested devres_release from devm_devfreq_unregister_notifier won't find anything. Fix the warning by calling the non-devm APIS for frequency notification. Using devm wrappers is not actually useful for a governor anyway: it relies on the devfreq core to correctly match the GOV_START/GOV_STOP notifications. Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com> --- drivers/devfreq/governor_passive.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) The only current user of passive governor is exynos-bus; does rmmod work for you? Maybe I'm missing something. It also seems that no attempt is made to increase the ref count of the passive "parent" so in theory devices can be removed while still referenced. However that would be a separate issue. diff --git a/drivers/devfreq/governor_passive.c b/drivers/devfreq/governor_passive.c index 58308948b863..da485477065c 100644 --- a/drivers/devfreq/governor_passive.c +++ b/drivers/devfreq/governor_passive.c @@ -163,16 +163,16 @@ static int devfreq_passive_event_handler(struct devfreq *devfreq, case DEVFREQ_GOV_START: if (!p_data->this) p_data->this = devfreq; nb->notifier_call = devfreq_passive_notifier_call; - ret = devm_devfreq_register_notifier(dev, parent, nb, + ret = devfreq_register_notifier(parent, nb, DEVFREQ_TRANSITION_NOTIFIER); break; case DEVFREQ_GOV_STOP: - devm_devfreq_unregister_notifier(dev, parent, nb, - DEVFREQ_TRANSITION_NOTIFIER); + WARN_ON(devfreq_unregister_notifier(parent, nb, + DEVFREQ_TRANSITION_NOTIFIER)); break; default: break; } -- 2.17.1 ^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] PM / devfreq: passive: Use non-devm notifiers 2019-08-08 16:54 ` [PATCH] PM / devfreq: passive: Use non-devm notifiers Leonard Crestez @ 2019-08-13 4:23 ` Chanwoo Choi 0 siblings, 0 replies; 2+ messages in thread From: Chanwoo Choi @ 2019-08-13 4:23 UTC (permalink / raw) To: Leonard Crestez, MyungJoo Ham, Kyungmin Park Cc: Artur Świgoń, Saravana Kannan, Krzysztof Kozlowski, Alexandre Bailon, Lukasz Luba, Rafael J. Wysocki, Geert Uytterhoeven, Bartosz Golaszewski, Bjorn Andersson, Greg Kroah-Hartman, linux-pm, linux-arm-kernel, cpgs (cpgs@samsung.com) Hi, On 19. 8. 9. 오전 1:54, Leonard Crestez wrote: > The devfreq passive governor registers and unregisters devfreq > transition notifiers on DEVFREQ_GOV_START/GOV_STOP using devm wrappers. > > If devfreq itself is registered with devm then a warning is triggered on > rmmod from devm_devfreq_unregister_notifier. Call stack looks like this: > > devm_devfreq_unregister_notifier+0x30/0x40 > devfreq_passive_event_handler+0x4c/0x88 > devfreq_remove_device.part.8+0x6c/0x9c > devm_devfreq_dev_release+0x18/0x20 > release_nodes+0x1b0/0x220 > devres_release_all+0x78/0x84 > device_release_driver_internal+0x100/0x1c0 > driver_detach+0x4c/0x90 > bus_remove_driver+0x7c/0xd0 > driver_unregister+0x2c/0x58 > platform_driver_unregister+0x10/0x18 > imx_devfreq_platdrv_exit+0x14/0xd40 [imx_devfreq] > > This happens because devres_release_all will first remove all the nodes > into a separate todo list so the nested devres_release from > devm_devfreq_unregister_notifier won't find anything. > > Fix the warning by calling the non-devm APIS for frequency notification. > Using devm wrappers is not actually useful for a governor anyway: it > relies on the devfreq core to correctly match the GOV_START/GOV_STOP > notifications. > > Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com> > > --- > drivers/devfreq/governor_passive.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > The only current user of passive governor is exynos-bus; does rmmod work > for you? Maybe I'm missing something. > > It also seems that no attempt is made to increase the ref count of > the passive "parent" so in theory devices can be removed while still > referenced. However that would be a separate issue. > > diff --git a/drivers/devfreq/governor_passive.c b/drivers/devfreq/governor_passive.c > index 58308948b863..da485477065c 100644 > --- a/drivers/devfreq/governor_passive.c > +++ b/drivers/devfreq/governor_passive.c > @@ -163,16 +163,16 @@ static int devfreq_passive_event_handler(struct devfreq *devfreq, > case DEVFREQ_GOV_START: > if (!p_data->this) > p_data->this = devfreq; > > nb->notifier_call = devfreq_passive_notifier_call; > - ret = devm_devfreq_register_notifier(dev, parent, nb, > + ret = devfreq_register_notifier(parent, nb, > DEVFREQ_TRANSITION_NOTIFIER); > break; > case DEVFREQ_GOV_STOP: > - devm_devfreq_unregister_notifier(dev, parent, nb, > - DEVFREQ_TRANSITION_NOTIFIER); > + WARN_ON(devfreq_unregister_notifier(parent, nb, > + DEVFREQ_TRANSITION_NOTIFIER)); > break; > default: > break; > } > > Looks good to me. But, you have to add the following fixes tag and send it to stable mailing list to fix the bug. - Fixes: 996133119f57 ("PM / devfreq: Add new passive governor") Acked-by: Chanwoo Choi <cw00.choi@samsung.com> -- Best Regards, Chanwoo Choi Samsung Electronics ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-08-13 4:19 UTC | newest] Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <CGME20190808165416epcas5p24d8b4688357cd0985592e457c107d98b@epcas5p2.samsung.com> 2019-08-08 16:54 ` [PATCH] PM / devfreq: passive: Use non-devm notifiers Leonard Crestez 2019-08-13 4:23 ` Chanwoo Choi
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).