aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/edac/amd64_edac.c
diff options
context:
space:
mode:
authorBorislav Petkov <borislav.petkov@amd.com>2010-10-01 13:27:58 -0400
committerBorislav Petkov <borislav.petkov@amd.com>2011-01-07 05:33:52 -0500
commitbbd0c1f675d7d64fc02393d4985a069be5037b54 (patch)
treedea760f017356a6b8da787c42333aa712e81cbb7 /drivers/edac/amd64_edac.c
parent0092b20d4cf3de243b5c82b410ee02644cec2707 (diff)
amd64_edac: Cleanup the CPU PCI device reservation
Shorten code and clarify comments, return proper -E* values on error. Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
Diffstat (limited to 'drivers/edac/amd64_edac.c')
-rw-r--r--drivers/edac/amd64_edac.c42
1 files changed, 12 insertions, 30 deletions
diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
index 0a9edf8cdaf3..437f5b67ab3c 100644
--- a/drivers/edac/amd64_edac.c
+++ b/drivers/edac/amd64_edac.c
@@ -2035,42 +2035,27 @@ void amd64_decode_bus_error(int node_id, struct mce *m, u32 nbcfg)
2035} 2035}
2036 2036
2037/* 2037/*
2038 * Input: 2038 * Use pvt->dram_f2_ctl which contains the F2 CPU PCI device to get the related
2039 * 1) struct amd64_pvt which contains pvt->dram_f2_ctl pointer 2039 * F1 (AddrMap) and F3 (Misc) devices. Return negative value on error.
2040 * 2) AMD Family index value
2041 *
2042 * Ouput:
2043 * Upon return of 0, the following filled in:
2044 *
2045 * struct pvt->addr_f1_ctl
2046 * struct pvt->misc_f3_ctl
2047 *
2048 * Filled in with related device funcitions of 'dram_f2_ctl'
2049 * These devices are "reserved" via the pci_get_device()
2050 *
2051 * Upon return of 1 (error status):
2052 *
2053 * Nothing reserved
2054 */ 2040 */
2055static int amd64_reserve_mc_sibling_devices(struct amd64_pvt *pvt, int mc_idx) 2041static int amd64_reserve_mc_sibling_devices(struct amd64_pvt *pvt, u16 f1_id,
2042 u16 f3_id)
2056{ 2043{
2057 const struct amd64_family_type *amd64_dev = &amd64_family_types[mc_idx];
2058
2059 /* Reserve the ADDRESS MAP Device */ 2044 /* Reserve the ADDRESS MAP Device */
2060 pvt->addr_f1_ctl = pci_get_related_function(pvt->dram_f2_ctl->vendor, 2045 pvt->addr_f1_ctl = pci_get_related_function(pvt->dram_f2_ctl->vendor,
2061 amd64_dev->addr_f1_ctl, 2046 f1_id,
2062 pvt->dram_f2_ctl); 2047 pvt->dram_f2_ctl);
2063 2048
2064 if (!pvt->addr_f1_ctl) { 2049 if (!pvt->addr_f1_ctl) {
2065 amd64_printk(KERN_ERR, "error address map device not found: " 2050 amd64_printk(KERN_ERR, "error address map device not found: "
2066 "vendor %x device 0x%x (broken BIOS?)\n", 2051 "vendor %x device 0x%x (broken BIOS?)\n",
2067 PCI_VENDOR_ID_AMD, amd64_dev->addr_f1_ctl); 2052 PCI_VENDOR_ID_AMD, f1_id);
2068 return 1; 2053 return -ENODEV;
2069 } 2054 }
2070 2055
2071 /* Reserve the MISC Device */ 2056 /* Reserve the MISC Device */
2072 pvt->misc_f3_ctl = pci_get_related_function(pvt->dram_f2_ctl->vendor, 2057 pvt->misc_f3_ctl = pci_get_related_function(pvt->dram_f2_ctl->vendor,
2073 amd64_dev->misc_f3_ctl, 2058 f3_id,
2074 pvt->dram_f2_ctl); 2059 pvt->dram_f2_ctl);
2075 2060
2076 if (!pvt->misc_f3_ctl) { 2061 if (!pvt->misc_f3_ctl) {
@@ -2079,8 +2064,8 @@ static int amd64_reserve_mc_sibling_devices(struct amd64_pvt *pvt, int mc_idx)
2079 2064
2080 amd64_printk(KERN_ERR, "error miscellaneous device not found: " 2065 amd64_printk(KERN_ERR, "error miscellaneous device not found: "
2081 "vendor %x device 0x%x (broken BIOS?)\n", 2066 "vendor %x device 0x%x (broken BIOS?)\n",
2082 PCI_VENDOR_ID_AMD, amd64_dev->misc_f3_ctl); 2067 PCI_VENDOR_ID_AMD, f3_id);
2083 return 1; 2068 return -ENODEV;
2084 } 2069 }
2085 2070
2086 debugf1(" Addr Map device PCI Bus ID:\t%s\n", 2071 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 if (!fam_type) 2631 if (!fam_type)
2647 goto err_free; 2632 goto err_free;
2648 2633
2649 /*
2650 * We have the dram_f2_ctl device as an argument, now go reserve its
2651 * sibling devices from the PCI system.
2652 */
2653 ret = -ENODEV; 2634 ret = -ENODEV;
2654 err = amd64_reserve_mc_sibling_devices(pvt, mc_type_index); 2635 err = amd64_reserve_mc_sibling_devices(pvt, fam_type->addr_f1_ctl,
2636 fam_type->misc_f3_ctl);
2655 if (err) 2637 if (err)
2656 goto err_free; 2638 goto err_free;
2657 2639