From: Borislav Petkov <borislav.petkov@amd.com>
To: akpm@linux-foundation.org, greg@kroah.com
Cc: mingo@elte.hu, tglx@linutronix.de, hpa@zytor.com,
dougthompson@xmission.com, <linux-kernel@vger.kernel.org>,
Borislav Petkov <borislav.petkov@amd.com>
Subject: [PATCH 13/21] amd64_edac: add f10-and-later methods-p3
Date: Wed, 29 Apr 2009 18:54:59 +0200 [thread overview]
Message-ID: <1241024107-14535-14-git-send-email-borislav.petkov@amd.com> (raw)
In-Reply-To: <1241024107-14535-1-git-send-email-borislav.petkov@amd.com>
From: Doug Thompson <dougthompson@xmission.com>
Signed-off-by: Doug Thompson <dougthompson@xmission.com>
Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
---
drivers/edac/amd64_edac.c | 318 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 318 insertions(+), 0 deletions(-)
diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
index fe2342c..84075c0 100644
--- a/drivers/edac/amd64_edac.c
+++ b/drivers/edac/amd64_edac.c
@@ -2726,4 +2726,322 @@ static int f10_lookup_addr_in_dct(u32 InputAddr, u32 NodeID, u32 ChannelSelect)
return CSFound;
}
+/*
+ * f10_match_to_this_node
+ *
+ * For a given 'DramRange' value, check if 'SystemAddr' fall within this value
+ */
+static int f10_match_to_this_node(struct amd64_pvt *pvt, int DramRange,
+ u64 SystemAddr,
+ int *node_id,
+ int *channel_select)
+{
+ int CSFound = -1;
+ int NodeID;
+ int HiRangeSelected;
+ u32 IntlvEn, IntlvSel;
+ u32 DramEn;
+ u32 Ilog;
+ u32 HoleOffset, HoleEn;
+ u32 InputAddr, Temp;
+ u32 DctSelBaseAddr, DctSelIntLvAddr;
+ u32 DctSelHi;
+ u32 ChannelSelect;
+ u64 DramBaseLong, DramLimitLong;
+ u64 DctSelBaseOffsetLong, ChannelAddrLong;
+
+ /* DRAM Base value for this DRAM instance */
+ DramBaseLong = pvt->dram_base[DramRange];
+ DramEn = pvt->dram_rw_en[DramRange];
+ IntlvEn = pvt->dram_IntlvEn[DramRange];
+
+ /* DRAM Limit value for this DRAM instance */
+ DramLimitLong = pvt->dram_limit[DramRange];
+ NodeID = pvt->dram_DstNode[DramRange];
+ IntlvSel = pvt->dram_IntlvSel[DramRange];
+
+ debugf1("%s(dram=%d) Base=0x%llx SystemAddr= 0x%llx Limit=0x%llx\n",
+ __func__, DramRange, DramBaseLong, SystemAddr, DramLimitLong);
+
+ /* This assumes that one node's DHAR is the same as
+ * all the other node's DHARs
+ */
+ HoleEn = pvt->dhar;
+ HoleOffset = (HoleEn & 0x0000FF80);
+ HoleEn = (HoleEn & 0x00000003);
+
+ debugf1(" HoleOffset=0x%x HoleEn=0x%x IntlvSel=0x%x\n",
+ HoleOffset, HoleEn, IntlvSel);
+
+ if ((IntlvEn == 0) || IntlvSel == ((SystemAddr >> 12) & IntlvEn)) {
+
+ Ilog = f10_map_IntlvEn_to_shift(IntlvEn);
+
+ Temp = pvt->dram_ctl_select_low;
+ DctSelBaseOffsetLong = pvt->dram_ctl_select_high << 16;
+
+ DctSelHi = (Temp >> 1) & 1;
+ DctSelIntLvAddr = dct_sel_interleave_addr(pvt);
+ DctSelBaseAddr = dct_sel_baseaddr(pvt);
+
+ if (dct_high_range_enabled(pvt) &&
+ !dct_ganging_enabled(pvt) &&
+ ((SystemAddr >> 27) >= (DctSelBaseAddr >> 11)))
+ HiRangeSelected = 1;
+ else
+ HiRangeSelected = 0;
+
+ ChannelSelect = f10_determine_channel(pvt, SystemAddr,
+ HiRangeSelected, IntlvEn);
+
+ ChannelAddrLong = f10_determine_base_addr_offset(
+ SystemAddr,
+ HiRangeSelected,
+ DctSelBaseAddr,
+ DctSelBaseOffsetLong,
+ HoleEn,
+ HoleOffset,
+ DramBaseLong);
+
+ /* Remove Node ID (in case of processor interleaving) */
+ Temp = ChannelAddrLong & 0xFC0;
+
+ ChannelAddrLong = ((ChannelAddrLong >> Ilog) &
+ 0xFFFFFFFFF000ULL) | Temp;
+
+ /* Remove Channel interleave and hash */
+ if (dct_interleave_enabled(pvt) &&
+ !dct_high_range_enabled(pvt) &&
+ !dct_ganging_enabled(pvt)) {
+ if (DctSelIntLvAddr != 1)
+ ChannelAddrLong =
+ (ChannelAddrLong >> 1) &
+ 0xFFFFFFFFFFFFFFC0ULL;
+ else {
+ Temp = ChannelAddrLong & 0xFC0;
+ ChannelAddrLong =
+ ((ChannelAddrLong &
+ 0xFFFFFFFFFFFFC000ULL)
+ >> 1) | Temp;
+ }
+ }
+
+ /* Form a normalize InputAddr (Move bits 36:8 down to 28:0
+ * which will set it up to match the DCT Base register
+ */
+ InputAddr = ChannelAddrLong >> 8;
+
+ debugf1(" (ChannelAddrLong=0x%llx) >> 8 becomes "
+ "InputAddr=0x%x\n", ChannelAddrLong, InputAddr);
+
+ /* Iterate over the DRAM DCTs looking for a
+ * match for InputAddr on the selected NodeID
+ */
+ CSFound = f10_lookup_addr_in_dct(InputAddr,
+ NodeID, ChannelSelect);
+
+ if (CSFound >= 0) {
+ *node_id = NodeID;
+ *channel_select = ChannelSelect;
+ }
+ }
+
+ return CSFound;
+}
+
+static int f10_translate_sysaddr_to_CS(struct amd64_pvt *pvt,
+ u64 SysAddr,
+ int *node,
+ int *chanSel)
+{
+ int DramRange;
+ int CSFound = -1;
+ u64 DramBaseLong, DramLimitLong;
+
+ for (DramRange = 0; DramRange < DRAM_REG_COUNT; DramRange++) {
+
+ if (!pvt->dram_rw_en[DramRange])
+ continue;
+
+ DramBaseLong = pvt->dram_base[DramRange];
+ DramLimitLong = pvt->dram_limit[DramRange];
+
+ if ((DramBaseLong <= SysAddr) && (SysAddr <= DramLimitLong)) {
+
+ CSFound = f10_match_to_this_node(pvt,
+ DramRange, SysAddr,
+ node, chanSel);
+ if (CSFound >= 0)
+ break;
+ }
+ }
+ return CSFound;
+}
+
+/*
+ * f10_map_sysaddr_to_csrow
+ *
+ * This the F10 reference code from AMD to
+ * map a SystemAddress to NodeID, CSROW, Channel
+ *
+ * See the Family 10h BKDG (with bug fixes in the code from AMD)
+ *
+ * The SystemAddress is usually an error address received from the
+ * hardware error detector.
+ */
+static void f10_map_sysaddr_to_csrow(struct mem_ctl_info *mci,
+ struct amd64_error_info_regs *info,
+ u64 SystemAddress)
+{
+ struct amd64_pvt *pvt = mci->pvt_info;
+ u32 page, offset;
+ unsigned short syndrome;
+ int chan = 0;
+ int node_id;
+ int csrow;
+
+ csrow = f10_translate_sysaddr_to_CS(pvt,
+ SystemAddress,
+ &node_id,
+ &chan);
+
+ if (csrow >= 0) {
+ error_address_to_page_and_offset(SystemAddress, &page, &offset);
+
+ syndrome = EXTRACT_HIGH_SYNDROME(info->nbsl) << 8;
+ syndrome |= EXTRACT_LOW_SYNDROME(info->nbsh);
+
+ /* Is CHIPKILL ON?
+ * If so, then we can attempt to use the 'syndrome' to isolate
+ * which channel the error was on
+ */
+ if (pvt->nbcfg & K8_NBCFG_CHIPKILL)
+ chan = get_channel_from_ecc_syndrome(syndrome);
+
+ if (chan >= 0) {
+ edac_mc_handle_ce(mci, page, offset, syndrome,
+ csrow, chan, EDAC_MOD_STR);
+ } else {
+ /* Channel is not known,
+ * report all channels on this CSROW as failed.
+ */
+ for (chan = 0; chan < mci->csrows[csrow].nr_channels;
+ chan++) {
+ edac_mc_handle_ce(mci, page, offset,
+ syndrome,
+ csrow, chan,
+ EDAC_MOD_STR);
+ }
+ }
+
+ } else {
+ edac_mc_handle_ce_no_info(mci, EDAC_MOD_STR);
+ }
+}
+
+/* map_dbam_to_csrow_size
+ *
+ * Input (index) is the DBAM DIMM value (1 of 4) used as an index into a
+ * shift table (revf_quad_ddr2_shift) which starts at 128MB DIMM size.
+ *
+ * Index of 0 indicates an empty DIMM slot, as reported by Hardware on
+ * empty slots.
+ *
+ * Normalize to 128MB by subracting 27 bit shift
+ */
+static int map_dbam_to_csrow_size(int index)
+{
+ int mega_bytes = 0;
+
+ if (index > 0 && index <= DBAM_MAX_VALUE)
+ mega_bytes = ((128 << (revf_quad_ddr2_shift[index]-27)));
+
+ return mega_bytes;
+}
+
+/*
+ * f10_debug_display_dimm_sizes
+ *
+ * debug routine to display the memory sizes of a DIMM
+ * (ganged or not) and it CSROWs as well
+ */
+static void f10_debug_display_dimm_sizes(int ctrl,
+ struct amd64_pvt *pvt, int ganged)
+{
+ int dimm;
+ int size0;
+ int size1;
+ u32 dbam;
+ u32 *dcsb;
+
+ debugf1(" dbam%d: 0x%8.08x CSROW is %s\n", ctrl,
+ ctrl ? pvt->dbam1 : pvt->dbam0,
+ ganged ? "GANGED - dbam1 not used" : "NON-GANGED");
+
+ dbam = ctrl ? pvt->dbam1 : pvt->dbam0;
+ dcsb = ctrl ? pvt->dcsb1 : pvt->dcsb0;
+
+ /* Dump memory sizes for DIMM and its CSROWs */
+ for (dimm = 0; dimm < 4; dimm++) {
+
+ size0 = 0;
+ if (dcsb[dimm*2] & K8_DCSB_CS_ENABLE)
+ size0 = map_dbam_to_csrow_size(DBAM_DIMM(dimm, dbam));
+
+ size1 = 0;
+ if (dcsb[dimm*2 + 1] & K8_DCSB_CS_ENABLE)
+ size1 = map_dbam_to_csrow_size(DBAM_DIMM(dimm, dbam));
+
+ debugf1(" CTRL-%d DIMM-%d=%5dMB CSROW-%d=%5dMB "
+ "CSROW-%d=%5dMB\n",
+ ctrl,
+ dimm,
+ size0 + size1,
+ dimm * 2,
+ size0,
+ dimm * 2 + 1,
+ size1);
+ }
+}
+
+/*
+ * f10_probe_valid_hardware
+ *
+ * Very early hardware probe on pci_probe thread to determine if this module can
+ * support the hardware.
+ *
+ * Return:
+ * 0 for OK
+ * 1 for error
+ */
+static int f10_probe_valid_hardware(struct amd64_pvt *pvt)
+{
+ int rc = 0;
+
+ /*
+ * If we are on a DDR3 machine, we don't know yet if
+ * we support that properly at this time
+ */
+ if ((pvt->dchr0 & F10_DCHR_Ddr3Mode) ||
+ (pvt->dchr1 & F10_DCHR_Ddr3Mode)) {
+
+ amd64_printk(KERN_WARNING,
+ "%s() This machine is running with DDR3 memory. "
+ "This is not currently supported. "
+ "DCHR0=0x%x DCHR1=0x%x\n",
+ __func__, pvt->dchr0, pvt->dchr1);
+
+ amd64_printk(KERN_WARNING,
+ " Contact '%s' module MAINTAINER to help add"
+ " support.\n",
+ EDAC_MOD_STR);
+
+ rc = 1;
+
+ } else {
+ debugf0("%s() DDR2 Memory Installed\n", __func__);
+ }
+
+ return rc;
+}
--
1.6.2.4
next prev parent reply other threads:[~2009-04-29 16:59 UTC|newest]
Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-29 16:54 [RFC PATCH 00/21 v2] amd64_edac: EDAC module for AMD64 Borislav Petkov
2009-04-29 16:54 ` [PATCH 01/21] x86: add methods for writing of an MSR on several CPUs Borislav Petkov
2009-04-29 17:39 ` H. Peter Anvin
2009-05-04 16:46 ` Borislav Petkov
2009-05-04 17:25 ` H. Peter Anvin
2009-05-04 17:53 ` Borislav Petkov
2009-05-04 20:51 ` Mauro Carvalho Chehab
2009-04-29 16:54 ` [PATCH 02/21] amd64_edac: add PCI config register defines Borislav Petkov
2009-05-04 20:54 ` Mauro Carvalho Chehab
2009-04-29 16:54 ` [PATCH 03/21] amd64_edac: add driver structs Borislav Petkov
2009-05-04 20:38 ` Mauro Carvalho Chehab
2009-04-29 16:54 ` [PATCH 04/21] amd64_edac: add memory scrubber interface Borislav Petkov
2009-05-04 21:02 ` Mauro Carvalho Chehab
2009-04-29 16:54 ` [PATCH 05/21] amd64_edac: add sys addr to memory controller mapping helpers Borislav Petkov
2009-05-04 21:08 ` Mauro Carvalho Chehab
2009-04-29 16:54 ` [PATCH 06/21] amd64_edac: add functionality to compute the DRAM hole Borislav Petkov
2009-05-04 21:22 ` Mauro Carvalho Chehab
2009-04-29 16:54 ` [PATCH 07/21] amd64_edac: add DRAM address type conversion facilities Borislav Petkov
2009-05-04 21:39 ` Mauro Carvalho Chehab
2009-04-29 16:54 ` [PATCH 08/21] amd64_edac: add helper to dump relevant registers Borislav Petkov
2009-05-04 21:43 ` Mauro Carvalho Chehab
2009-04-29 16:54 ` [PATCH 09/21] amd64_edac: assign DRAM chip select base and mask in a family-specific way Borislav Petkov
2009-05-04 21:59 ` Mauro Carvalho Chehab
2009-05-05 10:25 ` Borislav Petkov
2009-04-29 16:54 ` [PATCH 10/21] amd64_edac: add k8-specific methods Borislav Petkov
2009-05-04 22:06 ` Mauro Carvalho Chehab
2009-04-29 16:54 ` [PATCH 11/21] amd64_edac: add f10-and-later methods-p1 Borislav Petkov
2009-05-04 22:10 ` Mauro Carvalho Chehab
2009-04-29 16:54 ` [PATCH 12/21] amd64_edac: add f10-and-later methods-p2 Borislav Petkov
2009-05-04 23:25 ` Mauro Carvalho Chehab
2009-04-29 16:54 ` Borislav Petkov [this message]
2009-04-29 18:22 ` [PATCH 13/21] amd64_edac: add f10-and-later methods-p3 Ingo Molnar
2009-04-29 18:24 ` Ingo Molnar
2009-04-29 19:05 ` Andrew Morton
2009-04-29 19:23 ` Ingo Molnar
2009-04-29 19:42 ` Andrew Morton
2009-04-29 19:53 ` Ingo Molnar
2009-04-29 20:47 ` Ingo Molnar
2009-04-30 10:01 ` Borislav Petkov
2009-04-30 10:42 ` Ingo Molnar
2009-05-04 23:36 ` Mauro Carvalho Chehab
2009-04-29 16:55 ` [PATCH 14/21] amd64_edac: add per-family descriptors Borislav Petkov
2009-05-04 23:39 ` Mauro Carvalho Chehab
2009-04-29 16:55 ` [PATCH 15/21] amd64_edac: add ECC chipkill syndrome mapping table Borislav Petkov
2009-05-04 23:42 ` Mauro Carvalho Chehab
2009-04-29 16:55 ` [PATCH 16/21] amd64_edac: add error decoding logic Borislav Petkov
2009-04-29 18:19 ` Ingo Molnar
2009-05-04 23:48 ` Mauro Carvalho Chehab
2009-04-29 16:55 ` [PATCH 17/21] amd64_edac: add EDAC core-related initializers Borislav Petkov
2009-05-04 23:53 ` Mauro Carvalho Chehab
2009-04-29 16:55 ` [PATCH 18/21] amd64_edac: add ECC reporting initializers Borislav Petkov
2009-05-04 23:59 ` Mauro Carvalho Chehab
2009-04-29 16:55 ` [PATCH 19/21] amd64_edac: add debugging/testing code Borislav Petkov
2009-04-29 18:18 ` Ingo Molnar
2009-04-29 16:55 ` [PATCH 20/21] amd64_edac: add DRAM error injection logic using sysfs Borislav Petkov
2009-04-29 18:17 ` Ingo Molnar
2009-05-05 0:06 ` Mauro Carvalho Chehab
2009-04-29 16:55 ` [PATCH 21/21] amd64_edac: add module registration routines Borislav Petkov
2009-05-05 0:10 ` Mauro Carvalho Chehab
2009-04-29 19:30 ` [RFC PATCH 00/21 v2] amd64_edac: EDAC module for AMD64 Andi Kleen
2009-04-30 11:57 ` Borislav Petkov
2009-04-30 12:21 ` Ingo Molnar
2009-04-30 12:47 ` Andi Kleen
2009-04-30 14:48 ` Aristeu Rozanski
2009-05-01 7:53 ` Borislav Petkov
2009-05-03 0:32 ` Aristeu Rozanski
2009-04-30 18:37 ` Mauro Carvalho Chehab
2009-05-01 12:39 ` Ingo Molnar
-- strict thread matches above, loose matches on Subject: below --
2009-04-30 6:21 [PATCH 13/21] amd64_edac: add f10-and-later methods-p3 Doug Thompson
2009-05-05 19:30 Doug Thompson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1241024107-14535-14-git-send-email-borislav.petkov@amd.com \
--to=borislav.petkov@amd.com \
--cc=akpm@linux-foundation.org \
--cc=dougthompson@xmission.com \
--cc=greg@kroah.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox