mbox series

[V3,0/3] driver core: Add ability to delete device links of unregistered devices

Message ID 20210710103819.12532-1-adrian.hunter@intel.com
Headers show
Series driver core: Add ability to delete device links of unregistered devices | expand

Message

Adrian Hunter July 10, 2021, 10:38 a.m. UTC
Hi

There is an issue with the SCSI UFS driver when the optional
BOOT well-known LUN fails to probe, which is not a fatal error.
The issue is that the device and its "managed" device link do not
then get deleted.  The device because the device link has a
reference to it.  The device link because it can only be deleted
by device_del(), but device_add() was never called, so device_del()
never will be either.

Since V2, these patches fix the issue by amending device link removal to
accept removal of a link with an unregistered consumer device, as suggested
by Rafael.


Changes in V3:

    driver core: Prevent warning when removing a device link from unregistered consumer
	New patch split from "driver core: Add ability to delete device
	links of unregistered devices" except first chunk from that patch
	dropped as unnecessary

    driver core: Add ability to delete device links of unregistered devices
	Move warning fix to separate patch.


Changes in V2:

    Take approach suggested by Rafael


Adrian Hunter (3):
      driver core: Prevent warning when removing a device link from unregistered consumer
      driver core: Add ability to delete device links of unregistered devices
      scsi: ufshcd: Fix device links when BOOT WLUN fails to probe

 drivers/base/core.c       |  8 ++++++--
 drivers/scsi/ufs/ufshcd.c | 23 +++++++++++++++++++++--
 2 files changed, 27 insertions(+), 4 deletions(-)


Regards
Adrian

Comments

Rafael J. Wysocki July 14, 2021, 6:21 p.m. UTC | #1
On Sat, Jul 10, 2021 at 5:19 PM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> On Sat, Jul 10, 2021 at 01:38:17PM +0300, Adrian Hunter wrote:
> > sysfs_remove_link() causes a warning if the parent directory does not
> > exist. That can happen if the device link consumer has not been registered.
> > So do not attempt sysfs_remove_link() in that case.
> >
> > Fixes: 287905e68dd29 ("driver core: Expose device link details in sysfs")
> > Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> > ---
> >  drivers/base/core.c | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
>
> No Cc: stable for this?  Why not?

AFAICS that would be

Cc: 5.9+ <stable@vger.kernel.org> # 5.9+
Rafael J. Wysocki July 14, 2021, 6:22 p.m. UTC | #2
On Sat, Jul 10, 2021 at 12:38 PM Adrian Hunter <adrian.hunter@intel.com> wrote:
>
> sysfs_remove_link() causes a warning if the parent directory does not
> exist. That can happen if the device link consumer has not been registered.
> So do not attempt sysfs_remove_link() in that case.
>
> Fixes: 287905e68dd29 ("driver core: Expose device link details in sysfs")
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>

Reviewed-by: Rafael J. Wysocki <rafael@kernel.org>

> ---
>  drivers/base/core.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index ea5b85354526..2de8f7d8cf54 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -575,8 +575,10 @@ static void devlink_remove_symlinks(struct device *dev,
>                 return;
>         }
>
> -       snprintf(buf, len, "supplier:%s:%s", dev_bus_name(sup), dev_name(sup));
> -       sysfs_remove_link(&con->kobj, buf);
> +       if (device_is_registered(con)) {
> +               snprintf(buf, len, "supplier:%s:%s", dev_bus_name(sup), dev_name(sup));
> +               sysfs_remove_link(&con->kobj, buf);
> +       }
>         snprintf(buf, len, "consumer:%s:%s", dev_bus_name(con), dev_name(con));
>         sysfs_remove_link(&sup->kobj, buf);
>         kfree(buf);
> --
> 2.17.1
>