Skip to contentSkip to conversation

Account for uncorrectable failures in probing

PATCH Superseded Mario Limonciello 3 participants 12 messages Nov 3, 2017 – Nov 9, 2017 x86 platform drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Account for uncorrectable failures in probing

Pali raised some concerns around corner case scenarios that probing may fail on dell-wmi-descriptor causing dell-wmi and dell-smbios-wmi to be stuck in infinite deferred probing loops.

This patch series accounts for that corner case.

Changes since original submission:
- Add as second patch that catches potential NULL pointer
- Avoid potential race condition between driver init and calling check for if validation successful
Mario Limonciello (2):
platform/x86: dell-wmi-descriptor: check if memory was allocated platform/x86: dell-*wmi*: Relay failed initial probe to dependent
drivers

 drivers/platform/x86/dell-smbios-wmi.c     |  4 ++++
 drivers/platform/x86/dell-wmi-descriptor.c | 16 ++++++++++++++++
 drivers/platform/x86/dell-wmi-descriptor.h |  7 +++++++
 drivers/platform/x86/dell-wmi.c            |  5 +++++
 4 files changed, 32 insertions(+)
Signature · 1 line
2.14.1
#1 lore raw

PATCH 1/2 platform/x86: dell-wmi-descriptor: check if memory was allocated

devm_kzalloc will return NULL pointer if no memory was allocated. This should be checked. This problem also existed when the driver was dell-wmi.c.

---
 drivers/platform/x86/dell-wmi-descriptor.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/platform/x86/dell-wmi-descriptor.c +5 -0
index 3204c408e261..28ef5f37cfbf 100644
@@ -121,6 +121,11 @@ static int dell_wmi_descriptor_probe(struct wmi_device *wdev)
 	priv = devm_kzalloc(&wdev->dev, sizeof(struct descriptor_priv),
 	GFP_KERNEL);
 
+	if (!priv) {
+		ret = -ENOMEM;
+		goto out;
+	}
+
 	priv->interface_version = buffer[2];
 	priv->size = buffer[3];
 	ret = 0;
Signature · 1 line
2.14.1
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] platform/x86: dell-wmi-descriptor: check if memory was allocated

Quoted 5 lines · On Friday 03 November 2017 11:27:21 Mario Limonciello wrote:

devm_kzalloc will return NULL pointer if no memory was allocated. This should be checked. This problem also existed when the driver was dell-wmi.c.

Quoted 20 lines
---
 drivers/platform/x86/dell-wmi-descriptor.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/platform/x86/dell-wmi-descriptor.c +5 -0
index 3204c408e261..28ef5f37cfbf 100644
@@ -121,6 +121,11 @@ static int dell_wmi_descriptor_probe(struct wmi_device *wdev)
 	priv = devm_kzalloc(&wdev->dev, sizeof(struct descriptor_priv),
 	GFP_KERNEL);
 
+	if (!priv) {
+		ret = -ENOMEM;
+		goto out;
+	}
+
 	priv->interface_version = buffer[2];
 	priv->size = buffer[3];
 	ret = 0;
Signature · 2 lines
Pali Rohár
[email protected]
#3 lore raw

PATCH 2/2 platform/x86: dell-*wmi*: Relay failed initial probe to dependent drivers

In reply to Mario Limonciello

dell-wmi and dell-smbios-wmi are dependent upon dell-wmi-descriptor finishing probe successfully to probe themselves.

Currently if dell-wmi-descriptor fails probing in a non-recoverable way (such as invalid header) dell-wmi and dell-smbios-wmi will continue to try to redo probing due to deferred probing.

To solve this have the dependent drivers query the dell-wmi-descriptor driver whether the descriptor has been determined valid. The possible results are:
-EPROBE_DEFER: Descriptor not yet probed, dependent driver should wait
and use deferred probing
< 0: Descriptor probed, invalid. Dependent driver should return an
error.
0: Successful descriptor probe, dependent driver can continue

Successful descriptor probe still doesn't mean that the descriptor driver is necessarily bound at the time of initialization of dependent driver. Userspace can unbind the driver, so all methods used from driver should still be verified to return success values otherwise deferred probing be used.

---
 drivers/platform/x86/dell-smbios-wmi.c     |  4 ++++
 drivers/platform/x86/dell-wmi-descriptor.c | 11 +++++++++++
 drivers/platform/x86/dell-wmi-descriptor.h |  7 +++++++
 drivers/platform/x86/dell-wmi.c            |  5 +++++
 4 files changed, 27 insertions(+)
drivers/platform/x86/dell-smbios-wmi.c +4 -0
index 35c13815b24c..3fa53fa174b2 100644
@@ -151,6 +151,10 @@ static int dell_smbios_wmi_probe(struct wmi_device *wdev)
 	if (!wmi_has_guid(DELL_WMI_DESCRIPTOR_GUID))
 		return -ENODEV;
 
+	ret = dell_wmi_get_descriptor_valid();
+	if (ret)
+		return ret;
+
 	priv = devm_kzalloc(&wdev->dev, sizeof(struct wmi_smbios_priv),
 			    GFP_KERNEL);
 	if (!priv)
drivers/platform/x86/dell-wmi-descriptor.c +11 -0
index 28ef5f37cfbf..e7f4c3a7bfc4 100644
@@ -26,9 +26,16 @@ struct descriptor_priv {
 	u32 interface_version;
 	u32 size;
 };
+static int descriptor_valid = -EPROBE_DEFER;
 static LIST_HEAD(wmi_list);
 static DEFINE_MUTEX(list_mutex);
 
+int dell_wmi_get_descriptor_valid(void)
+{
+	return descriptor_valid;
+}
+EXPORT_SYMBOL_GPL(dell_wmi_get_descriptor_valid);
+
 bool dell_wmi_get_interface_version(u32 *version)
 {
 	struct descriptor_priv *priv;
@@ -91,6 +98,7 @@ static int dell_wmi_descriptor_probe(struct wmi_device *wdev)
 	if (obj->type != ACPI_TYPE_BUFFER) {
 		dev_err(&wdev->dev, "Dell descriptor has wrong type\n");
 		ret = -EINVAL;
+		descriptor_valid = ret;
 		goto out;
 	}
 
@@ -102,6 +110,7 @@ static int dell_wmi_descriptor_probe(struct wmi_device *wdev)
 			"Dell descriptor buffer has unexpected length (%d)\n",
 			obj->buffer.length);
 		ret = -EINVAL;
+		descriptor_valid = ret;
 		goto out;
 	}
 
@@ -111,8 +120,10 @@ static int dell_wmi_descriptor_probe(struct wmi_device *wdev)
 		dev_err(&wdev->dev, "Dell descriptor buffer has invalid signature (%8ph)\n",
 			buffer);
 		ret = -EINVAL;
