Commit bbd0c1f6 authored by Borislav Petkov's avatar Borislav Petkov

amd64_edac: Cleanup the CPU PCI device reservation

Shorten code and clarify comments, return proper -E* values on error.
Signed-off-by: default avatarBorislav Petkov <borislav.petkov@amd.com>
parent 0092b20d
...@@ -2035,42 +2035,27 @@ void amd64_decode_bus_error(int node_id, struct mce *m, u32 nbcfg) ...@@ -2035,42 +2035,27 @@ void amd64_decode_bus_error(int node_id, struct mce *m, u32 nbcfg)
} }
/* /*
* Input: * Use pvt->dram_f2_ctl which contains the F2 CPU PCI device to get the related
* 1) struct amd64_pvt which contains pvt->dram_f2_ctl pointer * F1 (AddrMap) and F3 (Misc) devices. Return negative value on error.
* 2) AMD Family index value
*
* Ouput:
* Upon return of 0, the following filled in:
*
* struct pvt->addr_f1_ctl
* struct pvt->misc_f3_ctl
*
* Filled in with related device funcitions of 'dram_f2_ctl'
* These devices are "reserved" via the pci_get_device()
*
* Upon return of 1 (error status):
*
* Nothing reserved
*/ */
static int amd64_reserve_mc_sibling_devices(struct amd64_pvt *pvt, int mc_idx) static int amd64_reserve_mc_sibling_devices(struct amd64_pvt *pvt, u16 f1_id,
u16 f3_id)
{ {
const struct amd64_family_type *amd64_dev = &amd64_family_types[mc_idx];
/* Reserve the ADDRESS MAP Device */ /* Reserve the ADDRESS MAP Device */
pvt->addr_f1_ctl = pci_get_related_function(pvt->dram_f2_ctl->vendor, pvt->addr_f1_ctl = pci_get_related_function(pvt->dram_f2_ctl->vendor,
amd64_dev->addr_f1_ctl, f1_id,
pvt->dram_f2_ctl); pvt->dram_f2_ctl);
if (!pvt->addr_f1_ctl) { if (!pvt->addr_f1_ctl) {
amd64_printk(KERN_ERR, "error address map device not found: " amd64_printk(KERN_ERR, "error address map device not found: "
"vendor %x device 0x%x (broken BIOS?)\n", "vendor %x device 0x%x (broken BIOS?)\n",
PCI_VENDOR_ID_AMD, amd64_dev->addr_f1_ctl); PCI_VENDOR_ID_AMD, f1_id);
return 1; return -ENODEV;
} }
/* Reserve the MISC Device */ /* Reserve the MISC Device */
pvt->misc_f3_ctl = pci_get_related_function(pvt->dram_f2_ctl->vendor, pvt->misc_f3_ctl = pci_get_related_function(pvt->dram_f2_ctl->vendor,
amd64_dev->misc_f3_ctl, f3_id,
pvt->dram_f2_ctl); pvt->dram_f2_ctl);
if (!pvt->misc_f3_ctl) { if (!pvt->misc_f3_ctl) {
...@@ -2079,8 +2064,8 @@ static int amd64_reserve_mc_sibling_devices(struct amd64_pvt *pvt, int mc_idx) ...@@ -2079,8 +2064,8 @@ static int amd64_reserve_mc_sibling_devices(struct amd64_pvt *pvt, int mc_idx)
amd64_printk(KERN_ERR, "error miscellaneous device not found: " amd64_printk(KERN_ERR, "error miscellaneous device not found: "
"vendor %x device 0x%x (broken BIOS?)\n", "vendor %x device 0x%x (broken BIOS?)\n",
PCI_VENDOR_ID_AMD, amd64_dev->misc_f3_ctl); PCI_VENDOR_ID_AMD, f3_id);
return 1; return -ENODEV;
} }
debugf1(" Addr Map device PCI Bus ID:\t%s\n", debugf1(" Addr Map device PCI Bus ID:\t%s\n",
...@@ -2646,12 +2631,9 @@ static int amd64_probe_one_instance(struct pci_dev *dram_f2_ctl, ...@@ -2646,12 +2631,9 @@ static int amd64_probe_one_instance(struct pci_dev *dram_f2_ctl,
if (!fam_type) if (!fam_type)
goto err_free; goto err_free;
/*
* We have the dram_f2_ctl device as an argument, now go reserve its
* sibling devices from the PCI system.
*/
ret = -ENODEV; ret = -ENODEV;
err = amd64_reserve_mc_sibling_devices(pvt, mc_type_index); err = amd64_reserve_mc_sibling_devices(pvt, fam_type->addr_f1_ctl,
fam_type->misc_f3_ctl);
if (err) if (err)
goto err_free; goto err_free;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment