i5100_edac: probe for device 19 function 0
authorNiklas Söderlund <niklas.soderlund@ericsson.com>
Wed, 8 Aug 2012 15:30:56 +0000 (12:30 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Thu, 21 Feb 2013 14:06:32 +0000 (11:06 -0300)
Probe and store the device handle for the device 19 function 0 during
driver initialization. The device is used during fault injection.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ericsson.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/edac/i5100_edac.c
include/linux/pci_ids.h

index d6955b2cc99fa47bc9ac665fa93eb5f59cafc88e..33c5c8e663f2111c9ca6c921ddba2ad422e1aa52 100644 (file)
@@ -338,6 +338,7 @@ struct i5100_priv {
        unsigned ranksperchan;  /* number of ranks per channel */
 
        struct pci_dev *mc;     /* device 16 func 1 */
+       struct pci_dev *einj;   /* device 19 func 0 */
        struct pci_dev *ch0mm;  /* device 21 func 0 */
        struct pci_dev *ch1mm;  /* device 22 func 0 */
 
@@ -869,7 +870,7 @@ static int i5100_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
        struct mem_ctl_info *mci;
        struct edac_mc_layer layers[2];
        struct i5100_priv *priv;
-       struct pci_dev *ch0mm, *ch1mm;
+       struct pci_dev *ch0mm, *ch1mm, *einj;
        int ret = 0;
        u32 dw;
        int ranksperch;
@@ -941,6 +942,22 @@ static int i5100_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
                goto bail_disable_ch1;
        }
 
+
+       /* device 19, func 0, Error injection */
+       einj = pci_get_device_func(PCI_VENDOR_ID_INTEL,
+                                   PCI_DEVICE_ID_INTEL_5100_19, 0);
+       if (!einj) {
+               ret = -ENODEV;
+               goto bail_einj;
+       }
+
+       rc = pci_enable_device(einj);
+       if (rc < 0) {
+               ret = rc;
+               goto bail_disable_einj;
+       }
+
+
        mci->pdev = &pdev->dev;
 
        priv = mci->pvt_info;
@@ -948,6 +965,7 @@ static int i5100_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
        priv->mc = pdev;
        priv->ch0mm = ch0mm;
        priv->ch1mm = ch1mm;
+       priv->einj = einj;
 
        INIT_DELAYED_WORK(&(priv->i5100_scrubbing), i5100_refresh_scrubbing);
 
@@ -999,6 +1017,12 @@ bail_scrub:
        cancel_delayed_work_sync(&(priv->i5100_scrubbing));
        edac_mc_free(mci);
 
+bail_disable_einj:
+       pci_disable_device(einj);
+
+bail_einj:
+       pci_dev_put(einj);
+
 bail_disable_ch1:
        pci_disable_device(ch1mm);
 
@@ -1036,8 +1060,10 @@ static void i5100_remove_one(struct pci_dev *pdev)
        pci_disable_device(pdev);
        pci_disable_device(priv->ch0mm);
        pci_disable_device(priv->ch1mm);
+       pci_disable_device(priv->einj);
        pci_dev_put(priv->ch0mm);
        pci_dev_put(priv->ch1mm);
+       pci_dev_put(priv->einj);
 
        edac_mc_free(mci);
 }
index 0eb65796bcb9af7f5876c300608e7caebdfe6297..d0d1e801e3509505c97459047b4087442f993559 100644 (file)
 #define PCI_DEVICE_ID_INTEL_JAKETOWN_UBOX      0x3ce0
 #define PCI_DEVICE_ID_INTEL_IOAT_SNB   0x402f
 #define PCI_DEVICE_ID_INTEL_5100_16    0x65f0
+#define PCI_DEVICE_ID_INTEL_5100_19    0x65f3
 #define PCI_DEVICE_ID_INTEL_5100_21    0x65f5
 #define PCI_DEVICE_ID_INTEL_5100_22    0x65f6
 #define PCI_DEVICE_ID_INTEL_5400_ERR   0x4030