aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/edac/amd64_edac.c
diff options
context:
space:
mode:
authorBorislav Petkov <borislav.petkov@amd.com>2009-08-05 09:47:22 -0400
committerBorislav Petkov <borislav.petkov@amd.com>2009-09-16 06:40:38 -0400
commitbe3468e8ff768c986849870b24e85fa84806da73 (patch)
treed97f18401258dd8f8cdde1486570e360e344f239 /drivers/edac/amd64_edac.c
parent6a8126911a5ab167783fce18ae9cc70ec9b84fe2 (diff)
amd64_edac: cleanup amd64_check_ecc_enabled
Simplify code flow and make sure return value is always valid since further driver init depends on it. Carve out long warning string and make code more readable. Shorten some names, while at it. There should be no functional change resulting from this patch. Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
Diffstat (limited to 'drivers/edac/amd64_edac.c')
-rw-r--r--drivers/edac/amd64_edac.c76
1 files changed, 25 insertions, 51 deletions
diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
index 173dc4a84166..bde3d027c2d3 100644
--- a/drivers/edac/amd64_edac.c
+++ b/drivers/edac/amd64_edac.c
@@ -2783,7 +2783,7 @@ static void check_mcg_ctl(void *ret)
2783} 2783}
2784 2784
2785/* check MCG_CTL on all the cpus on this node */ 2785/* check MCG_CTL on all the cpus on this node */
2786static int amd64_mcg_ctl_enabled_on_cpus(const cpumask_t *mask) 2786static int mcg_ctl_enabled_on_node(const struct cpumask *mask)
2787{ 2787{
2788 int ret = 1; 2788 int ret = 1;
2789 preempt_disable(); 2789 preempt_disable();
@@ -2799,71 +2799,45 @@ static int amd64_mcg_ctl_enabled_on_cpus(const cpumask_t *mask)
2799 * the memory system completely. A command line option allows to force-enable 2799 * the memory system completely. A command line option allows to force-enable
2800 * hardware ECC later in amd64_enable_ecc_error_reporting(). 2800 * hardware ECC later in amd64_enable_ecc_error_reporting().
2801 */ 2801 */
2802static const char *ecc_warning =
2803 "WARNING: ECC is disabled by BIOS. Module will NOT be loaded.\n"
2804 " Either Enable ECC in the BIOS, or set 'ecc_enable_override'.\n"
2805 " Also, use of the override can cause unknown side effects.\n";
2806
2802static int amd64_check_ecc_enabled(struct amd64_pvt *pvt) 2807static int amd64_check_ecc_enabled(struct amd64_pvt *pvt)
2803{ 2808{
2804 u32 value; 2809 u32 value;
2805 int err = 0, ret = 0; 2810 int err = 0;
2806 u8 ecc_enabled = 0; 2811 u8 ecc_enabled = 0, mcg_ctl_en = 0;
2807 2812
2808 err = pci_read_config_dword(pvt->misc_f3_ctl, K8_NBCFG, &value); 2813 err = pci_read_config_dword(pvt->misc_f3_ctl, K8_NBCFG, &value);
2809 if (err) 2814 if (err)
2810 debugf0("Reading K8_NBCTL failed\n"); 2815 debugf0("Reading K8_NBCTL failed\n");
2811 2816
2812 ecc_enabled = !!(value & K8_NBCFG_ECC_ENABLE); 2817 ecc_enabled = !!(value & K8_NBCFG_ECC_ENABLE);
2818 if (!ecc_enabled)
2819 amd64_printk(KERN_WARNING, "This node reports that Memory ECC "
2820 "is currently disabled, set F3x%x[22] (%s).\n",
2821 K8_NBCFG, pci_name(pvt->misc_f3_ctl));
2822 else
2823 amd64_printk(KERN_INFO, "ECC is enabled by BIOS.\n");
2813 2824
2814 ret = amd64_mcg_ctl_enabled_on_cpus(cpumask_of_node(pvt->mc_node_id)); 2825 mcg_ctl_en = mcg_ctl_enabled_on_node(cpumask_of_node(pvt->mc_node_id));
2815 2826 if (!mcg_ctl_en)
2816 debugf0("K8_NBCFG=0x%x, DRAM ECC is %s\n", value, 2827 amd64_printk(KERN_WARNING, "NB MCE bank disabled, set MSR "
2817 (value & K8_NBCFG_ECC_ENABLE ? "enabled" : "disabled")); 2828 "0x%08x[4] on node %d to enable.\n",
2818 2829 MSR_IA32_MCG_CTL, pvt->mc_node_id);
2819 if (!ecc_enabled || !ret) {
2820 if (!ecc_enabled) {
2821 amd64_printk(KERN_WARNING, "This node reports that "
2822 "Memory ECC is currently "
2823 "disabled.\n");
2824 2830
2825 amd64_printk(KERN_WARNING, "bit 0x%lx in register " 2831 if (!ecc_enabled || !mcg_ctl_en) {
2826 "F3x%x of the MISC_CONTROL device (%s) "
2827 "should be enabled\n", K8_NBCFG_ECC_ENABLE,
2828 K8_NBCFG, pci_name(pvt->misc_f3_ctl));
2829 }
2830 if (!ret) {
2831 amd64_printk(KERN_WARNING, "bit 0x%016lx in MSR 0x%08x "
2832 "of node %d should be enabled\n",
2833 K8_MSR_MCGCTL_NBE, MSR_IA32_MCG_CTL,
2834 pvt->mc_node_id);
2835 }
2836 if (!ecc_enable_override) { 2832 if (!ecc_enable_override) {
2837 amd64_printk(KERN_WARNING, "WARNING: ECC is NOT " 2833 amd64_printk(KERN_WARNING, "%s", ecc_warning);
2838 "currently enabled by the BIOS. Module " 2834 return -ENODEV;
2839 "will NOT be loaded.\n" 2835 }
2840 " Either Enable ECC in the BIOS, " 2836 } else
2841 "or use the 'ecc_enable_override' "
2842 "parameter.\n"
2843 " Might be a BIOS bug, if BIOS says "
2844 "ECC is enabled\n"
2845 " Use of the override can cause "
2846 "unknown side effects.\n");
2847 ret = -ENODEV;
2848 } else
2849 /*
2850 * enable further driver loading if ECC enable is
2851 * overridden.
2852 */
2853 ret = 0;
2854 } else {
2855 amd64_printk(KERN_INFO,
2856 "ECC is enabled by BIOS, Proceeding "
2857 "with EDAC module initialization\n");
2858
2859 /* Signal good ECC status */
2860 ret = 0;
2861
2862 /* CLEAR the override, since BIOS controlled it */ 2837 /* CLEAR the override, since BIOS controlled it */
2863 ecc_enable_override = 0; 2838 ecc_enable_override = 0;
2864 }
2865 2839
2866 return ret; 2840 return 0;
2867} 2841}
2868 2842
2869struct mcidev_sysfs_attribute sysfs_attrs[ARRAY_SIZE(amd64_dbg_attrs) + 2843struct mcidev_sysfs_attribute sysfs_attrs[ARRAY_SIZE(amd64_dbg_attrs) +