linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] platform/x86: dell-smbios-wmi: Disable userspace interface if missing hotfix
@ 2017-11-17  4:13 Mario Limonciello
  2017-11-17 20:39 ` Darren Hart
  0 siblings, 1 reply; 4+ messages in thread
From: Mario Limonciello @ 2017-11-17  4:13 UTC (permalink / raw)
  To: dvhart, Andy Shevchenko; +Cc: LKML, platform-driver-x86, Mario Limonciello

The Dell SMBIOS WMI interface will fail for some more complex calls unless
a WMI hotfix has been included.  Most platforms have this fix available in
a maintenance BIOS release.  In the case the driver is loaded on a
platform without this fix, disable the userspace interface.

A hotfix indicator is present in the dell-wmi-descriptor that represents
whether or not more complex calls will work properly.

"Simple" calls such as those used by dell-laptop and dell-wmi will continue
to work properly so dell-smbios-wmi should not be blocked from binding and
being used as the dell-smbios dispatcher.

Suggested-by: Girish Prakash <girish.prakash@dell.com>
Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
---
 drivers/platform/x86/dell-smbios-wmi.c     | 13 +++++++++++++
 drivers/platform/x86/dell-wmi-descriptor.c | 26 ++++++++++++++++++++++++--
 drivers/platform/x86/dell-wmi-descriptor.h |  1 +
 3 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/dell-smbios-wmi.c b/drivers/platform/x86/dell-smbios-wmi.c
index 8ad11ef..044a104 100644
--- a/drivers/platform/x86/dell-smbios-wmi.c
+++ b/drivers/platform/x86/dell-smbios-wmi.c
@@ -147,7 +147,10 @@ static long dell_smbios_wmi_filter(struct wmi_device *wdev, unsigned int cmd,
 
 static int dell_smbios_wmi_probe(struct wmi_device *wdev)
 {
+	struct wmi_driver *wdriver =
+		container_of(wdev->dev.driver, struct wmi_driver, driver);
 	struct wmi_smbios_priv *priv;
+	u32 hotfix;
 	int count;
 	int ret;
 
@@ -167,6 +170,16 @@ static int dell_smbios_wmi_probe(struct wmi_device *wdev)
 	if (!dell_wmi_get_size(&priv->req_buf_size))
 		return -EPROBE_DEFER;
 
+	/* some SMBIOS calls fail unless BIOS contains hotfix */
+	if (!dell_wmi_get_hotfix(&hotfix))
+		return -EPROBE_DEFER;
+	if (!hotfix) {
+		dev_warn(&wdev->dev,
+			"WMI SMBIOS userspace interface not supported(%u), try upgrading to a newer BIOS\n",
+			hotfix);
+		wdriver->filter_callback = NULL;
+	}
+
 	/* add in the length object we will use internally with ioctl */
 	priv->req_buf_size += sizeof(u64);
 	ret = set_required_buffer_size(wdev, priv->req_buf_size);
diff --git a/drivers/platform/x86/dell-wmi-descriptor.c b/drivers/platform/x86/dell-wmi-descriptor.c
index e7f4c3a..5083ce0 100644
--- a/drivers/platform/x86/dell-wmi-descriptor.c
+++ b/drivers/platform/x86/dell-wmi-descriptor.c
@@ -25,6 +25,7 @@ struct descriptor_priv {
 	struct list_head list;
 	u32 interface_version;
 	u32 size;
+	u32 hotfix;
 };
 static int descriptor_valid = -EPROBE_DEFER;
 static LIST_HEAD(wmi_list);
@@ -72,6 +73,24 @@ bool dell_wmi_get_size(u32 *size)
 }
 EXPORT_SYMBOL_GPL(dell_wmi_get_size);
 
+bool dell_wmi_get_hotfix(u32 *hotfix)
+{
+	struct descriptor_priv *priv;
+	bool ret = false;
+
+	mutex_lock(&list_mutex);
+	priv = list_first_entry_or_null(&wmi_list,
+					struct descriptor_priv,
+					list);
+	if (priv) {
+		*hotfix = priv->hotfix;
+		ret = true;
+	}
+	mutex_unlock(&list_mutex);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(dell_wmi_get_hotfix);
+
 /*
  * Descriptor buffer is 128 byte long and contains:
  *
@@ -80,6 +99,7 @@ EXPORT_SYMBOL_GPL(dell_wmi_get_size);
  * Object Signature          4       4    " WMI"
  * WMI Interface Version     8       4    <version>
  * WMI buffer length        12       4    <length>
+ * WMI hotfix number        16       4    <hotfix>
  */
 static int dell_wmi_descriptor_probe(struct wmi_device *wdev)
 {
@@ -139,15 +159,17 @@ static int dell_wmi_descriptor_probe(struct wmi_device *wdev)
 
 	priv->interface_version = buffer[2];
 	priv->size = buffer[3];
+	priv->hotfix = buffer[4];
 	ret = 0;
 	dev_set_drvdata(&wdev->dev, priv);
 	mutex_lock(&list_mutex);
 	list_add_tail(&priv->list, &wmi_list);
 	mutex_unlock(&list_mutex);
 
-	dev_dbg(&wdev->dev, "Detected Dell WMI interface version %lu and buffer size %lu\n",
+	dev_dbg(&wdev->dev, "Detected Dell WMI interface version %lu, buffer size %lu, hotfix %lu\n",
 		(unsigned long) priv->interface_version,
-		(unsigned long) priv->size);
+		(unsigned long) priv->size,
+		(unsigned long) priv->hotfix);
 
 out:
 	kfree(obj);
diff --git a/drivers/platform/x86/dell-wmi-descriptor.h b/drivers/platform/x86/dell-wmi-descriptor.h
index 776cddd..217b833 100644
--- a/drivers/platform/x86/dell-wmi-descriptor.h
+++ b/drivers/platform/x86/dell-wmi-descriptor.h
@@ -24,5 +24,6 @@ int dell_wmi_get_descriptor_valid(void);
 
 bool dell_wmi_get_interface_version(u32 *version);
 bool dell_wmi_get_size(u32 *size);
+bool dell_wmi_get_hotfix(u32 *hotfix);
 
 #endif
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] platform/x86: dell-smbios-wmi: Disable userspace interface if missing hotfix
  2017-11-17  4:13 [PATCH v2] platform/x86: dell-smbios-wmi: Disable userspace interface if missing hotfix Mario Limonciello
@ 2017-11-17 20:39 ` Darren Hart
  2017-11-20 16:03   ` Mario.Limonciello
  0 siblings, 1 reply; 4+ messages in thread
From: Darren Hart @ 2017-11-17 20:39 UTC (permalink / raw)
  To: Mario Limonciello; +Cc: Andy Shevchenko, LKML, platform-driver-x86

On Thu, Nov 16, 2017 at 10:13:12PM -0600, Mario Limonciello wrote:
> The Dell SMBIOS WMI interface will fail for some more complex calls unless
> a WMI hotfix has been included.  Most platforms have this fix available in
> a maintenance BIOS release.  In the case the driver is loaded on a
> platform without this fix, disable the userspace interface.
> 
> A hotfix indicator is present in the dell-wmi-descriptor that represents
> whether or not more complex calls will work properly.
> 
> "Simple" calls such as those used by dell-laptop and dell-wmi will continue
> to work properly so dell-smbios-wmi should not be blocked from binding and
> being used as the dell-smbios dispatcher.
> 
> Suggested-by: Girish Prakash <girish.prakash@dell.com>
> Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>

Queued up, thanks Mario.
-- 
Darren Hart
VMware Open Source Technology Center

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH v2] platform/x86: dell-smbios-wmi: Disable userspace interface if missing hotfix
  2017-11-17 20:39 ` Darren Hart
