Blob Blame History Raw
From 7190450511e91143bf1e610c91d57e1c7899ffa7 Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Wed, 8 Jan 2020 15:59:05 +0100
Subject: [PATCH] drivers/base: implement dev_enable_async_probe()
Patch-Mainline: never, SLE15-SP2 specific
References: jsc#SLE-11117,bsc#1156954

Implement dev_enable_async_probe() to selectively enable asynchronous
probing for individual devices.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/base/base.h    |    1 +
 drivers/base/core.c    |   11 +++++++++++
 drivers/base/dd.c      |    6 +++++-
 include/linux/device.h |    1 +
 4 files changed, 18 insertions(+), 1 deletion(-)

--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -96,6 +96,7 @@ struct device_private {
 	char *deferred_probe_reason;
 	struct device *device;
 	u8 dead:1;
+	u8 async_probe_enabled:1;
 };
 #define to_device_private_parent(obj)	\
 	container_of(obj, struct device_private, knode_parent)
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -4831,3 +4831,14 @@ int device_match_any(struct device *dev,
 	return 1;
 }
 EXPORT_SYMBOL_GPL(device_match_any);
+
+void dev_enable_async_probe(struct device *dev, bool enabled)
+{
+	if (!dev->p) {
+		if (device_private_init(dev))
+			return;
+	}
+	if (dev->p)
+		dev->p->async_probe_enabled = enabled;
+}
+EXPORT_SYMBOL_GPL(dev_enable_async_probe);
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -890,6 +890,9 @@ static int __device_attach_driver(struct
 	async_allowed = driver_allows_async_probing(drv);
 
 	if (async_allowed)
+		async_allowed = dev->p->async_probe_enabled;
+
+	if (async_allowed)
 		data->have_async = true;
 
 	if (data->check_async && async_allowed != data->want_async)
@@ -1134,7 +1137,8 @@ static int __driver_attach(struct device
 		return 0;
 	} /* ret > 0 means positive match */
 
-	if (driver_allows_async_probing(drv)) {
+	if (dev->p && dev->p->async_probe_enabled &&
+	    driver_allows_async_probing(drv)) {
 		/*
 		 * Instead of probing the device synchronously we will
 		 * probe it asynchronously to allow for more parallelism.
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -837,6 +837,7 @@ int device_change_owner(struct device *d
 const char *device_get_devnode(struct device *dev, umode_t *mode, kuid_t *uid,
 			       kgid_t *gid, const char **tmp);
 int device_is_dependent(struct device *dev, void *target);
+void dev_enable_async_probe(struct device *dev, bool enabled);
 
 static inline bool device_supports_offline(struct device *dev)
 {