From patchwork Mon Oct 17 13:01:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin He X-Patchwork-Id: 3437 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1436840wrs; Mon, 17 Oct 2022 06:07:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6snSXEa1gYIfFYUfHLlVHdgtu0Mk7mQpsLYfG4WuSIsEoaVKaeAUKkDYpUqIrcGuNJAfPC X-Received: by 2002:a17:903:2285:b0:185:44df:d916 with SMTP id b5-20020a170903228500b0018544dfd916mr11829983plh.120.1666012035786; Mon, 17 Oct 2022 06:07:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666012035; cv=none; d=google.com; s=arc-20160816; b=hBiPhHHSoEZnCtS4RHmp4/kscHKYou4FKZD4a1L9Ptk78V6Plquex15wNDBq9GMr/8 jtURML5AqurFbIohSmholmgyhQOZX80k0Op3euiAKp9DchWdscCzHXUtdm+h/8n1itoj 3pOMccciScjdfWCECgww2HYjrtbcv1uXsnkFfZoRYLVcjo4kVhYHdhcMveqwWwINZpUa vVD4L2kofDlUchAuK1U7gZhCHXwGCbJHyepVjYXtlHzsiNoVeosl4yTlqizHZ0sfAlMo wIgEIQDGWdhoexu7mLkT8vfS348ZT5F/GzOi2l+5FgrHpypGE/GGw67IzTW+osCGTmoG 88mw== 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=G6hiJbfMu0trAMC0w4D0u4HW5tVNMlkYfGkHnBStAKc=; b=JQXuiEQJg3h+Ppzpk02Y1hTrHyZEfnb+aDEqHEtyGBAtTHmxrSr4LOflciY7klrH9M 3UKsHaPgA3ujbVDVb3WvNedPNaqdYjDim4SI52pDiFFbJ9sVqox85obr6IPanYdsOisW O9L6A7Zulj5uY+80MaG1Er15ZU3HWuXTjxd26s+I5hoRo2BsNvWO43gNmtzu+X5fklq+ eftaFivnM9B70NQlPoGliJHkS+82hzVqO3FDzjZLZkeK8G0/tTljhPlzU87OYlfc0YO3 8Up6OHqwk7PQXaiSFrQC9w+xy5pBi8FlTojmH4XoQ1DHOjdxKA96fIYiJjOpGzATZkNk 2zEg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q15-20020a170902dacf00b0018018272902si13647065plx.554.2022.10.17.06.06.59; Mon, 17 Oct 2022 06:07:15 -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 S230481AbiJQNCI (ORCPT + 99 others); Mon, 17 Oct 2022 09:02:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229797AbiJQNCG (ORCPT ); Mon, 17 Oct 2022 09:02:06 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5E8492608; Mon, 17 Oct 2022 06:02:05 -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 591511042; Mon, 17 Oct 2022 06:02:11 -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 66B903F67D; Mon, 17 Oct 2022 06:01:58 -0700 (PDT) From: Jia He To: Ard Biesheuvel , Len Brown , Tony Luck , Borislav Petkov , Mauro Carvalho Chehab , Robert Richter , Robert Moore , Qiuxu Zhuo , Yazen Ghannam , Jan Luebbe , Khuong Dinh , Kani Toshi Cc: James Morse , 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, Peter Zijlstra , Jia He Subject: [PATCH v9 1/7] efi/cper: export several helpers for ghes_edac to use Date: Mon, 17 Oct 2022 13:01:34 +0000 Message-Id: <20221017130140.420986-2-justin.he@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221017130140.420986-1-justin.he@arm.com> References: <20221017130140.420986-1-justin.he@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746940236243330384?= X-GMAIL-MSGID: =?utf-8?q?1746940236243330384?= Before ghes_edac can be turned back into a proper module again, export several helpers which are going to be used by it. Signed-off-by: Jia He Acked-by: Ard Biesheuvel --- drivers/firmware/efi/cper.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/firmware/efi/cper.c b/drivers/firmware/efi/cper.c index e4e5ea7ce910..053eae13f409 100644 --- a/drivers/firmware/efi/cper.c +++ b/drivers/firmware/efi/cper.c @@ -290,6 +290,7 @@ int cper_mem_err_location(struct cper_mem_err_compact *mem, char *msg) return n; } +EXPORT_SYMBOL_GPL(cper_mem_err_location); int cper_dimm_err_location(struct cper_mem_err_compact *mem, char *msg) { @@ -310,6 +311,7 @@ int cper_dimm_err_location(struct cper_mem_err_compact *mem, char *msg) return n; } +EXPORT_SYMBOL_GPL(cper_dimm_err_location); void cper_mem_err_pack(const struct cper_sec_mem_err *mem, struct cper_mem_err_compact *cmem) @@ -331,6 +333,7 @@ void cper_mem_err_pack(const struct cper_sec_mem_err *mem, cmem->mem_array_handle = mem->mem_array_handle; cmem->mem_dev_handle = mem->mem_dev_handle; } +EXPORT_SYMBOL_GPL(cper_mem_err_pack); const char *cper_mem_err_unpack(struct trace_seq *p, struct cper_mem_err_compact *cmem) From patchwork Mon Oct 17 13:01:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin He X-Patchwork-Id: 3441 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1437721wrs; Mon, 17 Oct 2022 06:08:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5+XqROzEFYBhwlkCbll9kWJavWKCSNmRW7EYIyulu1lwnv/0ouuUul/9EOSw/mRxy+HacP X-Received: by 2002:a63:1b0f:0:b0:46b:910:6cd9 with SMTP id b15-20020a631b0f000000b0046b09106cd9mr10701806pgb.5.1666012133713; Mon, 17 Oct 2022 06:08:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666012133; cv=none; d=google.com; s=arc-20160816; b=ANsbd8z/k0ZB9KO0cH0jy+EXDHRac796G6Vkrs+Qt3SkUb2n0b7XVHJ3n4xGVixJLD NOiyUrgsKhHF1XZPp1DWJ2/rObxMfN2f7EzlKwg56djGc59y9t+78UlzqsPbq91E5A0w UnsbmucsbBG/lGtQHtBxUmogiuMAxNVdks2KiEblqmDdpyGuMHY1TynQBhyoOe/Egy7K x7BAq4c7lIqkgjFAY1SslL4dLirjH1RtiKduHAdJgQpQstJuBZcV7Cf9apvkSeOfkUZs hQn6jZk403W8s0AKX3/7N06kRWgCFkz25udjQEuW0QhcJ1eEBbqsqHCgztbBwTwIiPYW qtHw== 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=klHIHfpDpIW2F9viLK//W9n0kM8KINNcQwuqAoMtON8=; b=L6zIXZwU/rp/mWUFQxBLyNZ+10Fw5v1BKfcGhdVyc52NBgHxXE8v3sIJHCJYvA2wiD 8b5HNTfMrCAnmPmiFDkCpUF3MtNNpXHpYt8pqkHlmtxQjmkPEggM+W4DxhwU/m4F3w+o /9lc0wAOxA20pLeByo55LX7ZX/6+CiX1hQua73G/6KBaYclAyVM0BUsju9dQ/228xgtd 6BbFk+LCsNe9ZGF5amu74uXtT6BsSmUsApkmfrdvslgdt7aC5Ka16cq2Zu++8iTwNicO GSovVNn1e6VI7U1hw7mOvUx+hDD4KVBmA7EPs4AFa3r6k1s3dbPuZjCfbK/7NpTYItur azXw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t10-20020a17090a5d8a00b0020243dc975bsi16380773pji.116.2022.10.17.06.08.36; Mon, 17 Oct 2022 06:08:53 -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 S230028AbiJQNCT (ORCPT + 99 others); Mon, 17 Oct 2022 09:02:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230495AbiJQNCP (ORCPT ); Mon, 17 Oct 2022 09:02:15 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1E9C25F7D9; Mon, 17 Oct 2022 06:02:12 -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 8E4561FC7; Mon, 17 Oct 2022 06:02:18 -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 A83F13F67D; Mon, 17 Oct 2022 06:02:05 -0700 (PDT) From: Jia He To: Ard Biesheuvel , Len Brown , Tony Luck , Borislav Petkov , Mauro Carvalho Chehab , Robert Richter , Robert Moore , Qiuxu Zhuo , Yazen Ghannam , Jan Luebbe , Khuong Dinh , Kani Toshi Cc: James Morse , 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, Peter Zijlstra , Jia He Subject: [PATCH v9 2/7] EDAC/ghes: Add a notifier for reporting memory errors Date: Mon, 17 Oct 2022 13:01:35 +0000 Message-Id: <20221017130140.420986-3-justin.he@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221017130140.420986-1-justin.he@arm.com> References: <20221017130140.420986-1-justin.he@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746940338977807296?= X-GMAIL-MSGID: =?utf-8?q?1746940338977807296?= To make a proper module, add a notifier for reporting memory errors. Use an atomic notifier because calls sites like ghes_proc_in_irq() run in interrupt context. Suggested-by: Borislav Petkov Signed-off-by: Jia He --- drivers/acpi/apei/ghes.c | 16 +++++++++++++++- drivers/edac/ghes_edac.c | 19 +++++++++++++++++-- include/acpi/ghes.h | 10 +++------- 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index d91ad378c00d..8cb65f757d06 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -94,6 +94,8 @@ #define FIX_APEI_GHES_SDEI_CRITICAL __end_of_fixed_addresses #endif +static ATOMIC_NOTIFIER_HEAD(ghes_report_chain); + static inline bool is_hest_type_generic_v2(struct ghes *ghes) { return ghes->generic->header.type == ACPI_HEST_TYPE_GENERIC_ERROR_V2; @@ -645,7 +647,7 @@ static bool ghes_do_proc(struct ghes *ghes, if (guid_equal(sec_type, &CPER_SEC_PLATFORM_MEM)) { struct cper_sec_mem_err *mem_err = acpi_hest_get_payload(gdata); - ghes_edac_report_mem_error(sev, mem_err); + atomic_notifier_call_chain(&ghes_report_chain, sev, mem_err); arch_apei_report_mem_error(sev, mem_err); queued = ghes_handle_memory_failure(gdata, sev); @@ -1497,3 +1499,15 @@ void __init acpi_ghes_init(void) else pr_info(GHES_PFX "Failed to enable APEI firmware first mode.\n"); } + +void ghes_register_report_chain(struct notifier_block *nb) +{ + atomic_notifier_chain_register(&ghes_report_chain, nb); +} +EXPORT_SYMBOL_GPL(ghes_register_report_chain); + +void ghes_unregister_report_chain(struct notifier_block *nb) +{ + atomic_notifier_chain_unregister(&ghes_report_chain, nb); +} +EXPORT_SYMBOL_GPL(ghes_unregister_report_chain); diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c index c8fa7dcfdbd0..7b8d56a769f6 100644 --- a/drivers/edac/ghes_edac.c +++ b/drivers/edac/ghes_edac.c @@ -14,6 +14,7 @@ #include #include "edac_module.h" #include +#include #define OTHER_DETAIL_LEN 400 @@ -267,11 +268,14 @@ static int print_mem_error_other_detail(const struct cper_sec_mem_err *mem, char return n; } -void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err) +static int ghes_edac_report_mem_error(struct notifier_block *nb, + unsigned long val, void *data) { + struct cper_sec_mem_err *mem_err = (struct cper_sec_mem_err *)data; struct cper_mem_err_compact cmem; struct edac_raw_error_desc *e; struct mem_ctl_info *mci; + unsigned long sev = val; struct ghes_pvt *pvt; unsigned long flags; char *p; @@ -282,7 +286,7 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err) * know. */ if (WARN_ON_ONCE(in_nmi())) - return; + return NOTIFY_OK; spin_lock_irqsave(&ghes_lock, flags); @@ -374,8 +378,15 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err) unlock: spin_unlock_irqrestore(&ghes_lock, flags); + + return NOTIFY_OK; } +static struct notifier_block ghes_edac_mem_err_nb = { + .notifier_call = ghes_edac_report_mem_error, + .priority = 0, +}; + /* * Known systems that are safe to enable this module. */ @@ -503,6 +514,8 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev) ghes_pvt = pvt; spin_unlock_irqrestore(&ghes_lock, flags); + ghes_register_report_chain(&ghes_edac_mem_err_nb); + /* only set on success */ refcount_set(&ghes_refcount, 1); @@ -548,6 +561,8 @@ void ghes_edac_unregister(struct ghes *ghes) if (mci) edac_mc_free(mci); + ghes_unregister_report_chain(&ghes_edac_mem_err_nb); + unlock: mutex_unlock(&ghes_reg_mutex); } diff --git a/include/acpi/ghes.h b/include/acpi/ghes.h index 34fb3431a8f3..5cbd38b6e4e1 100644 --- a/include/acpi/ghes.h +++ b/include/acpi/ghes.h @@ -76,18 +76,11 @@ int ghes_estatus_pool_init(int num_ghes); /* From drivers/edac/ghes_edac.c */ #ifdef CONFIG_EDAC_GHES -void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err); - int ghes_edac_register(struct ghes *ghes, struct device *dev); void ghes_edac_unregister(struct ghes *ghes); #else -static inline void ghes_edac_report_mem_error(int sev, - struct cper_sec_mem_err *mem_err) -{ -} - static inline int ghes_edac_register(struct ghes *ghes, struct device *dev) { return -ENODEV; @@ -145,4 +138,7 @@ int ghes_notify_sea(void); static inline int ghes_notify_sea(void) { return -ENOENT; } #endif +struct notifier_block; +extern void ghes_register_report_chain(struct notifier_block *nb); +extern void ghes_unregister_report_chain(struct notifier_block *nb); #endif /* GHES_H */ From patchwork Mon Oct 17 13:01:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin He X-Patchwork-Id: 3438 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1437221wrs; Mon, 17 Oct 2022 06:07:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7t6UGkmED2vFHE7eeG0cBt9ebU4xH4521wIjxs9B1jRZ7gh8s8K95r6Ri6k7p01maZGWDN X-Received: by 2002:a17:90b:3804:b0:20d:4e77:373a with SMTP id mq4-20020a17090b380400b0020d4e77373amr33384284pjb.212.1666012074658; Mon, 17 Oct 2022 06:07:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666012074; cv=none; d=google.com; s=arc-20160816; b=XgH6iKuWI/0djNvLzFdggbcgkpPoLGAL1riFTg4ha/86U2iwCSXYmuj/rjQaR1xCf5 bEOvd3qIlCT3gR7slzQF2b6Vp64rOdVOLW0MGR5cwlutcKmNKERbCyIv6vS2VO6a71Vg pTxT1RqL2oaKBrFTf/OqJbD3W68DjAWVWd2cW50qE6OwP36+pX55PyTS4KVQIdze51xh AXtQGWdZwjZNb5JseYdzqFlra3YJ8Uv82k5a0aAnecYDnHkjqEgVNlRiqMINrUWbL3L1 r5rKpvFk7418N8sg5uVZBMGcjytrzBSiw1hxODndiH1rqlXj/7+/RrowcaEP81HX8xa4 MbHg== 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=SVEO++n8I4cXwVy4bT3hJivaBOvkPelYjMNZu2hwrYE=; b=AsZ8Xh68oh+M4RbSfUexyQWP1w5N5q8j6VOQbTRyAaY8UIn+nckzmfigfHSpMnZTEQ OiyW+fLKm9JRClUnl+zQ9/43SQrZuOJ725+zsUt+T9/hRl5lPgkvoFPf8HLkCVosqS5K neR7FOgjr4olz1d70oziLG4XNUlQVQzbqdBkzZUaTEQrmnUTtsdn2j+TYCC4ar1QEhML mTUhwM1aT9u4lb4tCLDIrUHuAiAXIKZOjcDKANChIUCYc0R1FbbqRWr57lfM87DiPNq2 dbtH1Ve/Pwx5D2y+5TjnfiQj2gyhZSOH/yNFz+IwoGKIHcZNxTGvyVKY45tDd+qIo2kR 8E3A== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 129-20020a630087000000b0045ff2a2f56csi11629935pga.546.2022.10.17.06.07.36; Mon, 17 Oct 2022 06:07:54 -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 S230504AbiJQNCa (ORCPT + 99 others); Mon, 17 Oct 2022 09:02:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230197AbiJQNCY (ORCPT ); Mon, 17 Oct 2022 09:02:24 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D24275EDE7; Mon, 17 Oct 2022 06:02:19 -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 C604F1042; Mon, 17 Oct 2022 06:02:25 -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 E0C663F67D; Mon, 17 Oct 2022 06:02:12 -0700 (PDT) From: Jia He To: Ard Biesheuvel , Len Brown , Tony Luck , Borislav Petkov , Mauro Carvalho Chehab , Robert Richter , Robert Moore , Qiuxu Zhuo , Yazen Ghannam , Jan Luebbe , Khuong Dinh , Kani Toshi Cc: James Morse , 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, Peter Zijlstra , Jia He Subject: [PATCH v9 3/7] EDAC/ghes: Prepare to make ghes_edac a proper module Date: Mon, 17 Oct 2022 13:01:36 +0000 Message-Id: <20221017130140.420986-4-justin.he@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221017130140.420986-1-justin.he@arm.com> References: <20221017130140.420986-1-justin.he@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746940277423098433?= X-GMAIL-MSGID: =?utf-8?q?1746940277423098433?= To make ghes_edac a proper module, prepare to decouple its dependencies on ghes. ghes_edac_register() is too late to set the module flag ghes_edac.force_load. Also, other edac drivers should not be able to control this flag. Move this flag to the module parameter in ghes and make it static. Introduce a helper ghes_get_devices(), which returns the dev list GHES probed when the platform-check passes on the system. The previous force_load check is not needed in ghes_edac_unregister() since it will be checked in module_init of ghes_edac later. Suggested-by: Toshi Kani Suggested-by: Borislav Petkov Signed-off-by: Jia He --- drivers/acpi/apei/ghes.c | 46 ++++++++++++++++++++++++++++++++++++++++ drivers/edac/ghes_edac.c | 35 ++---------------------------- include/acpi/ghes.h | 6 ++++++ 3 files changed, 54 insertions(+), 33 deletions(-) diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index 8cb65f757d06..6a0dcb8c0901 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -109,6 +109,13 @@ static inline bool is_hest_type_generic_v2(struct ghes *ghes) bool ghes_disable; module_param_named(disable, ghes_disable, bool, 0); +/* + * "ghes.edac_force_enable" forcibly enables ghes_edac and skips the platform + * check. + */ +static bool ghes_edac_force_enable; +module_param_named(edac_force_enable, ghes_edac_force_enable, bool, 0); + /* * All error sources notified with HED (Hardware Error Device) share a * single notifier callback, so they need to be linked and checked one @@ -120,6 +127,9 @@ module_param_named(disable, ghes_disable, bool, 0); static LIST_HEAD(ghes_hed); static DEFINE_MUTEX(ghes_list_mutex); +static LIST_HEAD(ghes_devs); +static DEFINE_MUTEX(ghes_devs_mutex); + /* * Because the memory area used to transfer hardware error information * from BIOS to Linux can be determined only in NMI, IRQ or timer @@ -1380,6 +1390,12 @@ static int ghes_probe(struct platform_device *ghes_dev) ghes_edac_register(ghes, &ghes_dev->dev); + ghes->dev = &ghes_dev->dev; + + mutex_lock(&ghes_devs_mutex); + list_add_tail(&ghes->elist, &ghes_devs); + mutex_unlock(&ghes_devs_mutex); + /* Handle any pending errors right away */ spin_lock_irqsave(&ghes_notify_lock_irq, flags); ghes_proc(ghes); @@ -1444,6 +1460,10 @@ static int ghes_remove(struct platform_device *ghes_dev) ghes_edac_unregister(ghes); + mutex_lock(&ghes_devs_mutex); + list_del(&ghes->elist); + mutex_unlock(&ghes_devs_mutex); + kfree(ghes); platform_set_drvdata(ghes_dev, NULL); @@ -1500,6 +1520,32 @@ void __init acpi_ghes_init(void) pr_info(GHES_PFX "Failed to enable APEI firmware first mode.\n"); } +/* + * Known x86 systems that prefer GHES error reporting: + */ +static struct acpi_platform_list plat_list[] = { + {"HPE ", "Server ", 0, ACPI_SIG_FADT, all_versions}, + { } /* End */ +}; + +struct list_head *ghes_get_devices(void) +{ + int idx = -1; + + if (IS_ENABLED(CONFIG_X86)) { + idx = acpi_match_platform_list(plat_list); + if (idx < 0) { + if (!ghes_edac_force_enable) + return NULL; + + pr_warn_once("Force-loading ghes_edac on an unsupported platform. You're on your own!\n"); + } + } + + return &ghes_devs; +} +EXPORT_SYMBOL_GPL(ghes_get_devices); + void ghes_register_report_chain(struct notifier_block *nb) { atomic_notifier_chain_register(&ghes_report_chain, nb); diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c index 7b8d56a769f6..b85a545d1cb0 100644 --- a/drivers/edac/ghes_edac.c +++ b/drivers/edac/ghes_edac.c @@ -54,10 +54,6 @@ static DEFINE_MUTEX(ghes_reg_mutex); */ static DEFINE_SPINLOCK(ghes_lock); -/* "ghes_edac.force_load=1" skips the platform check */ -static bool __read_mostly force_load; -module_param(force_load, bool, 0); - static bool system_scanned; /* Memory Device - Type 17 of SMBIOS spec */ @@ -387,14 +383,6 @@ static struct notifier_block ghes_edac_mem_err_nb = { .priority = 0, }; -/* - * Known systems that are safe to enable this module. - */ -static struct acpi_platform_list plat_list[] = { - {"HPE ", "Server ", 0, ACPI_SIG_FADT, all_versions}, - { } /* End */ -}; - int ghes_edac_register(struct ghes *ghes, struct device *dev) { bool fake = false; @@ -402,19 +390,8 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev) struct ghes_pvt *pvt; struct edac_mc_layer layers[1]; unsigned long flags; - int idx = -1; int rc = 0; - if (IS_ENABLED(CONFIG_X86)) { - /* Check if safe to enable on this system */ - idx = acpi_match_platform_list(plat_list); - if (!force_load && idx < 0) - return -ENODEV; - } else { - force_load = true; - idx = 0; - } - /* finish another registration/unregistration instance first */ mutex_lock(&ghes_reg_mutex); @@ -458,15 +435,10 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev) pr_info("This system has a very crappy BIOS: It doesn't even list the DIMMS.\n"); pr_info("Its SMBIOS info is wrong. It is doubtful that the error report would\n"); pr_info("work on such system. Use this driver with caution\n"); - } else if (idx < 0) { - pr_info("This EDAC driver relies on BIOS to enumerate memory and get error reports.\n"); - pr_info("Unfortunately, not all BIOSes reflect the memory layout correctly.\n"); - pr_info("So, the end result of using this driver varies from vendor to vendor.\n"); - pr_info("If you find incorrect reports, please contact your hardware vendor\n"); - pr_info("to correct its BIOS.\n"); - pr_info("This system has %d DIMM sockets.\n", ghes_hw.num_dimms); } + pr_info("This system has %d DIMM sockets.\n", ghes_hw.num_dimms); + if (!fake) { struct dimm_info *src, *dst; int i = 0; @@ -535,9 +507,6 @@ void ghes_edac_unregister(struct ghes *ghes) struct mem_ctl_info *mci; unsigned long flags; - if (!force_load) - return; - mutex_lock(&ghes_reg_mutex); system_scanned = false; diff --git a/include/acpi/ghes.h b/include/acpi/ghes.h index 5cbd38b6e4e1..ce693e9f07a0 100644 --- a/include/acpi/ghes.h +++ b/include/acpi/ghes.h @@ -27,6 +27,8 @@ struct ghes { struct timer_list timer; unsigned int irq; }; + struct device *dev; + struct list_head elist; }; struct ghes_estatus_node { @@ -80,6 +82,8 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev); void ghes_edac_unregister(struct ghes *ghes); +struct list_head *ghes_get_devices(void); + #else static inline int ghes_edac_register(struct ghes *ghes, struct device *dev) { @@ -89,6 +93,8 @@ static inline int ghes_edac_register(struct ghes *ghes, struct device *dev) static inline void ghes_edac_unregister(struct ghes *ghes) { } + +static inline struct list_head *ghes_get_devices(void) { return NULL; } #endif static inline int acpi_hest_get_version(struct acpi_hest_generic_data *gdata) From patchwork Mon Oct 17 13:01:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin He X-Patchwork-Id: 3443 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1438307wrs; Mon, 17 Oct 2022 06:10:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5HPQW9zpPRN/pw6xXtQo/GKLTWmnmPhFfmp+ohLENgzOzATKcO9RqprR32FmoDH5lLYMIp X-Received: by 2002:a05:6a00:2291:b0:563:9d0d:62b1 with SMTP id f17-20020a056a00229100b005639d0d62b1mr12431788pfe.42.1666012200697; Mon, 17 Oct 2022 06:10:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666012200; cv=none; d=google.com; s=arc-20160816; b=uKUfRaaPoj8G/ci9tOw1CZ+zlJgSxv0cesvD4jk0UbmpVgGlNk3LJj5WpSd9nezQy4 8TMNR4xIB7MUxO9t6TO/nIWaaGW4r8PQIUrqIHDJZd08lw0uKZTs45r32Oz4HzM9p8/X sqJBGpFX7L2Cn+9xaamciThQc2HRd8VUAxYJbMtHTUs7FRZV4J3ICV1qgjy5ayvzWMzh j8qYX+diwLF0Q6WwpydrBcKhuCcJfNY2Va1cPT0Q8ZYaIH38f6RQG7b7OwI6WyZWXG2w S9KFzkco7fJCxPdCwoECUwhnJUy5NaCa7Tksmlv6qBtSAAolTRU7qo8VUWnFqtx64wCH p81Q== 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=Ng/kjzupiSlkFzgtF4hXv3cSkZ8YFwtgJbaJrijJZKQ=; b=sEKw99jJ1aau6LQLIlw0s7Bl7W6rsXqe6q/Vmoh0AxWx2KNvD956vQ2n6iFs8u+qay RUWsDHks+YU+Vothhda9dCrVxaPgcJBxjRUJJCYM6gxoLH9XfsF9qn+mIDsuAZyqsVdX 9UwTcE/Yqu3Nj5L9JQIKZui5VKK+9jMVwgA8SOahtBkhbto4H7cQbN8zpInaMmMTS2f+ XWZBDhgYAffEDuPWZ1ivTfoMALJHSvIAoR+z0a5bkkfjSHkWR51Xpfqy7YsimE8VWJe8 SAs60yh2RaKoMiPYAr6Z4xe1/mdhGF0Vpgewe8UUkYAkCZOOLumbxva9xERumjDenMHl QCCA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k15-20020a170902d58f00b00176806795b7si11693440plh.351.2022.10.17.06.09.32; Mon, 17 Oct 2022 06:10:00 -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 S230312AbiJQNCf (ORCPT + 99 others); Mon, 17 Oct 2022 09:02:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230505AbiJQNC3 (ORCPT ); Mon, 17 Oct 2022 09:02:29 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8DA49520B0; Mon, 17 Oct 2022 06:02:27 -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 0B00A1042; Mon, 17 Oct 2022 06:02:33 -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 24F153F67D; Mon, 17 Oct 2022 06:02:19 -0700 (PDT) From: Jia He To: Ard Biesheuvel , Len Brown , Tony Luck , Borislav Petkov , Mauro Carvalho Chehab , Robert Richter , Robert Moore , Qiuxu Zhuo , Yazen Ghannam , Jan Luebbe , Khuong Dinh , Kani Toshi Cc: James Morse , 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, Peter Zijlstra , Jia He Subject: [PATCH v9 4/7] EDAC/ghes: Make ghes_edac a proper module to remove the dependency on ghes Date: Mon, 17 Oct 2022 13:01:37 +0000 Message-Id: <20221017130140.420986-5-justin.he@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221017130140.420986-1-justin.he@arm.com> References: <20221017130140.420986-1-justin.he@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746940409346009783?= X-GMAIL-MSGID: =?utf-8?q?1746940409346009783?= Commit dc4e8c07e9e2 ("ACPI: APEI: explicit init of HEST and GHES in apci_init()") introduced a bug that ghes_edac_register() would be invoked before edac_init(). Because at that time, the bus "edac" hadn't been even registered, this created sysfs /devices/mc0 instead of /sys/devices/system/edac/mc/mc0 on an Ampere eMag server. To remove the dependency of ghes_edac on ghes, make it a proper module. Use a list to save the probing devices in ghes_probe(), and defer the ghes_edac_register() to module_init() of the new ghes_edac module by iterating over the devices list. Co-developed-by: Borislav Petkov Signed-off-by: Borislav Petkov Signed-off-by: Jia He Fixes: dc4e8c07e9e2 ("ACPI: APEI: explicit init of HEST and GHES in apci_init()") Cc: Shuai Xue --- drivers/acpi/apei/ghes.c | 4 ---- drivers/edac/Kconfig | 4 ++-- drivers/edac/ghes_edac.c | 40 ++++++++++++++++++++++++++++++++++++++-- include/acpi/ghes.h | 22 ++-------------------- 4 files changed, 42 insertions(+), 28 deletions(-) diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index 6a0dcb8c0901..27c72b175e4b 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -1388,8 +1388,6 @@ static int ghes_probe(struct platform_device *ghes_dev) platform_set_drvdata(ghes_dev, ghes); - ghes_edac_register(ghes, &ghes_dev->dev); - ghes->dev = &ghes_dev->dev; mutex_lock(&ghes_devs_mutex); @@ -1458,8 +1456,6 @@ static int ghes_remove(struct platform_device *ghes_dev) ghes_fini(ghes); - ghes_edac_unregister(ghes); - mutex_lock(&ghes_devs_mutex); list_del(&ghes->elist); mutex_unlock(&ghes_devs_mutex); diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig index 17562cf1fe97..df45db81858b 100644 --- a/drivers/edac/Kconfig +++ b/drivers/edac/Kconfig @@ -53,8 +53,8 @@ config EDAC_DECODE_MCE has been initialized. config EDAC_GHES - bool "Output ACPI APEI/GHES BIOS detected errors via EDAC" - depends on ACPI_APEI_GHES && (EDAC=y) + tristate "Output ACPI APEI/GHES BIOS detected errors via EDAC" + depends on ACPI_APEI_GHES select UEFI_CPER help Not all machines support hardware-driven error report. Some of those diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c index b85a545d1cb0..dec1bb96e4b3 100644 --- a/drivers/edac/ghes_edac.c +++ b/drivers/edac/ghes_edac.c @@ -56,6 +56,8 @@ static DEFINE_SPINLOCK(ghes_lock); static bool system_scanned; +static struct list_head *ghes_devs; + /* Memory Device - Type 17 of SMBIOS spec */ struct memdev_dmi_entry { u8 type; @@ -383,7 +385,7 @@ static struct notifier_block ghes_edac_mem_err_nb = { .priority = 0, }; -int ghes_edac_register(struct ghes *ghes, struct device *dev) +static int ghes_edac_register(struct device *dev) { bool fake = false; struct mem_ctl_info *mci; @@ -502,7 +504,7 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev) return rc; } -void ghes_edac_unregister(struct ghes *ghes) +static void ghes_edac_unregister(struct ghes *ghes) { struct mem_ctl_info *mci; unsigned long flags; @@ -535,3 +537,37 @@ void ghes_edac_unregister(struct ghes *ghes) unlock: mutex_unlock(&ghes_reg_mutex); } + +static int __init ghes_edac_init(void) +{ + struct ghes *g, *g_tmp; + + ghes_devs = ghes_get_devices(); + if (!ghes_devs) + return -ENODEV; + + if (list_empty(ghes_devs)) { + pr_info("GHES probing device list is empty"); + return -ENODEV; + } + + list_for_each_entry_safe(g, g_tmp, ghes_devs, elist) { + ghes_edac_register(g->dev); + } + + return 0; +} +module_init(ghes_edac_init); + +static void __exit ghes_edac_exit(void) +{ + struct ghes *g, *g_tmp; + + list_for_each_entry_safe(g, g_tmp, ghes_devs, elist) { + ghes_edac_unregister(g); + } +} +module_exit(ghes_edac_exit); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("Output ACPI APEI/GHES BIOS detected errors module via EDAC"); diff --git a/include/acpi/ghes.h b/include/acpi/ghes.h index ce693e9f07a0..2e785d3554d8 100644 --- a/include/acpi/ghes.h +++ b/include/acpi/ghes.h @@ -71,32 +71,14 @@ int ghes_register_vendor_record_notifier(struct notifier_block *nb); * @nb: pointer to the notifier_block structure of the vendor record handler. */ void ghes_unregister_vendor_record_notifier(struct notifier_block *nb); -#endif - -int ghes_estatus_pool_init(int num_ghes); - -/* From drivers/edac/ghes_edac.c */ - -#ifdef CONFIG_EDAC_GHES -int ghes_edac_register(struct ghes *ghes, struct device *dev); - -void ghes_edac_unregister(struct ghes *ghes); struct list_head *ghes_get_devices(void); - #else -static inline int ghes_edac_register(struct ghes *ghes, struct device *dev) -{ - return -ENODEV; -} - -static inline void ghes_edac_unregister(struct ghes *ghes) -{ -} - static inline struct list_head *ghes_get_devices(void) { return NULL; } #endif +int ghes_estatus_pool_init(int num_ghes); + static inline int acpi_hest_get_version(struct acpi_hest_generic_data *gdata) { return gdata->revision >> 8; From patchwork Mon Oct 17 13:01:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin He X-Patchwork-Id: 3439 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1437525wrs; Mon, 17 Oct 2022 06:08:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7ozXjoa0l7ujkT5/8fhBr57US/w/HJ4xk5Q06lIBERqpUNOrknH16s6RJIz5xjMR8ORdpJ X-Received: by 2002:a63:5f0a:0:b0:459:537f:61d4 with SMTP id t10-20020a635f0a000000b00459537f61d4mr10538708pgb.609.1666012112439; Mon, 17 Oct 2022 06:08:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666012112; cv=none; d=google.com; s=arc-20160816; b=uEf22dQzslGlX+JTGypnDsbjsJYgj/W0/HEOi4onhrYHW+mMyrZcasYoAvV3klK4QI UR2Od31whJXCT4B+YEvDbQCqdrsTMXN2R1oCu8U4+yiuwfG3JeSx3YTzhaT+chMP5SmR OPyNfdBEHGcGalSVGieAdv7YcfIs8zvE+VXHlN1/38wo+LZSduHGusLZqeMrBouf6/my K03kIX/93jGk6nrwvmzOiP/q9mKQcK+NYdJ8wAnZSgFQdyllnvgOw2ie5GjAAwKRVe8s wuuldCSqLnunexfOQIwyCLXzF5KH3Zv1Uv1bsIjEvXLpD5a1PODPPxINTb5sby3yqi4S 6xOg== 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=PLWou9aHxYIwk8843AICYlvo+UVxf0K1WcBRRWoT/0s=; b=0+nHf3AePkKPfCYZ+I8RViI/77t1j2BR3Kw59Qe5caRbpPSm1N6zxwa73Wr514agBz QvE6aCcANwoz3B+Ka6ccdZfk4IcmLqZ4WMohOIAHZ3k0JO68ah4kqp3WCDL80u75YkvS 9wuwX6JwWlrCA80IvKeOQmzyC5W8s+MBl/H+QSnB53uz0OMMAAtbNrH8MTS9+Fx1Jz0y IHA0SB7QC1DEQOqD41PdrDsf6VslbrFi0NTGjtuwcpjvDcKhA3bjhl7s30LjjTnGEW3f B1Kiz6fvk+WX3z0A3ppQTAjDgPeM44BDgXsDDyROoJgyzLJAbfu6Ll2n9yhEWFczkH1k IQiw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pi10-20020a17090b1e4a00b00202ae67f30asi13432241pjb.163.2022.10.17.06.08.16; Mon, 17 Oct 2022 06:08:32 -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 S231203AbiJQNDE (ORCPT + 99 others); Mon, 17 Oct 2022 09:03:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231127AbiJQNCk (ORCPT ); Mon, 17 Oct 2022 09:02:40 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 00D835F99D; Mon, 17 Oct 2022 06:02:34 -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 45DBD1042; Mon, 17 Oct 2022 06:02:40 -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 5E3DA3F67D; Mon, 17 Oct 2022 06:02:27 -0700 (PDT) From: Jia He To: Ard Biesheuvel , Len Brown , Tony Luck , Borislav Petkov , Mauro Carvalho Chehab , Robert Richter , Robert Moore , Qiuxu Zhuo , Yazen Ghannam , Jan Luebbe , Khuong Dinh , Kani Toshi Cc: James Morse , 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, Peter Zijlstra , Jia He Subject: [PATCH v9 5/7] EDAC: Add the ghes_get_devices() check for chipset-specific edac drivers Date: Mon, 17 Oct 2022 13:01:38 +0000 Message-Id: <20221017130140.420986-6-justin.he@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221017130140.420986-1-justin.he@arm.com> References: <20221017130140.420986-1-justin.he@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746940316814940262?= X-GMAIL-MSGID: =?utf-8?q?1746940316814940262?= Add ghes_get_devices() check for chipset-specific edac drivers to ensure that ghes_edac is used on the platform where ghes_edac is preferred over chipset-specific edac driver. Unlike the existing edac_get_owner() check, the ghes_get_devices() check works independent to the module_init ordering. Suggested-by: Toshi Kani Signed-off-by: Jia He --- drivers/edac/amd64_edac.c | 3 +++ drivers/edac/armada_xp_edac.c | 3 +++ drivers/edac/edac_module.h | 1 + drivers/edac/i10nm_base.c | 3 +++ drivers/edac/igen6_edac.c | 3 +++ drivers/edac/layerscape_edac.c | 3 +++ drivers/edac/pnd2_edac.c | 3 +++ drivers/edac/sb_edac.c | 3 +++ drivers/edac/skx_base.c | 3 +++ drivers/edac/thunderx_edac.c | 3 +++ drivers/edac/xgene_edac.c | 3 +++ 11 files changed, 31 insertions(+) diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c index 2f854feeeb23..e3318e5575a3 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_get_devices()) + return -EBUSY; + owner = edac_get_owner(); if (owner && strncmp(owner, EDAC_MOD_STR, sizeof(EDAC_MOD_STR))) return -EBUSY; diff --git a/drivers/edac/armada_xp_edac.c b/drivers/edac/armada_xp_edac.c index 038abbb83f4b..c4bd2fb9c46b 100644 --- a/drivers/edac/armada_xp_edac.c +++ b/drivers/edac/armada_xp_edac.c @@ -599,6 +599,9 @@ static int __init armada_xp_edac_init(void) { int res; + if (ghes_get_devices()) + return -EBUSY; + /* only polling is supported */ edac_op_state = EDAC_OPSTATE_POLL; 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..75211ee4cd12 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_get_devices()) + 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..d33c666221f9 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_get_devices()) + return -EBUSY; + owner = edac_get_owner(); if (owner && strncmp(owner, EDAC_MOD_STR, sizeof(EDAC_MOD_STR))) return -ENODEV; diff --git a/drivers/edac/layerscape_edac.c b/drivers/edac/layerscape_edac.c index 94cac7686a56..35ceaca578e1 100644 --- a/drivers/edac/layerscape_edac.c +++ b/drivers/edac/layerscape_edac.c @@ -38,6 +38,9 @@ static int __init fsl_ddr_mc_init(void) { int res; + if (ghes_get_devices()) + return -EBUSY; + /* make sure error reporting method is sane */ switch (edac_op_state) { case EDAC_OPSTATE_POLL: diff --git a/drivers/edac/pnd2_edac.c b/drivers/edac/pnd2_edac.c index a20b299f1202..2b306f2cc605 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_get_devices()) + 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..2c860adf54a7 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_get_devices()) + 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..80a7334111b1 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_get_devices()) + return -EBUSY; + owner = edac_get_owner(); if (owner && strncmp(owner, EDAC_MOD_STR, sizeof(EDAC_MOD_STR))) return -EBUSY; diff --git a/drivers/edac/thunderx_edac.c b/drivers/edac/thunderx_edac.c index f13674081cb6..0bcd9f02c84a 100644 --- a/drivers/edac/thunderx_edac.c +++ b/drivers/edac/thunderx_edac.c @@ -2114,6 +2114,9 @@ static int __init thunderx_edac_init(void) { int rc = 0; + if (ghes_get_devices()) + return -EBUSY; + rc = pci_register_driver(&thunderx_lmc_driver); if (rc) return rc; diff --git a/drivers/edac/xgene_edac.c b/drivers/edac/xgene_edac.c index 54081403db4f..c52b9dd9154c 100644 --- a/drivers/edac/xgene_edac.c +++ b/drivers/edac/xgene_edac.c @@ -2004,6 +2004,9 @@ static int __init xgene_edac_init(void) { int rc; + if (ghes_get_devices()) + return -EBUSY; + /* Make sure error reporting method is sane */ switch (edac_op_state) { case EDAC_OPSTATE_POLL: From patchwork Mon Oct 17 13:01:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin He X-Patchwork-Id: 3440 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1437574wrs; Mon, 17 Oct 2022 06:08:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4UgUcRKpcz4DPM7Iped6rJnGSCSgaFXepvTFZRgG/cA9SbMbFqThncTaZovKtGV0cPGYBZ X-Received: by 2002:a17:90b:4b83:b0:20c:5ac8:1e30 with SMTP id lr3-20020a17090b4b8300b0020c5ac81e30mr34025106pjb.71.1666012119365; Mon, 17 Oct 2022 06:08:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666012119; cv=none; d=google.com; s=arc-20160816; b=APv5TuapFYERLptG0ymCg/Xj7GrHwd/4hQvNEyQ9acvjEa2jfweCIKQh7TiAR6NhEZ BwRdmnCdXDjWLwWJjGPUZ52GWdCU1TRImO9zO2UijqZ0jVeuzryH1pUWOBOKBgQGZxAq ZlsQGqfoseutgTlBeBoIOsOV8Axvwz2gloo4rAaLOyWmMxaqDNV7NlkJ/AXul6iaG0kZ EzFMv/ZfKlC5oNlQw8LO0PRwCpcfvm8digZYubOeLGOGclfX4/Ngv673mEJm3yDM1o93 641qBmX1wl29Rvp3hUuwypvWNETQZ3BJyTMRBIoBpeT/7/NUVqGhiV7MgVlI/r/CBrkl KsBw== 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=fDyf5gfcq/zf48UYeS/apalEfKwoRGzu1KfxvS6Zw28=; b=iODki6gY7pZE1v4rOAOLiENkYMZoGFFU/r49RWhopu/x5F4JLpvaPYeQdOce5UEE2w UYgejNfiAzgfjmQQG175ChY6KFjsIAn58+1TiI7uGt4ygCd3LSIcTEAXHzdXR/YR9sK8 5iQzQXYSNXfP1IedZ3yxGmzrt8xdRkhG3J7Wigbdsq6feuiWNkwsF3G7JzvskJK8ObY1 CcFI1yxa5hCdQF3vflUbxe+m5BSGDHCPLsMlXkZPb7CnNWSzw1zhwI20o9CHHhjWspTo /P+7oFZAF9EWWi9tJ6Txe4AMRNcpa/g0XSOvxJQj81Infog1n8NYnilSMvf+oXSC01jx 0bQw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nv15-20020a17090b1b4f00b00202fb366edbsi12568620pjb.172.2022.10.17.06.08.24; Mon, 17 Oct 2022 06:08:39 -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 S231205AbiJQNDN (ORCPT + 99 others); Mon, 17 Oct 2022 09:03:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231159AbiJQNCu (ORCPT ); Mon, 17 Oct 2022 09:02:50 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8FDBE5F7ED; Mon, 17 Oct 2022 06:02:41 -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 7F631113E; Mon, 17 Oct 2022 06:02:47 -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 97CEE3F67D; Mon, 17 Oct 2022 06:02:34 -0700 (PDT) From: Jia He To: Ard Biesheuvel , Len Brown , Tony Luck , Borislav Petkov , Mauro Carvalho Chehab , Robert Richter , Robert Moore , Qiuxu Zhuo , Yazen Ghannam , Jan Luebbe , Khuong Dinh , Kani Toshi Cc: James Morse , 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, Peter Zijlstra , Jia He Subject: [PATCH v9 6/7] apei/ghes: Use xchg_release() for updating new cache slot instead of cmpxchg() Date: Mon, 17 Oct 2022 13:01:39 +0000 Message-Id: <20221017130140.420986-7-justin.he@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221017130140.420986-1-justin.he@arm.com> References: <20221017130140.420986-1-justin.he@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746940324264239412?= X-GMAIL-MSGID: =?utf-8?q?1746940324264239412?= From: Ard Biesheuvel From: Ard Biesheuvel ghes_estatus_cache_add() selects a slot, and either succeeds in replacing its contents with a pointer to a new cached item, or it just gives up and frees the new item again, without attempting to select another slot even if one might be available. Since only inserting new items is needed, the race can only cause a failure if the selected slot was updated with another new item concurrently, which means that it is arbitrary which of those two items gets dropped. This means the cmpxchg() and the special case are not necessary, and hence just drop the existing item unconditionally. Note that this does not result in loss of error events, it simply means we might cause a false cache miss, and report the same event one additional time in quick succession even if the cache should have prevented that. Move the xchg_release() and call_rcu out of rcu_read_lock/unlock section since there is no actually dereferencing the pointer at all. Co-developed-by: Jia He Signed-off-by: Jia He Signed-off-by: Ard Biesheuvel --- drivers/acpi/apei/ghes.c | 47 +++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index 27c72b175e4b..5d7754053ca0 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -150,7 +150,7 @@ struct ghes_vendor_record_entry { static struct gen_pool *ghes_estatus_pool; static unsigned long ghes_estatus_pool_size_request; -static struct ghes_estatus_cache *ghes_estatus_caches[GHES_ESTATUS_CACHES_SIZE]; +static struct ghes_estatus_cache __rcu *ghes_estatus_caches[GHES_ESTATUS_CACHES_SIZE]; static atomic_t ghes_estatus_cache_alloced; static int ghes_panic_timeout __read_mostly = 30; @@ -785,31 +785,26 @@ static struct ghes_estatus_cache *ghes_estatus_cache_alloc( return cache; } -static void ghes_estatus_cache_free(struct ghes_estatus_cache *cache) +static void ghes_estatus_cache_rcu_free(struct rcu_head *head) { + struct ghes_estatus_cache *cache; u32 len; + cache = container_of(head, struct ghes_estatus_cache, rcu); len = cper_estatus_len(GHES_ESTATUS_FROM_CACHE(cache)); len = GHES_ESTATUS_CACHE_LEN(len); gen_pool_free(ghes_estatus_pool, (unsigned long)cache, len); atomic_dec(&ghes_estatus_cache_alloced); } -static void ghes_estatus_cache_rcu_free(struct rcu_head *head) -{ - struct ghes_estatus_cache *cache; - - cache = container_of(head, struct ghes_estatus_cache, rcu); - ghes_estatus_cache_free(cache); -} - static void ghes_estatus_cache_add( struct acpi_hest_generic *generic, struct acpi_hest_generic_status *estatus) { int i, slot = -1, count; unsigned long long now, duration, period, max_period = 0; - struct ghes_estatus_cache *cache, *slot_cache = NULL, *new_cache; + struct ghes_estatus_cache *cache, *new_cache; + struct ghes_estatus_cache __rcu *victim; new_cache = ghes_estatus_cache_alloc(generic, estatus); if (new_cache == NULL) @@ -820,13 +815,11 @@ static void ghes_estatus_cache_add( cache = rcu_dereference(ghes_estatus_caches[i]); if (cache == NULL) { slot = i; - slot_cache = NULL; break; } duration = now - cache->time_in; if (duration >= GHES_ESTATUS_IN_CACHE_MAX_NSEC) { slot = i; - slot_cache = cache; break; } count = atomic_read(&cache->count); @@ -835,18 +828,28 @@ static void ghes_estatus_cache_add( if (period > max_period) { max_period = period; slot = i; - slot_cache = cache; } } - /* new_cache must be put into array after its contents are written */ - smp_wmb(); - if (slot != -1 && cmpxchg(ghes_estatus_caches + slot, - slot_cache, new_cache) == slot_cache) { - if (slot_cache) - call_rcu(&slot_cache->rcu, ghes_estatus_cache_rcu_free); - } else - ghes_estatus_cache_free(new_cache); rcu_read_unlock(); + + if (slot != -1) { + /* + * Use release semantics to ensure that ghes_estatus_cached() + * running on another CPU will see the updated cache fields if + * it can see the new value of the pointer. + */ + victim = xchg_release(&ghes_estatus_caches[slot], new_cache); + + /* + * At this point, victim may point to a cached item different + * from the one based on which we selected the slot. Instead of + * going to the loop again to pick another slot, let's just + * drop the other item anyway: this may cause a false cache + * miss later on, but that won't cause any problems. + */ + if (victim) + call_rcu(unrcu_pointer(&victim->rcu), ghes_estatus_cache_rcu_free); + } } static void __ghes_panic(struct ghes *ghes, From patchwork Mon Oct 17 13:01:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin He X-Patchwork-Id: 3447 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1438581wrs; Mon, 17 Oct 2022 06:10:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6uYeErAaO90F5dPvvgaMZIKgQHyKnV/BwF5JGihsFAluWflicmH7HPpyDH3CrTjbTi9Vdc X-Received: by 2002:a05:6a00:234d:b0:561:f0c3:cde1 with SMTP id j13-20020a056a00234d00b00561f0c3cde1mr12441455pfj.34.1666012230860; Mon, 17 Oct 2022 06:10:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666012230; cv=none; d=google.com; s=arc-20160816; b=CDCAHP1W0cO+xsBPyFFAXHPHdqHDae+F/0vjQjvrSMwuRrUUs6FlRH6XU3aF5RUeWc 8oblv+kkusdXBjx/ApQVdkz/1+zmFi0EKR5BvIxsM0AizH1HmNx7rrquHEL9/fycqk6n jgcmwxwzvj/SyRPyPQkWryRT5zA2snSDu+VcwUmJlePyDNb7nSqF+KOJUJIWUwsjRMTu RV5HRQoHQ2ugNluisxG+oxlma0oROr/lVrzZppMjReN92+OxvxDQe2QkhDg66/K/nHuZ yKveEKKWAVcmwOsCsd4L2caCe2FOO58VDppmaHmw2K4SKighBz6dbAX6pClm8I/xLRTV 0cRA== 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=Vw1g3sddNnvBcivcb4H6I9inS/5uKnQ7+bfEhV6Tpv8=; b=Dpb6/rLpt/zj8DJTswpVoXXjCd7H/874N66Itwpdu57YBT+Kv/LQTExF2XaVw/kfyx Ew7Fo/F0RJ9bcBoAGJMp5H6/lBomDAeSLLIqX9266jpBPoBkQBVHhi+yZD1b/uon0gm0 5SkPPL6FG6k2zP2QHdY9DAocE43qSR/vFd8rqmvlcicUvDdJgAKNkZqKX4nrQ8FeoKyn mspM2vcrENcX/NK0HNk1ej8leC21IjDo7U7s5GDzAAFuhjfllV3Cx4IUmjmDyy3FSfwS GxCxGOC+ONpqlD+qtmzKe1TmvDp6ndqSpqy5wGroaP/uLrFBAgWDV69WblKC3jaEVAaa e+MA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lr17-20020a17090b4b9100b0020d4590814esi12238519pjb.87.2022.10.17.06.10.17; Mon, 17 Oct 2022 06:10:30 -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 S230215AbiJQND1 (ORCPT + 99 others); Mon, 17 Oct 2022 09:03:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230505AbiJQNCx (ORCPT ); Mon, 17 Oct 2022 09:02:53 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B852F6050B; Mon, 17 Oct 2022 06:02:49 -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 C361C1042; Mon, 17 Oct 2022 06:02:54 -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 D31173F67D; Mon, 17 Oct 2022 06:02:41 -0700 (PDT) From: Jia He To: Ard Biesheuvel , Len Brown , Tony Luck , Borislav Petkov , Mauro Carvalho Chehab , Robert Richter , Robert Moore , Qiuxu Zhuo , Yazen Ghannam , Jan Luebbe , Khuong Dinh , Kani Toshi Cc: James Morse , 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, Peter Zijlstra , Jia He Subject: [PATCH v9 7/7] EDAC/igen6: Return consistent errno when another edac driver is enabled Date: Mon, 17 Oct 2022 13:01:40 +0000 Message-Id: <20221017130140.420986-8-justin.he@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221017130140.420986-1-justin.he@arm.com> References: <20221017130140.420986-1-justin.he@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746940441090174907?= X-GMAIL-MSGID: =?utf-8?q?1746940441090174907?= Only a single edac driver can be enabled for EDAC MC. The igen6_init() should be returned with EBUSY instead of ENODEV, which is consistent with other edac drivers. Signed-off-by: Jia He --- drivers/edac/igen6_edac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/edac/igen6_edac.c b/drivers/edac/igen6_edac.c index d33c666221f9..544dd19072ea 100644 --- a/drivers/edac/igen6_edac.c +++ b/drivers/edac/igen6_edac.c @@ -1276,7 +1276,7 @@ static int __init igen6_init(void) owner = edac_get_owner(); if (owner && strncmp(owner, EDAC_MOD_STR, sizeof(EDAC_MOD_STR))) - return -ENODEV; + return -EBUSY; edac_op_state = EDAC_OPSTATE_NMI;