Skip to content

Commit

Permalink
i5100_edac: probe for device 19 function 0
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Niklas Söderlund authored and Mauro Carvalho Chehab committed Feb 21, 2013
1 parent e710047 commit 52608ba
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
28 changes: 27 additions & 1 deletion drivers/edac/i5100_edac.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -941,13 +942,30 @@ 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;
priv->ranksperchan = ranksperch;
priv->mc = pdev;
priv->ch0mm = ch0mm;
priv->ch1mm = ch1mm;
priv->einj = einj;

INIT_DELAYED_WORK(&(priv->i5100_scrubbing), i5100_refresh_scrubbing);

Expand Down Expand Up @@ -999,6 +1017,12 @@ static int i5100_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
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);

Expand Down Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions include/linux/pci_ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -2776,6 +2776,7 @@
#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
Expand Down

0 comments on commit 52608ba

Please sign in to comment.