diff options
author | Borislav Petkov <borislav.petkov@amd.com> | 2012-09-12 13:00:38 -0400 |
---|---|---|
committer | Borislav Petkov <bp@alien8.de> | 2012-11-28 05:47:36 -0500 |
commit | 10de6497a56e933d9ddca94aff186ac3b3105af9 (patch) | |
tree | f3fdcdeaf9f38f7431f4a1da64ec4af614adc6bf /drivers/edac/amd64_edac.c | |
parent | 0a5dfc31405d9b07a5b37f150815b9ad09685460 (diff) |
amd64_edac: Fix csrows size and pages computation
Make sure code pays attention to K8 having only one DCT, reformat and
cleanup code, correct debug messages, remove unused code.
Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
Diffstat (limited to 'drivers/edac/amd64_edac.c')
-rw-r--r-- | drivers/edac/amd64_edac.c | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c index 89cd71ea0e50..cb64bec374d9 100644 --- a/drivers/edac/amd64_edac.c +++ b/drivers/edac/amd64_edac.c | |||
@@ -2087,6 +2087,7 @@ static u32 amd64_csrow_nr_pages(struct amd64_pvt *pvt, u8 dct, int csrow_nr) | |||
2087 | u32 cs_mode, nr_pages; | 2087 | u32 cs_mode, nr_pages; |
2088 | u32 dbam = dct ? pvt->dbam1 : pvt->dbam0; | 2088 | u32 dbam = dct ? pvt->dbam1 : pvt->dbam0; |
2089 | 2089 | ||
2090 | |||
2090 | /* | 2091 | /* |
2091 | * The math on this doesn't look right on the surface because x/2*4 can | 2092 | * The math on this doesn't look right on the surface because x/2*4 can |
2092 | * be simplified to x*2 but this expression makes use of the fact that | 2093 | * be simplified to x*2 but this expression makes use of the fact that |
@@ -2098,9 +2099,9 @@ static u32 amd64_csrow_nr_pages(struct amd64_pvt *pvt, u8 dct, int csrow_nr) | |||
2098 | 2099 | ||
2099 | nr_pages = pvt->ops->dbam_to_cs(pvt, dct, cs_mode) << (20 - PAGE_SHIFT); | 2100 | nr_pages = pvt->ops->dbam_to_cs(pvt, dct, cs_mode) << (20 - PAGE_SHIFT); |
2100 | 2101 | ||
2101 | edac_dbg(0, " (csrow=%d) DBAM map index= %d\n", csrow_nr, cs_mode); | 2102 | edac_dbg(0, "csrow: %d, channel: %d, DBAM idx: %d\n", |
2102 | edac_dbg(0, " nr_pages/channel= %u channel-count = %d\n", | 2103 | csrow_nr, dct, cs_mode); |
2103 | nr_pages, pvt->channel_count); | 2104 | edac_dbg(0, "nr_pages/channel: %u\n", nr_pages); |
2104 | 2105 | ||
2105 | return nr_pages; | 2106 | return nr_pages; |
2106 | } | 2107 | } |
@@ -2111,15 +2112,14 @@ static u32 amd64_csrow_nr_pages(struct amd64_pvt *pvt, u8 dct, int csrow_nr) | |||
2111 | */ | 2112 | */ |
2112 | static int init_csrows(struct mem_ctl_info *mci) | 2113 | static int init_csrows(struct mem_ctl_info *mci) |
2113 | { | 2114 | { |
2115 | struct amd64_pvt *pvt = mci->pvt_info; | ||
2114 | struct csrow_info *csrow; | 2116 | struct csrow_info *csrow; |
2115 | struct dimm_info *dimm; | 2117 | struct dimm_info *dimm; |
2116 | struct amd64_pvt *pvt = mci->pvt_info; | ||
2117 | u64 base, mask; | ||
2118 | u32 val; | ||
2119 | int i, j, empty = 1; | ||
2120 | enum mem_type mtype; | ||
2121 | enum edac_type edac_mode; | 2118 | enum edac_type edac_mode; |
2119 | enum mem_type mtype; | ||
2120 | int i, j, empty = 1; | ||
2122 | int nr_pages = 0; | 2121 | int nr_pages = 0; |
2122 | u32 val; | ||
2123 | 2123 | ||
2124 | amd64_read_pci_cfg(pvt->F3, NBCFG, &val); | 2124 | amd64_read_pci_cfg(pvt->F3, NBCFG, &val); |
2125 | 2125 | ||
@@ -2129,29 +2129,35 @@ static int init_csrows(struct mem_ctl_info *mci) | |||
2129 | pvt->mc_node_id, val, | 2129 | pvt->mc_node_id, val, |
2130 | !!(val & NBCFG_CHIPKILL), !!(val & NBCFG_ECC_ENABLE)); | 2130 | !!(val & NBCFG_CHIPKILL), !!(val & NBCFG_ECC_ENABLE)); |
2131 | 2131 | ||
2132 | /* | ||
2133 | * We iterate over DCT0 here but we look at DCT1 in parallel, if needed. | ||
2134 | */ | ||
2132 | for_each_chip_select(i, 0, pvt) { | 2135 | for_each_chip_select(i, 0, pvt) { |
2133 | csrow = mci->csrows[i]; | 2136 | bool row_dct0 = !!csrow_enabled(i, 0, pvt); |
2137 | bool row_dct1 = false; | ||
2134 | 2138 | ||
2135 | if (!csrow_enabled(i, 0, pvt) && !csrow_enabled(i, 1, pvt)) { | 2139 | if (boot_cpu_data.x86 != 0xf) |
2136 | edac_dbg(1, "----CSROW %d VALID for MC node %d\n", | 2140 | row_dct1 = !!csrow_enabled(i, 1, pvt); |
2137 | i, pvt->mc_node_id); | 2141 | |
2142 | if (!row_dct0 && !row_dct1) | ||
2138 | continue; | 2143 | continue; |
2139 | } | ||
2140 | 2144 | ||
2145 | csrow = mci->csrows[i]; | ||
2141 | empty = 0; | 2146 | empty = 0; |
2142 | if (csrow_enabled(i, 0, pvt)) | 2147 | |
2148 | edac_dbg(1, "MC node: %d, csrow: %d\n", | ||
2149 | pvt->mc_node_id, i); | ||
2150 | |||
2151 | if (row_dct0) | ||
2143 | nr_pages = amd64_csrow_nr_pages(pvt, 0, i); | 2152 | nr_pages = amd64_csrow_nr_pages(pvt, 0, i); |
2144 | if (csrow_enabled(i, 1, pvt)) | ||
2145 | nr_pages += amd64_csrow_nr_pages(pvt, 1, i); | ||
2146 | 2153 | ||
2147 | get_cs_base_and_mask(pvt, i, 0, &base, &mask); | 2154 | /* K8 has only one DCT */ |
2148 | /* 8 bytes of resolution */ | 2155 | if (boot_cpu_data.x86 != 0xf && row_dct1) |
2156 | nr_pages += amd64_csrow_nr_pages(pvt, 1, i); | ||
2149 | 2157 | ||
2150 | mtype = amd64_determine_memory_type(pvt, i); | 2158 | mtype = amd64_determine_memory_type(pvt, i); |
2151 | 2159 | ||
2152 | edac_dbg(1, " for MC node %d csrow %d:\n", pvt->mc_node_id, i); | 2160 | edac_dbg(1, "Total csrow%d pages: %u\n", i, nr_pages); |
2153 | edac_dbg(1, " nr_pages: %u\n", | ||
2154 | nr_pages * pvt->channel_count); | ||
2155 | 2161 | ||
2156 | /* | 2162 | /* |
2157 | * determine whether CHIPKILL or JUST ECC or NO ECC is operating | 2163 | * determine whether CHIPKILL or JUST ECC or NO ECC is operating |