From patchwork Tue Sep 4 13:24:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fan Wu X-Patchwork-Id: 10587357 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 67A081669 for ; Tue, 4 Sep 2018 13:26:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5733529032 for ; Tue, 4 Sep 2018 13:26:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4AD3F2926A; Tue, 4 Sep 2018 13:26:05 +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 95F2229032 for ; Tue, 4 Sep 2018 13:26:04 +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=IoCcDGC9H6nwHJ76Z3namK3vMMCBGYqVFXMZ5YPoj2o=; b=UTX hj5qsiXL2vAQsuWrdIlY35fP8tDino79NMrPUCgqs1V26dHt8FD2CmYQwE94oVDZ8+sMyKhvBxJAd SWxZIZPkKEN7PeRUmwUt93WmxyvWLOkrMUi0+NBNNNCWauwWg14JtJI3nPV7uRkWMahVrgSXGLi6p I2UITfCJrI4rFHBwGyPfecHwe1iLeeoUv2LnV3T98a7/xtWOXB6qdE+OHEzAOqZyNSgVmDXGKYbqZ Z0CXDlKASLBDd0b5FLuYW7yj5bw7nFAJ56/e8Su/hZndntIEBZbt08RM3cjvyZsOsW8Cl+Xr3j4d4 IrQIX+oVSC21AL+VkCAUWFLOFh8fevQ==; 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 1fxBL2-0008Qn-1j; Tue, 04 Sep 2018 13:25:48 +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 1fxBKa-0006Wq-JL for linux-arm-kernel@lists.infradead.org; Tue, 04 Sep 2018 13:25:23 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id A4B2C609D1; Tue, 4 Sep 2018 13:25:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1536067509; bh=F/VcYaZ4aDYWRPIqHm+XVzb6H1bIr7poEwVFPLtQEaM=; h=From:To:Cc:Subject:Date:From; b=UCI5NWW5QAi0+BYTPNrRLPLTcPHyoBHwqk+HbKQPYLyPuVQcEH2lfo8znj8YlgsvW xPYJoCaQdGeJYfm4WPIfpJkjodO7ok/aEkUb+1c+KE1D3RpeJKwSfAOh+hdrm0efJ6 hy+sR9cr0wlstKQx0DdiDiMujYn1wq5fVmB/uALc= 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 5AE93608BF; Tue, 4 Sep 2018 13:25:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1536067508; bh=F/VcYaZ4aDYWRPIqHm+XVzb6H1bIr7poEwVFPLtQEaM=; h=From:To:Cc:Subject:Date:From; b=TadBigMt19eEnaJgbWa1/o+oi3vkrDauqCG/kzHsyQhoDxUm5GbAoQdpaBC4k+Rb0 2pHf2JE9A7iKHHPVHLO9Jw6zguzIZ7sinojMN+NOxUKwPdl9jNW9Zioluq/hxOrL8Y ZisiStaZ3Vg6spDTcWlHp+IH7Fn6iCFo011j4V18= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 5AE93608BF 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 v4] EDAC, ghes: use CPER module handles to locate DIMMs Date: Tue, 4 Sep 2018 13:24:53 +0000 Message-Id: <1536067493-31454-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-20180904_062520_719313_60D22A45 X-CRM114-Status: GOOD ( 14.84 ) 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: James Morse --- Changes from v3: * Updated Reviewed-by list 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 */ }; /**