[PATCH] drivers/base: use a worker for sysfs unbind

Rafael J. Wysocki rafael at kernel.org
Thu Dec 13 11:05:36 UTC 2018


On Thu, Dec 13, 2018 at 11:23 AM Rafael J. Wysocki <rafael at kernel.org> wrote:
>
> On Thu, Dec 13, 2018 at 10:58 AM Daniel Vetter <daniel at ffwll.ch> wrote:

[cut]

> >
> > - Most of these issues are never visible in normal usage, since normally
> >   driver bind/unbind is done from a kthread or model_load/unload, neither
> >   of which is running in the context of that kernfs mutex kernfs_fop_write
> >   holds. That's why I think the task work is the best solution, since it
> >   changes the locking context of the unbind sysfs to match the locking
> >   context of module unload and hotunplug.
>
> I think that using a task work here makes sense.  There is a drawback,
> which is that the original sysfs write will not wait for the driver to
> actually be released before returning to user space AFAICS, but that
> probably isn't a big deal.
>
> Also please note that the patch changes the code flow slightly,
> because passing a non-NULL parent pointer to
> device_release_driver_internal() potentially has side effects, but
> that should not be a big deal either.
>
> > Unfortunately that trick doesn't work for the bind sysfs file, since that way we can't thread the errno value back to userspace.
>
> Right.  That is unless we wait for the operation to complete and check
> the error left behind by it.  That should be doable, but somewhat
> complicated.

That said I'm not really sure if propagating the error to user space
in this case should be expected.  The interface could be defined as
asynchronous to begin with a separate way for user space to check the
status if necessary.  Changing that now may not be practical, though.


More information about the dri-devel mailing list