@ 2017-11-20 16:03   ` Mario.Limonciello
  2017-11-20 20:37     ` Darren Hart
  0 siblings, 1 reply; 4+ messages in thread
From: Mario.Limonciello @ 2017-11-20 16:03 UTC (permalink / raw)
  To: dvhart; +Cc: andy.shevchenko, linux-kernel, platform-driver-x86

> -----Original Message-----
> From: Darren Hart [mailto:dvhart@infradead.org]
> Sent: Friday, November 17, 2017 2:39 PM
> To: Limonciello, Mario <Mario_Limonciello@Dell.com>
> Cc: Andy Shevchenko <andy.shevchenko@gmail.com>; LKML <linux-
> kernel@vger.kernel.org>; platform-driver-x86@vger.kernel.org
> Subject: Re: [PATCH v2] platform/x86: dell-smbios-wmi: Disable userspace
> interface if missing hotfix
> 
> On Thu, Nov 16, 2017 at 10:13:12PM -0600, Mario Limonciello wrote:
> > The Dell SMBIOS WMI interface will fail for some more complex calls unless
> > a WMI hotfix has been included.  Most platforms have this fix available in
> > a maintenance BIOS release.  In the case the driver is loaded on a
> > platform without this fix, disable the userspace interface.
> >
> > A hotfix indicator is present in the dell-wmi-descriptor that represents
> > whether or not more complex calls will work properly.
> >
> > "Simple" calls such as those used by dell-laptop and dell-wmi will continue
> > to work properly so dell-smbios-wmi should not be blocked from binding and
> > being used as the dell-smbios dispatcher.
> >
> > Suggested-by: Girish Prakash <girish.prakash@dell.com>
> > Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
> 
> Queued up, thanks Mario.

