From patchwork Tue Sep 29 19:14:59 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Chen X-Patchwork-Id: 2313724 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:21b9:f100::1; helo=lists.ozlabs.org; envelope-from=linux-aspeed+bounces-5062-incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:21b9:f100::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (secp384r1 raw public key) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hvjt53xgcz1y0d for ; Wed, 30 Sep 2026 15:15:25 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4hvjt50Fppz2yn2; Wed, 30 Sep 2026 15:15:25 +1000 (AEST) X-Original-To: linux-aspeed@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=211.20.114.72 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1790745325; cv=none; b=B6FIZNukulzxLojxPOvEiQfUF5obFZmMH6Al5uBuWixb0iauhqnBKvQf3MGqvbmY67oNNACxqTzAr+hYbAQff3Jv9IKGyXBgbft1vSVsyF4k32p7JPrDF3ofLvPFK8bPx/ddjqx80T4cU3q5Eq5p5U6xJMRvUSzMhu9VDoNRrp/X19b7FK/FZ8tLMCvtuyLY677RrfXhQr9sB095Ucf/SlMuFIanpQL7AHRaW/e9h0WR7psU51J7i0oMeO8enyLqaCiuOlYR84oJEQtA2s+qmsrtS+SutOdOHuUDNz9jQFjqYv3NRATWNdTh1s5ZTz4Xa10UM0Xn86qqbImuZ6eMXQ== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1790745325; c=relaxed/relaxed; bh=xq1JLdoTMC21GchqZzbboOTemAtawiyGvXi9RSRs3mE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=DdjwxWdU/fdGzlEKcmzlwcHCmpiRPSSKmImT6NbbjR85KgnQK//CRkhIBsGNU1HtauTv5+juhJ7/vykcneg0ezTmp6ME6U2jCSWf5dCBZjHANlIrUezaIi6si0hW6J63gXkI3OlL3V+22waVj/PiP1LNm2Tr8Rb6rQ/c//OEtM5TvXhOT0ceEcIb6sdE/9MS1il4ip7zbZBTit9LCnkSkSyb23zh56Y35GNpYGTz4vhm3jSmHHoWVJxXgduoioqziWxuVXZu0iF8VrppMtzjABxcWMN3u87zbv3RogC0j751Q8ACqb3TAulhIRUZBSfUxAFzKVwWGbdspoKQsJZrqw== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=aspeedtech.com; spf=pass (client-ip=211.20.114.72; helo=twmbx01.aspeedtech.com; envelope-from=ryan_chen@aspeedtech.com; receiver=lists.ozlabs.org) smtp.mailfrom=aspeedtech.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=aspeedtech.com Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=aspeedtech.com (client-ip=211.20.114.72; helo=twmbx01.aspeedtech.com; envelope-from=ryan_chen@aspeedtech.com; receiver=lists.ozlabs.org) Received: from twmbx01.aspeedtech.com (mail.aspeedtech.com [211.20.114.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4hvjt42Fqtz2xnQ for ; Wed, 30 Sep 2026 15:15:24 +1000 (AEST) Received: from TWMBX01.aspeed.com (192.168.0.62) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Wed, 30 Sep 2026 13:15:00 +0800 Received: from [127.0.1.1] (192.168.10.13) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server id 15.2.1748.10 via Frontend Transport; Wed, 30 Sep 2026 13:15:00 +0800 From: Ryan Chen Date: Wed, 30 Sep 2026 13:14:59 +0800 Subject: [PATCH v4 1/9] EDAC/aspeed: Set the DIMM grain X-Mailing-List: linux-aspeed@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 Message-ID: <20260930-edac-v4-1-c2e526f3ed79@aspeedtech.com> References: <20260930-edac-v4-0-c2e526f3ed79@aspeedtech.com> In-Reply-To: <20260930-edac-v4-0-c2e526f3ed79@aspeedtech.com> To: Stefan Schaeckeler , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Joel Stanley , Andrew Jeffery , Borislav Petkov , Tony Luck CC: , , , , , Borislav Petkov , Ryan Chen X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1790745299; l=1202; i=ryan_chen@aspeedtech.com; s=20251126; h=from:subject:message-id; bh=3jMs/G66KFFfPwaucwRCSemgPoTboIC6tZoHaXof+m8=; b=sRf7TWL5EgGoyjxkzabJQ3BR3KN5+/hZwCavoxzhzcEykUwr4FbVallHrx6UpntmLwGpvb6tl +HF1wFm18J9Dk3vFfnFkIuQsSx/2Xn0ydiJAM2Hqq1CYB5SeTP6w60O X-Developer-Key: i=ryan_chen@aspeedtech.com; a=ed25519; pk=Xe73xY6tcnkuRjjbVAB/oU30KdB3FvG4nuJuILj7ZVc= X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on lists.ozlabs.org dimm->grain is never set, so every error is reported with a granularity of zero, which edac_raw_mc_handle_error() warns about and substitutes with 1. The controller records the address of a failing access with 16-byte granularity: MCR58 and MCR5C hold it in bits [30:4], with the low four bits reserved. Set the grain to 16 accordingly. Fixes: 9b7e6242ee4e ("EDAC, aspeed: Add an Aspeed AST2500 EDAC driver") Signed-off-by: Ryan Chen --- Changes in v4: - Explain where the grain value comes from rather than the warning it silences. - Drop the Cc: stable tag. --- drivers/edac/aspeed_edac.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/edac/aspeed_edac.c b/drivers/edac/aspeed_edac.c index 6e069b255595..83d60414f89a 100644 --- a/drivers/edac/aspeed_edac.c +++ b/drivers/edac/aspeed_edac.c @@ -266,6 +266,7 @@ static int init_csrows(struct mem_ctl_info *mci) dimm->mtype = dram_type; dimm->edac_mode = EDAC_SECDED; dimm->nr_pages = nr_pages / csrow->nr_channels; + dimm->grain = 16; dev_dbg(mci->pdev, "initialized dimm with first_page=0x%lx and nr_pages=0x%x\n", csrow->first_page, nr_pages); From patchwork Tue Sep 29 19:15:00 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Chen X-Patchwork-Id: 2313725 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linux-aspeed+bounces-5063-incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (secp384r1 raw public key) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hvjt74kPTz1y0d for ; Wed, 30 Sep 2026 15:15:27 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4hvjt575WTz2yqT; Wed, 30 Sep 2026 15:15:25 +1000 (AEST) X-Original-To: linux-aspeed@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=211.20.114.72 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1790745325; cv=none; b=O83Vd9R4HjT4RpGGOY6luo9XhfShFuGMTe477fI7k/osOExqtceaOwb9FwSqGYxuHQPuNIV9vv/xBNqcERcm/eDy8AOn6C6srxeLI7wPHj5LU4MApqswh6wVZRh4lHr2pgA/PvDVH4nyYzu0e5iR3k+7RefMHSXpVBnf95Z9MbleEtS974SkRuCZZxWDaREFKiFpQ1GC3LTPp/g2Ex2rd+sEwb1giw/Wp3c2J9wfz0yPTI4qI8K6MZtInQCzLkFIHjoQJqsi2GNJrsr8ojNOGTOnoZPWDljyORTswZsbeTLUP/qsTLZ/2QnUProKNK+j/Vps0I1d4Igb9/uE8XrqjA== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1790745325; c=relaxed/relaxed; bh=ToaTr9nCw8CRpNfW2tOaDTNTT5eV2ek9/YE3XY/AiNI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=N5lKf/LfkNvm3xlh5s49gZU9ff5yLJbALLed4grDCb55A9XCbPhEYiNnz7GtALxcgZLBVWAOWTz6CvvwVDvWClF+f2pMjzDcsgLHMnFqKtLQWDmex/cgWfCzRtUFk96J6jRMHV5qyEQptoCeLE7hBT4FEl7LO8L/wGWYsTV2tIQTJOkTj2nCBTuBGFk29mHObpjCq1AY6AR9zDQbJ12qbzDFLZX+yPM7HR4MZtBGQ7xN3eU/KXBLgPlYXI3OwcXClWmlkwmF/9l+Ru5XL7qtOzrUy1huVZ7bf6p9Jqg4lIYKKRZ4bLiTksd+33iPNj5GPw410hiifLfVazNHsUCuIQ== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=aspeedtech.com; spf=pass (client-ip=211.20.114.72; helo=twmbx01.aspeedtech.com; envelope-from=ryan_chen@aspeedtech.com; receiver=lists.ozlabs.org) smtp.mailfrom=aspeedtech.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=aspeedtech.com Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=aspeedtech.com (client-ip=211.20.114.72; helo=twmbx01.aspeedtech.com; envelope-from=ryan_chen@aspeedtech.com; receiver=lists.ozlabs.org) Received: from twmbx01.aspeedtech.com (mail.aspeedtech.com [211.20.114.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4hvjt51vV5z2xnQ for ; Wed, 30 Sep 2026 15:15:25 +1000 (AEST) Received: from TWMBX01.aspeed.com (192.168.0.62) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Wed, 30 Sep 2026 13:15:00 +0800 Received: from [127.0.1.1] (192.168.10.13) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server id 15.2.1748.10 via Frontend Transport; Wed, 30 Sep 2026 13:15:00 +0800 From: Ryan Chen Date: Wed, 30 Sep 2026 13:15:00 +0800 Subject: [PATCH v4 2/9] EDAC/aspeed: Free the interrupt before the mem_ctl_info on remove X-Mailing-List: linux-aspeed@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 Message-ID: <20260930-edac-v4-2-c2e526f3ed79@aspeedtech.com> References: <20260930-edac-v4-0-c2e526f3ed79@aspeedtech.com> In-Reply-To: <20260930-edac-v4-0-c2e526f3ed79@aspeedtech.com> To: Stefan Schaeckeler , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Joel Stanley , Andrew Jeffery , Borislav Petkov , Tony Luck CC: , , , , , Borislav Petkov , Ryan Chen X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1790745299; l=1381; i=ryan_chen@aspeedtech.com; s=20251126; h=from:subject:message-id; bh=xfnhxHJqIcWx+yqcMApIiBOpfhKo5Hdnp9j5TMIgdEc=; b=FdNW3hlvPud1TirgbEu7Fmt84CzEsuZiJGTUUd+Kpe0XIbfaQBlVmetPwC3sIqQn0SmRRX4k0 MwwHFA0Xe+NDmLX0ePDz4BBHe3LuzNs93TyFtMDgqYTYUixhtN3kfC/ X-Developer-Key: i=ryan_chen@aspeedtech.com; a=ed25519; pk=Xe73xY6tcnkuRjjbVAB/oU30KdB3FvG4nuJuILj7ZVc= X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on lists.ozlabs.org The ECC interrupt is devm-managed, so it is only released after .remove() has returned, and masking the controller does not wait for a handler already running on another CPU. edac_mc_free() can therefore free the mem_ctl_info the handler uses as its context while it is still running. Fix the ordering and synchronise by freeing the interrupt prior to releasing related memory. Fixes: 9b7e6242ee4e ("EDAC, aspeed: Add an Aspeed AST2500 EDAC driver") Signed-off-by: Ryan Chen --- Changes in v4: - Drop the Cc: stable tag. Changes in v2: - New patch. --- drivers/edac/aspeed_edac.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/edac/aspeed_edac.c b/drivers/edac/aspeed_edac.c index 83d60414f89a..e05ebed5c2f2 100644 --- a/drivers/edac/aspeed_edac.c +++ b/drivers/edac/aspeed_edac.c @@ -359,11 +359,16 @@ static int aspeed_probe(struct platform_device *pdev) static void aspeed_remove(struct platform_device *pdev) { struct mem_ctl_info *mci; + int irq; /* disable interrupts */ regmap_update_bits(aspeed_regmap, ASPEED_MCR_INTR_CTRL, ASPEED_MCR_INTR_CTRL_ENABLE, 0); + irq = platform_get_irq(pdev, 0); + WARN_ON(irq < 0); + devm_free_irq(&pdev->dev, irq, platform_get_drvdata(pdev)); + /* free resources */ mci = edac_mc_del_mc(&pdev->dev); if (mci) From patchwork Tue Sep 29 19:15:01 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Chen X-Patchwork-Id: 2313726 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linux-aspeed+bounces-5064-incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hvjt91dNfz1y0d for ; Wed, 30 Sep 2026 15:15:29 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4hvjt7008Mz308f; Wed, 30 Sep 2026 15:15:26 +1000 (AEST) X-Original-To: linux-aspeed@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=211.20.114.72 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1790745326; cv=none; b=B5pek/CJ9boxO0svH4N4BMPcBM+tAJtnNge1TdNUlRza7sJgEY8wWrSibBOQcGv7cKiGJvQKLNMo1m2h63naT08cfpw/bBdKf/8VAM2b6S7AkFx+fQ7WeYy+SMFYaVawGOxUxQK2UwJlq/V91C7fwjDGcBYxm9CXp9uuD9Il7eKDFvJG8n1q37sdEUdrnu6LkdWD7I6dc8VyAq1so1ujj+GVB/mpSx6LrIOH1CbH/+Xyleb98t6BeQoEDxRpoNm8vcfdbi1ioyWSd55/NbVnWj7gfYG1eO7oMRAN3xvU7u+6QpbF71laFvxx2aFKTjL3Gh4OUW9I+h726tQoCmeO4g== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1790745326; c=relaxed/relaxed; bh=Bv42BCq0VbJx83T3QQNyUqvHP1MGmtolrNTMYYRob5Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=XKvZazIuF8ywTYrD7ffKYV6haoyIuvneP578uDC7KTgB3865cRTedd9IBsFm9tdJOMhqUHToAkPAxSc40vf1IhcKuXNcQKKC0asIozYK/LP3njS8CZfYpL7Y0VNt436yxJ2w8kb7DTPxL4vyQldL/93XAMY7j+T+dpnEVya6Zgc7KUARermdCEaBTaRpMtclncTVZzqdpt0Q9fmKFJSCuoRs9hnE1Lwx/eK+9LvpyDzPAZrsXmwKq/TiPUamE/fSfYlhCr5GmfaclhoyTe2m7NM5if95AQOP92DESBwPhb9uaSZQ5TI5Z+uQjYxhaHTH2vW6NbJJhyyRfdI/OHRhkw== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=aspeedtech.com; spf=pass (client-ip=211.20.114.72; helo=twmbx01.aspeedtech.com; envelope-from=ryan_chen@aspeedtech.com; receiver=lists.ozlabs.org) smtp.mailfrom=aspeedtech.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=aspeedtech.com Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=aspeedtech.com (client-ip=211.20.114.72; helo=twmbx01.aspeedtech.com; envelope-from=ryan_chen@aspeedtech.com; receiver=lists.ozlabs.org) Received: from twmbx01.aspeedtech.com (mail.aspeedtech.com [211.20.114.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4hvjt61TZgz2xnQ for ; Wed, 30 Sep 2026 15:15:26 +1000 (AEST) Received: from TWMBX01.aspeed.com (192.168.0.62) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Wed, 30 Sep 2026 13:15:00 +0800 Received: from [127.0.1.1] (192.168.10.13) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server id 15.2.1748.10 via Frontend Transport; Wed, 30 Sep 2026 13:15:00 +0800 From: Ryan Chen Date: Wed, 30 Sep 2026 13:15:01 +0800 Subject: [PATCH v4 3/9] EDAC/aspeed: Clean up whitespace and include ordering X-Mailing-List: linux-aspeed@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 Message-ID: <20260930-edac-v4-3-c2e526f3ed79@aspeedtech.com> References: <20260930-edac-v4-0-c2e526f3ed79@aspeedtech.com> In-Reply-To: <20260930-edac-v4-0-c2e526f3ed79@aspeedtech.com> To: Stefan Schaeckeler , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Joel Stanley , Andrew Jeffery , Borislav Petkov , Tony Luck CC: , , , , , Borislav Petkov , Ryan Chen X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1790745299; l=4626; i=ryan_chen@aspeedtech.com; s=20251126; h=from:subject:message-id; bh=FhGqCgC1qcv7kHcNVhXGaiiu15ASlL/TX82CfVZ7NtU=; b=Zvr+kHcjG7woXBqcYLP/j2ul7EPBjCUbPtpcq3WtmxWAcrsM9r2jMsEjL7ZueNzb6OYSpZhx4 yOJdyGb7+9EA0UuKqWeS90lzOKdCVi4JOCIVBgEhUY1mNbEZjsvosvl X-Developer-Key: i=ryan_chen@aspeedtech.com; a=ed25519; pk=Xe73xY6tcnkuRjjbVAB/oU30KdB3FvG4nuJuILj7ZVc= X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on lists.ozlabs.org The driver separates functions and definition groups with two blank lines where the kernel style uses one, its headers are not sorted, and it includes linux/stop_machine.h without using it. Collapse the double blank lines, drop the unused include and sort the rest alphabetically so the following changes start from a consistent style. Signed-off-by: Ryan Chen --- drivers/edac/aspeed_edac.c | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/drivers/edac/aspeed_edac.c b/drivers/edac/aspeed_edac.c index e05ebed5c2f2..cd2a6fcca355 100644 --- a/drivers/edac/aspeed_edac.c +++ b/drivers/edac/aspeed_edac.c @@ -4,20 +4,17 @@ */ #include -#include #include #include -#include -#include #include +#include #include +#include #include #include "edac_module.h" - #define DRV_NAME "aspeed-edac" - #define ASPEED_MCR_PROT 0x00 /* protection key register */ #define ASPEED_MCR_CONF 0x04 /* configuration register */ #define ASPEED_MCR_INTR_CTRL 0x50 /* interrupt control/status register */ @@ -25,19 +22,16 @@ #define ASPEED_MCR_ADDR_REC 0x5c /* address of last recoverable error */ #define ASPEED_MCR_LAST ASPEED_MCR_ADDR_REC - -#define ASPEED_MCR_PROT_PASSWD 0xfc600309 -#define ASPEED_MCR_CONF_DRAM_TYPE BIT(4) -#define ASPEED_MCR_CONF_ECC BIT(7) -#define ASPEED_MCR_INTR_CTRL_CLEAR BIT(31) -#define ASPEED_MCR_INTR_CTRL_CNT_REC GENMASK(23, 16) -#define ASPEED_MCR_INTR_CTRL_CNT_UNREC GENMASK(15, 12) -#define ASPEED_MCR_INTR_CTRL_ENABLE (BIT(0) | BIT(1)) - +#define ASPEED_MCR_PROT_PASSWD 0xfc600309 +#define ASPEED_MCR_CONF_DRAM_TYPE BIT(4) +#define ASPEED_MCR_CONF_ECC BIT(7) +#define ASPEED_MCR_INTR_CTRL_CLEAR BIT(31) +#define ASPEED_MCR_INTR_CTRL_CNT_REC GENMASK(23, 16) +#define ASPEED_MCR_INTR_CTRL_CNT_UNREC GENMASK(15, 12) +#define ASPEED_MCR_INTR_CTRL_ENABLE (BIT(0) | BIT(1)) static struct regmap *aspeed_regmap; - static int regmap_reg_write(void *context, unsigned int reg, unsigned int val) { void __iomem *regs = (void __iomem *)context; @@ -53,7 +47,6 @@ static int regmap_reg_write(void *context, unsigned int reg, unsigned int val) return 0; } - static int regmap_reg_read(void *context, unsigned int reg, unsigned int *val) { void __iomem *regs = (void __iomem *)context; @@ -76,7 +69,6 @@ static bool regmap_is_volatile(struct device *dev, unsigned int reg) } } - static const struct regmap_config aspeed_regmap_config = { .reg_bits = 32, .val_bits = 32, @@ -88,7 +80,6 @@ static const struct regmap_config aspeed_regmap_config = { .fast_io = true, }; - static void count_rec(struct mem_ctl_info *mci, u8 rec_cnt, u32 rec_addr) { struct csrow_info *csrow = mci->csrows[0]; @@ -120,7 +111,6 @@ static void count_rec(struct mem_ctl_info *mci, u8 rec_cnt, u32 rec_addr) 0, 0, -1, "", ""); } - static void count_un_rec(struct mem_ctl_info *mci, u8 un_rec_cnt, u32 un_rec_addr) { @@ -153,7 +143,6 @@ static void count_un_rec(struct mem_ctl_info *mci, u8 un_rec_cnt, } } - static irqreturn_t mcr_isr(int irq, void *arg) { struct mem_ctl_info *mci = arg; @@ -200,7 +189,6 @@ static irqreturn_t mcr_isr(int irq, void *arg) return IRQ_HANDLED; } - static int config_irq(void *ctx, struct platform_device *pdev) { int irq; @@ -225,7 +213,6 @@ static int config_irq(void *ctx, struct platform_device *pdev) return 0; } - static int init_csrows(struct mem_ctl_info *mci) { struct csrow_info *csrow = mci->csrows[0]; @@ -274,7 +261,6 @@ static int init_csrows(struct mem_ctl_info *mci) return 0; } - static int aspeed_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -355,7 +341,6 @@ static int aspeed_probe(struct platform_device *pdev) return rc; } - static void aspeed_remove(struct platform_device *pdev) { struct mem_ctl_info *mci; @@ -375,7 +360,6 @@ static void aspeed_remove(struct platform_device *pdev) edac_mc_free(mci); } - static const struct of_device_id aspeed_of_match[] = { { .compatible = "aspeed,ast2400-sdram-edac" }, { .compatible = "aspeed,ast2500-sdram-edac" }, From patchwork Tue Sep 29 19:15:02 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Chen X-Patchwork-Id: 2313727 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linux-aspeed+bounces-5065-incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hvjtC1Jgsz1y0d for ; Wed, 30 Sep 2026 15:15:31 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4hvjt76YlHz30C0; Wed, 30 Sep 2026 15:15:27 +1000 (AEST) X-Original-To: linux-aspeed@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=211.20.114.72 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1790745327; cv=none; b=fQ3OfteuVUFHSbmIPrXxTFx6KmVI9tQU2ZECy8dlystjOaSdWmPgo0aHUBE6nNa8GegKYFHDHVMuquF5gt5UTiP3BstjGOVLLRqOaywPFSSqhGqluCD/v/1AHZTsKkPZIxt03kBy3nmDAhvFX9F4l6ZSulYNDdLWyKG+OF72LudOl2jCj8YcNmtCrwFnEZbqRHvwkF7U+xuZf9CI7GbzZVal/a5rdgqwgzY/6wZuv62N4jRiBnQAb+0zbOGOfmRnADJWg4CSVEBkxUD0kdfo3NPBelWQXm4QykWN+jnEex3EUAFYhU5/6mPDtg6awDdtxEs0mtUahcakWgc2S8oPVw== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1790745327; c=relaxed/relaxed; bh=WzfGEJLpHwH50IZOK4KkDMKN3sG+LbnJq7S0viXLif8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=FWbBY5lZiKv80k17pt0CEqqDmO+HietXB93ohN/1SJwNrRMAohJsXoz5wwTt1oxhB2wF4l0c0e3tiF9WUdr+0zVJe4U81WVuxdGt17R19AX3At064nfo+zOjSpK+tuXtwbnyyv9bYIOU9ihZzqAd8+BxSwU5CRmO5FRI7Ex4aNvuGU06LnUYNrLXA2e0cseZnqgmRd8++Ja4xet9k+9lB2vDJjeS4pt6I+Vb4IDA36WzRmQUhcqqTi+OpJlQBogLwOOwIotew3BMDdSpmgz+Od0SkZhq+ndcRg7/X1zCsGYdC2TlmfcYyJQOxycXH8OlpLWB6o80irfywhTDqBnvWw== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=aspeedtech.com; spf=pass (client-ip=211.20.114.72; helo=twmbx01.aspeedtech.com; envelope-from=ryan_chen@aspeedtech.com; receiver=lists.ozlabs.org) smtp.mailfrom=aspeedtech.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=aspeedtech.com Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=aspeedtech.com (client-ip=211.20.114.72; helo=twmbx01.aspeedtech.com; envelope-from=ryan_chen@aspeedtech.com; receiver=lists.ozlabs.org) Received: from twmbx01.aspeedtech.com (mail.aspeedtech.com [211.20.114.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4hvjt71bldz2xnQ for ; Wed, 30 Sep 2026 15:15:27 +1000 (AEST) Received: from TWMBX01.aspeed.com (192.168.0.62) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Wed, 30 Sep 2026 13:15:00 +0800 Received: from [127.0.1.1] (192.168.10.13) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server id 15.2.1748.10 via Frontend Transport; Wed, 30 Sep 2026 13:15:00 +0800 From: Ryan Chen Date: Wed, 30 Sep 2026 13:15:02 +0800 Subject: [PATCH v4 4/9] EDAC/aspeed: Free the mem_ctl_info unconditionally on remove X-Mailing-List: linux-aspeed@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 Message-ID: <20260930-edac-v4-4-c2e526f3ed79@aspeedtech.com> References: <20260930-edac-v4-0-c2e526f3ed79@aspeedtech.com> In-Reply-To: <20260930-edac-v4-0-c2e526f3ed79@aspeedtech.com> To: Stefan Schaeckeler , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Joel Stanley , Andrew Jeffery , Borislav Petkov , Tony Luck CC: , , , , , Borislav Petkov , Ryan Chen X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1790745299; l=1565; i=ryan_chen@aspeedtech.com; s=20251126; h=from:subject:message-id; bh=7kVBSW+iJq7iG0C/gaN+W7UHNDDfaeN9Q8zh7Gh7SjI=; b=H9Byb9NgdLg6aM+qdKUhskY0XKNa9wuQwv/hYGV/IVIx4+FzRHam+Uz3t55eaUDaRKrtRnhCy qdDLVAR5fFgBFRt9FCt3bjZCcOCH6GYL53CQoZE0ZvBMxugVM7OmnRY X-Developer-Key: i=ryan_chen@aspeedtech.com; a=ed25519; pk=Xe73xY6tcnkuRjjbVAB/oU30KdB3FvG4nuJuILj7ZVc= X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on lists.ozlabs.org aspeed_remove() is a driver .remove callback, so it only runs for a device that has already probed successfully and registered its mem_ctl_info. In that case edac_mc_del_mc() always returns the same, valid pointer, and the NULL check on its return value can never be false. Fetch the mem_ctl_info from the platform device's driver data instead and free it unconditionally, dropping the redundant check. This also decouples the teardown from the return value of edac_mc_del_mc(). Signed-off-by: Ryan Chen --- drivers/edac/aspeed_edac.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/edac/aspeed_edac.c b/drivers/edac/aspeed_edac.c index cd2a6fcca355..352910e1defc 100644 --- a/drivers/edac/aspeed_edac.c +++ b/drivers/edac/aspeed_edac.c @@ -343,7 +343,7 @@ static int aspeed_probe(struct platform_device *pdev) static void aspeed_remove(struct platform_device *pdev) { - struct mem_ctl_info *mci; + struct mem_ctl_info *mci = platform_get_drvdata(pdev); int irq; /* disable interrupts */ @@ -352,12 +352,11 @@ static void aspeed_remove(struct platform_device *pdev) irq = platform_get_irq(pdev, 0); WARN_ON(irq < 0); - devm_free_irq(&pdev->dev, irq, platform_get_drvdata(pdev)); + devm_free_irq(&pdev->dev, irq, mci); /* free resources */ - mci = edac_mc_del_mc(&pdev->dev); - if (mci) - edac_mc_free(mci); + edac_mc_del_mc(&pdev->dev); + edac_mc_free(mci); } static const struct of_device_id aspeed_of_match[] = { From patchwork Tue Sep 29 19:15:03 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Chen X-Patchwork-Id: 2313728 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:21b9:f100::1; helo=lists.ozlabs.org; envelope-from=linux-aspeed+bounces-5066-incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:21b9:f100::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hvjtD1T9yz1y0d for ; Wed, 30 Sep 2026 15:15:32 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4hvjt90M2Nz30C6; Wed, 30 Sep 2026 15:15:29 +1000 (AEST) X-Original-To: linux-aspeed@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=211.20.114.72 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1790745329; cv=none; b=XS3+H9Hg7/OfDAvEYoCyCBNXARNUsNzynnu8XGSiSfHqo0J1TmF/N3MvZ1FBA+IdLUEyQyPl00Zy3FubiPCaAJ7zgbqT2zKtNyw65fbt1zGfsSrThrkYfRInw9j40F84TZ6X20/M5dbSFhs7IHgUdExoYWBUUVAArNAZJp6UodLs4AsbioX12QABRXyTQ24D+Ex4IUkpIOHWn8qf7zhdln7K5WZnKuAc518I/WHmb6dfZkzZwlAcGODQQdatB++STn5OcBqHb9rQBKDHbF9MMatdrpLFqkX0FKYbvgwEPAe8hCAbACVlPcxsqPmXaOA3Hd7JmGThLfZT1mioCqVO6w== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1790745329; c=relaxed/relaxed; bh=jNQAJY0VrRNOcqodeuBlYf2NAb7EX7MKHfLgKkoDvxE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=ewg/Oiz7xzHEnbEUCA0L+YNA1C5U0Zs9iqRGRThCdFPJ8JaQQXwMHvzWmE9OzyN86d4G/t6LMU6glDRLwzkaMn/jJre8mtmr7+sdjx/EPx1MyESPjhm+aJhJIj9PYXmyh6ZQk94nohO4kq8XQVN2Zvi8+q0+XnCntkSFI/sMV9QUJkO0j76XApUb17aujKcILsyZPFdNpNZLDNMleyKcn1P87SHJK2NlKmqvDZ9wFdN2uevJOhbMTYV0bc5HWg56hYO2KFM+6m8QJFwDljd0RvBBlqKbvj0L+5zU/AV171IODs9aSH6CYinnwZy/ZxIKa6u5IBHT6VVGvt1aJmKdTw== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=aspeedtech.com; spf=pass (client-ip=211.20.114.72; helo=twmbx01.aspeedtech.com; envelope-from=ryan_chen@aspeedtech.com; receiver=lists.ozlabs.org) smtp.mailfrom=aspeedtech.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=aspeedtech.com Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=aspeedtech.com (client-ip=211.20.114.72; helo=twmbx01.aspeedtech.com; envelope-from=ryan_chen@aspeedtech.com; receiver=lists.ozlabs.org) Received: from twmbx01.aspeedtech.com (mail.aspeedtech.com [211.20.114.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4hvjt819Gkz2xnQ for ; Wed, 30 Sep 2026 15:15:28 +1000 (AEST) Received: from TWMBX01.aspeed.com (192.168.0.62) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Wed, 30 Sep 2026 13:15:00 +0800 Received: from [127.0.1.1] (192.168.10.13) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server id 15.2.1748.10 via Frontend Transport; Wed, 30 Sep 2026 13:15:00 +0800 From: Ryan Chen Date: Wed, 30 Sep 2026 13:15:03 +0800 Subject: [PATCH v4 5/9] dt-bindings: edac: aspeed: Add AST2700 SDRAM EDAC X-Mailing-List: linux-aspeed@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 Message-ID: <20260930-edac-v4-5-c2e526f3ed79@aspeedtech.com> References: <20260930-edac-v4-0-c2e526f3ed79@aspeedtech.com> In-Reply-To: <20260930-edac-v4-0-c2e526f3ed79@aspeedtech.com> To: Stefan Schaeckeler , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Joel Stanley , Andrew Jeffery , Borislav Petkov , Tony Luck CC: , , , , , Borislav Petkov , Ryan Chen , Krzysztof Kozlowski X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1790745299; l=1457; i=ryan_chen@aspeedtech.com; s=20251126; h=from:subject:message-id; bh=/rj5B9ojWffAdYkp2s4TIp84wfNqe/zSqKMEbEuHOX4=; b=Z6HQq7mR546yGnzLBw/SsqtjdNjKle8U107kZdQSOE4waSFfUuhGbCIe8C9JljTOo+uU5Mn+k qM0RwE61n72DZDmQGGjfc0FxA/oCbAezVMitvtjEi4Lai8SUPk2ukmR X-Developer-Key: i=ryan_chen@aspeedtech.com; a=ed25519; pk=Xe73xY6tcnkuRjjbVAB/oU30KdB3FvG4nuJuILj7ZVc= X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on lists.ozlabs.org Add the "aspeed,ast2700-sdram-edac" compatible and note DDR5 support. Signed-off-by: Ryan Chen Acked-by: Krzysztof Kozlowski --- .../devicetree/bindings/edac/aspeed,ast2400-sdram-edac.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/edac/aspeed,ast2400-sdram-edac.yaml b/Documentation/devicetree/bindings/edac/aspeed,ast2400-sdram-edac.yaml index 09735826d707..685b6815f293 100644 --- a/Documentation/devicetree/bindings/edac/aspeed,ast2400-sdram-edac.yaml +++ b/Documentation/devicetree/bindings/edac/aspeed,ast2400-sdram-edac.yaml @@ -10,8 +10,9 @@ maintainers: - Stefan Schaeckeler description: > - The Aspeed BMC SoC supports DDR3 and DDR4 memory with and without ECC (error - correction check). + The Aspeed BMC SoCs support DDR memory with and without ECC (error + correction check): DDR3 and DDR4 on the AST2400, AST2500 and AST2600, + and DDR4 and DDR5 on the AST2700. The memory controller supports SECDED (single bit error correction, double bit error detection) and single bit error auto scrubbing by reserving 8 bits for @@ -25,6 +26,7 @@ properties: - aspeed,ast2400-sdram-edac - aspeed,ast2500-sdram-edac - aspeed,ast2600-sdram-edac + - aspeed,ast2700-sdram-edac reg: maxItems: 1 From patchwork Tue Sep 29 19:15:04 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Chen X-Patchwork-Id: 2313729 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:21b9:f100::1; helo=lists.ozlabs.org; envelope-from=linux-aspeed+bounces-5067-incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:21b9:f100::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hvjtF33kSz1y0d for ; Wed, 30 Sep 2026 15:15:33 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4hvjtB20Nyz30C9; Wed, 30 Sep 2026 15:15:30 +1000 (AEST) X-Original-To: linux-aspeed@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=211.20.114.72 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1790745330; cv=none; b=bsp//30tt2p4xJuMlE2ielpA4deAcJr1xtTX0ROxYB77Fq9rXLEzly+4AMphZ7dJ1+6pIHOEPQl/PwWyn3+0tAvkmC5dzOzHfyFeZVzu3hrOMuGoM2BQ23efrINP5NgD20Z/2yLPa5A5ZbqMayTh4TDTUKx0D9uZ/Q3gWuU8iCRL/btOfDwVsLbDTdve3PW/5pLTLG0R6xkbvlSBrP6YCBwoFtvUtfMhsGOhszkMjEQtcJhzmx6EjVlpJeyXdjBH8Sz5bz9LmEGyQbNYtaySQRBlWNSilu3yYfVnjXI95c5q+zwA+gui+0Y4pT+2TNV/4UFxvGSPwmWYjk8aixq1GQ== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1790745330; c=relaxed/relaxed; bh=qKo3UAt+aea4ptaZgDeKs/FZOz2vSxjGek6rz3lGW3I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=di9lc+Ja/Yol8irQwAJL8qccxO0o2jnY7C13WPX8+sqYDGteNFnWBW32t3D5Uf4OXi7Ciu//dED6VF7xdupvVnB8dxYUWMML9NaFBlciF1ObkRr0DiPtBG4Z38AdxN7KOvWso/ny0mWagQmRkeIfw37VVWcHA2HwlhioPlo4zsEIphAlEuk6jndGlv/c4/I8hWj5oP1k+fEvjTbJ7G05OeNW3/hDJD1DTgrPcXt9XztBRtjnG6417R7BaBJxj05+dYgd9ZLQln/xuX2i28iJWhfV18uvQ6KkXQovjyD7AAG1Cyde3pX+fQYtktAmTARcalP/JLTtuUuoLsSREVROfw== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=aspeedtech.com; spf=pass (client-ip=211.20.114.72; helo=twmbx01.aspeedtech.com; envelope-from=ryan_chen@aspeedtech.com; receiver=lists.ozlabs.org) smtp.mailfrom=aspeedtech.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=aspeedtech.com Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=aspeedtech.com (client-ip=211.20.114.72; helo=twmbx01.aspeedtech.com; envelope-from=ryan_chen@aspeedtech.com; receiver=lists.ozlabs.org) Received: from twmbx01.aspeedtech.com (mail.aspeedtech.com [211.20.114.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4hvjt91x2Tz2xnQ for ; Wed, 30 Sep 2026 15:15:29 +1000 (AEST) Received: from TWMBX01.aspeed.com (192.168.0.62) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Wed, 30 Sep 2026 13:15:00 +0800 Received: from [127.0.1.1] (192.168.10.13) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server id 15.2.1748.10 via Frontend Transport; Wed, 30 Sep 2026 13:15:00 +0800 From: Ryan Chen Date: Wed, 30 Sep 2026 13:15:04 +0800 Subject: [PATCH v4 6/9] EDAC/aspeed: Replace regmap with direct register access X-Mailing-List: linux-aspeed@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 Message-ID: <20260930-edac-v4-6-c2e526f3ed79@aspeedtech.com> References: <20260930-edac-v4-0-c2e526f3ed79@aspeedtech.com> In-Reply-To: <20260930-edac-v4-0-c2e526f3ed79@aspeedtech.com> To: Stefan Schaeckeler , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Joel Stanley , Andrew Jeffery , Borislav Petkov , Tony Luck CC: , , , , , Borislav Petkov , Ryan Chen X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1790745299; l=9581; i=ryan_chen@aspeedtech.com; s=20251126; h=from:subject:message-id; bh=4vIvjd+wMbaMeekyBwMSPu6kmxJS0RjmBqXcVzKV5HY=; b=bw/OBcacWr7xP+gl6uLEV/B9fx1xuULkIo7gY+CkgRaElUATCVuZvVyUxo+eGlovd5hniPiZC vQzh7KIKaJSAivvJx75G+ZWM4FZhq6dFsE+w24iC6fGeRgNtR1cKTG3 X-Developer-Key: i=ryan_chen@aspeedtech.com; a=ed25519; pk=Xe73xY6tcnkuRjjbVAB/oU30KdB3FvG4nuJuILj7ZVc= X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on lists.ozlabs.org The driver instantiates its own regmap purely as an MMIO wrapper: it has no register cache, uses custom .reg_read()/.reg_write() callbacks, and is not shared as a syscon with other drivers. So it brings nothing here beyond the spinlock that regmap takes around each access when fast_io is set. Drop the regmap and access the registers directly with readl()/writel() under an explicit raw spinlock, held across the whole read-modify-write so the controller is unlocked once around the grouped writes rather than on every register write. Annotate the register base with __guarded_by() so that, under CONFIG_WARN_CONTEXT_ANALYSIS, the compiler checks at build time that every hardware register access is performed while holding the lock. Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Ryan Chen --- Changes in v2: - Take the register lock with the irqsave variant in init_csrows() and in aspeed_probe(); the interrupt handler takes the same lock in hardirq context. - Move the dev_dbg() of the interrupt status register out of the raw_spinlock critical section in the interrupt handler. - Opt aspeed_edac.o into context analysis in drivers/edac/Makefile, so that the __guarded_by() annotation is actually checked. - Note in the interrupt handler that the counter and interrupt flag fields are read-only, so writing back the read value is harmless. --- drivers/edac/Makefile | 1 + drivers/edac/aspeed_edac.c | 131 +++++++++++++++++---------------------------- 2 files changed, 51 insertions(+), 81 deletions(-) diff --git a/drivers/edac/Makefile b/drivers/edac/Makefile index a37534300ab9..9215dd0bb835 100644 --- a/drivers/edac/Makefile +++ b/drivers/edac/Makefile @@ -82,6 +82,7 @@ obj-$(CONFIG_EDAC_SYNOPSYS) += synopsys_edac.o obj-$(CONFIG_EDAC_XGENE) += xgene_edac.o obj-$(CONFIG_EDAC_TI) += ti_edac.o obj-$(CONFIG_EDAC_QCOM) += qcom_edac.o +CONTEXT_ANALYSIS_aspeed_edac.o := y obj-$(CONFIG_EDAC_ASPEED) += aspeed_edac.o obj-$(CONFIG_EDAC_BLUEFIELD) += bluefield_edac.o obj-$(CONFIG_EDAC_DMC520) += dmc520_edac.o diff --git a/drivers/edac/aspeed_edac.c b/drivers/edac/aspeed_edac.c index 352910e1defc..26d2c456cc0d 100644 --- a/drivers/edac/aspeed_edac.c +++ b/drivers/edac/aspeed_edac.c @@ -3,6 +3,7 @@ * Copyright 2018, 2019 Cisco Systems */ +#include #include #include #include @@ -10,7 +11,7 @@ #include #include #include -#include +#include #include "edac_module.h" #define DRV_NAME "aspeed-edac" @@ -20,7 +21,6 @@ #define ASPEED_MCR_INTR_CTRL 0x50 /* interrupt control/status register */ #define ASPEED_MCR_ADDR_UNREC 0x58 /* address of first un-recoverable error */ #define ASPEED_MCR_ADDR_REC 0x5c /* address of last recoverable error */ -#define ASPEED_MCR_LAST ASPEED_MCR_ADDR_REC #define ASPEED_MCR_PROT_PASSWD 0xfc600309 #define ASPEED_MCR_CONF_DRAM_TYPE BIT(4) @@ -30,55 +30,8 @@ #define ASPEED_MCR_INTR_CTRL_CNT_UNREC GENMASK(15, 12) #define ASPEED_MCR_INTR_CTRL_ENABLE (BIT(0) | BIT(1)) -static struct regmap *aspeed_regmap; - -static int regmap_reg_write(void *context, unsigned int reg, unsigned int val) -{ - void __iomem *regs = (void __iomem *)context; - - /* enable write to MCR register set */ - writel(ASPEED_MCR_PROT_PASSWD, regs + ASPEED_MCR_PROT); - - writel(val, regs + reg); - - /* disable write to MCR register set */ - writel(~ASPEED_MCR_PROT_PASSWD, regs + ASPEED_MCR_PROT); - - return 0; -} - -static int regmap_reg_read(void *context, unsigned int reg, unsigned int *val) -{ - void __iomem *regs = (void __iomem *)context; - - *val = readl(regs + reg); - - return 0; -} - -static bool regmap_is_volatile(struct device *dev, unsigned int reg) -{ - switch (reg) { - case ASPEED_MCR_PROT: - case ASPEED_MCR_INTR_CTRL: - case ASPEED_MCR_ADDR_UNREC: - case ASPEED_MCR_ADDR_REC: - return true; - default: - return false; - } -} - -static const struct regmap_config aspeed_regmap_config = { - .reg_bits = 32, - .val_bits = 32, - .reg_stride = 4, - .max_register = ASPEED_MCR_LAST, - .reg_write = regmap_reg_write, - .reg_read = regmap_reg_read, - .volatile_reg = regmap_is_volatile, - .fast_io = true, -}; +static DEFINE_RAW_SPINLOCK(aspeed_lock); +static void __iomem *aspeed_regs __guarded_by(&aspeed_lock); static void count_rec(struct mem_ctl_info *mci, u8 rec_cnt, u32 rec_addr) { @@ -147,10 +100,27 @@ static irqreturn_t mcr_isr(int irq, void *arg) { struct mem_ctl_info *mci = arg; u32 rec_addr, un_rec_addr; - u32 reg50, reg5c, reg58; - u8 rec_cnt, un_rec_cnt; + u8 rec_cnt, un_rec_cnt; + u32 reg50; + + scoped_guard(raw_spinlock, &aspeed_lock) { + reg50 = readl(aspeed_regs + ASPEED_MCR_INTR_CTRL); + un_rec_addr = readl(aspeed_regs + ASPEED_MCR_ADDR_UNREC); + rec_addr = readl(aspeed_regs + ASPEED_MCR_ADDR_REC); + + /* + * Clearing the counters needs a set-then-clear of CLEAR. The + * counter and interrupt flag fields are read-only, so writing + * back the values read above leaves them unaffected. + */ + writel(ASPEED_MCR_PROT_PASSWD, aspeed_regs + ASPEED_MCR_PROT); + writel(reg50 | ASPEED_MCR_INTR_CTRL_CLEAR, + aspeed_regs + ASPEED_MCR_INTR_CTRL); + writel(reg50 & ~ASPEED_MCR_INTR_CTRL_CLEAR, + aspeed_regs + ASPEED_MCR_INTR_CTRL); + writel(~ASPEED_MCR_PROT_PASSWD, aspeed_regs + ASPEED_MCR_PROT); + } - regmap_read(aspeed_regmap, ASPEED_MCR_INTR_CTRL, ®50); dev_dbg(mci->pdev, "received edac interrupt w/ mcr register 50: 0x%x\n", reg50); @@ -161,20 +131,6 @@ static irqreturn_t mcr_isr(int irq, void *arg) dev_dbg(mci->pdev, "%d recoverable interrupts and %d unrecoverable interrupts\n", rec_cnt, un_rec_cnt); - regmap_read(aspeed_regmap, ASPEED_MCR_ADDR_UNREC, ®58); - un_rec_addr = reg58; - - regmap_read(aspeed_regmap, ASPEED_MCR_ADDR_REC, ®5c); - rec_addr = reg5c; - - /* clear interrupt flags and error counters: */ - regmap_update_bits(aspeed_regmap, ASPEED_MCR_INTR_CTRL, - ASPEED_MCR_INTR_CTRL_CLEAR, - ASPEED_MCR_INTR_CTRL_CLEAR); - - regmap_update_bits(aspeed_regmap, ASPEED_MCR_INTR_CTRL, - ASPEED_MCR_INTR_CTRL_CLEAR, 0); - /* process recoverable and unrecoverable errors */ count_rec(mci, rec_cnt, rec_addr); count_un_rec(mci, un_rec_cnt, un_rec_addr); @@ -182,13 +138,31 @@ static irqreturn_t mcr_isr(int irq, void *arg) if (!rec_cnt && !un_rec_cnt) dev_dbg(mci->pdev, "received edac interrupt, but did not find any ECC counters\n"); - regmap_read(aspeed_regmap, ASPEED_MCR_INTR_CTRL, ®50); + scoped_guard(raw_spinlock, &aspeed_lock) + reg50 = readl(aspeed_regs + ASPEED_MCR_INTR_CTRL); dev_dbg(mci->pdev, "edac interrupt handled. mcr reg 50 is now: 0x%x\n", reg50); return IRQ_HANDLED; } +static void aspeed_set_irq(bool enable) +{ + u32 val; + + guard(raw_spinlock_irqsave)(&aspeed_lock); + + val = readl(aspeed_regs + ASPEED_MCR_INTR_CTRL); + if (enable) + val |= ASPEED_MCR_INTR_CTRL_ENABLE; + else + val &= ~ASPEED_MCR_INTR_CTRL_ENABLE; + + writel(ASPEED_MCR_PROT_PASSWD, aspeed_regs + ASPEED_MCR_PROT); + writel(val, aspeed_regs + ASPEED_MCR_INTR_CTRL); + writel(~ASPEED_MCR_PROT_PASSWD, aspeed_regs + ASPEED_MCR_PROT); +} + static int config_irq(void *ctx, struct platform_device *pdev) { int irq; @@ -206,9 +180,7 @@ static int config_irq(void *ctx, struct platform_device *pdev) return rc; /* enable interrupts */ - regmap_update_bits(aspeed_regmap, ASPEED_MCR_INTR_CTRL, - ASPEED_MCR_INTR_CTRL_ENABLE, - ASPEED_MCR_INTR_CTRL_ENABLE); + aspeed_set_irq(true); return 0; } @@ -246,7 +218,8 @@ static int init_csrows(struct mem_ctl_info *mci) nr_pages = resource_size(&r) >> PAGE_SHIFT; csrow->last_page = csrow->first_page + nr_pages - 1; - regmap_read(aspeed_regmap, ASPEED_MCR_CONF, ®04); + scoped_guard(raw_spinlock_irqsave, &aspeed_lock) + reg04 = readl(aspeed_regs + ASPEED_MCR_CONF); dram_type = (reg04 & ASPEED_MCR_CONF_DRAM_TYPE) ? MEM_DDR4 : MEM_DDR3; dimm = csrow->channels[0]->dimm; @@ -263,7 +236,6 @@ static int init_csrows(struct mem_ctl_info *mci) static int aspeed_probe(struct platform_device *pdev) { - struct device *dev = &pdev->dev; struct edac_mc_layer layers[2]; struct mem_ctl_info *mci; void __iomem *regs; @@ -274,13 +246,11 @@ static int aspeed_probe(struct platform_device *pdev) if (IS_ERR(regs)) return PTR_ERR(regs); - aspeed_regmap = devm_regmap_init(dev, NULL, (__force void *)regs, - &aspeed_regmap_config); - if (IS_ERR(aspeed_regmap)) - return PTR_ERR(aspeed_regmap); + scoped_guard(raw_spinlock_irqsave, &aspeed_lock) + aspeed_regs = regs; /* bail out if ECC mode is not configured */ - regmap_read(aspeed_regmap, ASPEED_MCR_CONF, ®04); + reg04 = readl(regs + ASPEED_MCR_CONF); if (!(reg04 & ASPEED_MCR_CONF_ECC)) { dev_err(&pdev->dev, "ECC mode is not configured in u-boot\n"); return -EPERM; @@ -347,8 +317,7 @@ static void aspeed_remove(struct platform_device *pdev) int irq; /* disable interrupts */ - regmap_update_bits(aspeed_regmap, ASPEED_MCR_INTR_CTRL, - ASPEED_MCR_INTR_CTRL_ENABLE, 0); + aspeed_set_irq(false); irq = platform_get_irq(pdev, 0); WARN_ON(irq < 0); From patchwork Tue Sep 29 19:15:05 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Chen X-Patchwork-Id: 2313730 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:21b9:f100::1; helo=lists.ozlabs.org; envelope-from=linux-aspeed+bounces-5068-incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:21b9:f100::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hvjtG4kHsz1y0d for ; Wed, 30 Sep 2026 15:15:34 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4hvjtC3wcgz30CZ; Wed, 30 Sep 2026 15:15:31 +1000 (AEST) X-Original-To: linux-aspeed@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=211.20.114.72 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1790745331; cv=none; b=U/xo9NyKGwi8dCBOsQansJKwI/be5GiAMQqLC2bQ5Lhg2MJ3X82Q/rzrXvPBjG/SNksmu0uRY9Cjf8mM1M2CuEXO3N06KIl7o5bMf3YNGpDTNCa5L4aWoEHN5c//rAQ0xo+HSk3etlwrcD8hnmWePjgdsfRy9uIu7lxVlRESapBziTfDT+nWImlj9PKn8LMWdh8COYqEuB01Wu+OWHACC0pP6C9IqwG4AevNPtdD3+LK3zorJA0D7XM5zVUBbtKO6FX+7RTvcb0+7I/y4dbMLWqdiDf4vwbGSQMGQgAUqf8YR+4XbdFqtF+0wzMBwhwHr+PrdZkA2HsuOEk8XZ/4yQ== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1790745331; c=relaxed/relaxed; bh=a1g4cFM2WSPo1E46t/j2LwC9w7NZQoGrUjOI+UYrux0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=FMc0DdhbpfpjOVoVmptXFjjKndA1Ur4CsWkR2uSJlCO+qmKzijUo5YgH03FPhZpirw0JmMnGQCWO8+XSMYG0amC3ct4/UG02D1oDwblpPfp1v4IWOgCWxwHLZUa3aF4sVV7fcne2wSX0uN8EAXm5M1hQG1CGAQzb0Bp/82IrK/jfuyLmiLkcd4h6Xe5+H7yMwfyG9acIapA0J09XnwRQF1vyOkAIWGMlOzp7ZJaHp7Pgcvj5zybJBsAY9J0gbE7yK7QgVPoGYWx4w72EVBt8dIhjHK3B6xMV6MpLIbs+7dMv63P/T8bMWOkZ6LNEjk2LQzMEgiU3LNrIbNkG/1+2XA== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=aspeedtech.com; spf=pass (client-ip=211.20.114.72; helo=twmbx01.aspeedtech.com; envelope-from=ryan_chen@aspeedtech.com; receiver=lists.ozlabs.org) smtp.mailfrom=aspeedtech.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=aspeedtech.com Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=aspeedtech.com (client-ip=211.20.114.72; helo=twmbx01.aspeedtech.com; envelope-from=ryan_chen@aspeedtech.com; receiver=lists.ozlabs.org) Received: from twmbx01.aspeedtech.com (mail.aspeedtech.com [211.20.114.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4hvjtB3d22z2xnQ for ; Wed, 30 Sep 2026 15:15:30 +1000 (AEST) Received: from TWMBX01.aspeed.com (192.168.0.62) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Wed, 30 Sep 2026 13:15:00 +0800 Received: from [127.0.1.1] (192.168.10.13) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server id 15.2.1748.10 via Frontend Transport; Wed, 30 Sep 2026 13:15:00 +0800 From: Ryan Chen Date: Wed, 30 Sep 2026 13:15:05 +0800 Subject: [PATCH v4 7/9] EDAC/aspeed: Abstract SoC differences behind chip data X-Mailing-List: linux-aspeed@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 Message-ID: <20260930-edac-v4-7-c2e526f3ed79@aspeedtech.com> References: <20260930-edac-v4-0-c2e526f3ed79@aspeedtech.com> In-Reply-To: <20260930-edac-v4-0-c2e526f3ed79@aspeedtech.com> To: Stefan Schaeckeler , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Joel Stanley , Andrew Jeffery , Borislav Petkov , Tony Luck CC: , , , , , Borislav Petkov , Ryan Chen X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1790745299; l=12030; i=ryan_chen@aspeedtech.com; s=20251126; h=from:subject:message-id; bh=9GcVj2fdxxCTsPwP9/o+MgofFZHMPAKymQnxcoTT3v0=; b=z06yhgWmDDxmmobB9Znqh+9VV0zKNDMZSd0lxTkZUva6dOs8DPudbF/kxpklHwtY7TYVYMsM1 8Lo8BNUuTbrCIj640Z4gOtyVLak36on77kjW78Npeicbus2FjRBNq18 X-Developer-Key: i=ryan_chen@aspeedtech.com; a=ed25519; pk=Xe73xY6tcnkuRjjbVAB/oU30KdB3FvG4nuJuILj7ZVc= X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on lists.ozlabs.org The driver hard-codes the AST2400/2500/2600 register layout, ECC and DRAM-type bits, memory types and write-protection key. Abstract these SoC-specific details behind a per-SoC struct aspeed_edac_chip selected by the compatible, and move the per-instance state (register base, lock) into mci->pvt_info instead of globals, so controller variants that differ in these details can be added as table data. Only the AST2400 and AST2500 key-protect the interrupt control register (MCR50); the AST2600 does not. Gate the unlock/relock on the chip carrying a protection key and split the shared entry into keyed (AST2400/2500) and unkeyed (AST2600) variants, so the AST2600 no longer performs the unnecessary unlock. Tested on an AST2600: A correctable error was injected from the console by unlocking the controller and writing its ECC error inject test register: # mw 1e6e0000 fc600309 # mw 1e6e00b0 81 EDAC MC0: 1 CE address(es) not available on mc#0csrow#0channel#0 (csrow:0 channel:0 page:0x0 offset:0x0 grain:16 syndrome:0x0) EDAC MC0: 1 CE on mc#0csrow#0channel#0 (csrow:0 channel:0 page:0x8a543 offset:0xec0 grain:16 syndrome:0x0) Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Ryan Chen --- Changes in v2: - Carry over the irqsave lock acquisition in init_csrows() and the dev_dbg() moved out of the raw_spinlock critical section. - Store the interrupt number in struct aspeed_edac so that aspeed_remove() can free the interrupt without looking it up again. --- drivers/edac/aspeed_edac.c | 163 +++++++++++++++++++++++++++++++-------------- 1 file changed, 114 insertions(+), 49 deletions(-) diff --git a/drivers/edac/aspeed_edac.c b/drivers/edac/aspeed_edac.c index 26d2c456cc0d..e88d9d2646de 100644 --- a/drivers/edac/aspeed_edac.c +++ b/drivers/edac/aspeed_edac.c @@ -3,12 +3,14 @@ * Copyright 2018, 2019 Cisco Systems */ +#include #include #include #include #include #include #include +#include #include #include #include @@ -30,8 +32,23 @@ #define ASPEED_MCR_INTR_CTRL_CNT_UNREC GENMASK(15, 12) #define ASPEED_MCR_INTR_CTRL_ENABLE (BIT(0) | BIT(1)) -static DEFINE_RAW_SPINLOCK(aspeed_lock); -static void __iomem *aspeed_regs __guarded_by(&aspeed_lock); +struct aspeed_edac_chip { + unsigned int conf_reg; + u32 conf_ecc; + u32 conf_dram_type; + enum mem_type dram_type[2]; + unsigned long mtype_cap; + unsigned int prot_reg; + u32 prot_key; +}; + +struct aspeed_edac { + raw_spinlock_t lock; + + void __iomem *regs __guarded_by(&lock); + const struct aspeed_edac_chip *chip; + int irq; +}; static void count_rec(struct mem_ctl_info *mci, u8 rec_cnt, u32 rec_addr) { @@ -96,37 +113,54 @@ static void count_un_rec(struct mem_ctl_info *mci, u8 un_rec_cnt, } } -static irqreturn_t mcr_isr(int irq, void *arg) +static void aspeed_mcr_irq_update_enter(struct aspeed_edac *priv) + __must_hold(&priv->lock) +{ + if (priv->chip->prot_key) + writel(priv->chip->prot_key, priv->regs + priv->chip->prot_reg); +} + +static void aspeed_mcr_irq_update_exit(struct aspeed_edac *priv) + __must_hold(&priv->lock) +{ + if (priv->chip->prot_key) + writel(~priv->chip->prot_key, priv->regs + priv->chip->prot_reg); +} + +static irqreturn_t aspeed_mcr_isr(int irq, void *arg) { struct mem_ctl_info *mci = arg; u32 rec_addr, un_rec_addr; + struct aspeed_edac *priv; u8 rec_cnt, un_rec_cnt; u32 reg50; - scoped_guard(raw_spinlock, &aspeed_lock) { - reg50 = readl(aspeed_regs + ASPEED_MCR_INTR_CTRL); - un_rec_addr = readl(aspeed_regs + ASPEED_MCR_ADDR_UNREC); - rec_addr = readl(aspeed_regs + ASPEED_MCR_ADDR_REC); + priv = mci->pvt_info; + + scoped_guard(raw_spinlock, &priv->lock) { + reg50 = readl(priv->regs + ASPEED_MCR_INTR_CTRL); + un_rec_addr = readl(priv->regs + ASPEED_MCR_ADDR_UNREC); + rec_addr = readl(priv->regs + ASPEED_MCR_ADDR_REC); /* * Clearing the counters needs a set-then-clear of CLEAR. The * counter and interrupt flag fields are read-only, so writing * back the values read above leaves them unaffected. */ - writel(ASPEED_MCR_PROT_PASSWD, aspeed_regs + ASPEED_MCR_PROT); + aspeed_mcr_irq_update_enter(priv); writel(reg50 | ASPEED_MCR_INTR_CTRL_CLEAR, - aspeed_regs + ASPEED_MCR_INTR_CTRL); + priv->regs + ASPEED_MCR_INTR_CTRL); writel(reg50 & ~ASPEED_MCR_INTR_CTRL_CLEAR, - aspeed_regs + ASPEED_MCR_INTR_CTRL); - writel(~ASPEED_MCR_PROT_PASSWD, aspeed_regs + ASPEED_MCR_PROT); + priv->regs + ASPEED_MCR_INTR_CTRL); + aspeed_mcr_irq_update_exit(priv); } dev_dbg(mci->pdev, "received edac interrupt w/ mcr register 50: 0x%x\n", reg50); /* collect data about recoverable and unrecoverable errors */ - rec_cnt = (reg50 & ASPEED_MCR_INTR_CTRL_CNT_REC) >> 16; - un_rec_cnt = (reg50 & ASPEED_MCR_INTR_CTRL_CNT_UNREC) >> 12; + rec_cnt = FIELD_GET(ASPEED_MCR_INTR_CTRL_CNT_REC, reg50); + un_rec_cnt = FIELD_GET(ASPEED_MCR_INTR_CTRL_CNT_UNREC, reg50); dev_dbg(mci->pdev, "%d recoverable interrupts and %d unrecoverable interrupts\n", rec_cnt, un_rec_cnt); @@ -136,35 +170,36 @@ static irqreturn_t mcr_isr(int irq, void *arg) count_un_rec(mci, un_rec_cnt, un_rec_addr); if (!rec_cnt && !un_rec_cnt) - dev_dbg(mci->pdev, "received edac interrupt, but did not find any ECC counters\n"); + dev_dbg_ratelimited(mci->pdev, "received edac interrupt, but did not find any ECC counters\n"); - scoped_guard(raw_spinlock, &aspeed_lock) - reg50 = readl(aspeed_regs + ASPEED_MCR_INTR_CTRL); + scoped_guard(raw_spinlock, &priv->lock) + reg50 = readl(priv->regs + ASPEED_MCR_INTR_CTRL); dev_dbg(mci->pdev, "edac interrupt handled. mcr reg 50 is now: 0x%x\n", reg50); return IRQ_HANDLED; } -static void aspeed_set_irq(bool enable) +static void aspeed_set_irq(struct aspeed_edac *priv, bool enable) { u32 val; - guard(raw_spinlock_irqsave)(&aspeed_lock); + guard(raw_spinlock_irqsave)(&priv->lock); - val = readl(aspeed_regs + ASPEED_MCR_INTR_CTRL); + val = readl(priv->regs + ASPEED_MCR_INTR_CTRL); if (enable) val |= ASPEED_MCR_INTR_CTRL_ENABLE; else val &= ~ASPEED_MCR_INTR_CTRL_ENABLE; - writel(ASPEED_MCR_PROT_PASSWD, aspeed_regs + ASPEED_MCR_PROT); - writel(val, aspeed_regs + ASPEED_MCR_INTR_CTRL); - writel(~ASPEED_MCR_PROT_PASSWD, aspeed_regs + ASPEED_MCR_PROT); + aspeed_mcr_irq_update_enter(priv); + writel(val, priv->regs + ASPEED_MCR_INTR_CTRL); + aspeed_mcr_irq_update_exit(priv); } -static int config_irq(void *ctx, struct platform_device *pdev) +static int config_irq(struct mem_ctl_info *mci, struct platform_device *pdev) { + struct aspeed_edac *priv = mci->pvt_info; int irq; int rc; @@ -174,13 +209,15 @@ static int config_irq(void *ctx, struct platform_device *pdev) if (irq < 0) return irq; - rc = devm_request_irq(&pdev->dev, irq, mcr_isr, IRQF_TRIGGER_HIGH, - DRV_NAME, ctx); + rc = devm_request_irq(&pdev->dev, irq, aspeed_mcr_isr, IRQF_TRIGGER_HIGH, + DRV_NAME, mci); if (rc) return rc; + priv->irq = irq; + /* enable interrupts */ - aspeed_set_irq(true); + aspeed_set_irq(priv, true); return 0; } @@ -188,11 +225,13 @@ static int config_irq(void *ctx, struct platform_device *pdev) static int init_csrows(struct mem_ctl_info *mci) { struct csrow_info *csrow = mci->csrows[0]; - u32 nr_pages, dram_type; - struct dimm_info *dimm; + struct aspeed_edac *priv = mci->pvt_info; struct device_node *np; + struct dimm_info *dimm; struct resource r; - u32 reg04; + unsigned int type; + u32 nr_pages; + u32 conf; int rc; /* retrieve info about physical memory from device tree */ @@ -218,12 +257,12 @@ static int init_csrows(struct mem_ctl_info *mci) nr_pages = resource_size(&r) >> PAGE_SHIFT; csrow->last_page = csrow->first_page + nr_pages - 1; - scoped_guard(raw_spinlock_irqsave, &aspeed_lock) - reg04 = readl(aspeed_regs + ASPEED_MCR_CONF); - dram_type = (reg04 & ASPEED_MCR_CONF_DRAM_TYPE) ? MEM_DDR4 : MEM_DDR3; + scoped_guard(raw_spinlock_irqsave, &priv->lock) + conf = readl(priv->regs + priv->chip->conf_reg); + type = field_get(priv->chip->conf_dram_type, conf); dimm = csrow->channels[0]->dimm; - dimm->mtype = dram_type; + dimm->mtype = priv->chip->dram_type[type]; dimm->edac_mode = EDAC_SECDED; dimm->nr_pages = nr_pages / csrow->nr_channels; dimm->grain = 16; @@ -236,22 +275,26 @@ static int init_csrows(struct mem_ctl_info *mci) static int aspeed_probe(struct platform_device *pdev) { + const struct aspeed_edac_chip *chip; + struct device *dev = &pdev->dev; struct edac_mc_layer layers[2]; + struct aspeed_edac *priv; struct mem_ctl_info *mci; void __iomem *regs; - u32 reg04; + u32 conf; int rc; + chip = of_device_get_match_data(dev); + if (!chip) + return -EINVAL; + regs = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(regs)) return PTR_ERR(regs); - scoped_guard(raw_spinlock_irqsave, &aspeed_lock) - aspeed_regs = regs; - /* bail out if ECC mode is not configured */ - reg04 = readl(regs + ASPEED_MCR_CONF); - if (!(reg04 & ASPEED_MCR_CONF_ECC)) { + conf = readl(regs + chip->conf_reg); + if (!field_get(chip->conf_ecc, conf)) { dev_err(&pdev->dev, "ECC mode is not configured in u-boot\n"); return -EPERM; } @@ -266,12 +309,17 @@ static int aspeed_probe(struct platform_device *pdev) layers[1].size = 1; layers[1].is_virt_csrow = false; - mci = edac_mc_alloc(0, ARRAY_SIZE(layers), layers, 0); + mci = edac_mc_alloc(0, ARRAY_SIZE(layers), layers, sizeof(*priv)); if (!mci) return -ENOMEM; + priv = mci->pvt_info; + priv->chip = chip; + scoped_guard(raw_spinlock_init, &priv->lock) + priv->regs = regs; + mci->pdev = &pdev->dev; - mci->mtype_cap = MEM_FLAG_DDR3 | MEM_FLAG_DDR4; + mci->mtype_cap = chip->mtype_cap; mci->edac_ctl_cap = EDAC_FLAG_SECDED; mci->edac_cap = EDAC_FLAG_SECDED; mci->scrub_cap = SCRUB_FLAG_HW_SRC; @@ -314,24 +362,41 @@ static int aspeed_probe(struct platform_device *pdev) static void aspeed_remove(struct platform_device *pdev) { struct mem_ctl_info *mci = platform_get_drvdata(pdev); - int irq; + struct aspeed_edac *priv = mci->pvt_info; /* disable interrupts */ - aspeed_set_irq(false); + aspeed_set_irq(priv, false); - irq = platform_get_irq(pdev, 0); - WARN_ON(irq < 0); - devm_free_irq(&pdev->dev, irq, mci); + devm_free_irq(&pdev->dev, priv->irq, mci); /* free resources */ edac_mc_del_mc(&pdev->dev); edac_mc_free(mci); } +static const struct aspeed_edac_chip ast2400_edac = { + .conf_reg = ASPEED_MCR_CONF, + .conf_ecc = ASPEED_MCR_CONF_ECC, + .conf_dram_type = ASPEED_MCR_CONF_DRAM_TYPE, + .dram_type = { MEM_DDR3, MEM_DDR4 }, + .mtype_cap = MEM_FLAG_DDR3 | MEM_FLAG_DDR4, + .prot_reg = ASPEED_MCR_PROT, + .prot_key = ASPEED_MCR_PROT_PASSWD, +}; + +/* The AST2600 does not key-protect the interrupt control register (MCR50). */ +static const struct aspeed_edac_chip ast2600_edac = { + .conf_reg = ASPEED_MCR_CONF, + .conf_ecc = ASPEED_MCR_CONF_ECC, + .conf_dram_type = ASPEED_MCR_CONF_DRAM_TYPE, + .dram_type = { MEM_DDR3, MEM_DDR4 }, + .mtype_cap = MEM_FLAG_DDR3 | MEM_FLAG_DDR4, +}; + static const struct of_device_id aspeed_of_match[] = { - { .compatible = "aspeed,ast2400-sdram-edac" }, - { .compatible = "aspeed,ast2500-sdram-edac" }, - { .compatible = "aspeed,ast2600-sdram-edac" }, + { .compatible = "aspeed,ast2400-sdram-edac", .data = &ast2400_edac }, + { .compatible = "aspeed,ast2500-sdram-edac", .data = &ast2400_edac }, + { .compatible = "aspeed,ast2600-sdram-edac", .data = &ast2600_edac }, {}, }; From patchwork Tue Sep 29 19:15:06 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Chen X-Patchwork-Id: 2313731 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:21b9:f100::1; helo=lists.ozlabs.org; envelope-from=linux-aspeed+bounces-5069-incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:21b9:f100::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hvjtH6tR1z1y0d for ; Wed, 30 Sep 2026 15:15:35 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4hvjtD5jgwz30Cj; Wed, 30 Sep 2026 15:15:32 +1000 (AEST) X-Original-To: linux-aspeed@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=211.20.114.72 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1790745332; cv=none; b=EzNPRyOJW2NNBQXjW9BG1HYQEVWG6Py3NNlobfc9IFH4R0c0ebVWfmkJu8lKLGccNrwATU7fkqT502tFRfBnVwI0X033K6tEd5QP2eVC6MabFs6kYOKPO5+lgMn15ooaaRSNMLuTprVjPgfSkfFij1xxobnBz2Qy0rKb91cjuhDSuIpdwgAPZ3hjW4VxCneWlSX0+Y+OHzcjgMKoVl0dMPMeGDdb1rQqeK/iar/gu7t+sVgVF/q0GqNLLEVzce2v8c7ArNy+PVXQmQPh98VQ0ec+IKHNQ9IH3YQ5I3YOazVGkk4mxFiJzhXNC6bj4eivTURxdxrZyBcQmlnN92e7DQ== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1790745332; c=relaxed/relaxed; bh=T3NjR1lpP0/EOJMVTP0wPi+tLRU/cbjhAfdMWsJ1lac=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=KxbiKRVhWkodb0HSGft7i5l5//b/rcL1Iur5lTJthlkHL1+8sA4vq9+dcMqelskRmzd9We7z2HE6306Tmq/jhAA88PyG2miMLXYLYVo6lZe50S4SfwUT8l9KQuxaP+oWG2QvN1ZCONpPEvCa1BE4IWbXFgcVua1RC8mvgLZuP+YaOFkgKH+r0bqrBQT7C00RWaQ/5fYIpWsRiBp04N+IkoPlAbE+rzNv8bfI8/kidhKmG40gFhkQnk74EAoyUnLF6esp5JweKjnzHqUbPJ6h6/o4XE2xMf8dIXaEoeLId8vyiu2JuC5orkUDEY6BxJX9FCcix5UNFnNtP6KkQ2H/Mg== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=aspeedtech.com; spf=pass (client-ip=211.20.114.72; helo=twmbx01.aspeedtech.com; envelope-from=ryan_chen@aspeedtech.com; receiver=lists.ozlabs.org) smtp.mailfrom=aspeedtech.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=aspeedtech.com Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=aspeedtech.com (client-ip=211.20.114.72; helo=twmbx01.aspeedtech.com; envelope-from=ryan_chen@aspeedtech.com; receiver=lists.ozlabs.org) Received: from twmbx01.aspeedtech.com (mail.aspeedtech.com [211.20.114.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4hvjtC5Wn9z2xnQ for ; Wed, 30 Sep 2026 15:15:31 +1000 (AEST) Received: from TWMBX01.aspeed.com (192.168.0.62) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Wed, 30 Sep 2026 13:15:00 +0800 Received: from [127.0.1.1] (192.168.10.13) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server id 15.2.1748.10 via Frontend Transport; Wed, 30 Sep 2026 13:15:00 +0800 From: Ryan Chen Date: Wed, 30 Sep 2026 13:15:06 +0800 Subject: [PATCH v4 8/9] EDAC/aspeed: Add AST2700 support X-Mailing-List: linux-aspeed@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 Message-ID: <20260930-edac-v4-8-c2e526f3ed79@aspeedtech.com> References: <20260930-edac-v4-0-c2e526f3ed79@aspeedtech.com> In-Reply-To: <20260930-edac-v4-0-c2e526f3ed79@aspeedtech.com> To: Stefan Schaeckeler , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Joel Stanley , Andrew Jeffery , Borislav Petkov , Tony Luck CC: , , , , , Borislav Petkov , Ryan Chen X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1790745299; l=11921; i=ryan_chen@aspeedtech.com; s=20251126; h=from:subject:message-id; bh=pVNIBo5jD1DayuSl+51+0RH3NZwaV/1iDB0EjZVcUqc=; b=GSAeDw7Mg7rnBKA1RpkRxPnuSYN3dLFUQbio8/ZDe5LqUVySAQet1SECTmBdVXPYsMnex2nL0 wUUfI3+A1tyBBABopLCMkzN8BPgSQyPI2nmfw0+kZcBkiVkowLtM0C7 X-Developer-Key: i=ryan_chen@aspeedtech.com; a=ed25519; pk=Xe73xY6tcnkuRjjbVAB/oU30KdB3FvG4nuJuILj7ZVc= X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on lists.ozlabs.org Add SDRAM ECC reporting for the Aspeed AST2700. Its DRAMC has a different register layout, a split interrupt status/clear/mask scheme, DDR4/DDR5 memory and interrupt registers that are not key-protected. Its interrupt status/clear and enable sequences differ from the earlier SoCs, so add per-chip isr() and set_irq() hooks and route the devm_request_irq() and enable/disable paths through them, keeping the existing AST2400/2500/2600 behaviour under the shared aspeed_mcr_isr()/aspeed_set_irq(). Unlike the earlier SoCs it records a single failure address shared by both error types, so extend the shared count_rec()/count_un_rec() helpers with a have_addr flag to report an error without an address (existing SoCs pass have_addr = true, unchanged) and widen their address argument to phys_addr_t as the AST2700 address can exceed 32 bits. Tested on an AST2700: A correctable error was injected from the console by unlocking the controller and writing its ECC error inject test register: # mw 12c00000 1688a8a8 # mw 12c00080 31 EDAC MC0: 1 CE on mc#0csrow#0channel#0 (csrow:0 channel:0 page:0x40f6da offset:0xdb0 grain:16 syndrome:0x0) Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Ryan Chen --- Changes in v3: - Write the AST2700 interrupt mask register outright rather than read-modify-write: mask every source and unmask only the ECC ones. The driver owns the line exclusively, so it should establish the mask itself instead of deriving it from the register's contents. - Mask the interrupts before requesting them rather than after, so the mask is established before the handler can run. Changes in v2: - Return IRQ_NONE from ast2700_dramc_isr() when no ECC interrupt status bit is set. The handler clears only the ECC bits, so unconditionally claiming the interrupt could livelock the level-triggered line if another DRAMC source was left unmasked. - Add AST2700_INT_ECC for the pair of ECC interrupt bits, now used by both the handler and the enable path. - Expand the enable/disable ternary in ast2700_set_irq() into if/else, matching the shape of aspeed_set_irq(). - Pass struct aspeed_edac to the set_irq() hooks instead of struct mem_ctl_info, which the callees only used to reach pvt_info. --- drivers/edac/aspeed_edac.c | 161 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 135 insertions(+), 26 deletions(-) diff --git a/drivers/edac/aspeed_edac.c b/drivers/edac/aspeed_edac.c index e88d9d2646de..6fe6314cda72 100644 --- a/drivers/edac/aspeed_edac.c +++ b/drivers/edac/aspeed_edac.c @@ -32,6 +32,24 @@ #define ASPEED_MCR_INTR_CTRL_CNT_UNREC GENMASK(15, 12) #define ASPEED_MCR_INTR_CTRL_ENABLE (BIT(0) | BIT(1)) +#define AST2700_INT_STS 0x04 +#define AST2700_INT_CLR 0x08 +#define AST2700_INT_MASK 0x0c +#define AST2700_INT_ECC_RECOVERABLE BIT(5) +#define AST2700_INT_ECC_UNRECOVERABLE BIT(4) +#define AST2700_INT_ECC (AST2700_INT_ECC_RECOVERABLE | \ + AST2700_INT_ECC_UNRECOVERABLE) +#define AST2700_INT_ALL GENMASK(16, 0) +#define AST2700_MCFG 0x10 +#define AST2700_MCFG_ECC BIT(6) +#define AST2700_MCFG_DRAM_TYPE BIT(0) /* 0=DDR4, 1=DDR5 */ +#define AST2700_ECC_STS 0x78 +#define AST2700_ECC_REC_CNT GENMASK(15, 8) +#define AST2700_ECC_UNREC_CNT GENMASK(7, 0) +#define AST2700_ECC_FAIL_ADDR 0x7c + +struct aspeed_edac; + struct aspeed_edac_chip { unsigned int conf_reg; u32 conf_ecc; @@ -40,6 +58,8 @@ struct aspeed_edac_chip { unsigned long mtype_cap; unsigned int prot_reg; u32 prot_key; + irqreturn_t (*isr)(int irq, void *arg); + void (*set_irq)(struct aspeed_edac *priv, bool enable); }; struct aspeed_edac { @@ -50,26 +70,34 @@ struct aspeed_edac { int irq; }; -static void count_rec(struct mem_ctl_info *mci, u8 rec_cnt, u32 rec_addr) +static void count_rec(struct mem_ctl_info *mci, u8 rec_cnt, phys_addr_t rec_addr, + bool have_addr) { struct csrow_info *csrow = mci->csrows[0]; - u32 page, offset, syndrome; + unsigned long page, offset, syndrome; if (!rec_cnt) return; - /* report first few errors (if there are) */ - /* note: no addresses are recorded */ - if (rec_cnt > 1) { + /* + * Report the errors whose address is not recorded: all of them when + * no address is available, otherwise all but the last one (reported + * with its address below). + */ + if (rec_cnt > 1 || !have_addr) { /* page, offset and syndrome are not available */ page = 0; offset = 0; syndrome = 0; - edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, rec_cnt-1, + edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, + have_addr ? rec_cnt - 1 : rec_cnt, page, offset, syndrome, 0, 0, -1, "address(es) not available", ""); } + if (!have_addr) + return; + /* report last error */ /* note: rec_addr is the last recoverable error addr */ page = rec_addr >> PAGE_SHIFT; @@ -82,32 +110,34 @@ static void count_rec(struct mem_ctl_info *mci, u8 rec_cnt, u32 rec_addr) } static void count_un_rec(struct mem_ctl_info *mci, u8 un_rec_cnt, - u32 un_rec_addr) + phys_addr_t un_rec_addr, bool have_addr) { struct csrow_info *csrow = mci->csrows[0]; - u32 page, offset, syndrome; + unsigned long page, offset, syndrome; if (!un_rec_cnt) return; - /* report 1. error */ - /* note: un_rec_addr is the first unrecoverable error addr */ - page = un_rec_addr >> PAGE_SHIFT; - offset = un_rec_addr & ~PAGE_MASK; - /* syndrome is not available */ - syndrome = 0; - edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1, - csrow->first_page + page, offset, syndrome, - 0, 0, -1, "", ""); + /* report the first error with its address when one is available */ + if (have_addr) { + /* note: un_rec_addr is the first unrecoverable error addr */ + page = un_rec_addr >> PAGE_SHIFT; + offset = un_rec_addr & ~PAGE_MASK; + /* syndrome is not available */ + syndrome = 0; + edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1, + csrow->first_page + page, offset, syndrome, + 0, 0, -1, "", ""); + } - /* report further errors (if there are) */ - /* note: no addresses are recorded */ - if (un_rec_cnt > 1) { + /* report the remaining errors without a recorded address */ + if (un_rec_cnt > 1 || !have_addr) { /* page, offset and syndrome are not available */ page = 0; offset = 0; syndrome = 0; - edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, un_rec_cnt-1, + edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, + have_addr ? un_rec_cnt - 1 : un_rec_cnt, page, offset, syndrome, 0, 0, -1, "address(es) not available", ""); } @@ -166,8 +196,8 @@ static irqreturn_t aspeed_mcr_isr(int irq, void *arg) rec_cnt, un_rec_cnt); /* process recoverable and unrecoverable errors */ - count_rec(mci, rec_cnt, rec_addr); - count_un_rec(mci, un_rec_cnt, un_rec_addr); + count_rec(mci, rec_cnt, rec_addr, true); + count_un_rec(mci, un_rec_cnt, un_rec_addr, true); if (!rec_cnt && !un_rec_cnt) dev_dbg_ratelimited(mci->pdev, "received edac interrupt, but did not find any ECC counters\n"); @@ -180,6 +210,54 @@ static irqreturn_t aspeed_mcr_isr(int irq, void *arg) return IRQ_HANDLED; } +static irqreturn_t ast2700_dramc_isr(int irq, void *arg) +{ + u32 int_sts, ecc_sts, fail_addr; + struct mem_ctl_info *mci = arg; + struct aspeed_edac *priv; + u8 rec_cnt, un_rec_cnt; + phys_addr_t addr; + + priv = mci->pvt_info; + + scoped_guard(raw_spinlock, &priv->lock) { + int_sts = readl(priv->regs + AST2700_INT_STS); + if (!(int_sts & AST2700_INT_ECC)) + return IRQ_NONE; + + ecc_sts = readl(priv->regs + AST2700_ECC_STS); + fail_addr = readl(priv->regs + AST2700_ECC_FAIL_ADDR); + + /* the interrupt registers are not key-protected; clear only ECC */ + writel(int_sts & AST2700_INT_ECC, priv->regs + AST2700_INT_CLR); + } + + rec_cnt = FIELD_GET(AST2700_ECC_REC_CNT, ecc_sts); + un_rec_cnt = FIELD_GET(AST2700_ECC_UNREC_CNT, ecc_sts); + + /* the register holds address bits [35:4], in units of 16 bytes */ + addr = (phys_addr_t)fail_addr << 4; + + /* + * The controller records only the address of the latest failure, + * shared by both error types. When only one type occurred it owns + * that address; when both occurred attribute it to the uncorrectable + * error and report the corrected ones without an address. + */ + if (un_rec_cnt && !rec_cnt) { + count_un_rec(mci, un_rec_cnt, addr, true); + } else if (!un_rec_cnt && rec_cnt) { + count_rec(mci, rec_cnt, addr, true); + } else if (un_rec_cnt && rec_cnt) { + count_un_rec(mci, un_rec_cnt, addr, true); + count_rec(mci, rec_cnt, 0, false); + } else { + dev_dbg_ratelimited(mci->pdev, "received interrupt with no ECC counters set\n"); + } + + return IRQ_HANDLED; +} + static void aspeed_set_irq(struct aspeed_edac *priv, bool enable) { u32 val; @@ -197,6 +275,19 @@ static void aspeed_set_irq(struct aspeed_edac *priv, bool enable) aspeed_mcr_irq_update_exit(priv); } +static void ast2700_set_irq(struct aspeed_edac *priv, bool enable) +{ + u32 val = AST2700_INT_ALL; + + guard(raw_spinlock_irqsave)(&priv->lock); + + /* interrupts are enabled by clearing their mask bits */ + if (enable) + val &= ~AST2700_INT_ECC; + + writel(val, priv->regs + AST2700_INT_MASK); +} + static int config_irq(struct mem_ctl_info *mci, struct platform_device *pdev) { struct aspeed_edac *priv = mci->pvt_info; @@ -209,7 +300,9 @@ static int config_irq(struct mem_ctl_info *mci, struct platform_device *pdev) if (irq < 0) return irq; - rc = devm_request_irq(&pdev->dev, irq, aspeed_mcr_isr, IRQF_TRIGGER_HIGH, + priv->chip->set_irq(priv, false); + + rc = devm_request_irq(&pdev->dev, irq, priv->chip->isr, IRQF_TRIGGER_HIGH, DRV_NAME, mci); if (rc) return rc; @@ -217,7 +310,7 @@ static int config_irq(struct mem_ctl_info *mci, struct platform_device *pdev) priv->irq = irq; /* enable interrupts */ - aspeed_set_irq(priv, true); + priv->chip->set_irq(priv, true); return 0; } @@ -365,7 +458,7 @@ static void aspeed_remove(struct platform_device *pdev) struct aspeed_edac *priv = mci->pvt_info; /* disable interrupts */ - aspeed_set_irq(priv, false); + priv->chip->set_irq(priv, false); devm_free_irq(&pdev->dev, priv->irq, mci); @@ -382,6 +475,8 @@ static const struct aspeed_edac_chip ast2400_edac = { .mtype_cap = MEM_FLAG_DDR3 | MEM_FLAG_DDR4, .prot_reg = ASPEED_MCR_PROT, .prot_key = ASPEED_MCR_PROT_PASSWD, + .isr = aspeed_mcr_isr, + .set_irq = aspeed_set_irq, }; /* The AST2600 does not key-protect the interrupt control register (MCR50). */ @@ -391,12 +486,26 @@ static const struct aspeed_edac_chip ast2600_edac = { .conf_dram_type = ASPEED_MCR_CONF_DRAM_TYPE, .dram_type = { MEM_DDR3, MEM_DDR4 }, .mtype_cap = MEM_FLAG_DDR3 | MEM_FLAG_DDR4, + .isr = aspeed_mcr_isr, + .set_irq = aspeed_set_irq, +}; + +/* The AST2700 interrupt registers are not key-protected either. */ +static const struct aspeed_edac_chip ast2700_edac = { + .conf_reg = AST2700_MCFG, + .conf_ecc = AST2700_MCFG_ECC, + .conf_dram_type = AST2700_MCFG_DRAM_TYPE, + .dram_type = { MEM_DDR4, MEM_DDR5 }, + .mtype_cap = MEM_FLAG_DDR4 | MEM_FLAG_DDR5, + .isr = ast2700_dramc_isr, + .set_irq = ast2700_set_irq, }; static const struct of_device_id aspeed_of_match[] = { { .compatible = "aspeed,ast2400-sdram-edac", .data = &ast2400_edac }, { .compatible = "aspeed,ast2500-sdram-edac", .data = &ast2400_edac }, { .compatible = "aspeed,ast2600-sdram-edac", .data = &ast2600_edac }, + { .compatible = "aspeed,ast2700-sdram-edac", .data = &ast2700_edac }, {}, }; From patchwork Tue Sep 29 19:15:07 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Chen X-Patchwork-Id: 2313732 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linux-aspeed+bounces-5070-incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hvjtK2STnz1y0d for ; Wed, 30 Sep 2026 15:15:37 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4hvjtF6RQcz30DK; Wed, 30 Sep 2026 15:15:33 +1000 (AEST) X-Original-To: linux-aspeed@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=211.20.114.72 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1790745333; cv=none; b=N3iV+gB1wQl1OLOJNOQOIU5gDU+NsJsrYvKUGPYlYFX7SwpL9YadcrfyriL9OLUUCgc0foADge3NUWbamLxN1WuZyWZjWoetdj+afUcbH/sYPDasVyngNaI/mAStw45QsNTl4YwAzNxZbdBrGQjdA0mXU9Ou2UuLFh69gJODysS/FWPNrbuMgpQOY08JKAf2+qmbKrq0fiDUlJw3o4HbNrwI5Hl+1/JYsAPwbVUaBjzkI1EHA+LI2U73KpBMG/aUsfdkKpMUAOA4VcWBX22v9e4LTG62J8X0b9+YjpPyDBV5f+cxkjS8+32J5NgspZk57nh6dgLwULxAaTIhzCFrMQ== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1790745333; c=relaxed/relaxed; bh=/X2m62a78v/3gjrOVXpAmQisanBIpSXgnWT0Pnie/eA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=oVGV/1WeigBVq65ehGbdRvl0uZgUqSBg287trkGfrqGCsqtmnIvO2YsVR8JNViIZ8EfESKIlurSxOS7lriKYJQy3s7AceLPjoI+XW3+1mSoWXNRFbIPJwxAhNAK6hkde9RRh8WBa0IqlcbtjPqqfxrW7iY5w4kjlxdvrr4zRbsrXQGkusgUCyCBw0jIABtZBznTiCfZ2cUeOZFoCl5N6nUrCqS6fTWdXebY1jwyJ4nZvrXCjGVmEvJHjepOwnM0DzMU5mwVRtl3o7KOuJfGh9JhM2bVBjGUGHFVG28D3sKiv9BlLp8xrSh2s6gmdEWbWQnP8WXCL0gN2+gjDilSOqg== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=aspeedtech.com; spf=pass (client-ip=211.20.114.72; helo=twmbx01.aspeedtech.com; envelope-from=ryan_chen@aspeedtech.com; receiver=lists.ozlabs.org) smtp.mailfrom=aspeedtech.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=aspeedtech.com Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=aspeedtech.com (client-ip=211.20.114.72; helo=twmbx01.aspeedtech.com; envelope-from=ryan_chen@aspeedtech.com; receiver=lists.ozlabs.org) Received: from twmbx01.aspeedtech.com (mail.aspeedtech.com [211.20.114.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4hvjtF06SKz2xnQ for ; Wed, 30 Sep 2026 15:15:33 +1000 (AEST) Received: from TWMBX01.aspeed.com (192.168.0.62) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Wed, 30 Sep 2026 13:15:01 +0800 Received: from [127.0.1.1] (192.168.10.13) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server id 15.2.1748.10 via Frontend Transport; Wed, 30 Sep 2026 13:15:00 +0800 From: Ryan Chen Date: Wed, 30 Sep 2026 13:15:07 +0800 Subject: [PATCH v4 9/9] MAINTAINERS: Step down as Aspeed AST2500 EDAC driver maintainer X-Mailing-List: linux-aspeed@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 Message-ID: <20260930-edac-v4-9-c2e526f3ed79@aspeedtech.com> References: <20260930-edac-v4-0-c2e526f3ed79@aspeedtech.com> In-Reply-To: <20260930-edac-v4-0-c2e526f3ed79@aspeedtech.com> To: Stefan Schaeckeler , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Joel Stanley , Andrew Jeffery , Borislav Petkov , Tony Luck CC: , , , , , Borislav Petkov , Ryan Chen X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1790745299; l=1860; i=ryan_chen@aspeedtech.com; s=20251126; h=from:subject:message-id; bh=0JAwcCSCddvZK+VJy0ySr5E6GGqKRb6s6URpXuDAV2s=; b=SRW3DY/LBt8IbrnG7P+7riWOpQaGuOT3/0PIom3r5pFRAH36Lisy/enbx/1uc4QeqgS2+fxuF VPnGrKlRwU9APVSN+LrUJdyuOv+cZpfndUasx6xHg26KZ5cHDL9CVtF X-Developer-Key: i=ryan_chen@aspeedtech.com; a=ed25519; pk=Xe73xY6tcnkuRjjbVAB/oU30KdB3FvG4nuJuILj7ZVc= X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on lists.ozlabs.org From: Stefan M Schaeckeler I am stepping down as a maintainer for drivers/edac/aspeed_edac.c and Documentation/devicetree/bindings/edac/aspeed,ast2400-sdram-edac.yaml Move my entry from the MAINTAINERS file to CREDITS to reflect my past contributions. [ ryan: keep the EDAC-AST2500 entry and list myself as its reviewer rather than removing it ] Signed-off-by: Stefan M Schaeckeler Signed-off-by: Ryan Chen Link: https://lore.kernel.org/r/20260920225846.4039017-1-sschaeck@cisco.com --- Changes in v4: - Merge Stefan's step-down patch into this one, keeping the MAINTAINERS entry alive with a reviewer instead of removing it. Changes in v3: - New patch. --- CREDITS | 8 ++++++++ MAINTAINERS | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CREDITS b/CREDITS index 091412875a66..28e5b274bc28 100644 --- a/CREDITS +++ b/CREDITS @@ -3655,6 +3655,14 @@ D: I2O kernel layer (config, block, core, pci, net). I2O disk support for LILO D: XScale (IOP, IXP) porting and other random ARM bits S: Portland, OR +N: Stefan Schaeckeler +E: sschaeck@cisco.com +E: schaecsn@gmx.net +D: Author and initial maintainer of the Aspeed AST2500 EDAC driver +S: 2253 Anna Dr. +S: Santa Clara, CA 95050 +S: USA + N: Eric Schenk E: Eric.Schenk@dna.lth.se D: Random kernel debugging. diff --git a/MAINTAINERS b/MAINTAINERS index d413dac5c8b3..2001466fd6da 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -9283,7 +9283,7 @@ F: Documentation/devicetree/bindings/memory-controllers/marvell,mvebu-sdram-cont F: drivers/edac/armada_xp_* EDAC-AST2500 -M: Stefan Schaeckeler +R: Ryan Chen S: Supported F: Documentation/devicetree/bindings/edac/aspeed,ast2400-sdram-edac.yaml F: drivers/edac/aspeed_edac.c