Skip to contentSkip to conversation

x86, MCE, fix MSR_IA32_MCI_CTL2 CMCI threshold setup

PATCH In review Huang Ying 2 participants 4 messages May 17, 2010 – May 18, 2010 x86

lore
Share & tools
lore

Huang Ying

author
#0 lore raw

PATCH 1/1 x86, MCE, fix MSR_IA32_MCI_CTL2 CMCI threshold setup

It is reported that CMCI is not raised when number of corrected error reaches preset threshold. After inspection, it is found that MSR_IA32_MCI_CTL2 threshold field is not setup properly. This patch fixed it.

Changelog:

v2:

- Rename CMCI_EN to MCI_CTL2_CMCI_EN and CMCI_THRESHOLD_MASK to MCI_CTL2_CMCI_THRESHOLD_MASK to make naming consistent.

---
 arch/x86/include/asm/mce.h             |    4 ++++
 arch/x86/include/asm/msr-index.h       |    3 ---
 arch/x86/kernel/cpu/mcheck/mce_intel.c |    9 +++++----
 3 files changed, 9 insertions(+), 7 deletions(-)
arch/x86/include/asm/mce.h +4 -0
index 6c3fdd6..6202db7 100644
@@ -38,6 +38,10 @@
 #define MCM_ADDR_MEM	 3	/* memory address */
 #define MCM_ADDR_GENERIC 7	/* generic */
 
+/* CTL2 register defines */
+#define MCI_CTL2_CMCI_EN		(1ULL << 30)
+#define MCI_CTL2_CMCI_THRESHOLD_MASK	0x7fffULL
+
 #define MCJ_CTX_MASK		3
 #define MCJ_CTX(flags)		((flags) & MCJ_CTX_MASK)
 #define MCJ_CTX_RANDOM		0    /* inject context: random */
arch/x86/include/asm/msr-index.h +0 -3
index 4604e6a..baa6370 100644
@@ -91,9 +91,6 @@
 #define MSR_IA32_MC0_CTL2		0x00000280
 #define MSR_IA32_MCx_CTL2(x)		(MSR_IA32_MC0_CTL2 + (x))
 
-#define CMCI_EN			(1ULL << 30)
-#define CMCI_THRESHOLD_MASK		0xffffULL
-
 #define MSR_P6_PERFCTR0			0x000000c1
 #define MSR_P6_PERFCTR1			0x000000c2
 #define MSR_P6_EVNTSEL0			0x00000186
arch/x86/kernel/cpu/mcheck/mce_intel.c +5 -4
index 62b48e4..6fcd093 100644
@@ -95,19 +95,20 @@ static void cmci_discover(int banks, int boot)
 		rdmsrl(MSR_IA32_MCx_CTL2(i), val);
 
 		/* Already owned by someone else? */
