Introduce ie31200_edac driver
Subsystems (4)
Jason Baron
maintainerv2 cover Introduce ie31200_edac driver
Hi,
Add support for memory errors for the Intel E3-1200 DRAM controllers.
While testing the driver, I found that doing a readq() on the memory mapped memory controller hub registers caused a hard lockup on my x86_64 system. It turns out that a read across a DW boundary is a no no here.
"
Software must not access B0/D0/F0 32-bit memory-mapped registers with requests that cross a DW boundary.
"
(http://www.intel.com/content/www/us/en/processors/xeon/xeon-e3-1200-family-vol-2-datasheet.html p. 16)
Thus, I've added a generic lo_hi_[read|write]_q API, to deal with this issue.
I think longer term the right thing is maybe to simply add these definitions to include/asm-generic/io.h, as I didn't see any in tree users of 'io-64-nonatomic-hi-lo.h', and simply remove io-64-nonatomic-hi-lo.h and io-64-nonatomic-lo-hi.h. But I didn't want to tie that cleanup to this edac driver submission.
I've been able to test this driver with a bad dimm on Sandy, Ivy Bridge and Haswell systems, and it seems to be doing the right things, and populating '/sys/devices/system/edac/mc/mc0/ue_count' correctly (which is what I really care about).
I've tested:
CPU E3-1270 v3 @ 3.50GHz : 8086:0c08 (haswell)
CPU E3-1270 V2 @ 3.50GHz : 8086:0158 (ivy bridge)
CPU E31270 @ 3.40GHz : 8086:0108 (sandy bridge)
Posted before as: https://lkml.org/lkml/2014/4/4/462
Patch against 3.16.0-rc2
Thanks,
-Jason
Changes since v1:
- Cleanups and formatting based on previous feedback
Jason Baron (3):
readq/writeq: Add explicit lo_hi_[read|write]_q and hi_lo_[read|write]_q
x38_edac: make use of lo_hi_readq()
ie31200_edac: Add driver
drivers/edac/Kconfig | 7 + drivers/edac/Makefile | 1 + drivers/edac/ie31200_edac.c | 542 ++++++++++++++++++++++++++++ drivers/edac/x38_edac.c | 15 +- include/asm-generic/io-64-nonatomic-hi-lo.h | 14 +- include/asm-generic/io-64-nonatomic-lo-hi.h | 14 +- 6 files changed, 574 insertions(+), 19 deletions(-) create mode 100644 drivers/edac/ie31200_edac.c
Signature · 1 line
1.8.2.rc2
Jason Baron
maintainerPATCH v2 1/3 readq/writeq: Add explicit lo_hi_[read|write]_q and hi_lo_[read|write]_q
Even on x86-64, I've found the need to break up a readq() into 2 readl() calls. According to the Intel datasheet for the E3-1200 processor:
"
Software must not access B0/D0/F0 32-bit memory-mapped registers with requests that cross a DW boundary.
"
(http://www.intel.com/content/www/us/en/processors/xeon/xeon-e3-1200-family-vol-2-datasheet.html p. 16)
I can confirm this is true via several hard machine lockups.
Thus, add explicit hi_lo_[readq|write]_q and lo_hi_[read|write]_q so that these uses are spelled out.
--- include/asm-generic/io-64-nonatomic-hi-lo.h | 14 +++++++++----- include/asm-generic/io-64-nonatomic-lo-hi.h | 14 +++++++++----- 2 files changed, 18 insertions(+), 10 deletions(-)
include/asm-generic/io-64-nonatomic-hi-lo.h +9 -5
@@ -4,8 +4,7 @@#include <linux/io.h> #include <asm-generic/int-ll64.h> -#ifndef readq -static inline __u64 readq (const volatile void __iomem *addr) +static inline __u64 hi_lo_readq (const volatile void __iomem *addr) {const volatile u32 __iomem *p = addr;u32 low, high;
@@ -15,14 +14,19 @@ static inline __u64 readq(const volatile void __iomem *addr) return low + ((u64)high << 32); } -#endif -#ifndef writeq -static inline void writeq (__u64 val,volatile void __iomem *addr) +static inline void hi_lo_writeq (__u64 val,volatile void __iomem *addr) {writel (val >>32 , addr +4 );writel (val, addr); } + +#ifndef readq +#define readq hi_lo_readq +#endif + +#ifndef writeq +#define writeq hi_lo_writeq#endif #endif /* _ASM_IO_64_NONATOMIC_HI_LO_H_ */
include/asm-generic/io-64-nonatomic-lo-hi.h +9 -5
@@ -4,8 +4,7 @@#include <linux/io.h> #include <asm-generic/int-ll64.h> -#ifndef readq -static inline __u64 readq (const volatile void __iomem *addr) +static inline __u64 lo_hi_readq (const volatile void __iomem *addr) {const volatile u32 __iomem *p = addr;u32 low, high;
@@ -15,14 +14,19 @@ static inline __u64 readq(const volatile void __iomem *addr) return low + ((u64)high << 32); } -#endif -#ifndef writeq -static inline void writeq (__u64 val,volatile void __iomem *addr) +static inline void lo_hi_writeq (__u64 val,volatile void __iomem *addr) {writel (val, addr);writel (val >>32 , addr +4 ); } + +#ifndef readq +#define readq lo_hi_readq +#endif + +#ifndef writeq +#define writeq lo_hi_writeq#endif #endif /* _ASM_IO_64_NONATOMIC_LO_HI_H_ */
Signature · 1 line
1.8.2.rc2
Re: [PATCH v2 1/3] readq/writeq: Add explicit lo_hi_[read|write]_q and hi_lo_[read|write]_q
Quoted 8 lines · Jason Baron
Even on x86-64, I've found the need to break up a
readq()into 2readl()calls. According to the Intel datasheet for the E3-1200 processor:"
Software must not access B0/D0/F0 32-bit memory-mapped registers with requests that cross a DW boundary.
"
Quoted 8 lines
(http://www.intel.com/content/www/us/en/processors/xeon/xeon-e3-1200-family-vol-2-datasheet.html p. 16)
I can confirm this is true via several hard machine lockups.
Thus, add explicit hi_lo_[readq|write]_q and lo_hi_[read|write]_q so that these uses are spelled out.
Signed-off-by Jason Baron <[email protected]>
Applied, thanks.
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Jason Baron
maintainerPATCH v2 2/3 x38_edac: make use of lo_hi_readq()
In reply to Jason BaronConvert to the generic API.
--- drivers/edac/x38_edac.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/edac/x38_edac.c +6 -9
@@ -14,6 +14,8 @@#include <linux/pci.h> #include <linux/pci_ids.h> #include <linux/edac.h> + +#include <asm-generic/io-64-nonatomic-lo-hi.h> #include "edac_core.h" #define X38_REVISION "1.1"
@@ -161,11 +163,6 @@ static void x38_clear_error_info(struct mem_ctl_info *mci) X38_ERRSTS_BITS); } -static u64 x38_readq (const void __iomem *addr) -{ -return readl (addr) | (((u64 )readl (addr +4 )) <<32 ); -} -static void x38_get_and_clear_error_info (struct mem_ctl_info *mci,struct x38_error_info *info) {
@@ -183,9 +180,9 @@ static void x38_get_and_clear_error_info(struct mem_ctl_info *mci,if (!(info->errsts &X38_ERRSTS_BITS ))return ; - info->eccerrlog[0 ] =x38_readq (window +X38_C0ECCERRLOG ); + info->eccerrlog[0 ] =lo_hi_readq (window +X38_C0ECCERRLOG );if (x38_channel_num ==2 ) - info->eccerrlog[1 ] =x38_readq (window +X38_C1ECCERRLOG ); + info->eccerrlog[1 ] =lo_hi_readq (window +X38_C1ECCERRLOG );pci_read_config_word (pdev,X38_ERRSTS , &info->errsts2);
@@ -196,10 +193,10 @@ static void x38_get_and_clear_error_info(struct mem_ctl_info *mci,* should be UE info. */ if ((info->errsts ^ info->errsts2) &X38_ERRSTS_BITS ) { - info->eccerrlog[0 ] =x38_readq (window +X38_C0ECCERRLOG ); + info->eccerrlog[0 ] =lo_hi_readq (window +X38_C0ECCERRLOG );if (x38_channel_num ==2 ) info->eccerrlog[1 ] = -x38_readq (window +X38_C1ECCERRLOG ); +lo_hi_readq (window +X38_C1ECCERRLOG ); }x38_clear_error_info (mci);
Signature · 1 line
1.8.2.rc2
Re: [PATCH v2 2/3] x38_edac: make use of lo_hi_readq()
Quoted 4 lines · Jason Baron
Convert to the generic API.
Signed-off-by Jason Baron <[email protected]>---
Applied, thanks.
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Jason Baron
maintainerPATCH v2 3/3 ie31200_edac: Introduce the driver
In reply to Jason BaronAdd 'ie31200_edac' driver for the E3-1200 series of Intel DRAM controllers. Driver is based on the following E3-1200 specs:
http://www.intel.com/content/www/us/en/processors/xeon/xeon-e3-1200-family-vol-2-datasheet.html
http://www.intel.com/content/www/us/en/processors/xeon/xeon-e3-1200v3-vol-2-datasheet.html
I've tested this on bad memory hardware, and observed correlating bad reads and uncorrected memory errors as reported by the driver.
Tested against:
CPU E3-1270 v3 @ 3.50GHz : 8086:0c08 (haswell)
CPU E3-1270 V2 @ 3.50GHz : 8086:0158 (ivy bridge)
CPU E31270 @ 3.40GHz : 8086:0108 (sandy bridge)
--- drivers/edac/Kconfig | 7 + drivers/edac/Makefile | 1 + drivers/edac/ie31200_edac.c | 542 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 550 insertions(+) create mode 100644 drivers/edac/ie31200_edac.c
drivers/edac/Kconfig +7 -0
@@ -186,6 +186,13 @@ config EDAC_I3200 Support for error detection and correction on the Intel 3200 and 3210 server chipsets. +config EDAC_IE31200 + tristate "Intel e312xx" + depends on EDAC_MM_EDAC && PCI && X86 + help + Support for error detection and correction on the Intel + E3-1200 based DRAM controllers. + config EDAC_X38 tristate "Intel X38" depends on EDAC_MM_EDAC && PCI && X86
drivers/edac/Makefile +1 -0
@@ -37,6 +37,7 @@ obj-$(CONFIG_EDAC_I82875P) += i82875p_edac.o obj-$(CONFIG_EDAC_I82975X) += i82975x_edac.o obj-$(CONFIG_EDAC_I3000) += i3000_edac.o obj-$(CONFIG_EDAC_I3200) += i3200_edac.o +obj-$(CONFIG_EDAC_IE31200) += ie31200_edac.o obj-$(CONFIG_EDAC_X38) += x38_edac.o obj-$(CONFIG_EDAC_I82860) += i82860_edac.o obj-$(CONFIG_EDAC_R82600) += r82600_edac.o
drivers/edac/ie31200_edac.c new file +542 -0
542 lines not on this page · raw message
Signature · 1 line
1.8.2.rc2
Borislav Petkov
maintainerRe: [PATCH v2 3/3] ie31200_edac: Introduce the driver
Quoted 9 lines · Jason Baron
Add '
ie31200_edac' driver for the E3-1200 series of Intel DRAM controllers. Driver is based on the following E3-1200 specs:http://www.intel.com/content/www/us/en/processors/xeon/xeon-e3-1200-family-vol-2-datasheet.html
http://www.intel.com/content/www/us/en/processors/xeon/xeon-e3-1200v3-vol-2-datasheet.htmlI've tested this on bad memory hardware, and observed correlating bad reads and uncorrected memory errors as reported by the driver.
Quoted 7 lines
Tested against:
CPU E3-1270 v3 @ 3.50GHz : 8086:0c08 (haswell)
CPU E3-1270 V2 @ 3.50GHz : 8086:0158 (ivy bridge)
CPU E31270 @ 3.40GHz : 8086:0108 (sandy bridge)Signed-off-by Jason Baron <[email protected]>
Applied albeit with some remarks, see below.
Quoted 128 lines
drivers/edac/ie31200_edac.c new file +122
-0@@ -0,0 +1,542 @@ +/* +* Intel E3-1200 +* Copyright (C) 2014 Jason Baron <[email protected]> +* +* Support for the E3-1200 processor family. Heavily based on previous +* Intel EDAC drivers. +* +* Since the DRAM controller is on the cpu chip, we can use its PCI device +* id to identify these processors. +* +* PCI DRAM controller device ids (Taken from The PCI ID Repository - http://pci-ids.ucw.cz/) +* +* 0108: Xeon E3-1200 Processor Family DRAM Controller +* 010c: Xeon E3-1200/2nd Generation Core Processor Family DRAM Controller +* 0150: Xeon E3-1200 v2/3rd Gen Core processor DRAM Controller +* 0158: Xeon E3-1200 v2/Ivy Bridge DRAM Controller +* 015c: Xeon E3-1200 v2/3rd Gen Core processor DRAM Controller +* 0c04: Xeon E3-1200 v3/4th Gen Core Processor DRAM Controller +* 0c08: Xeon E3-1200 v3 Processor DRAM Controller +* +* Based on Intel specification: +* http://www.intel.com/content/dam/www/public/us/en/documents/datasheets/xeon-e3-1200v3-vol-2-datasheet.pdf +* http://www.intel.com/content/www/us/en/processors/xeon/xeon-e3-1200-family-vol-2-datasheet.html +* +* According to the above datasheet (p.16): +* " +* 6. Software must not access B0/D0/F0 32-bit memory-mapped registers with +* requests that cross a DW boundary. +* " +* +* Thus, we make use of the explicit: lo_hi_readq(), which breaks the readq into +* 2 readl() calls. This restriction may be lifted in subsequent chip releases, +* but lo_hi_readq() ensures that we are safe across all e3-1200 processors. +*/ + +#include <linux/module.h> +#include <linux/init.h> +#include <linux/pci.h> +#include <linux/pci_ids.h> +#include <linux/edac.h> + +#include <asm-generic/io-64-nonatomic-lo-hi.h> +#include "edac_core.h" + +#define IE31200_REVISION "1.0" +#define EDAC_MOD_STR "ie31200_edac" + +#define ie31200_printk(level, fmt, arg...) \ + edac_printk(level, "ie31200", fmt, ##arg) + +#define PCI_DEVICE_ID_INTEL_IE31200_HB_1 0x0108 +#define PCI_DEVICE_ID_INTEL_IE31200_HB_2 0x010c +#define PCI_DEVICE_ID_INTEL_IE31200_HB_3 0x0150 +#define PCI_DEVICE_ID_INTEL_IE31200_HB_4 0x0158 +#define PCI_DEVICE_ID_INTEL_IE31200_HB_5 0x015c +#define PCI_DEVICE_ID_INTEL_IE31200_HB_6 0x0c04 +#define PCI_DEVICE_ID_INTEL_IE31200_HB_7 0x0c08 + +#define IE31200_DIMMS 4 +#define IE31200_RANKS 8 +#define IE31200_RANKS_PER_CHANNEL 4 +#define IE31200_DIMMS_PER_CHANNEL 2 +#define IE31200_CHANNELS 2 + +/* Intel IE31200 register addresses - device 0 function 0 - DRAM Controller */ +#define IE31200_MCHBAR_LOW 0x48 +#define IE31200_MCHBAR_HIGH 0x4c +#define IE31200_MCHBAR_MASK GENMASK_ULL(38, 15) +#define IE31200_MMR_WINDOW_SIZE (1 << 15) + +/* +* Error Status Register (16b) +* +* 15 reserved +* 14 Isochronous TBWRR Run Behind FIFO Full +* (ITCV) +* 13 Isochronous TBWRR Run Behind FIFO Put +* (ITSTV) +* 12 reserved +* 11 MCH Thermal Sensor Event +* for SMI/SCI/SERR (GTSE) +* 10 reserved +* 9 LOCK to non-DRAM Memory Flag (LCKF) +* 8 reserved +* 7 DRAM Throttle Flag (DTF) +* 6:2 reserved +* 1 Multi-bit DRAM ECC Error Flag (DMERR) +* 0 Single-bit DRAM ECC Error Flag (DSERR) +*/ +#define IE31200_ERRSTS 0xc8 +#define IE31200_ERRSTS_UE BIT(1) +#define IE31200_ERRSTS_CE BIT(0) +#define IE31200_ERRSTS_BITS (IE31200_ERRSTS_UE | IE31200_ERRSTS_CE) + +/* +* Channel 0 ECC Error Log (64b) +* +* 63:48 Error Column Address (ERRCOL) +* 47:32 Error Row Address (ERRROW) +* 31:29 Error Bank Address (ERRBANK) +* 28:27 Error Rank Address (ERRRANK) +* 26:24 reserved +* 23:16 Error Syndrome (ERRSYND) +* 15: 2 reserved +* 1 Multiple Bit Error Status (MERRSTS) +* 0 Correctable Error Status (CERRSTS) +*/ +#define IE31200_C0ECCERRLOG 0x40c8 +#define IE31200_C1ECCERRLOG 0x44c8 +#define IE31200_ECCERRLOG_CE BIT(0) +#define IE31200_ECCERRLOG_UE BIT(1) +#define IE31200_ECCERRLOG_RANK_BITS GENMASK_ULL(28, 27) +#define IE31200_ECCERRLOG_RANK_SHIFT 27 +#define IE31200_ECCERRLOG_SYNDROME_BITS GENMASK_ULL(23, 16) +#define IE31200_ECCERRLOG_SYNDROME_SHIFT 16 + +#define IE31200_ECCERRLOG_SYNDROME (log) \ + ((log & IE31200_ECCERRLOG_SYNDROME_BITS) >> \ + IE31200_ECCERRLOG_SYNDROME_SHIFT) + +#define IE31200_CAPID0 0xe4 +#define IE31200_CAPID0_PDCD BIT(4)
drivers/edac/ie31200_edac.c line 132
Quoted 10 lines
drivers/edac/ie31200_edac.c new file +10
-0+#define IE31200_CAPID0_DDPCD BIT(6) +#define IE31200_CAPID0_ECC BIT(1) + +#define IE31200_MAD_DIMM_0_OFFSET 0x5004 +#define IE31200_MAD_DIMM_SIZE GENMASK_ULL(7, 0) +#define IE31200_MAD_DIMM_A_RANK BIT(17) +#define IE31200_MAD_DIMM_A_WIDTH BIT(19) + +#define IE31200_PAGES (n) \ + (n << (28 - PAGE_SHIFT))
I realigned all those defines, see attached final patch.
...
Quoted 45 lines
drivers/edac/ie31200_edac.c new file +45
-0+static int ie31200_probe1 (struct pci_dev *pdev,int dev_idx) +{ +int rc; +int i, j; +struct mem_ctl_info *mci =NULL ; +struct edac_mc_layer layers[2 ]; +struct dimm_data dimm_info[IE31200_CHANNELS ][IE31200_DIMMS_PER_CHANNEL ]; +void __iomem *window; +struct ie31200_priv *priv; +u32 addr_decode; + +edac_dbg (0 ,"MC:\n" ); + +if (!ecc_capable (pdev)) { +ie31200_printk (KERN_INFO ,"No ECC support\n" ); +return -ENODEV ; + } + + window =ie31200_map_mchbar (pdev); +if (!window) +return -ENODEV ; + +/* populate DIMM info */ +for (i =0 ; i <IE31200_CHANNELS ; i++) { + addr_decode =readl (window +IE31200_MAD_DIMM_0_OFFSET + + (i *4 )); +edac_dbg (0 ,"addr_decode: 0x%x\n" , addr_decode); +for (j =0 ; j <IE31200_DIMMS_PER_CHANNEL ; j++) { + dimm_info[i][j].size = (addr_decode >> (j *8 )) & +IE31200_MAD_DIMM_SIZE ; + dimm_info[i][j].dual_rank = (addr_decode & + (IE31200_MAD_DIMM_A_RANK << j)) ?1 :0 ; + dimm_info[i][j].x16_width = (addr_decode & + (IE31200_MAD_DIMM_A_WIDTH << j)) ?1 :0 ; +edac_dbg (0 ,"size: 0x%x, rank: %d, width: %d\n" , + dimm_info[i][j].size, + dimm_info[i][j].dual_rank, + dimm_info[i][j].x16_width); + } + } + + nr_channels =how_many_channels (pdev); + + layers[0 ].type =EDAC_MC_LAYER_CHIP_SELECT ; + layers[0 ].size =IE31200_DIMMS ;
drivers/edac/ie31200_edac.c line 187
Quoted 10 lines
drivers/edac/ie31200_edac.c new file +10
-0+ layers[0 ].is_virt_csrow = true; + layers[1 ].type =EDAC_MC_LAYER_CHANNEL ; + layers[1 ].size = nr_channels; + layers[1 ].is_virt_csrow = false; + mci =edac_mc_alloc (0 ,ARRAY_SIZE (layers), layers, +sizeof (struct ie31200_priv )); + + rc = -ENOMEM ; +if (!mci) + goto fail_unmap;
Just an idea:
You can move the edac_mc_alloc() allocation before mapping of the mchbar so that in the failure path you can save yourself all the work you've done in populating dimm info above needlessly.
But you can do that in a follow-on patch along with the MAINTAINERS one. You could use the for-next branch here as a base:
git://git.kernel.org/pub/scm/linux/kernel/git/bp/bp.git
Thanks.
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Quoted 1 line
From
7ee40b897d18ab03111eda9a6a0550e98166eadaMon Sep 17 00:00:00 2001
From: Jason Baron <[email protected]>
Date: Fri, 4 Jul 2014 13:48:32 +0200
Subject: [PATCH] ie31200_edac: Introduce the driver
Add a driver for the E3-1200 series of Intel DRAM controllers, based on the following E3-1200 specs:
http://www.intel.com/content/www/us/en/processors/xeon/xeon-e3-1200-family-vol-2-datasheet.html
http://www.intel.com/content/www/us/en/processors/xeon/xeon-e3-1200v3-vol-2-datasheet.html
I've tested this on bad memory hardware, and observed correlating bad reads and uncorrected memory errors as reported by the driver.
Tested against:
CPU E3-1270 v3 @ 3.50GHz : 8086:0c08 (haswell)
CPU E3-1270 V2 @ 3.50GHz : 8086:0158 (ivy bridge)
CPU E31270 @ 3.40GHz : 8086:0108 (sandy bridge)
--- drivers/edac/Kconfig | 7 + drivers/edac/Makefile | 1 + drivers/edac/ie31200_edac.c | 541 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 549 insertions(+) create mode 100644 drivers/edac/ie31200_edac.c
drivers/edac/Kconfig +7 -0
@@ -186,6 +186,13 @@ config EDAC_I3200 Support for error detection and correction on the Intel 3200 and 3210 server chipsets. +config EDAC_IE31200 + tristate "Intel e312xx" + depends on EDAC_MM_EDAC && PCI && X86 + help + Support for error detection and correction on the Intel + E3-1200 based DRAM controllers. + config EDAC_X38 tristate "Intel X38" depends on EDAC_MM_EDAC && PCI && X86
drivers/edac/Makefile +1 -0
@@ -37,6 +37,7 @@ obj-$(CONFIG_EDAC_I82875P) += i82875p_edac.o obj-$(CONFIG_EDAC_I82975X) += i82975x_edac.o obj-$(CONFIG_EDAC_I3000) += i3000_edac.o obj-$(CONFIG_EDAC_I3200) += i3200_edac.o +obj-$(CONFIG_EDAC_IE31200) += ie31200_edac.o obj-$(CONFIG_EDAC_X38) += x38_edac.o obj-$(CONFIG_EDAC_I82860) += i82860_edac.o obj-$(CONFIG_EDAC_R82600) += r82600_edac.o
drivers/edac/ie31200_edac.c new file +541 -0
541 lines not on this page · raw message
Signature · 1 line
2.0.0