From: Saravana Kannan <saravanak@google.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>
Cc: Saravana Kannan <saravanak@google.com>,
Michael Walle <michael@walle.cc>,
Jon Hunter <jonathanh@nvidia.com>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Geert Uytterhoeven <geert@linux-m68k.org>,
Guenter Roeck <linux@roeck-us.net>,
kernel-team@android.com, linux-kernel@vger.kernel.org
Subject: [PATCH v1 1/3] driver core: Avoid pointless deferred probe attempts
Date: Tue, 2 Mar 2021 13:11:30 -0800 [thread overview]
Message-ID: <20210302211133.2244281-2-saravanak@google.com> (raw)
In-Reply-To: <20210302211133.2244281-1-saravanak@google.com>
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>
---
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 {
bool offline:1;
bool of_node_reused:1;
bool state_synced:1;
+ bool can_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
next prev parent reply other threads:[~2021-03-02 22:55 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-02 21:11 [PATCH v1 0/3] driver core: Set fw_devlink=on take II Saravana Kannan
2021-03-02 21:11 ` Saravana Kannan [this message]
2021-03-09 23:26 ` [PATCH v1 1/3] driver core: Avoid pointless deferred probe attempts Saravana Kannan
2021-03-23 13:58 ` Greg Kroah-Hartman
2021-03-02 21:11 ` [PATCH v1 2/3] driver core: Update device link status properly for device_bind_driver() Saravana Kannan
2021-03-12 16:59 ` Jon Hunter
2021-03-02 21:11 ` [PATCH v1 3/3] Revert "Revert "driver core: Set fw_devlink=on by default"" Saravana Kannan
[not found] ` <161670714806.3012082.14889556041667946511@swboyd.mtv.corp.google.com>
2021-03-25 21:59 ` Saravana Kannan
2021-04-26 20:51 ` Florian Fainelli
2021-04-26 21:33 ` Saravana Kannan
2021-04-26 21:47 ` Florian Fainelli
2021-04-27 7:05 ` Geert Uytterhoeven
2021-04-27 7:48 ` Cristian Marussi
[not found] ` <CA+-6iNz_kL0DnbRb0A=WSSLK0mnqw35S47TDXq5rhwXL_VWdPg@mail.gmail.com>
2021-04-27 14:11 ` Cristian Marussi
2021-04-27 15:10 ` Sudeep Holla
2021-04-27 16:24 ` Saravana Kannan
2021-04-27 16:47 ` Florian Fainelli
2021-04-27 21:05 ` Saravana Kannan
2021-04-28 8:40 ` Sudeep Holla
2021-04-27 16:24 ` Florian Fainelli
2021-04-27 16:28 ` Saravana Kannan
2021-04-27 16:42 ` Sudeep Holla
2021-04-27 16:39 ` Sudeep Holla
2021-04-27 16:50 ` Florian Fainelli
2021-04-27 17:10 ` Geert Uytterhoeven
2021-03-02 22:24 ` [PATCH v1 0/3] driver core: Set fw_devlink=on take II Michael Walle
2021-03-02 22:42 ` Saravana Kannan
2021-03-02 22:47 ` Saravana Kannan
2021-03-03 8:59 ` Michael Walle
2021-03-03 9:28 ` Saravana Kannan
2021-03-03 10:21 ` Michael Walle
2021-03-05 3:25 ` Saravana Kannan
2021-03-03 9:22 ` Geert Uytterhoeven
2021-03-03 9:24 ` Saravana Kannan
2021-03-03 10:02 ` Geert Uytterhoeven
2021-03-03 16:55 ` Saravana Kannan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210302211133.2244281-2-saravanak@google.com \
--to=saravanak@google.com \
--cc=geert@linux-m68k.org \
--cc=gregkh@linuxfoundation.org \
--cc=jonathanh@nvidia.com \
--cc=kernel-team@android.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=m.szyprowski@samsung.com \
--cc=michael@walle.cc \
--cc=rafael@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox