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
@@ -84,6 +84,7 @@ struct device_private {
struct device_driver *async_driver;
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
@@ -3554,3 +3554,14 @@ int device_match_acpi_dev(struct device
return ACPI_COMPANION(dev) == adev;
}
EXPORT_SYMBOL(device_match_acpi_dev);
+
+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
@@ -823,6 +823,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)
@@ -1055,7 +1058,8 @@ static int __driver_attach(struct device
return ret;
} /* 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
@@ -1469,6 +1469,7 @@ extern int device_move(struct device *de
extern const char *device_get_devnode(struct device *dev,
umode_t *mode, kuid_t *uid, kgid_t *gid,
const char **tmp);
+extern void dev_enable_async_probe(struct device *dev, bool enabled);
static inline bool device_supports_offline(struct device *dev)
{