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 12/21] amd64_edac: add f10-and-later methods-p2
Date: Wed, 29 Apr 2009 18:54:58 +0200 [thread overview]
Message-ID: <1241024107-14535-13-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 | 239 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 239 insertions(+), 0 deletions(-)
diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
index 2658852..fe2342c 100644
--- a/drivers/edac/amd64_edac.c
+++ b/drivers/edac/amd64_edac.c
@@ -2488,3 +2488,242 @@ static void f10_read_dram_base_limit(struct amd64_pvt *pvt, int dram)
pvt->dram_limit[dram] =
((((u64) high_limit << 32) + (u64) low_limit) << 8) | (0xFF);
}
+
+/*
+ * f10_read_dram_ctl_register
+ * Read DRAM Controller Select registers for the F10 that are NOT
+ * in the K8 series
+ */
+static void f10_read_dram_ctl_register(struct amd64_pvt *pvt)
+{
+ int err;
+
+ err = pci_read_config_dword(pvt->dram_f2_ctl,
+ F10_DCTL_SEL_LOW,
+ &pvt->dram_ctl_select_low);
+ if (err != 0) {
+ debugf0("%s() Reading F10_DCTL_SEL_LOW failed\n", __func__);
+ } else {
+ debugf0("%s() DRAM_DCTL_SEL_LOW=0x%x DctSelBaseAddr=0x%x\n",
+ __func__,
+ pvt->dram_ctl_select_low,
+ dct_sel_baseaddr(pvt));
+
+ debugf0(" DRAM DCTs are=%s DRAM Is=%s DRAM-Ctl-"
+ "sel-hi-range=%s\n",
+ (dct_ganging_enabled(pvt) ? "GANGED "
+ : "NOT GANGED "),
+ (dct_dram_enabled(pvt) ? "Enabled "
+ : "Disabled "),
+ (dct_high_range_enabled(pvt) ? "Enabled "
+ : "Disabled "));
+
+ debugf0(" DctDatIntLv=%s MemCleared=%s "
+ "DctSelIntLvAddr=0x%x\n",
+ (dct_data_interleave_enabled(pvt) ? "Enabled "
+ : "Disabled"),
+ (dct_memory_cleared(pvt) ? "True " : "False "),
+ dct_sel_interleave_addr(pvt));
+ }
+
+ err = pci_read_config_dword(pvt->dram_f2_ctl,
+ F10_DCTL_SEL_HIGH,
+ &pvt->dram_ctl_select_high);
+ if (err != 0)
+ debugf0("%s() Reading F10_DCTL_SEL_HIGH failed\n",
+ __func__);
+ debugf0("%s() DRAM_CTL_SELECT_HIGH=0x%x\n", __func__,
+ pvt->dram_ctl_select_high);
+}
+
+static u32 f10_determine_channel(struct amd64_pvt *pvt, u64 SystemAddr,
+ int HiRangeSelected, u32 IntlvEn)
+{
+ u32 ChannelSelect;
+ u32 temp = pvt->dram_ctl_select_low;
+ u32 DctSelIntLvAddr, interleave;
+ u32 DctSelHi;
+
+ interleave = dct_interleave_enabled(pvt);
+ DctSelIntLvAddr = dct_sel_interleave_addr(pvt);
+ DctSelHi = (temp >> 1) & 1;
+
+ if (dct_ganging_enabled(pvt))
+ ChannelSelect = 0;
+ else if (HiRangeSelected)
+ ChannelSelect = DctSelHi;
+ else if (interleave) {
+ if (DctSelIntLvAddr == 0)
+ ChannelSelect = SystemAddr >> 6 & 1;
+ else if ((DctSelIntLvAddr >> 1) & 1) {
+ temp = popcnt((u32) ((SystemAddr >> 16) & 0x1F)) % 2;
+
+ if (DctSelIntLvAddr & 1)
+ ChannelSelect = (SystemAddr >> 9 & 1) ^ temp;
+ else
+ ChannelSelect = (SystemAddr >> 6 & 1) ^ temp;
+ } else if (IntlvEn & 4)
+ ChannelSelect = SystemAddr >> 15 & 1;
+ else if (IntlvEn & 2)
+ ChannelSelect = SystemAddr >> 14 & 1;
+ else if (IntlvEn & 1)
+ ChannelSelect = SystemAddr >> 13 & 1;
+ else
+ ChannelSelect = SystemAddr >> 12 & 1;
+ } else if (dct_high_range_enabled(pvt) && !dct_ganging_enabled(pvt))
+ ChannelSelect = ~DctSelHi & 1;
+ else
+ ChannelSelect = 0;
+
+ return ChannelSelect;
+}
+
+static inline u32 f10_map_IntlvEn_to_shift(u32 IntlvEn)
+{
+ u32 shift;
+
+ if (IntlvEn == 1)
+ shift = 1;
+ else if (IntlvEn == 3)
+ shift = 2;
+ else if (IntlvEn == 7)
+ shift = 3;
+ else
+ shift = 0;
+
+ return shift;
+}
+
+static inline u64 f10_determine_base_addr_offset(
+ u64 SystemAddr,
+ int HiRangeSelected,
+ u32 DctSelBaseAddr,
+ u64 DctSelBaseOffsetLong,
+ u32 HoleEn,
+ u32 HoleOffset,
+ u64 DramBaseLong)
+{
+ u64 ChannelAddrLong;
+ u64 ChannelOffsetLong;
+
+ if (HiRangeSelected) {
+ if ((!DctSelBaseAddr & 0xFFFF0000) &&
+ (HoleEn & 1) && (SystemAddr >= 0x100000000ULL))
+ ChannelOffsetLong = HoleOffset << 16;
+ else
+ ChannelOffsetLong = DctSelBaseOffsetLong;
+ } else {
+ if ((HoleEn & 1) && (SystemAddr >= 0x100000000ULL))
+ ChannelOffsetLong = HoleOffset << 16;
+ else
+ ChannelOffsetLong = DramBaseLong & 0xFFFFF8000000ULL;
+ }
+
+ ChannelAddrLong = (SystemAddr & 0x0000FFFFFFFFFFC0ULL) -
+ (ChannelOffsetLong & 0x0000FFFFFF800000ULL);
+
+ return ChannelAddrLong;
+}
+
+/* Hack for the time being - Can we get this from BIOS?? */
+#define CH0SPARE_RANK 0
+#define CH1SPARE_RANK 1
+
+/*
+ * f10_process_possible_spare
+ *
+ * checks if the csrow passed in is marked as SPARED, if so
+ * returns the new spare row
+ */
+static inline int f10_process_possible_spare(int csrow,
+ u32 ChannelSelect, struct amd64_pvt *pvt)
+{
+ u32 SwapDone;
+ u32 BadDramCs;
+ u32 OnLineSpareCTL;
+
+ OnLineSpareCTL = pvt->online_spare;
+
+ /* Depending on channel, isolate respective SPARING info */
+ if (ChannelSelect) {
+ SwapDone = F10_ONLINE_SPARE_SWAPDONE1(OnLineSpareCTL);
+ BadDramCs = F10_ONLINE_SPARE_BADDRAM_CS1(OnLineSpareCTL);
+ if (SwapDone && (csrow == BadDramCs))
+ csrow = CH1SPARE_RANK;
+ } else {
+ SwapDone = F10_ONLINE_SPARE_SWAPDONE0(OnLineSpareCTL);
+ BadDramCs = F10_ONLINE_SPARE_BADDRAM_CS0(OnLineSpareCTL);
+ if (SwapDone && (csrow == BadDramCs))
+ csrow = CH0SPARE_RANK;
+ }
+ return csrow;
+}
+
+/*
+ * f10_lookup_addr_in_dct
+ *
+ * Iterate over the DRAM DCT "base" and "mask" register looking for
+ * a SystemAddr match on the specified 'ChannelSelect' and 'NodeID'
+ *
+ * Return:
+ * -1 NOT FOUND
+ * 0..csrow = Chip-Select Row
+ */
+static int f10_lookup_addr_in_dct(u32 InputAddr, u32 NodeID, u32 ChannelSelect)
+{
+ struct mem_ctl_info *mci;
+ struct amd64_pvt *pvt;
+ u32 CSBase, CSMask;
+ int CSFound = -1;
+ int csrow;
+
+ mci = mci_lookup[NodeID];
+ if (!mci)
+ return CSFound;
+
+ pvt = mci->pvt_info;
+
+ debugf1("%s() InputAddr=0x%x channelselect=%d\n",
+ __func__, InputAddr, ChannelSelect);
+
+ for (csrow = 0; csrow < CHIPSELECT_COUNT; csrow++) {
+
+ CSBase = amd64_get_dct_base(pvt, ChannelSelect, csrow);
+ if (!(CSBase & K8_DCSB_CS_ENABLE))
+ continue;
+
+ /* We have an ENABLED CSROW, Isolate just the MASK
+ * bits of the target: 28:19 and 13:5, which map to
+ * 36:27 and 21:13 of the actual address
+ */
+ CSBase &= REV_F_F1Xh_DCSB_BASE_BITS;
+
+ /* Get the DCT Mask, and ENABLE the reserved bits:
+ * 18:16 and 4:0 to become ON. Then mask off bits
+ * 28:0 (36:8)
+ */
+ CSMask = amd64_get_dct_mask(pvt, ChannelSelect, csrow);
+
+ debugf1(" CSROW=%d CSBase=0x%x RAW CSMask=0x%x\n",
+ csrow, CSBase, CSMask);
+
+ CSMask = (CSMask | 0x0007C01F) & 0x1FFFFFFF;
+
+ debugf1(" Final CSMask=0x%x\n", CSMask);
+ debugf1(" (InputAddr & ~CSMask)=0x%x "
+ "(CSBase & ~CSMask)=0x%x\n",
+ (InputAddr & ~CSMask), (CSBase & ~CSMask));
+
+ /* Perform the lookup MATCH operation */
+ if ((InputAddr & ~CSMask) == (CSBase & ~CSMask)) {
+ CSFound = f10_process_possible_spare(csrow,
+ ChannelSelect, pvt);
+
+ debugf1(" MATCH csrow=%d\n", CSFound);
+ break;
+ }
+ }
+ return CSFound;
+}
+
+
--
1.6.2.4
next prev parent reply other threads:[~2009-04-29 17:00 UTC|newest]
Thread overview: 69+ 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 ` Borislav Petkov [this message]
2009-05-04 23:25 ` [PATCH 12/21] amd64_edac: add f10-and-later methods-p2 Mauro Carvalho Chehab
2009-04-29 16:54 ` [PATCH 13/21] amd64_edac: add f10-and-later methods-p3 Borislav Petkov
2009-04-29 18:22 ` 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-05-05 19:28 [PATCH 12/21] amd64_edac: add f10-and-later methods-p2 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-13-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