From patchwork Wed Aug 29 18:33:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fan Wu X-Patchwork-Id: 10580753 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CB4655A4 for ; Wed, 29 Aug 2018 18:34:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BACE8287E9 for ; Wed, 29 Aug 2018 18:34:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AE33C2B63D; Wed, 29 Aug 2018 18:34:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 604A4287E9 for ; Wed, 29 Aug 2018 18:34:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=stpPTeVUPYXi6HqiSlSehvyldWFajv8k8e3xnLtukH8=; b=e9T AR3lMSEZ5EIeUY31KDdy6LYYKvy82AXUJGW13I7RMO9hTEUJ25KVcKYFl2lSo9jCS7J4n56rHcXpJ wNa2JyAc9uSsPBrnDC7Od7rEUB43tVKn8y9B68qaIxkJ0Sua8l3NHGdokR5Zm837E32z4QUaK48mk rhsZouULPXBjyKt40wYjDioEgF0WiEu58i8elzXB5h+9NsBFx3NYr7urgQ8y0O/kQLsEQq4zgUdX4 Vrj9wDxwZzv2ZJZUnNGhzV0BW2oqrZBhTP6cZUOyzsFKwu+slptBR+ugsI9z7zgK6PAJuFEkQN6dN C3B4mUTNi1rItEBe7jz8wOqMERTpOIw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fv5IB-0003aB-2c; Wed, 29 Aug 2018 18:34:11 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fv5I7-0003Y5-Q0 for linux-arm-kernel@lists.infradead.org; Wed, 29 Aug 2018 18:34:09 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id CFD2360271; Wed, 29 Aug 2018 18:33:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1535567636; bh=umWvDB2GUgXjzPQxybvq5exqOnvpeZPtmBMZgUyFah0=; h=From:To:Cc:Subject:Date:From; b=fXQitN6Kxv/htbwcCHs0BkuU79L9xM6WpQvMVNIlwz3oQM7cHvlp8ELU42dztwW3u UkyWMVFtGI1elzd+e+uKG5J5I1FTjP7tRtJWPypD6U6fqPb9ZDvb3OhMGFxykuqNBc rqOFik+vhkvGuO+N1aC/S0hfI7PrFsUNtw3K9ByY= Received: from controller.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: wufan@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 52F91602AE; Wed, 29 Aug 2018 18:33:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1535567636; bh=umWvDB2GUgXjzPQxybvq5exqOnvpeZPtmBMZgUyFah0=; h=From:To:Cc:Subject:Date:From; b=fXQitN6Kxv/htbwcCHs0BkuU79L9xM6WpQvMVNIlwz3oQM7cHvlp8ELU42dztwW3u UkyWMVFtGI1elzd+e+uKG5J5I1FTjP7tRtJWPypD6U6fqPb9ZDvb3OhMGFxykuqNBc rqOFik+vhkvGuO+N1aC/S0hfI7PrFsUNtw3K9ByY= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 52F91602AE Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=wufan@codeaurora.org From: Fan Wu To: mchehab@kernel.org Subject: [PATCH] EDAC, ghes: use CPER module handles to locate DIMMs Date: Wed, 29 Aug 2018 18:33:52 +0000 Message-Id: <1535567632-18089-1-git-send-email-wufan@codeaurora.org> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180829_113407_895108_5DD63095 X-CRM114-Status: GOOD ( 15.55 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fan Wu , baicar.tyler@gmail.com, linux-kernel@vger.kernel.org, james.morse@arm.com, bp@alien8.de, linux-arm-kernel@lists.infradead.org, linux-edac@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The current ghes_edac driver does not update per-dimm error counters when reporting memory errors, because there is no platform-independent way to find DIMMs based on the error information provided by firmware. This patch offers a solution for platforms whose firmwares provide valid module handles (SMBIOS type 17) in error records. In this case ghes_edac will use the module handles to locate DIMMs and thus makes per-dimm error reporting possible. Signed-off-by: Fan Wu --- drivers/edac/ghes_edac.c | 36 +++++++++++++++++++++++++++++++++--- include/linux/edac.h | 2 ++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c index 473aeec..db527f0 100644 --- a/drivers/edac/ghes_edac.c +++ b/drivers/edac/ghes_edac.c @@ -81,6 +81,26 @@ static void ghes_edac_count_dimms(const struct dmi_header *dh, void *arg) (*num_dimm)++; } +static int ghes_edac_dimm_index(u16 handle) +{ + struct mem_ctl_info *mci; + int i; + + if (!ghes_pvt) + return -1; + + mci = ghes_pvt->mci; + + if (!mci) + return -1; + + for (i = 0; i < mci->tot_dimms; i++) { + if (mci->dimms[i]->smbios_handle == handle) + return i; + } + return -1; +} + static void ghes_edac_dmidecode(const struct dmi_header *dh, void *arg) { struct ghes_edac_dimm_fill *dimm_fill = arg; @@ -177,6 +197,8 @@ static void ghes_edac_dmidecode(const struct dmi_header *dh, void *arg) entry->total_width, entry->data_width); } + dimm->smbios_handle = entry->handle; + dimm_fill->count++; } } @@ -327,12 +349,20 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err) p += sprintf(p, "bit_pos:%d ", mem_err->bit_pos); if (mem_err->validation_bits & CPER_MEM_VALID_MODULE_HANDLE) { const char *bank = NULL, *device = NULL; + int index = -1; + dmi_memdev_name(mem_err->mem_dev_handle, &bank, &device); + p += sprintf(p, "DIMM DMI handle: 0x%.4x ", + mem_err->mem_dev_handle); if (bank != NULL && device != NULL) p += sprintf(p, "DIMM location:%s %s ", bank, device); - else - p += sprintf(p, "DIMM DMI handle: 0x%.4x ", - mem_err->mem_dev_handle); + + index = ghes_edac_dimm_index(mem_err->mem_dev_handle); + if (index >= 0) { + e->top_layer = index; + e->enable_per_layer_report = true; + } + } if (p > e->location) *(p - 1) = '\0'; diff --git a/include/linux/edac.h b/include/linux/edac.h index bffb978..a45ce1f 100644 --- a/include/linux/edac.h +++ b/include/linux/edac.h @@ -451,6 +451,8 @@ struct dimm_info { u32 nr_pages; /* number of pages on this dimm */ unsigned csrow, cschannel; /* Points to the old API data */ + + u16 smbios_handle; /* Handle for SMBIOS type 17 */ }; /**