From patchwork Tue Oct 18 08:22:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin He X-Patchwork-Id: 4010 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1842813wrs; Tue, 18 Oct 2022 01:39:58 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4BwYIA3s+fHyyOpdOltVuWZd6ZDZ7D5ZAza1P3ZslPNvlsfiaxZIT8OQx8q9TiGT1BDewR X-Received: by 2002:a65:6849:0:b0:461:8779:2452 with SMTP id q9-20020a656849000000b0046187792452mr1676227pgt.383.1666082398110; Tue, 18 Oct 2022 01:39:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666082398; cv=none; d=google.com; s=arc-20160816; b=wpXsHFB9URygQxSAWvZ/sVZraMWWAAmc/bH4aDgE+zBwxynIPi8pSkLAJqrDkuntzz rbkCHbvEtxQ/XaSfJZM6QnRwVlra4I2AiUgxlTD6sgYHgJsW9KIV+aFuQh705prGqPS+ 0m4+p6hsDiKwsqVZeCz7VvKSpPmm2RIugJfTVcp2fyRKFzzQ7y/pWwIJYQmYIgdfMFvX F//Icpm2lZ0BHZp7KQpRgK6n/VuVoONOxm5mvHR/sUk8d5UJ14vIqgUIfxnNoQkMpojk 6iFls2ewMyYSWbLGJTqqjM64whgEls+heP3CuFwXrkKo4ZpiKnXPhCuEPXq23EUCDTYE 0JFA== 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=dpzR3o33K6+hUL2Gy2P9BFu7mmp4F7Q1N8yjTJ/0OPdsxgK+lnrA4zN6oy4v1+FCP9 BTFeaHhIcp/CZ3d+1MkiubueEh/IPVfbocdXrNQdazl0b8J158C0JDi5bebWezILirax L23itCvW1WrxwYc9qp7m2/HtHXHTf7TpzCx8/ZRqbNMWL/KcyVdVBr8O3tutxxtWiRgt JmP0QSm0oaLhDviw5l/bw69qb9ywwvarmLwW7BRDvmEMN3tNb5KcJYBgVzH+d9QnrB2e GXtO9EokBgsymMKt9oqBuouiX078RNukyRrBjg92UW47iFtOZ7xLivzO1jSRQy1ODfin NICQ== 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 a11-20020a170902eccb00b00176db576dc0si17748311plh.147.2022.10.18.01.39.45; Tue, 18 Oct 2022 01:39:58 -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 S230131AbiJRI1Z (ORCPT + 99 others); Tue, 18 Oct 2022 04:27:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230501AbiJRI1U (ORCPT ); Tue, 18 Oct 2022 04:27:20 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3BD5E9AC05; Tue, 18 Oct 2022 01:27: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 19232175D; Tue, 18 Oct 2022 01:27: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 265D43F7D8; Tue, 18 Oct 2022 01:27:11 -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 v10 1/7] efi/cper: export several helpers for ghes_edac to use Date: Tue, 18 Oct 2022 08:22:08 +0000 Message-Id: <20221018082214.569504-2-justin.he@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221018082214.569504-1-justin.he@arm.com> References: <20221018082214.569504-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?1747014016756197238?= X-GMAIL-MSGID: =?utf-8?q?1747014016756197238?= 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 Tue Oct 18 08:22:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin He X-Patchwork-Id: 4011 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1842866wrs; Tue, 18 Oct 2022 01:40:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4S6QQeo8BwGcaPYt8r8IZ00ZfnDhpRvsD9O9dlp7Mhv+Ydh5B9HcM+8UtGC/Zyx3VM2jyh X-Received: by 2002:a17:902:b907:b0:178:9d11:c978 with SMTP id bf7-20020a170902b90700b001789d11c978mr1978526plb.90.1666082409164; Tue, 18 Oct 2022 01:40:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666082409; cv=none; d=google.com; s=arc-20160816; b=oRnvfBTOGtoVx8wDKa7MA8RvrwrP7qk/aqcTd7LfLZ/B0FLuOD7J54jOi5d/7nxyy3 Er3FL2RMtvICDajMj8XVTC8/9MY5/6vgcTP/t9ql2g6jz/bOYJPeX/6Ch1/c5WxLXXB7 8TACokZMOlgT90RCLmjxwG9O3Crk+Oi3rUc9+Jly3y8CaNXbCgMRcY4a+fLskNnizaDX OUZlNRNHdoiU6ZiA8wkwAkMEDUAnX0cqCrfeALq5/BuffppYJtncsJGypI9ozS9aFg/N szsfABxqBck3SbweHDok6pcL1UtmQuwK0hMIdpcvReoJRmzbyjGAegYamLgBayqau1yZ H2iA== 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=dAlg5GnuqGuzQYr5xbIjPfjYKOpeFK4AUhh4ZzqMMb7vFkYdmSauGtgA3tQC9HQgsb LNjPQ8werY8rj9W2cAqvau2E93QaLY2YBpI3OeGQOPpcVU1K0iGb4tp7634d4bIufi2M z926h+M0TNfxih9Q0zBKGEJeKAeO1UABbd5A6RHaKIe3TxdU/CjqK64XbxutZCKfdVj3 r7PhyN+JhVaYpSAaEXh02DhT9tB6VnPTUBTlAFCiAozOgZzEWMQ5+9kGIZq9fBfLKZbo s5+Vv+fiQoF7lCrEs7PYlq7qYJ6wdN0CdkfvGqqvrjD3g1qAHCEb7k5mszXQ8DzW9nSm z/vA== 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 x13-20020a65538d000000b0043c8ce98a69si16083231pgq.711.2022.10.18.01.39.57; Tue, 18 Oct 2022 01:40:09 -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 S230525AbiJRI1n (ORCPT + 99 others); Tue, 18 Oct 2022 04:27:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229986AbiJRI1j (ORCPT ); Tue, 18 Oct 2022 04:27:39 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0FA9B9A2B6; Tue, 18 Oct 2022 01:27:26 -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 5C2152050; Tue, 18 Oct 2022 01:27:32 -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 6CF9D3F7D8; Tue, 18 Oct 2022 01:27: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 v10 2/7] EDAC/ghes: Add a notifier for reporting memory errors Date: Tue, 18 Oct 2022 08:22:09 +0000 Message-Id: <20221018082214.569504-3-justin.he@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221018082214.569504-1-justin.he@arm.com> References: <20221018082214.569504-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?1747014028117642658?= X-GMAIL-MSGID: =?utf-8?q?1747014028117642658?= 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 Tue Oct 18 08:22:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin He X-Patchwork-Id: 4012 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1842891wrs; Tue, 18 Oct 2022 01:40:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM76Ur6KsPRgesNM2zdSJDj8KDi4q0qlGobYYe3N6NFs0R3aXLCJ7Nn9k7Ct5NgSsCjHJd8q X-Received: by 2002:a17:90b:314b:b0:20d:a462:b996 with SMTP id ip11-20020a17090b314b00b0020da462b996mr2348684pjb.39.1666082411560; Tue, 18 Oct 2022 01:40:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666082411; cv=none; d=google.com; s=arc-20160816; b=AnwPOX5Xr9lrqfkj6TNO2xJVV8paBO/U1zgPabZZ33ZAnbNwrxY+4Kiw/3prlBTKhW 5NqLgbdMGTa/Q3y4g1PgKCXduu+urpVxKV74ACM02sa6etKEZi9oKITg4Lf+0Ps+hPOq v2vTQRi/EnMC/4Dk+NyeYn6ccrhcJephrEcKOmi12Pnu3PVaMZrAXnDBlyYRXHYafaLk hvS1cQjMuXrAbX5DdBYiBX0lT51t8zRw19tqcfXfNTQHhi52KA8QGI9NVHMS6OtfVJ3a AZGU4ULZ0vaqbmtAkjKY+DLmhUTujPNTmEzUc2u9YxQeOArkOAkPeyegqBVVUFzGDKEI OIhQ== 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=hOuzJ0/+J5kImCaNzdpWVKXMmsCmmu1Xn2QobeDVG64=; b=t4VH6XfKZhcAyK1vmJeptIMQEB3HUOnbDmQyk9a+n81uYm9gcv2zP7r54Wd4AYzAKl to80qpH3XGPHZmOnyoeXGrVz3j8wZAvume7J9EHsJgHBnNp+TEaEM6QuvWYqcl815oD7 h+fTsvDB5o2yVVZw/cjt4kHEdB3j4DOLQxatcEgzLDu68NnCaxLR9bN3lO8h5JxEcTCU 7W0zi9BWoKeQV/mWsnOnSkQuJUxmOKSRYrSrKzVQj4nlCqEq/lmOWn3cAFNFWTZe5BKU Ho1Lyoc+N8go9C+KNxPfbtff9JV2TVTkccTh10YkgMhdcRtypCUv9QX15M/impLISOhi 6LZA== 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 d6-20020a637346000000b0046b041e1123si14074595pgn.452.2022.10.18.01.39.59; Tue, 18 Oct 2022 01:40:11 -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 S229718AbiJRI17 (ORCPT + 99 others); Tue, 18 Oct 2022 04:27:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230235AbiJRI1m (ORCPT ); Tue, 18 Oct 2022 04:27:42 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 76D4A9B846; Tue, 18 Oct 2022 01:27:33 -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 9B88F113E; Tue, 18 Oct 2022 01:27:39 -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 B09743F7D8; Tue, 18 Oct 2022 01:27:26 -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 v10 3/7] EDAC/ghes: Prepare to make ghes_edac a proper module Date: Tue, 18 Oct 2022 08:22:10 +0000 Message-Id: <20221018082214.569504-4-justin.he@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221018082214.569504-1-justin.he@arm.com> References: <20221018082214.569504-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?1747014031089125608?= X-GMAIL-MSGID: =?utf-8?q?1747014031089125608?= To make ghes_edac a proper module, prepare to decouple its dependencies on ghes. ghes_edac_register() is too late to set 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 Tue Oct 18 08:22:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin He X-Patchwork-Id: 4013 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1842900wrs; Tue, 18 Oct 2022 01:40:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6EOZIYeoQWx4aJhv8zy9/MwML3zLEiIKkvccHE9nzkoPaA0Nh8GFw9r0AKKi0KjnW4qih9 X-Received: by 2002:a17:90b:384e:b0:20d:4b52:ddf0 with SMTP id nl14-20020a17090b384e00b0020d4b52ddf0mr2389678pjb.113.1666082414649; Tue, 18 Oct 2022 01:40:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666082414; cv=none; d=google.com; s=arc-20160816; b=cBswtCUqa9iKbzTDYrcjsCvgPfozmDGTCoxkKuPoMTW1PyBn8VQynNNWPxAugJ4McX ZMU2MtgjOviNV7IXjqGAxi5U3p5g6/2X5QwoRCLtIB5Mt3jeS01+1hhz/PJdlFncha3+ QJRjZkR9Kkcpg2U7hrxhCRIBbvaZQ1N9AiEbsetj2IROmHDo9xkqgSi0gQnz1Kdrhi6R SrHDvei7/8zX8PPF3rT8kIV8HX8WhZyKtnjmX6f8aviquWDtnQNm6IEfy7lflwLY45Lu f9xYXQjIL95tkl/b77p2+QwwlG0Zl1vLcY4uDFiSCbaUkHh1dnhTGsyLHSJgK9/Tj1cL SMvA== 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=BmMlbR0ZJKzvW99F9pk0HAWOGulpuLNN7shfbGNeAMQIfK4EGFpCYairh4l85pLz7A P0YIRnYVAU75n8U9/ZJbQ6tPpvgUM3ZL+C1h7HOt/ZzKiFjVJvAltpy0/SnOtTzq2RPs wDH2XE2xgh+vvY1WsoX1vKw3igSYlkWVBjU9lvY2D3V7UirwoWw343hWHTsO8+Muq6HU MSw4O4pWTq1drkawrDTXgsGNz8Hfzee77S8qKk5oEUfz5nVuUzC5n544p8Saag0E1Dkj b2ZQpMcJoZypEv2SX0ypzB29U20aReZ4aZHCXPkzNYRq1BO3T/FapdQbqTxqbVcKYlzk 10bg== 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 s19-20020a63f053000000b0046af247a436si13593231pgj.644.2022.10.18.01.40.02; Tue, 18 Oct 2022 01:40:14 -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 S230499AbiJRI2U (ORCPT + 99 others); Tue, 18 Oct 2022 04:28:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231137AbiJRI1y (ORCPT ); Tue, 18 Oct 2022 04:27:54 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B8B319AFA1; Tue, 18 Oct 2022 01:27: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 D9F0F175D; Tue, 18 Oct 2022 01:27:46 -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 EE1033F7D8; Tue, 18 Oct 2022 01:27:33 -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 v10 4/7] EDAC/ghes: Make ghes_edac a proper module to remove the dependency on ghes Date: Tue, 18 Oct 2022 08:22:11 +0000 Message-Id: <20221018082214.569504-5-justin.he@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221018082214.569504-1-justin.he@arm.com> References: <20221018082214.569504-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?1747014034381441387?= X-GMAIL-MSGID: =?utf-8?q?1747014034381441387?= 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 Tue Oct 18 08:22:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin He X-Patchwork-Id: 4014 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1842940wrs; Tue, 18 Oct 2022 01:40:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Uyox8Hlc39F/Ux0SFP5rH8pNgtlX8SugD2uOXHwfI2K4WgMO5KI9mbXfRCLHubMRsdYHm X-Received: by 2002:a17:902:ce03:b0:178:3ba6:f731 with SMTP id k3-20020a170902ce0300b001783ba6f731mr2108928plg.115.1666082422727; Tue, 18 Oct 2022 01:40:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666082422; cv=none; d=google.com; s=arc-20160816; b=DdVkxby64p1oX5gYIJZnEfSeak/NL4gVG/dkUHG8w26lOjbYrzb9pKi1dxde6VXxIF SZMlH9x20l12ayLDWTcQLV/zeOM1RO+YFgAwDpCvEXSpVLziTXvtWaKhRTm+76lLwuBW gx6QonEnQeIF7tAN81t7UXvoDvZEwgI//rH6I8Bq7FDUTrdSJMAgZdN5f9QeTmlQoESi yq4UVKSVa86tv68//xFDRWeQn9rVfj6Zl5eLL1owgDCfIJ54yYKp90EOlIperv50dVgI veDPJVIw3tYBhvY1/dcL0cAanB7WUbIV9/bMaZp3OhrDdk1F57I1gVzxoOrK0iYdao6i iW2g== 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=BlDwKoKvK+ms18marCwqLDLF4644d4HR6EbHksuLjnvk3FXHzoS9hL3tlnh/KbdNi/ aL5yo8IgLKehzl+mBG6gc/1XfV87+/znp5qGyoqY/s/BsJZkpM1gt7FexJoR3+oCszCu 1MN+Ol6PdltelZTu3WLjPYVkFGHzgRla3PpS2XD/pWc86Qc97szQ9bXl9scfsSMs8ZB8 GuOxxxS5dhwFgrS3rQu3EN9VjikNC9J/ptdjzEGk24LWCXmQ6kV8ZqB27zODQneZM4nt khHrgOAQZMNfZeIRdRJcOcryXKtcUkdUwCraV4YLhGvJcKT+fLpSzUnZZKOpC7yByy5Z H98g== 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 u10-20020a17090341ca00b00174a7230e39si16377321ple.329.2022.10.18.01.40.10; Tue, 18 Oct 2022 01:40:22 -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 S231187AbiJRI2d (ORCPT + 99 others); Tue, 18 Oct 2022 04:28:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231139AbiJRI1z (ORCPT ); Tue, 18 Oct 2022 04:27:55 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 956429C2C0; Tue, 18 Oct 2022 01:27:50 -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 268342050; Tue, 18 Oct 2022 01:27: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 377373F7D8; Tue, 18 Oct 2022 01:27:40 -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 v10 5/7] EDAC: Add the ghes_get_devices() check for chipset-specific edac drivers Date: Tue, 18 Oct 2022 08:22:12 +0000 Message-Id: <20221018082214.569504-6-justin.he@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221018082214.569504-1-justin.he@arm.com> References: <20221018082214.569504-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?1747014042075947779?= X-GMAIL-MSGID: =?utf-8?q?1747014042075947779?= 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 Tue Oct 18 08:22:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin He X-Patchwork-Id: 4015 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1843018wrs; Tue, 18 Oct 2022 01:40:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5rtn7UdYSWTEOGDItFUkVs2i8K8uwK5DD0KlbahSXId0P3SMSosan6ERHhCTu3Xi4MHA19 X-Received: by 2002:a17:902:da83:b0:185:5837:f43a with SMTP id j3-20020a170902da8300b001855837f43amr2224178plx.26.1666082438135; Tue, 18 Oct 2022 01:40:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666082438; cv=none; d=google.com; s=arc-20160816; b=w/a7uUk8hCm7s1XvaWdcjemezgYCO08DBZxmPygM7MtmrFMg5lf0As0J0nMc8oPM81 c3gmws3ZBNeeNsYkeg4iQiWWzUoXDb7O0rafysPM38D5Oc7fycjwo5vRNe6R6m6PtWv9 SvKZwXRSg9DlUuYFIShuG5laKowJviE1rF8xuUn1LTLFDeBBYLfNUt6Yj4ByoSQyO+iA R8jjclu+FDfwPkYVITEv5ICXKVgY905PuuBQ+VBskSME35hY8uGZJNBZZMWeZOfulmkE VzloUOJbOoWZD2d2PJIrgQ5NkVi73C2XCwVd8mJN18dPLuubonBtR1kjhLp4f/S9cKPd ttDg== 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=XgBr/Exf9jetnEHto4I4Vp5TTeJmxoN5RaqemhG/pak=; b=zUvlvWy5f0tA9UZHD6W70Y+wRSTfL4putPrhrJ2wUCbIrep/9PcxjoqXmTWv3DL2g7 99vWlt0s33aPycdBmxqj/0/fozuGxYf+0qqV8kbP8nZdO+Jq2zq0b6MocUW8WQJNWwBm jJUmc4G+sjSfJ+ZO7d7CGCBWQZPRQqciYtcn7f0YfiQru3KtrISxlswXbKUnotJnDi1v xOjNwVys5vJOFMe7C2Malu/InOjQRljqrdLCYv8NVCpTdUNkjD9usY1Xnf+5dSzcTPdH n6OADXx1p9f0yLXyMd2DTadMlOR1AMAXuriazkdDPxQ5Z9Jc8wsSU9/7yg8jwEr2lEJ+ M6fA== 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 z12-20020a170903018c00b00177f35ce11fsi4146698plg.22.2022.10.18.01.40.19; Tue, 18 Oct 2022 01:40:38 -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 S230287AbiJRI3A (ORCPT + 99 others); Tue, 18 Oct 2022 04:29:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231176AbiJRI2c (ORCPT ); Tue, 18 Oct 2022 04:28:32 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2475E9AFC2; Tue, 18 Oct 2022 01:27:59 -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 63354175D; Tue, 18 Oct 2022 01:28:01 -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 773723F7D8; Tue, 18 Oct 2022 01:27:48 -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 v10 6/7] apei/ghes: Use xchg_release() for updating new cache slot instead of cmpxchg() Date: Tue, 18 Oct 2022 08:22:13 +0000 Message-Id: <20221018082214.569504-7-justin.he@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221018082214.569504-1-justin.he@arm.com> References: <20221018082214.569504-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?1747014058398716257?= X-GMAIL-MSGID: =?utf-8?q?1747014058398716257?= 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 | 49 ++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index 27c72b175e4b..3ade61e6b7a5 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,30 @@ 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], + RCU_INITIALIZER(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 Tue Oct 18 08:22:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin He X-Patchwork-Id: 4019 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1843640wrs; Tue, 18 Oct 2022 01:42:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7PaYpjV1IsecGYpnm1032qOS3kU+P8XvyeQqoOm98h6Hq8P9QU7imGSfLEUZwSL7jAF73P X-Received: by 2002:a63:4e16:0:b0:43f:3554:ff9c with SMTP id c22-20020a634e16000000b0043f3554ff9cmr1796493pgb.578.1666082567147; Tue, 18 Oct 2022 01:42:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666082567; cv=none; d=google.com; s=arc-20160816; b=PbGwdQxQK6bDb+APySNKoDtn3Q4/cKEL4+5rxsTbrKOVJ52wE1KNVU8mToZy08Xoh1 c5EUaIIIZq+SGaC0bH5Ajr7IVFMfoUqsD1VKGeHyOWLdQeDT40AQL8KZ/a7W8IikG9BE vMM7cf44lX8uG4cVVRt1u1AgOjQGU9ePdmfbPMZDQBqHNSupL8UEZB+VYJoFXTrnVyhY QyUXqgL3I07ukb94BiewuzJNshkWQmcZYoDgd+JaiqzzTDiC/kE6QJKdmaCpWozFWuF/ G3BRLi1sq2NzuiUHovH49lAbT51Dn/ZdhLfCZ75/R/3LpTCCdsZ7jv4APTM6uwe8ZLEg fqlA== 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=wVs5HT37pO9oD2TzPr1pwHEjRzR7Zr6QdW+Y2dQPBF+ZALnM+Re3uywIesuyM7Udjz SeHjE4IehOFow/PfR4SnOlwydf/Fdkd6eKS1mj39/AnEqI/3HTmyoJXQYGiOawUZ9swp FV46VUxsHqYVdEEWq7v5uhTQbBFH3iBIDnUqtwHrLMWR6eayMthIMXoJNVJIlwvdxGUl OT8qpkSqMOlZoO4MyPhBmAGuu/giYnb/Rp2UWCmmA+TD6wDXXgQDN1vum+r9ccrYCSxv CItB8MWzEP3E+n3d33rHrEZPPuMDLhM58n2VJjUoRKLf8okWshaYn45Tut3xjJetf/DX h/XQ== 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 q1-20020a634301000000b004607d0f5a34si14032135pga.504.2022.10.18.01.42.35; Tue, 18 Oct 2022 01:42:47 -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 S229648AbiJRI3O (ORCPT + 99 others); Tue, 18 Oct 2022 04:29:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230048AbiJRI2g (ORCPT ); Tue, 18 Oct 2022 04:28:36 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 308A792F6B; Tue, 18 Oct 2022 01:28:07 -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 A95ED2050; Tue, 18 Oct 2022 01:28:08 -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 B46AB3F7D8; Tue, 18 Oct 2022 01:27:55 -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 v10 7/7] EDAC/igen6: Return consistent errno when another edac driver is enabled Date: Tue, 18 Oct 2022 08:22:14 +0000 Message-Id: <20221018082214.569504-8-justin.he@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221018082214.569504-1-justin.he@arm.com> References: <20221018082214.569504-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?1747014193476649462?= X-GMAIL-MSGID: =?utf-8?q?1747014193476649462?= 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;