-		if (val & CMCI_EN) {
+		if (val & MCI_CTL2_CMCI_EN) {
 			if (test_and_clear_bit(i, owned) && !boot)
 				print_update("SHD", &hdr, i);
 			__clear_bit(i, __get_cpu_var(mce_poll_banks));
 			continue;
 		}
 
-		val |= CMCI_EN | CMCI_THRESHOLD;
+		val &= ~MCI_CTL2_CMCI_THRESHOLD_MASK;
+		val |= MCI_CTL2_CMCI_EN | CMCI_THRESHOLD;
 		wrmsrl(MSR_IA32_MCx_CTL2(i), val);
 		rdmsrl(MSR_IA32_MCx_CTL2(i), val);
 
 		/* Did the enable bit stick? -- the bank supports CMCI */
-		if (val & CMCI_EN) {
+		if (val & MCI_CTL2_CMCI_EN) {
 			if (!test_and_set_bit(i, owned) && !boot)
 				print_update("CMCI", &hdr, i);
 			__clear_bit(i, __get_cpu_var(mce_poll_banks));
@@ -155,7 +156,7 @@ void cmci_clear(void)
 			continue;
 		/* Disable CMCI */
 		rdmsrl(MSR_IA32_MCx_CTL2(i), val);
-		val &= ~(CMCI_EN|CMCI_THRESHOLD_MASK);
+		val &= ~(MCI_CTL2_CMCI_EN|MCI_CTL2_CMCI_THRESHOLD_MASK);
 		wrmsrl(MSR_IA32_MCx_CTL2(i), val);
 		__clear_bit(i, __get_cpu_var(mce_banks_owned));
 	}
#1 lore raw
Quoted 6 lines · Huang Ying

It is reported that CMCI is not raised when number of corrected error reaches preset threshold. After inspection, it is found that MSR_IA32_MCI_CTL2 threshold field is not setup properly. This patch fixed it.

Quoted 7 lines

Changelog:

v2:

- Rename CMCI_EN to MCI_CTL2_CMCI_EN and CMCI_THRESHOLD_MASK to MCI_CTL2_CMCI_THRESHOLD_MASK to make naming consistent.

This looks like a mix of a renaming patch and new functionality. Please submit the renaming as a one patch and then the new functionality as a second patch on top, otherwise it gets hard to see what is actually going on.

If I'm not mistaken, there are at least two functionality changes:

+#define MCI_CTL2_CMCI_THRESHOLD_MASK 0x7fffULL
-#define CMCI_THRESHOLD_MASK 0xffffULL

... change of mask, and:

- val |= CMCI_EN | CMCI_THRESHOLD;
+ val &= ~MCI_CTL2_CMCI_THRESHOLD_MASK;
+ val |= MCI_CTL2_CMCI_EN | CMCI_THRESHOLD;

bit being cleared which wasn't before.

-hpa

author
#2 lore raw

Hi, Peter,

Thanks for review.

Quoted 31 lines · H. Peter Anvin
Quoted 6 lines · Huang Ying

It is reported that CMCI is not raised when number of corrected error reaches preset threshold. After inspection, it is found that MSR_IA32_MCI_CTL2 threshold field is not setup properly. This patch fixed it.

Quoted 7 lines

Changelog:

v2:

- Rename CMCI_EN to MCI_CTL2_CMCI_EN and CMCI_THRESHOLD_MASK to MCI_CTL2_CMCI_THRESHOLD_MASK to make naming consistent.

This looks like a mix of a renaming patch and new functionality. Please submit the renaming as a one patch and then the new functionality as a second patch on top, otherwise it gets hard to see what is actually going on.

If I'm not mistaken, there are at least two functionality changes:

(quoted diff) +1 -1
+#define MCI_CTL2_CMCI_THRESHOLD_MASK	0x7fffULL
-#define CMCI_THRESHOLD_MASK		0xffffULL

... change of mask, and:

arch/x86/kernel/cpu/mcheck/mce_intel.c +2 -1
-		val |= CMCI_EN | CMCI_THRESHOLD;
+		val &= ~MCI_CTL2_CMCI_THRESHOLD_MASK;
+		val |= MCI_CTL2_CMCI_EN | CMCI_THRESHOLD;
Quoted 1 line

bit being cleared which wasn't before.

This means we need 3 patches?

Best Regards,
Huang Ying

#3 lore raw
Quoted 32 lines · Huang Ying

Hi, Peter,

Thanks for review.

Quoted 27 lines · H. Peter Anvin
Quoted 6 lines · Huang Ying

It is reported that CMCI is not raised when number of corrected error reaches preset threshold. After inspection, it is found that MSR_IA32_MCI_CTL2 threshold field is not setup properly. This patch fixed it.

Quoted 7 lines

Changelog:

v2:

- Rename CMCI_EN to MCI_CTL2_CMCI_EN and CMCI_THRESHOLD_MASK to MCI_CTL2_CMCI_THRESHOLD_MASK to make naming consistent.

This looks like a mix of a renaming patch and new functionality. Please submit the renaming as a one patch and then the new functionality as a second patch on top, otherwise it gets hard to see what is actually going on.

If I'm not mistaken, there are at least two functionality changes:

(quoted diff) +1 -1
+#define MCI_CTL2_CMCI_THRESHOLD_MASK	0x7fffULL
-#define CMCI_THRESHOLD_MASK		0xffffULL

... change of mask, and:

Quoted 8 lines
Quoted 5 lines
arch/x86/kernel/cpu/mcheck/mce_intel.c +2 -1
-		val |= CMCI_EN | CMCI_THRESHOLD;
+		val &= ~MCI_CTL2_CMCI_THRESHOLD_MASK;
+		val |= MCI_CTL2_CMCI_EN | CMCI_THRESHOLD;

bit being cleared which wasn't before.

This means we need 3 patches?

No, two patches is fine -- one for the rename (no binary changes) and one for the functionality changes.

-hpa

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.