From patchwork Thu Aug 3 21:57:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kani, Toshi" X-Patchwork-Id: 9879951 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AE788603FB for ; Thu, 3 Aug 2017 22:10:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 99F7028971 for ; Thu, 3 Aug 2017 22:10:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8EDFB2897E; Thu, 3 Aug 2017 22:10:21 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 328B028971 for ; Thu, 3 Aug 2017 22:10:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751866AbdHCWJC (ORCPT ); Thu, 3 Aug 2017 18:09:02 -0400 Received: from g2t2354.austin.hpe.com ([15.233.44.27]:52125 "EHLO g2t2354.austin.hpe.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752006AbdHCWHc (ORCPT ); Thu, 3 Aug 2017 18:07:32 -0400 Received: from g2t2360.austin.hpecorp.net (g2t2360.austin.hpecorp.net [16.196.225.135]) by g2t2354.austin.hpe.com (Postfix) with ESMTP id 7FBE278; Thu, 3 Aug 2017 22:07:31 +0000 (UTC) Received: from misato.americas.hpqcorp.net (unknown [10.34.81.122]) by g2t2360.austin.hpecorp.net (Postfix) with ESMTP id 068523F; Thu, 3 Aug 2017 22:07:30 +0000 (UTC) From: Toshi Kani To: rjw@rjwysocki.net, bp@alien8.de Cc: mchehab@kernel.org, tony.luck@intel.com, lenb@kernel.org, linux-acpi@vger.kernel.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, Toshi Kani Subject: [PATCH v2 4/7] ghes_edac: avoid multiple calls to dmi_walk() Date: Thu, 3 Aug 2017 15:57:50 -0600 Message-Id: <20170803215753.30553-5-toshi.kani@hpe.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170803215753.30553-1-toshi.kani@hpe.com> References: <20170803215753.30553-1-toshi.kani@hpe.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP ghes_edac_register() is called for each GHES platform device instantiated per a GHES entry in ACPI HEST table. dmi_walk() counts the number of DIMMs on the system, and there is no need to call it multiple times. Change ghes_edac_register() to call dmi_walk() only when 'num_dimm' is uninitialized. Signed-off-by: Toshi Kani Suggested-by: Borislav Petkov Cc: Borislav Petkov Cc: Mauro Carvalho Chehab --- drivers/edac/ghes_edac.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c index 4e61a62..2e9ce9c 100644 --- a/drivers/edac/ghes_edac.c +++ b/drivers/edac/ghes_edac.c @@ -407,15 +407,18 @@ EXPORT_SYMBOL_GPL(ghes_edac_report_mem_error); int ghes_edac_register(struct ghes *ghes, struct device *dev) { - bool fake = false; - int rc, num_dimm = 0; struct mem_ctl_info *mci; struct edac_mc_layer layers[1]; struct ghes_edac_pvt *pvt; struct ghes_edac_dimm_fill dimm_fill; + int rc; + + static int num_dimm; + static bool fake; /* Get the number of DIMMs */ - dmi_walk(ghes_edac_count_dimms, &num_dimm); + if (num_dimm == 0) + dmi_walk(ghes_edac_count_dimms, &num_dimm); /* Check if we've got a bogus BIOS */ if (num_dimm == 0) {