From patchwork Tue Sep 4 03:50:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fan Wu X-Patchwork-Id: 10586589 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 671DF112B for ; Tue, 4 Sep 2018 03:51:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 540F2290A2 for ; Tue, 4 Sep 2018 03:51:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4791F290B6; Tue, 4 Sep 2018 03:51:24 +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 B6C7C290A2 for ; Tue, 4 Sep 2018 03:51:23 +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=ghP+RmU+tNUgRypwloIUjNcWa0wZxVml2YzMoDCXSBY=; b=tVX M2zBPbmFnF1c8ow7eo6oUA5TY86EfE0zhmFcN+A6Z45UU9YZUIYGKPImpE5pykbVs84z7XFI467zU RWvLpaLktZO8kpgeEfxzhGPDn3p9OmWeXyxaEdfbpPXbrj31Igqb4w3+UHqu5TYbbGPjPYTJ8Nx7q ho82MkAKL78SBDgIsQE/mR2kjppdTTn9Xjfj0dD24NFQn64KaB2rzxvfFupTf4mvuOeOei92DT59Z +mVk0QXa310lkEIOcl8tbGIiaNTpAZYQfBQlhO+gP1duS6gh1/mr4Bhwz7pvwoBCxr50Sllf4QBOX fnmZCwbGOgG5OGY4LMxWW2xsZhwD8bg==; 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 1fx2N1-0002cJ-DX; Tue, 04 Sep 2018 03:51:15 +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 1fx2My-0002az-DK for linux-arm-kernel@lists.infradead.org; Tue, 04 Sep 2018 03:51:13 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id BE533607BD; Tue, 4 Sep 2018 03:51:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1536033061; bh=WNxFlAjiXtNw0S3ADpsV0WUgw3N9yMarJU/lCZLCnu4=; h=From:To:Cc:Subject:Date:From; b=gXlWnFBP2dVGejmKebbj+5B8h8OGs9OkxlPaEGeCoVetGUNOVDNdVQflbSuTj20CX 2eHcoLpUCqSRqkdUi7gjbsksGcU7a7CYBKeJqAFwYEBiUG5e04RFJIuPYKsRuvbD/f 6Jki2IUV7HI5xQVPWo27/DGSDTz6R/t2a63qmYD0= 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 4F9D1603D2; Tue, 4 Sep 2018 03:50:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1536033060; bh=WNxFlAjiXtNw0S3ADpsV0WUgw3N9yMarJU/lCZLCnu4=; h=From:To:Cc:Subject:Date:From; b=KKb/fCXAHSMZrYYTaxxH03RmEUXsyIisqby77ofqXPvjsDtxTHm/AALr4eC3OKPny lL4/zgJkXFLgnmIAX0RfL8KvOTMOvtpguh2cho8YHSvCrzVGsM29D06zpnfpVdA8P+ V3micJlAcAvTNacRQc2HtN+obYXlSVQ+K+mFSrkQ= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 4F9D1603D2 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 v3] EDAC, ghes: use CPER module handles to locate DIMMs Date: Tue, 4 Sep 2018 03:50:55 +0000 Message-Id: <1536033055-25522-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-20180903_205112_487449_D158A3DD X-CRM114-Status: GOOD ( 14.64 ) 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 , toshi.kani@hpe.com, baicar.tyler@gmail.com, john.garry@huawei.com, linux-kernel@vger.kernel.org, tanxiaofei@huawei.com, james.morse@arm.com, wanghuiqiang@huawei.com, bp@alien8.de, shiju.jose@huawei.com, 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 For platforms whose firmwares provide valid module handles (SMBIOS type 17) in error records, this patch uses the module handles to locate corresponding DIMMs and enables per-DIMM error counter update. Signed-off-by: Fan Wu Reviewed-by: Tyler Baicar Tested-by: Toshi Kani Reviewed-by: Borislav Petkov Reviewed-by: James Morse Reviewed-by: tanxiaofei --- Changes from v2: * Fixed coding style glitch * Added Tested-by/Reviewed-by Changes from v1: * Changed the new function name to get_dimm_smbios_index * Removed unnecessary checks inside get_dimm_smbios_index * Reverted the change of the DMI handle print * Updated commit message --- drivers/edac/ghes_edac.c | 23 +++++++++++++++++++++++ include/linux/edac.h | 2 ++ 2 files changed, 25 insertions(+) diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c index 473aeec..ba46160 100644 --- a/drivers/edac/ghes_edac.c +++ b/drivers/edac/ghes_edac.c @@ -81,6 +81,18 @@ static void ghes_edac_count_dimms(const struct dmi_header *dh, void *arg) (*num_dimm)++; } +static int get_dimm_smbios_index(u16 handle) +{ + int i; + struct mem_ctl_info *mci = ghes_pvt->mci; + + 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 +189,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 +341,21 @@ 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); 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 = get_dimm_smbios_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 */ }; /**