Re: [PATCH v1 1/3] driver core: Avoid pointless deferred probe attempts
On Tue, Mar 09, 2021 at 03:26:05PM -0800, Saravana Kannan wrote: > On Tue, Mar 2, 2021 at 1:11 PM Saravana Kannan wrote: > > > > There's no point in adding a device to the deferred probe list if we > > know for sure that it doesn't have a matching driver. So, check if a > > device can match with a driver before adding it to the deferred probe > > list. > > > > Signed-off-by: Saravana Kannan > > Rafael/Greg, > > Any concerns with this specific patch? Do you see any bugs? I'm asking > because some of the other improvements I'm working on depend on this > flag. So I want to make sure this can land before I take my work in > progress too far. Looks fine, now queuing up, thanks. greg k-h
Re: [PATCH v1 1/3] driver core: Avoid pointless deferred probe attempts
On Tue, Mar 2, 2021 at 1:11 PM Saravana Kannan wrote: > > There's no point in adding a device to the deferred probe list if we > know for sure that it doesn't have a matching driver. So, check if a > device can match with a driver before adding it to the deferred probe > list. > > Signed-off-by: Saravana Kannan Rafael/Greg, Any concerns with this specific patch? Do you see any bugs? I'm asking because some of the other improvements I'm working on depend on this flag. So I want to make sure this can land before I take my work in progress too far. -Saravana > --- > drivers/base/dd.c | 6 ++ > include/linux/device.h | 4 > 2 files changed, 10 insertions(+) > > diff --git a/drivers/base/dd.c b/drivers/base/dd.c > index 9179825ff646..f18963f42e21 100644 > --- a/drivers/base/dd.c > +++ b/drivers/base/dd.c > @@ -123,6 +123,9 @@ static DECLARE_WORK(deferred_probe_work, > deferred_probe_work_func); > > void driver_deferred_probe_add(struct device *dev) > { > + if (!dev->can_match) > + return; > + > mutex_lock(&deferred_probe_mutex); > if (list_empty(&dev->p->deferred_probe)) { > dev_dbg(dev, "Added to deferred list\n"); > @@ -726,6 +729,7 @@ static int driver_probe_device(struct device_driver *drv, > struct device *dev) > if (!device_is_registered(dev)) > return -ENODEV; > > + dev->can_match = true; > pr_debug("bus: '%s': %s: matched device %s with driver %s\n", > drv->bus->name, __func__, dev_name(dev), drv->name); > > @@ -829,6 +833,7 @@ static int __device_attach_driver(struct device_driver > *drv, void *_data) > return 0; > } else if (ret == -EPROBE_DEFER) { > dev_dbg(dev, "Device match requests probe deferral\n"); > + dev->can_match = true; > driver_deferred_probe_add(dev); > } else if (ret < 0) { > dev_dbg(dev, "Bus failed to match device: %d\n", ret); > @@ -1064,6 +1069,7 @@ static int __driver_attach(struct device *dev, void > *data) > return 0; > } else if (ret == -EPROBE_DEFER) { > dev_dbg(dev, "Device match requests probe deferral\n"); > + dev->can_match = true; > driver_deferred_probe_add(dev); > } else if (ret < 0) { > dev_dbg(dev, "Bus failed to match device: %d\n", ret); > diff --git a/include/linux/device.h b/include/linux/device.h > index ba660731bd25..569932d282c0 100644 > --- a/include/linux/device.h > +++ b/include/linux/device.h > @@ -439,6 +439,9 @@ struct dev_links_info { > * @state_synced: The hardware state of this device has been synced to match > * the software state of this device by calling the driver/bus > * sync_state() callback. > + * @can_match: The device has matched with a driver at least once or it is in > + * a bus (like AMBA) which can't check for matching drivers until > + * other devices probe successfully. > * @dma_coherent: this particular device is dma coherent, even if the > * architecture supports non-coherent devices. > * @dma_ops_bypass: If set to %true then the dma_ops are bypassed for the > @@ -545,6 +548,7 @@ struct device { > booloffline:1; > boolof_node_reused:1; > boolstate_synced:1; > + boolcan_match:1; > #if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \ > defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \ > defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL) > -- > 2.30.1.766.gb4fecdf3b7-goog >
[PATCH v1 1/3] driver core: Avoid pointless deferred probe attempts
There's no point in adding a device to the deferred probe list if we know for sure that it doesn't have a matching driver. So, check if a device can match with a driver before adding it to the deferred probe list. Signed-off-by: Saravana Kannan --- drivers/base/dd.c | 6 ++ include/linux/device.h | 4 2 files changed, 10 insertions(+) diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 9179825ff646..f18963f42e21 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -123,6 +123,9 @@ static DECLARE_WORK(deferred_probe_work, deferred_probe_work_func); void driver_deferred_probe_add(struct device *dev) { + if (!dev->can_match) + return; + mutex_lock(&deferred_probe_mutex); if (list_empty(&dev->p->deferred_probe)) { dev_dbg(dev, "Added to deferred list\n"); @@ -726,6 +729,7 @@ static int driver_probe_device(struct device_driver *drv, struct device *dev) if (!device_is_registered(dev)) return -ENODEV; + dev->can_match = true; pr_debug("bus: '%s': %s: matched device %s with driver %s\n", drv->bus->name, __func__, dev_name(dev), drv->name); @@ -829,6 +833,7 @@ static int __device_attach_driver(struct device_driver *drv, void *_data) return 0; } else if (ret == -EPROBE_DEFER) { dev_dbg(dev, "Device match requests probe deferral\n"); + dev->can_match = true; driver_deferred_probe_add(dev); } else if (ret < 0) { dev_dbg(dev, "Bus failed to match device: %d\n", ret); @@ -1064,6 +1069,7 @@ static int __driver_attach(struct device *dev, void *data) return 0; } else if (ret == -EPROBE_DEFER) { dev_dbg(dev, "Device match requests probe deferral\n"); + dev->can_match = true; driver_deferred_probe_add(dev); } else if (ret < 0) { dev_dbg(dev, "Bus failed to match device: %d\n", ret); diff --git a/include/linux/device.h b/include/linux/device.h index ba660731bd25..569932d282c0 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -439,6 +439,9 @@ struct dev_links_info { * @state_synced: The hardware state of this device has been synced to match * the software state of this device by calling the driver/bus * sync_state() callback. + * @can_match: The device has matched with a driver at least once or it is in + * a bus (like AMBA) which can't check for matching drivers until + * other devices probe successfully. * @dma_coherent: this particular device is dma coherent, even if the * architecture supports non-coherent devices. * @dma_ops_bypass: If set to %true then the dma_ops are bypassed for the @@ -545,6 +548,7 @@ struct device { booloffline:1; boolof_node_reused:1; boolstate_synced:1; + boolcan_match:1; #if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \ defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \ defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL) -- 2.30.1.766.gb4fecdf3b7-goog