On Wed, Feb 6, 2019 at 8:47 AM Greg KH <gre...@linuxfoundation.org> wrote: > > On Tue, Feb 05, 2019 at 02:12:31PM -0500, Sven Van Asbroeck wrote: > > On Tue, Feb 5, 2019 at 1:43 PM Greg KH <gre...@linuxfoundation.org> wrote: > > > > > > > > > It really should happen when the device is removed (if it is a driver > > > that binds to a device.) > > > > Absolutely. That's why I'm advocating adding a devm_init_work(), > > which will take care of this automatically. > > > > But it's of course not universally applicable. Not all drivers use devm. > > Ick, no, watch out for devm() calls. Odds are this is _NOT_ what you > want to do for a device. Remember when devm calls get freed (hint, not > at driver unbind/unload, but at device structure removal.
??? We unwind devm on probe() failure and after remove() is called. The device can live on. > > > By creating a work queue, you are suddenly tying module code to a device > memory structure lifespan, both of which are totally independant. > > It's the same issue with the devm irq call, that has been nothing but a > nightmare as everyone gets it wrong. Try to learn from our past > mistakes please :) Yeah. But devm irq gave most trouble because we did not have enough devm APIs so we often ended up with mixed devm/non-devm usage and that is what was causing most of the issues. If we can switch everything to devm then devm irq is not that troublesome. I have 2+ drivers that currently use devm_add_action_or_reset() to install action canceling work, they could be switched to devm_init_work(). Thanks, -- Dmitry