diff mbox

[Precise,SRU] mei: add mei_quirk_probe function

Message ID 1345812056-3980-1-git-send-email-tim.gardner@canonical.com
State New
Headers show

Commit Message

Tim Gardner Aug. 24, 2012, 12:40 p.m. UTC
BugLink: http://bugs.launchpad.net/bugs/1041164

The main purpose of this function is to exclude ME devices
without support for MEI/HECI interface from binding

Currently affected systems are C600/X79 based servers
that expose PCI device even though it doesn't supported ME Interface.
MEI driver accessing such nonfunctional device can corrupt
the system.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(back ported from commit a2f6985332d2564e443d9d889ce70f39b3293d09)

Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
---
 drivers/staging/mei/main.c |   27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

Comments

Herton Ronaldo Krzesinski Aug. 24, 2012, 1:27 p.m. UTC | #1

Colin Ian King Aug. 24, 2012, 1:33 p.m. UTC | #2
On 24/08/12 13:40, Tim Gardner wrote:
> BugLink: http://bugs.launchpad.net/bugs/1041164
>
> The main purpose of this function is to exclude ME devices
> without support for MEI/HECI interface from binding
>
> Currently affected systems are C600/X79 based servers
> that expose PCI device even though it doesn't supported ME Interface.
> MEI driver accessing such nonfunctional device can corrupt
> the system.
>
> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> (back ported from commit a2f6985332d2564e443d9d889ce70f39b3293d09)
>
> Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
> ---
>   drivers/staging/mei/main.c |   27 +++++++++++++++++++++++++++
>   1 file changed, 27 insertions(+)
>
> diff --git a/drivers/staging/mei/main.c b/drivers/staging/mei/main.c
> index eb05c36..44ed7a8 100644
> --- a/drivers/staging/mei/main.c
> +++ b/drivers/staging/mei/main.c
> @@ -106,6 +106,27 @@ MODULE_DEVICE_TABLE(pci, mei_pci_tbl);
>   static DEFINE_MUTEX(mei_mutex);
>
>   /**
> + * mei_quirk_probe - probe for devices that doesn't valid ME interface
> + * @pdev: PCI device structure
> + * @ent: entry into pci_device_table
> + *
> + * returns true if ME Interface is valid, false otherwise
> + */
> +static bool __devinit mei_quirk_probe(struct pci_dev *pdev,
> +				const struct pci_device_id *ent)
> +{
> +	u32 reg;
> +	if (ent->device == MEI_DEV_ID_PBG_1) {
> +		pci_read_config_dword(pdev, 0x48, &reg);
> +		/* make sure that bit 9 is up and bit 10 is down */
> +		if ((reg & 0x600) == 0x200) {
> +			dev_info(&pdev->dev, "Device doesn't have valid ME Interface\n");
> +			return false;
> +		}
> +	}
> +	return true;
> +}
> +/**
>    * mei_probe - Device Initialization Routine
>    *
>    * @pdev: PCI device structure
> @@ -120,6 +141,12 @@ static int __devinit mei_probe(struct pci_dev *pdev,
>   	int err;
>
>   	mutex_lock(&mei_mutex);
> +
> +	if (!mei_quirk_probe(pdev, ent)) {
> +		err = -ENODEV;
> +		goto end;
> +	}
> +
>   	if (mei_device) {
>   		err = -EEXIST;
>   		goto end;
>
Tim Gardner Aug. 24, 2012, 6:39 p.m. UTC | #3

diff mbox

Patch

diff --git a/drivers/staging/mei/main.c b/drivers/staging/mei/main.c
index eb05c36..44ed7a8 100644
--- a/drivers/staging/mei/main.c
+++ b/drivers/staging/mei/main.c
@@ -106,6 +106,27 @@  MODULE_DEVICE_TABLE(pci, mei_pci_tbl);
 static DEFINE_MUTEX(mei_mutex);
 
 /**
+ * mei_quirk_probe - probe for devices that doesn't valid ME interface
+ * @pdev: PCI device structure
+ * @ent: entry into pci_device_table
+ *
+ * returns true if ME Interface is valid, false otherwise
+ */
+static bool __devinit mei_quirk_probe(struct pci_dev *pdev,
+				const struct pci_device_id *ent)
+{
+	u32 reg;
+	if (ent->device == MEI_DEV_ID_PBG_1) {
+		pci_read_config_dword(pdev, 0x48, &reg);
+		/* make sure that bit 9 is up and bit 10 is down */
+		if ((reg & 0x600) == 0x200) {
+			dev_info(&pdev->dev, "Device doesn't have valid ME Interface\n");
+			return false;
+		}
+	}
+	return true;
+}
+/**
  * mei_probe - Device Initialization Routine
  *
  * @pdev: PCI device structure
@@ -120,6 +141,12 @@  static int __devinit mei_probe(struct pci_dev *pdev,
 	int err;
 
 	mutex_lock(&mei_mutex);
+
+	if (!mei_quirk_probe(pdev, ent)) {
+		err = -ENODEV;
+		goto end;
+	}
+
 	if (mei_device) {
 		err = -EEXIST;
 		goto end;