diff options
author | Borislav Petkov <borislav.petkov@amd.com> | 2010-10-01 13:20:05 -0400 |
---|---|---|
committer | Borislav Petkov <borislav.petkov@amd.com> | 2011-01-07 05:33:51 -0500 |
commit | 0092b20d4cf3de243b5c82b410ee02644cec2707 (patch) | |
tree | b839d0953cf4949d93dd957f776aae0c4b9f8751 /drivers/edac | |
parent | 395ae783b384e5243804b07fba3e3f8379ddf1d6 (diff) |
amd64_edac: Simplify CPU family detection
Concentrate CPU family detection in the per-family init function.
Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
Diffstat (limited to 'drivers/edac')
-rw-r--r-- | drivers/edac/amd64_edac.c | 56 | ||||
-rw-r--r-- | drivers/edac/amd64_edac.h | 8 |
2 files changed, 32 insertions, 32 deletions
diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c index de3672188b15..0a9edf8cdaf3 100644 --- a/drivers/edac/amd64_edac.c +++ b/drivers/edac/amd64_edac.c | |||
@@ -783,19 +783,6 @@ static u16 extract_syndrome(struct err_regs *err) | |||
783 | return ((err->nbsh >> 15) & 0xff) | ((err->nbsl >> 16) & 0xff00); | 783 | return ((err->nbsh >> 15) & 0xff) | ((err->nbsl >> 16) & 0xff00); |
784 | } | 784 | } |
785 | 785 | ||
786 | static void amd64_cpu_display_info(struct amd64_pvt *pvt) | ||
787 | { | ||
788 | if (boot_cpu_data.x86 == 0x10) | ||
789 | edac_printk(KERN_DEBUG, EDAC_MC, "F10h CPU detected\n"); | ||
790 | else if (boot_cpu_data.x86 == 0xf) | ||
791 | edac_printk(KERN_DEBUG, EDAC_MC, "%s detected\n", | ||
792 | (pvt->ext_model >= K8_REV_F) ? | ||
793 | "Rev F or later" : "Rev E or earlier"); | ||
794 | else | ||
795 | /* we'll hardly ever ever get here */ | ||
796 | edac_printk(KERN_ERR, EDAC_MC, "Unknown cpu!\n"); | ||
797 | } | ||
798 | |||
799 | /* | 786 | /* |
800 | * Determine if the DIMMs have ECC enabled. ECC is enabled ONLY if all the DIMMs | 787 | * Determine if the DIMMs have ECC enabled. ECC is enabled ONLY if all the DIMMs |
801 | * are ECC capable. | 788 | * are ECC capable. |
@@ -1719,7 +1706,7 @@ static void amd64_debug_display_dimm_sizes(int ctrl, struct amd64_pvt *pvt) | |||
1719 | 1706 | ||
1720 | static struct amd64_family_type amd64_family_types[] = { | 1707 | static struct amd64_family_type amd64_family_types[] = { |
1721 | [K8_CPUS] = { | 1708 | [K8_CPUS] = { |
1722 | .ctl_name = "RevF", | 1709 | .ctl_name = "K8", |
1723 | .addr_f1_ctl = PCI_DEVICE_ID_AMD_K8_NB_ADDRMAP, | 1710 | .addr_f1_ctl = PCI_DEVICE_ID_AMD_K8_NB_ADDRMAP, |
1724 | .misc_f3_ctl = PCI_DEVICE_ID_AMD_K8_NB_MISC, | 1711 | .misc_f3_ctl = PCI_DEVICE_ID_AMD_K8_NB_MISC, |
1725 | .ops = { | 1712 | .ops = { |
@@ -1731,7 +1718,7 @@ static struct amd64_family_type amd64_family_types[] = { | |||
1731 | } | 1718 | } |
1732 | }, | 1719 | }, |
1733 | [F10_CPUS] = { | 1720 | [F10_CPUS] = { |
1734 | .ctl_name = "Family 10h", | 1721 | .ctl_name = "F10h", |
1735 | .addr_f1_ctl = PCI_DEVICE_ID_AMD_10H_NB_MAP, | 1722 | .addr_f1_ctl = PCI_DEVICE_ID_AMD_10H_NB_MAP, |
1736 | .misc_f3_ctl = PCI_DEVICE_ID_AMD_10H_NB_MISC, | 1723 | .misc_f3_ctl = PCI_DEVICE_ID_AMD_10H_NB_MISC, |
1737 | .ops = { | 1724 | .ops = { |
@@ -2137,8 +2124,6 @@ static void amd64_read_mc_registers(struct amd64_pvt *pvt) | |||
2137 | } else | 2124 | } else |
2138 | debugf0(" TOP_MEM2 disabled.\n"); | 2125 | debugf0(" TOP_MEM2 disabled.\n"); |
2139 | 2126 | ||
2140 | amd64_cpu_display_info(pvt); | ||
2141 | |||
2142 | amd64_read_pci_cfg(pvt->misc_f3_ctl, K8_NBCAP, &pvt->nbcap); | 2127 | amd64_read_pci_cfg(pvt->misc_f3_ctl, K8_NBCAP, &pvt->nbcap); |
2143 | 2128 | ||
2144 | if (pvt->ops->read_dram_ctl_register) | 2129 | if (pvt->ops->read_dram_ctl_register) |
@@ -2583,7 +2568,7 @@ static void amd64_setup_mci_misc_attributes(struct mem_ctl_info *mci) | |||
2583 | mci->edac_cap = amd64_determine_edac_cap(pvt); | 2568 | mci->edac_cap = amd64_determine_edac_cap(pvt); |
2584 | mci->mod_name = EDAC_MOD_STR; | 2569 | mci->mod_name = EDAC_MOD_STR; |
2585 | mci->mod_ver = EDAC_AMD64_VERSION; | 2570 | mci->mod_ver = EDAC_AMD64_VERSION; |
2586 | mci->ctl_name = get_amd_family_name(pvt->mc_type_index); | 2571 | mci->ctl_name = pvt->ctl_name; |
2587 | mci->dev_name = pci_name(pvt->dram_f2_ctl); | 2572 | mci->dev_name = pci_name(pvt->dram_f2_ctl); |
2588 | mci->ctl_page_to_phys = NULL; | 2573 | mci->ctl_page_to_phys = NULL; |
2589 | 2574 | ||
@@ -2592,21 +2577,37 @@ static void amd64_setup_mci_misc_attributes(struct mem_ctl_info *mci) | |||
2592 | mci->get_sdram_scrub_rate = amd64_get_scrub_rate; | 2577 | mci->get_sdram_scrub_rate = amd64_get_scrub_rate; |
2593 | } | 2578 | } |
2594 | 2579 | ||
2595 | static int amd64_per_family_init(struct amd64_pvt *pvt) | 2580 | /* |
2581 | * returns a pointer to the family descriptor on success, NULL otherwise. | ||
2582 | */ | ||
2583 | static struct amd64_family_type *amd64_per_family_init(struct amd64_pvt *pvt) | ||
2596 | { | 2584 | { |
2597 | switch (boot_cpu_data.x86) { | 2585 | u8 fam = boot_cpu_data.x86; |
2586 | struct amd64_family_type *fam_type = NULL; | ||
2587 | |||
2588 | switch (fam) { | ||
2598 | case 0xf: | 2589 | case 0xf: |
2599 | pvt->min_scrubrate = K8_MIN_SCRUB_RATE_BITS; | 2590 | fam_type = &amd64_family_types[K8_CPUS]; |
2591 | pvt->ctl_name = fam_type->ctl_name; | ||
2592 | pvt->min_scrubrate = K8_MIN_SCRUB_RATE_BITS; | ||
2600 | break; | 2593 | break; |
2601 | case 0x10: | 2594 | case 0x10: |
2602 | pvt->min_scrubrate = F10_MIN_SCRUB_RATE_BITS; | 2595 | fam_type = &amd64_family_types[F10_CPUS]; |
2596 | pvt->ctl_name = fam_type->ctl_name; | ||
2597 | pvt->min_scrubrate = F10_MIN_SCRUB_RATE_BITS; | ||
2603 | break; | 2598 | break; |
2604 | 2599 | ||
2605 | default: | 2600 | default: |
2606 | amd64_printk(KERN_ERR, "Unsupported family!\n"); | 2601 | amd64_printk(KERN_ERR, "Unsupported family!\n"); |
2607 | return -EINVAL; | 2602 | return NULL; |
2608 | } | 2603 | } |
2609 | return 0; | 2604 | |
2605 | amd64_printk(KERN_INFO, "%s %s detected.\n", pvt->ctl_name, | ||
2606 | (fam == 0xf ? | ||
2607 | (pvt->ext_model >= K8_REV_F ? "revF or later" | ||
2608 | : "revE or earlier") | ||
2609 | : "")); | ||
2610 | return fam_type; | ||
2610 | } | 2611 | } |
2611 | 2612 | ||
2612 | /* | 2613 | /* |
@@ -2625,6 +2626,7 @@ static int amd64_probe_one_instance(struct pci_dev *dram_f2_ctl, | |||
2625 | int mc_type_index) | 2626 | int mc_type_index) |
2626 | { | 2627 | { |
2627 | struct amd64_pvt *pvt = NULL; | 2628 | struct amd64_pvt *pvt = NULL; |
2629 | struct amd64_family_type *fam_type = NULL; | ||
2628 | int err = 0, ret; | 2630 | int err = 0, ret; |
2629 | 2631 | ||
2630 | ret = -ENOMEM; | 2632 | ret = -ENOMEM; |
@@ -2640,7 +2642,8 @@ static int amd64_probe_one_instance(struct pci_dev *dram_f2_ctl, | |||
2640 | pvt->ops = family_ops(mc_type_index); | 2642 | pvt->ops = family_ops(mc_type_index); |
2641 | 2643 | ||
2642 | ret = -EINVAL; | 2644 | ret = -EINVAL; |
2643 | if (amd64_per_family_init(pvt)) | 2645 | fam_type = amd64_per_family_init(pvt); |
2646 | if (!fam_type) | ||
2644 | goto err_free; | 2647 | goto err_free; |
2645 | 2648 | ||
2646 | /* | 2649 | /* |
@@ -2762,8 +2765,7 @@ static int __devinit amd64_init_one_instance(struct pci_dev *pdev, | |||
2762 | { | 2765 | { |
2763 | int ret = 0; | 2766 | int ret = 0; |
2764 | 2767 | ||
2765 | debugf0("(MC node=%d,mc_type='%s')\n", get_node_id(pdev), | 2768 | debugf0("(MC node=%d)\n", get_node_id(pdev)); |
2766 | get_amd_family_name(mc_type->driver_data)); | ||
2767 | 2769 | ||
2768 | ret = pci_enable_device(pdev); | 2770 | ret = pci_enable_device(pdev); |
2769 | if (ret < 0) | 2771 | if (ret < 0) |
diff --git a/drivers/edac/amd64_edac.h b/drivers/edac/amd64_edac.h index e5204feda191..064e0d691ff9 100644 --- a/drivers/edac/amd64_edac.h +++ b/drivers/edac/amd64_edac.h | |||
@@ -464,6 +464,9 @@ struct amd64_pvt { | |||
464 | /* DCT per-family scrubrate setting */ | 464 | /* DCT per-family scrubrate setting */ |
465 | u32 min_scrubrate; | 465 | u32 min_scrubrate; |
466 | 466 | ||
467 | /* family name this instance is running on */ | ||
468 | const char *ctl_name; | ||
469 | |||
467 | /* misc settings */ | 470 | /* misc settings */ |
468 | struct flags { | 471 | struct flags { |
469 | unsigned long cf8_extcfg:1; | 472 | unsigned long cf8_extcfg:1; |
@@ -526,11 +529,6 @@ struct amd64_family_type { | |||
526 | 529 | ||
527 | static struct amd64_family_type amd64_family_types[]; | 530 | static struct amd64_family_type amd64_family_types[]; |
528 | 531 | ||
529 | static inline const char *get_amd_family_name(int index) | ||
530 | { | ||
531 | return amd64_family_types[index].ctl_name; | ||
532 | } | ||
533 | |||
534 | static inline struct low_ops *family_ops(int index) | 532 | static inline struct low_ops *family_ops(int index) |
535 | { | 533 | { |
536 | return &amd64_family_types[index].ops; | 534 | return &amd64_family_types[index].ops; |