From patchwork Fri Sep 13 05:28:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Widawsky X-Patchwork-Id: 2881681 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B0D239F1E3 for ; Fri, 13 Sep 2013 05:38:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C71B620278 for ; Fri, 13 Sep 2013 05:38:39 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id D592E20276 for ; Fri, 13 Sep 2013 05:38:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CA788E6234 for ; Thu, 12 Sep 2013 22:38:38 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail.bwidawsk.net (bwidawsk.net [166.78.191.112]) by gabe.freedesktop.org (Postfix) with ESMTP id C4ADCE63D8 for ; Thu, 12 Sep 2013 22:29:13 -0700 (PDT) Received: by mail.bwidawsk.net (Postfix, from userid 5001) id 52DDE59D14; Thu, 12 Sep 2013 22:29:13 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from lundgren.intel.com (c-24-21-100-90.hsd1.or.comcast.net [24.21.100.90]) by mail.bwidawsk.net (Postfix) with ESMTPSA id F2D3859D0F; Thu, 12 Sep 2013 22:28:56 -0700 (PDT) From: Ben Widawsky To: intel-gfx@lists.freedesktop.org Date: Thu, 12 Sep 2013 22:28:41 -0700 Message-Id: <1379050122-12774-16-git-send-email-benjamin.widawsky@intel.com> X-Mailer: git-send-email 1.8.4 In-Reply-To: <1379050122-12774-1-git-send-email-benjamin.widawsky@intel.com> References: <1379050122-12774-1-git-send-email-benjamin.widawsky@intel.com> Cc: bryan.j.bell@intel.com, Ben Widawsky , Ben Widawsky , vishnu.venkatesh@intel.com Subject: [Intel-gfx] [PATCH 15/16] intel_l3_parity: Support error injection X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org X-Virus-Scanned: ClamAV using ClamSMTP Haswell added the ability to inject errors which is extremely useful for testing. Add two arguments to the tool to inject, and uninject. Signed-off-by: Ben Widawsky --- tests/sysfs_l3_parity | 2 +- tools/intel_l3_parity.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 68 insertions(+), 3 deletions(-) diff --git a/tests/sysfs_l3_parity b/tests/sysfs_l3_parity index a0dfad9..e9d4411 100755 --- a/tests/sysfs_l3_parity +++ b/tests/sysfs_l3_parity @@ -21,7 +21,7 @@ fi $SOURCE_DIR/../tools/intel_l3_parity -r 0 -b 0 -s 0 -e #Check that we can clear remaps -if [ `$SOURCE_DIR/../tools/intel_l3_parity -l | wc -c` != "0" ] ; then +if [ `$SOURCE_DIR/../tools/intel_l3_parity -l | wc -l` != 1 ] ; then echo "Fail 2" exit 1 fi diff --git a/tools/intel_l3_parity.c b/tools/intel_l3_parity.c index cf15541..cd6754e 100644 --- a/tools/intel_l3_parity.c +++ b/tools/intel_l3_parity.c @@ -79,6 +79,20 @@ static int which_slice = -1; (__i) < ((which_slice == -1) ? MAX_SLICES : (which_slice + 1)); \ (__i)++) +static void decode_dft(uint32_t dft) +{ + if (IS_IVYBRIDGE(devid) || !(dft & 1)) { + printf("Error injection disabled\n"); + return; + } + printf("Error injection enabled\n"); + printf(" Hang = %s\n", (dft >> 28) & 0x1 ? "yes" : "no"); + printf(" Row = %d\n", (dft >> 7) & 0x7ff); + printf(" Bank = %d\n", (dft >> 2) & 0x3); + printf(" Subbank = %d\n", (dft >> 4) & 0x7); + printf(" Slice = %d\n", (dft >> 1) & 0x1); +} + static void dumpit(int slice) { int i, j; @@ -150,7 +164,9 @@ static void usage(const char *name) " -l, --list List the current L3 logs\n" " -a, --clear-all Clear all disabled rows\n" " -e, --enable Enable row, bank, subbank (undo -d)\n" - " -d, --disable= Disable row, bank, subbank (inline arguments are deprecated. Please use -r, -b, -s instead\n", + " -d, --disable= Disable row, bank, subbank (inline arguments are deprecated. Please use -r, -b, -s instead\n" + " -i, --inject [HSW only] Cause hardware to inject a row errors\n" + " -u, --uninject [HSW only] Turn off hardware error injectection (undo -i)\n", name); } @@ -158,6 +174,7 @@ int main(int argc, char *argv[]) { const int device = drm_get_card(); char *path[REAL_MAX_SLICES]; + uint32_t dft; int row = 0, bank = 0, sbank = 0; int fd[REAL_MAX_SLICES] = {0}, ret, i; int action = '0'; @@ -167,6 +184,8 @@ int main(int argc, char *argv[]) if (intel_gen(devid) < 7) exit(EXIT_SUCCESS); + assert(intel_register_access_init(intel_get_pci_device(), 0) == 0); + ret = asprintf(&path[0], "/sys/class/drm/card%d/l3_parity", device); assert(ret != -1); ret = asprintf(&path[1], "/sys/class/drm/card%d/l3_parity_slice_1", device); @@ -183,6 +202,7 @@ int main(int argc, char *argv[]) assert(lseek(fd[i], 0, SEEK_SET) == 0); } + dft = intel_register_read(0xb038); while (1) { int c, option_index = 0; @@ -192,6 +212,8 @@ int main(int argc, char *argv[]) { "clear-all", no_argument, 0, 'a' }, { "enable", no_argument, 0, 'e' }, { "disable", optional_argument, 0, 'd' }, + { "inject", no_argument, 0, 'i' }, + { "uninject", no_argument, 0, 'u' }, { "hw-info", no_argument, 0, 'H' }, { "row", required_argument, 0, 'r' }, { "bank", required_argument, 0, 'b' }, @@ -200,7 +222,7 @@ int main(int argc, char *argv[]) {0, 0, 0, 0} }; - c = getopt_long(argc, argv, "hHr:b:s:w:aled::", long_options, + c = getopt_long(argc, argv, "hHr:b:s:w:aled::iu", long_options, &option_index); if (c == -1) break; @@ -215,6 +237,7 @@ int main(int argc, char *argv[]) printf("Number of banks: %d\n", num_banks()); printf("Subbanks per bank: %d\n", NUM_SUBBANKS); printf("Max L3 size: %dK\n", L3_SIZE >> 10); + printf("Has error injection: %s\n", IS_HASWELL(devid) ? "yes" : "no"); exit(EXIT_SUCCESS); case 'r': row = atoi(optarg); @@ -236,6 +259,12 @@ int main(int argc, char *argv[]) if (which_slice >= MAX_SLICES) exit(EXIT_FAILURE); break; + case 'i': + case 'u': + if (!IS_HASWELL(devid)) { + fprintf(stderr, "Error injection supported on HSW+ only\n"); + exit(EXIT_FAILURE); + } case 'd': if (optarg) { ret = sscanf(optarg, "%d,%d,%d", &row, &bank, &sbank); @@ -256,6 +285,23 @@ int main(int argc, char *argv[]) } } + if (action == 'i') { + if (((dft >> 1) & 1) != which_slice) { + fprintf(stderr, "DFT register already has slice %d enabled, and we don't support multiple slices. Try modifying -w; but sometimes the register sticks in the wrong way\n", (dft >> 1) & 1); + exit(EXIT_FAILURE); + } + + if (which_slice == -1) { + fprintf(stderr, "Cannot inject errors to multiple slices (modify -w)\n"); + exit(EXIT_FAILURE); + } + if (dft & 1 && ((dft >> 1) && 1) == which_slice) + printf("warning: overwriting existing injections. This is very dangerous.\n"); + } + + if (action == 'l') + decode_dft(dft); + /* Per slice operations */ for_each_slice(i) { switch (action) { @@ -271,11 +317,30 @@ int main(int argc, char *argv[]) case 'd': assert(disable_rbs(row, bank, sbank, i) == 0); break; + case 'i': + if (bank == 3) { + fprintf(stderr, "The hardware does not support error inject on bank 3.\n"); + exit(EXIT_FAILURE); + } + dft |= row << 7; + dft |= sbank << 4; + dft |= bank << 2; + assert(i < 2); + dft |= i << 1; /* slice */ + dft |= 1 << 0; /* enable */ + intel_register_write(0xb038, dft); + break; + case 'u': + intel_register_write(0xb038, dft & ~(1<<0)); + break; + case 'L': + break; default: abort(); } } + intel_register_access_fini(); if (action == 'l') exit(EXIT_SUCCESS);