From patchwork Thu Feb 22 18:12:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13567988 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BCEB9C54791 for ; Thu, 22 Feb 2024 19:16:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=kd8vFMLobnR/HvemO16aJVyaNvcxoYlVVsXL1O73wfk=; b=bcMRfIjv/MoGuA ui63FWMWnwJhGtOcGt1mDpw08yWxD597HI4ZeXTzsVLrS10PgGvOBr6SU9QkAYlmg1q3VnBPQGDwL gG4WjPhAOtKU3RhChy5+jlbErNkW8OvNbCNpRkHep7ZjGickSDxlTyK/HKwn+cL2c7K9eGRMr5WTg l2Oim7M/rtlKTpxiFxKltdV17t2RhY+2F0iqHwo0a19Zn4cKgbrjCqaQGAgxGFjMqIgTmyvigif28 dYc7lTfBqhfuBOgSPS40WUjRwY6RLrw5CD2JXnT2M1D/fT487vg/MJ2aEkA8ehD0t+8PZcA3/N9/9 dp07jow7Qyz6oyQLNMFw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdEYN-00000006I2g-1vGW; Thu, 22 Feb 2024 19:16:19 +0000 Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDaW-00000005x3X-3OuQ for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 18:14:41 +0000 Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-5101cd91017so76567e87.2 for ; Thu, 22 Feb 2024 10:14:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708625663; x=1709230463; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/qyJghl0xqwmscdyWmOAn7eBB6UolwNf9WzGJ00ORnM=; b=PqwquHHZTsJyTSSE5upDsMj/8MT0BI2PL0bMLkrQon6LhxhmUmULxWHWwImebKnwKH p7bD5dYvAq8PF/PxZhV1qqYIswFXw5jIhRfOW6omtbMI4b1HtLLr9leRhLmFV+awtnXq M0ptiAYRb/LKpxV5p3NNgwnBnzJFVJHh1U5CbDvka10HthiBlJuODCu7RVoERT2V6MNK 12tryWQ7k3iwUzQGl2ZzFAhKPY0jApdH8B5DB79sbz8deBNNRkcqRunLo/JuyIArIg3a 92TOfARKs9y0/sxX3YSWh5J/FCpUG9HG3GaYpUfBNgNtmoIxKPlMJgDjyiZ/L8+ethTd v7wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708625663; x=1709230463; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/qyJghl0xqwmscdyWmOAn7eBB6UolwNf9WzGJ00ORnM=; b=XKrITJccyojSNrgsN/V6xkw440mi28aR3ie6ygdA5mmXwijjG+Mapmy2mRD8auw6Ll P+mbHmpc9f+3t87NfyLus4LHEWmVQ9bXD1hK5pvZICLj6gdH0Ie1X4E6+X9/uWT9mo9w GUgEgTqwRp2YToYRsWYJOnCKvbBZ5tFHdw6N9V0fLECJ3Leb4e5v8cpa8oaTCWlXNtQg eQadqt2uxz9XDdg1AhMvKqyFFqy2bwPvKzAWHGak2LgrPgQOv0TEbnID6hC1XPOT3cHS l4ywIP7ZGOzCEXi2VuxQ+3makBKY2jy0JDCFh4dyNmQkJD3JfULaT+KaU8iu9cQkqKpk Fmsg== X-Forwarded-Encrypted: i=1; AJvYcCVkyS7xxQBx2RDfFodLpUWYZq28emv2vM9+pd9z68ZGZz1rDWGXdz02kiu+nalHDJCl+hVQDuO38y9NsrXpAzPuzbvKx3xusPTU9oJhnaniln4G/A4= X-Gm-Message-State: AOJu0YyU53KnX3NX82mkkMMm0Ez+6MgXTadeDmSe4QSs1u86fM5PtDkX zt0oqZe4Qj3XT9e8v+QytZ53XE6aBOXc4WnU7a29kJ7zMWkg9O5T X-Google-Smtp-Source: AGHT+IFijz6QFs1d/1Wsr4KVrtHFrWPHYvhKrodu21VdqHALqVlmpK2g3OEicBVmuVI9kJVbBEFJpw== X-Received: by 2002:a05:6512:3fc:b0:512:ceae:93d9 with SMTP id n28-20020a05651203fc00b00512ceae93d9mr3374265lfq.28.1708625662700; Thu, 22 Feb 2024 10:14:22 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id g12-20020ac24d8c000000b005126ab0e3fasm2152711lfe.124.2024.02.22.10.14.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 10:14:22 -0800 (PST) From: Serge Semin To: Michal Simek , Alexander Stein , Borislav Petkov , Tony Luck , James Morse , Mauro Carvalho Chehab , Robert Richter , Dinh Nguyen Cc: Serge Semin , Punnaiah Choudary Kalluri , Arnd Bergmann , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, Sherry Sun , Borislav Petkov Subject: [PATCH v5 01/20] EDAC/synopsys: Fix ECC status data and IRQ disable race condition Date: Thu, 22 Feb 2024 21:12:46 +0300 Message-ID: <20240222181324.28242-2-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240222181324.28242-1-fancer.lancer@gmail.com> References: <20240222181324.28242-1-fancer.lancer@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240222_101432_559771_41D3F70F X-CRM114-Status: GOOD ( 23.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The race condition around the ECCCLR register access happens in the IRQ disable method called in the device remove() procedure and in the ECC IRQ handler: 1. Enable IRQ: a. ECCCLR = EN_CE | EN_UE 2. Disable IRQ: a. ECCCLR = 0 3. IRQ handler: a. ECCCLR = CLR_CE | CLR_CE_CNT | CLR_CE | CLR_CE_CNT b. ECCCLR = 0 c. ECCCLR = EN_CE | EN_UE So if the IRQ disabling procedure is called concurrently with the IRQ handler method the IRQ might be actually left enabled due to the statement 3c. The root cause of the problem is that ECCCLR register (which since v3.10a has been called as ECCCTL) has intermixed ECC status data clear flags and the IRQ enable/disable flags. Thus the IRQ disabling (clear EN flags) and handling (write 1 to clear ECC status data) procedures must be serialised around the ECCCTL register modification to prevent the race. So fix the problem described above by adding the spin-lock around the ECCCLR modifications and preventing the IRQ-handler from modifying the IRQs enable flags (there is no point in disabling the IRQ and then re-enabling it again within a single IRQ handler call, see the statements 3a/3b and 3c above). Fixes: f7824ded4149 ("EDAC/synopsys: Add support for version 3 of the Synopsys EDAC DDR") Signed-off-by: Serge Semin --- Cc: Sherry Sun Changelog v4: - This is a new patch detached from [PATCH v3 01/17] EDAC/synopsys: Fix native uMCTL2 IRQs handling procedure - Rename lock to reglock (Borislav) --- drivers/edac/synopsys_edac.c | 50 ++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/drivers/edac/synopsys_edac.c b/drivers/edac/synopsys_edac.c index 709babce43ba..0168b05e3ca1 100644 --- a/drivers/edac/synopsys_edac.c +++ b/drivers/edac/synopsys_edac.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -299,6 +300,7 @@ struct synps_ecc_status { /** * struct synps_edac_priv - DDR memory controller private instance data. * @baseaddr: Base address of the DDR controller. + * @reglock: Concurrent CSRs access lock. * @message: Buffer for framing the event specific info. * @stat: ECC status information. * @p_data: Platform data. @@ -313,6 +315,7 @@ struct synps_ecc_status { */ struct synps_edac_priv { void __iomem *baseaddr; + spinlock_t reglock; char message[SYNPS_EDAC_MSG_SIZE]; struct synps_ecc_status stat; const struct synps_platform_data *p_data; @@ -408,7 +411,8 @@ static int zynq_get_error_info(struct synps_edac_priv *priv) static int zynqmp_get_error_info(struct synps_edac_priv *priv) { struct synps_ecc_status *p; - u32 regval, clearval = 0; + u32 regval, clearval; + unsigned long flags; void __iomem *base; base = priv->baseaddr; @@ -452,10 +456,14 @@ static int zynqmp_get_error_info(struct synps_edac_priv *priv) p->ueinfo.blknr = (regval & ECC_CEADDR1_BLKNR_MASK); p->ueinfo.data = readl(base + ECC_UESYND0_OFST); out: - clearval = ECC_CTRL_CLR_CE_ERR | ECC_CTRL_CLR_CE_ERRCNT; - clearval |= ECC_CTRL_CLR_UE_ERR | ECC_CTRL_CLR_UE_ERRCNT; + spin_lock_irqsave(&priv->reglock, flags); + + clearval = readl(base + ECC_CLR_OFST) | + ECC_CTRL_CLR_CE_ERR | ECC_CTRL_CLR_CE_ERRCNT | + ECC_CTRL_CLR_UE_ERR | ECC_CTRL_CLR_UE_ERRCNT; writel(clearval, base + ECC_CLR_OFST); - writel(0x0, base + ECC_CLR_OFST); + + spin_unlock_irqrestore(&priv->reglock, flags); return 0; } @@ -515,24 +523,41 @@ static void handle_error(struct mem_ctl_info *mci, struct synps_ecc_status *p) static void enable_intr(struct synps_edac_priv *priv) { + unsigned long flags; + /* Enable UE/CE Interrupts */ - if (priv->p_data->quirks & DDR_ECC_INTR_SELF_CLEAR) - writel(DDR_UE_MASK | DDR_CE_MASK, - priv->baseaddr + ECC_CLR_OFST); - else + if (!(priv->p_data->quirks & DDR_ECC_INTR_SELF_CLEAR)) { writel(DDR_QOSUE_MASK | DDR_QOSCE_MASK, priv->baseaddr + DDR_QOS_IRQ_EN_OFST); + return; + } + + spin_lock_irqsave(&priv->reglock, flags); + + writel(DDR_UE_MASK | DDR_CE_MASK, + priv->baseaddr + ECC_CLR_OFST); + + spin_unlock_irqrestore(&priv->reglock, flags); } static void disable_intr(struct synps_edac_priv *priv) { + unsigned long flags; + /* Disable UE/CE Interrupts */ - if (priv->p_data->quirks & DDR_ECC_INTR_SELF_CLEAR) - writel(0x0, priv->baseaddr + ECC_CLR_OFST); - else + if (!(priv->p_data->quirks & DDR_ECC_INTR_SELF_CLEAR)) { writel(DDR_QOSUE_MASK | DDR_QOSCE_MASK, priv->baseaddr + DDR_QOS_IRQ_DB_OFST); + + return; + } + + spin_lock_irqsave(&priv->reglock, flags); + + writel(0, priv->baseaddr + ECC_CLR_OFST); + + spin_unlock_irqrestore(&priv->reglock, flags); } /** @@ -576,8 +601,6 @@ static irqreturn_t intr_handler(int irq, void *dev_id) /* v3.0 of the controller does not have this register */ if (!(priv->p_data->quirks & DDR_ECC_INTR_SELF_CLEAR)) writel(regval, priv->baseaddr + DDR_QOS_IRQ_STAT_OFST); - else - enable_intr(priv); return IRQ_HANDLED; } @@ -1359,6 +1382,7 @@ static int mc_probe(struct platform_device *pdev) priv = mci->pvt_info; priv->baseaddr = baseaddr; priv->p_data = p_data; + spin_lock_init(&priv->reglock); mc_init(mci, pdev); From patchwork Thu Feb 22 18:12:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13567989 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 78411C48BF8 for ; Thu, 22 Feb 2024 19:16:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=IZRi6v5Ef/wl++mMFOvcN62OOSSWDvFIjusRzYzh1X4=; b=NlR8GON+uA6wLd Oh8/2ItBGlLDT31YIrWc8MHooYW5lmJmBmi3IFHiCUprIrz0Ho/xfewyd3KnsCdpzEIjxPUry8Zm1 fG5j1cHv9NIjN8GnROCSErEBPFjxNbTM1S8+nk7Kzp8ZmiED1VnL9RZhdz0ykJjbUwfU/jCKnmFKs Uqq2UASAdDjzYaAzj7j/UFfsHX5rREby9jxjPd0oYLy86sopXY+Qxbge+zm+wcSExJVnerqQ8tvxs yofJMLwaWn5lW7dvFbQ8CNWSwTY9J+uVpe9Hu4edr8ZDkxQ1Q2ON949UOKaoXqBpC8QLc+GMAC/HB yY291IjpjD554MVhu9Rg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdEYO-00000006I3K-1AkZ; Thu, 22 Feb 2024 19:16:20 +0000 Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDaY-00000005x3f-0VUH for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 18:14:43 +0000 Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-51294b40a52so82632e87.0 for ; Thu, 22 Feb 2024 10:14:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708625664; x=1709230464; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=x4DYckUBnyYVrA7U82dE/dSUDjWpjIV6W2v0tQMwU8w=; b=IMEXWujQq57ftPEkZk5XPAxZxvPAWAy4geBNO1IUscBcC7Wr1ZphHeTBZsi5ItI8K/ hG2uodcCxjkpx9l1/qDOjYOIItKv4z/sveH82LfviFW+4P1iahXuquYac3olw6CcrfRM gHWvGLTj6d7ZG0irtm+7i4eqE0kErjgu7KAYvgOVf42s9cmUItRxcxg/B0UoZj+l6fo5 QPtkIZ9Jbd3LWgHJ4u/XyzH9U0b+pApqyJ8E/D1reyRsOdSOKGn9gDX0Z11RyceFqGOb fuhkCGBRQlpj6Au9uK6289bBq02Fo4Stqd/scKtGh2huOUV5rrip1H2Zk82rcEG3Meh4 wjpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708625664; x=1709230464; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=x4DYckUBnyYVrA7U82dE/dSUDjWpjIV6W2v0tQMwU8w=; b=VrFks1Y5a3Tdfqyq95uW46wNbIqWyQVhLHNX8Q09S90NdW20c5r89+sdL5XGfqAKGg EPkkwAZByblSKaffP5X6w/VK6rHmZQJ8TO6wk+xjsMdMapda2zvwEYKQLUtvutpV2WQL bXKyXlpuNGUEn8q6Wh882cnyrfLMnKpVwWO8WDiIeWx0gwSg6dHW0SlLhL2wby/rOVvB rFtylA6OCa9D93xrDHcPjHfeT80tHmX7EBbvjzD8u8f8pXvAMGqJDrpkID+mDZ9bpmzy hOBV0yLa+KpWNcjyuWrMHvdten3GP021aEqEM8U1iom9OZCLhMN1zXP71qydr/A41TOb l8Pw== X-Forwarded-Encrypted: i=1; AJvYcCVSoUDdKFfS7GReaxyyZ1N9EePsrECBmfpH4lZIWDg0sDAZnK/EHu3cyAHFWQUDWUjQspZBW9/kpCs/+d6yB+e4J3648uQmJ6xEQhqQnAQIqz1FW3Q= X-Gm-Message-State: AOJu0YxH5Aplw9WfuA5cv767sMmU7z1FlMCmCUd1/RQd+z+3yV9iOb4a hwCJcQVzboBl4RlHRtR2U9BICAQeSNeAna4lbwbcyR4Z8Y9WJcO9 X-Google-Smtp-Source: AGHT+IGJ/nsuVLRKc8FXj1WcjDvwWPQJBicyowF64SttTvyGSeLfyGnnezM8knKtZRAhXGeFbwZldw== X-Received: by 2002:ac2:4ac2:0:b0:512:cd90:221d with SMTP id m2-20020ac24ac2000000b00512cd90221dmr1228096lfp.33.1708625664597; Thu, 22 Feb 2024 10:14:24 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id m15-20020a19520f000000b00512c8ef474asm1042885lfb.270.2024.02.22.10.14.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 10:14:24 -0800 (PST) From: Serge Semin To: Michal Simek , Alexander Stein , Borislav Petkov , Tony Luck , James Morse , Mauro Carvalho Chehab , Robert Richter , Manish Narani Cc: Serge Semin , Punnaiah Choudary Kalluri , Dinh Nguyen , Arnd Bergmann , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, Borislav Petkov Subject: [PATCH v5 02/20] EDAC/synopsys: Fix generic device type detection procedure Date: Thu, 22 Feb 2024 21:12:47 +0300 Message-ID: <20240222181324.28242-3-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240222181324.28242-1-fancer.lancer@gmail.com> References: <20240222181324.28242-1-fancer.lancer@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240222_101432_574655_AC20DC21 X-CRM114-Status: GOOD ( 20.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org First of all the enum dev_type constants describe the memory DRAM chips used at the stick, not the entire DQ-bus width (see the enumeration kdoc for details). So what is returned from the zynqmp_get_dtype() function and then specified to the dimm_info->dtype field is definitely incorrect. Secondly the DRAM chips type has nothing to do with the data bus width specified in the MSTR.data_bus_width CSR field. That CSR field just determines the part of the whole DQ-bus currently used to access the data from the all DRAM memory chips. So it doesn't indicate the individual chips type. Thirdly the DRAM chips type can be determined only in case of the DDR4 protocol by means of the MSTR.device_config field state (it is supposed to be set by the system firmware). Finally the DW uMCTL2 DDRC ECC capability doesn't depend on the memory chips type. Moreover it doesn't depend on the utilized data bus width in runtime either. The IP-core reference manual says in [1,2] that the ECC support can't be enabled during the IP-core synthesizes for the DRAM data bus widths other than 16, 32 or 64. At the same time the bus width mode (MSTR.data_bus_width) doesn't change the ECC feature availability. Thus it was wrong to determine the ECC state with respect to the DQ-bus width mode. Fix all of the mistakes described above in the zynqmp_get_dtype() and zynqmp_get_ecc_state() methods: specify actual DRAM chips data width only for the DDR4 protocol and return that it's UNKNOWN in the rest of the cases; determine ECC availability by the ECCCFG0.ecc_mode field state only (that field can't be modified anyway if the IP-core was synthesized with no ECC support). [1] DesignWare® Cores Enhanced Universal DDR Memory Controller (uMCTL2) Databook, Version 3.91a, October 2020, p. 421. [2] DesignWare® Cores Enhanced Universal DDR Memory Controller (uMCTL2) Databook, Version 3.91a, October 2020, p. 633. Fixes: b500b4a029d5 ("EDAC, synopsys: Add ECC support for ZynqMP DDR controller") Signed-off-by: Serge Semin --- Changelog v2: - Include "linux/bitfield.h" header file to get the FIELD_GET macro definition. (@tbot) --- drivers/edac/synopsys_edac.c | 49 +++++++++++++++--------------------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/drivers/edac/synopsys_edac.c b/drivers/edac/synopsys_edac.c index 0168b05e3ca1..455d2fcfd8c1 100644 --- a/drivers/edac/synopsys_edac.c +++ b/drivers/edac/synopsys_edac.c @@ -674,26 +674,25 @@ static enum dev_type zynq_get_dtype(const void __iomem *base) */ static enum dev_type zynqmp_get_dtype(const void __iomem *base) { - enum dev_type dt; - u32 width; - - width = readl(base + CTRL_OFST); - width = (width & ECC_CTRL_BUSWIDTH_MASK) >> ECC_CTRL_BUSWIDTH_SHIFT; - switch (width) { - case DDRCTL_EWDTH_16: - dt = DEV_X2; - break; - case DDRCTL_EWDTH_32: - dt = DEV_X4; - break; - case DDRCTL_EWDTH_64: - dt = DEV_X8; - break; - default: - dt = DEV_UNKNOWN; + u32 regval; + + regval = readl(base + CTRL_OFST); + if (!(regval & MEM_TYPE_DDR4)) + return DEV_UNKNOWN; + + regval = (regval & DDRC_MSTR_CFG_MASK) >> DDRC_MSTR_CFG_SHIFT; + switch (regval) { + case DDRC_MSTR_CFG_X4_MASK: + return DEV_X4; + case DDRC_MSTR_CFG_X8_MASK: + return DEV_X8; + case DDRC_MSTR_CFG_X16_MASK: + return DEV_X16; + case DDRC_MSTR_CFG_X32_MASK: + return DEV_X32; } - return dt; + return DEV_UNKNOWN; } /** @@ -730,19 +729,11 @@ static bool zynq_get_ecc_state(void __iomem *base) */ static bool zynqmp_get_ecc_state(void __iomem *base) { - enum dev_type dt; - u32 ecctype; + u32 regval; - dt = zynqmp_get_dtype(base); - if (dt == DEV_UNKNOWN) - return false; + regval = readl(base + ECC_CFG0_OFST) & SCRUB_MODE_MASK; - ecctype = readl(base + ECC_CFG0_OFST) & SCRUB_MODE_MASK; - if ((ecctype == SCRUB_MODE_SECDED) && - ((dt == DEV_X2) || (dt == DEV_X4) || (dt == DEV_X8))) - return true; - - return false; + return (regval == SCRUB_MODE_SECDED); } /** From patchwork Thu Feb 22 18:12:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13567987 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A8D61C5478C for ; Thu, 22 Feb 2024 19:16:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8bsj+Oi4138CtPzqLeUjAh8gvGekjgS7D7udGW9qBPU=; b=247H6ohbG3COR0 W1ROJg4kur5caUvNwwurTe2Iq9beVlLNS+gXn45niTF7Fb4GltBUUMBBxodyCk1bT378KeNjcjao8 Ml8jG0JsweVQxovjmFwEaEh7AeOm+N/E2hkLpEJWs/UDHVO7OgJXP5joMoKIj4m2lUPwv2jjA9e3t rBSPaQ46WO0Ctl2Wihu6XNB0Ykl2JvYceL9bmgbT5ZtKmEZ68OARCp1nIbZFfJ7fMutiL3V8TH+da psdqnb204t7Ja7d7nm7B1o6w+m0QhxZ9ucbGJzAw65iDrFn3TlI+HjHB8zO4sjqBwxx+uGZn05nJw 9weHjkxmZ4FOhkc2lYsg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdEYM-00000006I2N-3p3K; Thu, 22 Feb 2024 19:16:18 +0000 Received: from mail-lj1-x234.google.com ([2a00:1450:4864:20::234]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDaY-00000005x3k-0Vi3 for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 18:14:41 +0000 Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2d2509c66daso815261fa.3 for ; Thu, 22 Feb 2024 10:14:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708625666; x=1709230466; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=s0PkFM1zHHNODsMfc/INZSKS8pmA7KHQoUde1CaCg/A=; b=ajq+9F8/EOSncgMkaIavHG15QXrS7aApDuCB69P4qQL3D9DHA3shLYds9ah3u4AoQO ADYr2yfYdpE879fWz2Cd2TQifT9xbEL1meW9sHAHQxy00+CCtYIzYfNreN+mN6fgJhW4 ppuBCT0xpXze3nvrunXx7nyIyHa60kLsGqVeQTv8svjdYddTKhCBqwMS+JVUGjZ5VbD3 40bLhi3b43R9mXoYZMwZD6p2IT/v1e74h8sfuu+CUN1dD8amnawNCmRJBahMNGTBZ9Lr FJIE6OfePRzAZFDOqi+BKom7/tEz2Uxsgnu1X7AXatDfQ+IrPVNHASWbC0kgUEX6DJmJ Z06Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708625666; x=1709230466; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=s0PkFM1zHHNODsMfc/INZSKS8pmA7KHQoUde1CaCg/A=; b=FcnsEKanwgapXBhGn7iwaeMe5wKHHWLFTDBJ55M8kjCfk+9sdqHlxAZpd8SBXQ0zr6 9LJHzi6olrvER3bYpwTAH4O1WAsJNMXquLQ5JOhtKNatoYZCnLMwxuMFleLEGIMY2vhA acUEmquXhnPWGOxnLkyWtnbz+65Qygp+CC3Y6KtiCLQXNQszlHyEiB8q9XLQmaKcAQO4 XEM9/J3dThYhLJgumR1GqrBQ5ScLHiuGDHz5e26Imf/wuvTxS2fDsuCSuMTWqwZ5n169 qf+odZVoxGI0Xpf+a/mjw7V9muAzFIVoAvqGBiN+H/fpPNXMQ56MR42EZp8vs5RQhL6D cQGQ== X-Forwarded-Encrypted: i=1; AJvYcCVshvvbVtkgUC32ggZToWMgGl5eqDagGbg2TvAR7lKlaFZoEIXVWMHVPV4gXQmeTFPnnydrnSd4hCeHm4vwR2TApsXrOQijiIBaxINLYQAqRNIkEkw= X-Gm-Message-State: AOJu0YxmEGjPi/EbrBTMlrPof8QmQ2pNhZrIvWhpKp6pkGb9z/SbyHbu I5e5cDV+KePuCkPljSle+5JU1fgFH5QJc+nKnqiv1GRoEKxOFpMm X-Google-Smtp-Source: AGHT+IHahT0a07aFA2OedK8mTZdnaBkfS3CSGBF+9vHiELIFN8mrf5vJu/bEAFsJ399T8e/mgXYx1Q== X-Received: by 2002:ac2:593b:0:b0:512:b366:6c42 with SMTP id v27-20020ac2593b000000b00512b3666c42mr8072382lfi.32.1708625666512; Thu, 22 Feb 2024 10:14:26 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id q2-20020ac25a02000000b00512daaef13bsm398124lfn.102.2024.02.22.10.14.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 10:14:26 -0800 (PST) From: Serge Semin To: Michal Simek , Alexander Stein , Borislav Petkov , Tony Luck , James Morse , Mauro Carvalho Chehab , Robert Richter , Punnaiah Choudary Kalluri Cc: Serge Semin , Dinh Nguyen , Arnd Bergmann , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, Borislav Petkov Subject: [PATCH v5 03/20] EDAC/synopsys: Fix mci->scrub_cap field setting Date: Thu, 22 Feb 2024 21:12:48 +0300 Message-ID: <20240222181324.28242-4-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240222181324.28242-1-fancer.lancer@gmail.com> References: <20240222181324.28242-1-fancer.lancer@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240222_101432_563800_16AB2AFC X-CRM114-Status: GOOD ( 15.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The mem_ctl_info.scrub_cap field is supposed to be set with the ECC scrub-related flags. Instead the driver erroneously initializes it with the SCRUB_HW_SRC flag ID. It's definitely wrong, though it hasn't caused any problem so far since the structure field isn't used by the EDAC core. Fix it anyway by using the SCRUB_FLAG_HW_SRC macro to initialize the field. Fixes: ae9b56e3996d ("EDAC, synps: Add EDAC support for zynq ddr ecc controller") Signed-off-by: Serge Semin --- drivers/edac/synopsys_edac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/edac/synopsys_edac.c b/drivers/edac/synopsys_edac.c index 455d2fcfd8c1..7c57c43b4d31 100644 --- a/drivers/edac/synopsys_edac.c +++ b/drivers/edac/synopsys_edac.c @@ -855,7 +855,7 @@ static void mc_init(struct mem_ctl_info *mci, struct platform_device *pdev) /* Initialize controller capabilities and configuration */ mci->mtype_cap = MEM_FLAG_DDR3 | MEM_FLAG_DDR2; mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED; - mci->scrub_cap = SCRUB_HW_SRC; + mci->scrub_cap = SCRUB_FLAG_HW_SRC; mci->scrub_mode = SCRUB_NONE; mci->edac_cap = EDAC_FLAG_SECDED; From patchwork Thu Feb 22 18:12:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13567858 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1A539C5478C for ; Thu, 22 Feb 2024 18:16:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+l+BemmXDOSgJAmQAnLodMcB/l0O811y28sDHm0EaWE=; b=MLWhNqlNKEuHJ9 13wa/na+ywgRCw9McGdNYjtbVGa1wv4+WboNKy6AB2pLJUkXBQKQESql9M8fhb09ESr1zFxW0HJe9 oT0Z8sZDstUJycHBFGjITySriiYxMkG3JaS21xO7SRwRVGevQUV5jNdqabR8Bb2DUG4N3+b4Wjq/q q0FRnckGFQ+A9NNWeXNWiyYBvcg+vMsDXZA3KnpLNprgLws6NFN10Pwa2PMhFOoIcvqD+KmDCl8/1 TEH2DbbtMSDlYyIJC1UerCZKa8YeE3Su8n6fJuJpjtIoFHOz85HHV/Y6V0EjMIOF27KNhHTVYJF3L iTw1OtCwiiqPHqI1VCkA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDbT-00000005xVE-41i6; Thu, 22 Feb 2024 18:15:28 +0000 Received: from mail-lj1-x233.google.com ([2a00:1450:4864:20::233]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDab-00000005x3r-3dzb for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 18:14:47 +0000 Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2d21cdbc85bso1179301fa.2 for ; Thu, 22 Feb 2024 10:14:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708625668; x=1709230468; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=e3HjL25KMxGa56gkLYon0vOuoqvhZeVF+dp0oSQkrO0=; b=OW+fNAcJLFo50rIdLHPOb1dX2UPO8BEyaEIVwc8YerWnR4r3SrAE5yvUzDond0mGA2 FFNugYtBL4f2UexXbjGX68uZKyS5XZXr75Jhlrj6c6eVwnMhB+WfocqPklaaMy4GQxQV i9lOiPN419ClBNjdznP9SLiMjcCrdit04aN/q96ZxAQC4zH4Fe+RFJDQAfnlwIufS5Wu DfYSmrVAaoimiNsrW/qEZshP7CQaa1ecuWeGbIT14nB4iUzySrIQCyLcDOdP7/OVbc6e LNo+HJ9KmlUFAAmumNDsHmV9zHNSZFvUq8Go4UitZ99UTe9b166n9v9M37LlrE544Cuf RgCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708625668; x=1709230468; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=e3HjL25KMxGa56gkLYon0vOuoqvhZeVF+dp0oSQkrO0=; b=hSe3Kkxrag7LEhyZKIP+uvWcTp/go+u08vd7R8h8+e7OqGUfqCtyxzmmTET0kZlGRg O1pm8/GlHPNxl8EXaOu4iEvWdFC461ByIegxYNiZKv3mUs43UyA9UCO2bgy/rlnAw9a3 5ea2F4JljEdHxirH8ira+QA2Z0kcsRXMeGAGWH2sUzVyz3Rdt9rrMbR6N8pKEAxelJqO koXfaAGmaKsLBUjggB89phScaYPbMwILABlO7gAtkE1tlXcOqEsNAlNP1RVkTBpAgtYo vs/zfkLyd8QIU6Qv7MJ5C8oAdUS/PWTtQcPoTqefWc+VJUa/RZo7a9Lhu9AdLxd/J8NR VZPQ== X-Forwarded-Encrypted: i=1; AJvYcCUSbVgAc7ekp31j+5354/TXTdhFQLzL11n9kRV4Pzin3w2XtnXPWNzuPRpLYp5RmKNXaBDkfgqVOkGH3xlOh1rOlcIBRPG4dZhCUF2R9ZUtqQaaPFQ= X-Gm-Message-State: AOJu0YyExx+wVcmk5Zl54av3eCA6j1VqofMj6Bh6+zFHyY2cRlOG5smo 6mJCwOoLW5lTpC9QHn6b4EUhcuj1VtwYFvGVlW8cfKQ/zcLKj7+2 X-Google-Smtp-Source: AGHT+IHxkZX3auLTPAfGj/5QgChR12wrYdWdu9SKHx0EmevS1A3wDKwZARalLbPB/ZrSULuvY5aXew== X-Received: by 2002:a2e:b169:0:b0:2d2:643b:df06 with SMTP id a9-20020a2eb169000000b002d2643bdf06mr1365251ljm.2.1708625668311; Thu, 22 Feb 2024 10:14:28 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id j26-20020a2e801a000000b002d10d093c4csm2381337ljg.111.2024.02.22.10.14.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 10:14:27 -0800 (PST) From: Serge Semin To: Michal Simek , Alexander Stein , Borislav Petkov , Tony Luck , James Morse , Mauro Carvalho Chehab , Robert Richter , Manish Narani Cc: Serge Semin , Punnaiah Choudary Kalluri , Dinh Nguyen , Arnd Bergmann , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, Borislav Petkov Subject: [PATCH v5 04/20] EDAC/synopsys: Drop erroneous ADDRMAP4.addrmap_col_b10 parse Date: Thu, 22 Feb 2024 21:12:49 +0300 Message-ID: <20240222181324.28242-5-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240222181324.28242-1-fancer.lancer@gmail.com> References: <20240222181324.28242-1-fancer.lancer@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240222_101441_586238_D1AF7C66 X-CRM114-Status: GOOD ( 13.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Currently the ADDRMAP4.addrmap_col_b10 field gets to be parsed in case of the LPDDR3 memory and Quarter DQ bus width mode. It's wrong since that field is marked as unused for that mode in all the available DW uMCTL2 DDRC releases (up to IP-core v3.91a). Most likely the field parsing was added by mistake as a result of the copy-paste from the Half DQ bus width mode part of the same function. Even though the field is supposed to be always set to the UNUSED value (0x1F) drop parsing it anyway so to simplify the setup_column_address_map() method a tiny bit. Fixes: 1a81361f75d8 ("EDAC, synopsys: Add Error Injection support for ZynqMP DDR controller") Signed-off-by: Serge Semin --- drivers/edac/synopsys_edac.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/edac/synopsys_edac.c b/drivers/edac/synopsys_edac.c index 7c57c43b4d31..bd6e52db68bc 100644 --- a/drivers/edac/synopsys_edac.c +++ b/drivers/edac/synopsys_edac.c @@ -1236,10 +1236,6 @@ static void setup_column_address_map(struct synps_edac_priv *priv, u32 *addrmap) COL_MAX_VAL_MASK) == COL_MAX_VAL_MASK) ? 0 : (((addrmap[3] >> 24) & COL_MAX_VAL_MASK) + COL_B9_BASE); - priv->col_shift[13] = ((addrmap[4] & - COL_MAX_VAL_MASK) == COL_MAX_VAL_MASK) ? 0 : - ((addrmap[4] & COL_MAX_VAL_MASK) + - COL_B10_BASE); } else { priv->col_shift[11] = (((addrmap[3] >> 16) & COL_MAX_VAL_MASK) == COL_MAX_VAL_MASK) ? 0 : From patchwork Thu Feb 22 18:12:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13567859 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E3BB8C48BF8 for ; Thu, 22 Feb 2024 18:16:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=yFW7YYopqdoHQ3JtB+kmaOyNtFBQXo7e1+ObftyjW08=; b=vL6EBNZ2krwgN4 nRmt2o/7dOJ4U4/4Yz0Gspz8I818rp0kNa0tITAJNwvbyVBdEshnK3VJLmaiQ0M8rAkKiZjHRRwVp uRTvf34GBFex20t00XFTtNDZIzC5ZQOcPNAsVO3dQ9qzAjTVl9XFz9vE8j7npMYXNU5NgQt1EyXO+ s6BURNwyhQigM51XP2AwurlSizMq0EVGD5hybfzPedUswWhfVpFIgU4wvB6o7deFZUe+A6vWFicfL 4NFy3ixe/6EtpGSQ/jsRPs8YlKh+WzkJZxMpOBHkTOHln1fOHJDKELk7YoXDt1uGxiTKmPY5DdfaF 1pJnqwnt2HKoCmqw78CQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDba-00000005xYo-18A5; Thu, 22 Feb 2024 18:15:34 +0000 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDai-00000005x3z-3ZAo for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 18:14:46 +0000 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-5129e5b8cecso97994e87.3 for ; Thu, 22 Feb 2024 10:14:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708625670; x=1709230470; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WbPuoFHthQO7fGdQQUUYWZPA9hiREThQLMfvHVCy2ro=; b=ONe/z6ddw94n9dBjRdJ4Vs+1zkO87WSKR1996qCgWlvkoTqLhS9Tj0dj7UhJ3Eu0li jMA0yWkSkH+Yfxdz6zDCQLkRH23fc2h+esvbgJJLwrvWATIQ6uV+LIy1WiOpSgmiQP38 YPk1oxjpltXo5U0TU22gTp6HzH1sPVtqbrFdghw2GmXabxtsQIaSsq/u27ekb5wf72dj SMQ/Iht/dfvToklJtMOovcE3YGjH04+O7fMDLGeoKNke6QFOal9y/HDOdZMU5QQ13nPn kGMxqYa8NcuW10hGkveMZZ65y8qVM92+NkjDATy3m09CfowES9vAU6PJF82CHuJbv5Vx MZCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708625670; x=1709230470; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WbPuoFHthQO7fGdQQUUYWZPA9hiREThQLMfvHVCy2ro=; b=D0FJvOt1/YH5IHeiqp7wf3EmM3d9lPWNAAAyJowA0+GomBhg9QQO5mfESkLe+oA4hv ASjMEnWtnImpNr1pDio7ajMYxDloWyPpi5xy/9BnA1KI0GgGILOZIVdwJELA0XhwwzfT N9WM3MJw60bbTKh5f54+erlweGCppy4iPVBz/I5XDwJoG+DX6BxOWQc6/I9n91I09XC/ EpHIPR+zvVPBhbwBgtpMHE4+2Fown3y9043GpVLFdfPiCabpa0yRxlof8b3l79QQeeFi rjAmiOP5zMSSuwQtnPBiJUNl3pKFnKe6SQYJxApt8dn8uzZgLv2ree7oUIZlfkWJupBs l5WQ== X-Forwarded-Encrypted: i=1; AJvYcCWKdX1KPX3VB4GQSFbyRkunnzexDx/LuEopBwMd2graQNNWFfqiOxYgA7D/vNum/QOFSIb7e8rItlhBJtwg3xYu5yaBf6nJEFyqTLsOO1yglVHlzA4= X-Gm-Message-State: AOJu0Yw/ZwJwg53NSV+RRafs3TNSRQ3pFEctqoGcCjJ6dGhPvoeSQC9X Cc6E9pd3VjniBHqeHT+na3bmbWgnFPTOjdEJ6oj/ws6q+vI1qrq1 X-Google-Smtp-Source: AGHT+IGub+R7lksw83N6+DHfltE4tBIGvnJJIwOUCUdGcZp49D75S0w8KHqmr2FCPWTC9/SRdqNmdg== X-Received: by 2002:a05:6512:31d6:b0:512:a9a4:d933 with SMTP id j22-20020a05651231d600b00512a9a4d933mr12295115lfe.69.1708625670043; Thu, 22 Feb 2024 10:14:30 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id t4-20020ac24c04000000b00512acc62388sm1837562lfq.237.2024.02.22.10.14.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 10:14:29 -0800 (PST) From: Serge Semin To: Michal Simek , Alexander Stein , Borislav Petkov , Tony Luck , James Morse , Mauro Carvalho Chehab , Robert Richter , Shubhrajyoti Datta Cc: Serge Semin , Punnaiah Choudary Kalluri , Dinh Nguyen , Arnd Bergmann , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, Shubhrajyoti Datta , Borislav Petkov Subject: [PATCH v5 05/20] EDAC/synopsys: Fix reading errors count before ECC status Date: Thu, 22 Feb 2024 21:12:50 +0300 Message-ID: <20240222181324.28242-6-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240222181324.28242-1-fancer.lancer@gmail.com> References: <20240222181324.28242-1-fancer.lancer@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240222_101441_549369_64A560F6 X-CRM114-Status: GOOD ( 15.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Aside with fixing the errors count CSR usage the commit e2932d1f6f05 ("EDAC/synopsys: Read the error count from the correct register") all of the sudden has also changed the order of the errors status check procedure. So now the errors handler method first reads the number of CE and UE and only then makes sure that any of these errors have actually happened. It doesn't make sense. Fix that by getting back the correct procedures order: first check the ECC status, then read the number of errors. Fixes: e2932d1f6f05 ("EDAC/synopsys: Read the error count from the correct register") Signed-off-by: Serge Semin Reviewed-by: Shubhrajyoti Datta --- drivers/edac/synopsys_edac.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/edac/synopsys_edac.c b/drivers/edac/synopsys_edac.c index bd6e52db68bc..fbaf3d9ad517 100644 --- a/drivers/edac/synopsys_edac.c +++ b/drivers/edac/synopsys_edac.c @@ -418,18 +418,18 @@ static int zynqmp_get_error_info(struct synps_edac_priv *priv) base = priv->baseaddr; p = &priv->stat; - regval = readl(base + ECC_ERRCNT_OFST); - p->ce_cnt = regval & ECC_ERRCNT_CECNT_MASK; - p->ue_cnt = (regval & ECC_ERRCNT_UECNT_MASK) >> ECC_ERRCNT_UECNT_SHIFT; - if (!p->ce_cnt) - goto ue_err; - regval = readl(base + ECC_STAT_OFST); if (!regval) return 1; p->ceinfo.bitpos = (regval & ECC_STAT_BITNUM_MASK); + regval = readl(base + ECC_ERRCNT_OFST); + p->ce_cnt = regval & ECC_ERRCNT_CECNT_MASK; + p->ue_cnt = (regval & ECC_ERRCNT_UECNT_MASK) >> ECC_ERRCNT_UECNT_SHIFT; + if (!p->ce_cnt) + goto ue_err; + regval = readl(base + ECC_CEADDR0_OFST); p->ceinfo.row = (regval & ECC_CEADDR0_RW_MASK); regval = readl(base + ECC_CEADDR1_OFST); From patchwork Thu Feb 22 18:12:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13567913 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CB66CC5478C for ; Thu, 22 Feb 2024 18:24:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4L9HJDbkz2rvvRTLqolyPhBUaJdkWjE5q2ot2kg1OPg=; b=jVdUYFpSkZ/e5d HSNDobAtBhZaoFp4+YBkxAHl4c3UGM1Z+gL5M557HohiWiCOKAONHW/PlrpYR0n3ORbUazhvIN0Bq wP6lRIpmJEYKQ8NZQZryvEBYYNsKbGR+5nXP4za2sGWfQ6UgnF9JSMxFNU9Ka8vbw9Nx3LdrQANYL 1bA9FwJVUb8IAqXvF/CJxpB1+s6NcPf0AI3wtQVznbV0eWtRp3lAVvvKLq3Wy6dQX2qmdZPe1XU8I 6CXgR5s4ya8PUzm/O8ixVNQUV6k9fkQiHL0ABbALjkYPukXT6DfAgk5L5VNOchSlV2SY4EJthvAdl dkW0BleGKtNGvu6MqF4A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDk7-000000061vQ-1NIQ; Thu, 22 Feb 2024 18:24:23 +0000 Received: from mail-lj1-x229.google.com ([2a00:1450:4864:20::229]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDai-00000005x43-3Zqw for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 18:14:46 +0000 Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2d21cdbc85bso1180121fa.2 for ; Thu, 22 Feb 2024 10:14:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708625672; x=1709230472; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FxFAh3uoI4mzu17nUzZOceQCxF3v8VnFVlLwfRIN1G8=; b=Q7cGZ4DpdDA85+lxXZN0877hNHt4vuXwNDyc07LXNgIxjt8gYuwwJrG4pjww7QA7bw arQ0r3Xo3k7Wd8E0Qg27/0MH4Ig6FIwbJkWkU9Lr6SJGZXFbeUxMxu5xuMD5uhnRj7ws 9MOcHk0F8nv/n7afrNS3eezYHnWYdKMWAGS9w7m9Nzgi0JzNKX0ZSDq0wGgjFSaLhNUG miqpK89hvyCXW4PsLsYE/yVMtKt/vvuMu+w/50nLLR/Jv2gA1em6MNV1EwH/xX4BI2ag nJtjzOn42Z4R6Oa1Yg56bpiG3WoEhmD5N+8yTN66wX86o1Np1UKeqlpfBbGjQj0b7S3j blmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708625672; x=1709230472; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FxFAh3uoI4mzu17nUzZOceQCxF3v8VnFVlLwfRIN1G8=; b=J265U1pyFPddGu7oYpIdoujZefbxDz++PmVMwlgNYLfnBkB1Mj2HN2+mhoWPBSfQIA 4Dbhl8txzB2oHjzFl2KpliOH45gvNo5gw3tPwg6jdf02XzfXNu4J25hxfybHHFFcLWc+ ytIrhE2/YBRYeiqTpEZk8nuEXaKXpR3e6w2ET2bI4JTM7Ukgg7A786gqkrDlSPDnUr3l c9TRKBCesR4WDVjaKcitkiBWg1URTH1D5jmXJiHOuzKEPVS/ii/96oKvkNaouYmtx8o/ vrBjaIn+S5l8bniT+4WizMr4D5Q19vtSiUD+/oBEeT61v/aEtKRiWFj9b8dOS2hEbLxS x6gw== X-Forwarded-Encrypted: i=1; AJvYcCVdGraQ1m5X6EpZdmNFZv0OYA0yotIXLgOwwjlW8Zic8DGTAAx2TWdtkiCI+Wdc0Beqs1U+9RVDh5Geb2fGd2s3nLXVXf8ztqXl/w+x3LBWRqxHckI= X-Gm-Message-State: AOJu0YzFWET5B5A2Q3p2yKlebLfwPN0y3eyzAqIsbNIDOpeoYvz7Dn7L d/bEGjWgUrSJDmorRsBbKxhgLgyD9TtbzCJ1mtgkDUr/J1TT1Otc X-Google-Smtp-Source: AGHT+IEBxM0SCQ/qh7iQYAnlf4bfAWyykcK2D4qRb34ypGnhSJishMItFlRhuHiRMAC1rEyOZCuebA== X-Received: by 2002:a05:651c:1311:b0:2d2:373b:5b15 with SMTP id u17-20020a05651c131100b002d2373b5b15mr7681787lja.43.1708625671643; Thu, 22 Feb 2024 10:14:31 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id z8-20020a2e3508000000b002d0d5373290sm2350157ljz.4.2024.02.22.10.14.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 10:14:31 -0800 (PST) From: Serge Semin To: Michal Simek , Alexander Stein , Borislav Petkov , Tony Luck , James Morse , Mauro Carvalho Chehab , Robert Richter Cc: Serge Semin , Punnaiah Choudary Kalluri , Dinh Nguyen , Arnd Bergmann , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 06/20] EDAC/synopsys: Fix misleading IRQ self-cleared quirk flag Date: Thu, 22 Feb 2024 21:12:51 +0300 Message-ID: <20240222181324.28242-7-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240222181324.28242-1-fancer.lancer@gmail.com> References: <20240222181324.28242-1-fancer.lancer@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240222_101441_559465_3725FBFE X-CRM114-Status: GOOD ( 24.73 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The DDR_ECC_INTR_SELF_CLEAR quirk flag was initially added in the commit f7824ded4149 ("EDAC/synopsys: Add support for version 3 of the Synopsys EDAC DDR") in order to distinguish the ZynqMP DDRC (based on DW uMCTL2 DDRC v2.40a) and the announced in that commit Synopsys DDR controller v3.80a. The selected name is misleading for the next reasons: 1. None of the Synopsys DW uMCTL2 DDR IP-core has the UE/CE IRQs auto or self cleared. The IRQ signals (ecc_corrected_err_intr and ecc_uncorrected_err_intr) are cleared together with the rest of the ECC error data by means of writing 1's to the respective ECCCLR bits. It worked like that in DW uMCTL2 DDRC v2.x IP-core and it's still true for the modern DW uMCTL2 DDRC v3.x. 2. The IRQ-related registers accessed unless the denoted quirk is specified are actually Xilinx Zynq-specific. None of the Synopsys DW uMCTL DDRC IP-core have any registers at the offsets 0x20200/0x20208/0x2020C. The most modern DW uMCTL2 DDRC v3.91a IP-core available has CSRs space end at the 0x43dc offset. The older IP-cores have even smaller registers space. 3. What was actually introduced in the DW uMCTL2 DDRC v3.10 by Synopsys is the IRQ enable flags which older DW uMCTL2 DDRC IP-core didn't have. They were added to the ECCCLR register (the CSR was also renamed to ECCCTL in the v3.10 IP-core HW databook). So since then there have been no point in having a vendor-specific IRQs masking solution like described in 2. and the IRQ signal can be now shared even for the native DW uMCTL2 DDR controllers. So let's harmonize the quirked IRQs code based on the statements above: rename the DDR_ECC_INTR_SELF_CLEAR quirk flag to SYNPS_ZYNQMP_IRQ_REGS thus indicating the ZynqMP-specific IRQ CSRs; add the new quirk flag to the ZynqMP platform data; drop the misleading comments about the auto-cleared ue/ce flags; add a comment about the new IRQ enable flags added in v3.10 IP-core. Signed-off-by: Serge Semin --- Changelog v4: - This is a new patch detached from [PATCH v3 01/17] EDAC/synopsys: Fix native uMCTL2 IRQs handling procedure --- drivers/edac/synopsys_edac.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/edac/synopsys_edac.c b/drivers/edac/synopsys_edac.c index fbaf3d9ad517..9f79f14e57b2 100644 --- a/drivers/edac/synopsys_edac.c +++ b/drivers/edac/synopsys_edac.c @@ -88,7 +88,7 @@ /* DDR ECC Quirks */ #define DDR_ECC_INTR_SUPPORT BIT(0) #define DDR_ECC_DATA_POISON_SUPPORT BIT(1) -#define DDR_ECC_INTR_SELF_CLEAR BIT(2) +#define SYNPS_ZYNQMP_IRQ_REGS BIT(2) /* ZynqMP Enhanced DDR memory controller registers that are relevant to ECC */ /* ECC Configuration Registers */ @@ -526,7 +526,7 @@ static void enable_intr(struct synps_edac_priv *priv) unsigned long flags; /* Enable UE/CE Interrupts */ - if (!(priv->p_data->quirks & DDR_ECC_INTR_SELF_CLEAR)) { + if (priv->p_data->quirks & SYNPS_ZYNQMP_IRQ_REGS) { writel(DDR_QOSUE_MASK | DDR_QOSCE_MASK, priv->baseaddr + DDR_QOS_IRQ_EN_OFST); @@ -535,6 +535,10 @@ static void enable_intr(struct synps_edac_priv *priv) spin_lock_irqsave(&priv->reglock, flags); + /* + * IRQs Enable/Disable flags have been available since v3.10a. + * This is noop for the older controllers. + */ writel(DDR_UE_MASK | DDR_CE_MASK, priv->baseaddr + ECC_CLR_OFST); @@ -546,7 +550,7 @@ static void disable_intr(struct synps_edac_priv *priv) unsigned long flags; /* Disable UE/CE Interrupts */ - if (!(priv->p_data->quirks & DDR_ECC_INTR_SELF_CLEAR)) { + if (priv->p_data->quirks & SYNPS_ZYNQMP_IRQ_REGS) { writel(DDR_QOSUE_MASK | DDR_QOSCE_MASK, priv->baseaddr + DDR_QOS_IRQ_DB_OFST); @@ -577,11 +581,7 @@ static irqreturn_t intr_handler(int irq, void *dev_id) priv = mci->pvt_info; p_data = priv->p_data; - /* - * v3.0 of the controller has the ce/ue bits cleared automatically, - * so this condition does not apply. - */ - if (!(priv->p_data->quirks & DDR_ECC_INTR_SELF_CLEAR)) { + if (priv->p_data->quirks & SYNPS_ZYNQMP_IRQ_REGS) { regval = readl(priv->baseaddr + DDR_QOS_IRQ_STAT_OFST); regval &= (DDR_QOSCE_MASK | DDR_QOSUE_MASK); if (!(regval & ECC_CE_UE_INTR_MASK)) @@ -598,8 +598,8 @@ static irqreturn_t intr_handler(int irq, void *dev_id) edac_dbg(3, "Total error count CE %d UE %d\n", priv->ce_cnt, priv->ue_cnt); - /* v3.0 of the controller does not have this register */ - if (!(priv->p_data->quirks & DDR_ECC_INTR_SELF_CLEAR)) + + if (priv->p_data->quirks & SYNPS_ZYNQMP_IRQ_REGS) writel(regval, priv->baseaddr + DDR_QOS_IRQ_STAT_OFST); return IRQ_HANDLED; @@ -913,7 +913,7 @@ static const struct synps_platform_data zynqmp_edac_def = { .get_mtype = zynqmp_get_mtype, .get_dtype = zynqmp_get_dtype, .get_ecc_state = zynqmp_get_ecc_state, - .quirks = (DDR_ECC_INTR_SUPPORT + .quirks = (DDR_ECC_INTR_SUPPORT | SYNPS_ZYNQMP_IRQ_REGS #ifdef CONFIG_EDAC_DEBUG | DDR_ECC_DATA_POISON_SUPPORT #endif @@ -925,7 +925,7 @@ static const struct synps_platform_data synopsys_edac_def = { .get_mtype = zynqmp_get_mtype, .get_dtype = zynqmp_get_dtype, .get_ecc_state = zynqmp_get_ecc_state, - .quirks = (DDR_ECC_INTR_SUPPORT | DDR_ECC_INTR_SELF_CLEAR + .quirks = (DDR_ECC_INTR_SUPPORT #ifdef CONFIG_EDAC_DEBUG | DDR_ECC_DATA_POISON_SUPPORT #endif From patchwork Thu Feb 22 18:12:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13567901 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 461A2C54791 for ; Thu, 22 Feb 2024 18:22:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1Aj+5AtWWCESgqn3e1I5KwX0KGpDClY0TI7GqfoXe5s=; b=doCS3GrHttOTwE my23fxW9f7qLahSD6Exgz71mBElPmjvmZgPnIO26Y256DW7alkgdRztzBeJ+FwWq4MqHO5dxuUVNK bD7R72OfteDALtdRe2ccjtion+F4yz7vgJAHp19sRUWjr8acjEdFY3zGuSfr9RqI32CejNJj0CN2N hZiEvWzoiwiDE9QKfvxiplNgtMKqS9BNuEeeXKL52pI86BrPA7+osgFnse0c9tEfefbyKePzylWDn tm299FS++mE8nBnfK2R/zVRi4ZqbiuNJkZtPdtjfybgnRDklficq+M9pOVgX9NBGDTxWq6R/FG6kT TX4vhU7YQgqEuMJHh9gg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDhv-000000060hE-0De2; Thu, 22 Feb 2024 18:22:07 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDbg-00000005xdf-1yF1 for linux-arm-kernel@bombadil.infradead.org; Thu, 22 Feb 2024 18:16:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=bBJgQUpt9QPAedIUl/F1sU9yR+N7bF2zoeqIhscgJyQ=; b=CZlhKjmkFLmGB6m8tXkWZZ1fQT gotCEpDTrXlj/qyIfbmKkXm0vz4zpVGtwszjxodegrGTqFWMFc15sx1klP/+ECd2uL0yPKytPjQMz 0ypryHJFIfcUJAkJ9Kt9JR+9Qyc/LuXc32Jt345yauw5zXXLsv0FhVTzDqirrcyVa3lB3Dp2Ml6C+ C+zETK1cXJvM/2XgZS8nfBgp9U7fIrDXSu8m28Ohl5P7x6DaybVOrxj8/V2bSzqSAbsD9pwI73gKE 2yds75O/0ZObojS3kHFnx3d3NX9rGzIwYVDLZTo2S/Yq48Gq1c46wDVhole94ozJ2CM+nse3oL2wJ 7dmi334g==; Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDbd-00000004Ikj-2see for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 18:15:39 +0000 Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-51197ca63f5so120829e87.1 for ; Thu, 22 Feb 2024 10:15:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708625674; x=1709230474; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bBJgQUpt9QPAedIUl/F1sU9yR+N7bF2zoeqIhscgJyQ=; b=Wdu0Ok7Gjlg/DM/sK2nC6sNMXQsc1hvGBOqpKWp5EzGHDfM8bwItMlSUBiz5Yt26sP I2Q+DKR42GocWcD9Ehks2VA/8KeO6UwIwTf2V80H5D99aTEe5NA7w50U8wbvr/WTV9kW SHMxe/dozSCXFdFq3vkpu1uHG9wZMwTLo2sR3Cch6igmvxkhT64Nt6lp84o4v0xFGEiN B0aIpS5WzqFb6PpYwwTs4Iojz0EJNBgQnnW7yE62mG6CRcWlAUOo1zNCZxNOEk0+NILE GWmwvP60HtHyzuqeBS77Fs1fCfcIfaUHG34Pd0dj4rQf8fedtL5PacVBZOKthKh2ovYp gaFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708625674; x=1709230474; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bBJgQUpt9QPAedIUl/F1sU9yR+N7bF2zoeqIhscgJyQ=; b=YFdFo4RVyKUDsYgaA5zd8CWVDWgdeyaFplzSNACe76EH4+4WbjWUWTmXNBQ7RoNKZ1 Ojn9E/yitIK5BpkgLzoxpaOsr+9+zrZi2AfL3xKJXY6b01SHewmJSikFu69WejfKxmed +ORXa06RgakOZJ8GKQp6U2Wof1+tFPHuRuA6v03sXvfm293uCcMzNKEPE7bfif7M4jI4 rT+e3zJL3lBnbVcDBqn0qg1VNwa6MV2nmBb+K/zHI4vkaUEpSLY0iOV7M3B+wX3CbHqg eMocCfu6duaDyG8c53gJnPodTcg0X000HlGwq4Mgav5EWDBMUYevC/1X23Nt+80hnFlm I8Zw== X-Forwarded-Encrypted: i=1; AJvYcCXedYt40kTDvOUUbrZ5gQRDpM0iJyX53e7DZ8hvR7tmFfEd8U8jN50zSa1hDOl/TQOA+l7XZNDSkHHlqFpGS2+UBhYesAZkLbahbOvomsCO1EFChvU= X-Gm-Message-State: AOJu0YxAWgmn0EfTG9iblEx6n6Wuh2gYVWr5YU86SlixgIsNUGaLXYfy lKkQdEHDrRqYPQS2dhyhXmElL9oHU5tz7LJHZVkQdhbPojjP++q1 X-Google-Smtp-Source: AGHT+IHKAOKhAnBFoPeZwONNUJ2X2BwTf+yE6S14EUUfcztnzHrErdARP1//97DTkUotDbqufLNMLg== X-Received: by 2002:a05:6512:3ba2:b0:512:a2c7:e44c with SMTP id g34-20020a0565123ba200b00512a2c7e44cmr12225023lfv.20.1708625673758; Thu, 22 Feb 2024 10:14:33 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id q25-20020ac246f9000000b00512b0462438sm1744919lfo.116.2024.02.22.10.14.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 10:14:32 -0800 (PST) From: Serge Semin To: Michal Simek , Alexander Stein , Borislav Petkov , Tony Luck , James Morse , Mauro Carvalho Chehab , Robert Richter Cc: Serge Semin , Punnaiah Choudary Kalluri , Dinh Nguyen , Arnd Bergmann , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 07/20] EDAC/synopsys: Use platform device devm ioremap method Date: Thu, 22 Feb 2024 21:12:52 +0300 Message-ID: <20240222181324.28242-8-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240222181324.28242-1-fancer.lancer@gmail.com> References: <20240222181324.28242-1-fancer.lancer@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240222_181537_737070_8F06F6C7 X-CRM114-Status: GOOD ( 11.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DW DDRs CSRs resource descriptor is used by the devm_ioremap_resource() function invocation only in the driver probe method. Thus convert the platform_get_resource() and devm_ioremap_resource() couple to just a single devm_platform_ioremap_resource() method call. Signed-off-by: Serge Semin --- drivers/edac/synopsys_edac.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/edac/synopsys_edac.c b/drivers/edac/synopsys_edac.c index 9f79f14e57b2..6976ef84e952 100644 --- a/drivers/edac/synopsys_edac.c +++ b/drivers/edac/synopsys_edac.c @@ -1334,11 +1334,9 @@ static int mc_probe(struct platform_device *pdev) struct synps_edac_priv *priv; struct mem_ctl_info *mci; void __iomem *baseaddr; - struct resource *res; int rc; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - baseaddr = devm_ioremap_resource(&pdev->dev, res); + baseaddr = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(baseaddr)) return PTR_ERR(baseaddr); From patchwork Thu Feb 22 18:12:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13567904 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6E0F1C5478C for ; Thu, 22 Feb 2024 18:22:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4BBH61gm4Gj5i5Y+Z7wp4mD3w5EKF+NksH8JVjJnSxo=; b=eqkjLm9SIBnLj4 iRcO+/1w15IGoxq1LCL2N8k0mOQ0QIN7jqaDuuOebFXvgbgyKQ+VWYLu+3tmyOUywWTgbGVF+2kx0 pINHXFGg5+I6zS6YZs+IIS9WU3kcVlwfmkWwrlJyDSJSebjfSYcQF5S8UAH8ARUaRBglxzFrITs4/ 6dwcf5mfo0P+/SOo4z2Q8TzIvcqQgql499mqxBr3G2YFDEUdQC8ODa99l9pNj0qu+h3K0pHeYiWTW fpuFzrpZ62MeRc2f62Ptf3P7pTbdPEG5ydCH3Lo/HM1sUASAPKWRX9uR5YjRzvQYeKdrEBrZpzE+k jSpGUGHqleAbpRyx2A/w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDi2-000000060mr-2STe; Thu, 22 Feb 2024 18:22:14 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDbj-00000005xeB-1Cwr for linux-arm-kernel@bombadil.infradead.org; Thu, 22 Feb 2024 18:16:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=75JkZwTsL4Dcbz0CcBW0plC9VrJj9UCwkyPRaMtpo4c=; b=hRGzzth/4yT0pFjrdF1S2aDPO3 X64qhYHPZMaUWNozxdIf5hQmh7gVZJJFT1sqvblJyQEylXomSGm3hBDpkMfwcL1k63G0DFGZ0U1+v avg1k16Pemye5+x4POoZZFG5ta85BcSpCvsksq/0mJAwfWdrrP4Hfimo4L0ed582v/Ml/riJdIP2X 0DTLkkYUKz3KNClfmxlrY8HvxAz5v72Z9FRyWaAikpllMZrM9jarOIiUqry4cFuFhLKWlRM0zeXkH xuGS2CjME+8vdRWLOwABTW/LRRbYK40XOSWhOo8CYycSJwwWcYlp2+Bag+9Ft3y1Vf2fQ+NqUmlj5 Zrs2OFCg==; Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDbg-00000004Il2-1ZNn for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 18:15:42 +0000 Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-512b29f82d1so105216e87.1 for ; Thu, 22 Feb 2024 10:15:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708625675; x=1709230475; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=75JkZwTsL4Dcbz0CcBW0plC9VrJj9UCwkyPRaMtpo4c=; b=Grr6G+yX+jhyuZJqrz8NNLxupSaVyvWL05tBYg7jkuE3Y04Ma46Vis34jkf55Bj3cl d/wLwmEUKn8XzTAnRqKWY/UtJTVIzPWOJvC1MSORxFkk4fxGvMRviUvKz90lclx2oSqf x9rYn2GCklZ2MkzpccLMpCA4oe/2hIPV98Eqs7IpMx7vNyNaPq6sROsUNc86WTszysMr 5pmloNXA5dnkphtMDIFCkirxwX7Cf61kMV3csg4BXntFfdbYK1ycicPQnOZqr1KZHZUv KAIxuaafXBiO/sams0sTsBzADTPotgIFTw0983J+uitpwjMxseGm4ArOwDg7f0qB6Qs3 MZdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708625675; x=1709230475; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=75JkZwTsL4Dcbz0CcBW0plC9VrJj9UCwkyPRaMtpo4c=; b=gjCTAdX0BNSetN2uAlYwPiqPTQvKzF0amVrICSvqFglY2hEx6fcBLPotCPGy03vEYG axn9SvH2JvFal4MGwvZALUTUDaWdDSOKpJ6GeQtlnOfdYLJSkhqBmmNXQY+p0C0t9mzB tFpWJyD6IM3sMHutnM7P6rwUL7HsnCni8DHrftuR0dZrHXsUdtnQSZGYAolhByGIzRhW KVlrA5yhWjUFN4xEGupMrK8z9PF3Wc72P57bMs59TP27AUi1sewTGpZlqdlM6mbZB640 KZWkvkG/1o17hAuZ1WuwjBM19GhqyIjXaD7YGo0U38ZuEervXsUPKUGQO/6usrwdX7P3 o1wg== X-Forwarded-Encrypted: i=1; AJvYcCW/7iSkZN8noJQjbWc0ivXUBo9MRo2Gxiq9OO4ZpkZbxJUejyFxePAXnnR4RkaWh/TRutQR58ghDZj+1bzOdPVle0TdtS18AIwu/gblREcLdeXgduQ= X-Gm-Message-State: AOJu0YwbwAm6+8lgB+ONx4y67q6t2F3EpTcbnReqTdUMrp2fhZsDwQto c9Hg0mF9YMj/x1tOG7MnSNWd5SYqSkt9hHJvPZ1AzRAJIv5B0Em8 X-Google-Smtp-Source: AGHT+IHL5/hu6VK7d3WPOWjLHTAPQ0FqlAB/KtPSK88tLkHZmTgfAUxJRAjJ8Q5xs1zpJYKDO1R7kg== X-Received: by 2002:a19:5e42:0:b0:512:aa57:f38b with SMTP id z2-20020a195e42000000b00512aa57f38bmr10450667lfi.53.1708625675351; Thu, 22 Feb 2024 10:14:35 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id x18-20020a056512047200b00512a62a176bsm2030675lfd.26.2024.02.22.10.14.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 10:14:35 -0800 (PST) From: Serge Semin To: Michal Simek , Alexander Stein , Borislav Petkov , Tony Luck , James Morse , Mauro Carvalho Chehab , Robert Richter Cc: Serge Semin , Punnaiah Choudary Kalluri , Dinh Nguyen , Arnd Bergmann , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 08/20] EDAC/synopsys: Drop internal CE and UE counters Date: Thu, 22 Feb 2024 21:12:53 +0300 Message-ID: <20240222181324.28242-9-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240222181324.28242-1-fancer.lancer@gmail.com> References: <20240222181324.28242-1-fancer.lancer@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240222_181540_429322_4E19013F X-CRM114-Status: GOOD ( 10.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org First of all these counters aren't exposed anyhow from the driver. Secondly the EDAC core already tracks the total amount of the correctable and uncorrectable errors (see mem_ctl_info.{ce_mc,ue_mc} fields usage). Drop the useless internal counters then for good. Signed-off-by: Serge Semin --- Changelog v4: - Drop redundant empty line. - Drop private counters access from the check_errors() method too. --- drivers/edac/synopsys_edac.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/drivers/edac/synopsys_edac.c b/drivers/edac/synopsys_edac.c index 6976ef84e952..5099246db90e 100644 --- a/drivers/edac/synopsys_edac.c +++ b/drivers/edac/synopsys_edac.c @@ -304,8 +304,6 @@ struct synps_ecc_status { * @message: Buffer for framing the event specific info. * @stat: ECC status information. * @p_data: Platform data. - * @ce_cnt: Correctable Error count. - * @ue_cnt: Uncorrectable Error count. * @poison_addr: Data poison address. * @row_shift: Bit shifts for row bit. * @col_shift: Bit shifts for column bit. @@ -319,8 +317,6 @@ struct synps_edac_priv { char message[SYNPS_EDAC_MSG_SIZE]; struct synps_ecc_status stat; const struct synps_platform_data *p_data; - u32 ce_cnt; - u32 ue_cnt; #ifdef CONFIG_EDAC_DEBUG ulong poison_addr; u32 row_shift[18]; @@ -592,13 +588,8 @@ static irqreturn_t intr_handler(int irq, void *dev_id) if (status) return IRQ_NONE; - priv->ce_cnt += priv->stat.ce_cnt; - priv->ue_cnt += priv->stat.ue_cnt; handle_error(mci, &priv->stat); - edac_dbg(3, "Total error count CE %d UE %d\n", - priv->ce_cnt, priv->ue_cnt); - if (priv->p_data->quirks & SYNPS_ZYNQMP_IRQ_REGS) writel(regval, priv->baseaddr + DDR_QOS_IRQ_STAT_OFST); @@ -624,12 +615,7 @@ static void check_errors(struct mem_ctl_info *mci) if (status) return; - priv->ce_cnt += priv->stat.ce_cnt; - priv->ue_cnt += priv->stat.ue_cnt; handle_error(mci, &priv->stat); - - edac_dbg(3, "Total error count CE %d UE %d\n", - priv->ce_cnt, priv->ue_cnt); } /** From patchwork Thu Feb 22 18:12:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13567900 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 37739C5478C for ; Thu, 22 Feb 2024 18:22:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5hYfsy/ssX//EOlPFh9ldjgsYVugi0ZkVURfho2RQOI=; b=t44ZJzj0kTsg+L VyKSGkwzBIOazIHkJs0LVMrkD9ej2OtAckpj3DCzMloU7F0goF7XHFrx47hyaxVIxrdX8V0/xRfHD ovVcNR8ySLdIu9/23TtDtZAticbKzgI93DytgvSGc2Yc3m0gtAtSCy/Hwiy3TKlSfVTlnhUVjrqc1 QZz1LcGhyzTWvOswaUDK5JTeyQVBryS4PyKNB9iSdMBETnd4F56vr862voXr0o53levRoP39MQckx UQAXLPmMG4xi3XQthpSfSDgbKn/yQlYfiFVP6ERAjyxnRa7WzL2rvdenUghSQxc2ZVwKtlMTl/rtZ G3wKcGH22ELFgAx8CNAw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDhx-000000060ip-2wQn; Thu, 22 Feb 2024 18:22:09 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDbn-00000005xec-0RYK for linux-arm-kernel@bombadil.infradead.org; Thu, 22 Feb 2024 18:16:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=/KDD/bgajALRVWO+j8th9FkNjs1Uxn5aRXvljpgi1rg=; b=RSxpLuyQWCFYjX1Md1I68VhL2T qkMqOwCejHQdyekpu0CEr7KC8Ra7DmY0JF+WwpEToB7y4dqoJhwuSCwwBLbmCb3qhZvQxcnHaLl40 2ZORBKDqqJ6E+g70YuGdOsLcd42zKlDwgKMF0ZdHt1yb8bhGHGDcRLsXzUKMSPl4W0OG0dBDj4J6K iePKCJ2CiKqcXbRpLgRL7jmlHvOUfbq5eOiMdTvt1+AYaC+f8wYajNVRCiyv2seFFaact5JFJOcew DvdMsTuoujkmNI6cn9JOsbmsLhT7ykxUxsModK6siYP2lIwpZnLV8/B61uee7m+38lUJK/6AoDaIS jf72VZFA==; Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDbj-00000004Ila-2LZr for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 18:15:46 +0000 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-512cba0f953so83884e87.2 for ; Thu, 22 Feb 2024 10:15:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708625677; x=1709230477; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/KDD/bgajALRVWO+j8th9FkNjs1Uxn5aRXvljpgi1rg=; b=PH5CcHj3twbVcXInDiPc7XvCuyr9zeykJds2riR4on59xOxvcBPw1iylF0GfNeNGkf EsYFDDhdLWYIsCENM4Wren8eizt1VaBC7f4cY7PpmXnV02MqDS4IAaHdtG2B92v2ELNI I7Fm9peLNtXobT09KT0F1f9bE0MxTccmjky8UZgRqWJomEIwHrkWOiYB7gYEkIEgj3zB ZMxyWsVa5o1WyaZlvwH9VvYQDi8nmlS7aeePANwANV1hcl0/C9S6SdmLn2bODbP03YY7 7MNHI7n/5DaPMbozCVlpxveDs/Q2d12J2roCtC0wZLkuieCnTwwGZ0hZsm7acxcv3jy5 Zd6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708625677; x=1709230477; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/KDD/bgajALRVWO+j8th9FkNjs1Uxn5aRXvljpgi1rg=; b=j91+k/hD3x0dhZzTUZqZPCM4tKlGEhtLdbHpWNatStKTiRbYMqdZdDxsZoAmFLBaBT GaoiNZC28AKw72zAd5VMwZMXqK+xlKNN1DV/Rluex18A8VzbfddnZxzuwGfOpH48hsfa 1yJWa+ZMMJDeiEtcvNtSzv4iU2tylFVCqbe3Buomf8M4rLuImVPQqW9o7E0l4zgyeAoN l3iKebYzYyWAbkea+7Vo1UXdiXrpGUPKUFy11SKYDlJ1QuVqbezwU8bYrzfwMpb1yEfi jxdhxUOjHO9dna2Y2xZv2kzLr6v7F4cqM7lM4Bvuas2QS3Eg1YAi6mKUOEoUmx5AzqU6 L4zw== X-Forwarded-Encrypted: i=1; AJvYcCVk6bmquk0fkBG0BfhvTodlz6gJEQUm/XtikeUF1oL56qcihOqz8pqF5VB9Ht5wita19pAQ/fRG/OzAkIK5cfOn+2kqX3wq4Ze415KkLmJIyv8ol2c= X-Gm-Message-State: AOJu0YwuCrJEbMurGrbVi4bqlzgx4hTu2NoN5XQn1U8BYIlqizOqShhG RbVJ7IaM9gsuJh8RNGkEq0AOedx92GcanuFHGFjNc92oga0ONueB X-Google-Smtp-Source: AGHT+IEqX3LxEhT5jkFdrvdQSh0VSFYxzZfMDjApSMdtK11qjBKsdW+5JPn+EfVyBINk1xssUQMbPQ== X-Received: by 2002:a05:6512:1327:b0:512:99a3:62eb with SMTP id x39-20020a056512132700b0051299a362ebmr13469414lfu.54.1708625676990; Thu, 22 Feb 2024 10:14:36 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id a10-20020ac25e6a000000b00512dd50af1dsm296800lfr.22.2024.02.22.10.14.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 10:14:36 -0800 (PST) From: Serge Semin To: Michal Simek , Alexander Stein , Borislav Petkov , Tony Luck , James Morse , Mauro Carvalho Chehab , Robert Richter Cc: Serge Semin , Punnaiah Choudary Kalluri , Dinh Nguyen , Arnd Bergmann , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 09/20] EDAC/synopsys: Drop local to_mci() macro definition Date: Thu, 22 Feb 2024 21:12:54 +0300 Message-ID: <20240222181324.28242-10-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240222181324.28242-1-fancer.lancer@gmail.com> References: <20240222181324.28242-1-fancer.lancer@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240222_181543_639187_B81C3A4D X-CRM114-Status: GOOD ( 12.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The to_mci() macro was added in commit 1a81361f75d8 ("EDAC, synopsys: Add Error Injection support for ZynqMP DDR controller") together with the errors injection debug feature. It turns out the absolutely the same macro-function has already been defined in the edac_mc.h (former edac_core.h) header file. No idea why it was needed to have a local version of the macro, but there is no point in it now. Drop the local macro-function definition for good. Signed-off-by: Serge Semin --- drivers/edac/synopsys_edac.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/edac/synopsys_edac.c b/drivers/edac/synopsys_edac.c index 5099246db90e..21b0d791cb8b 100644 --- a/drivers/edac/synopsys_edac.c +++ b/drivers/edac/synopsys_edac.c @@ -940,7 +940,6 @@ static const struct of_device_id synps_edac_match[] = { MODULE_DEVICE_TABLE(of, synps_edac_match); #ifdef CONFIG_EDAC_DEBUG -#define to_mci(k) container_of(k, struct mem_ctl_info, dev) /** * ddr_poison_setup - Update poison registers. From patchwork Thu Feb 22 18:12:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13567903 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8FA27C5479F for ; Thu, 22 Feb 2024 18:22:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Zl7trGBa4ccYnCfZPbMp0euikgIp6jtvjZBYJubLPkA=; b=aiUx+zREab+uI5 COeCdz+W05fjcgdsmLeHXOuea90CcXa9/JFadN9CJOP7JnVN/6MqC80NO4Gucjj5Qr6seJBDfOCpH 9mYrulg0a9Mm7Avcb47SHoI9zCqzfl42pui/KLXkimV8Hz/WuX9gJUKg8UXbQwBgOAf7zA3y306He AVoy1hrBQZC+9Y+AXPzYKcOECd1nBTPL4vTo57FaIH8/WjtfmL4nUaBXyBpJthKNzQcH2t+0P6dID BLHirrlKGUoSgzMpbF1v1b6fVm0rAFo9ULlHBwwvecxXKgwhBydKCR5P94/OAQvOS6pafOGx25zQN DiqvSJVGTq6Wf3raiu9g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDhw-000000060iP-3Edu; Thu, 22 Feb 2024 18:22:08 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDbo-00000005xeu-13oB for linux-arm-kernel@bombadil.infradead.org; Thu, 22 Feb 2024 18:16:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=Tv0ab2lgE4guOpRcHEiI1iTXuRh4uBNVZdl4mwlt2wg=; b=r+/LjkkfCTibOWbgvljDpdeooh IMpDQNVT0XxNB7UQVEzM5CPzGibCPM3GnI6aXOiVqrCiW5H5T3jnaT6iSqo55ThyTZDE7t3YGfwyF nRo2JQv4i4+rlI3xhqUmCL1qJcVeeSb8KIk3HWN7u4y/Hm9gpznIQD8+AEeDTrOARdbU/YN4qR2b+ 23o0RvLXoCk2jI6i6qHgxFkd/FW/s1ozqYrO9obEpEuT6Q36jgvVHvd9Tos5R7MsCmqJi0gskO8uT 3n6y9QhdmVuocgO5ZYUynb1gO/hzaJk4W4Q1x0uVULL0AAGy4VOfi/PDCMLec/ile6liL6k6NSaWT DArUo91A==; Received: from mail-lj1-x229.google.com ([2a00:1450:4864:20::229]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDbj-00000004Ild-3Kie for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 18:15:47 +0000 Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2d21e2b2245so1342791fa.0 for ; Thu, 22 Feb 2024 10:15:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708625679; x=1709230479; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Tv0ab2lgE4guOpRcHEiI1iTXuRh4uBNVZdl4mwlt2wg=; b=cJL/7hL2YD6L28ql4wsLrh2wUcrJeQKY75XICdyl0mpbjIT9qpMjelmWPIjcdQ7ny5 63AmZnOeQNHNXSWQpT6sxqCfkZQF0rUGfMDgY6HY9YrLAA1U9AZUARVJRxQQuID5jKPv hys2F/Q3KXiN7DEVofu6TV2bjJEx/u8fbuqzCtwXGLdoTu3DxtKyvj3oys9qWD4ZCtiy l2TZf8+BeQwxzUOh9aI7d+6XKKf+T0pP/J64UxdpzxY+L9DuDM4Nrb85oIJbKyIzKczn qTDd+y49WsdmF9qc3wb8PqtfXEgOd53R+bv+vLkImAEPipC4D59Ttr7WFHN98Ol21kH3 fxjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708625679; x=1709230479; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Tv0ab2lgE4guOpRcHEiI1iTXuRh4uBNVZdl4mwlt2wg=; b=R858R2IkuXi7aiRv11JlCmkEGJn4e3pPDnVSx1qgIvjfioFs1oamtqnk58AwdmhLtV bmewCLEhpT9eMELKhdLDE2dk9IF09zuJ9xaHqMF0Krwz8FKxmIZDPsrfv8MMqsg+Saar L2I1u4egxGXDSXe4NBua0c+nQf3PrtyHXW7jQR5KD9d61C+VBCAl55dS3b4iBHiJl0ql GQTPenqgChz1pyolqdYE9M+uSK/9w77gAhcW+qZbcSlLx1NlpasdAFPW7g033FYxcUfB RjBSX0GUrC41BwNUqj9bodTLdfPjEauiOp5zsZ5epJx+tIuPg6PPtJ8iytM3fPxN0My7 aYOg== X-Forwarded-Encrypted: i=1; AJvYcCXllu5eZ+2E83aMXKW8waW9KuE6IMd9JVK44/VUbbC37N7RlXKkh+icmAJDqRTov0CwA9FtJtS546yGBWP2X+egjfKUWLWFM3QP1f0gnykXFhFoZWA= X-Gm-Message-State: AOJu0Yx2H6G+iDS1jBOmob0u8ga67z2DPIkw237BI8V/P4CEW/fWiG8M sDAhN3cGfBnlHyzEAWEUilURzdZzUVL6/8bYbrjOHeAdAcjP5ClX X-Google-Smtp-Source: AGHT+IHA+WyWxnQ+pOSdLU4Imqh9orDNdwYCUlK6uxFXLm/wiayy7DJwE0Kc0gDTLDO3NPom4pMyow== X-Received: by 2002:a05:6512:1244:b0:512:bf7e:ca25 with SMTP id fb4-20020a056512124400b00512bf7eca25mr7610267lfb.20.1708625678696; Thu, 22 Feb 2024 10:14:38 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id o5-20020ac24c45000000b00512e50c09acsm1089lfk.48.2024.02.22.10.14.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 10:14:38 -0800 (PST) From: Serge Semin To: Michal Simek , Alexander Stein , Borislav Petkov , Tony Luck , James Morse , Mauro Carvalho Chehab , Robert Richter Cc: Serge Semin , Punnaiah Choudary Kalluri , Dinh Nguyen , Arnd Bergmann , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 10/20] EDAC/synopsys: Drop struct ecc_error_info.blknr field Date: Thu, 22 Feb 2024 21:12:55 +0300 Message-ID: <20240222181324.28242-11-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240222181324.28242-1-fancer.lancer@gmail.com> References: <20240222181324.28242-1-fancer.lancer@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240222_181543_857698_C44592C2 X-CRM114-Status: GOOD ( 12.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Even though the ECC(C|U)ADDR1 CSR description indeed says it's a "Block number" in the DW uMCTL2 DDRC IP-core databooks, the corresponding register field is named as ECC(C|U)ADDR1.ecc_(un)corr_col (which means ECC (un)corrected column) and in the rest of the document it's referred as the SDRAM address column. Thus use the already available ecc_error_info.col field to read the column number to and drop the questionable ecc_error_info.blknr field for good. Signed-off-by: Serge Semin --- drivers/edac/synopsys_edac.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/drivers/edac/synopsys_edac.c b/drivers/edac/synopsys_edac.c index 21b0d791cb8b..6ca119459bd3 100644 --- a/drivers/edac/synopsys_edac.c +++ b/drivers/edac/synopsys_edac.c @@ -173,7 +173,7 @@ #define ECC_CEADDR0_RNK_MASK BIT(24) #define ECC_CEADDR1_BNKGRP_MASK 0x3000000 #define ECC_CEADDR1_BNKNR_MASK 0x70000 -#define ECC_CEADDR1_BLKNR_MASK 0xFFF +#define ECC_CEADDR1_COL_MASK 0xFFF #define ECC_CEADDR1_BNKGRP_SHIFT 24 #define ECC_CEADDR1_BNKNR_SHIFT 16 @@ -271,7 +271,6 @@ * @bitpos: Bit position. * @data: Data causing the error. * @bankgrpnr: Bank group number. - * @blknr: Block number. */ struct ecc_error_info { u32 row; @@ -280,7 +279,6 @@ struct ecc_error_info { u32 bitpos; u32 data; u32 bankgrpnr; - u32 blknr; }; /** @@ -433,7 +431,7 @@ static int zynqmp_get_error_info(struct synps_edac_priv *priv) ECC_CEADDR1_BNKNR_SHIFT; p->ceinfo.bankgrpnr = (regval & ECC_CEADDR1_BNKGRP_MASK) >> ECC_CEADDR1_BNKGRP_SHIFT; - p->ceinfo.blknr = (regval & ECC_CEADDR1_BLKNR_MASK); + p->ceinfo.col = (regval & ECC_CEADDR1_COL_MASK); p->ceinfo.data = readl(base + ECC_CSYND0_OFST); edac_dbg(2, "ECCCSYN0: 0x%08X ECCCSYN1: 0x%08X ECCCSYN2: 0x%08X\n", readl(base + ECC_CSYND0_OFST), readl(base + ECC_CSYND1_OFST), @@ -449,7 +447,7 @@ static int zynqmp_get_error_info(struct synps_edac_priv *priv) ECC_CEADDR1_BNKGRP_SHIFT; p->ueinfo.bank = (regval & ECC_CEADDR1_BNKNR_MASK) >> ECC_CEADDR1_BNKNR_SHIFT; - p->ueinfo.blknr = (regval & ECC_CEADDR1_BLKNR_MASK); + p->ueinfo.col = (regval & ECC_CEADDR1_COL_MASK); p->ueinfo.data = readl(base + ECC_UESYND0_OFST); out: spin_lock_irqsave(&priv->reglock, flags); @@ -480,10 +478,9 @@ static void handle_error(struct mem_ctl_info *mci, struct synps_ecc_status *p) pinf = &p->ceinfo; if (priv->p_data->quirks & DDR_ECC_INTR_SUPPORT) { snprintf(priv->message, SYNPS_EDAC_MSG_SIZE, - "DDR ECC error type:%s Row %d Bank %d BankGroup Number %d Block Number %d Bit Position: %d Data: 0x%08x", - "CE", pinf->row, pinf->bank, - pinf->bankgrpnr, pinf->blknr, - pinf->bitpos, pinf->data); + "DDR ECC error type:%s Row %d Col %d Bank %d BankGroup Number %d Bit Position: %d Data: 0x%08x", + "CE", pinf->row, pinf->col, pinf->bank, + pinf->bankgrpnr, pinf->bitpos, pinf->data); } else { snprintf(priv->message, SYNPS_EDAC_MSG_SIZE, "DDR ECC error type:%s Row %d Bank %d Col %d Bit Position: %d Data: 0x%08x", @@ -500,9 +497,9 @@ static void handle_error(struct mem_ctl_info *mci, struct synps_ecc_status *p) pinf = &p->ueinfo; if (priv->p_data->quirks & DDR_ECC_INTR_SUPPORT) { snprintf(priv->message, SYNPS_EDAC_MSG_SIZE, - "DDR ECC error type :%s Row %d Bank %d BankGroup Number %d Block Number %d", - "UE", pinf->row, pinf->bank, - pinf->bankgrpnr, pinf->blknr); + "DDR ECC error type :%s Row %d Col %d Bank %d BankGroup Number %d", + "UE", pinf->row, pinf->col, pinf->bank, + pinf->bankgrpnr); } else { snprintf(priv->message, SYNPS_EDAC_MSG_SIZE, "DDR ECC error type :%s Row %d Bank %d Col %d ", From patchwork Thu Feb 22 18:12:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13567899 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A6BC2C48BF8 for ; Thu, 22 Feb 2024 18:22:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=msUUlDSXPo6za9zo6KK5rFO5y8WviifjHIsTXVs9Sdk=; b=NoNnqy2c1j6Mbh bOzg6Lo5nNUR0PV3ydN4Kzaelgy3D/EEzllN7eC70DTkI5bOYHiuWohVL1tpfFYCDH5KThWnhAMJD 1/5BKa8c6oobvqvyq4VWobnkOqhmpvSQpiWgyEQraZt3d5azD/i0xyrOgccRN3INx3LBPt+fCE33N W4ChNl9abOXwkUEfyCe5D9kVNagT1rek+geCPngvbWE0uga4Bk+JWXFh0bfSkdAIbxfKHCj5g/iF4 Kp5k3iO+HphadiODnUDo8dH489X1yJZMcffOxUn3d5bY8DJFYrGVZc0dqYKXrUfill7W4ZVrTe62F 3i8T3QdgxRfpU4btStrA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDhv-000000060hu-40Ig; Thu, 22 Feb 2024 18:22:07 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDbm-00000005xeV-1rJa for linux-arm-kernel@bombadil.infradead.org; Thu, 22 Feb 2024 18:16:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=pzoe6r6O1SQZpxBPwnEmbzP/LY9Wg9dUZAFh860tCdU=; b=bbkUGq/loyPvypBRHnkKfmg+b9 BTvG+hwPEbo4Ozo4p/qjj8kT/0y8IOz9mE8Bm1bS+fCefvowLNVXkxZ2vZMRMprAiY1nlsinZvQeE +Ffvle19JYYI5WJAHri/Ft3i2H6+XSbOiQ9o9FQ5dUzCexwStTZ41DE9zmm+NLAk3k3ncXq/quvRH snLte4gdSm7FNymmSXut+jyNUh4wK6q2B+SdAux68Le8xCRGTd2ShLDVyWBxxBp/MlDoO/Xwgzsnp riyCZOB+RV/5dDARl26jVN4Jg0ztqPc5pOtAcjsZVGvlNti/Tqzt9NjkqnSl3D6xIrmvIXVTxOULM hIOxppLw==; Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDbj-00000004Ilb-2LW3 for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 18:15:45 +0000 Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-512bce554a5so91895e87.3 for ; Thu, 22 Feb 2024 10:15:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708625680; x=1709230480; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pzoe6r6O1SQZpxBPwnEmbzP/LY9Wg9dUZAFh860tCdU=; b=ml0+lkxYStwt9XGzvSGKI07C90PVrP9G0CQTnCp7qR108mTcCJ6y8K+e9dMC2lx7Dk pf5XtiZAwwp/aTSGXx5kwg+Zzmm8PWoXbWoQttmd6v2Xp8H3EN2IPfv3AcRYSLlu1aMo VYYg3jis3GA9rtHmhvQBGN6CydE4/WLaZWxCkPWOX5lFwV3LCkE1yVRYb6rUf9tc3ETB ew2K1vxY10POEQdWda0H0xfZPmU81ytZ+SyjL9Ntj+D3IjGDnnW97XvnwBifG9wTY7qG 60rnlxRCM9184RUhHqShEJU7vQt0HGzvLN7Zs7+bmT3vyCciz84maMF2CN4+fwyNFLYe XNHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708625680; x=1709230480; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pzoe6r6O1SQZpxBPwnEmbzP/LY9Wg9dUZAFh860tCdU=; b=PmwXCqK6n0ATbXpO2kfEhL7tdjbEAUwy6kRRkcCnJc26Et0oJth4GxNCDCDey/sr6C bYgk5vjwVjDXVUCGLzy3NP+PFqcQRvynntoKeSdlRuNXv00XV/zjpLeO/U1kWkeqNcCo doX0jgCD5CCwyMGG/pewXBiJ2cmXpq0QxSU2MFQfMpjRB4DeKx8dvej8k2Yp5XBkQht/ CZILl77Ggzdfc5buIBe+tl+IyvbLEH/FdC0O81PGom7awl+xsqE3yTNf/BGBdMSZQUJ/ YnZ/HZBuz8ZqQ1yCJ8C/j9MA6i77xawKKAp+zW1sruPzpc9hTGG+Id6oxO//6Q/KX+9C 5KxA== X-Forwarded-Encrypted: i=1; AJvYcCXKW4df2mIYQRJMVj77/om0Y2lRciqHRsecyih9faa+LDnp46g/iNHGs67WqzJZobhdjBExxVUjEzPbO/WTSeN1HqP/ORHhLvql5ZGsqSECETTSCcQ= X-Gm-Message-State: AOJu0YzO3Be6F1BJsc83V2zH9sNcB9i6gblsR4oJf2XtyCi/9bBKhpbz x/Wh5nkv8LtM27VYa9xammyGlACsXDiyjigo805Wa4qkz8i+kh63 X-Google-Smtp-Source: AGHT+IGcYWp+ryzNnOE+1eySElC1nrZpk/ByoTpbeCgHQM0hU5MtdJZ4f5r0RBCPz3VjbsW6XtHv6A== X-Received: by 2002:a05:6512:1384:b0:512:cb9f:a25b with SMTP id fc4-20020a056512138400b00512cb9fa25bmr6050995lfb.28.1708625680264; Thu, 22 Feb 2024 10:14:40 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id y10-20020ac255aa000000b00512c531ffe4sm1081849lfg.180.2024.02.22.10.14.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 10:14:39 -0800 (PST) From: Serge Semin To: Michal Simek , Alexander Stein , Borislav Petkov , Tony Luck , James Morse , Mauro Carvalho Chehab , Robert Richter Cc: Serge Semin , Punnaiah Choudary Kalluri , Dinh Nguyen , Arnd Bergmann , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 11/20] EDAC/synopsys: Shorten out struct ecc_error_info.bankgrpnr field name Date: Thu, 22 Feb 2024 21:12:56 +0300 Message-ID: <20240222181324.28242-12-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240222181324.28242-1-fancer.lancer@gmail.com> References: <20240222181324.28242-1-fancer.lancer@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240222_181543_618212_099EC4B0 X-CRM114-Status: GOOD ( 12.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org None of the ecc_error_info structure fields have "nr" suffix even though each of them do represent some number (row number, column number, bank number). Drop the suffix from the bankgrpnr field name for the sake of unification then. Similarly drop the word "Number" from the CE/UE error messages too since it doesn't give any helpful info there. Signed-off-by: Serge Semin --- drivers/edac/synopsys_edac.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/edac/synopsys_edac.c b/drivers/edac/synopsys_edac.c index 6ca119459bd3..b0ff831287f5 100644 --- a/drivers/edac/synopsys_edac.c +++ b/drivers/edac/synopsys_edac.c @@ -268,17 +268,17 @@ * @row: Row number. * @col: Column number. * @bank: Bank number. + * @bankgrp: Bank group number. * @bitpos: Bit position. * @data: Data causing the error. - * @bankgrpnr: Bank group number. */ struct ecc_error_info { u32 row; u32 col; u32 bank; + u32 bankgrp; u32 bitpos; u32 data; - u32 bankgrpnr; }; /** @@ -429,7 +429,7 @@ static int zynqmp_get_error_info(struct synps_edac_priv *priv) regval = readl(base + ECC_CEADDR1_OFST); p->ceinfo.bank = (regval & ECC_CEADDR1_BNKNR_MASK) >> ECC_CEADDR1_BNKNR_SHIFT; - p->ceinfo.bankgrpnr = (regval & ECC_CEADDR1_BNKGRP_MASK) >> + p->ceinfo.bankgrp = (regval & ECC_CEADDR1_BNKGRP_MASK) >> ECC_CEADDR1_BNKGRP_SHIFT; p->ceinfo.col = (regval & ECC_CEADDR1_COL_MASK); p->ceinfo.data = readl(base + ECC_CSYND0_OFST); @@ -443,7 +443,7 @@ static int zynqmp_get_error_info(struct synps_edac_priv *priv) regval = readl(base + ECC_UEADDR0_OFST); p->ueinfo.row = (regval & ECC_CEADDR0_RW_MASK); regval = readl(base + ECC_UEADDR1_OFST); - p->ueinfo.bankgrpnr = (regval & ECC_CEADDR1_BNKGRP_MASK) >> + p->ueinfo.bankgrp = (regval & ECC_CEADDR1_BNKGRP_MASK) >> ECC_CEADDR1_BNKGRP_SHIFT; p->ueinfo.bank = (regval & ECC_CEADDR1_BNKNR_MASK) >> ECC_CEADDR1_BNKNR_SHIFT; @@ -478,9 +478,9 @@ static void handle_error(struct mem_ctl_info *mci, struct synps_ecc_status *p) pinf = &p->ceinfo; if (priv->p_data->quirks & DDR_ECC_INTR_SUPPORT) { snprintf(priv->message, SYNPS_EDAC_MSG_SIZE, - "DDR ECC error type:%s Row %d Col %d Bank %d BankGroup Number %d Bit Position: %d Data: 0x%08x", + "DDR ECC error type:%s Row %d Col %d Bank %d Bank Group %d Bit Position: %d Data: 0x%08x", "CE", pinf->row, pinf->col, pinf->bank, - pinf->bankgrpnr, pinf->bitpos, pinf->data); + pinf->bankgrp, pinf->bitpos, pinf->data); } else { snprintf(priv->message, SYNPS_EDAC_MSG_SIZE, "DDR ECC error type:%s Row %d Bank %d Col %d Bit Position: %d Data: 0x%08x", @@ -497,9 +497,9 @@ static void handle_error(struct mem_ctl_info *mci, struct synps_ecc_status *p) pinf = &p->ueinfo; if (priv->p_data->quirks & DDR_ECC_INTR_SUPPORT) { snprintf(priv->message, SYNPS_EDAC_MSG_SIZE, - "DDR ECC error type :%s Row %d Col %d Bank %d BankGroup Number %d", + "DDR ECC error type :%s Row %d Col %d Bank %d Bank Group %d", "UE", pinf->row, pinf->col, pinf->bank, - pinf->bankgrpnr); + pinf->bankgrp); } else { snprintf(priv->message, SYNPS_EDAC_MSG_SIZE, "DDR ECC error type :%s Row %d Bank %d Col %d ", From patchwork Thu Feb 22 18:12:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13567947 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7432AC48BF8 for ; Thu, 22 Feb 2024 18:40:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2SuKPTi6W2O8u+CCLrtaBK1XlWOk9pKId1dUghkWF4g=; b=x22IZ769MZmfs5 fZVog8Vskf3cX3726wFcLNTx1nxtkTOqDNfSliLE1wMTZ/xSB/z/I07l8Mwju5KBiCCpDboVcQhD5 YRqh6aB/y0X6rQN8qrFAWE/HuL5j1FMZMHQS+kkRsU5bT/4tWRdpHkBlvxFljSxK3x4tUb79cxXOx gfkhZ1OIApGbKVmTPGyWC5S2ZZdf1Kz0/RFfi/Rlm5vP5HuDKxN0Df5tcvXGCRfBSEHHUD3Ws05EN kEZscXhop1hXSNywAx/ci6mRVTnMyqULqtgu6EDeb9LIuaFGUTDQjGR3SxkDQ91QEEqFXv4f7q/fO ntaMaciBB6cybQPDAb4w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDzX-000000069QF-3adz; Thu, 22 Feb 2024 18:40:19 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDzE-0000000699O-218x for linux-arm-kernel@bombadil.infradead.org; Thu, 22 Feb 2024 18:40:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=Oj2Zk+yOX3iTlO1YnU+dJlP9WROVQ6dXGrz5dId9J7c=; b=nGeoCGBC4W9KBl8TkpfmFjewoS Z46MbEltUG5ksNQctob/0JV0oGVzU8/rFtZv/KYyuMOE0qBBxz1fguIArodP9FAtjyfEsvG+eGYWm +VGQiyO7ux/ogAg8F4Rb69n/j6q1orBMLVJGgVO7/XO37PcjwIYM0PojbswoFy7MwPeqoYe29TLKU BmrcyjaWYBplrfsaR9ViI7PJMoTZ/1kDAY2daRbeyIz6X4uihZiIxiOCKfl0pD0m+kcPrPrYZo93w qre7qidmnINNJf7668AJjbWalVfy1MuN9yxfIOjrv4bFRTLR2dT3ZAdeZknskrtHvjEM78PoTJGGn MwZd/RgQ==; Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDc5-00000004IxG-36AV for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 18:16:08 +0000 Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2d22b8801b9so1475031fa.0 for ; Thu, 22 Feb 2024 10:16:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708625703; x=1709230503; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Oj2Zk+yOX3iTlO1YnU+dJlP9WROVQ6dXGrz5dId9J7c=; b=BZDDMYvNcEW22HKLmX52t3Z50+Lzfjx/Z+Jwt60ny0jOUmy+5K3fu4eUs5fHvuzE1c Rjudq4gncMt0FE7gMK9NfNpfGIUlzUvlgYbWC5WHYG2vUbIw/+y90PIWI9+iw8vZU1M9 rUWZlq524UNUGS5mmyGPqzygvNREr6geO7t7DQr0VmhwYzF7q+XeRtfnF78/hOux6oOT xAWFlD162OnzLKVZZXUELyfXg70zwd/kV+citFJVPaLif4uVp1p0F69lgSprn07HdsbS 0kYom3CWIrMvCc+rCgkOxNA4pOydjvPJPIBDKPypr9G8qqnhuX7ChgGESNSrnZv6XTAa il1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708625703; x=1709230503; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Oj2Zk+yOX3iTlO1YnU+dJlP9WROVQ6dXGrz5dId9J7c=; b=AR5LQj0EF3yaj0SprI1Ypv1avcOdI9GULQRXDtz6Sb5+RQ+2aLqYMQlNhA25R6XtQl drJmdZGezKyWwHV/NC0ZrO5MnCm8NCsW78vdLBDAOsoEGo2jE++6K7THc6/mKZ1WKygr 3ErdDkFm2CLsREzAZfSlvg0+12LAzdo+dKjjuOb9axpclE3Gh+ZWRkNQCMU/AjQcnIUt k+DcFjzAEAEYX5Ll+O4tp2IikSOzR/Zyl6H5Cft42P5/VcCmhyWO7xXaRUelo58GxyhW qLcm0oxZHReUPwSIpSDhWyK6JZ3O7UktaXDfOQrUMV67JNhoQi9W3tcBYm6HvUkpuYSn P+KA== X-Forwarded-Encrypted: i=1; AJvYcCWR1ek1FLZOe8OoCwJ14JZxuL/nTRvOi6JHRRmU9/A4ELRQhIfbuM49khrzirFUB8mAH1fZeTY2DLSoOwe/am+DXwUI9hCpfeYcj8bcUhrPq0j2/aA= X-Gm-Message-State: AOJu0Ywq0utbco/cnjXio4B0A2DpeS7NoNMRVoOoy805VFHyGtD1udzF pHjUFW2tn20MG9l7AJ9nMm2GoBMfeZ9PEEO8N3aFFX3J+oEuikEnmDNBLoW4rh8= X-Google-Smtp-Source: AGHT+IFOFkHys1bH4WkLHPGQ3V9fUh1P0YVQPkq70kk/yd9g6H865FEq3BXbnYj7ckxtOrhkoU1gaQ== X-Received: by 2002:a05:6512:15a7:b0:512:a6cd:b37c with SMTP id bp39-20020a05651215a700b00512a6cdb37cmr11450521lfb.47.1708625681964; Thu, 22 Feb 2024 10:14:41 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id x7-20020ac25dc7000000b00512dbd9cf32sm348778lfq.54.2024.02.22.10.14.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 10:14:41 -0800 (PST) From: Serge Semin To: Michal Simek , Alexander Stein , Borislav Petkov , Tony Luck , James Morse , Mauro Carvalho Chehab , Robert Richter Cc: Serge Semin , Punnaiah Choudary Kalluri , Dinh Nguyen , Arnd Bergmann , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 12/20] EDAC/synopsys: Drop redundant info from the error messages Date: Thu, 22 Feb 2024 21:12:57 +0300 Message-ID: <20240222181324.28242-13-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240222181324.28242-1-fancer.lancer@gmail.com> References: <20240222181324.28242-1-fancer.lancer@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240222_181605_845817_F874EFB2 X-CRM114-Status: GOOD ( 12.77 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Currently the custom error messages are needlessly long so the logged text gets to be printed in several lines in console. There is some duplicated/redundant information which can be freely removed from it: drop the message prefix "DDR ECC error type:%s" since the resultant text printed to the log by the edac_mc_printk() method will contain the error type and the memory controller id referring to the device detected the error anyway; with no harm to readability shorten out the phrase "Bit Position" to being just "Bit". Signed-off-by: Serge Semin --- drivers/edac/synopsys_edac.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/edac/synopsys_edac.c b/drivers/edac/synopsys_edac.c index b0ff831287f5..dfe1abe7c86c 100644 --- a/drivers/edac/synopsys_edac.c +++ b/drivers/edac/synopsys_edac.c @@ -478,13 +478,13 @@ static void handle_error(struct mem_ctl_info *mci, struct synps_ecc_status *p) pinf = &p->ceinfo; if (priv->p_data->quirks & DDR_ECC_INTR_SUPPORT) { snprintf(priv->message, SYNPS_EDAC_MSG_SIZE, - "DDR ECC error type:%s Row %d Col %d Bank %d Bank Group %d Bit Position: %d Data: 0x%08x", - "CE", pinf->row, pinf->col, pinf->bank, - pinf->bankgrp, pinf->bitpos, pinf->data); + "Row %d Col %d Bank %d Bank Group %d Bit %d Data 0x%08x", + pinf->row, pinf->col, pinf->bank, pinf->bankgrp, + pinf->bitpos, pinf->data); } else { snprintf(priv->message, SYNPS_EDAC_MSG_SIZE, - "DDR ECC error type:%s Row %d Bank %d Col %d Bit Position: %d Data: 0x%08x", - "CE", pinf->row, pinf->bank, pinf->col, + "Row %d Bank %d Col %d Bit: %d Data: 0x%08x", + pinf->row, pinf->bank, pinf->col, pinf->bitpos, pinf->data); } @@ -497,13 +497,12 @@ static void handle_error(struct mem_ctl_info *mci, struct synps_ecc_status *p) pinf = &p->ueinfo; if (priv->p_data->quirks & DDR_ECC_INTR_SUPPORT) { snprintf(priv->message, SYNPS_EDAC_MSG_SIZE, - "DDR ECC error type :%s Row %d Col %d Bank %d Bank Group %d", - "UE", pinf->row, pinf->col, pinf->bank, - pinf->bankgrp); + "Row %d Col %d Bank %d Bank Group %d", + pinf->row, pinf->col, pinf->bank, pinf->bankgrp); } else { snprintf(priv->message, SYNPS_EDAC_MSG_SIZE, - "DDR ECC error type :%s Row %d Bank %d Col %d ", - "UE", pinf->row, pinf->bank, pinf->col); + "Row %d Bank %d Col %d", + pinf->row, pinf->bank, pinf->col); } edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, From patchwork Thu Feb 22 18:12:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13567873 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6AEECC54791 for ; Thu, 22 Feb 2024 18:21:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=r6Dq5KPC1nIYkIWQRnZavVtyJeFX5aW9OgQB04/EZZM=; b=IUErIdMSjdFDM9 0w+751dYfiKVq3Mt7MOVNabGGGlRS/OCf62L9fatgEnpohrB0YLV8Z0si/H3RePcaH9YgyHwuug8a BWnPG/81sI+rhHKgREHHKhBGTq0/6jKn0jLn4luLVzsvqHq+/LLkpGoj/W6MeMt5EgBRjrAuSmvgA WwvBz/Zux5dVV3GA9+8erbXU+p5GKUnggxK5FHDUUUdPnauPWDPGOk+Wdv+R1J5Nh5BVIZKrCNmGH r9tMgVYjFIYTUuDzrzDnNSKXqxKK9/RuC4O3O5XfBtKFnmZifaANJUWAP8UF9N0Tuu4AhshCVJSF9 8XrJUCrm2BJ2q4c+2MEA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDgd-0000000600j-2Pqz; Thu, 22 Feb 2024 18:20:47 +0000 Received: from mail-lj1-x234.google.com ([2a00:1450:4864:20::234]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDap-00000005x9t-416Q for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 18:14:59 +0000 Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2d208d0b282so1003731fa.0 for ; Thu, 22 Feb 2024 10:14:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708625684; x=1709230484; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+o0t5l+gbhBR5sr353Zx4OwnR+/NtUKsRVbiL7FnCuk=; b=f1rSLwnPGPRLZ8guN9SvY0oeLlNdJ+G5T4uaWdRND5Io1fAgqg3JSPk3RdX363bhye zQHhU3r2FHpiP5EcxcOxOwMtxDyVrKT35W4HpLj9nXMqJpG+FEjofbStPHuCBb/8Tvjy ttBNh/TRnksueAiZjL2NYCzJ1aSfi+POV6XfGtNJMWKD3PK8oZBoFgfOH/JPKJJKB72Y 0y4DXvoOaXUiNzFIFueDRhIr6bHoSBoAKgA9a5XtA3xR+VUP1ZmikIDDmlk4RNb81owT dxt/L4aCgj6n6QUMjATc9vQxgsTCaIaaDlJD95FIn08yJqt4IjaW5zFffgK8M/iNUahm /fXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708625684; x=1709230484; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+o0t5l+gbhBR5sr353Zx4OwnR+/NtUKsRVbiL7FnCuk=; b=ihge/sAaNKYhoR8E7JfxhSePZJR/55cSNm75FD6HF9taID9rZjvWDgsr3mBbW21WnY vMYTVO+cK8YbS3wFh3AuWQv7qtWvNApAO7F2LfSnaqd5AY2Xxpq/BILWZZ//7nmtsCtu Z88igpag6mwWaqB1LIxlNA3nd3CJ7uftUr6B10ruZKWyk9MVVuu9zI8yT/aMOHSO6Hzb 548FA/nqZNoviwP2F9iysFIrZNJ2GAOWCJu3VkmCrP+ywTKihJPD4vzlQCRdJ73iboX0 ME7MNl+0936KWAP4XrFxyOyE+4veXw01+X9MCjpF6g0LBIlDL8WVqNBPOctU+jVtIeWK TbGQ== X-Forwarded-Encrypted: i=1; AJvYcCVz4xfaGCTI3qK2qb6/y49xogURqh7DpfXtMqY8vSFtALLL42j56Vs0v5xyaCjiQvhmiJXFbE37lQM8ZXdItpu+0aJvXxJqQGH40O4gmFjCKiNr+50= X-Gm-Message-State: AOJu0YzZhHYmi41w+lAn5/Gqv+IByNPB8n9uaez8dQMKLMHw9AJxmKy7 DWZj1bMYd4mFM3B/IN6oaWEKJWV7DEqG95ctFsmzO2WxhVv/kcbDOSaHQoKzXvQ= X-Google-Smtp-Source: AGHT+IHujCBUf3uP+SOmn6mxJZA8UNgrf2Op4NXH3LML5XVClyL6ZZ2opxWdtVcY7NGtBDIbf+PxtA== X-Received: by 2002:a2e:8256:0:b0:2d2:5169:27f3 with SMTP id j22-20020a2e8256000000b002d2516927f3mr4079549ljh.34.1708625683925; Thu, 22 Feb 2024 10:14:43 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id a16-20020a05651c211000b002d26782e8d9sm65176ljq.55.2024.02.22.10.14.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 10:14:43 -0800 (PST) From: Serge Semin To: Michal Simek , Alexander Stein , Borislav Petkov , Tony Luck , James Morse , Mauro Carvalho Chehab , Robert Richter Cc: Serge Semin , Punnaiah Choudary Kalluri , Dinh Nguyen , Arnd Bergmann , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 13/20] EDAC/mc: Init DIMM labels in MC registration method Date: Thu, 22 Feb 2024 21:12:58 +0300 Message-ID: <20240222181324.28242-14-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240222181324.28242-1-fancer.lancer@gmail.com> References: <20240222181324.28242-1-fancer.lancer@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240222_101450_518900_8384E5C6 X-CRM114-Status: GOOD ( 16.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Move the DIMM labels initialization to the memory controller registration method as a preparation before adding the generic procedure to allocate an unique MC index. It's required because the DIMM labels contain the MC index as the "mc%u" part of the string, which in case of the auto-generated index isn't available at the moment of the MCI/csrow/dimms descriptor allocation. Signed-off-by: Serge Semin --- drivers/edac/edac_mc.c | 48 +++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c index d6eed727b0cd..c0b36349999f 100644 --- a/drivers/edac/edac_mc.c +++ b/drivers/edac/edac_mc.c @@ -257,7 +257,6 @@ static int edac_mc_alloc_dimms(struct mem_ctl_info *mci) unsigned int pos[EDAC_MAX_LAYERS]; unsigned int row, chn, idx; int layer; - void *p; /* * Allocate and fill the dimm structs @@ -272,7 +271,6 @@ static int edac_mc_alloc_dimms(struct mem_ctl_info *mci) for (idx = 0; idx < mci->tot_dimms; idx++) { struct dimm_info *dimm; struct rank_info *chan; - int n, len; chan = mci->csrows[row]->channels[chn]; @@ -283,22 +281,9 @@ static int edac_mc_alloc_dimms(struct mem_ctl_info *mci) dimm->mci = mci; dimm->idx = idx; - /* - * Copy DIMM location and initialize it. - */ - len = sizeof(dimm->label); - p = dimm->label; - n = scnprintf(p, len, "mc#%u", mci->mc_idx); - p += n; - len -= n; - for (layer = 0; layer < mci->n_layers; layer++) { - n = scnprintf(p, len, "%s#%u", - edac_layer_name[mci->layers[layer].type], - pos[layer]); - p += n; - len -= n; + /* Copy DIMM location */ + for (layer = 0; layer < mci->n_layers; layer++) dimm->location[layer] = pos[layer]; - } /* Link it to the csrows old API data */ chan->dimm = dimm; @@ -511,6 +496,33 @@ void edac_mc_reset_delay_period(unsigned long value) +/** + * edac_mc_init_labels() - Initialize DIMM labels + * + * @mci: pointer to the mci structure which DIMM labels need to be initialized + * + * .. note:: + * locking model: must be called with the mem_ctls_mutex lock held + */ +static void edac_mc_init_labels(struct mem_ctl_info *mci) +{ + int n, len, layer; + unsigned int idx; + char *p; + + for (idx = 0; idx < mci->tot_dimms; idx++) { + len = sizeof(mci->dimms[idx]->label); + p = mci->dimms[idx]->label; + + n = scnprintf(p, len, "mc#%u", mci->mc_idx); + for (layer = 0; layer < mci->n_layers; layer++) { + n += scnprintf(p + n, len - n, "%s#%u", + edac_layer_name[mci->layers[layer].type], + mci->dimms[idx]->location[layer]); + } + } +} + /* Return 0 on success, 1 on failure. * Before calling this function, caller must * assign a unique value to mci->mc_idx. @@ -638,6 +650,8 @@ int edac_mc_add_mc_with_groups(struct mem_ctl_info *mci, goto fail0; } + edac_mc_init_labels(mci); + if (add_mc_to_global_list(mci)) goto fail0; From patchwork Thu Feb 22 18:12:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13567907 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 23588C5478C for ; Thu, 22 Feb 2024 18:22:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KJe78g5E3N00LEMLn797nTCVysxZviiEdbGtR9UM4vk=; b=S14tYK/ErZ5ktR WDNXsaWhfLi9h5dahZXYH2VHimXVM3la/Vuh0Eg3dOPc3xTm/njSBc/tlu5y6JiXBNT7fLxfVLPNr sHK2DH6WeYPE/Li3q59I56dw6w498K/YPzliQdg1SDwmJ55SugV52jk+YPWHD4VBZf0Rjw9LFyLyF cCEX7QvQxzuOvPPosryr/AQu6KV7DtLNdcbfWUDpnB1R9LsxoRFvsv1uYYNA+aGhhJaYNYWgfENHW 0QC71UcAoxRlpJribsjcyhThiQC9hRh/Rka5fJL0WuWSrPO9yn30yZD8SKut5LU7SHLbQlFjs6M5x we623vrnz+1G8QsmatBQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDi9-000000060sl-2VMZ; Thu, 22 Feb 2024 18:22:21 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDbs-00000005xfY-3imo for linux-arm-kernel@bombadil.infradead.org; Thu, 22 Feb 2024 18:16:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=fLzBjMC1HQrpBSrNG7IsBicFltQpQsnlTrfLyFywK/U=; b=HigsxFdLn67BUXNtPssdHOJ1XV RhPRtOT3XyNpQcaJYqUR5IfNB7mbw4ovpLlqx2hvTHQrvsmdaWVa6vl3iuYMC9jxcjlicUCh1+NnO 5xdmixdgp+GSpOOc9Ni/Q29KcNDlfnYMEa0cYhp1wlI1beRG3/Iz7VsvLvJbGZgQ1bDQZDmegMY2p J37iZLKgSOg+59p/dnyuNnLDyUBZ/ZKzoyANBYlGSSEmZp8ugup4r+316ZOqa79QdNcFVSATia4sd DyYpn9b3xjUNbXiZGU+o3QdUFXkm9ytasj1i49b73EQswUaVjljTNPoYXGCiQrga3LTuwlRgub9Mf 09RA31Qg==; Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDbp-00000004IoS-3T6d for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 18:15:51 +0000 Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2d2628e81b8so7694711fa.0 for ; Thu, 22 Feb 2024 10:15:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708625686; x=1709230486; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fLzBjMC1HQrpBSrNG7IsBicFltQpQsnlTrfLyFywK/U=; b=nB2wYnOBXNCYH2gA0nCn1FYbvw9cDHARlTB4zbmStpFbimcuVCGBf811xvyOCZrMpo eb4Rj5OUBF6Lbgfh8ye8NT/6MfQQMBZOqBfYu9yuNcdrcv0WAoRaJ4mPAXWIMPKNXWGt npW9xk/VOs9PHMZCgrqP3evVmnXgXSaC1jRXcChmR2JAB1rmd1fiX/hc8YAwfTbTsQ+w j5+NE2fdXtzx9VSN6vBJMxuimxjr11c0EkTLQP+zAQ8DNY+iTynkzwfu3xjBbTlqAqZ/ SsxWbWotSJpwK0LTH8uxplQUo8+F34u0r+y4qghgI/MI87vXuzLnNmuZaihfo1PBCO+b Yrew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708625686; x=1709230486; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fLzBjMC1HQrpBSrNG7IsBicFltQpQsnlTrfLyFywK/U=; b=G59VFarzF3ICo85QmaWnp4/abF1pQHkJnQjb9RMgWZGrBtH5nSkpN8vc43Dk5fc5oG q1UTwXcCZpCCdr6sxeAX2e4WAQ3HRfDKVvgGh6WmhD6TaqzfKXRPjKNqMmLtfDwJ26P2 /13wbukXD1S31N828+/m1Q7sHMjBrw5+GT7sZgzRS2u67CVC/XNT/v8cEGUCgkJOz2kB lDYhfY8GXSguYEFkG7Ee1T9MkggC+jJqKRIaF6rvKzqQeJIS4qyjsKdBWCR7pFSnPaVE La1la7kLKZXTumoQYmEcp9hVmXGduZnELT9qfWE0zEgiPjOlG7mXYoSsMxmuEzh98ToF uyRA== X-Forwarded-Encrypted: i=1; AJvYcCVBSNrqg9097V3cfINX/1EuV6lIFVbzNY8j2m8jn53PoBeq1JAI3VS6Bt+9cjXzNJE9So1aX7NAPXQzBKB1pr3+DRONMK3j/ePtLSu22caL2ipmSUE= X-Gm-Message-State: AOJu0YwGw6l3/8nbaRNVJkgD8WW5Sv5Zh0YfgXCcB5rHIBa/HmUi9awj oI0z9fUcw675wM4PCVfDSZ5KSfkWudhl+VceZYmPL0avUm4xZ0nm X-Google-Smtp-Source: AGHT+IGVGG7JHCiusAb9XSxJwziVVLr/Gx8dPNPsWyTUDy9bkr+juJL1rqqgPwYEfdccnfH+Cn2TRA== X-Received: by 2002:a19:654b:0:b0:511:a0db:5062 with SMTP id c11-20020a19654b000000b00511a0db5062mr1107289lfj.17.1708625685752; Thu, 22 Feb 2024 10:14:45 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id z7-20020a19f707000000b00512e1f810cesm141154lfe.47.2024.02.22.10.14.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 10:14:45 -0800 (PST) From: Serge Semin To: Michal Simek , Alexander Stein , Borislav Petkov , Tony Luck , James Morse , Mauro Carvalho Chehab , Robert Richter Cc: Serge Semin , Punnaiah Choudary Kalluri , Dinh Nguyen , Arnd Bergmann , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 14/20] EDAC/mc: Add generic unique MC index allocation procedure Date: Thu, 22 Feb 2024 21:12:59 +0300 Message-ID: <20240222181324.28242-15-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240222181324.28242-1-fancer.lancer@gmail.com> References: <20240222181324.28242-1-fancer.lancer@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240222_181549_914222_1A6AF28F X-CRM114-Status: GOOD ( 26.25 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Currently the EDAC subsystem relies on the low-level device drivers to select an unique index for each memory controller available in the system. Here are the already implemented approaches: 1. Fixed zero id. The vast majority of the drivers expect to have a single memory controller in the system. 2. Calculate based on a platform-specific way (Pre-defined devices order, PCIe-bus address, Numa node ID + PCIe-function number, etc). 3. Use platform_device->id. 4. Use custom ACPI/OF property value. 5. Use locally maintained static MC counter. Create a generic method of the MC index allocation which could be utilized for the case 5 (it doesn't imply any strict memory controller order) and which would prevent the new MC EDAC drivers re-implementing the approaches 3 and 4. Moreover it will be useful for the cases when a platform is equipped with memory-controllers of different types [1] and which are probed by different drivers [2]. [1] Link: https://lore.kernel.org/all/9dc2a947-d2ab-4f00-8ed3-d2499cb6fdfd@BN1BFFO11FD002.protection.gbl/ [2] Link: https://lore.kernel.org/linux-edac/BY5PR12MB4258CB67B70D71F107EC1E9DDB3E9@BY5PR12MB4258.namprd12.prod.outlook.com The suggested implementation is based on the IDA kernel API and implies the next semantics: 1. If a particular MC index is specified it will be registered in the IDR pool unless the specified ID has already been reserved. 2. If a special MC index is specified (EDAC_AUTO_MC_NUM) the EDAC core will check whether there is a "mcID" alias is defined in the device tree and use the ID from there if it's found. 3. Otherwise a next free index will be allocated and assigned to the registered memory controller. Signed-off-by: Serge Semin --- Note the approach implemented here has been partly ported from the SPI core driver using IDA to track/allocate SPI bus numbers. Link: https://elixir.bootlin.com/linux/latest/source/drivers/spi/spi.c#L2957 --- drivers/edac/edac_mc.c | 89 +++++++++++++++++++++++++++++++++++++++--- drivers/edac/edac_mc.h | 4 ++ 2 files changed, 87 insertions(+), 6 deletions(-) diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c index c0b36349999f..2144e0615679 100644 --- a/drivers/edac/edac_mc.c +++ b/drivers/edac/edac_mc.c @@ -29,6 +29,9 @@ #include #include #include +#include +#include + #include #include "edac_mc.h" #include "edac_module.h" @@ -46,6 +49,7 @@ EXPORT_SYMBOL_GPL(edac_op_state); /* lock to memory controller's control array */ static DEFINE_MUTEX(mem_ctls_mutex); static LIST_HEAD(mc_devices); +static DEFINE_IDR(mc_idr); /* * Used to lock EDAC MC to just one module, avoiding two drivers e. g. @@ -494,7 +498,64 @@ void edac_mc_reset_delay_period(unsigned long value) mutex_unlock(&mem_ctls_mutex); } +/** + * edac_mc_alloc_id() - Allocate unique Memory Controller identifier + * + * @mci: pointer to the mci structure to allocate ID for + * + * Use edac_mc_free_id() to coherently free the MC identifier. + * + * .. note:: + * locking model: must be called with the mem_ctls_mutex lock held + * + * Returns: + * 0 on Success, or an error code on failure + */ +static int edac_mc_alloc_id(struct mem_ctl_info *mci) +{ + struct device_node *np = dev_of_node(mci->pdev); + int ret, min, max; + + if (mci->mc_idx == EDAC_AUTO_MC_NUM) { + ret = of_alias_get_id(np, "mc"); + if (ret >= 0) { + min = ret; + max = ret + 1; + } else { + min = of_alias_get_highest_id("mc"); + if (min >= 0) + min++; + else + min = 0; + + max = 0; + } + } else { + min = mci->mc_idx; + max = mci->mc_idx + 1; + } + + ret = idr_alloc(&mc_idr, mci, min, max, GFP_KERNEL); + if (ret < 0) + return ret == -ENOSPC ? -EBUSY : ret; + + mci->mc_idx = ret; + + return 0; +} +/** + * edac_mc_free_id() - Free Memory Controller identifier + * + * @mci: pointer to the mci structure to free ID from + * + * .. note:: + * locking model: must be called with the mem_ctls_mutex lock held + */ +static void edac_mc_free_id(struct mem_ctl_info *mci) +{ + idr_remove(&mc_idr, mci->mc_idx); +} /** * edac_mc_init_labels() - Initialize DIMM labels @@ -613,7 +674,8 @@ EXPORT_SYMBOL_GPL(edac_get_owner); int edac_mc_add_mc_with_groups(struct mem_ctl_info *mci, const struct attribute_group **groups) { - int ret = -EINVAL; + int ret; + edac_dbg(0, "\n"); #ifdef CONFIG_EDAC_DEBUG @@ -650,20 +712,30 @@ int edac_mc_add_mc_with_groups(struct mem_ctl_info *mci, goto fail0; } + ret = edac_mc_alloc_id(mci); + if (ret) { + edac_printk(KERN_ERR, EDAC_MC, "failed to allocate MC idx %u\n", + mci->mc_idx); + goto fail0; + } + edac_mc_init_labels(mci); - if (add_mc_to_global_list(mci)) - goto fail0; + if (add_mc_to_global_list(mci)) { + ret = -EINVAL; + goto fail1; + } /* set load time so that error rate can be tracked */ mci->start_time = jiffies; mci->bus = edac_get_sysfs_subsys(); - if (edac_create_sysfs_mci_device(mci, groups)) { + ret = edac_create_sysfs_mci_device(mci, groups); + if (ret) { edac_mc_printk(mci, KERN_WARNING, "failed to create sysfs device\n"); - goto fail1; + goto fail2; } if (mci->edac_check) { @@ -687,9 +759,12 @@ int edac_mc_add_mc_with_groups(struct mem_ctl_info *mci, mutex_unlock(&mem_ctls_mutex); return 0; -fail1: +fail2: del_mc_from_global_list(mci); +fail1: + edac_mc_free_id(mci); + fail0: mutex_unlock(&mem_ctls_mutex); return ret; @@ -717,6 +792,8 @@ struct mem_ctl_info *edac_mc_del_mc(struct device *dev) if (del_mc_from_global_list(mci)) edac_mc_owner = NULL; + edac_mc_free_id(mci); + mutex_unlock(&mem_ctls_mutex); if (mci->edac_check) diff --git a/drivers/edac/edac_mc.h b/drivers/edac/edac_mc.h index 881b00eadf7a..4b6676235b1b 100644 --- a/drivers/edac/edac_mc.h +++ b/drivers/edac/edac_mc.h @@ -23,6 +23,7 @@ #define _EDAC_MC_H_ #include +#include #include #include #include @@ -37,6 +38,9 @@ #include #include +/* Generate MC identifier automatically */ +#define EDAC_AUTO_MC_NUM UINT_MAX + #if PAGE_SHIFT < 20 #define PAGES_TO_MiB(pages) ((pages) >> (20 - PAGE_SHIFT)) #define MiB_TO_PAGES(mb) ((mb) << (20 - PAGE_SHIFT)) From patchwork Thu Feb 22 18:13:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13567860 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 26B13C48BF8 for ; Thu, 22 Feb 2024 18:18:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Ywn4c1jAL8Pp1EkIADDYj3y0stXSvyp2NGmSy5lKzzk=; b=lCGCImXantYoV7 4iGeA2r4CYwRlEHB89lwA281bLKWQ/x2fG/UJf1HPrv6uukSPk7l5aLbyICv5nmKQ0E4HZUElYNjb xd+kcpUxVI8yFk4k0cyVk4LTI+pdJDtN/vmeiGFvLnBMeJYMWhnPN7cxkP4pCicMAt0kS4bLIAt2l 8iG3FYmXnRPCuKpa2CAb28TUq9YaI8mVj4paqrZTIgMg2iueO9JAQi3sWHFNBbBF70Q1a3kOQD8cC zXpr7+hgqLh5OYNrtmVGyJGFFZ6NIfKDH85BAAUomGXfIFvfI95WAUxWafkdEB9tpELcEpyEoSPM2 xto2fSd859i5sLex/dMw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDdp-00000005yI7-1Fym; Thu, 22 Feb 2024 18:17:53 +0000 Received: from mail-lj1-x234.google.com ([2a00:1450:4864:20::234]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDaz-00000005xBU-3ebr for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 18:15:04 +0000 Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2d0cdbd67f0so844081fa.3 for ; Thu, 22 Feb 2024 10:14:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708625688; x=1709230488; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0nAXuUIOjmGqCty40Smyp4CQdr7UcxvXuJwOvkK+QNc=; b=LjW9v/RRRWwEEq9RB1cw3yZbNSboXMwFd2HavFxKELTKNkQUwlVq8f2Jk2bCNoMwCy F7z/qHN3p8HUS59+yDmgBQn1yUt5m6j7ansUsQyZJvl5DA2CWnEqBc8R7TRfgy2dXzX5 2xH9838sVvOQ/4eZ81BdSGQi8od2Dh2Nbz8ifvVf8TmdaIUarwrVRBqlRjBMJT7pT8Ow 0GHWp1Q5EM8S5ST+j+8z/BzwH45xxJMjfYL/rtOojf22I7e04QlD8hhQvf2Uidi2WmYc CpfVKJEe+PTdv/sqHb4aY1PRqoZDVkWHks1HaDewpH3h101Q9a53rokfKSbwoqo1WLQY ZhyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708625688; x=1709230488; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0nAXuUIOjmGqCty40Smyp4CQdr7UcxvXuJwOvkK+QNc=; b=fqV9YF6KI17XvvYSuF9PDuwATLze/I9p5voGjr8P1haHimQGh13L0JlaGzcG0QQngr KG0cB28vIlvmVGHlUn8XrdPNaMYKUZLLSt7CaZQKLFjznANVnWnGAu5EVQb1l2d+om/p kaN/C8ae4O85RM6Z4JDvDjXoExbDlsB4TZbZCwvqI0chaEBSWryhOWw8FL/8wGLUTwAa Ls5CgMB2BjTp9WL0KlSXO7AVxSe30FPC1p7M5vwj29CKFuaeHem3IDd3ZCRHofAEfyk4 QyEXcKx/sKad7s/In34YgMjKkXg8K52zikCydYFvq8jHQiQrWD8Wa1ef/MpOqoLmEicL hMkQ== X-Forwarded-Encrypted: i=1; AJvYcCXEDy+Tda++5ueMS4H0rqZ+cU1C3vbCFial1c6nKZVcGRc9I1HP7rrh2Aq/+J9pOoq8c4Iv/+qrfP8mBOR5hHDqiQKneSdTI5zxGo7WOnG9tcqwsPc= X-Gm-Message-State: AOJu0YwbxLbDeJ6xLTjddlS1bM/52PT0Aruqq6Y4qKYvBod/IoMiTQbG 3TDZrgCiQvrPN65xojNsgwYLyKdBXxwt3+h3D/xUcqEACm/24yMq X-Google-Smtp-Source: AGHT+IHuWrnLpg4juM7jhgCVO9zVn6Qc74sw3WuVEmtL6YWr4BWGK20vM8RFfEGoQoVZiRd12s1KiA== X-Received: by 2002:a2e:a272:0:b0:2d2:4388:63fc with SMTP id k18-20020a2ea272000000b002d2438863fcmr6085862ljm.44.1708625687765; Thu, 22 Feb 2024 10:14:47 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id bd7-20020a05651c168700b002d24c720b16sm969025ljb.101.2024.02.22.10.14.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 10:14:47 -0800 (PST) From: Serge Semin To: Michal Simek , Alexander Stein , Borislav Petkov , Tony Luck , James Morse , Mauro Carvalho Chehab , Robert Richter , Lei Wang , Egor Martovetsky , Michael Ellerman , Nicholas Piggin , Christophe Leroy , "Aneesh Kumar K.V" , "Naveen N. Rao" Cc: Serge Semin , Punnaiah Choudary Kalluri , Dinh Nguyen , Arnd Bergmann , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH v5 15/20] EDAC/mc: Re-use generic unique MC index allocation procedure Date: Thu, 22 Feb 2024 21:13:00 +0300 Message-ID: <20240222181324.28242-16-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240222181324.28242-1-fancer.lancer@gmail.com> References: <20240222181324.28242-1-fancer.lancer@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240222_101458_414654_3C16E798 X-CRM114-Status: GOOD ( 16.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The EDAC drivers locally maintaining a statically defined memory-controllers counter don't care much about the MC index assigned as long as it's unique so the EDAC core perceives it. Convert these drivers to be using the generic MC index allocation procedure recently added to the EDAC core. Signed-off-by: Serge Semin --- Changelog v4: - Initial patch introduction. --- drivers/edac/dmc520_edac.c | 4 +--- drivers/edac/pasemi_edac.c | 5 +---- drivers/edac/ppc4xx_edac.c | 5 +---- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/edac/dmc520_edac.c b/drivers/edac/dmc520_edac.c index 4e30b989a1a4..93734a97a67b 100644 --- a/drivers/edac/dmc520_edac.c +++ b/drivers/edac/dmc520_edac.c @@ -173,8 +173,6 @@ struct dmc520_edac { int masks[NUMBER_OF_IRQS]; }; -static int dmc520_mc_idx; - static u32 dmc520_read_reg(struct dmc520_edac *pvt, u32 offset) { return readl(pvt->reg_base + offset); @@ -517,7 +515,7 @@ static int dmc520_edac_probe(struct platform_device *pdev) layers[0].size = dmc520_get_rank_count(reg_base); layers[0].is_virt_csrow = true; - mci = edac_mc_alloc(dmc520_mc_idx++, ARRAY_SIZE(layers), layers, sizeof(*pvt)); + mci = edac_mc_alloc(EDAC_AUTO_MC_NUM, ARRAY_SIZE(layers), layers, sizeof(*pvt)); if (!mci) { edac_printk(KERN_ERR, EDAC_MOD_NAME, "Failed to allocate memory for mc instance\n"); diff --git a/drivers/edac/pasemi_edac.c b/drivers/edac/pasemi_edac.c index 1a1c3296ccc8..afebfbda1ea0 100644 --- a/drivers/edac/pasemi_edac.c +++ b/drivers/edac/pasemi_edac.c @@ -57,8 +57,6 @@ #define PASEMI_EDAC_ERROR_GRAIN 64 static int last_page_in_mmc; -static int system_mmc_id; - static u32 pasemi_edac_get_error_info(struct mem_ctl_info *mci) { @@ -203,8 +201,7 @@ static int pasemi_edac_probe(struct pci_dev *pdev, layers[1].type = EDAC_MC_LAYER_CHANNEL; layers[1].size = PASEMI_EDAC_NR_CHANS; layers[1].is_virt_csrow = false; - mci = edac_mc_alloc(system_mmc_id++, ARRAY_SIZE(layers), layers, - 0); + mci = edac_mc_alloc(EDAC_AUTO_MC_NUM, ARRAY_SIZE(layers), layers, 0); if (mci == NULL) return -ENOMEM; diff --git a/drivers/edac/ppc4xx_edac.c b/drivers/edac/ppc4xx_edac.c index 1eea3341a916..06d267d40a6a 100644 --- a/drivers/edac/ppc4xx_edac.c +++ b/drivers/edac/ppc4xx_edac.c @@ -1214,7 +1214,6 @@ static int ppc4xx_edac_probe(struct platform_device *op) const struct device_node *np = op->dev.of_node; struct mem_ctl_info *mci = NULL; struct edac_mc_layer layers[2]; - static int ppc4xx_edac_instance; /* * At this point, we only support the controller realized on @@ -1265,7 +1264,7 @@ static int ppc4xx_edac_probe(struct platform_device *op) layers[1].type = EDAC_MC_LAYER_CHANNEL; layers[1].size = ppc4xx_edac_nr_chans; layers[1].is_virt_csrow = false; - mci = edac_mc_alloc(ppc4xx_edac_instance, ARRAY_SIZE(layers), layers, + mci = edac_mc_alloc(EDAC_AUTO_MC_NUM, ARRAY_SIZE(layers), layers, sizeof(struct ppc4xx_edac_pdata)); if (mci == NULL) { ppc4xx_edac_printk(KERN_ERR, "%pOF: " @@ -1303,8 +1302,6 @@ static int ppc4xx_edac_probe(struct platform_device *op) goto fail1; } - ppc4xx_edac_instance++; - return 0; fail1: From patchwork Thu Feb 22 18:13:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13567908 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C6B74C48BF8 for ; Thu, 22 Feb 2024 18:22:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=058E9IQpK/Fq/SShOwDY/S64zs6EjipBvHN4dez1BHI=; b=r91x9NKqDuyj1q 6r9o68SWvE9fGDCKaB4cgOfdHaT0yuSjW9VcAehXiN0cmouUgLv0tAElIasbXLxVxMGwDk9vsYxhs 5GHX7P8FquhxqIxJqG6MQWv8XniuyDB9FSnvaEhidC6ySr5WTwXLopsPbYGcPUgKHRxNYKjvznK1i zcpIgo6RL6ig3Llv+KkQdH6IH1DNixrICCqyPOi9D/FGAgxFSmeORKbZhZCNV3Q1uVcEkfMEGB+HA uH9A/FChIhrTuFeGe+sF9fS2xVBWsMlK2/jvof8e4f+Q34yY2tCZpVGeutR/oDnRBVk/ohQgXR502 2/8vl7Y1oNIWzD2VgKcw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDi4-000000060oT-2ABx; Thu, 22 Feb 2024 18:22:16 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDbw-00000005xfv-3Tjb for linux-arm-kernel@bombadil.infradead.org; Thu, 22 Feb 2024 18:16:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=zdDgER3I/FBUh4v2IZo5kVqc0y5a5FgLioTBOyGmBsw=; b=cZv+v79MAAh7+FayAYfBf9s+kS x/4GORbBvkB0IBcLrPCtOjKDQHSPDPeDvLra6p0+RecWN+N+w4Xb/Jtrj75LReUwj4jh6B4Qq8UOd nCeZN4zlNBPOiDuudMMID/u0czd3DLcYHyt4Nqaj8gvgNI3rYkQ5m5jPh2XZh5Gw69nZPclfKsKXs LRBuPzW9hfraBZv8Ac7abDqF9eMkZAS4m/SJ12wNOab/JnYNruNN7XbZE1/IqeFZsky30waMKx8qP ZOawEuqjpUSCBi0vHoP/ktQbQvFM5oz+lwEdIvSDI4w/EbejbDfp2davqWYJuFmyh0h5xoaQofcbM ynZkXLRg==; Received: from mail-lj1-x235.google.com ([2a00:1450:4864:20::235]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDbs-00000004Iqc-3qIu for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 18:15:55 +0000 Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2d21cdbc85bso1185121fa.2 for ; Thu, 22 Feb 2024 10:15:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708625690; x=1709230490; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zdDgER3I/FBUh4v2IZo5kVqc0y5a5FgLioTBOyGmBsw=; b=laBNWkmvxVYDfHadK5uv1DMd0PsEmf1ss/TNHIvD/BqD9HB/9kiX956Vvvw7lDpbTa 1SO66729M3ZQEAe9GzbM+8L9iTwQQx5CDjEu1mzofAUkFpq1KSXgWAjECq/pq4RYyyIF /a9FnyskBiaBI9nmXrM2zFp4Gm0vrJJovwYtVJSSjLWIZZ3MrY1T1fgFRYP/9SAbnsa1 BTSnYSF0W4xMHNx/AfUtzRwtVPUsW3l3iay5GX6Sg81xJQdGSOmZaCXGXlp8iB7/nApE TbuKuQ0uMlZz6XCUHZgklWsL7GKcQpf+ZgDvXPqVFs7AHfaMyLYv6EyEKolWQTc2srMm vOAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708625690; x=1709230490; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zdDgER3I/FBUh4v2IZo5kVqc0y5a5FgLioTBOyGmBsw=; b=xUp5J6DXov38Lt/MJ0Bz6M3fwkJuvLy0nwTASkhKMAsYDlSwdRaijPYvfi4qHboOtM sqmnW8pzGspYEKYAInaaU1wK8t9pucQCEZp0Qru0yLkhMG3ciQWtPAhHyY7Zkwe2roDc xUVV9ksJNRRFY2mcsv1sOuGI1z10p2IgH4cGDrdX2HT/doKS1AtdlSiDwjnjlZiSjQ/2 RNSsmNC9Kk4TvRnr8rBBc2N3HELz58H7bExZEbTLTvynWM09abWgQ9QjXHRt5a3uynEN djq/5nFJ9ZNt3waeiLwb66gMESv7m9kNFpAGiweyCfvh0NRGi0HEl3qd8tMJlbmG+TNz lblw== X-Forwarded-Encrypted: i=1; AJvYcCVi82jxjy5Q7ApDAjaxwQq97kJldvg3ieLnqYDkqoSvJIvcSEObLyEqL528LtGpZjI+s+KY+WBe62nVz9LUafvHnQLkOGQAy4780lgzAfn65nrTyxI= X-Gm-Message-State: AOJu0YwTlKKGjtneayd/p4iR55et1ZbIBjukVo++rt1dCX9sfqbsZCgO IEErHBBNvSCWOsa4nhRTEQTjLGHn3sU3dpEaj+7kAdx/NG/BQQvo X-Google-Smtp-Source: AGHT+IGsX/zIDEFsJKLLkyNvQrmhZsnlQAJbqwhUiiFzPWDqhIC+rib/r/pPcRtu7WVXI9Uoz5vKBA== X-Received: by 2002:ac2:5e6f:0:b0:512:b297:286f with SMTP id a15-20020ac25e6f000000b00512b297286fmr7624463lfr.52.1708625690268; Thu, 22 Feb 2024 10:14:50 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id br21-20020a056512401500b00512da707c90sm406390lfb.43.2024.02.22.10.14.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 10:14:49 -0800 (PST) From: Serge Semin To: Michal Simek , Alexander Stein , Borislav Petkov , Tony Luck , James Morse , Mauro Carvalho Chehab , Robert Richter Cc: Serge Semin , Punnaiah Choudary Kalluri , Dinh Nguyen , Arnd Bergmann , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 16/20] EDAC/synopsys: Detach Zynq A05 DDRC support to separate driver Date: Thu, 22 Feb 2024 21:13:01 +0300 Message-ID: <20240222181324.28242-17-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240222181324.28242-1-fancer.lancer@gmail.com> References: <20240222181324.28242-1-fancer.lancer@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240222_181552_987561_F664CC20 X-CRM114-Status: GOOD ( 24.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The synopsys_edac.c driver currently supports three memory-controllers: 1. Synopsys DW uMCTL2 DDRC v3.80 (with the ZynqMP-specific params). 2. Xilinx ZynqMP DDRC Synopsys DW uMCTL2 DDRC v2.40. 3. Xilinx Zynq A05 DDR controller. If the first two devices are based on the Synopsys DW uMCTL2 IP-cores (ZynqMP MC is based on the DW uMCTL2 v2.40) the later device has absolutely nothing in common with the Synopsys DW uMCTL2 DDR controllers: the CSRs map is absolutely different; it doesn't support IRQs unlike the Synopsys memory controllers. Having the driver to support so different devices caused implementing an additional level of abstraction, which will be a great deal of obstacle in about to be added comprehensive set of the Synopsys DDR-controller features (DW uCMTL2 IP-core parameters auto-detection, common SDRAM<->phys address translation, multi-ranked memory, ECC scrubber, individual IRQs, DFI alert_n IRQ, and so on). Moreover the original reason of having these devices support living in a single driver hasn't been introduced for all these years: the synopsys_edac.c driver currently supports only a single memory controller detected on the system. So in order to make the Synopsys driver ready for the new features added move the Xilinx Zynq A05 DDRC support into a separate driver: detach the Zynq-specific callbacks, init/probe/remove methods and move them into the new zynq_edac.c driver. The resultant driver will mostly look similar to the code submitted in the initial commit ae9b56e3996d ("EDAC, synps: Add EDAC support for zynq ddr ecc controller") except a few fixes added afterwards. Note several Zynq-specific macros have been used in the DW uMCTL2 DDRC-specific functions. These macros just for a mere coincident have values suitable for the DW uMCTL2 code but their names either partly or fully unrelated with the Synopsys memory controllers. Since these macros are now moved to another driver introduce a new Synopsys-specific ones and fix the places where the macros have been improperly utilized. Signed-off-by: Serge Semin --- Changelog v3: - Drop the no longer used "priv" pointer from the zynq_mc_init() function. (@tbot) Changelog v5: - Rename handle_error and check_errors to zynq_handle_error and zynq_check_errors in the kdoc comments (@tbot) --- MAINTAINERS | 1 + drivers/edac/Kconfig | 9 +- drivers/edac/Makefile | 1 + drivers/edac/synopsys_edac.c | 239 ++--------------- drivers/edac/zynq_edac.c | 501 +++++++++++++++++++++++++++++++++++ 5 files changed, 531 insertions(+), 220 deletions(-) create mode 100644 drivers/edac/zynq_edac.c diff --git a/MAINTAINERS b/MAINTAINERS index 960512bec428..baca1e55cf49 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3020,6 +3020,7 @@ F: arch/arm/mach-zynq/ F: drivers/clocksource/timer-cadence-ttc.c F: drivers/cpuidle/cpuidle-zynq.c F: drivers/edac/synopsys_edac.c +F: drivers/edac/zynq_edac.c F: drivers/i2c/busses/i2c-cadence.c F: drivers/i2c/busses/i2c-xiic.c F: drivers/mmc/host/sdhci-of-arasan.c diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig index 5a7f3fabee22..6e411376d2bb 100644 --- a/drivers/edac/Kconfig +++ b/drivers/edac/Kconfig @@ -487,7 +487,7 @@ config EDAC_ARMADA_XP config EDAC_SYNOPSYS tristate "Synopsys DDR Memory Controller" - depends on ARCH_ZYNQ || ARCH_ZYNQMP || ARCH_INTEL_SOCFPGA || ARCH_MXC + depends on ARCH_ZYNQMP || ARCH_INTEL_SOCFPGA || ARCH_MXC help Support for error detection and correction on the Synopsys DDR memory controller. @@ -542,6 +542,13 @@ config EDAC_DMC520 Support for error detection and correction on the SoCs with ARM DMC-520 DRAM controller. +config EDAC_ZYNQ + tristate "Xilinx Zynq A05 DDR Memory Controller" + depends on ARCH_ZYNQ || COMPILE_TEST + help + Support for error detection and correction on the Xilinx Zynq A05 + DDR memory controller. + config EDAC_ZYNQMP tristate "Xilinx ZynqMP OCM Controller" depends on ARCH_ZYNQMP || COMPILE_TEST diff --git a/drivers/edac/Makefile b/drivers/edac/Makefile index 9c09893695b7..2829036f8468 100644 --- a/drivers/edac/Makefile +++ b/drivers/edac/Makefile @@ -85,5 +85,6 @@ obj-$(CONFIG_EDAC_ASPEED) += aspeed_edac.o obj-$(CONFIG_EDAC_BLUEFIELD) += bluefield_edac.o obj-$(CONFIG_EDAC_DMC520) += dmc520_edac.o obj-$(CONFIG_EDAC_NPCM) += npcm_edac.o +obj-$(CONFIG_EDAC_ZYNQ) += zynq_edac.o obj-$(CONFIG_EDAC_ZYNQMP) += zynqmp_edac.o obj-$(CONFIG_EDAC_VERSAL) += versal_edac.o diff --git a/drivers/edac/synopsys_edac.c b/drivers/edac/synopsys_edac.c index dfe1abe7c86c..6ea1eaaa7d6f 100644 --- a/drivers/edac/synopsys_edac.c +++ b/drivers/edac/synopsys_edac.c @@ -29,68 +29,16 @@ #define SYNPS_EDAC_MOD_STRING "synps_edac" #define SYNPS_EDAC_MOD_VER "1" -/* Synopsys DDR memory controller registers that are relevant to ECC */ -#define CTRL_OFST 0x0 -#define T_ZQ_OFST 0xA4 - -/* ECC control register */ -#define ECC_CTRL_OFST 0xC4 -/* ECC log register */ -#define CE_LOG_OFST 0xC8 -/* ECC address register */ -#define CE_ADDR_OFST 0xCC -/* ECC data[31:0] register */ -#define CE_DATA_31_0_OFST 0xD0 - -/* Uncorrectable error info registers */ -#define UE_LOG_OFST 0xDC -#define UE_ADDR_OFST 0xE0 -#define UE_DATA_31_0_OFST 0xE4 - -#define STAT_OFST 0xF0 -#define SCRUB_OFST 0xF4 - -/* Control register bit field definitions */ -#define CTRL_BW_MASK 0xC -#define CTRL_BW_SHIFT 2 - -#define DDRCTL_WDTH_16 1 -#define DDRCTL_WDTH_32 0 - -/* ZQ register bit field definitions */ -#define T_ZQ_DDRMODE_MASK 0x2 - -/* ECC control register bit field definitions */ -#define ECC_CTRL_CLR_CE_ERR 0x2 -#define ECC_CTRL_CLR_UE_ERR 0x1 - -/* ECC correctable/uncorrectable error log register definitions */ -#define LOG_VALID 0x1 -#define CE_LOG_BITPOS_MASK 0xFE -#define CE_LOG_BITPOS_SHIFT 1 - -/* ECC correctable/uncorrectable error address register definitions */ -#define ADDR_COL_MASK 0xFFF -#define ADDR_ROW_MASK 0xFFFF000 -#define ADDR_ROW_SHIFT 12 -#define ADDR_BANK_MASK 0x70000000 -#define ADDR_BANK_SHIFT 28 - -/* ECC statistic register definitions */ -#define STAT_UECNT_MASK 0xFF -#define STAT_CECNT_MASK 0xFF00 -#define STAT_CECNT_SHIFT 8 - -/* ECC scrub register definitions */ -#define SCRUB_MODE_MASK 0x7 -#define SCRUB_MODE_SECDED 0x4 - /* DDR ECC Quirks */ #define DDR_ECC_INTR_SUPPORT BIT(0) #define DDR_ECC_DATA_POISON_SUPPORT BIT(1) #define SYNPS_ZYNQMP_IRQ_REGS BIT(2) -/* ZynqMP Enhanced DDR memory controller registers that are relevant to ECC */ +/* Synopsys DDR memory controller registers that are relevant to ECC */ + +/* DDRC Master 0 Register */ +#define DDR_MSTR_OFST 0x0 + /* ECC Configuration Registers */ #define ECC_CFG0_OFST 0x70 #define ECC_CFG1_OFST 0x74 @@ -134,16 +82,22 @@ #define ECC_ADDRMAP0_OFFSET 0x200 /* Control register bitfield definitions */ -#define ECC_CTRL_BUSWIDTH_MASK 0x3000 -#define ECC_CTRL_BUSWIDTH_SHIFT 12 +#define ECC_CTRL_CLR_CE_ERR BIT(0) +#define ECC_CTRL_CLR_UE_ERR BIT(1) #define ECC_CTRL_CLR_CE_ERRCNT BIT(2) #define ECC_CTRL_CLR_UE_ERRCNT BIT(3) /* DDR Control Register width definitions */ +#define DDR_MSTR_BUSWIDTH_MASK 0x3000 +#define DDR_MSTR_BUSWIDTH_SHIFT 12 #define DDRCTL_EWDTH_16 2 #define DDRCTL_EWDTH_32 1 #define DDRCTL_EWDTH_64 0 +/* ECC CFG0 register definitions */ +#define ECC_CFG0_MODE_MASK 0x7 +#define ECC_CFG0_MODE_SECDED 0x4 + /* ECC status register definitions */ #define ECC_STAT_UECNT_MASK 0xF0000 #define ECC_STAT_UECNT_SHIFT 16 @@ -341,61 +295,6 @@ struct synps_platform_data { int quirks; }; -/** - * zynq_get_error_info - Get the current ECC error info. - * @priv: DDR memory controller private instance data. - * - * Return: one if there is no error, otherwise zero. - */ -static int zynq_get_error_info(struct synps_edac_priv *priv) -{ - struct synps_ecc_status *p; - u32 regval, clearval = 0; - void __iomem *base; - - base = priv->baseaddr; - p = &priv->stat; - - regval = readl(base + STAT_OFST); - if (!regval) - return 1; - - p->ce_cnt = (regval & STAT_CECNT_MASK) >> STAT_CECNT_SHIFT; - p->ue_cnt = regval & STAT_UECNT_MASK; - - regval = readl(base + CE_LOG_OFST); - if (!(p->ce_cnt && (regval & LOG_VALID))) - goto ue_err; - - p->ceinfo.bitpos = (regval & CE_LOG_BITPOS_MASK) >> CE_LOG_BITPOS_SHIFT; - regval = readl(base + CE_ADDR_OFST); - p->ceinfo.row = (regval & ADDR_ROW_MASK) >> ADDR_ROW_SHIFT; - p->ceinfo.col = regval & ADDR_COL_MASK; - p->ceinfo.bank = (regval & ADDR_BANK_MASK) >> ADDR_BANK_SHIFT; - p->ceinfo.data = readl(base + CE_DATA_31_0_OFST); - edac_dbg(3, "CE bit position: %d data: %d\n", p->ceinfo.bitpos, - p->ceinfo.data); - clearval = ECC_CTRL_CLR_CE_ERR; - -ue_err: - regval = readl(base + UE_LOG_OFST); - if (!(p->ue_cnt && (regval & LOG_VALID))) - goto out; - - regval = readl(base + UE_ADDR_OFST); - p->ueinfo.row = (regval & ADDR_ROW_MASK) >> ADDR_ROW_SHIFT; - p->ueinfo.col = regval & ADDR_COL_MASK; - p->ueinfo.bank = (regval & ADDR_BANK_MASK) >> ADDR_BANK_SHIFT; - p->ueinfo.data = readl(base + UE_DATA_31_0_OFST); - clearval |= ECC_CTRL_CLR_UE_ERR; - -out: - writel(clearval, base + ECC_CTRL_OFST); - writel(0x0, base + ECC_CTRL_OFST); - - return 0; -} - /** * zynqmp_get_error_info - Get the current ECC error info. * @priv: DDR memory controller private instance data. @@ -614,37 +513,6 @@ static void check_errors(struct mem_ctl_info *mci) handle_error(mci, &priv->stat); } -/** - * zynq_get_dtype - Return the controller memory width. - * @base: DDR memory controller base address. - * - * Get the EDAC device type width appropriate for the current controller - * configuration. - * - * Return: a device type width enumeration. - */ -static enum dev_type zynq_get_dtype(const void __iomem *base) -{ - enum dev_type dt; - u32 width; - - width = readl(base + CTRL_OFST); - width = (width & CTRL_BW_MASK) >> CTRL_BW_SHIFT; - - switch (width) { - case DDRCTL_WDTH_16: - dt = DEV_X2; - break; - case DDRCTL_WDTH_32: - dt = DEV_X4; - break; - default: - dt = DEV_UNKNOWN; - } - - return dt; -} - /** * zynqmp_get_dtype - Return the controller memory width. * @base: DDR memory controller base address. @@ -658,7 +526,7 @@ static enum dev_type zynqmp_get_dtype(const void __iomem *base) { u32 regval; - regval = readl(base + CTRL_OFST); + regval = readl(base + DDR_MSTR_OFST); if (!(regval & MEM_TYPE_DDR4)) return DEV_UNKNOWN; @@ -677,30 +545,6 @@ static enum dev_type zynqmp_get_dtype(const void __iomem *base) return DEV_UNKNOWN; } -/** - * zynq_get_ecc_state - Return the controller ECC enable/disable status. - * @base: DDR memory controller base address. - * - * Get the ECC enable/disable status of the controller. - * - * Return: true if enabled, otherwise false. - */ -static bool zynq_get_ecc_state(void __iomem *base) -{ - enum dev_type dt; - u32 ecctype; - - dt = zynq_get_dtype(base); - if (dt == DEV_UNKNOWN) - return false; - - ecctype = readl(base + SCRUB_OFST) & SCRUB_MODE_MASK; - if ((ecctype == SCRUB_MODE_SECDED) && (dt == DEV_X2)) - return true; - - return false; -} - /** * zynqmp_get_ecc_state - Return the controller ECC enable/disable status. * @base: DDR memory controller base address. @@ -713,9 +557,9 @@ static bool zynqmp_get_ecc_state(void __iomem *base) { u32 regval; - regval = readl(base + ECC_CFG0_OFST) & SCRUB_MODE_MASK; + regval = readl(base + ECC_CFG0_OFST) & ECC_CFG0_MODE_MASK; - return (regval == SCRUB_MODE_SECDED); + return (regval == ECC_CFG0_MODE_SECDED); } /** @@ -732,30 +576,6 @@ static u32 get_memsize(void) return inf.totalram * inf.mem_unit; } -/** - * zynq_get_mtype - Return the controller memory type. - * @base: Synopsys ECC status structure. - * - * Get the EDAC memory type appropriate for the current controller - * configuration. - * - * Return: a memory type enumeration. - */ -static enum mem_type zynq_get_mtype(const void __iomem *base) -{ - enum mem_type mt; - u32 memtype; - - memtype = readl(base + T_ZQ_OFST); - - if (memtype & T_ZQ_DDRMODE_MASK) - mt = MEM_DDR3; - else - mt = MEM_DDR2; - - return mt; -} - /** * zynqmp_get_mtype - Returns controller memory type. * @base: Synopsys ECC status structure. @@ -770,7 +590,7 @@ static enum mem_type zynqmp_get_mtype(const void __iomem *base) enum mem_type mt; u32 memtype; - memtype = readl(base + CTRL_OFST); + memtype = readl(base + DDR_MSTR_OFST); if ((memtype & MEM_TYPE_DDR3) || (memtype & MEM_TYPE_LPDDR3)) mt = MEM_DDR3; @@ -882,14 +702,6 @@ static int setup_irq(struct mem_ctl_info *mci, return 0; } -static const struct synps_platform_data zynq_edac_def = { - .get_error_info = zynq_get_error_info, - .get_mtype = zynq_get_mtype, - .get_dtype = zynq_get_dtype, - .get_ecc_state = zynq_get_ecc_state, - .quirks = 0, -}; - static const struct synps_platform_data zynqmp_edac_def = { .get_error_info = zynqmp_get_error_info, .get_mtype = zynqmp_get_mtype, @@ -916,10 +728,6 @@ static const struct synps_platform_data synopsys_edac_def = { static const struct of_device_id synps_edac_match[] = { - { - .compatible = "xlnx,zynq-ddrc-a05", - .data = (void *)&zynq_edac_def - }, { .compatible = "xlnx,zynqmp-ddrc-2.40a", .data = (void *)&zynqmp_edac_def @@ -1141,8 +949,8 @@ static void setup_column_address_map(struct synps_edac_priv *priv, u32 *addrmap) u32 width, memtype; int index; - memtype = readl(priv->baseaddr + CTRL_OFST); - width = (memtype & ECC_CTRL_BUSWIDTH_MASK) >> ECC_CTRL_BUSWIDTH_SHIFT; + memtype = readl(priv->baseaddr + DDR_MSTR_OFST); + width = (memtype & DDR_MSTR_BUSWIDTH_MASK) >> DDR_MSTR_BUSWIDTH_SHIFT; priv->col_shift[0] = 0; priv->col_shift[1] = 1; @@ -1337,7 +1145,7 @@ static int mc_probe(struct platform_device *pdev) layers[1].size = SYNPS_EDAC_NR_CHANS; layers[1].is_virt_csrow = false; - mci = edac_mc_alloc(0, ARRAY_SIZE(layers), layers, + mci = edac_mc_alloc(EDAC_AUTO_MC_NUM, ARRAY_SIZE(layers), layers, sizeof(struct synps_edac_priv)); if (!mci) { edac_printk(KERN_ERR, EDAC_MC, @@ -1379,13 +1187,6 @@ static int mc_probe(struct platform_device *pdev) setup_address_map(priv); #endif - /* - * Start capturing the correctable and uncorrectable errors. A write of - * 0 starts the counters. - */ - if (!(priv->p_data->quirks & DDR_ECC_INTR_SUPPORT)) - writel(0x0, baseaddr + ECC_CTRL_OFST); - return rc; free_edac_mc: diff --git a/drivers/edac/zynq_edac.c b/drivers/edac/zynq_edac.c new file mode 100644 index 000000000000..be26934a9c20 --- /dev/null +++ b/drivers/edac/zynq_edac.c @@ -0,0 +1,501 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Zynq DDR ECC Driver + * This driver is based on ppc4xx_edac.c drivers + * + * Copyright (C) 2012 - 2014 Xilinx, Inc. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "edac_module.h" + +/* Number of cs_rows needed per memory controller */ +#define ZYNQ_EDAC_NR_CSROWS 1 + +/* Number of channels per memory controller */ +#define ZYNQ_EDAC_NR_CHANS 1 + +/* Granularity of reported error in bytes */ +#define ZYNQ_EDAC_ERR_GRAIN 1 + +#define ZYNQ_EDAC_MSG_SIZE 256 + +#define ZYNQ_EDAC_MOD_STRING "zynq_edac" +#define ZYNQ_EDAC_MOD_VER "1" + +/* Zynq DDR memory controller ECC registers */ +#define ZYNQ_CTRL_OFST 0x0 +#define ZYNQ_T_ZQ_OFST 0xA4 + +/* ECC control register */ +#define ZYNQ_ECC_CTRL_OFST 0xC4 +/* ECC log register */ +#define ZYNQ_CE_LOG_OFST 0xC8 +/* ECC address register */ +#define ZYNQ_CE_ADDR_OFST 0xCC +/* ECC data[31:0] register */ +#define ZYNQ_CE_DATA_31_0_OFST 0xD0 + +/* Uncorrectable error info registers */ +#define ZYNQ_UE_LOG_OFST 0xDC +#define ZYNQ_UE_ADDR_OFST 0xE0 +#define ZYNQ_UE_DATA_31_0_OFST 0xE4 + +#define ZYNQ_STAT_OFST 0xF0 +#define ZYNQ_SCRUB_OFST 0xF4 + +/* Control register bit field definitions */ +#define ZYNQ_CTRL_BW_MASK 0xC +#define ZYNQ_CTRL_BW_SHIFT 2 + +#define ZYNQ_DDRCTL_WDTH_16 1 +#define ZYNQ_DDRCTL_WDTH_32 0 + +/* ZQ register bit field definitions */ +#define ZYNQ_T_ZQ_DDRMODE_MASK 0x2 + +/* ECC control register bit field definitions */ +#define ZYNQ_ECC_CTRL_CLR_CE_ERR 0x2 +#define ZYNQ_ECC_CTRL_CLR_UE_ERR 0x1 + +/* ECC correctable/uncorrectable error log register definitions */ +#define ZYNQ_LOG_VALID 0x1 +#define ZYNQ_CE_LOG_BITPOS_MASK 0xFE +#define ZYNQ_CE_LOG_BITPOS_SHIFT 1 + +/* ECC correctable/uncorrectable error address register definitions */ +#define ZYNQ_ADDR_COL_MASK 0xFFF +#define ZYNQ_ADDR_ROW_MASK 0xFFFF000 +#define ZYNQ_ADDR_ROW_SHIFT 12 +#define ZYNQ_ADDR_BANK_MASK 0x70000000 +#define ZYNQ_ADDR_BANK_SHIFT 28 + +/* ECC statistic register definitions */ +#define ZYNQ_STAT_UECNT_MASK 0xFF +#define ZYNQ_STAT_CECNT_MASK 0xFF00 +#define ZYNQ_STAT_CECNT_SHIFT 8 + +/* ECC scrub register definitions */ +#define ZYNQ_SCRUB_MODE_MASK 0x7 +#define ZYNQ_SCRUB_MODE_SECDED 0x4 + +/** + * struct zynq_ecc_error_info - ECC error log information. + * @row: Row number. + * @col: Column number. + * @bank: Bank number. + * @bitpos: Bit position. + * @data: Data causing the error. + */ +struct zynq_ecc_error_info { + u32 row; + u32 col; + u32 bank; + u32 bitpos; + u32 data; +}; + +/** + * struct zynq_ecc_status - ECC status information to report. + * @ce_cnt: Correctable error count. + * @ue_cnt: Uncorrectable error count. + * @ceinfo: Correctable error log information. + * @ueinfo: Uncorrectable error log information. + */ +struct zynq_ecc_status { + u32 ce_cnt; + u32 ue_cnt; + struct zynq_ecc_error_info ceinfo; + struct zynq_ecc_error_info ueinfo; +}; + +/** + * struct zynq_edac_priv - DDR memory controller private instance data. + * @baseaddr: Base address of the DDR controller. + * @message: Buffer for framing the event specific info. + * @stat: ECC status information. + */ +struct zynq_edac_priv { + void __iomem *baseaddr; + char message[ZYNQ_EDAC_MSG_SIZE]; + struct zynq_ecc_status stat; +}; + +/** + * zynq_get_error_info - Get the current ECC error info. + * @priv: DDR memory controller private instance data. + * + * Return: one if there is no error, otherwise zero. + */ +static int zynq_get_error_info(struct zynq_edac_priv *priv) +{ + struct zynq_ecc_status *p; + u32 regval, clearval = 0; + void __iomem *base; + + base = priv->baseaddr; + p = &priv->stat; + + regval = readl(base + ZYNQ_STAT_OFST); + if (!regval) + return 1; + + p->ce_cnt = (regval & ZYNQ_STAT_CECNT_MASK) >> ZYNQ_STAT_CECNT_SHIFT; + p->ue_cnt = regval & ZYNQ_STAT_UECNT_MASK; + + regval = readl(base + ZYNQ_CE_LOG_OFST); + if (!(p->ce_cnt && (regval & ZYNQ_LOG_VALID))) + goto ue_err; + + p->ceinfo.bitpos = (regval & ZYNQ_CE_LOG_BITPOS_MASK) >> ZYNQ_CE_LOG_BITPOS_SHIFT; + regval = readl(base + ZYNQ_CE_ADDR_OFST); + p->ceinfo.row = (regval & ZYNQ_ADDR_ROW_MASK) >> ZYNQ_ADDR_ROW_SHIFT; + p->ceinfo.col = regval & ZYNQ_ADDR_COL_MASK; + p->ceinfo.bank = (regval & ZYNQ_ADDR_BANK_MASK) >> ZYNQ_ADDR_BANK_SHIFT; + p->ceinfo.data = readl(base + ZYNQ_CE_DATA_31_0_OFST); + edac_dbg(3, "CE bit position: %d data: %d\n", p->ceinfo.bitpos, + p->ceinfo.data); + clearval = ZYNQ_ECC_CTRL_CLR_CE_ERR; + +ue_err: + regval = readl(base + ZYNQ_UE_LOG_OFST); + if (!(p->ue_cnt && (regval & ZYNQ_LOG_VALID))) + goto out; + + regval = readl(base + ZYNQ_UE_ADDR_OFST); + p->ueinfo.row = (regval & ZYNQ_ADDR_ROW_MASK) >> ZYNQ_ADDR_ROW_SHIFT; + p->ueinfo.col = regval & ZYNQ_ADDR_COL_MASK; + p->ueinfo.bank = (regval & ZYNQ_ADDR_BANK_MASK) >> ZYNQ_ADDR_BANK_SHIFT; + p->ueinfo.data = readl(base + ZYNQ_UE_DATA_31_0_OFST); + clearval |= ZYNQ_ECC_CTRL_CLR_UE_ERR; + +out: + writel(clearval, base + ZYNQ_ECC_CTRL_OFST); + writel(0x0, base + ZYNQ_ECC_CTRL_OFST); + + return 0; +} + +/** + * zynq_handle_error - Handle Correctable and Uncorrectable errors. + * @mci: EDAC memory controller instance. + * @p: Zynq ECC status structure. + * + * Handles ECC correctable and uncorrectable errors. + */ +static void zynq_handle_error(struct mem_ctl_info *mci, struct zynq_ecc_status *p) +{ + struct zynq_edac_priv *priv = mci->pvt_info; + struct zynq_ecc_error_info *pinf; + + if (p->ce_cnt) { + pinf = &p->ceinfo; + + snprintf(priv->message, ZYNQ_EDAC_MSG_SIZE, + "Row %d Bank %d Col %d Bit %d Data 0x%08x", + pinf->row, pinf->bank, pinf->col, + pinf->bitpos, pinf->data); + + edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, + p->ce_cnt, 0, 0, 0, 0, 0, -1, + priv->message, ""); + } + + if (p->ue_cnt) { + pinf = &p->ueinfo; + + snprintf(priv->message, ZYNQ_EDAC_MSG_SIZE, + "Row %d Bank %d Col %d", + pinf->row, pinf->bank, pinf->col); + + edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, + p->ue_cnt, 0, 0, 0, 0, 0, -1, + priv->message, ""); + } + + memset(p, 0, sizeof(*p)); +} + +/** + * zynq_check_errors - Check controller for ECC errors. + * @mci: EDAC memory controller instance. + * + * Check and post ECC errors. Called by the polling thread. + */ +static void zynq_check_errors(struct mem_ctl_info *mci) +{ + struct zynq_edac_priv *priv = mci->pvt_info; + int status; + + status = zynq_get_error_info(priv); + if (status) + return; + + zynq_handle_error(mci, &priv->stat); +} + +/** + * zynq_get_dtype - Return the controller memory width. + * @base: DDR memory controller base address. + * + * Get the EDAC device type width appropriate for the current controller + * configuration. + * + * Return: a device type width enumeration. + */ +static enum dev_type zynq_get_dtype(const void __iomem *base) +{ + enum dev_type dt; + u32 width; + + width = readl(base + ZYNQ_CTRL_OFST); + width = (width & ZYNQ_CTRL_BW_MASK) >> ZYNQ_CTRL_BW_SHIFT; + + switch (width) { + case ZYNQ_DDRCTL_WDTH_16: + dt = DEV_X2; + break; + case ZYNQ_DDRCTL_WDTH_32: + dt = DEV_X4; + break; + default: + dt = DEV_UNKNOWN; + } + + return dt; +} + +/** + * zynq_get_ecc_state - Return the controller ECC enable/disable status. + * @base: DDR memory controller base address. + * + * Get the ECC enable/disable status of the controller. + * + * Return: true if enabled, otherwise false. + */ +static bool zynq_get_ecc_state(void __iomem *base) +{ + enum dev_type dt; + u32 ecctype; + + dt = zynq_get_dtype(base); + if (dt == DEV_UNKNOWN) + return false; + + ecctype = readl(base + ZYNQ_SCRUB_OFST) & ZYNQ_SCRUB_MODE_MASK; + if ((ecctype == ZYNQ_SCRUB_MODE_SECDED) && (dt == DEV_X2)) + return true; + + return false; +} + +/** + * zynq_get_memsize - Read the size of the attached memory device. + * + * Return: the memory size in bytes. + */ +static u32 zynq_get_memsize(void) +{ + struct sysinfo inf; + + si_meminfo(&inf); + + return inf.totalram * inf.mem_unit; +} + +/** + * zynq_get_mtype - Return the controller memory type. + * @base: Zynq ECC status structure. + * + * Get the EDAC memory type appropriate for the current controller + * configuration. + * + * Return: a memory type enumeration. + */ +static enum mem_type zynq_get_mtype(const void __iomem *base) +{ + enum mem_type mt; + u32 memtype; + + memtype = readl(base + ZYNQ_T_ZQ_OFST); + + if (memtype & ZYNQ_T_ZQ_DDRMODE_MASK) + mt = MEM_DDR3; + else + mt = MEM_DDR2; + + return mt; +} + +/** + * zynq_init_csrows - Initialize the csrow data. + * @mci: EDAC memory controller instance. + * + * Initialize the chip select rows associated with the EDAC memory + * controller instance. + */ +static void zynq_init_csrows(struct mem_ctl_info *mci) +{ + struct zynq_edac_priv *priv = mci->pvt_info; + struct csrow_info *csi; + struct dimm_info *dimm; + u32 size, row; + int j; + + for (row = 0; row < mci->nr_csrows; row++) { + csi = mci->csrows[row]; + size = zynq_get_memsize(); + + for (j = 0; j < csi->nr_channels; j++) { + dimm = csi->channels[j]->dimm; + dimm->edac_mode = EDAC_SECDED; + dimm->mtype = zynq_get_mtype(priv->baseaddr); + dimm->nr_pages = (size >> PAGE_SHIFT) / csi->nr_channels; + dimm->grain = ZYNQ_EDAC_ERR_GRAIN; + dimm->dtype = zynq_get_dtype(priv->baseaddr); + } + } +} + +/** + * zynq_mc_init - Initialize one driver instance. + * @mci: EDAC memory controller instance. + * @pdev: platform device. + * + * Perform initialization of the EDAC memory controller instance and + * related driver-private data associated with the memory controller the + * instance is bound to. + */ +static void zynq_mc_init(struct mem_ctl_info *mci, struct platform_device *pdev) +{ + mci->pdev = &pdev->dev; + platform_set_drvdata(pdev, mci); + + /* Initialize controller capabilities and configuration */ + mci->mtype_cap = MEM_FLAG_DDR3 | MEM_FLAG_DDR2; + mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED; + mci->scrub_cap = SCRUB_FLAG_HW_SRC; + mci->scrub_mode = SCRUB_NONE; + + mci->edac_cap = EDAC_FLAG_SECDED; + mci->ctl_name = "zynq_ddr_controller"; + mci->dev_name = ZYNQ_EDAC_MOD_STRING; + mci->mod_name = ZYNQ_EDAC_MOD_VER; + + edac_op_state = EDAC_OPSTATE_POLL; + mci->edac_check = zynq_check_errors; + + mci->ctl_page_to_phys = NULL; + + zynq_init_csrows(mci); +} + +/** + * zynq_mc_probe - Check controller and bind driver. + * @pdev: platform device. + * + * Probe a specific controller instance for binding with the driver. + * + * Return: 0 if the controller instance was successfully bound to the + * driver; otherwise, < 0 on error. + */ +static int zynq_mc_probe(struct platform_device *pdev) +{ + struct edac_mc_layer layers[2]; + struct zynq_edac_priv *priv; + struct mem_ctl_info *mci; + void __iomem *baseaddr; + int rc; + + baseaddr = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(baseaddr)) + return PTR_ERR(baseaddr); + + if (!zynq_get_ecc_state(baseaddr)) { + edac_printk(KERN_INFO, EDAC_MC, "ECC not enabled\n"); + return -ENXIO; + } + + layers[0].type = EDAC_MC_LAYER_CHIP_SELECT; + layers[0].size = ZYNQ_EDAC_NR_CSROWS; + layers[0].is_virt_csrow = true; + layers[1].type = EDAC_MC_LAYER_CHANNEL; + layers[1].size = ZYNQ_EDAC_NR_CHANS; + layers[1].is_virt_csrow = false; + + mci = edac_mc_alloc(EDAC_AUTO_MC_NUM, ARRAY_SIZE(layers), layers, + sizeof(struct zynq_edac_priv)); + if (!mci) { + edac_printk(KERN_ERR, EDAC_MC, + "Failed memory allocation for mc instance\n"); + return -ENOMEM; + } + + priv = mci->pvt_info; + priv->baseaddr = baseaddr; + + zynq_mc_init(mci, pdev); + + rc = edac_mc_add_mc(mci); + if (rc) { + edac_printk(KERN_ERR, EDAC_MC, + "Failed to register with EDAC core\n"); + goto free_edac_mc; + } + + /* + * Start capturing the correctable and uncorrectable errors. A write of + * 0 starts the counters. + */ + writel(0x0, baseaddr + ZYNQ_ECC_CTRL_OFST); + + return 0; + +free_edac_mc: + edac_mc_free(mci); + + return rc; +} + +/** + * zynq_mc_remove - Unbind driver from controller. + * @pdev: Platform device. + * + * Return: Unconditionally 0 + */ +static int zynq_mc_remove(struct platform_device *pdev) +{ + struct mem_ctl_info *mci = platform_get_drvdata(pdev); + + edac_mc_del_mc(&pdev->dev); + edac_mc_free(mci); + + return 0; +} + +static const struct of_device_id zynq_edac_match[] = { + { .compatible = "xlnx,zynq-ddrc-a05" }, + {} +}; +MODULE_DEVICE_TABLE(of, zynq_edac_match); + +static struct platform_driver zynq_edac_mc_driver = { + .driver = { + .name = "zynq-edac", + .of_match_table = zynq_edac_match, + }, + .probe = zynq_mc_probe, + .remove = zynq_mc_remove, +}; +module_platform_driver(zynq_edac_mc_driver); + +MODULE_AUTHOR("Xilinx Inc"); +MODULE_DESCRIPTION("Zynq DDR ECC driver"); +MODULE_LICENSE("GPL v2"); From patchwork Thu Feb 22 18:13:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13567941 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 888E3C48BF8 for ; Thu, 22 Feb 2024 18:39:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=NwE8shj8k7RXGjeaSjVLCLLdHliIzwpNRXFt9lJQ0K4=; b=Y7qJS1zLLQwQRi fgnJpHBLup5hkKtQ5MSSyreNJVNume8NHzP0wsudMJjLRdvwdDFS60TNCbakXcrnx7P4C+WknKcIL ONGIDZiCSVp2yLvBfdKAiaoXyFTfae4eBuoY4tfAq2Iwis/TvaSHr5ININO+cDBh6F49DMD3EARuO H3oNPctzKEdjl1sshxECVyXIq4WADngm0mPfGYgYaqybpIrgUXTeaw2L8WDHTJ5+I2xA5VpOpBBYk ZJlVE5KBp3DPjF4w5/rX74TPFvQwBt+Gwvf/bC68uXRy2R0fDqBp41TPZQ1Vb2y69k9r9Km8JoTdg +pSpKwTPJ9c7byaeDbyw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDyU-000000068a2-2OaS; Thu, 22 Feb 2024 18:39:14 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDyM-000000068X1-1JQq for linux-arm-kernel@bombadil.infradead.org; Thu, 22 Feb 2024 18:39:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=Fl1k5+lYKw5HlM2KYot8vM467N06m05HgUvKEyN6tJ8=; b=Tq3UKv3dvwLGiy/TPFM7pkqjLk e4fXXq2I6kOdDgCnAEPc5A7jCmrncHZ2zsIL5V22G+iE8LHSKxPe0MSwIoBGv1ebm7aYIsCunrO64 77vaHPMj6MXEB6TWybzACbpdim62gFc18wDTsC5M1CjExVyBS7UXdFBGoxmRoylHnUNFo6eFDHZei VlYKpp72A36ongyOMmjIqb3dRW3aUsE/7VRYS8/y165aOKYV5a/Ez4/4KhJknoyClyFDlvRddNb1d 2rEmsZhPKy9VW9KLpq6mj/wbD4tDd+URZa2zww+oETAeC/SvS5RyrTlJxbnOHQ1IF6zc+nbtXKCkm VUgkuPOw==; Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDbv-00000004IsK-2kvA for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 18:15:58 +0000 Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-512b700c8ebso117675e87.0 for ; Thu, 22 Feb 2024 10:15:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708625692; x=1709230492; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Fl1k5+lYKw5HlM2KYot8vM467N06m05HgUvKEyN6tJ8=; b=cE7BE2jr5G+lgM31hDRlKj7eifNGVLx4KfGIg0uqJcsMBxQ0jFEnJf9b52aSDt3Czl JuX/YSm962dazAVvuhLwQ90JzrNDTWOQff3nIeH75pzDGB6kaHixsKnz1DWp+I6C/uy7 0XStTyUGALUj26ceL5zcfO3/QxB3rQVM017GbLHVpGDKf2pGIiasWeJhLBEYlOerKBF9 G+3rBI8VTtRMHLCNfsO/kC9JPyFGzEOMVRFvnBSIHhz0RsvMqpqJ1GE+DOY34LzBI5An CLEKafZ7ERCRIesRJFXMhw8LIbrTnikGMeirDvcZ4k0OQ0/S2BJj/eSVmFID3CNeMkz0 Fx+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708625692; x=1709230492; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Fl1k5+lYKw5HlM2KYot8vM467N06m05HgUvKEyN6tJ8=; b=PkcyKFwZPbfLuPjWTnpv6z/4n4x1llla8ixzOtpKrG8QogpE094ZBeeXd6vHPI4RuK 6FpQSqwtKSkd3ASEacDAAS0rgJJYV5eGZCjWRp4p9GUUK1Mp3qWkSwYUh3ipl1SxYHeF /FoaTP5dctV+Y5cWLyGtHsQDWcJBfME3b+KFNbVpICA3tbGcKHLhdKByZ0jh1GdY921G MeHn+gqfsgCVVb6wrbBV2Kl++djX2bJjIfk8LcnP/7uZ5wHhR3r/yXkrO+tAN9ddEMcv yzoWKv/1WO+VAu/3VreJWtPbi2PbbYLu2E7qNtGd0WsZX50o5GlhBWR35Ao0RVnNw1mi o4Lw== X-Forwarded-Encrypted: i=1; AJvYcCX54itcXozcAtkI5UdShgRfL+/9S+nc2CsaJStVNfhHnAGxcA2rzehN6fKucEsgVqU5psUdrFXDoZlOLrxgZ04lo9iHG5OEAD7aE8sN0iUB/Vt/VyU= X-Gm-Message-State: AOJu0YyqN/SyNRqFsWVCHNqx70bfeMT0tO9r+Kt2hGPON/tuvX4/tIF0 d4x0xGESNuESY5QxHiT1LuNy+VxfsEjuyzRWPcfheEmZ9K8J2dJM X-Google-Smtp-Source: AGHT+IFoL/XCZ2Ks7+fgcMasDWSs9e7/s1j3RQC/zsHVDmpXyqG5t29RRkx/5c0GJbUyvUd9eAkJnw== X-Received: by 2002:ac2:5f72:0:b0:512:b051:7b06 with SMTP id c18-20020ac25f72000000b00512b0517b06mr8468525lfc.31.1708625692016; Thu, 22 Feb 2024 10:14:52 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id u14-20020ac248ae000000b005115430488bsm2148044lfg.243.2024.02.22.10.14.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 10:14:51 -0800 (PST) From: Serge Semin To: Michal Simek , Alexander Stein , Borislav Petkov , Tony Luck , James Morse , Mauro Carvalho Chehab , Robert Richter Cc: Serge Semin , Punnaiah Choudary Kalluri , Dinh Nguyen , Arnd Bergmann , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 17/20] EDAC/synopsys: Drop unused platform-specific setup API Date: Thu, 22 Feb 2024 21:13:02 +0300 Message-ID: <20240222181324.28242-18-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240222181324.28242-1-fancer.lancer@gmail.com> References: <20240222181324.28242-1-fancer.lancer@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240222_181555_731084_FE0DB33E X-CRM114-Status: GOOD ( 24.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The driver now works with the Synopsys DW uMCTL2 DDRC IP-core-based devices only (Xilinx Zynq A05 DDRC support has been moved to the separate driver). All the currently available IP-core revisions have got almost the same ECC and main part of the DDR-config CSRs map. Thus there is no point in supporting the no longer used internal abstraction layer like the callbacks responsible for getting the ECC errors info, memory and device types, ECC state. All of that data can be retrieved in the same way from all the Synopys DW uMCTL2 DDR controller versions. Similarly there is no longer need in the DDR_ECC_INTR_SUPPORT and DDR_ECC_DATA_POISON_SUPPORT quirk flags since DW uMCTL2 always supports IRQs and data poisoning (as long as the ECC is supported). Drop that infrastructure for good then. While at it move the module device table to being defined at the bottom of the file, above the platform driver descriptor definition. Signed-off-by: Serge Semin --- Changelog v2: - Drop the no longer used "priv" pointer from the mc_init() function. (@tbot) --- drivers/edac/synopsys_edac.c | 192 ++++++++++------------------------- 1 file changed, 51 insertions(+), 141 deletions(-) diff --git a/drivers/edac/synopsys_edac.c b/drivers/edac/synopsys_edac.c index 6ea1eaaa7d6f..1cd02859e2b9 100644 --- a/drivers/edac/synopsys_edac.c +++ b/drivers/edac/synopsys_edac.c @@ -30,9 +30,7 @@ #define SYNPS_EDAC_MOD_VER "1" /* DDR ECC Quirks */ -#define DDR_ECC_INTR_SUPPORT BIT(0) -#define DDR_ECC_DATA_POISON_SUPPORT BIT(1) -#define SYNPS_ZYNQMP_IRQ_REGS BIT(2) +#define SYNPS_ZYNQMP_IRQ_REGS BIT(0) /* Synopsys DDR memory controller registers that are relevant to ECC */ @@ -280,28 +278,20 @@ struct synps_edac_priv { }; /** - * struct synps_platform_data - synps platform data structure. - * @get_error_info: Get EDAC error info. - * @get_mtype: Get mtype. - * @get_dtype: Get dtype. - * @get_ecc_state: Get ECC state. - * @quirks: To differentiate IPs. + * struct synps_platform_data - Synopsys uMCTL2 DDRC platform data. + * @quirks: IP-core specific quirks. */ struct synps_platform_data { - int (*get_error_info)(struct synps_edac_priv *priv); - enum mem_type (*get_mtype)(const void __iomem *base); - enum dev_type (*get_dtype)(const void __iomem *base); - bool (*get_ecc_state)(void __iomem *base); - int quirks; + u32 quirks; }; /** - * zynqmp_get_error_info - Get the current ECC error info. + * synps_get_error_info - Get the current ECC error info. * @priv: DDR memory controller private instance data. * * Return: one if there is no error otherwise returns zero. */ -static int zynqmp_get_error_info(struct synps_edac_priv *priv) +static int synps_get_error_info(struct synps_edac_priv *priv) { struct synps_ecc_status *p; u32 regval, clearval; @@ -375,17 +365,11 @@ static void handle_error(struct mem_ctl_info *mci, struct synps_ecc_status *p) if (p->ce_cnt) { pinf = &p->ceinfo; - if (priv->p_data->quirks & DDR_ECC_INTR_SUPPORT) { - snprintf(priv->message, SYNPS_EDAC_MSG_SIZE, - "Row %d Col %d Bank %d Bank Group %d Bit %d Data 0x%08x", - pinf->row, pinf->col, pinf->bank, pinf->bankgrp, - pinf->bitpos, pinf->data); - } else { - snprintf(priv->message, SYNPS_EDAC_MSG_SIZE, - "Row %d Bank %d Col %d Bit: %d Data: 0x%08x", - pinf->row, pinf->bank, pinf->col, - pinf->bitpos, pinf->data); - } + + snprintf(priv->message, SYNPS_EDAC_MSG_SIZE, + "Row %d Col %d Bank %d Bank Group %d Bit %d Data 0x%08x", + pinf->row, pinf->col, pinf->bank, pinf->bankgrp, + pinf->bitpos, pinf->data); edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, p->ce_cnt, 0, 0, 0, 0, 0, -1, @@ -394,15 +378,10 @@ static void handle_error(struct mem_ctl_info *mci, struct synps_ecc_status *p) if (p->ue_cnt) { pinf = &p->ueinfo; - if (priv->p_data->quirks & DDR_ECC_INTR_SUPPORT) { - snprintf(priv->message, SYNPS_EDAC_MSG_SIZE, - "Row %d Col %d Bank %d Bank Group %d", - pinf->row, pinf->col, pinf->bank, pinf->bankgrp); - } else { - snprintf(priv->message, SYNPS_EDAC_MSG_SIZE, - "Row %d Bank %d Col %d", - pinf->row, pinf->bank, pinf->col); - } + + snprintf(priv->message, SYNPS_EDAC_MSG_SIZE, + "Row %d Col %d Bank %d Bank Group %d", + pinf->row, pinf->col, pinf->bank, pinf->bankgrp); edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, p->ue_cnt, 0, 0, 0, 0, 0, -1, @@ -464,13 +443,11 @@ static void disable_intr(struct synps_edac_priv *priv) */ static irqreturn_t intr_handler(int irq, void *dev_id) { - const struct synps_platform_data *p_data; struct mem_ctl_info *mci = dev_id; struct synps_edac_priv *priv; int status, regval; priv = mci->pvt_info; - p_data = priv->p_data; if (priv->p_data->quirks & SYNPS_ZYNQMP_IRQ_REGS) { regval = readl(priv->baseaddr + DDR_QOS_IRQ_STAT_OFST); @@ -479,7 +456,7 @@ static irqreturn_t intr_handler(int irq, void *dev_id) return IRQ_NONE; } - status = p_data->get_error_info(priv); + status = synps_get_error_info(priv); if (status) return IRQ_NONE; @@ -492,29 +469,7 @@ static irqreturn_t intr_handler(int irq, void *dev_id) } /** - * check_errors - Check controller for ECC errors. - * @mci: EDAC memory controller instance. - * - * Check and post ECC errors. Called by the polling thread. - */ -static void check_errors(struct mem_ctl_info *mci) -{ - const struct synps_platform_data *p_data; - struct synps_edac_priv *priv; - int status; - - priv = mci->pvt_info; - p_data = priv->p_data; - - status = p_data->get_error_info(priv); - if (status) - return; - - handle_error(mci, &priv->stat); -} - -/** - * zynqmp_get_dtype - Return the controller memory width. + * synps_get_dtype - Return the controller memory width. * @base: DDR memory controller base address. * * Get the EDAC device type width appropriate for the current controller @@ -522,7 +477,7 @@ static void check_errors(struct mem_ctl_info *mci) * * Return: a device type width enumeration. */ -static enum dev_type zynqmp_get_dtype(const void __iomem *base) +static enum dev_type synps_get_dtype(const void __iomem *base) { u32 regval; @@ -546,14 +501,14 @@ static enum dev_type zynqmp_get_dtype(const void __iomem *base) } /** - * zynqmp_get_ecc_state - Return the controller ECC enable/disable status. + * synps_get_ecc_state - Return the controller ECC enable/disable status. * @base: DDR memory controller base address. * * Get the ECC enable/disable status for the controller. * * Return: a ECC status boolean i.e true/false - enabled/disabled. */ -static bool zynqmp_get_ecc_state(void __iomem *base) +static bool synps_get_ecc_state(void __iomem *base) { u32 regval; @@ -577,7 +532,7 @@ static u32 get_memsize(void) } /** - * zynqmp_get_mtype - Returns controller memory type. + * synps_get_mtype - Returns controller memory type. * @base: Synopsys ECC status structure. * * Get the EDAC memory type appropriate for the current controller @@ -585,7 +540,7 @@ static u32 get_memsize(void) * * Return: a memory type enumeration. */ -static enum mem_type zynqmp_get_mtype(const void __iomem *base) +static enum mem_type synps_get_mtype(const void __iomem *base) { enum mem_type mt; u32 memtype; @@ -614,14 +569,11 @@ static enum mem_type zynqmp_get_mtype(const void __iomem *base) static void init_csrows(struct mem_ctl_info *mci) { struct synps_edac_priv *priv = mci->pvt_info; - const struct synps_platform_data *p_data; struct csrow_info *csi; struct dimm_info *dimm; u32 size, row; int j; - p_data = priv->p_data; - for (row = 0; row < mci->nr_csrows; row++) { csi = mci->csrows[row]; size = get_memsize(); @@ -629,10 +581,10 @@ static void init_csrows(struct mem_ctl_info *mci) for (j = 0; j < csi->nr_channels; j++) { dimm = csi->channels[j]->dimm; dimm->edac_mode = EDAC_SECDED; - dimm->mtype = p_data->get_mtype(priv->baseaddr); + dimm->mtype = synps_get_mtype(priv->baseaddr); dimm->nr_pages = (size >> PAGE_SHIFT) / csi->nr_channels; dimm->grain = SYNPS_EDAC_ERR_GRAIN; - dimm->dtype = p_data->get_dtype(priv->baseaddr); + dimm->dtype = synps_get_dtype(priv->baseaddr); } } } @@ -648,10 +600,7 @@ static void init_csrows(struct mem_ctl_info *mci) */ static void mc_init(struct mem_ctl_info *mci, struct platform_device *pdev) { - struct synps_edac_priv *priv; - mci->pdev = &pdev->dev; - priv = mci->pvt_info; platform_set_drvdata(pdev, mci); /* Initialize controller capabilities and configuration */ @@ -665,12 +614,7 @@ static void mc_init(struct mem_ctl_info *mci, struct platform_device *pdev) mci->dev_name = SYNPS_EDAC_MOD_STRING; mci->mod_name = SYNPS_EDAC_MOD_VER; - if (priv->p_data->quirks & DDR_ECC_INTR_SUPPORT) { - edac_op_state = EDAC_OPSTATE_INT; - } else { - edac_op_state = EDAC_OPSTATE_POLL; - mci->edac_check = check_errors; - } + edac_op_state = EDAC_OPSTATE_INT; mci->ctl_page_to_phys = NULL; @@ -702,47 +646,6 @@ static int setup_irq(struct mem_ctl_info *mci, return 0; } -static const struct synps_platform_data zynqmp_edac_def = { - .get_error_info = zynqmp_get_error_info, - .get_mtype = zynqmp_get_mtype, - .get_dtype = zynqmp_get_dtype, - .get_ecc_state = zynqmp_get_ecc_state, - .quirks = (DDR_ECC_INTR_SUPPORT | SYNPS_ZYNQMP_IRQ_REGS -#ifdef CONFIG_EDAC_DEBUG - | DDR_ECC_DATA_POISON_SUPPORT -#endif - ), -}; - -static const struct synps_platform_data synopsys_edac_def = { - .get_error_info = zynqmp_get_error_info, - .get_mtype = zynqmp_get_mtype, - .get_dtype = zynqmp_get_dtype, - .get_ecc_state = zynqmp_get_ecc_state, - .quirks = (DDR_ECC_INTR_SUPPORT -#ifdef CONFIG_EDAC_DEBUG - | DDR_ECC_DATA_POISON_SUPPORT -#endif - ), -}; - - -static const struct of_device_id synps_edac_match[] = { - { - .compatible = "xlnx,zynqmp-ddrc-2.40a", - .data = (void *)&zynqmp_edac_def - }, - { - .compatible = "snps,ddrc-3.80a", - .data = (void *)&synopsys_edac_def - }, - { - /* end of table */ - } -}; - -MODULE_DEVICE_TABLE(of, synps_edac_match); - #ifdef CONFIG_EDAC_DEBUG /** @@ -1133,7 +1036,7 @@ static int mc_probe(struct platform_device *pdev) if (!p_data) return -ENODEV; - if (!p_data->get_ecc_state(baseaddr)) { + if (!synps_get_ecc_state(baseaddr)) { edac_printk(KERN_INFO, EDAC_MC, "ECC not enabled\n"); return -ENXIO; } @@ -1160,11 +1063,9 @@ static int mc_probe(struct platform_device *pdev) mc_init(mci, pdev); - if (priv->p_data->quirks & DDR_ECC_INTR_SUPPORT) { - rc = setup_irq(mci, pdev); - if (rc) - goto free_edac_mc; - } + rc = setup_irq(mci, pdev); + if (rc) + goto free_edac_mc; rc = edac_mc_add_mc(mci); if (rc) { @@ -1174,17 +1075,13 @@ static int mc_probe(struct platform_device *pdev) } #ifdef CONFIG_EDAC_DEBUG - if (priv->p_data->quirks & DDR_ECC_DATA_POISON_SUPPORT) { - rc = edac_create_sysfs_attributes(mci); - if (rc) { - edac_printk(KERN_ERR, EDAC_MC, - "Failed to create sysfs entries\n"); - goto free_edac_mc; - } + rc = edac_create_sysfs_attributes(mci); + if (rc) { + edac_printk(KERN_ERR, EDAC_MC, "Failed to create sysfs entries\n"); + goto free_edac_mc; } - if (priv->p_data->quirks & DDR_ECC_INTR_SUPPORT) - setup_address_map(priv); + setup_address_map(priv); #endif return rc; @@ -1206,18 +1103,31 @@ static void mc_remove(struct platform_device *pdev) struct mem_ctl_info *mci = platform_get_drvdata(pdev); struct synps_edac_priv *priv = mci->pvt_info; - if (priv->p_data->quirks & DDR_ECC_INTR_SUPPORT) - disable_intr(priv); + disable_intr(priv); #ifdef CONFIG_EDAC_DEBUG - if (priv->p_data->quirks & DDR_ECC_DATA_POISON_SUPPORT) - edac_remove_sysfs_attributes(mci); + edac_remove_sysfs_attributes(mci); #endif edac_mc_del_mc(&pdev->dev); edac_mc_free(mci); } +static const struct synps_platform_data zynqmp_edac_def = { + .quirks = SYNPS_ZYNQMP_IRQ_REGS, +}; + +static const struct synps_platform_data synopsys_edac_def = { + .quirks = 0, +}; + +static const struct of_device_id synps_edac_match[] = { + { .compatible = "xlnx,zynqmp-ddrc-2.40a", .data = &zynqmp_edac_def }, + { .compatible = "snps,ddrc-3.80a", .data = &synopsys_edac_def }, + { } +}; +MODULE_DEVICE_TABLE(of, synps_edac_match); + static struct platform_driver synps_edac_mc_driver = { .driver = { .name = "synopsys-edac", From patchwork Thu Feb 22 18:13:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13567940 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BC00DC48BF8 for ; Thu, 22 Feb 2024 18:39:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=odaTGAe7S+iShPVHu639NoOvKDIz69JHW5OJFxXnVSU=; b=OgmdXMx8vrrZGG PFDa3WAcZgXB7Y6AxpKcYfRRSL1R0JCPCQRsRFHZ4QwzXPN6OzF7RSwqR700z1lx8rlHf9ztMGSgF RTiQ9heS8rFMDjCI45igNX6IfF8QDp5NDYr6hVEpKXfLOf7f/dtU5JRS9DbI52guSfkfdPhV+Jgk7 KNIFr7S/FPYBS4dqGAfexN2bkM0DMtCu45PSf8NHrKy5zGWbtNgWaOuxGiQDnH7XwWfmE3s/bLK6G GG2WWKJlpIpH+oRAk3MjB7cWGy+nmw/YmVUost99FxhFBvO0qDXIqItTR21FlUiUa5nBztJLuKJch b3x8gSNdbAqHBMy2cbxQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDyM-000000068Xc-223A; Thu, 22 Feb 2024 18:39:06 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDyK-000000068WZ-3sFr for linux-arm-kernel@bombadil.infradead.org; Thu, 22 Feb 2024 18:39:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=X1gagcZMEXzd9ETmOtwHx7GZqRUhrIVl6MciINJPufo=; b=ImR6wOJqRBJLKir/8LsWPE1Dxb oBa0Ft2L4hPfd/U/AXsAx8ATo6NXzRk/C8+5tZR3JzqK5NjL/SqYe4uqtYelonzubcjWcQcL+cpg0 iCTvVPUAYFKNMqYyRb9L5JZRatXzAEtUiLhra/6WRpwptOIDu5v10RQ5dgMBLOi5ayfMjeRyjxkhE UiqCmSb3k+zY4+UHj66Kdop2TvnQxgux/N598yJ9/MDlW76ncATj08JsN/ZxiishuQc/gu1j3XLDP kyztMxC1HlI82YsQoTnw9FQD6gZmeKuH9utuF6s2md21ZRtlzCw0y/i9zMwme+0x+0wJcrF8IF70U JboI18xw==; Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDbv-00000004IsN-2l0m for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 18:15:57 +0000 Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-512b29f82d1so105771e87.1 for ; Thu, 22 Feb 2024 10:15:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708625694; x=1709230494; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=X1gagcZMEXzd9ETmOtwHx7GZqRUhrIVl6MciINJPufo=; b=XsvgQ+63yWBNjDO+v3uErz0wOeCPjQYUJjv3M4sko45iBvHnpO1q6KIZMGtU7sSV4q Bn8YeKEOQXdpwE1iGdoYOiGYQqyTeszNM7klfZCbO2XCJrQFF47pQNQFQV1Ya1OEz6fm 5pLFAu1+FLQqmW9rWnNSMi8Vm0o0QfUQWX1wP9YkfE5vNDilEzGmZ6oQ7eGZSUJUt9Qx sOB4z9iREWpM5fYMDf1NuFUygDHLk5Jat/sIMA2a6eOrS2BAMRcI7GhGXOYKyMR9zqLo Kj80ZNUQX6kmiY7f/L9vPKAIxqdXSkitaRmR8YFyvhLQqVLQJ7XBf0NEdoetys2ZLuX2 d/Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708625694; x=1709230494; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=X1gagcZMEXzd9ETmOtwHx7GZqRUhrIVl6MciINJPufo=; b=a6SpmFVCteA0o/yzm8lttzDb5env3JlGMFenJ7OfuMuuE4CJk9IzYxI6E15CCU0MoA Q8iOJ1svaDlfcav1U6vmGX09md+J0Tg+1e7zsDyBM2/dLS5PtcnHQIKd0ONrP9G63xJb IbO9JOJ0ead7F626V1lW1Hun02yMUxP+aqrPSmgqAeYMFAfabEvbNGLkcqT6V7qvGBUS BF+MvaZQ5VzynHceX9i8ixWfW2dkhXe3+bo5/JaY7wTfNeTTVRB6yNvg231ZR5xjr4p5 2ZtYqBMilHvtAc+HYsgeF/0g1S4gXnquRY6Q8T62m62hGsvJ3G/IDuhs5A1TOa3ocQhx 5gHw== X-Forwarded-Encrypted: i=1; AJvYcCUfvQ2j6r0ra6Iy/+neFbcIHTcalHc5xG+4N+uT0rlwQA7j+Z7z4d7bHsalIvYV9S5EkEdWJugt7P2Mn3QN0+0D2jvJR9yjRsJJceBU96JjsEfLK7M= X-Gm-Message-State: AOJu0YxJKgqEkFTJqZJQ01+/r29h0J1ohrkwd7XpIDDsIvhkNTxNUDVk DLQJD22a68KEwqvAvaaOv2DbNshFXGCM5MDuTu2InvQbHcOXp488 X-Google-Smtp-Source: AGHT+IGkBNOYhd1JS2L9Kps9qop3w6ZZqgdoNMIixKVJidLIwVObqR0EQ9xiiebcC8E+nC/VNSgxhw== X-Received: by 2002:a05:6512:308d:b0:512:a8bd:4bee with SMTP id z13-20020a056512308d00b00512a8bd4beemr10777912lfd.45.1708625693842; Thu, 22 Feb 2024 10:14:53 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id m15-20020a19520f000000b00512c8ef474asm1043015lfb.270.2024.02.22.10.14.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 10:14:53 -0800 (PST) From: Serge Semin To: Michal Simek , Alexander Stein , Borislav Petkov , Tony Luck , James Morse , Mauro Carvalho Chehab , Robert Richter Cc: Serge Semin , Punnaiah Choudary Kalluri , Dinh Nguyen , Arnd Bergmann , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 18/20] EDAC/synopsys: Unify CSRs macro declarations Date: Thu, 22 Feb 2024 21:13:03 +0300 Message-ID: <20240222181324.28242-19-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240222181324.28242-1-fancer.lancer@gmail.com> References: <20240222181324.28242-1-fancer.lancer@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240222_181555_796676_D8FCADF0 X-CRM114-Status: GOOD ( 21.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Originally the device CSR macros were supposed to be defined following the next local convention: first CSR offsets are listed, then their fields and flags are described in the same order; CSRs offset macros are supposed to have _OFST suffix; ECC-related macros shall have ECC_ prefix, generic DDR-related macros - DDR_ prefix. After all the years the driver has been living in kernel the CSRs macros have turned to be partly deviated away from the denoted convention. Fix all the related inconsistencies: move several CSRs offset macros to be defined before the CSRs fields and flags macros; replace OFFSET suffix with OFST; replace DDRC_ prefix with DDR_ and ECC_ with DDR_ where it's appropriate; group DDR_MSTR and ECC_CTRL (ECC_CLR) sibling fields macros together and make sure their prefixes match to the CSRs offset macros. In addition to that drop _MASK suffix from the macros which aren't used as masks and add ZYNQMP_ prefix to the ZYNQMP-specific macros to distinguish them from the generic Synopsys memory controller macros. Signed-off-by: Serge Semin --- Changelog v4: - This is a new patch collected from the rest of the series to simplify the review process. --- drivers/edac/synopsys_edac.c | 134 +++++++++++++++++------------------ 1 file changed, 66 insertions(+), 68 deletions(-) diff --git a/drivers/edac/synopsys_edac.c b/drivers/edac/synopsys_edac.c index 1cd02859e2b9..1de9f3f86d5a 100644 --- a/drivers/edac/synopsys_edac.c +++ b/drivers/edac/synopsys_edac.c @@ -77,20 +77,34 @@ #define ECC_POISON0_OFST 0xB8 #define ECC_POISON1_OFST 0xBC -#define ECC_ADDRMAP0_OFFSET 0x200 - -/* Control register bitfield definitions */ -#define ECC_CTRL_CLR_CE_ERR BIT(0) -#define ECC_CTRL_CLR_UE_ERR BIT(1) -#define ECC_CTRL_CLR_CE_ERRCNT BIT(2) -#define ECC_CTRL_CLR_UE_ERRCNT BIT(3) - -/* DDR Control Register width definitions */ +/* DDR Address Map Registers */ +#define DDR_ADDRMAP0_OFST 0x200 + +/* DDR Software Control Register */ +#define DDR_SWCTL 0x320 + +/* ZynqMP DDR QOS Registers */ +#define ZYNQMP_DDR_QOS_IRQ_STAT_OFST 0x20200 +#define ZYNQMP_DDR_QOS_IRQ_EN_OFST 0x20208 +#define ZYNQMP_DDR_QOS_IRQ_DB_OFST 0x2020C + +/* DDR Master register definitions */ +#define DDR_MSTR_DEV_CFG_MASK 0xC0000000 +#define DDR_MSTR_DEV_CFG_SHIFT 30 +#define DDR_MSTR_DEV_X4 0 +#define DDR_MSTR_DEV_X8 1 +#define DDR_MSTR_DEV_X16 2 +#define DDR_MSTR_DEV_X32 3 #define DDR_MSTR_BUSWIDTH_MASK 0x3000 #define DDR_MSTR_BUSWIDTH_SHIFT 12 -#define DDRCTL_EWDTH_16 2 -#define DDRCTL_EWDTH_32 1 -#define DDRCTL_EWDTH_64 0 +#define DDR_MSTR_BUSWIDTH_16 2 +#define DDR_MSTR_BUSWIDTH_32 1 +#define DDR_MSTR_BUSWIDTH_64 0 +#define DDR_MSTR_MEM_LPDDR4 0x20 +#define DDR_MSTR_MEM_DDR4 0x10 +#define DDR_MSTR_MEM_LPDDR3 0x8 +#define DDR_MSTR_MEM_DDR2 0x4 +#define DDR_MSTR_MEM_DDR3 0x1 /* ECC CFG0 register definitions */ #define ECC_CFG0_MODE_MASK 0x7 @@ -103,23 +117,19 @@ #define ECC_STAT_CECNT_SHIFT 8 #define ECC_STAT_BITNUM_MASK 0x7F +/* ECC control/clear register definitions */ +#define ECC_CTRL_CLR_CE_ERR BIT(0) +#define ECC_CTRL_CLR_UE_ERR BIT(1) +#define ECC_CTRL_CLR_CE_ERRCNT BIT(2) +#define ECC_CTRL_CLR_UE_ERRCNT BIT(3) +#define ECC_CTRL_EN_CE_IRQ BIT(8) +#define ECC_CTRL_EN_UE_IRQ BIT(9) + /* ECC error count register definitions */ #define ECC_ERRCNT_UECNT_MASK 0xFFFF0000 #define ECC_ERRCNT_UECNT_SHIFT 16 #define ECC_ERRCNT_CECNT_MASK 0xFFFF -/* DDR QOS Interrupt register definitions */ -#define DDR_QOS_IRQ_STAT_OFST 0x20200 -#define DDR_QOSUE_MASK 0x4 -#define DDR_QOSCE_MASK 0x2 -#define ECC_CE_UE_INTR_MASK 0x6 -#define DDR_QOS_IRQ_EN_OFST 0x20208 -#define DDR_QOS_IRQ_DB_OFST 0x2020C - -/* DDR QOS Interrupt register definitions */ -#define DDR_UE_MASK BIT(9) -#define DDR_CE_MASK BIT(8) - /* ECC Corrected Error Register Mask and Shifts*/ #define ECC_CEADDR0_RW_MASK 0x3FFFF #define ECC_CEADDR0_RNK_MASK BIT(24) @@ -141,28 +151,11 @@ #define ECC_POISON1_ROW_SHIFT 0 #define ECC_POISON1_ROW_MASK 0x3FFFF -/* DDR Memory type defines */ -#define MEM_TYPE_DDR3 0x1 -#define MEM_TYPE_LPDDR3 0x8 -#define MEM_TYPE_DDR2 0x4 -#define MEM_TYPE_DDR4 0x10 -#define MEM_TYPE_LPDDR4 0x20 - -/* DDRC Software control register */ -#define DDRC_SWCTL 0x320 - /* DDRC ECC CE & UE poison mask */ #define ECC_CEPOISON_MASK 0x3 #define ECC_UEPOISON_MASK 0x1 -/* DDRC Device config masks */ -#define DDRC_MSTR_CFG_MASK 0xC0000000 -#define DDRC_MSTR_CFG_SHIFT 30 -#define DDRC_MSTR_CFG_X4_MASK 0x0 -#define DDRC_MSTR_CFG_X8_MASK 0x1 -#define DDRC_MSTR_CFG_X16_MASK 0x2 -#define DDRC_MSTR_CFG_X32_MASK 0x3 - +/* DDRC Device config shifts/masks */ #define DDR_MAX_ROW_SHIFT 18 #define DDR_MAX_COL_SHIFT 14 #define DDR_MAX_BANK_SHIFT 3 @@ -215,6 +208,11 @@ #define RANK_B0_BASE 6 +/* ZynqMP DDR QOS Interrupt register definitions */ +#define ZYNQMP_DDR_QOS_UE_MASK 0x4 +#define ZYNQMP_DDR_QOS_CE_MASK 0x2 +#define ZYNQMP_DDR_QOS_IRQ_MASK 0x6 + /** * struct ecc_error_info - ECC error log information. * @row: Row number. @@ -397,8 +395,8 @@ static void enable_intr(struct synps_edac_priv *priv) /* Enable UE/CE Interrupts */ if (priv->p_data->quirks & SYNPS_ZYNQMP_IRQ_REGS) { - writel(DDR_QOSUE_MASK | DDR_QOSCE_MASK, - priv->baseaddr + DDR_QOS_IRQ_EN_OFST); + writel(ZYNQMP_DDR_QOS_UE_MASK | ZYNQMP_DDR_QOS_CE_MASK, + priv->baseaddr + ZYNQMP_DDR_QOS_IRQ_EN_OFST); return; } @@ -409,7 +407,7 @@ static void enable_intr(struct synps_edac_priv *priv) * IRQs Enable/Disable flags have been available since v3.10a. * This is noop for the older controllers. */ - writel(DDR_UE_MASK | DDR_CE_MASK, + writel(ECC_CTRL_EN_CE_IRQ | ECC_CTRL_EN_UE_IRQ, priv->baseaddr + ECC_CLR_OFST); spin_unlock_irqrestore(&priv->reglock, flags); @@ -421,8 +419,8 @@ static void disable_intr(struct synps_edac_priv *priv) /* Disable UE/CE Interrupts */ if (priv->p_data->quirks & SYNPS_ZYNQMP_IRQ_REGS) { - writel(DDR_QOSUE_MASK | DDR_QOSCE_MASK, - priv->baseaddr + DDR_QOS_IRQ_DB_OFST); + writel(ZYNQMP_DDR_QOS_UE_MASK | ZYNQMP_DDR_QOS_CE_MASK, + priv->baseaddr + ZYNQMP_DDR_QOS_IRQ_DB_OFST); return; } @@ -450,9 +448,9 @@ static irqreturn_t intr_handler(int irq, void *dev_id) priv = mci->pvt_info; if (priv->p_data->quirks & SYNPS_ZYNQMP_IRQ_REGS) { - regval = readl(priv->baseaddr + DDR_QOS_IRQ_STAT_OFST); - regval &= (DDR_QOSCE_MASK | DDR_QOSUE_MASK); - if (!(regval & ECC_CE_UE_INTR_MASK)) + regval = readl(priv->baseaddr + ZYNQMP_DDR_QOS_IRQ_STAT_OFST); + regval &= (ZYNQMP_DDR_QOS_CE_MASK | ZYNQMP_DDR_QOS_UE_MASK); + if (!(regval & ZYNQMP_DDR_QOS_IRQ_MASK)) return IRQ_NONE; } @@ -463,7 +461,7 @@ static irqreturn_t intr_handler(int irq, void *dev_id) handle_error(mci, &priv->stat); if (priv->p_data->quirks & SYNPS_ZYNQMP_IRQ_REGS) - writel(regval, priv->baseaddr + DDR_QOS_IRQ_STAT_OFST); + writel(regval, priv->baseaddr + ZYNQMP_DDR_QOS_IRQ_STAT_OFST); return IRQ_HANDLED; } @@ -482,18 +480,18 @@ static enum dev_type synps_get_dtype(const void __iomem *base) u32 regval; regval = readl(base + DDR_MSTR_OFST); - if (!(regval & MEM_TYPE_DDR4)) + if (!(regval & DDR_MSTR_MEM_DDR4)) return DEV_UNKNOWN; - regval = (regval & DDRC_MSTR_CFG_MASK) >> DDRC_MSTR_CFG_SHIFT; + regval = (regval & DDR_MSTR_DEV_CFG_MASK) >> DDR_MSTR_DEV_CFG_SHIFT; switch (regval) { - case DDRC_MSTR_CFG_X4_MASK: + case DDR_MSTR_DEV_X4: return DEV_X4; - case DDRC_MSTR_CFG_X8_MASK: + case DDR_MSTR_DEV_X8: return DEV_X8; - case DDRC_MSTR_CFG_X16_MASK: + case DDR_MSTR_DEV_X16: return DEV_X16; - case DDRC_MSTR_CFG_X32_MASK: + case DDR_MSTR_DEV_X32: return DEV_X32; } @@ -547,11 +545,11 @@ static enum mem_type synps_get_mtype(const void __iomem *base) memtype = readl(base + DDR_MSTR_OFST); - if ((memtype & MEM_TYPE_DDR3) || (memtype & MEM_TYPE_LPDDR3)) + if ((memtype & DDR_MSTR_MEM_DDR3) || (memtype & DDR_MSTR_MEM_LPDDR3)) mt = MEM_DDR3; - else if (memtype & MEM_TYPE_DDR2) + else if (memtype & DDR_MSTR_MEM_DDR2) mt = MEM_RDDR2; - else if ((memtype & MEM_TYPE_LPDDR4) || (memtype & MEM_TYPE_DDR4)) + else if ((memtype & DDR_MSTR_MEM_LPDDR4) || (memtype & DDR_MSTR_MEM_DDR4)) mt = MEM_DDR4; else mt = MEM_EMPTY; @@ -756,12 +754,12 @@ static ssize_t inject_data_poison_store(struct device *dev, struct mem_ctl_info *mci = to_mci(dev); struct synps_edac_priv *priv = mci->pvt_info; - writel(0, priv->baseaddr + DDRC_SWCTL); + writel(0, priv->baseaddr + DDR_SWCTL); if (strncmp(data, "CE", 2) == 0) writel(ECC_CEPOISON_MASK, priv->baseaddr + ECC_CFG1_OFST); else writel(ECC_UEPOISON_MASK, priv->baseaddr + ECC_CFG1_OFST); - writel(1, priv->baseaddr + DDRC_SWCTL); + writel(1, priv->baseaddr + DDR_SWCTL); return count; } @@ -878,8 +876,8 @@ static void setup_column_address_map(struct synps_edac_priv *priv, u32 *addrmap) priv->col_shift[9] = (((addrmap[3] >> 24) & COL_MAX_VAL_MASK) == COL_MAX_VAL_MASK) ? 0 : (((addrmap[3] >> 24) & COL_MAX_VAL_MASK) + COL_B9_BASE); - if (width == DDRCTL_EWDTH_64) { - if (memtype & MEM_TYPE_LPDDR3) { + if (width == DDR_MSTR_BUSWIDTH_64) { + if (memtype & DDR_MSTR_MEM_LPDDR3) { priv->col_shift[10] = ((addrmap[4] & COL_MAX_VAL_MASK) == COL_MAX_VAL_MASK) ? 0 : ((addrmap[4] & COL_MAX_VAL_MASK) + @@ -898,8 +896,8 @@ static void setup_column_address_map(struct synps_edac_priv *priv, u32 *addrmap) (((addrmap[4] >> 8) & COL_MAX_VAL_MASK) + COL_B11_BASE); } - } else if (width == DDRCTL_EWDTH_32) { - if (memtype & MEM_TYPE_LPDDR3) { + } else if (width == DDR_MSTR_BUSWIDTH_32) { + if (memtype & DDR_MSTR_MEM_LPDDR3) { priv->col_shift[10] = (((addrmap[3] >> 24) & COL_MAX_VAL_MASK) == COL_MAX_VAL_MASK) ? 0 : (((addrmap[3] >> 24) & COL_MAX_VAL_MASK) + @@ -919,7 +917,7 @@ static void setup_column_address_map(struct synps_edac_priv *priv, u32 *addrmap) COL_B10_BASE); } } else { - if (memtype & MEM_TYPE_LPDDR3) { + if (memtype & DDR_MSTR_MEM_LPDDR3) { priv->col_shift[10] = (((addrmap[3] >> 16) & COL_MAX_VAL_MASK) == COL_MAX_VAL_MASK) ? 0 : (((addrmap[3] >> 16) & COL_MAX_VAL_MASK) + @@ -994,7 +992,7 @@ static void setup_address_map(struct synps_edac_priv *priv) for (index = 0; index < 12; index++) { u32 addrmap_offset; - addrmap_offset = ECC_ADDRMAP0_OFFSET + (index * 4); + addrmap_offset = DDR_ADDRMAP0_OFST + (index * 4); addrmap[index] = readl(priv->baseaddr + addrmap_offset); } From patchwork Thu Feb 22 18:13:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13567952 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 91EC0C5478C for ; Thu, 22 Feb 2024 18:41:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1PpgFqdJZom14/sI/W7I0/lkNY0YIGUPnxyTmNwO548=; b=F4pyjeGShUCmm8 ydVKKgW9ynMQiV+qC+trvYlHXsUKz8B2I12JBDpyA+YwMEYLq+tcV7cyiIIMn9DmTfmEVCDmTXasb h9XQTXgOFg/f34Qrp7E6kvymOizfbDps/3++K5zlz5mPZV/oJ9xSJUJWPktg1LUiXMGn0/ievILU6 nm2rOAwgBOwlCa+BFDbXOnVBlYsnBNI5od3W0dHnzLvAcgcGCxbCSIu1IokvtKxEnmzQ6kdxmN2Dt 8F4OJIi5tO+XT3W9CfAkU/AScR3DopaZjvBM91bjBk12Bro2xyWGGXYLyY6qWpzmgsNnEJTdAVjzw 2/WKn0Wi1Hb8/TtdsjHw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdE0a-00000006A3i-2W4K; Thu, 22 Feb 2024 18:41:24 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDzc-000000069Sm-0z9t for linux-arm-kernel@bombadil.infradead.org; Thu, 22 Feb 2024 18:40:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=hZmVebWUwgliJQ+UKVckaGpQ670gZeKocKw7vAXcPzE=; b=valAPIn2O9972x2mvRMte6SIjt aFyG8BTlvznlehIQSmQL9s5frNCuwePYqZyd5umuF8HKPxgIrPMoixGkgpwAbsAf+tsXVEvlLOwY1 nu9F89lDYy4qNQO80kDzZzjFaU/RsR3UVm0ZR06EozubGYxbOMn8K54DL6AughozV/DZQn4xg22OV Kb67TXB2Uv52YUV9aWm8+CgkXx6bZFd12dRh6Oe5VYkGl8fi4XxtywTuM3tWb1kM/fjXxKVKYiI0q 1y/LUEhDhIzQcwnzM9PoNT+pjhOBsXl7XyIy/vmuvDL8kZwVL7JI9kJXS/PUxg03108wWUJQzjsvB bfcM2mWg==; Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDbz-00000004Iu2-1Ste for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 18:16:01 +0000 Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2d2628e81b8so7696821fa.0 for ; Thu, 22 Feb 2024 10:15:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708625696; x=1709230496; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hZmVebWUwgliJQ+UKVckaGpQ670gZeKocKw7vAXcPzE=; b=cTfkmLa82c3wgTliZ2FNzza75bimeJFfuZbfaQ+XeGWMibOo1TAcizevzGSBF7dhio ojZCYtgGc5UtwYn0L5IfC6caLRJLdG8HMP+wujxeP4Qtgql6NyawnnMgN61LHszFUSyL z7XrhmMVuKUOaQCRGVcMpS2jYJJMtGsx3zdSvlvj2ntJPYRoF/uKL/GplTU0WKq5WeAa jJuXRqVeRSQvHQ3XpStuMcvec+xEvtrAeTG8At9HEhB4vJ1PNuQZnZF1PFufMCXXickS 95U9/XiIjARNFiaLi/eXdcZpnsqncS0wKYKYkjR/bcpFvBGJwXMl3aBsQUyb9zUElQEU 0F4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708625696; x=1709230496; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hZmVebWUwgliJQ+UKVckaGpQ670gZeKocKw7vAXcPzE=; b=Flwwrx7aZg0yDymR1vRCD5bpA+EUTnhIXP/aQOYtFbNiz7m7jAVdVybzi/L2QCN0xz +JpYrF90nNQzu9cylH1xZ8f/vjYLvx0YpfRbdfxLCsMU4NxTA426ID3UNbtmkZLCZyBT S4g8f8RDdYIxFgzJw+0RueO3Ctfh9a0vpMH8/vulrB+JolGoY2RuwTtvqZTbS/8tvnJm t91j9A/zzC9MbtA2jYcxrCWSPTI0S0oRXJET5io/g/mhdbH+Jwu0QJkXdV/KgvHrgZRE 46QxpQI2fffmqB2FjzZecfEoUkEIKOeu4xWpNOqYhjUn+hdeSyGYr9dBb5tz0wyjd3Fp U3Iw== X-Forwarded-Encrypted: i=1; AJvYcCVukD7rQgAmRXJ3xwflOu251NwKoxAqu03E+d+BUAS4b64qJAmsCsmRMPg5VXdO7zu/vz2cJnutwk1KFVNPCALK9gOrY178QG/qnXm+Y2y93aA2Bck= X-Gm-Message-State: AOJu0YyKhycgnElpauzcVB/rpKXWwLiUB4FzABL4Kbf/dxvUf0AjGkaC OQ/GoIMzn+1IpfydCVGDQUpVWVTAKR0BIjo8D0+/y9dwJ5KuE12N X-Google-Smtp-Source: AGHT+IErzLkaz3qzDZdhNtrHLZQMnhpUWSRNnekUm3iqbVpGOXv3C1PVjwu/aSIVXozg7Cr/m283Lg== X-Received: by 2002:a05:6512:3602:b0:512:bf10:832d with SMTP id f2-20020a056512360200b00512bf10832dmr1157440lfs.17.1708625695616; Thu, 22 Feb 2024 10:14:55 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id o6-20020ac24e86000000b0051186931619sm2142012lfr.146.2024.02.22.10.14.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 10:14:55 -0800 (PST) From: Serge Semin To: Michal Simek , Alexander Stein , Borislav Petkov , Tony Luck , James Morse , Mauro Carvalho Chehab , Robert Richter Cc: Serge Semin , Punnaiah Choudary Kalluri , Dinh Nguyen , Arnd Bergmann , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 19/20] EDAC/synopsys: Unify struct/macro/function prefixes Date: Thu, 22 Feb 2024 21:13:04 +0300 Message-ID: <20240222181324.28242-20-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240222181324.28242-1-fancer.lancer@gmail.com> References: <20240222181324.28242-1-fancer.lancer@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240222_181559_411704_0697C58F X-CRM114-Status: GOOD ( 22.48 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Currently the driver entities naming schema is kind of random. There are structures and methods with the "synps" prefix, there are structures and methods with no driver-specific prefix, there are methods with the "edac" prefix, there are structure instances with "zynqmp" and "synopsys" prefixes, there are macros with "SYNPS", "ECC" and "DDR" prefixes. Moreover some time ago some of function names were shortened out by completely removing the vendor-specific prefixes thus leaving the driver with no strict entities naming convention (see commit bb894bc46ed0 ("EDAC, synopsys: Shorten static function names")). All of that makes the code much harder to read for no much reason (except shorter names utilization) since there is no easy way to distinguish now the local, EDAC core and global name spaces right from the code context. Similarly the kernel code index services (like elixir) gets to find the different functions with the same name, which harden the kernel hacking. Fix all of that by unifying the driver local entity names like functions, structures and non-CSR-related macros especially seeing the same approach has been used in the most of the EDAC LLDD. Use the "snps" prefix here as the shortest version of the controller vendor name. While at it add a more detailed controller name (DW uMCTL2 DDRC) to the driver comments and string literals where it's appropriate. Signed-off-by: Serge Semin --- Note "dw" prefix would be even shorter alternative. But we decided to stick with "snps" since "synopsys" has already been used in the module name. Changelog v2: - Forgot to fix some of the SYNPS_ZYNQMP_IRQ_REGS macro utilizations. (@tbot) --- drivers/edac/synopsys_edac.c | 241 ++++++++++++++++++----------------- 1 file changed, 121 insertions(+), 120 deletions(-) diff --git a/drivers/edac/synopsys_edac.c b/drivers/edac/synopsys_edac.c index 1de9f3f86d5a..c46cee035c0d 100644 --- a/drivers/edac/synopsys_edac.c +++ b/drivers/edac/synopsys_edac.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Synopsys DDR ECC Driver + * Synopsys DW uMCTL2 DDR ECC Driver * This driver is based on ppc4xx_edac.c drivers * * Copyright (C) 2012 - 2014 Xilinx, Inc. @@ -16,23 +16,23 @@ #include "edac_module.h" /* Number of cs_rows needed per memory controller */ -#define SYNPS_EDAC_NR_CSROWS 1 +#define SNPS_EDAC_NR_CSROWS 1 /* Number of channels per memory controller */ -#define SYNPS_EDAC_NR_CHANS 1 +#define SNPS_EDAC_NR_CHANS 1 /* Granularity of reported error in bytes */ -#define SYNPS_EDAC_ERR_GRAIN 1 +#define SNPS_EDAC_ERR_GRAIN 1 -#define SYNPS_EDAC_MSG_SIZE 256 +#define SNPS_EDAC_MSG_SIZE 256 -#define SYNPS_EDAC_MOD_STRING "synps_edac" -#define SYNPS_EDAC_MOD_VER "1" +#define SNPS_EDAC_MOD_STRING "snps_edac" +#define SNPS_EDAC_MOD_VER "1" /* DDR ECC Quirks */ -#define SYNPS_ZYNQMP_IRQ_REGS BIT(0) +#define SNPS_ZYNQMP_IRQ_REGS BIT(0) -/* Synopsys DDR memory controller registers that are relevant to ECC */ +/* Synopsys uMCTL2 DDR controller registers that are relevant to ECC */ /* DDRC Master 0 Register */ #define DDR_MSTR_OFST 0x0 @@ -214,7 +214,7 @@ #define ZYNQMP_DDR_QOS_IRQ_MASK 0x6 /** - * struct ecc_error_info - ECC error log information. + * struct snps_ecc_error_info - ECC error log information. * @row: Row number. * @col: Column number. * @bank: Bank number. @@ -222,7 +222,7 @@ * @bitpos: Bit position. * @data: Data causing the error. */ -struct ecc_error_info { +struct snps_ecc_error_info { u32 row; u32 col; u32 bank; @@ -232,21 +232,21 @@ struct ecc_error_info { }; /** - * struct synps_ecc_status - ECC status information to report. + * struct snps_ecc_status - ECC status information to report. * @ce_cnt: Correctable error count. * @ue_cnt: Uncorrectable error count. * @ceinfo: Correctable error log information. * @ueinfo: Uncorrectable error log information. */ -struct synps_ecc_status { +struct snps_ecc_status { u32 ce_cnt; u32 ue_cnt; - struct ecc_error_info ceinfo; - struct ecc_error_info ueinfo; + struct snps_ecc_error_info ceinfo; + struct snps_ecc_error_info ueinfo; }; /** - * struct synps_edac_priv - DDR memory controller private instance data. + * struct snps_edac_priv - DDR memory controller private data. * @baseaddr: Base address of the DDR controller. * @reglock: Concurrent CSRs access lock. * @message: Buffer for framing the event specific info. @@ -259,12 +259,12 @@ struct synps_ecc_status { * @bankgrp_shift: Bit shifts for bank group bit. * @rank_shift: Bit shifts for rank bit. */ -struct synps_edac_priv { +struct snps_edac_priv { void __iomem *baseaddr; spinlock_t reglock; - char message[SYNPS_EDAC_MSG_SIZE]; - struct synps_ecc_status stat; - const struct synps_platform_data *p_data; + char message[SNPS_EDAC_MSG_SIZE]; + struct snps_ecc_status stat; + const struct snps_platform_data *p_data; #ifdef CONFIG_EDAC_DEBUG ulong poison_addr; u32 row_shift[18]; @@ -276,22 +276,22 @@ struct synps_edac_priv { }; /** - * struct synps_platform_data - Synopsys uMCTL2 DDRC platform data. + * struct snps_platform_data - Synopsys uMCTL2 DDRC platform data. * @quirks: IP-core specific quirks. */ -struct synps_platform_data { +struct snps_platform_data { u32 quirks; }; /** - * synps_get_error_info - Get the current ECC error info. + * snps_get_error_info - Get the current ECC error info. * @priv: DDR memory controller private instance data. * * Return: one if there is no error otherwise returns zero. */ -static int synps_get_error_info(struct synps_edac_priv *priv) +static int snps_get_error_info(struct snps_edac_priv *priv) { - struct synps_ecc_status *p; + struct snps_ecc_status *p; u32 regval, clearval; unsigned long flags; void __iomem *base; @@ -350,21 +350,21 @@ static int synps_get_error_info(struct synps_edac_priv *priv) } /** - * handle_error - Handle Correctable and Uncorrectable errors. + * snps_handle_error - Handle Correctable and Uncorrectable errors. * @mci: EDAC memory controller instance. * @p: Synopsys ECC status structure. * * Handles ECC correctable and uncorrectable errors. */ -static void handle_error(struct mem_ctl_info *mci, struct synps_ecc_status *p) +static void snps_handle_error(struct mem_ctl_info *mci, struct snps_ecc_status *p) { - struct synps_edac_priv *priv = mci->pvt_info; - struct ecc_error_info *pinf; + struct snps_edac_priv *priv = mci->pvt_info; + struct snps_ecc_error_info *pinf; if (p->ce_cnt) { pinf = &p->ceinfo; - snprintf(priv->message, SYNPS_EDAC_MSG_SIZE, + snprintf(priv->message, SNPS_EDAC_MSG_SIZE, "Row %d Col %d Bank %d Bank Group %d Bit %d Data 0x%08x", pinf->row, pinf->col, pinf->bank, pinf->bankgrp, pinf->bitpos, pinf->data); @@ -377,7 +377,7 @@ static void handle_error(struct mem_ctl_info *mci, struct synps_ecc_status *p) if (p->ue_cnt) { pinf = &p->ueinfo; - snprintf(priv->message, SYNPS_EDAC_MSG_SIZE, + snprintf(priv->message, SNPS_EDAC_MSG_SIZE, "Row %d Col %d Bank %d Bank Group %d", pinf->row, pinf->col, pinf->bank, pinf->bankgrp); @@ -389,12 +389,12 @@ static void handle_error(struct mem_ctl_info *mci, struct synps_ecc_status *p) memset(p, 0, sizeof(*p)); } -static void enable_intr(struct synps_edac_priv *priv) +static void snps_enable_irq(struct snps_edac_priv *priv) { unsigned long flags; /* Enable UE/CE Interrupts */ - if (priv->p_data->quirks & SYNPS_ZYNQMP_IRQ_REGS) { + if (priv->p_data->quirks & SNPS_ZYNQMP_IRQ_REGS) { writel(ZYNQMP_DDR_QOS_UE_MASK | ZYNQMP_DDR_QOS_CE_MASK, priv->baseaddr + ZYNQMP_DDR_QOS_IRQ_EN_OFST); @@ -413,12 +413,12 @@ static void enable_intr(struct synps_edac_priv *priv) spin_unlock_irqrestore(&priv->reglock, flags); } -static void disable_intr(struct synps_edac_priv *priv) +static void snps_disable_irq(struct snps_edac_priv *priv) { unsigned long flags; /* Disable UE/CE Interrupts */ - if (priv->p_data->quirks & SYNPS_ZYNQMP_IRQ_REGS) { + if (priv->p_data->quirks & SNPS_ZYNQMP_IRQ_REGS) { writel(ZYNQMP_DDR_QOS_UE_MASK | ZYNQMP_DDR_QOS_CE_MASK, priv->baseaddr + ZYNQMP_DDR_QOS_IRQ_DB_OFST); @@ -433,41 +433,41 @@ static void disable_intr(struct synps_edac_priv *priv) } /** - * intr_handler - Interrupt Handler for ECC interrupts. + * snps_irq_handler - Interrupt Handler for ECC interrupts. * @irq: IRQ number. * @dev_id: Device ID. * * Return: IRQ_NONE, if interrupt not set or IRQ_HANDLED otherwise. */ -static irqreturn_t intr_handler(int irq, void *dev_id) +static irqreturn_t snps_irq_handler(int irq, void *dev_id) { struct mem_ctl_info *mci = dev_id; - struct synps_edac_priv *priv; + struct snps_edac_priv *priv; int status, regval; priv = mci->pvt_info; - if (priv->p_data->quirks & SYNPS_ZYNQMP_IRQ_REGS) { + if (priv->p_data->quirks & SNPS_ZYNQMP_IRQ_REGS) { regval = readl(priv->baseaddr + ZYNQMP_DDR_QOS_IRQ_STAT_OFST); regval &= (ZYNQMP_DDR_QOS_CE_MASK | ZYNQMP_DDR_QOS_UE_MASK); if (!(regval & ZYNQMP_DDR_QOS_IRQ_MASK)) return IRQ_NONE; } - status = synps_get_error_info(priv); + status = snps_get_error_info(priv); if (status) return IRQ_NONE; - handle_error(mci, &priv->stat); + snps_handle_error(mci, &priv->stat); - if (priv->p_data->quirks & SYNPS_ZYNQMP_IRQ_REGS) + if (priv->p_data->quirks & SNPS_ZYNQMP_IRQ_REGS) writel(regval, priv->baseaddr + ZYNQMP_DDR_QOS_IRQ_STAT_OFST); return IRQ_HANDLED; } /** - * synps_get_dtype - Return the controller memory width. + * snps_get_dtype - Return the controller memory width. * @base: DDR memory controller base address. * * Get the EDAC device type width appropriate for the current controller @@ -475,7 +475,7 @@ static irqreturn_t intr_handler(int irq, void *dev_id) * * Return: a device type width enumeration. */ -static enum dev_type synps_get_dtype(const void __iomem *base) +static enum dev_type snps_get_dtype(const void __iomem *base) { u32 regval; @@ -499,14 +499,14 @@ static enum dev_type synps_get_dtype(const void __iomem *base) } /** - * synps_get_ecc_state - Return the controller ECC enable/disable status. + * snps_get_ecc_state - Return the controller ECC enable/disable status. * @base: DDR memory controller base address. * * Get the ECC enable/disable status for the controller. * * Return: a ECC status boolean i.e true/false - enabled/disabled. */ -static bool synps_get_ecc_state(void __iomem *base) +static bool snps_get_ecc_state(void __iomem *base) { u32 regval; @@ -516,11 +516,11 @@ static bool synps_get_ecc_state(void __iomem *base) } /** - * get_memsize - Read the size of the attached memory device. + * snps_get_memsize - Read the size of the attached memory device. * * Return: the memory size in bytes. */ -static u32 get_memsize(void) +static u32 snps_get_memsize(void) { struct sysinfo inf; @@ -530,7 +530,7 @@ static u32 get_memsize(void) } /** - * synps_get_mtype - Returns controller memory type. + * snps_get_mtype - Returns controller memory type. * @base: Synopsys ECC status structure. * * Get the EDAC memory type appropriate for the current controller @@ -538,7 +538,7 @@ static u32 get_memsize(void) * * Return: a memory type enumeration. */ -static enum mem_type synps_get_mtype(const void __iomem *base) +static enum mem_type snps_get_mtype(const void __iomem *base) { enum mem_type mt; u32 memtype; @@ -558,15 +558,15 @@ static enum mem_type synps_get_mtype(const void __iomem *base) } /** - * init_csrows - Initialize the csrow data. + * snps_init_csrows - Initialize the csrow data. * @mci: EDAC memory controller instance. * * Initialize the chip select rows associated with the EDAC memory * controller instance. */ -static void init_csrows(struct mem_ctl_info *mci) +static void snps_init_csrows(struct mem_ctl_info *mci) { - struct synps_edac_priv *priv = mci->pvt_info; + struct snps_edac_priv *priv = mci->pvt_info; struct csrow_info *csi; struct dimm_info *dimm; u32 size, row; @@ -574,21 +574,21 @@ static void init_csrows(struct mem_ctl_info *mci) for (row = 0; row < mci->nr_csrows; row++) { csi = mci->csrows[row]; - size = get_memsize(); + size = snps_get_memsize(); for (j = 0; j < csi->nr_channels; j++) { dimm = csi->channels[j]->dimm; dimm->edac_mode = EDAC_SECDED; - dimm->mtype = synps_get_mtype(priv->baseaddr); + dimm->mtype = snps_get_mtype(priv->baseaddr); dimm->nr_pages = (size >> PAGE_SHIFT) / csi->nr_channels; - dimm->grain = SYNPS_EDAC_ERR_GRAIN; - dimm->dtype = synps_get_dtype(priv->baseaddr); + dimm->grain = SNPS_EDAC_ERR_GRAIN; + dimm->dtype = snps_get_dtype(priv->baseaddr); } } } /** - * mc_init - Initialize one driver instance. + * snps_mc_init - Initialize one driver instance. * @mci: EDAC memory controller instance. * @pdev: platform device. * @@ -596,7 +596,7 @@ static void init_csrows(struct mem_ctl_info *mci) * related driver-private data associated with the memory controller the * instance is bound to. */ -static void mc_init(struct mem_ctl_info *mci, struct platform_device *pdev) +static void snps_mc_init(struct mem_ctl_info *mci, struct platform_device *pdev) { mci->pdev = &pdev->dev; platform_set_drvdata(pdev, mci); @@ -608,21 +608,22 @@ static void mc_init(struct mem_ctl_info *mci, struct platform_device *pdev) mci->scrub_mode = SCRUB_NONE; mci->edac_cap = EDAC_FLAG_SECDED; - mci->ctl_name = "synps_ddr_controller"; - mci->dev_name = SYNPS_EDAC_MOD_STRING; - mci->mod_name = SYNPS_EDAC_MOD_VER; + mci->ctl_name = "snps_umctl2_ddrc"; + mci->dev_name = SNPS_EDAC_MOD_STRING; + mci->mod_name = SNPS_EDAC_MOD_VER; edac_op_state = EDAC_OPSTATE_INT; mci->ctl_page_to_phys = NULL; - init_csrows(mci); + snps_init_csrows(mci); } -static int setup_irq(struct mem_ctl_info *mci, - struct platform_device *pdev) + + +static int snps_setup_irq(struct mem_ctl_info *mci, struct platform_device *pdev) { - struct synps_edac_priv *priv = mci->pvt_info; + struct snps_edac_priv *priv = mci->pvt_info; int ret, irq; irq = platform_get_irq(pdev, 0); @@ -632,14 +633,14 @@ static int setup_irq(struct mem_ctl_info *mci, return irq; } - ret = devm_request_irq(&pdev->dev, irq, intr_handler, + ret = devm_request_irq(&pdev->dev, irq, snps_irq_handler, 0, dev_name(&pdev->dev), mci); if (ret < 0) { edac_printk(KERN_ERR, EDAC_MC, "Failed to request IRQ\n"); return ret; } - enable_intr(priv); + snps_enable_irq(priv); return 0; } @@ -647,13 +648,13 @@ static int setup_irq(struct mem_ctl_info *mci, #ifdef CONFIG_EDAC_DEBUG /** - * ddr_poison_setup - Update poison registers. + * snps_data_poison_setup - Update poison registers. * @priv: DDR memory controller private instance data. * * Update poison registers as per DDR mapping. * Return: none. */ -static void ddr_poison_setup(struct synps_edac_priv *priv) +static void snps_data_poison_setup(struct snps_edac_priv *priv) { int col = 0, row = 0, bank = 0, bankgrp = 0, rank = 0, regval; int index; @@ -711,7 +712,7 @@ static ssize_t inject_data_error_show(struct device *dev, char *data) { struct mem_ctl_info *mci = to_mci(dev); - struct synps_edac_priv *priv = mci->pvt_info; + struct snps_edac_priv *priv = mci->pvt_info; return sprintf(data, "Poison0 Addr: 0x%08x\n\rPoison1 Addr: 0x%08x\n\r" "Error injection Address: 0x%lx\n\r", @@ -725,12 +726,12 @@ static ssize_t inject_data_error_store(struct device *dev, const char *data, size_t count) { struct mem_ctl_info *mci = to_mci(dev); - struct synps_edac_priv *priv = mci->pvt_info; + struct snps_edac_priv *priv = mci->pvt_info; if (kstrtoul(data, 0, &priv->poison_addr)) return -EINVAL; - ddr_poison_setup(priv); + snps_data_poison_setup(priv); return count; } @@ -740,7 +741,7 @@ static ssize_t inject_data_poison_show(struct device *dev, char *data) { struct mem_ctl_info *mci = to_mci(dev); - struct synps_edac_priv *priv = mci->pvt_info; + struct snps_edac_priv *priv = mci->pvt_info; return sprintf(data, "Data Poisoning: %s\n\r", (((readl(priv->baseaddr + ECC_CFG1_OFST)) & 0x3) == 0x3) @@ -752,7 +753,7 @@ static ssize_t inject_data_poison_store(struct device *dev, const char *data, size_t count) { struct mem_ctl_info *mci = to_mci(dev); - struct synps_edac_priv *priv = mci->pvt_info; + struct snps_edac_priv *priv = mci->pvt_info; writel(0, priv->baseaddr + DDR_SWCTL); if (strncmp(data, "CE", 2) == 0) @@ -767,7 +768,7 @@ static ssize_t inject_data_poison_store(struct device *dev, static DEVICE_ATTR_RW(inject_data_error); static DEVICE_ATTR_RW(inject_data_poison); -static int edac_create_sysfs_attributes(struct mem_ctl_info *mci) +static int snps_create_sysfs_attributes(struct mem_ctl_info *mci) { int rc; @@ -780,13 +781,13 @@ static int edac_create_sysfs_attributes(struct mem_ctl_info *mci) return 0; } -static void edac_remove_sysfs_attributes(struct mem_ctl_info *mci) +static void snps_remove_sysfs_attributes(struct mem_ctl_info *mci) { device_remove_file(&mci->dev, &dev_attr_inject_data_error); device_remove_file(&mci->dev, &dev_attr_inject_data_poison); } -static void setup_row_address_map(struct synps_edac_priv *priv, u32 *addrmap) +static void snps_setup_row_address_map(struct snps_edac_priv *priv, u32 *addrmap) { u32 addrmap_row_b2_10; int index; @@ -845,7 +846,7 @@ static void setup_row_address_map(struct synps_edac_priv *priv, u32 *addrmap) ROW_MAX_VAL_MASK) + ROW_B17_BASE); } -static void setup_column_address_map(struct synps_edac_priv *priv, u32 *addrmap) +static void snps_setup_column_address_map(struct snps_edac_priv *priv, u32 *addrmap) { u32 width, memtype; int index; @@ -947,7 +948,7 @@ static void setup_column_address_map(struct synps_edac_priv *priv, u32 *addrmap) } -static void setup_bank_address_map(struct synps_edac_priv *priv, u32 *addrmap) +static void snps_setup_bank_address_map(struct snps_edac_priv *priv, u32 *addrmap) { priv->bank_shift[0] = (addrmap[1] & BANK_MAX_VAL_MASK) + BANK_B0_BASE; priv->bank_shift[1] = ((addrmap[1] >> 8) & @@ -959,7 +960,7 @@ static void setup_bank_address_map(struct synps_edac_priv *priv, u32 *addrmap) } -static void setup_bg_address_map(struct synps_edac_priv *priv, u32 *addrmap) +static void snps_setup_bg_address_map(struct snps_edac_priv *priv, u32 *addrmap) { priv->bankgrp_shift[0] = (addrmap[8] & BANKGRP_MAX_VAL_MASK) + BANKGRP_B0_BASE; @@ -969,7 +970,7 @@ static void setup_bg_address_map(struct synps_edac_priv *priv, u32 *addrmap) } -static void setup_rank_address_map(struct synps_edac_priv *priv, u32 *addrmap) +static void snps_setup_rank_address_map(struct snps_edac_priv *priv, u32 *addrmap) { priv->rank_shift[0] = ((addrmap[0] & RANK_MAX_VAL_MASK) == RANK_MAX_VAL_MASK) ? 0 : ((addrmap[0] & @@ -977,14 +978,14 @@ static void setup_rank_address_map(struct synps_edac_priv *priv, u32 *addrmap) } /** - * setup_address_map - Set Address Map by querying ADDRMAP registers. + * snps_setup_address_map - Set Address Map by querying ADDRMAP registers. * @priv: DDR memory controller private instance data. * * Set Address Map by querying ADDRMAP registers. * * Return: none. */ -static void setup_address_map(struct synps_edac_priv *priv) +static void snps_setup_address_map(struct snps_edac_priv *priv) { u32 addrmap[12]; int index; @@ -996,20 +997,20 @@ static void setup_address_map(struct synps_edac_priv *priv) addrmap[index] = readl(priv->baseaddr + addrmap_offset); } - setup_row_address_map(priv, addrmap); + snps_setup_row_address_map(priv, addrmap); - setup_column_address_map(priv, addrmap); + snps_setup_column_address_map(priv, addrmap); - setup_bank_address_map(priv, addrmap); + snps_setup_bank_address_map(priv, addrmap); - setup_bg_address_map(priv, addrmap); + snps_setup_bg_address_map(priv, addrmap); - setup_rank_address_map(priv, addrmap); + snps_setup_rank_address_map(priv, addrmap); } #endif /* CONFIG_EDAC_DEBUG */ /** - * mc_probe - Check controller and bind driver. + * snps_mc_probe - Check controller and bind driver. * @pdev: platform device. * * Probe a specific controller instance for binding with the driver. @@ -1017,11 +1018,11 @@ static void setup_address_map(struct synps_edac_priv *priv) * Return: 0 if the controller instance was successfully bound to the * driver; otherwise, < 0 on error. */ -static int mc_probe(struct platform_device *pdev) +static int snps_mc_probe(struct platform_device *pdev) { - const struct synps_platform_data *p_data; + const struct snps_platform_data *p_data; struct edac_mc_layer layers[2]; - struct synps_edac_priv *priv; + struct snps_edac_priv *priv; struct mem_ctl_info *mci; void __iomem *baseaddr; int rc; @@ -1034,20 +1035,20 @@ static int mc_probe(struct platform_device *pdev) if (!p_data) return -ENODEV; - if (!synps_get_ecc_state(baseaddr)) { + if (!snps_get_ecc_state(baseaddr)) { edac_printk(KERN_INFO, EDAC_MC, "ECC not enabled\n"); return -ENXIO; } layers[0].type = EDAC_MC_LAYER_CHIP_SELECT; - layers[0].size = SYNPS_EDAC_NR_CSROWS; + layers[0].size = SNPS_EDAC_NR_CSROWS; layers[0].is_virt_csrow = true; layers[1].type = EDAC_MC_LAYER_CHANNEL; - layers[1].size = SYNPS_EDAC_NR_CHANS; + layers[1].size = SNPS_EDAC_NR_CHANS; layers[1].is_virt_csrow = false; mci = edac_mc_alloc(EDAC_AUTO_MC_NUM, ARRAY_SIZE(layers), layers, - sizeof(struct synps_edac_priv)); + sizeof(struct snps_edac_priv)); if (!mci) { edac_printk(KERN_ERR, EDAC_MC, "Failed memory allocation for mc instance\n"); @@ -1059,9 +1060,9 @@ static int mc_probe(struct platform_device *pdev) priv->p_data = p_data; spin_lock_init(&priv->reglock); - mc_init(mci, pdev); + snps_mc_init(mci, pdev); - rc = setup_irq(mci, pdev); + rc = snps_setup_irq(mci, pdev); if (rc) goto free_edac_mc; @@ -1073,13 +1074,13 @@ static int mc_probe(struct platform_device *pdev) } #ifdef CONFIG_EDAC_DEBUG - rc = edac_create_sysfs_attributes(mci); + rc = snps_create_sysfs_attributes(mci); if (rc) { edac_printk(KERN_ERR, EDAC_MC, "Failed to create sysfs entries\n"); goto free_edac_mc; } - setup_address_map(priv); + snps_setup_address_map(priv); #endif return rc; @@ -1091,52 +1092,52 @@ static int mc_probe(struct platform_device *pdev) } /** - * mc_remove - Unbind driver from controller. + * snps_mc_remove - Unbind driver from device. * @pdev: Platform device. * * Return: Unconditionally 0 */ -static void mc_remove(struct platform_device *pdev) + +static void snps_mc_remove(struct platform_device *pdev) { struct mem_ctl_info *mci = platform_get_drvdata(pdev); - struct synps_edac_priv *priv = mci->pvt_info; + struct snps_edac_priv *priv = mci->pvt_info; - disable_intr(priv); + snps_disable_irq(priv); #ifdef CONFIG_EDAC_DEBUG - edac_remove_sysfs_attributes(mci); + snps_remove_sysfs_attributes(mci); #endif edac_mc_del_mc(&pdev->dev); edac_mc_free(mci); } -static const struct synps_platform_data zynqmp_edac_def = { - .quirks = SYNPS_ZYNQMP_IRQ_REGS, +static const struct snps_platform_data zynqmp_edac_def = { + .quirks = SNPS_ZYNQMP_IRQ_REGS, }; -static const struct synps_platform_data synopsys_edac_def = { +static const struct snps_platform_data snps_edac_def = { .quirks = 0, }; -static const struct of_device_id synps_edac_match[] = { +static const struct of_device_id snps_edac_match[] = { { .compatible = "xlnx,zynqmp-ddrc-2.40a", .data = &zynqmp_edac_def }, - { .compatible = "snps,ddrc-3.80a", .data = &synopsys_edac_def }, + { .compatible = "snps,ddrc-3.80a", .data = &snps_edac_def }, { } }; -MODULE_DEVICE_TABLE(of, synps_edac_match); +MODULE_DEVICE_TABLE(of, snps_edac_match); -static struct platform_driver synps_edac_mc_driver = { +static struct platform_driver snps_edac_mc_driver = { .driver = { - .name = "synopsys-edac", - .of_match_table = synps_edac_match, + .name = "snps-edac", + .of_match_table = snps_edac_match, }, - .probe = mc_probe, - .remove_new = mc_remove, + .probe = snps_mc_probe, + .remove_new = snps_mc_remove, }; - -module_platform_driver(synps_edac_mc_driver); +module_platform_driver(snps_edac_mc_driver); MODULE_AUTHOR("Xilinx Inc"); -MODULE_DESCRIPTION("Synopsys DDR ECC driver"); +MODULE_DESCRIPTION("Synopsys uMCTL2 DDR ECC driver"); MODULE_LICENSE("GPL v2"); From patchwork Thu Feb 22 18:13:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13567866 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5F343C54E42 for ; Thu, 22 Feb 2024 18:19:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0Z1AdkzCgB6icX7o1fScpfrEghB4SKLpslNLJXWCTag=; b=DG6BZSzG9B/KB0 bWAQeExc0t8bPBfN7XeB/JEJqcCj8Tz/ynCGZVdcy1mrsUzgs4X7XTuzpz+4ny4Fq3IIk59jnd81v xNrMd+P4Bq7vLfTdIYpmnaFTzUyYtua1wzC5Qwd3YZV6y5ATmuw4YHZFBvoQedSIBzzIRbDNn+PbW hK2xqzHZxSya2s4FPwVKhSZGAPoStV/WQNezROubkE1/fqWxKwSu3zTLPNf24ETOhsXGnKk7Ez7f/ VUzWtrQKto9nS9PFjHU5zpKPBwuleNy1n9iRpP9KazACLWrut8Fc3v+CUAHR0tQp/NRRNP4L/E0C9 c5tMJAGUR2/L4ViEIEmQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDfa-00000005zGE-0Cr4; Thu, 22 Feb 2024 18:19:42 +0000 Received: from mail-lf1-f42.google.com ([209.85.167.42]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDb1-00000005xFo-3Nhj for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 18:15:17 +0000 Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-512cba0f953so84314e87.2 for ; Thu, 22 Feb 2024 10:14:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708625697; x=1709230497; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6+6eluhzIXzdxVu9lwksRYlR6Z+Jeq9cMOHs7DzxPZ0=; b=TASF5YB7PTJaIBLm212U2G2+6Q0Vtu1vCK078ea9fc1xtPdHLYAby3f77OIGz/fROL K1QHsTFtXskEHugeJ0+vbFEv5OhpmKg5nw5ARznh+pyItwvPu4XPlBeJ3FsXXjzu/yV0 UmTaQkmHETKgtVppWEpYfG6COWm3tEpicIhUpRYyWsJtZHRnJLnqLViJYCkLW1djLZuj Zy12QCXaUI0wCPoCxyzPAVQQ8R1DwwE6XGXtMLuDwJOaxRA5Kc07uk7OOc3gAoU2xvB2 fE4HGVihrGkQr4ld9tdBvlzi2wBsyd1aB+44HtZk5YcBIIeszYFk5ak19vcJ4kauYHvG 9Ctg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708625697; x=1709230497; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6+6eluhzIXzdxVu9lwksRYlR6Z+Jeq9cMOHs7DzxPZ0=; b=ACDiNxlkMiJ338HgqTwbo0cNTX4G6M8S0OOUgNGBpvwsLef3NUi3wxcQIwDgFIvI5i 52fE99LUm744XIkAab4MD2G64d3P7BMrdWnwiuLKVJix4DvOb4vwaIOFwTN1z2EFjj47 XOIDb6/N+0ZQxSN4CKLRkg08m/M0cQBRc7ll6NV1BiV+YM35m+aVo4I8zAkapRTS8zVd sUepK34DBv03/BcksfBdjT7SgcPPY9by5lNC1hS518XNvC0Ht8XyrlHQgyA9VaDulV/M /jamaJv09491dFZn3uyWN9synr0NuxY4+MiPMUX2OmJiIqwBfixHoLZYfmPIPBFbqYjB SI0w== X-Forwarded-Encrypted: i=1; AJvYcCV6cbmKCInNpLeT4/FN9RNbD7N0g5P/Z9FcaWOyQM1BIJJ5YbxxGfe6Yb1q9o3bApJuMXY7xw+HapLZOAgrmzy+cOVro5SbuiFGl2qE0SL+OEJbwqI= X-Gm-Message-State: AOJu0Yws5CkMk51GQZ+K39Nlpdp8Vtcwuy8Mg7gbUvwN8H0n5cQRG27d 5b00UOSEU6a+/8PPb1dZF5j2BEhvgQFi6i2BNfdtjBWHwDVoRSx1 X-Google-Smtp-Source: AGHT+IGViWdTRMiTTkc5ZBZ6Oe/2Vf9SZKO55IAHmMniONZyEa0q+s5UPxtDimTkeKhEFaUSr/qKnA== X-Received: by 2002:a05:6512:2190:b0:512:c508:b8c8 with SMTP id b16-20020a056512219000b00512c508b8c8mr5788854lft.4.1708625697367; Thu, 22 Feb 2024 10:14:57 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id g38-20020a0565123ba600b00511767de71bsm2134577lfv.291.2024.02.22.10.14.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 10:14:56 -0800 (PST) From: Serge Semin To: Michal Simek , Alexander Stein , Borislav Petkov , Tony Luck , James Morse , Mauro Carvalho Chehab , Robert Richter Cc: Serge Semin , Punnaiah Choudary Kalluri , Dinh Nguyen , Arnd Bergmann , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 20/20] EDAC/synopsys: Convert to using BIT/GENMASK/FIELD_x macros Date: Thu, 22 Feb 2024 21:13:05 +0300 Message-ID: <20240222181324.28242-21-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240222181324.28242-1-fancer.lancer@gmail.com> References: <20240222181324.28242-1-fancer.lancer@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240222_101507_131354_18FB4CC9 X-CRM114-Status: GOOD ( 18.36 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Instead of using the very handy helpers denoted in the subject the driver has been created with the open-coded {mask,shift} statements. It makes the code bulky, prone to mistakes and much harder to read. Seeing there are many places in the driver implementing the CSR fields get/set pattern use the FIELD_GET()/FIELD_PREP() macros introduced in the kernel specifically for that case. In addition use the BIT() and GENMASK() macros to generate the CSR flags/masks. While at it unify the row, column, rank, bank and bank group macros names to be having a suffix similar to the snps_ecc_error_info structure fields name. Signed-off-by: Serge Semin --- drivers/edac/synopsys_edac.c | 137 +++++++++++++++++------------------ 1 file changed, 67 insertions(+), 70 deletions(-) diff --git a/drivers/edac/synopsys_edac.c b/drivers/edac/synopsys_edac.c index c46cee035c0d..f181cd7b4447 100644 --- a/drivers/edac/synopsys_edac.c +++ b/drivers/edac/synopsys_edac.c @@ -6,6 +6,8 @@ * Copyright (C) 2012 - 2014 Xilinx, Inc. */ +#include +#include #include #include #include @@ -89,33 +91,29 @@ #define ZYNQMP_DDR_QOS_IRQ_DB_OFST 0x2020C /* DDR Master register definitions */ -#define DDR_MSTR_DEV_CFG_MASK 0xC0000000 -#define DDR_MSTR_DEV_CFG_SHIFT 30 +#define DDR_MSTR_DEV_CFG_MASK GENMASK(31, 30) #define DDR_MSTR_DEV_X4 0 #define DDR_MSTR_DEV_X8 1 #define DDR_MSTR_DEV_X16 2 #define DDR_MSTR_DEV_X32 3 -#define DDR_MSTR_BUSWIDTH_MASK 0x3000 -#define DDR_MSTR_BUSWIDTH_SHIFT 12 +#define DDR_MSTR_BUSWIDTH_MASK GENMASK(13, 12) #define DDR_MSTR_BUSWIDTH_16 2 #define DDR_MSTR_BUSWIDTH_32 1 #define DDR_MSTR_BUSWIDTH_64 0 -#define DDR_MSTR_MEM_LPDDR4 0x20 -#define DDR_MSTR_MEM_DDR4 0x10 -#define DDR_MSTR_MEM_LPDDR3 0x8 -#define DDR_MSTR_MEM_DDR2 0x4 -#define DDR_MSTR_MEM_DDR3 0x1 +#define DDR_MSTR_MEM_LPDDR4 BIT(5) +#define DDR_MSTR_MEM_DDR4 BIT(4) +#define DDR_MSTR_MEM_LPDDR3 BIT(3) +#define DDR_MSTR_MEM_DDR2 BIT(2) +#define DDR_MSTR_MEM_DDR3 BIT(0) /* ECC CFG0 register definitions */ -#define ECC_CFG0_MODE_MASK 0x7 +#define ECC_CFG0_MODE_MASK GENMASK(2, 0) #define ECC_CFG0_MODE_SECDED 0x4 /* ECC status register definitions */ -#define ECC_STAT_UECNT_MASK 0xF0000 -#define ECC_STAT_UECNT_SHIFT 16 -#define ECC_STAT_CECNT_MASK 0xF00 -#define ECC_STAT_CECNT_SHIFT 8 -#define ECC_STAT_BITNUM_MASK 0x7F +#define ECC_STAT_UE_MASK GENMASK(23, 16) +#define ECC_STAT_CE_MASK GENMASK(15, 8) +#define ECC_STAT_BITNUM_MASK GENMASK(6, 0) /* ECC control/clear register definitions */ #define ECC_CTRL_CLR_CE_ERR BIT(0) @@ -126,34 +124,26 @@ #define ECC_CTRL_EN_UE_IRQ BIT(9) /* ECC error count register definitions */ -#define ECC_ERRCNT_UECNT_MASK 0xFFFF0000 -#define ECC_ERRCNT_UECNT_SHIFT 16 -#define ECC_ERRCNT_CECNT_MASK 0xFFFF - -/* ECC Corrected Error Register Mask and Shifts*/ -#define ECC_CEADDR0_RW_MASK 0x3FFFF -#define ECC_CEADDR0_RNK_MASK BIT(24) -#define ECC_CEADDR1_BNKGRP_MASK 0x3000000 -#define ECC_CEADDR1_BNKNR_MASK 0x70000 -#define ECC_CEADDR1_COL_MASK 0xFFF -#define ECC_CEADDR1_BNKGRP_SHIFT 24 -#define ECC_CEADDR1_BNKNR_SHIFT 16 - -/* ECC Poison register shifts */ -#define ECC_POISON0_RANK_SHIFT 24 -#define ECC_POISON0_RANK_MASK BIT(24) -#define ECC_POISON0_COLUMN_SHIFT 0 -#define ECC_POISON0_COLUMN_MASK 0xFFF -#define ECC_POISON1_BG_SHIFT 28 -#define ECC_POISON1_BG_MASK 0x30000000 -#define ECC_POISON1_BANKNR_SHIFT 24 -#define ECC_POISON1_BANKNR_MASK 0x7000000 -#define ECC_POISON1_ROW_SHIFT 0 -#define ECC_POISON1_ROW_MASK 0x3FFFF +#define ECC_ERRCNT_UECNT_MASK GENMASK(31, 16) +#define ECC_ERRCNT_CECNT_MASK GENMASK(15, 0) + +/* ECC Corrected Error register definitions */ +#define ECC_CEADDR0_RANK_MASK GENMASK(27, 24) +#define ECC_CEADDR0_ROW_MASK GENMASK(17, 0) +#define ECC_CEADDR1_BANKGRP_MASK GENMASK(25, 24) +#define ECC_CEADDR1_BANK_MASK GENMASK(23, 16) +#define ECC_CEADDR1_COL_MASK GENMASK(11, 0) + +/* ECC Poison register definitions */ +#define ECC_POISON0_RANK_MASK GENMASK(27, 24) +#define ECC_POISON0_COL_MASK GENMASK(11, 0) +#define ECC_POISON1_BANKGRP_MASK GENMASK(29, 28) +#define ECC_POISON1_BANK_MASK GENMASK(26, 24) +#define ECC_POISON1_ROW_MASK GENMASK(17, 0) /* DDRC ECC CE & UE poison mask */ -#define ECC_CEPOISON_MASK 0x3 -#define ECC_UEPOISON_MASK 0x1 +#define ECC_CEPOISON_MASK GENMASK(1, 0) +#define ECC_UEPOISON_MASK BIT(0) /* DDRC Device config shifts/masks */ #define DDR_MAX_ROW_SHIFT 18 @@ -209,9 +199,9 @@ #define RANK_B0_BASE 6 /* ZynqMP DDR QOS Interrupt register definitions */ -#define ZYNQMP_DDR_QOS_UE_MASK 0x4 -#define ZYNQMP_DDR_QOS_CE_MASK 0x2 -#define ZYNQMP_DDR_QOS_IRQ_MASK 0x6 +#define ZYNQMP_DDR_QOS_UE_MASK BIT(2) +#define ZYNQMP_DDR_QOS_CE_MASK BIT(1) +#define ZYNQMP_DDR_QOS_IRQ_MASK (ZYNQMP_DDR_QOS_UE_MASK | ZYNQMP_DDR_QOS_CE_MASK) /** * struct snps_ecc_error_info - ECC error log information. @@ -303,38 +293,40 @@ static int snps_get_error_info(struct snps_edac_priv *priv) if (!regval) return 1; - p->ceinfo.bitpos = (regval & ECC_STAT_BITNUM_MASK); + p->ceinfo.bitpos = FIELD_GET(ECC_STAT_BITNUM_MASK, regval); regval = readl(base + ECC_ERRCNT_OFST); - p->ce_cnt = regval & ECC_ERRCNT_CECNT_MASK; - p->ue_cnt = (regval & ECC_ERRCNT_UECNT_MASK) >> ECC_ERRCNT_UECNT_SHIFT; + p->ce_cnt = FIELD_GET(ECC_ERRCNT_CECNT_MASK, regval); + p->ue_cnt = FIELD_GET(ECC_ERRCNT_UECNT_MASK, regval); if (!p->ce_cnt) goto ue_err; regval = readl(base + ECC_CEADDR0_OFST); - p->ceinfo.row = (regval & ECC_CEADDR0_RW_MASK); + p->ceinfo.row = FIELD_GET(ECC_CEADDR0_ROW_MASK, regval); + regval = readl(base + ECC_CEADDR1_OFST); - p->ceinfo.bank = (regval & ECC_CEADDR1_BNKNR_MASK) >> - ECC_CEADDR1_BNKNR_SHIFT; - p->ceinfo.bankgrp = (regval & ECC_CEADDR1_BNKGRP_MASK) >> - ECC_CEADDR1_BNKGRP_SHIFT; - p->ceinfo.col = (regval & ECC_CEADDR1_COL_MASK); + p->ceinfo.bank = FIELD_GET(ECC_CEADDR1_BANK_MASK, regval); + p->ceinfo.bankgrp = FIELD_GET(ECC_CEADDR1_BANKGRP_MASK, regval); + p->ceinfo.col = FIELD_GET(ECC_CEADDR1_COL_MASK, regval); + p->ceinfo.data = readl(base + ECC_CSYND0_OFST); + edac_dbg(2, "ECCCSYN0: 0x%08X ECCCSYN1: 0x%08X ECCCSYN2: 0x%08X\n", readl(base + ECC_CSYND0_OFST), readl(base + ECC_CSYND1_OFST), readl(base + ECC_CSYND2_OFST)); + ue_err: if (!p->ue_cnt) goto out; regval = readl(base + ECC_UEADDR0_OFST); - p->ueinfo.row = (regval & ECC_CEADDR0_RW_MASK); + p->ueinfo.row = FIELD_GET(ECC_CEADDR0_ROW_MASK, regval); + regval = readl(base + ECC_UEADDR1_OFST); - p->ueinfo.bankgrp = (regval & ECC_CEADDR1_BNKGRP_MASK) >> - ECC_CEADDR1_BNKGRP_SHIFT; - p->ueinfo.bank = (regval & ECC_CEADDR1_BNKNR_MASK) >> - ECC_CEADDR1_BNKNR_SHIFT; - p->ueinfo.col = (regval & ECC_CEADDR1_COL_MASK); + p->ueinfo.bankgrp = FIELD_GET(ECC_CEADDR1_BANKGRP_MASK, regval); + p->ueinfo.bank = FIELD_GET(ECC_CEADDR1_BANK_MASK, regval); + p->ueinfo.col = FIELD_GET(ECC_CEADDR1_COL_MASK, regval); + p->ueinfo.data = readl(base + ECC_UESYND0_OFST); out: spin_lock_irqsave(&priv->reglock, flags); @@ -483,7 +475,7 @@ static enum dev_type snps_get_dtype(const void __iomem *base) if (!(regval & DDR_MSTR_MEM_DDR4)) return DEV_UNKNOWN; - regval = (regval & DDR_MSTR_DEV_CFG_MASK) >> DDR_MSTR_DEV_CFG_SHIFT; + regval = FIELD_GET(DDR_MSTR_DEV_CFG_MASK, regval); switch (regval) { case DDR_MSTR_DEV_X4: return DEV_X4; @@ -510,7 +502,8 @@ static bool snps_get_ecc_state(void __iomem *base) { u32 regval; - regval = readl(base + ECC_CFG0_OFST) & ECC_CFG0_MODE_MASK; + regval = readl(base + ECC_CFG0_OFST); + regval = FIELD_GET(ECC_CFG0_MODE_MASK, regval); return (regval == ECC_CFG0_MODE_SECDED); } @@ -697,13 +690,13 @@ static void snps_data_poison_setup(struct snps_edac_priv *priv) if (priv->rank_shift[0]) rank = (hif_addr >> priv->rank_shift[0]) & BIT(0); - regval = (rank << ECC_POISON0_RANK_SHIFT) & ECC_POISON0_RANK_MASK; - regval |= (col << ECC_POISON0_COLUMN_SHIFT) & ECC_POISON0_COLUMN_MASK; + regval = FIELD_PREP(ECC_POISON0_RANK_MASK, rank) | + FIELD_PREP(ECC_POISON0_COL_MASK, col); writel(regval, priv->baseaddr + ECC_POISON0_OFST); - regval = (bankgrp << ECC_POISON1_BG_SHIFT) & ECC_POISON1_BG_MASK; - regval |= (bank << ECC_POISON1_BANKNR_SHIFT) & ECC_POISON1_BANKNR_MASK; - regval |= (row << ECC_POISON1_ROW_SHIFT) & ECC_POISON1_ROW_MASK; + regval = FIELD_PREP(ECC_POISON1_BANKGRP_MASK, bankgrp) | + FIELD_PREP(ECC_POISON1_BANK_MASK, bank) | + FIELD_PREP(ECC_POISON1_ROW_MASK, row); writel(regval, priv->baseaddr + ECC_POISON1_OFST); } @@ -742,10 +735,14 @@ static ssize_t inject_data_poison_show(struct device *dev, { struct mem_ctl_info *mci = to_mci(dev); struct snps_edac_priv *priv = mci->pvt_info; + const char *errstr; + u32 regval; + + regval = readl(priv->baseaddr + ECC_CFG1_OFST); + errstr = FIELD_GET(ECC_CEPOISON_MASK, regval) == ECC_CEPOISON_MASK ? + "Correctable Error" : "UnCorrectable Error"; - return sprintf(data, "Data Poisoning: %s\n\r", - (((readl(priv->baseaddr + ECC_CFG1_OFST)) & 0x3) == 0x3) - ? ("Correctable Error") : ("UnCorrectable Error")); + return sprintf(data, "Data Poisoning: %s\n\r", errstr); } static ssize_t inject_data_poison_store(struct device *dev, @@ -852,7 +849,7 @@ static void snps_setup_column_address_map(struct snps_edac_priv *priv, u32 *addr int index; memtype = readl(priv->baseaddr + DDR_MSTR_OFST); - width = (memtype & DDR_MSTR_BUSWIDTH_MASK) >> DDR_MSTR_BUSWIDTH_SHIFT; + width = FIELD_GET(DDR_MSTR_BUSWIDTH_MASK, memtype); priv->col_shift[0] = 0; priv->col_shift[1] = 1;