Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp2535452rwa; Mon, 22 Aug 2022 09:11:06 -0700 (PDT) X-Google-Smtp-Source: AA6agR6UKkgdgEPMCclrTWqndoyd2XlB6LcWhyP4XrhjhEonpGmXYs15ILVT3+GXcuTTRWKTFOCP X-Received: by 2002:a17:902:e848:b0:172:d851:e24f with SMTP id t8-20020a170902e84800b00172d851e24fmr10186226plg.146.1661184666360; Mon, 22 Aug 2022 09:11:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661184666; cv=none; d=google.com; s=arc-20160816; b=QLLvwwLciQfrZQfn/H8/rRqiEH23ZZbgshSfLIvAzfQCWqgYCBf3/ripQeiScU92Fk UgW3YGxmRnuduGStSo0PmGlBhPPUdtxsllsrlIl0S1hAkC6xixCIf8uwgQpS9kt/zDfs pft8k0ZmNyWi4rQMjtCvBx4ncjHR54ACJLXKbTORA/PghpVWKbw/KD6ydcGVrq26Qh8E rbhywlYN4pAGLEu0jmGZ9z8+R6W1+KaEUFKK3kX6NpECa5h0oMXSySGvC3fj4YqvV5fm nHVMyCtfqd6I6c1bDbgUQRtCe8zcxWrihMt5FC1pCHdhUotHwDj5LoDZ3g2dVOVbGkZR gtUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=pUEYQ/qLQaqdF3wjVVlfNtrctXbNy0jK4ddKKv2KatM=; b=X0gmwhInCqO4S8rLCjaPN9hkSToPiH2vqvzNXmWh0fXwa8oKKjgGZPcBY1WH5k9sln Q2ayZjcvcwAWcAHrxGFnFHP+eJS0vweHLu+vs8YUeWapb69/0bHpI65lIENFzP09y5N6 fBEddRjd1D/X+f9hWqYHtagg/i7Aw4wSyQq1fY1ceb2UdgGKxMDYUqNqQIks4e6avGNQ PBYhmEqGxSr7WeyoT2MJVbTBsk0iE1A1sbq5ELklMuwz8LYjZ08LpY8wayGwriL+CtUt p9l6Z/CUbj+3s5qDYVXXxeiPQOn+KOsvGx4vqXuDAIw7bVKIs1TLwUe41mMWrTKifMHc EEpg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q127-20020a632a85000000b00422a29e9f9esi12273094pgq.590.2022.08.22.09.10.54; Mon, 22 Aug 2022 09:11:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236692AbiHVPmy (ORCPT + 99 others); Mon, 22 Aug 2022 11:42:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236761AbiHVPl7 (ORCPT ); Mon, 22 Aug 2022 11:41:59 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6903F1F2EF; Mon, 22 Aug 2022 08:41:54 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 29C6FED1; Mon, 22 Aug 2022 08:41:57 -0700 (PDT) Received: from entos-ampere-02.shanghai.arm.com (entos-ampere-02.shanghai.arm.com [10.169.212.212]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 6C8AF3F70D; Mon, 22 Aug 2022 08:41:45 -0700 (PDT) From: Jia He To: Len Brown , James Morse , Tony Luck , Borislav Petkov , Mauro Carvalho Chehab , Robert Richter , Robert Moore , Qiuxu Zhuo , Yazen Ghannam , Jonathan Corbet , Jan Luebbe , Khuong Dinh , Kani Toshi Cc: Ard Biesheuvel , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-edac@vger.kernel.org, devel@acpica.org, "Rafael J . Wysocki" , Shuai Xue , Jarkko Sakkinen , linux-efi@vger.kernel.org, nd@arm.com, "Paul E. McKenney" , Andrew Morton , Neeraj Upadhyay , Randy Dunlap , Damien Le Moal , Muchun Song , linux-doc@vger.kernel.org, Jia He Subject: [RESEND PATCH v3 5/9] EDAC: Don't load chipset-specific edac drivers when ghes_edac is preferred Date: Mon, 22 Aug 2022 15:40:44 +0000 Message-Id: <20220822154048.188253-6-justin.he@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220822154048.188253-1-justin.he@arm.com> References: <20220822154048.188253-1-justin.he@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org edac_mc_add_mc* is too late in the init path and that check should happen as the very first thing in the driver init function. Suggested-by: Toshi Kani Signed-off-by: Jia He --- drivers/acpi/apei/ghes.c | 13 +++++++++++-- drivers/edac/amd64_edac.c | 3 +++ drivers/edac/edac_module.h | 1 + drivers/edac/i10nm_base.c | 3 +++ drivers/edac/igen6_edac.c | 3 +++ drivers/edac/pnd2_edac.c | 3 +++ drivers/edac/sb_edac.c | 3 +++ drivers/edac/skx_base.c | 3 +++ include/acpi/ghes.h | 2 ++ 9 files changed, 32 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index e17e0ee8f842..327386f3cf33 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -1537,16 +1537,25 @@ static struct acpi_platform_list plat_list[] = { { } /* End */ }; -struct list_head *ghes_get_devices(void) +bool ghes_edac_preferred(void) { int idx = -1; if (IS_ENABLED(CONFIG_X86)) { idx = acpi_match_platform_list(plat_list); if (idx < 0 && !ghes_edac_force) - return NULL; + return false; } + return true; +} +EXPORT_SYMBOL_GPL(ghes_edac_preferred); + +struct list_head *ghes_get_devices(void) +{ + if (!ghes_edac_preferred()) + return NULL; + return &ghes_devs; } EXPORT_SYMBOL_GPL(ghes_get_devices); diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c index 2f854feeeb23..5314a934c2bf 100644 --- a/drivers/edac/amd64_edac.c +++ b/drivers/edac/amd64_edac.c @@ -4329,6 +4329,9 @@ static int __init amd64_edac_init(void) int err = -ENODEV; int i; + if (ghes_edac_preferred()) + return -EBUSY; + owner = edac_get_owner(); if (owner && strncmp(owner, EDAC_MOD_STR, sizeof(EDAC_MOD_STR))) return -EBUSY; diff --git a/drivers/edac/edac_module.h b/drivers/edac/edac_module.h index 96f6de0c8ff6..3826f82de487 100644 --- a/drivers/edac/edac_module.h +++ b/drivers/edac/edac_module.h @@ -11,6 +11,7 @@ #ifndef __EDAC_MODULE_H__ #define __EDAC_MODULE_H__ +#include #include "edac_mc.h" #include "edac_pci.h" #include "edac_device.h" diff --git a/drivers/edac/i10nm_base.c b/drivers/edac/i10nm_base.c index 6cf50ee0b77c..691df9b51622 100644 --- a/drivers/edac/i10nm_base.c +++ b/drivers/edac/i10nm_base.c @@ -548,6 +548,9 @@ static int __init i10nm_init(void) edac_dbg(2, "\n"); + if (ghes_edac_preferred()) + return -EBUSY; + owner = edac_get_owner(); if (owner && strncmp(owner, EDAC_MOD_STR, sizeof(EDAC_MOD_STR))) return -EBUSY; diff --git a/drivers/edac/igen6_edac.c b/drivers/edac/igen6_edac.c index a07bbfd075d0..4ac6d0c533ec 100644 --- a/drivers/edac/igen6_edac.c +++ b/drivers/edac/igen6_edac.c @@ -1271,6 +1271,9 @@ static int __init igen6_init(void) edac_dbg(2, "\n"); + if (ghes_edac_preferred()) + return -EBUSY; + owner = edac_get_owner(); if (owner && strncmp(owner, EDAC_MOD_STR, sizeof(EDAC_MOD_STR))) return -ENODEV; diff --git a/drivers/edac/pnd2_edac.c b/drivers/edac/pnd2_edac.c index a20b299f1202..4ddc43e6c420 100644 --- a/drivers/edac/pnd2_edac.c +++ b/drivers/edac/pnd2_edac.c @@ -1528,6 +1528,9 @@ static int __init pnd2_init(void) edac_dbg(2, "\n"); + if (ghes_edac_preferred()) + return -EBUSY; + owner = edac_get_owner(); if (owner && strncmp(owner, EDAC_MOD_STR, sizeof(EDAC_MOD_STR))) return -EBUSY; diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c index 9678ab97c7ac..3ff604a5e95a 100644 --- a/drivers/edac/sb_edac.c +++ b/drivers/edac/sb_edac.c @@ -3506,6 +3506,9 @@ static int __init sbridge_init(void) edac_dbg(2, "\n"); + if (ghes_edac_preferred()) + return -EBUSY; + owner = edac_get_owner(); if (owner && strncmp(owner, EDAC_MOD_STR, sizeof(EDAC_MOD_STR))) return -EBUSY; diff --git a/drivers/edac/skx_base.c b/drivers/edac/skx_base.c index 1abc020d49ab..286370728552 100644 --- a/drivers/edac/skx_base.c +++ b/drivers/edac/skx_base.c @@ -653,6 +653,9 @@ static int __init skx_init(void) edac_dbg(2, "\n"); + if (ghes_edac_preferred()) + return -EBUSY; + owner = edac_get_owner(); if (owner && strncmp(owner, EDAC_MOD_STR, sizeof(EDAC_MOD_STR))) return -EBUSY; diff --git a/include/acpi/ghes.h b/include/acpi/ghes.h index e29327ee0b83..1c47018a1e43 100644 --- a/include/acpi/ghes.h +++ b/include/acpi/ghes.h @@ -73,9 +73,11 @@ int ghes_register_vendor_record_notifier(struct notifier_block *nb); void ghes_unregister_vendor_record_notifier(struct notifier_block *nb); struct list_head *ghes_get_devices(void); +bool ghes_edac_preferred(void); extern bool ghes_edac_force; #else static inline struct list_head *ghes_get_devices(void) { return NULL; } +static bool ghes_edac_preferred(void) { return false; } static bool ghes_edac_force; #endif -- 2.25.1