+		descriptor_valid = ret;
 		goto out;
 	}
+	descriptor_valid = 0;
 
 	if (buffer[2] != 0 && buffer[2] != 1)
 		dev_warn(&wdev->dev, "Dell descriptor buffer has unknown version (%lu)\n",
drivers/platform/x86/dell-wmi-descriptor.h +7 -0
index 5f7b69c2c83a..776cddd5e135 100644
@@ -15,6 +15,13 @@
 
 #define DELL_WMI_DESCRIPTOR_GUID "8D9DDCBC-A997-11DA-B012-B622A1EF5492"
 
+/* possible return values:
+ *  -EPROBE_DEFER: probing for dell-wmi-descriptor not yet run
+ *  0: valid descriptor, successfully probed
+ *  < 0: invalid descriptor, don't probe dependent devices
+ */
+int dell_wmi_get_descriptor_valid(void);
+
 bool dell_wmi_get_interface_version(u32 *version);
 bool dell_wmi_get_size(u32 *size);
 
drivers/platform/x86/dell-wmi.c +5 -0
index 54321080a30d..bb7c1e681792 100644
@@ -655,10 +655,15 @@ static int dell_wmi_events_set_enabled(bool enable)
 static int dell_wmi_probe(struct wmi_device *wdev)
 {
 	struct dell_wmi_priv *priv;
+	int ret;
 
 	if (!wmi_has_guid(DELL_WMI_DESCRIPTOR_GUID))
 		return -ENODEV;
 
+	ret = dell_wmi_get_descriptor_valid();
+	if (ret)
+		return ret;
+
 	priv = devm_kzalloc(
 		&wdev->dev, sizeof(struct dell_wmi_priv), GFP_KERNEL);
 	if (!priv)
Signature · 1 line
2.14.1
#4 lore raw

Re: [PATCH 2/2] platform/x86: dell-*wmi*: Relay failed initial probe to dependent drivers

Quoted 16 lines · Mario Limonciello

dell-wmi and dell-smbios-wmi are dependent upon dell-wmi-descriptor finishing probe successfully to probe themselves.

Currently if dell-wmi-descriptor fails probing in a non-recoverable way (such as invalid header) dell-wmi and dell-smbios-wmi will continue to try to redo probing due to deferred probing.

To solve this have the dependent drivers query the dell-wmi-descriptor driver whether the descriptor has been determined valid. The possible results are:
-EPROBE_DEFER: Descriptor not yet probed, dependent driver should wait
and use deferred probing
< 0: Descriptor probed, invalid. Dependent driver should return an
error.
0: Successful descriptor probe, dependent driver can continue

Quoted 3 lines

Successful descriptor probe still doesn't mean that the descriptor driver is necessarily bound at the time of initialization of dependent driver. Userspace can unbind the driver, so all methods used from driver

Userspace shouldn't be able to remove the dell-wmi-descriptor driver if a dependent driver is loaded. It isn't clear to me in which scenario we encounter this problem ??

Quoted 2 lines

should still be verified to return success values otherwise deferred probing be used.

The part after "otherwise" is breaking my English parser...

Should this read: "Userspace can unbind the driver, so all methods used from the driver should still be verified to return successful values, falling back to deferred probing in case of failure." ??

drivers/platform/x86/dell-wmi-descriptor.h line 18

Quoted 9 lines
drivers/platform/x86/dell-wmi-descriptor.h +1 -0
index 5f7b69c2c83a..776cddd5e135 100644
@@ -15,6 +15,13 @@
 
 #define DELL_WMI_DESCRIPTOR_GUID "8D9DDCBC-A997-11DA-B012-B622A1EF5492"
 
+/* possible return values:

This should trigger a checkpatch error, but doesn't. Huh. For everything but "net", comment blocks should start with /* and not following text.

/*
* First line.
* Second line.
*/

A nit, and I can clean up if no changes are deemed necessary here.

Quoted 4 lines
drivers/platform/x86/dell-wmi-descriptor.h +4 -0
+ *  -EPROBE_DEFER: probing for dell-wmi-descriptor not yet run
+ *  0: valid descriptor, successfully probed
+ *  < 0: invalid descriptor, don't probe dependent devices
+ */
Signature · 2 lines
Darren Hart
VMware Open Source Technology Center
#5 lore raw

RE: [PATCH 2/2] platform/x86: dell-*wmi*: Relay failed initial probe to dependent drivers

Quoted 27 lines

-----Original Message-----
From: Darren Hart [mailto:[email protected]]
Sent: Friday, November 3, 2017 7:53 PM
To: Limonciello, Mario <[email protected]>
Cc: Andy Shevchenko <[email protected]>; LKML <linux- [email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH 2/2] platform/x86: dell-*wmi*: Relay failed initial probe to dependent drivers

Quoted 16 lines · Mario Limonciello

dell-wmi and dell-smbios-wmi are dependent upon dell-wmi-descriptor finishing probe successfully to probe themselves.

Currently if dell-wmi-descriptor fails probing in a non-recoverable way (such as invalid header) dell-wmi and dell-smbios-wmi will continue to try to redo probing due to deferred probing.

To solve this have the dependent drivers query the dell-wmi-descriptor driver whether the descriptor has been determined valid. The possible results are:
-EPROBE_DEFER: Descriptor not yet probed, dependent driver should wait
and use deferred probing
< 0: Descriptor probed, invalid. Dependent driver should return an
error.
0: Successful descriptor probe, dependent driver can continue

Quoted 7 lines
Quoted 3 lines

Successful descriptor probe still doesn't mean that the descriptor driver is necessarily bound at the time of initialization of dependent driver. Userspace can unbind the driver, so all methods used from driver

Userspace shouldn't be able to remove the dell-wmi-descriptor driver if a dependent driver is loaded. It isn't clear to me in which scenario we encounter this problem ??

Userspace can however unbind a bound GUID. When this happens getting the interface version and size will both fail.

Quoted 10 lines
Quoted 4 lines

should still be verified to return success values otherwise deferred probing be used.

The part after "otherwise" is breaking my English parser...

Should this read: "Userspace can unbind the driver, so all methods used from the driver should still be verified to return successful values, falling back to deferred probing in case of failure." ??

Yeah that's clearer and correct.

Quoted 8 lines

Review

Quoted 2 lines
(quoted diff) +0 -0

b/drivers/platform/x86/dell-wmi-descriptor.h

Quoted 5 lines

index 5f7b69c2c83a..776cddd5e135 100644

drivers/platform/x86/dell-wmi-descriptor.h +0 -0
@@ -15,6 +15,13 @@
 
Quoted 8 lines

drivers/platform/x86/dell-wmi-descriptor.h line 16

Quoted 1 line
drivers/platform/x86/dell-wmi-descriptor.h +0 -0
 #define DELL_WMI_DESCRIPTOR_GUID "8D9DDCBC-A997-11DA-B012-

B622A1EF5492"

drivers/platform/x86/dell-wmi-descriptor.h line 18

Quoted 2 lines
drivers/platform/x86/dell-wmi-descriptor.h +1 -0
+/* possible return values:

This should trigger a checkpatch error, but doesn't. Huh. For everything but "net", comment blocks should start with /* and not following text.

OK.

Quoted 15 lines

/*
* First line.
* Second line.
*/

A nit, and I can clean up if no changes are deemed necessary here.

drivers/platform/x86/dell-wmi-descriptor.h line 22

Quoted 4 lines
drivers/platform/x86/dell-wmi-descriptor.h +4 -0
+ *  -EPROBE_DEFER: probing for dell-wmi-descriptor not yet run
+ *  0: valid descriptor, successfully probed
+ *  < 0: invalid descriptor, don't probe dependent devices
+ */

--
Darren Hart
VMware Open Source Technology Center

#6 lore raw

Re: [PATCH 2/2] platform/x86: dell-*wmi*: Relay failed initial probe to dependent drivers

In reply to Mario Limonciello
Quoted 16 lines · On Friday 03 November 2017 11:27:22 Mario Limonciello wrote:

dell-wmi and dell-smbios-wmi are dependent upon dell-wmi-descriptor finishing probe successfully to probe themselves.

Currently if dell-wmi-descriptor fails probing in a non-recoverable way (such as invalid header) dell-wmi and dell-smbios-wmi will continue to try to redo probing due to deferred probing.

To solve this have the dependent drivers query the dell-wmi-descriptor driver whether the descriptor has been determined valid. The possible results are:
-EPROBE_DEFER: Descriptor not yet probed, dependent driver should wait
and use deferred probing
< 0: Descriptor probed, invalid. Dependent driver should return an
error.
0: Successful descriptor probe, dependent driver can continue

Quoted 5 lines

Successful descriptor probe still doesn't mean that the descriptor driver is necessarily bound at the time of initialization of dependent driver. Userspace can unbind the driver, so all methods used from driver should still be verified to return success values otherwise deferred probing be used.

Darren, Andy, any comments on this patch?

I think now it should work also those corner, but legit cases.

Quoted 94 lines
---
 drivers/platform/x86/dell-smbios-wmi.c     |  4 ++++
 drivers/platform/x86/dell-wmi-descriptor.c | 11 +++++++++++
 drivers/platform/x86/dell-wmi-descriptor.h |  7 +++++++
 drivers/platform/x86/dell-wmi.c            |  5 +++++
 4 files changed, 27 insertions(+)
drivers/platform/x86/dell-smbios-wmi.c +4 -0
index 35c13815b24c..3fa53fa174b2 100644
@@ -151,6 +151,10 @@ static int dell_smbios_wmi_probe(struct wmi_device *wdev)
 	if (!wmi_has_guid(DELL_WMI_DESCRIPTOR_GUID))
 		return -ENODEV;
 
+	ret = dell_wmi_get_descriptor_valid();
+	if (ret)
+		return ret;
+
 	priv = devm_kzalloc(&wdev->dev, sizeof(struct wmi_smbios_priv),
 			    GFP_KERNEL);
 	if (!priv)
drivers/platform/x86/dell-wmi-descriptor.c +11 -0
index 28ef5f37cfbf..e7f4c3a7bfc4 100644
@@ -26,9 +26,16 @@ struct descriptor_priv {
 	u32 interface_version;
 	u32 size;
 };
+static int descriptor_valid = -EPROBE_DEFER;
 static LIST_HEAD(wmi_list);
 static DEFINE_MUTEX(list_mutex);
 
+int dell_wmi_get_descriptor_valid(void)
+{
+	return descriptor_valid;
+}
+EXPORT_SYMBOL_GPL(dell_wmi_get_descriptor_valid);
+
 bool dell_wmi_get_interface_version(u32 *version)
 {
 	struct descriptor_priv *priv;
@@ -91,6 +98,7 @@ static int dell_wmi_descriptor_probe(struct wmi_device *wdev)
 	if (obj->type != ACPI_TYPE_BUFFER) {
 		dev_err(&wdev->dev, "Dell descriptor has wrong type\n");
 		ret = -EINVAL;
+		descriptor_valid = ret;
 		goto out;
 	}
 
@@ -102,6 +110,7 @@ static int dell_wmi_descriptor_probe(struct wmi_device *wdev)
 			"Dell descriptor buffer has unexpected length (%d)\n",
 			obj->buffer.length);
 		ret = -EINVAL;
+		descriptor_valid = ret;
 		goto out;
 	}
 
@@ -111,8 +120,10 @@ static int dell_wmi_descriptor_probe(struct wmi_device *wdev)
 		dev_err(&wdev->dev, "Dell descriptor buffer has invalid signature (%8ph)\n",
 			buffer);
 		ret = -EINVAL;
+		descriptor_valid = ret;
 		goto out;
 	}
