Message ID | 20201104232356.4038506-15-saravanak@google.com (mailing list archive) |
---|---|
State | Changes Requested, archived |
Headers | show |
Series | [v1,01/18] Revert "driver core: Avoid deferred probe due to fw_devlink_pause/resume()" | expand |
On Thu, Nov 5, 2020 at 12:24 AM Saravana Kannan <saravanak@google.com> wrote: > > To check if a device is still waiting for its supplier devices to be > added, we used to check if the devices is in a global > waiting_for_suppliers list. Since the global list will be deleted in > subsequent patches, this patch stops using this check. My kind of educated guess is that you want to drop waiting_for_suppliers and that's why you want to use supplier links here. > > Instead, this patch uses a more device specific check. It checks if the > device's fwnode has any fwnode links that haven't been converted to > device links yet. > > Signed-off-by: Saravana Kannan <saravanak@google.com> > --- > drivers/base/core.c | 18 ++++++++---------- > 1 file changed, 8 insertions(+), 10 deletions(-) > > diff --git a/drivers/base/core.c b/drivers/base/core.c > index 4ae5f2885ac5..d51dd564add1 100644 > --- a/drivers/base/core.c > +++ b/drivers/base/core.c > @@ -51,6 +51,7 @@ static DEFINE_MUTEX(wfs_lock); > static LIST_HEAD(deferred_sync); > static unsigned int defer_sync_state_count = 1; > static DEFINE_MUTEX(fwnode_link_lock); > +static bool fw_devlink_is_permissive(void); > > /** > * fwnode_link_add - Create a link between two fwnode_handles. > @@ -994,13 +995,13 @@ int device_links_check_suppliers(struct device *dev) > * Device waiting for supplier to become available is not allowed to > * probe. > */ > - mutex_lock(&wfs_lock); > - if (!list_empty(&dev->links.needs_suppliers) && > - dev->links.need_for_probe) { > - mutex_unlock(&wfs_lock); > + mutex_lock(&fwnode_link_lock); > + if (dev->fwnode && !list_empty(&dev->fwnode->suppliers) && > + !fw_devlink_is_permissive()) { > + mutex_unlock(&fwnode_link_lock); > return -EPROBE_DEFER; > } > - mutex_unlock(&wfs_lock); > + mutex_unlock(&fwnode_link_lock); > > device_links_write_lock(); > > @@ -1166,10 +1167,7 @@ static ssize_t waiting_for_supplier_show(struct device *dev, > bool val; > > device_lock(dev); > - mutex_lock(&wfs_lock); > - val = !list_empty(&dev->links.needs_suppliers) > - && dev->links.need_for_probe; > - mutex_unlock(&wfs_lock); Why isn't the lock needed any more? Or maybe it wasn't needed previously too? > + val = !list_empty(&dev->fwnode->suppliers); > device_unlock(dev); > return sysfs_emit(buf, "%u\n", val); > } > @@ -2226,7 +2224,7 @@ static int device_add_attrs(struct device *dev) > goto err_remove_dev_groups; > } > > - if (fw_devlink_flags && !fw_devlink_is_permissive()) { > + if (fw_devlink_flags && !fw_devlink_is_permissive() && dev->fwnode) { And why is this change needed? > error = device_create_file(dev, &dev_attr_waiting_for_supplier); > if (error) > goto err_remove_dev_online; > -- > 2.29.1.341.ge80a0c044ae-goog >
On Mon, Nov 16, 2020 at 8:34 AM Rafael J. Wysocki <rafael@kernel.org> wrote: > > On Thu, Nov 5, 2020 at 12:24 AM Saravana Kannan <saravanak@google.com> wrote: > > > > To check if a device is still waiting for its supplier devices to be > > added, we used to check if the devices is in a global > > waiting_for_suppliers list. Since the global list will be deleted in > > subsequent patches, this patch stops using this check. > > My kind of educated guess is that you want to drop > waiting_for_suppliers and that's why you want to use supplier links > here. Yes, and a device would never be added waiting_for_suppliers list. > > > > Instead, this patch uses a more device specific check. It checks if the > > device's fwnode has any fwnode links that haven't been converted to > > device links yet. > > > > Signed-off-by: Saravana Kannan <saravanak@google.com> > > --- > > drivers/base/core.c | 18 ++++++++---------- > > 1 file changed, 8 insertions(+), 10 deletions(-) > > > > diff --git a/drivers/base/core.c b/drivers/base/core.c > > index 4ae5f2885ac5..d51dd564add1 100644 > > --- a/drivers/base/core.c > > +++ b/drivers/base/core.c > > @@ -51,6 +51,7 @@ static DEFINE_MUTEX(wfs_lock); > > static LIST_HEAD(deferred_sync); > > static unsigned int defer_sync_state_count = 1; > > static DEFINE_MUTEX(fwnode_link_lock); > > +static bool fw_devlink_is_permissive(void); > > > > /** > > * fwnode_link_add - Create a link between two fwnode_handles. > > @@ -994,13 +995,13 @@ int device_links_check_suppliers(struct device *dev) > > * Device waiting for supplier to become available is not allowed to > > * probe. > > */ > > - mutex_lock(&wfs_lock); > > - if (!list_empty(&dev->links.needs_suppliers) && > > - dev->links.need_for_probe) { > > - mutex_unlock(&wfs_lock); > > + mutex_lock(&fwnode_link_lock); > > + if (dev->fwnode && !list_empty(&dev->fwnode->suppliers) && > > + !fw_devlink_is_permissive()) { > > + mutex_unlock(&fwnode_link_lock); > > return -EPROBE_DEFER; > > } > > - mutex_unlock(&wfs_lock); > > + mutex_unlock(&fwnode_link_lock); > > > > device_links_write_lock(); > > > > @@ -1166,10 +1167,7 @@ static ssize_t waiting_for_supplier_show(struct device *dev, > > bool val; > > > > device_lock(dev); > > - mutex_lock(&wfs_lock); > > - val = !list_empty(&dev->links.needs_suppliers) > > - && dev->links.need_for_probe; > > - mutex_unlock(&wfs_lock); > > Why isn't the lock needed any more? > > Or maybe it wasn't needed previously too? Yeah, I sent a separate patch for dropping this lock [1]. But I didn't want to wait for that to land to write this series. The lock wasn't needed in the first place and it was causing a lockdep warning. > > > + val = !list_empty(&dev->fwnode->suppliers); > > device_unlock(dev); > > return sysfs_emit(buf, "%u\n", val); > > } > > @@ -2226,7 +2224,7 @@ static int device_add_attrs(struct device *dev) > > goto err_remove_dev_groups; > > } > > > > - if (fw_devlink_flags && !fw_devlink_is_permissive()) { > > + if (fw_devlink_flags && !fw_devlink_is_permissive() && dev->fwnode) { > > And why is this change needed? Because if a device doesn't have a fwnode, it can't ever be waiting on a supplier. Also, the "show" function dereferences dev->fwnode->suppliers. -Saravana [1] - https://lore.kernel.org/lkml/20201104205431.3795207-1-saravanak@google.com/ Ignore the 1/2 thing. There's only 1 relevant patch.
diff --git a/drivers/base/core.c b/drivers/base/core.c index 4ae5f2885ac5..d51dd564add1 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -51,6 +51,7 @@ static DEFINE_MUTEX(wfs_lock); static LIST_HEAD(deferred_sync); static unsigned int defer_sync_state_count = 1; static DEFINE_MUTEX(fwnode_link_lock); +static bool fw_devlink_is_permissive(void); /** * fwnode_link_add - Create a link between two fwnode_handles. @@ -994,13 +995,13 @@ int device_links_check_suppliers(struct device *dev) * Device waiting for supplier to become available is not allowed to * probe. */ - mutex_lock(&wfs_lock); - if (!list_empty(&dev->links.needs_suppliers) && - dev->links.need_for_probe) { - mutex_unlock(&wfs_lock); + mutex_lock(&fwnode_link_lock); + if (dev->fwnode && !list_empty(&dev->fwnode->suppliers) && + !fw_devlink_is_permissive()) { + mutex_unlock(&fwnode_link_lock); return -EPROBE_DEFER; } - mutex_unlock(&wfs_lock); + mutex_unlock(&fwnode_link_lock); device_links_write_lock(); @@ -1166,10 +1167,7 @@ static ssize_t waiting_for_supplier_show(struct device *dev, bool val; device_lock(dev); - mutex_lock(&wfs_lock); - val = !list_empty(&dev->links.needs_suppliers) - && dev->links.need_for_probe; - mutex_unlock(&wfs_lock); + val = !list_empty(&dev->fwnode->suppliers); device_unlock(dev); return sysfs_emit(buf, "%u\n", val); } @@ -2226,7 +2224,7 @@ static int device_add_attrs(struct device *dev) goto err_remove_dev_groups; } - if (fw_devlink_flags && !fw_devlink_is_permissive()) { + if (fw_devlink_flags && !fw_devlink_is_permissive() && dev->fwnode) { error = device_create_file(dev, &dev_attr_waiting_for_supplier); if (error) goto err_remove_dev_online;
To check if a device is still waiting for its supplier devices to be added, we used to check if the devices is in a global waiting_for_suppliers list. Since the global list will be deleted in subsequent patches, this patch stops using this check. Instead, this patch uses a more device specific check. It checks if the device's fwnode has any fwnode links that haven't been converted to device links yet. Signed-off-by: Saravana Kannan <saravanak@google.com> --- drivers/base/core.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)