From patchwork Thu Aug 3 21:57:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kani, Toshi" X-Patchwork-Id: 9879937 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 E79CF60360 for ; Thu, 3 Aug 2017 22:08:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D3C0F288C4 for ; Thu, 3 Aug 2017 22:08:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C8B4A28971; Thu, 3 Aug 2017 22:08:30 +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=unavailable 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 50286288C4 for ; Thu, 3 Aug 2017 22:08:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752065AbdHCWHg (ORCPT ); Thu, 3 Aug 2017 18:07:36 -0400 Received: from g2t2353.austin.hpe.com ([15.233.44.26]:47110 "EHLO g2t2353.austin.hpe.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751754AbdHCWHe (ORCPT ); Thu, 3 Aug 2017 18:07:34 -0400 Received: from g2t2360.austin.hpecorp.net (g2t2360.austin.hpecorp.net [16.196.225.135]) by g2t2353.austin.hpe.com (Postfix) with ESMTP id D848747; Thu, 3 Aug 2017 22:07:33 +0000 (UTC) Received: from misato.americas.hpqcorp.net (unknown [10.34.81.122]) by g2t2360.austin.hpecorp.net (Postfix) with ESMTP id 67FFC37; Thu, 3 Aug 2017 22:07:33 +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 6/7] EDAC: add edac_check_mc_owner() to check MC owner Date: Thu, 3 Aug 2017 15:57:52 -0600 Message-Id: <20170803215753.30553-7-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 Only a single edac driver can be enabled for EDAC MC. When ghes_edac is enabled, a regular edac driver for the CPU type / platform still attempts to register itself and fails in edac_mc_add_mc(). Add edac_check_mc_owner() so that regular edac drivers can check the owner of EDAC MC at the beginning of initialization. Also change the owner check to string comparison from address check. Signed-off-by: Toshi Kani Cc: Borislav Petkov Cc: Mauro Carvalho Chehab Cc: Tony Luck --- drivers/edac/edac_mc.c | 15 ++++++++++++++- drivers/edac/edac_mc.h | 12 ++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) -- 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/edac_mc.c b/drivers/edac/edac_mc.c index 4800721..52d8d5e 100644 --- a/drivers/edac/edac_mc.c +++ b/drivers/edac/edac_mc.c @@ -701,6 +701,19 @@ struct mem_ctl_info *edac_mc_find(int idx) } EXPORT_SYMBOL(edac_mc_find); +/* + * Returns: + * 1 when EDAC MC is free or owned by the module name + * 0 when EDAC MC is owned by other module + */ +int edac_check_mc_owner(const char *mod_name) +{ + if (edac_mc_owner && strcmp(edac_mc_owner, mod_name)) + return 0; + + return 1; +} +EXPORT_SYMBOL(edac_check_mc_owner); /* FIXME - should a warning be printed if no error detection? correction? */ int edac_mc_add_mc_with_groups(struct mem_ctl_info *mci, @@ -742,7 +755,7 @@ int edac_mc_add_mc_with_groups(struct mem_ctl_info *mci, #endif mutex_lock(&mem_ctls_mutex); - if (edac_mc_owner && edac_mc_owner != mci->mod_name) { + if (!edac_check_mc_owner(mci->mod_name)) { ret = -EPERM; goto fail0; } diff --git a/drivers/edac/edac_mc.h b/drivers/edac/edac_mc.h index 5357800..0e95eba 100644 --- a/drivers/edac/edac_mc.h +++ b/drivers/edac/edac_mc.h @@ -128,6 +128,18 @@ struct mem_ctl_info *edac_mc_alloc(unsigned mc_num, unsigned sz_pvt); /** + * + * edac_check_mc_owner - Check the owner of EDAC MC + * + * @mod_name: pointer to the module name + * + * Returns: + * 1 when EDAC MC is free or owned by the module name + * 0 when EDAC MC is owned by other module + */ +extern int edac_check_mc_owner(const char *mod_name); + +/* * edac_mc_add_mc_with_groups() - Insert the @mci structure into the mci * global list and create sysfs entries associated with @mci structure. *