+	descriptor_valid = 0;
 
 	if (buffer[2] != 0 && buffer[2] != 1)
 		dev_warn(&wdev->dev, "Dell descriptor buffer has unknown version (%lu)\n",
drivers/platform/x86/dell-wmi-descriptor.h +7 -0
index 5f7b69c2c83a..776cddd5e135 100644
@@ -15,6 +15,13 @@
 
 #define DELL_WMI_DESCRIPTOR_GUID "8D9DDCBC-A997-11DA-B012-B622A1EF5492"
 
+/* possible return values:
+ *  -EPROBE_DEFER: probing for dell-wmi-descriptor not yet run
+ *  0: valid descriptor, successfully probed
+ *  < 0: invalid descriptor, don't probe dependent devices
+ */
+int dell_wmi_get_descriptor_valid(void);
+
 bool dell_wmi_get_interface_version(u32 *version);
 bool dell_wmi_get_size(u32 *size);
 
drivers/platform/x86/dell-wmi.c +0 -0
index 54321080a30d..bb7c1e681792 100644

drivers/platform/x86/dell-wmi.c static int dell_wmi_events_set_enabled(bool enable) · line 661

Quoted 7 lines
drivers/platform/x86/dell-wmi.c +1 -0
@@ -655,10 +655,15 @@ static int dell_wmi_events_set_enabled(bool enable)
 static int dell_wmi_probe(struct wmi_device *wdev)
 {
 	struct dell_wmi_priv *priv;
+	int ret;
 
 	if (!wmi_has_guid(DELL_WMI_DESCRIPTOR_GUID))
 		return -ENODEV;

Just one suggestion, is above check still needed in dell-wmi.c code? I think that now it should be job of dell_wmi_get_descriptor_valid() function to fully validate if dell wmi descriptor driver is able to provide all needed information for dell-wmi driver.

Quoted 7 lines
drivers/platform/x86/dell-wmi.c +4 -0
+	ret = dell_wmi_get_descriptor_valid();
+	if (ret)
+		return ret;
+
 	priv = devm_kzalloc(
 		&wdev->dev, sizeof(struct dell_wmi_priv), GFP_KERNEL);
 	if (!priv)
Signature · 2 lines
Pali Rohár
[email protected]
#7 lore raw

RE: [PATCH 2/2] platform/x86: dell-*wmi*: Relay failed initial probe to dependent drivers

Quoted 145 lines

-----Original Message-----
From: Pali Rohár [mailto:[email protected]]
Sent: Thursday, November 9, 2017 10:03 AM
To: Limonciello, Mario <[email protected]>
Cc: [email protected]; Andy Shevchenko <[email protected]>; LKML <[email protected]>; [email protected]
Subject: Re: [PATCH 2/2] platform/x86: dell-*wmi*: Relay failed initial probe to dependent drivers

Quoted 16 lines · On Friday 03 November 2017 11:27:22 Mario Limonciello wrote:

dell-wmi and dell-smbios-wmi are dependent upon dell-wmi-descriptor finishing probe successfully to probe themselves.

Currently if dell-wmi-descriptor fails probing in a non-recoverable way (such as invalid header) dell-wmi and dell-smbios-wmi will continue to try to redo probing due to deferred probing.

To solve this have the dependent drivers query the dell-wmi-descriptor driver whether the descriptor has been determined valid. The possible results are:
-EPROBE_DEFER: Descriptor not yet probed, dependent driver should wait
and use deferred probing
< 0: Descriptor probed, invalid. Dependent driver should return an
error.
0: Successful descriptor probe, dependent driver can continue

Quoted 5 lines

Successful descriptor probe still doesn't mean that the descriptor driver is necessarily bound at the time of initialization of dependent driver. Userspace can unbind the driver, so all methods used from driver should still be verified to return success values otherwise deferred probing be used.

Darren, Andy, any comments on this patch?

I think now it should work also those corner, but legit cases.

drivers/platform/x86/dell-

Quoted 9 lines
---
 drivers/platform/x86/dell-smbios-wmi.c     |  4 ++++
 drivers/platform/x86/dell-wmi-descriptor.c | 11 +++++++++++
 drivers/platform/x86/dell-wmi-descriptor.h |  7 +++++++
 drivers/platform/x86/dell-wmi.c            |  5 +++++
 4 files changed, 27 insertions(+)
drivers/platform/x86/dell- renamed from drivers/platform/x86/dell-smbios-wmi.c +0 -0

smbios-wmi.c

drivers/platform/x86/dell-smbios-wmi.c static int dell_smbios_wmi_probe(struct wmi_device

Quoted 4 lines

index 35c13815b24c..3fa53fa174b2 100644

drivers/platform/x86/dell-smbios-wmi.c +0 -0
@@ -151,6 +151,10 @@ static int dell_smbios_wmi_probe(struct wmi_device

*wdev)

Review

Quoted 11 lines
drivers/platform/x86/dell-smbios-wmi.c +4 -0
 	if (!wmi_has_guid(DELL_WMI_DESCRIPTOR_GUID))
 		return -ENODEV;
 
+	ret = dell_wmi_get_descriptor_valid();
+	if (ret)
+		return ret;
+
 	priv = devm_kzalloc(&wdev->dev, sizeof(struct wmi_smbios_priv),
 			    GFP_KERNEL);
 	if (!priv)
(quoted diff) +0 -0

b/drivers/platform/x86/dell-wmi-descriptor.c

drivers/platform/x86/dell-wmi-descriptor.c static int dell_wmi_descriptor_probe(struct wmi_device

Quoted 21 lines

index 28ef5f37cfbf..e7f4c3a7bfc4 100644

drivers/platform/x86/dell-wmi-descriptor.c +7 -0
@@ -26,9 +26,16 @@ struct descriptor_priv {
 	u32 interface_version;
 	u32 size;
 };
+static int descriptor_valid = -EPROBE_DEFER;
 static LIST_HEAD(wmi_list);
 static DEFINE_MUTEX(list_mutex);
 
+int dell_wmi_get_descriptor_valid(void)
+{
+	return descriptor_valid;
+}
+EXPORT_SYMBOL_GPL(dell_wmi_get_descriptor_valid);
+
 bool dell_wmi_get_interface_version(u32 *version)
 {
 	struct descriptor_priv *priv;
@@ -91,6 +98,7 @@ static int dell_wmi_descriptor_probe(struct wmi_device

*wdev)

drivers/platform/x86/dell-wmi-descriptor.c static int dell_wmi_descriptor_probe(struct wmi_device

Quoted 8 lines
drivers/platform/x86/dell-wmi-descriptor.c +1 -0
 	if (obj->type != ACPI_TYPE_BUFFER) {
 		dev_err(&wdev->dev, "Dell descriptor has wrong type\n");
 		ret = -EINVAL;
+		descriptor_valid = ret;
 		goto out;
 	}
 
@@ -102,6 +110,7 @@ static int dell_wmi_descriptor_probe(struct wmi_device

*wdev)

drivers/platform/x86/dell-wmi-descriptor.c static int dell_wmi_descriptor_probe(struct wmi_device

Quoted 8 lines
drivers/platform/x86/dell-wmi-descriptor.c +1 -0
 			"Dell descriptor buffer has unexpected length (%d)\n",
 			obj->buffer.length);
 		ret = -EINVAL;
+		descriptor_valid = ret;
 		goto out;
 	}
 
@@ -111,8 +120,10 @@ static int dell_wmi_descriptor_probe(struct wmi_device

*wdev)

drivers/platform/x86/dell-wmi-descriptor.c static int dell_wmi_descriptor_probe(struct wmi_device · line 120

Quoted 1 line
drivers/platform/x86/dell-wmi-descriptor.c +0 -0
 		dev_err(&wdev->dev, "Dell descriptor buffer has invalid signature

(%8ph)\n",

drivers/platform/x86/dell-wmi-descriptor.c static int dell_wmi_descriptor_probe(struct wmi_device *wdev)

Quoted 9 lines
drivers/platform/x86/dell-wmi-descriptor.c +2 -0
 			buffer);
 		ret = -EINVAL;
+		descriptor_valid = ret;
 		goto out;
 	}
+	descriptor_valid = 0;
 
 	if (buffer[2] != 0 && buffer[2] != 1)
 		dev_warn(&wdev->dev, "Dell descriptor buffer has unknown

version (%lu)\n",

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/platform/x86/dell-wmi-descriptor.h

drivers/platform/x86/dell-wmi-descriptor.h line 16

Quoted 6 lines

index 5f7b69c2c83a..776cddd5e135 100644

drivers/platform/x86/dell-wmi-descriptor.h +0 -0
@@ -15,6 +15,13 @@
 
 #define DELL_WMI_DESCRIPTOR_GUID "8D9DDCBC-A997-11DA-B012-

B622A1EF5492"

Quoted 21 lines
drivers/platform/x86/dell-wmi-descriptor.h +7 -0
+/* possible return values:
+ *  -EPROBE_DEFER: probing for dell-wmi-descriptor not yet run
+ *  0: valid descriptor, successfully probed
+ *  < 0: invalid descriptor, don't probe dependent devices
+ */
+int dell_wmi_get_descriptor_valid(void);
+
 bool dell_wmi_get_interface_version(u32 *version);
 bool dell_wmi_get_size(u32 *size);
 
drivers/platform/x86/dell-wmi.c +1 -0
index 54321080a30d..bb7c1e681792 100644
@@ -655,10 +655,15 @@ static int dell_wmi_events_set_enabled(bool enable)
 static int dell_wmi_probe(struct wmi_device *wdev)
 {
 	struct dell_wmi_priv *priv;
+	int ret;
 
Quoted 8 lines

drivers/platform/x86/dell-wmi.c static int dell_wmi_events_set_enabled(bool enable) · line 661

Quoted 2 lines
drivers/platform/x86/dell-wmi.c +0 -0
 	if (!wmi_has_guid(DELL_WMI_DESCRIPTOR_GUID))
 		return -ENODEV;

Just one suggestion, is above check still needed in dell-wmi.c code? I think that now it should be job of dell_wmi_get_descriptor_valid() function to fully validate if dell wmi descriptor driver is able to provide all needed information for dell-wmi driver.

Yes, I believe it's still needed because if the GUID isn't on the bus the probe routine for dell-wmi-descriptor won't run and dell_wmi_get_descriptor_valid() will continually return -EPROBE_DEFER.

That's the exact problem this patch exists for (preventing infinite deferred probing).

Perhaps a "cleaner" solution is to have the init routine of dell-wmi-descriptor do this wmi_has_guid check and set the descriptor_valid variable to -ENODEV so that "dependent" drivers don't need to.

Quoted 11 lines

drivers/platform/x86/dell-wmi.c static int dell_wmi_events_set_enabled(bool enable) · line 669

Quoted 7 lines
drivers/platform/x86/dell-wmi.c +4 -0
+	ret = dell_wmi_get_descriptor_valid();
+	if (ret)
+		return ret;
+
 	priv = devm_kzalloc(
 		&wdev->dev, sizeof(struct dell_wmi_priv), GFP_KERNEL);
 	if (!priv)

--
Pali Rohár
[email protected]

#8 lore raw

Re: [PATCH 2/2] platform/x86: dell-*wmi*: Relay failed initial probe to dependent drivers

Quoted 158 lines · On Thursday 09 November 2017 16:13:52 [email protected] wrote:
Quoted 145 lines

-----Original Message-----
From: Pali Rohár [mailto:[email protected]]
Sent: Thursday, November 9, 2017 10:03 AM
To: Limonciello, Mario <[email protected]>
Cc: [email protected]; Andy Shevchenko <[email protected]>; LKML <[email protected]>; [email protected]
Subject: Re: [PATCH 2/2] platform/x86: dell-*wmi*: Relay failed initial probe to dependent drivers

Quoted 16 lines · On Friday 03 November 2017 11:27:22 Mario Limonciello wrote:

dell-wmi and dell-smbios-wmi are dependent upon dell-wmi-descriptor finishing probe successfully to probe themselves.

Currently if dell-wmi-descriptor fails probing in a non-recoverable way (such as invalid header) dell-wmi and dell-smbios-wmi will continue to try to redo probing due to deferred probing.

To solve this have the dependent drivers query the dell-wmi-descriptor driver whether the descriptor has been determined valid. The possible results are:
-EPROBE_DEFER: Descriptor not yet probed, dependent driver should wait
and use deferred probing
< 0: Descriptor probed, invalid. Dependent driver should return an
error.
0: Successful descriptor probe, dependent driver can continue

Quoted 5 lines

Successful descriptor probe still doesn't mean that the descriptor driver is necessarily bound at the time of initialization of dependent driver. Userspace can unbind the driver, so all methods used from driver should still be verified to return success values otherwise deferred probing be used.

Darren, Andy, any comments on this patch?

I think now it should work also those corner, but legit cases.

drivers/platform/x86/dell-

Quoted 9 lines
---
 drivers/platform/x86/dell-smbios-wmi.c     |  4 ++++
 drivers/platform/x86/dell-wmi-descriptor.c | 11 +++++++++++
 drivers/platform/x86/dell-wmi-descriptor.h |  7 +++++++
 drivers/platform/x86/dell-wmi.c            |  5 +++++
 4 files changed, 27 insertions(+)
drivers/platform/x86/dell- renamed from drivers/platform/x86/dell-smbios-wmi.c +0 -0

smbios-wmi.c

drivers/platform/x86/dell-smbios-wmi.c static int dell_smbios_wmi_probe(struct wmi_device

Quoted 4 lines

index 35c13815b24c..3fa53fa174b2 100644

drivers/platform/x86/dell-smbios-wmi.c +0 -0
@@ -151,6 +151,10 @@ static int dell_smbios_wmi_probe(struct wmi_device

*wdev)

Review

Quoted 11 lines
drivers/platform/x86/dell-smbios-wmi.c +4 -0
 	if (!wmi_has_guid(DELL_WMI_DESCRIPTOR_GUID))
 		return -ENODEV;
 
+	ret = dell_wmi_get_descriptor_valid();
+	if (ret)
+		return ret;
+
 	priv = devm_kzalloc(&wdev->dev, sizeof(struct wmi_smbios_priv),
 			    GFP_KERNEL);
 	if (!priv)
(quoted diff) +0 -0

b/drivers/platform/x86/dell-wmi-descriptor.c

drivers/platform/x86/dell-wmi-descriptor.c static int dell_wmi_descriptor_probe(struct wmi_device

Quoted 21 lines

index 28ef5f37cfbf..e7f4c3a7bfc4 100644

drivers/platform/x86/dell-wmi-descriptor.c +7 -0
@@ -26,9 +26,16 @@ struct descriptor_priv {
 	u32 interface_version;
 	u32 size;
 };
+static int descriptor_valid = -EPROBE_DEFER;
 static LIST_HEAD(wmi_list);
 static DEFINE_MUTEX(list_mutex);
 
+int dell_wmi_get_descriptor_valid(void)
+{
+	return descriptor_valid;
+}
+EXPORT_SYMBOL_GPL(dell_wmi_get_descriptor_valid);
+
 bool dell_wmi_get_interface_version(u32 *version)
 {
 	struct descriptor_priv *priv;
@@ -91,6 +98,7 @@ static int dell_wmi_descriptor_probe(struct wmi_device

*wdev)

drivers/platform/x86/dell-wmi-descriptor.c static int dell_wmi_descriptor_probe(struct wmi_device

Quoted 8 lines
drivers/platform/x86/dell-wmi-descriptor.c +1 -0
 	if (obj->type != ACPI_TYPE_BUFFER) {
 		dev_err(&wdev->dev, "Dell descriptor has wrong type\n");
 		ret = -EINVAL;
+		descriptor_valid = ret;
 		goto out;
 	}
 
@@ -102,6 +110,7 @@ static int dell_wmi_descriptor_probe(struct wmi_device

*wdev)

drivers/platform/x86/dell-wmi-descriptor.c static int dell_wmi_descriptor_probe(struct wmi_device

Quoted 8 lines
drivers/platform/x86/dell-wmi-descriptor.c +1 -0
 			"Dell descriptor buffer has unexpected length (%d)\n",
 			obj->buffer.length);
 		ret = -EINVAL;
+		descriptor_valid = ret;
 		goto out;
 	}
 
@@ -111,8 +120,10 @@ static int dell_wmi_descriptor_probe(struct wmi_device

*wdev)

drivers/platform/x86/dell-wmi-descriptor.c static int dell_wmi_descriptor_probe(struct wmi_device · line 120

Quoted 1 line
drivers/platform/x86/dell-wmi-descriptor.c +0 -0
 		dev_err(&wdev->dev, "Dell descriptor buffer has invalid signature

(%8ph)\n",

drivers/platform/x86/dell-wmi-descriptor.c static int dell_wmi_descriptor_probe(struct wmi_device *wdev)

Quoted 9 lines
drivers/platform/x86/dell-wmi-descriptor.c +2 -0
 			buffer);
 		ret = -EINVAL;
+		descriptor_valid = ret;
 		goto out;
 	}
+	descriptor_valid = 0;
 
 	if (buffer[2] != 0 && buffer[2] != 1)
 		dev_warn(&wdev->dev, "Dell descriptor buffer has unknown

version (%lu)\n",

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/platform/x86/dell-wmi-descriptor.h

drivers/platform/x86/dell-wmi-descriptor.h line 16

Quoted 6 lines

index 5f7b69c2c83a..776cddd5e135 100644

drivers/platform/x86/dell-wmi-descriptor.h +0 -0
@@ -15,6 +15,13 @@
 
 #define DELL_WMI_DESCRIPTOR_GUID "8D9DDCBC-A997-11DA-B012-

B622A1EF5492"

Quoted 21 lines
drivers/platform/x86/dell-wmi-descriptor.h +7 -0
+/* possible return values:
+ *  -EPROBE_DEFER: probing for dell-wmi-descriptor not yet run
+ *  0: valid descriptor, successfully probed
+ *  < 0: invalid descriptor, don't probe dependent devices
+ */
+int dell_wmi_get_descriptor_valid(void);
+
 bool dell_wmi_get_interface_version(u32 *version);
 bool dell_wmi_get_size(u32 *size);
 
drivers/platform/x86/dell-wmi.c +1 -0
index 54321080a30d..bb7c1e681792 100644
@@ -655,10 +655,15 @@ static int dell_wmi_events_set_enabled(bool enable)
 static int dell_wmi_probe(struct wmi_device *wdev)
 {
 	struct dell_wmi_priv *priv;
+	int ret;
 
Quoted 8 lines

drivers/platform/x86/dell-wmi.c static int dell_wmi_events_set_enabled(bool enable) · line 661

Quoted 2 lines
drivers/platform/x86/dell-wmi.c +0 -0
 	if (!wmi_has_guid(DELL_WMI_DESCRIPTOR_GUID))
 		return -ENODEV;

Just one suggestion, is above check still needed in dell-wmi.c code? I think that now it should be job of dell_wmi_get_descriptor_valid() function to fully validate if dell wmi descriptor driver is able to provide all needed information for dell-wmi driver.

Yes, I believe it's still needed because if the GUID isn't on the bus the probe routine for dell-wmi-descriptor won't run and dell_wmi_get_descriptor_valid() will continually return -EPROBE_DEFER.

Quoted 6 lines

That's the exact problem this patch exists for (preventing infinite deferred probing).

Perhaps a "cleaner" solution is to have the init routine of dell-wmi-descriptor do this wmi_has_guid check and set the descriptor_valid variable to -ENODEV so that "dependent" drivers don't need to.

I understand. But I mean, if function dell_wmi_get_descriptor_valid() should not do that check for DELL_WMI_DESCRIPTOR_GUID itself.

Because every driver which would use dell-wmi-descriptor needs to do that check.

Quoted 11 lines
Quoted 11 lines

drivers/platform/x86/dell-wmi.c static int dell_wmi_events_set_enabled(bool enable) · line 669

Quoted 7 lines
drivers/platform/x86/dell-wmi.c +4 -0
+	ret = dell_wmi_get_descriptor_valid();
+	if (ret)
+		return ret;
+
 	priv = devm_kzalloc(
 		&wdev->dev, sizeof(struct dell_wmi_priv), GFP_KERNEL);
 	if (!priv)

--
Pali Rohár
[email protected]

Signature · 2 lines
Pali Rohár
[email protected]
#9 lore raw

RE: [PATCH 2/2] platform/x86: dell-*wmi*: Relay failed initial probe to dependent drivers

Quoted 182 lines

-----Original Message-----
From: [email protected] [mailto:platform-driver-x86- [email protected]] On Behalf Of Pali Rohár
Sent: Thursday, November 9, 2017 11:29 AM
To: Limonciello, Mario <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]
Subject: Re: [PATCH 2/2] platform/x86: dell-*wmi*: Relay failed initial probe to dependent drivers

Quoted 44 lines · On Thursday 09 November 2017 16:13:52 [email protected] wrote:
Quoted 44 lines

-----Original Message-----
From: Pali Rohár [mailto:[email protected]]
Sent: Thursday, November 9, 2017 10:03 AM
To: Limonciello, Mario <[email protected]>
Cc: [email protected]; Andy Shevchenko <[email protected]>; LKML <[email protected]>; [email protected]
Subject: Re: [PATCH 2/2] platform/x86: dell-*wmi*: Relay failed initial probe to dependent drivers

Quoted 16 lines · On Friday 03 November 2017 11:27:22 Mario Limonciello wrote:

dell-wmi and dell-smbios-wmi are dependent upon dell-wmi-descriptor finishing probe successfully to probe themselves.

Currently if dell-wmi-descriptor fails probing in a non-recoverable way (such as invalid header) dell-wmi and dell-smbios-wmi will continue to try to redo probing due to deferred probing.

To solve this have the dependent drivers query the dell-wmi-descriptor driver whether the descriptor has been determined valid. The possible results are:
-EPROBE_DEFER: Descriptor not yet probed, dependent driver should wait
and use deferred probing
< 0: Descriptor probed, invalid. Dependent driver should return an
error.
0: Successful descriptor probe, dependent driver can continue

Quoted 5 lines

Successful descriptor probe still doesn't mean that the descriptor driver is necessarily bound at the time of initialization of dependent driver. Userspace can unbind the driver, so all methods used from driver should still be verified to return success values otherwise deferred probing be used.

Darren, Andy, any comments on this patch?

I think now it should work also those corner, but legit cases.

Quoted 8 lines
---
 drivers/platform/x86/dell-smbios-wmi.c     |  4 ++++
 drivers/platform/x86/dell-wmi-descriptor.c | 11 +++++++++++
 drivers/platform/x86/dell-wmi-descriptor.h |  7 +++++++
 drivers/platform/x86/dell-wmi.c            |  5 +++++
 4 files changed, 27 insertions(+)
Quoted 1 line
Quoted 1 line

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/platform/x86/dell-

Quoted 5 lines
Quoted 5 lines

smbios-wmi.c

drivers/platform/x86/dell-smbios-wmi.c static int dell_smbios_wmi_probe(struct

Quoted 4 lines

index 35c13815b24c..3fa53fa174b2 100644

drivers/platform/x86/dell-smbios-wmi.c +0 -0
@@ -151,6 +151,10 @@ static int dell_smbios_wmi_probe(struct

wmi_device

Quoted 35 lines
Quoted 35 lines

*wdev)

Review

Quoted 11 lines
drivers/platform/x86/dell-smbios-wmi.c +4 -0
 	if (!wmi_has_guid(DELL_WMI_DESCRIPTOR_GUID))
 		return -ENODEV;
 
+	ret = dell_wmi_get_descriptor_valid();
+	if (ret)
+		return ret;
+
 	priv = devm_kzalloc(&wdev->dev, sizeof(struct wmi_smbios_priv),
 			    GFP_KERNEL);
 	if (!priv)
(quoted diff) +0 -0

b/drivers/platform/x86/dell-wmi-descriptor.c

drivers/platform/x86/dell-wmi-descriptor.c static int dell_wmi_descriptor_probe(struct wmi_device

Quoted 21 lines

index 28ef5f37cfbf..e7f4c3a7bfc4 100644

drivers/platform/x86/dell-wmi-descriptor.c +7 -0
@@ -26,9 +26,16 @@ struct descriptor_priv {
 	u32 interface_version;
 	u32 size;
 };
+static int descriptor_valid = -EPROBE_DEFER;
 static LIST_HEAD(wmi_list);
 static DEFINE_MUTEX(list_mutex);
 
+int dell_wmi_get_descriptor_valid(void)
+{
+	return descriptor_valid;
+}
+EXPORT_SYMBOL_GPL(dell_wmi_get_descriptor_valid);
+
 bool dell_wmi_get_interface_version(u32 *version)
 {
 	struct descriptor_priv *priv;
@@ -91,6 +98,7 @@ static int dell_wmi_descriptor_probe(struct wmi_device

*wdev)

Quoted 8 lines
Quoted 8 lines

drivers/platform/x86/dell-wmi-descriptor.c static int dell_wmi_descriptor_probe(struct

Quoted 8 lines
drivers/platform/x86/dell-wmi-descriptor.c +1 -0
 	if (obj->type != ACPI_TYPE_BUFFER) {
 		dev_err(&wdev->dev, "Dell descriptor has wrong type\n");
 		ret = -EINVAL;
+		descriptor_valid = ret;
 		goto out;
 	}
 
@@ -102,6 +110,7 @@ static int dell_wmi_descriptor_probe(struct

wmi_device

Quoted 9 lines
Quoted 9 lines

*wdev)

drivers/platform/x86/dell-wmi-descriptor.c static int dell_wmi_descriptor_probe(struct

Quoted 8 lines
drivers/platform/x86/dell-wmi-descriptor.c +1 -0
 			"Dell descriptor buffer has unexpected length (%d)\n",
 			obj->buffer.length);
 		ret = -EINVAL;
+		descriptor_valid = ret;
 		goto out;
 	}
 
@@ -111,8 +120,10 @@ static int dell_wmi_descriptor_probe(struct

wmi_device

Quoted 33 lines
Quoted 33 lines

*wdev)

drivers/platform/x86/dell-wmi-descriptor.c static int dell_wmi_descriptor_probe(struct · line 120

Quoted 1 line
drivers/platform/x86/dell-wmi-descriptor.c +0 -0
 		dev_err(&wdev->dev, "Dell descriptor buffer has invalid signature

(%8ph)\n",

drivers/platform/x86/dell-wmi-descriptor.c static int dell_wmi_descriptor_probe(struct wmi_device *wdev)

Quoted 9 lines
drivers/platform/x86/dell-wmi-descriptor.c +2 -0
 			buffer);
 		ret = -EINVAL;
+		descriptor_valid = ret;
 		goto out;
 	}
+	descriptor_valid = 0;
 
 	if (buffer[2] != 0 && buffer[2] != 1)
 		dev_warn(&wdev->dev, "Dell descriptor buffer has unknown

version (%lu)\n",

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/platform/x86/dell-wmi-descriptor.h

drivers/platform/x86/dell-wmi-descriptor.h line 16

Quoted 6 lines

index 5f7b69c2c83a..776cddd5e135 100644

drivers/platform/x86/dell-wmi-descriptor.h +0 -0
@@ -15,6 +15,13 @@
 
 #define DELL_WMI_DESCRIPTOR_GUID "8D9DDCBC-A997-11DA-B012-

B622A1EF5492"

Quoted 11 lines
drivers/platform/x86/dell-wmi-descriptor.h +7 -0
+/* possible return values:
+ *  -EPROBE_DEFER: probing for dell-wmi-descriptor not yet run
+ *  0: valid descriptor, successfully probed
+ *  < 0: invalid descriptor, don't probe dependent devices
+ */
+int dell_wmi_get_descriptor_valid(void);
+
 bool dell_wmi_get_interface_version(u32 *version);
 bool dell_wmi_get_size(u32 *size);
 
Quoted 1 line
Quoted 1 line

drivers/platform/x86/dell-

Quoted 1 line
drivers/platform/x86/dell- renamed from drivers/platform/x86/dell-wmi.c +0 -0

wmi.c

Quoted 4 lines
Quoted 4 lines

drivers/platform/x86/dell-wmi.c static int dell_wmi_events_set_enabled(bool

Quoted 4 lines

index 54321080a30d..bb7c1e681792 100644

drivers/platform/x86/dell-wmi.c +0 -0
@@ -655,10 +655,15 @@ static int dell_wmi_events_set_enabled(bool

enable)

Quoted 18 lines
Quoted 5 lines
Quoted 5 lines
drivers/platform/x86/dell-wmi.c +1 -0
 static int dell_wmi_probe(struct wmi_device *wdev)
 {
 	struct dell_wmi_priv *priv;
+	int ret;
 
Quoted 8 lines

drivers/platform/x86/dell-wmi.c static int dell_wmi_events_set_enabled(bool · line 661

Quoted 2 lines
drivers/platform/x86/dell-wmi.c +0 -0
 	if (!wmi_has_guid(DELL_WMI_DESCRIPTOR_GUID))
 		return -ENODEV;

Just one suggestion, is above check still needed in dell-wmi.c code? I think that now it should be job of dell_wmi_get_descriptor_valid() function to fully validate if dell wmi descriptor driver is able to provide all needed information for dell-wmi driver.

Yes, I believe it's still needed because if the GUID isn't on the bus the probe routine for dell-wmi-descriptor won't run and dell_wmi_get_descriptor_valid() will continually return -EPROBE_DEFER.

Quoted 6 lines

That's the exact problem this patch exists for (preventing infinite deferred probing).

Perhaps a "cleaner" solution is to have the init routine of dell-wmi-descriptor do this wmi_has_guid check and set the descriptor_valid variable to -ENODEV so that "dependent" drivers don't need to.

Quoted 5 lines

I understand. But I mean, if function dell_wmi_get_descriptor_valid() should not do that check for DELL_WMI_DESCRIPTOR_GUID itself.

Because every driver which would use dell-wmi-descriptor needs to do that check.

I'll move the check to dell_wmi_descriptor_valid(). That actually does remove the need for even including the GUID #define in a header file. All use will be contained now directly in dell-wmi-descriptor.c.

Quoted 16 lines
Quoted 12 lines
Quoted 12 lines

drivers/platform/x86/dell-wmi.c static int dell_wmi_events_set_enabled(bool enable) · line 669

Quoted 8 lines
drivers/platform/x86/dell-wmi.c +4 -0
+	ret = dell_wmi_get_descriptor_valid();
+	if (ret)
+		return ret;
+
 	priv = devm_kzalloc(
 		&wdev->dev, sizeof(struct dell_wmi_priv), GFP_KERNEL);
 	if (!priv)

--
Pali Rohár
[email protected]

--
Pali Rohár
[email protected]

#10 lore raw

Re: [PATCH 2/2] platform/x86: dell-*wmi*: Relay failed initial probe to dependent drivers

Quoted 28 lines · On Thu, Nov 09, 2017 at 05:34:39PM +0000, [email protected] wrote:
Quoted 28 lines
Quoted 18 lines
Quoted 5 lines
Quoted 5 lines

static int dell_wmi_probe(struct wmi_device *wdev) {

drivers/platform/x86/dell-wmi.c +1 -0
 	struct dell_wmi_priv *priv;
+	int ret;
Quoted 8 lines

Review

Quoted 2 lines
(quoted diff) +0 -0
 	if (!wmi_has_guid(DELL_WMI_DESCRIPTOR_GUID))
 		return -ENODEV;

Just one suggestion, is above check still needed in dell-wmi.c code? I think that now it should be job of dell_wmi_get_descriptor_valid() function to fully validate if dell wmi descriptor driver is able to provide all needed information for dell-wmi driver.

Yes, I believe it's still needed because if the GUID isn't on the bus the probe routine for dell-wmi-descriptor won't run and dell_wmi_get_descriptor_valid() will continually return -EPROBE_DEFER.

Quoted 6 lines

That's the exact problem this patch exists for (preventing infinite deferred probing).

Perhaps a "cleaner" solution is to have the init routine of dell-wmi-descriptor do this wmi_has_guid check and set the descriptor_valid variable to -ENODEV so that "dependent" drivers don't need to.

I understand. But I mean, if function dell_wmi_get_descriptor_valid() should not do that check for DELL_WMI_DESCRIPTOR_GUID itself.

Quoted 6 lines
Quoted 2 lines

Because every driver which would use dell-wmi-descriptor needs to do that check.

I'll move the check to dell_wmi_descriptor_valid(). That actually does remove the need for even including the GUID #define in a header file. All use will be contained now directly in dell-wmi-descriptor.c.

This is a worthwhile improvement.

Signature · 2 lines
Darren Hart
VMware Open Source Technology Center
#11 lore raw
In reply to Mario Limonciello
Quoted 23 lines

-----Original Message-----
From: Limonciello, Mario
Sent: Friday, November 3, 2017 11:27 AM
To: [email protected]; Andy Shevchenko <[email protected]>
Cc: LKML <[email protected]>; [email protected]; [email protected]; Limonciello, Mario <[email protected]>
Subject: [PATCH 0/2] Account for uncorrectable failures in probing

Pali raised some concerns around corner case scenarios that probing may fail on dell-wmi-descriptor causing dell-wmi and dell-smbios-wmi to be stuck in infinite deferred probing loops.

This patch series accounts for that corner case.

Changes since original submission:
- Add as second patch that catches potential NULL pointer
- Avoid potential race condition between driver init and calling check for if validation successful
Mario Limonciello (2):
platform/x86: dell-wmi-descriptor: check if memory was allocated platform/x86: dell-*wmi*: Relay failed initial probe to dependent
drivers

Quoted 8 lines
 drivers/platform/x86/dell-smbios-wmi.c     |  4 ++++
 drivers/platform/x86/dell-wmi-descriptor.c | 16 ++++++++++++++++
 drivers/platform/x86/dell-wmi-descriptor.h |  7 +++++++
 drivers/platform/x86/dell-wmi.c            |  5 +++++
 4 files changed, 32 insertions(+)

--
2.14.1

Pali,

Did you have any thoughts on these two patches? I believe they should account for the concerns you raised regarding the corner cases with probing in my series.

The series is queued up in the platform-drivers-x86 testing branch and they are intended to be on top of that.

Thanks,