Darren, even though this came after the merge windows opened considering this 
restricts the SMBIOS interface from some platform/firmware combinations it 
shouldn't be offered, do you think this can be included with a future 4.15 
RCx PR so it can land with the rest of the series rather than targeted for 4.16?

I'd hate to get stuck in a situation that an interface deemed "broken" gets offered
to people it shouldn't.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] platform/x86: dell-smbios-wmi: Disable userspace interface if missing hotfix
  2017-11-20 16:03   ` Mario.Limonciello
@ 2017-11-20 20:37     ` Darren Hart
  0 siblings, 0 replies; 4+ messages in thread
From: Darren Hart @ 2017-11-20 20:37 UTC (permalink / raw)
  To: Mario.Limonciello; +Cc: andy.shevchenko, linux-kernel, platform-driver-x86

On Mon, Nov 20, 2017 at 04:03:53PM +0000, Mario.Limonciello@dell.com wrote:
> > -----Original Message-----
> > From: Darren Hart [mailto:dvhart@infradead.org]
> > Sent: Friday, November 17, 2017 2:39 PM
> > To: Limonciello, Mario <Mario_Limonciello@Dell.com>
> > Cc: Andy Shevchenko <andy.shevchenko@gmail.com>; LKML <linux-
> > kernel@vger.kernel.org>; platform-driver-x86@vger.kernel.org
> > Subject: Re: [PATCH v2] platform/x86: dell-smbios-wmi: Disable userspace
> > interface if missing hotfix
> > 
> > On Thu, Nov 16, 2017 at 10:13:12PM -0600, Mario Limonciello wrote:
> > > The Dell SMBIOS WMI interface will fail for some more complex calls unless
> > > a WMI hotfix has been included.  Most platforms have this fix available in
> > > a maintenance BIOS release.  In the case the driver is loaded on a
> > > platform without this fix, disable the userspace interface.
> > >
> > > A hotfix indicator is present in the dell-wmi-descriptor that represents
> > > whether or not more complex calls will work properly.
> > >
> > > "Simple" calls such as those used by dell-laptop and dell-wmi will continue
> > > to work properly so dell-smbios-wmi should not be blocked from binding and
> > > being used as the dell-smbios dispatcher.
> > >
> > > Suggested-by: Girish Prakash <girish.prakash@dell.com>
> > > Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
> > 
> > Queued up, thanks Mario.
> 
> Darren, even though this came after the merge windows opened considering this 
> restricts the SMBIOS interface from some platform/firmware combinations it 
> shouldn't be offered, do you think this can be included with a future 4.15 
> RCx PR so it can land with the rest of the series rather than targeted for 4.16?

This will make 4.15.

> 
> I'd hate to get stuck in a situation that an interface deemed "broken" gets offered
> to people it shouldn't.
> 

Agreed.

-- 
Darren Hart
VMware Open Source Technology Center

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-11-20 20:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-17  4:13 [PATCH v2] platform/x86: dell-smbios-wmi: Disable userspace interface if missing hotfix Mario Limonciello
2017-11-17 20:39 ` Darren Hart
2017-11-20 16:03   ` Mario.Limonciello
2017-11-20 20:37     ` Darren Hart

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).