aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/edac
diff options
context:
space:
mode:
authorBorislav Petkov <borislav.petkov@amd.com>2010-10-01 12:38:19 -0400
committerBorislav Petkov <borislav.petkov@amd.com>2011-01-07 05:33:50 -0500
commit395ae783b384e5243804b07fba3e3f8379ddf1d6 (patch)
treed5b841a23508eed59caf67d7a4ee411e808b2860 /drivers/edac
parent9f56da0e3c3269abe0b2745a54f1b082c3c14433 (diff)
amd64_edac: Add per-family init function
Run a per-family init function which does all the settings based on the family this driver instance is running on. Move the scrubrate calculation in it and simplify code. Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
Diffstat (limited to 'drivers/edac')
-rw-r--r--drivers/edac/amd64_edac.c44
-rw-r--r--drivers/edac/amd64_edac.h3
2 files changed, 28 insertions, 19 deletions
diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
index 0cbcf6e34a4c..de3672188b15 100644
--- a/drivers/edac/amd64_edac.c
+++ b/drivers/edac/amd64_edac.c
@@ -117,8 +117,7 @@ struct scrubrate scrubrates[] = {
117 * scan the scrub rate mapping table for a close or matching bandwidth value to 117 * scan the scrub rate mapping table for a close or matching bandwidth value to
118 * issue. If requested is too big, then use last maximum value found. 118 * issue. If requested is too big, then use last maximum value found.
119 */ 119 */
120static int amd64_search_set_scrub_rate(struct pci_dev *ctl, u32 new_bw, 120static int __amd64_set_scrub_rate(struct pci_dev *ctl, u32 new_bw, u32 min_rate)
121 u32 min_scrubrate)
122{ 121{
123 u32 scrubval; 122 u32 scrubval;
124 int i; 123 int i;
@@ -134,7 +133,7 @@ static int amd64_search_set_scrub_rate(struct pci_dev *ctl, u32 new_bw,
134 * skip scrub rates which aren't recommended 133 * skip scrub rates which aren't recommended
135 * (see F10 BKDG, F3x58) 134 * (see F10 BKDG, F3x58)
136 */ 135 */
137 if (scrubrates[i].scrubval < min_scrubrate) 136 if (scrubrates[i].scrubval < min_rate)
138 continue; 137 continue;
139 138
140 if (scrubrates[i].bandwidth <= new_bw) 139 if (scrubrates[i].bandwidth <= new_bw)
@@ -160,25 +159,11 @@ static int amd64_search_set_scrub_rate(struct pci_dev *ctl, u32 new_bw,
160 return 0; 159 return 0;
161} 160}
162 161
163static int amd64_set_scrub_rate(struct mem_ctl_info *mci, u32 bandwidth) 162static int amd64_set_scrub_rate(struct mem_ctl_info *mci, u32 bw)
164{ 163{
165 struct amd64_pvt *pvt = mci->pvt_info; 164 struct amd64_pvt *pvt = mci->pvt_info;
166 u32 min_scrubrate = 0x0;
167 165
168 switch (boot_cpu_data.x86) { 166 return __amd64_set_scrub_rate(pvt->misc_f3_ctl, bw, pvt->min_scrubrate);
169 case 0xf:
170 min_scrubrate = K8_MIN_SCRUB_RATE_BITS;
171 break;
172 case 0x10:
173 min_scrubrate = F10_MIN_SCRUB_RATE_BITS;
174 break;
175
176 default:
177 amd64_printk(KERN_ERR, "Unsupported family!\n");
178 return -EINVAL;
179 }
180 return amd64_search_set_scrub_rate(pvt->misc_f3_ctl, bandwidth,
181 min_scrubrate);
182} 167}
183 168
184static int amd64_get_scrub_rate(struct mem_ctl_info *mci, u32 *bw) 169static int amd64_get_scrub_rate(struct mem_ctl_info *mci, u32 *bw)
@@ -2607,6 +2592,23 @@ static void amd64_setup_mci_misc_attributes(struct mem_ctl_info *mci)
2607 mci->get_sdram_scrub_rate = amd64_get_scrub_rate; 2592 mci->get_sdram_scrub_rate = amd64_get_scrub_rate;
2608} 2593}
2609 2594
2595static int amd64_per_family_init(struct amd64_pvt *pvt)
2596{
2597 switch (boot_cpu_data.x86) {
2598 case 0xf:
2599 pvt->min_scrubrate = K8_MIN_SCRUB_RATE_BITS;
2600 break;
2601 case 0x10:
2602 pvt->min_scrubrate = F10_MIN_SCRUB_RATE_BITS;
2603 break;
2604
2605 default:
2606 amd64_printk(KERN_ERR, "Unsupported family!\n");
2607 return -EINVAL;
2608 }
2609 return 0;
2610}
2611
2610/* 2612/*
2611 * Init stuff for this DRAM Controller device. 2613 * Init stuff for this DRAM Controller device.
2612 * 2614 *
@@ -2637,6 +2639,10 @@ static int amd64_probe_one_instance(struct pci_dev *dram_f2_ctl,
2637 pvt->mc_type_index = mc_type_index; 2639 pvt->mc_type_index = mc_type_index;
2638 pvt->ops = family_ops(mc_type_index); 2640 pvt->ops = family_ops(mc_type_index);
2639 2641
2642 ret = -EINVAL;
2643 if (amd64_per_family_init(pvt))
2644 goto err_free;
2645
2640 /* 2646 /*
2641 * We have the dram_f2_ctl device as an argument, now go reserve its 2647 * We have the dram_f2_ctl device as an argument, now go reserve its
2642 * sibling devices from the PCI system. 2648 * sibling devices from the PCI system.
diff --git a/drivers/edac/amd64_edac.h b/drivers/edac/amd64_edac.h
index c8f27345ec76..e5204feda191 100644
--- a/drivers/edac/amd64_edac.h
+++ b/drivers/edac/amd64_edac.h
@@ -461,6 +461,9 @@ struct amd64_pvt {
461 /* MC Type Index value: socket F vs Family 10h */ 461 /* MC Type Index value: socket F vs Family 10h */
462 u32 mc_type_index; 462 u32 mc_type_index;
463 463
464 /* DCT per-family scrubrate setting */
465 u32 min_scrubrate;
466
464 /* misc settings */ 467 /* misc settings */
465 struct flags { 468 struct flags {
466 unsigned long cf8_extcfg:1; 469 unsigned long cf8_extcfg:1;