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 <saravanak@google.com> Link: https://lore.kernel.org/r/20210302211133.2244281-2-saravanak@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
01085e24ff
commit
f2db85b64f
@@ -122,6 +122,9 @@ static DECLARE_WORK(deferred_probe_work, deferred_probe_work_func);
|
|||||||
|
|
||||||
void driver_deferred_probe_add(struct device *dev)
|
void driver_deferred_probe_add(struct device *dev)
|
||||||
{
|
{
|
||||||
|
if (!dev->can_match)
|
||||||
|
return;
|
||||||
|
|
||||||
mutex_lock(&deferred_probe_mutex);
|
mutex_lock(&deferred_probe_mutex);
|
||||||
if (list_empty(&dev->p->deferred_probe)) {
|
if (list_empty(&dev->p->deferred_probe)) {
|
||||||
dev_dbg(dev, "Added to deferred list\n");
|
dev_dbg(dev, "Added to deferred list\n");
|
||||||
@@ -725,6 +728,7 @@ static int driver_probe_device(struct device_driver *drv, struct device *dev)
|
|||||||
if (!device_is_registered(dev))
|
if (!device_is_registered(dev))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
|
dev->can_match = true;
|
||||||
pr_debug("bus: '%s': %s: matched device %s with driver %s\n",
|
pr_debug("bus: '%s': %s: matched device %s with driver %s\n",
|
||||||
drv->bus->name, __func__, dev_name(dev), drv->name);
|
drv->bus->name, __func__, dev_name(dev), drv->name);
|
||||||
|
|
||||||
@@ -828,6 +832,7 @@ static int __device_attach_driver(struct device_driver *drv, void *_data)
|
|||||||
return 0;
|
return 0;
|
||||||
} else if (ret == -EPROBE_DEFER) {
|
} else if (ret == -EPROBE_DEFER) {
|
||||||
dev_dbg(dev, "Device match requests probe deferral\n");
|
dev_dbg(dev, "Device match requests probe deferral\n");
|
||||||
|
dev->can_match = true;
|
||||||
driver_deferred_probe_add(dev);
|
driver_deferred_probe_add(dev);
|
||||||
} else if (ret < 0) {
|
} else if (ret < 0) {
|
||||||
dev_dbg(dev, "Bus failed to match device: %d\n", ret);
|
dev_dbg(dev, "Bus failed to match device: %d\n", ret);
|
||||||
@@ -1063,6 +1068,7 @@ static int __driver_attach(struct device *dev, void *data)
|
|||||||
return 0;
|
return 0;
|
||||||
} else if (ret == -EPROBE_DEFER) {
|
} else if (ret == -EPROBE_DEFER) {
|
||||||
dev_dbg(dev, "Device match requests probe deferral\n");
|
dev_dbg(dev, "Device match requests probe deferral\n");
|
||||||
|
dev->can_match = true;
|
||||||
driver_deferred_probe_add(dev);
|
driver_deferred_probe_add(dev);
|
||||||
} else if (ret < 0) {
|
} else if (ret < 0) {
|
||||||
dev_dbg(dev, "Bus failed to match device: %d\n", ret);
|
dev_dbg(dev, "Bus failed to match device: %d\n", ret);
|
||||||
|
|||||||
@@ -439,6 +439,9 @@ struct dev_links_info {
|
|||||||
* @state_synced: The hardware state of this device has been synced to match
|
* @state_synced: The hardware state of this device has been synced to match
|
||||||
* the software state of this device by calling the driver/bus
|
* the software state of this device by calling the driver/bus
|
||||||
* sync_state() callback.
|
* 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
|
* @dma_coherent: this particular device is dma coherent, even if the
|
||||||
* architecture supports non-coherent devices.
|
* architecture supports non-coherent devices.
|
||||||
* @dma_ops_bypass: If set to %true then the dma_ops are bypassed for the
|
* @dma_ops_bypass: If set to %true then the dma_ops are bypassed for the
|
||||||
@@ -545,6 +548,7 @@ struct device {
|
|||||||
bool offline:1;
|
bool offline:1;
|
||||||
bool of_node_reused:1;
|
bool of_node_reused:1;
|
||||||
bool state_synced:1;
|
bool state_synced:1;
|
||||||
|
bool can_match:1;
|
||||||
#if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \
|
#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) || \
|
||||||
defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL)
|
defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL)
|
||||||
|
|||||||
Reference in New Issue
Block a user