From patchwork Wed Sep 20 19:56:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13393394 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 35DDAC04FF7 for ; Wed, 20 Sep 2023 19:58:51 +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=qV4ZAbvVOw38nIdXzoDePbKI/NjTFJCHEatpOBj3NZs=; b=E1WRcnamC7YA8t qtbsVAj2+rmtLw3+3+wZ412fyS7+8rhpkqumRSJFSTRdE9iW/lNMA5GWqCWEj2fjjBzY0k6zlxpBE wQccQS6RYqE1lK53f5d61SaEkFQS/6gjV7yJfmB97dPXrHAWSQ24EQs01g3NheQPEKsZ7y0boSlFM bYreJSBzmsgJKYG1nX5ttT2b0c9M/GVlW4mufzHIKZ3aKQd7PL0lJdGSy18QdbMQHUylEE366OsKz QHzrhicYyF/8q/KZ0rUhNrqrZ//eWkVYkgkAjSwof32wc0Uz8FJlK/dq+Iu1jaRzBsFzJ3PDilcd9 4+8163bfswTYW/xk1Cww==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qj3L6-0044p8-00; Wed, 20 Sep 2023 19:58:24 +0000 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qj3Ky-0044iE-0I for linux-arm-kernel@lists.infradead.org; Wed, 20 Sep 2023 19:58:20 +0000 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-503056c8195so450919e87.1 for ; Wed, 20 Sep 2023 12:58:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695239894; x=1695844694; 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=ISTWIBRRgGQ6k7IaJyUXutua9+M2xYZb0hYe8x2rkfo=; b=e353dJF5qW/XikLZdqSaTD/qo6g6lymM8llz/MALSWoTuHMzGA63K5hQzHCa5hj8t8 cWG+sfsqKGO9Il8GLHrvLXSbrblZvE7sbmvRA6kdytXwy7ZYVBJw90wfnvgrSXefGWgZ DYy9g39klhtS+C9xIaoSf0xm3wPKqhLb9GyV0J2lLbkdTfTL9duzPs1ve1cGrzZhck8Q x9YcJD0e8+sD8iYUBDg/NmDwesGZHzGZ/3IhvNtx15Zb6Da8xREaC6nnwLVnSIG+RYpB jDKrDUVllEPZcTU4eUDB3bNgaChRjgqKtY1Xn42AI/0Q5YO31qzSnFpyt6xuatTFi3KG uoNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695239894; x=1695844694; 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=ISTWIBRRgGQ6k7IaJyUXutua9+M2xYZb0hYe8x2rkfo=; b=EBi0xtnZ1P/otlvKLgMRZTxoRXQLqiEZMHXuG9tdDZH6WSu3k07+gf7/7ZZd6aeoGE umUgRChuPTFdK2qn176CLbY0+CxkDAOBdhlxnmo7M0uHQBFRIKXkggQ1RlzI7BKG41Mj 7KuNpsBjPl+nDsZm5Glq/jPiO9Q207Q8gZ7q8l79kDQHbfTjKq22cZwc2EFNa7E0isV6 KL+9V35Wz0XyFPZ8siIO/NM0LEUSmhvOCeT6HZy4k48U1AAp9FB+EbEBdMdu/OHNPeD9 vsqupXI18O9AHm/LRKLkUKUdFokmCddrtCXJ0+gwKO+XT8EJYFPLZy7FvzHtqNyZabo+ M1JQ== X-Gm-Message-State: AOJu0YwwkMEE6po8KFBgjC65Ju/LowcC5Q7LGT4473S2rMH4Xq3aRkmN gNPQcw/qoYytYsL3CdSVV+0= X-Google-Smtp-Source: AGHT+IF4nAvtsmuyhd6TMdEeySHXDZWhs0pkfRlku1HrRV19gVZn41tiL0zEJS6g0+RM9f4kwNV5zg== X-Received: by 2002:a05:6512:a8b:b0:502:ff3b:7670 with SMTP id m11-20020a0565120a8b00b00502ff3b7670mr4184923lfu.4.1695239894325; Wed, 20 Sep 2023 12:58:14 -0700 (PDT) Received: from localhost ([178.176.81.142]) by smtp.gmail.com with ESMTPSA id m15-20020a056512014f00b00501c6d78f11sm378265lfo.298.2023.09.20.12.58.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 12:58:13 -0700 (PDT) From: Serge Semin To: Michal Simek , Alexander Stein , Borislav Petkov , Tony Luck , James Morse , Mauro Carvalho Chehab , Robert Richter , Rob Herring , Krzysztof Kozlowski Cc: Serge Semin , Punnaiah Choudary Kalluri , Dinh Nguyen , Arnd Bergmann , Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 08/13] EDAC/synopsys: Add individual named ECC IRQs support Date: Wed, 20 Sep 2023 22:56:39 +0300 Message-ID: <20230920195720.32047-9-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230920195720.32047-1-fancer.lancer@gmail.com> References: <20230920195720.32047-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-20230920_125816_198739_030D1728 X-CRM114-Status: GOOD ( 23.15 ) 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 DW uMCTL2 DDRC EDAC driver supports a common unnamed IRQ only. It isn't suitable for the platforms which have the individual IRQ lines for each DDRC event (ECC UE, ECC CE, DFI parity error, Scrubber done, etc). Moreover the DW uMCTL2 DDRC IP-core doesn't have an option to be configured with a common interrupts output line. So in order to have the generic DW uMCTL2 DDR controller supported by the driver add the individual (per DDRC event) IRQs request support. There is not much to do really since the common IRQs handler has already been split up into the sub-handlers: first try to request the individual IRQs; if failed fallback to using the common IRQ. The IRQ names are used in accordance with the DW uMCTL2 DDRC DT-bindings. Signed-off-by: Serge Semin --- drivers/edac/synopsys_edac.c | 91 ++++++++++++++++++++++++++++++++---- 1 file changed, 81 insertions(+), 10 deletions(-) diff --git a/drivers/edac/synopsys_edac.c b/drivers/edac/synopsys_edac.c index 9dde43636199..19b7bce06e13 100644 --- a/drivers/edac/synopsys_edac.c +++ b/drivers/edac/synopsys_edac.c @@ -1533,25 +1533,96 @@ static void snps_mc_free(struct mem_ctl_info *mci) edac_mc_free(mci); } -static int snps_setup_irq(struct mem_ctl_info *mci) +/** + * snps_request_ind_irq - Request individual DDRC IRQs. + * @mci: EDAC memory controller instance. + * + * Return: 0 if the IRQs were successfully requested, 1 if the individual IRQs + * are unavailable, otherwise negative errno. + */ +static int snps_request_ind_irq(struct mem_ctl_info *mci) { struct snps_edac_priv *priv = mci->pvt_info; - int ret, irq; + struct device *dev = &priv->pdev->dev; + int rc, irq; - irq = platform_get_irq(priv->pdev, 0); - if (irq < 0) { - edac_printk(KERN_ERR, EDAC_MC, - "No IRQ %d in DT\n", irq); + irq = platform_get_irq_byname_optional(priv->pdev, "ecc_ce"); + if (irq == -ENXIO) + return 1; + if (irq < 0) + return irq; + + rc = devm_request_irq(dev, irq, snps_ce_irq_handler, 0, "ecc_ce", mci); + if (rc) { + edac_printk(KERN_ERR, EDAC_MC, "Failed to request ECC CE IRQ\n"); + return rc; + } + + irq = platform_get_irq_byname(priv->pdev, "ecc_ue"); + if (irq < 0) return irq; + + rc = devm_request_irq(dev, irq, snps_ue_irq_handler, 0, "ecc_ue", mci); + if (rc) { + edac_printk(KERN_ERR, EDAC_MC, "Failed to request ECC UE IRQ\n"); + return rc; + } + + return 0; +} + +/** + * snps_request_com_irq - Request common DDRC IRQ. + * @mci: EDAC memory controller instance. + * + * It first attempts to get the named IRQ. If failed the method fallbacks + * to first available one. + * + * Return: 0 if the IRQ was successfully requested otherwise negative errno. + */ +static int snps_request_com_irq(struct mem_ctl_info *mci) +{ + struct snps_edac_priv *priv = mci->pvt_info; + struct device *dev = &priv->pdev->dev; + int rc, irq; + + irq = platform_get_irq_byname_optional(priv->pdev, "ecc"); + if (irq < 0) { + irq = platform_get_irq(priv->pdev, 0); + if (irq < 0) + return irq; } - ret = devm_request_irq(&priv->pdev->dev, irq, snps_com_irq_handler, - 0, dev_name(&priv->pdev->dev), mci); - if (ret < 0) { + rc = devm_request_irq(dev, irq, snps_com_irq_handler, 0, "ecc", mci); + if (rc) { edac_printk(KERN_ERR, EDAC_MC, "Failed to request IRQ\n"); - return ret; + return rc; } + return 0; +} + +/** + * snps_setup_irq - Request and enable DDRC IRQs. + * @mci: EDAC memory controller instance. + * + * It first tries to get and request individual IRQs. If failed the method + * fallbacks to the common IRQ line case. The IRQs will be enabled only if + * some of these requests have been successful. + * + * Return: 0 if IRQs were successfully setup otherwise negative errno. + */ +static int snps_setup_irq(struct mem_ctl_info *mci) +{ + struct snps_edac_priv *priv = mci->pvt_info; + int rc; + + rc = snps_request_ind_irq(mci); + if (rc > 0) + rc = snps_request_com_irq(mci); + if (rc) + return rc; + snps_enable_irq(priv); return 0;