From patchwork Wed Aug 14 14:56:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Renner Berthing X-Patchwork-Id: 13763604 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 F0B51C531DD for ; Wed, 14 Aug 2024 14:57:59 +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=xX3QxYVlJlCXw/o9torEFfjlXHZoiv2pvdbzskElP4A=; b=meWzSiJu2qmyBH 3NcF6lG+4KD7K+/nJT4k9Rvsnght8YifJSyQV/cg0kcvtdA5GoO+cOtvnErfchEgbTXfZmVmTxxnL Kxv7Pt6OlpkOk0Jf7uyRk23xxH72XNSGV2wYRPIR9UVAWYML1uVGM+IwdW98mUBCq/AuVm7vh4sSR et6p582u52jhAUA3clA6xGfWveobm12tQcVeuySqaNmmqe/IY2bOrr0CIEOp2ZIV+dfJakc0pc4Oq 6gXhuaqKWp4FO1KkU5uVZqzMHJ+xUUglnyArWtTL/qCX2RHATZCN7MMXSd5vqg1qcVILdgwsBW7tc XshYDnGCw5ZIg/UDVVYA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seFRk-00000007OKY-2EKj; Wed, 14 Aug 2024 14:57:56 +0000 Received: from smtp-relay-internal-1.canonical.com ([185.125.188.123]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seFQi-00000007O1o-3H8o for linux-riscv@lists.infradead.org; Wed, 14 Aug 2024 14:56:55 +0000 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 33167402D8 for ; Wed, 14 Aug 2024 14:56:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1723647409; bh=sxLtNA8jlC2UdtFSfJSplJrgcfSiQ+BvRmrjXsCvtrQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aZyojXWXk6kVEPjLQLsZPfc7+y5DtkJE0z6HdgydLNNJGeJyUb1zPSjwmozQFmfVP Bfwh22gcZdB85BicWogqesOlwsnXRSvZjGz2B7X7wDW3CxHRWseYowAYR0pal9Aes2 QczuvtGEGfR0sOhO090hIvXR/v8hFXwJWO0JCu+BD+GGGhzCCdKzLm5Bh+2cLtTEhz vWjIoN09UdHXSnQPqBrKyxCWN+cSOff1mn7nDAKQeg3i40gsheSr4ws6zwnFKXCMxp sSvIL20qgOH6cvCZIxbWEk5KTMor947hdURdijxV5u6DUG95UmMfS5dnGeCILb12a5 fi1G4jYMMBTDg== Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-5bba487c10eso10575a12.1 for ; Wed, 14 Aug 2024 07:56:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723647405; x=1724252205; 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=sxLtNA8jlC2UdtFSfJSplJrgcfSiQ+BvRmrjXsCvtrQ=; b=ITlHj12ClHPbLorPP9vHYVftxGwnjmvXpmduHyp+4m2V4lIWRzN6MGr3H8OtwWyrEJ wx0jm7M6/1C2qwLxDkEkh+lzFkcMSRTsKSj6vNOrumFXGtxJSj3fajbJ54fuuSD3DAlv ReWyKv/6ab/Otv8iEDSlwA3/+VaSlCKNXOHvlxxl+5iORZZ6zAJ3oqSDIaWYVl76HBPh +PcxSxFigqbo9vAwPfZBY508+Pm6gz7F9qV9sFKTXEe9FfgYBBHg5n+ecyNz6SuaW1iI VXjSNNprHqrhenbPRbeUX0ffJDC95OoEbZsKlpr0YDocsveZEnRCxeWzFCSsDJUf5wG7 6Q4Q== X-Forwarded-Encrypted: i=1; AJvYcCUaO7o5zKLv1d9kBhbCcRyuQPltUKOuyyVmHjDo7sS03BO4TX+h+IymnuyFlk1bf2T8poOIyiwvzmUW5OHxQ3EDLasF+HzsVIVj/NZgtsiP X-Gm-Message-State: AOJu0YwLcNde8r3FFP/iNvrErsdPRNQjj3lnBSZNixoF4Yxm0LZOI+Kj UBCSADKlEd1Okh0I/fzgehyuhwCsuDDtFSHv68uAmj1EiigcXqkA7B7CoZ7q/7v3V9xSCRTA0xX wjdbYLyuRHSisBr/aX8VUFdj62/mHMnngS/lNQ7gr849kQQX/unmtH0RJn2HE6RaWYZxAKmndvq /pk3jMOQ== X-Received: by 2002:a17:906:d7d3:b0:a7a:bcbc:f7e1 with SMTP id a640c23a62f3a-a8366c32951mr208988966b.15.1723647405480; Wed, 14 Aug 2024 07:56:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHc/yfSJrvFTuMnyZ4+Y0SRDIMqZrC+J2GedSuxes8D5p74/pWwqtE1Vv2fGbgkAkF4zdDaxg== X-Received: by 2002:a17:906:d7d3:b0:a7a:bcbc:f7e1 with SMTP id a640c23a62f3a-a8366c32951mr208986766b.15.1723647404802; Wed, 14 Aug 2024 07:56:44 -0700 (PDT) Received: from stitch.. ([2a01:4262:1ab:c:bbf4:eba3:898f:7501]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a80f411bdcbsm182316866b.105.2024.08.14.07.56.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 07:56:44 -0700 (PDT) From: Emil Renner Berthing To: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Anup Patel Cc: Thomas Gleixner , Paul Walmsley , Samuel Holland , Palmer Dabbelt , Albert Ou Subject: [PATCH v1 1/9] Revert "irqchip/sifive-plic: Chain to parent IRQ after handlers are ready" Date: Wed, 14 Aug 2024 16:56:33 +0200 Message-ID: <20240814145642.344485-2-emil.renner.berthing@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240814145642.344485-1-emil.renner.berthing@canonical.com> References: <20240814145642.344485-1-emil.renner.berthing@canonical.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240814_075653_060866_CB8EB635 X-CRM114-Status: GOOD ( 16.60 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org This reverts commit e306a894bd511804ba9db7c00ca9cc05b55df1f2. This is a prerequisite to reverting the patch converting the PLIC into a platform driver. Unfortunately this breaks booting the Allwinner D1 SoC. Fixes: 8ec99b033147 ("irqchip/sifive-plic: Convert PLIC driver into a platform driver") Signed-off-by: Emil Renner Berthing --- drivers/irqchip/irq-sifive-plic.c | 34 +++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c index 9e22f7e378f5..8fb183ced1e7 100644 --- a/drivers/irqchip/irq-sifive-plic.c +++ b/drivers/irqchip/irq-sifive-plic.c @@ -85,7 +85,7 @@ struct plic_handler { struct plic_priv *priv; }; static int plic_parent_irq __ro_after_init; -static bool plic_global_setup_done __ro_after_init; +static bool plic_cpuhp_setup_done __ro_after_init; static DEFINE_PER_CPU(struct plic_handler, plic_handlers); static int plic_irq_set_type(struct irq_data *d, unsigned int type); @@ -487,8 +487,10 @@ static int plic_probe(struct platform_device *pdev) unsigned long plic_quirks = 0; struct plic_handler *handler; u32 nr_irqs, parent_hwirq; + struct irq_domain *domain; struct plic_priv *priv; irq_hw_number_t hwirq; + bool cpuhp_setup; if (is_of_node(dev->fwnode)) { const struct of_device_id *id; @@ -547,6 +549,14 @@ static int plic_probe(struct platform_device *pdev) continue; } + /* Find parent domain and register chained handler */ + domain = irq_find_matching_fwnode(riscv_get_intc_hwnode(), DOMAIN_BUS_ANY); + if (!plic_parent_irq && domain) { + plic_parent_irq = irq_create_mapping(domain, RV_IRQ_EXT); + if (plic_parent_irq) + irq_set_chained_handler(plic_parent_irq, plic_handle_irq); + } + /* * When running in M-mode we need to ignore the S-mode handler. * Here we assume it always comes later, but that might be a @@ -587,35 +597,25 @@ static int plic_probe(struct platform_device *pdev) goto fail_cleanup_contexts; /* - * We can have multiple PLIC instances so setup global state + * We can have multiple PLIC instances so setup cpuhp state * and register syscore operations only once after context * handlers of all online CPUs are initialized. */ - if (!plic_global_setup_done) { - struct irq_domain *domain; - bool global_setup = true; - + if (!plic_cpuhp_setup_done) { + cpuhp_setup = true; for_each_online_cpu(cpu) { handler = per_cpu_ptr(&plic_handlers, cpu); if (!handler->present) { - global_setup = false; + cpuhp_setup = false; break; } } - - if (global_setup) { - /* Find parent domain and register chained handler */ - domain = irq_find_matching_fwnode(riscv_get_intc_hwnode(), DOMAIN_BUS_ANY); - if (domain) - plic_parent_irq = irq_create_mapping(domain, RV_IRQ_EXT); - if (plic_parent_irq) - irq_set_chained_handler(plic_parent_irq, plic_handle_irq); - + if (cpuhp_setup) { cpuhp_setup_state(CPUHP_AP_IRQ_SIFIVE_PLIC_STARTING, "irqchip/sifive/plic:starting", plic_starting_cpu, plic_dying_cpu); register_syscore_ops(&plic_irq_syscore_ops); - plic_global_setup_done = true; + plic_cpuhp_setup_done = true; } } From patchwork Wed Aug 14 14:56:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Renner Berthing X-Patchwork-Id: 13763602 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 34CACC52D7B for ; Wed, 14 Aug 2024 14:57:58 +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=KI54jcscEOaXAtXYGbuawsFMFp43RsH4SpPjncDdiaA=; b=Ux3V/T/9c4jv66 StrbGn/oBDCQ+pZmzx5SxZGcJoUWlMm6P1nifyPvlsJm8kj7YzP/Xl5+1Q0xPpbc/PYfXUkTOMbdd PhiKP96UFLAbOKxk0PqYMMT60MpVdzRetqC+f8dfjfKEIjWG4VNq/Yno/bxqi9owAzjfK5FCzdC0k ck7S1SFvwtwbs8KkPrZXOh3QzaM+25HU8HFO5MVhRYriYGeXfU5EffV0/ti6A41yKE8AKq0QRUey7 Q3VdMn4yJCo05DKf09L5Yp99lUoS2jAuHSg9Cy8bBtDraBIDwfEUdWdMfe4on+DgoFC25om67R8dm M7nffsUsCKBTw6zDi3wg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seFRj-00000007OJY-1kTs; Wed, 14 Aug 2024 14:57:55 +0000 Received: from smtp-relay-internal-1.canonical.com ([185.125.188.123]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seFQi-00000007O1s-3KD4 for linux-riscv@lists.infradead.org; Wed, 14 Aug 2024 14:56:54 +0000 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id C1A53402EE for ; Wed, 14 Aug 2024 14:56:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1723647409; bh=EVnujh8KUTCiCooAY0SE0ZN2aSfYIbE0OsxWHQEB47A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pnVXmcKy0S46jptl83+Tenc9qxvnrofYSGheyjS3BXk9+2LehXVq5LugNtzNK8WnE 6f2CaQExjKgj1u8Krja3sk1w7da2Vouwk8k8L0d3QAndW3oIRmv8Qv659Gz6HjCoFw /JBTJCZVyL9T2mdlfaS9Fa5IiZgZtrn34XmpELyehbIu0m1tCYWQk5/8x5zbyio+q0 LZihxWis1Hikid3eSjdN8oMbyO/fzcY/dK1XQNAO/3uAroBykrI9UT+vhrVHLv8umb qcFYJfdUNNaYZIA+0G7vBFQmr3EKmSD+SADPw2AITPBBPySKn+aqcQqg2KvNEA1SCs PtjlOkUFZWvkQ== Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a79c35c28f1so534101566b.3 for ; Wed, 14 Aug 2024 07:56:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723647407; x=1724252207; 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=EVnujh8KUTCiCooAY0SE0ZN2aSfYIbE0OsxWHQEB47A=; b=cmrH+K4X/ICVeuhbERRqY7ogMOrKofznt6s6df+EvfbJj5B9466tTD20LxqO2R0rAt oNyBIPzf/vUxUY1WHvgSjaXpYf7882O/fxdEOgarRgB6ceDyjayAkpidh/KIZQowopeS iZsWWNzsOk7rsuzUlPMOHjbcch2ObJegdl7yHhAfuS68CMXyeT3LQjNWu2bR3uPe41sb FoNFYCFaJxIfiaiY9HZQYeduiqp4C6yIRR+rAZY97bKJ4BW3LvkQEnkwYEbxZd6jPrqr WPUe4cwnXyPIt68zULWkDMu/OoU/fsfSQg4BRPHkUWIEKY9LDqL3zKCSTzAlVS915rKn mq6A== X-Forwarded-Encrypted: i=1; AJvYcCUlfM8murB4A0SrusvK1F2mkEvgLkuOMHSGEpGexVUAKg36959Kc++FOB1wMyBDzhcApQm/uZWCOg+6rPMJJdsDYsyBlVi6Ra+X2VhrE1Mq X-Gm-Message-State: AOJu0YwqgPgMIEPFxJ6HuJSdWiGECeK9GFZz/DIrLMtqUG1+2GJ3dUNv L3yFpvTN8g+5UFYxfpT2KSmOyYMSIzBQBpSm7cs41EsuU+yAJvWp1SnqTB8caBYYuND2Y/eUSVX nHgBmE6xXphlPLgLVw/5LcrQq7RDBISOF87Ms0nE3bUPXa0KA6Fl5/8sGN+U3TdvVfOCTuVBHB6 PFepEnng== X-Received: by 2002:a17:906:cadd:b0:a7a:b620:aa3a with SMTP id a640c23a62f3a-a8367034961mr201276366b.52.1723647406656; Wed, 14 Aug 2024 07:56:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFLxomAnKFjWs6A9VwCQwHg3vLbUdpfFg+VMb2VSAn6s+ZN+y2p/gB4Mu5QbgZontrDcC2N0Q== X-Received: by 2002:a17:906:cadd:b0:a7a:b620:aa3a with SMTP id a640c23a62f3a-a8367034961mr201273066b.52.1723647405821; Wed, 14 Aug 2024 07:56:45 -0700 (PDT) Received: from stitch.. ([2a01:4262:1ab:c:bbf4:eba3:898f:7501]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a80f411bdcbsm182316866b.105.2024.08.14.07.56.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 07:56:45 -0700 (PDT) From: Emil Renner Berthing To: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Anup Patel Cc: Thomas Gleixner , Paul Walmsley , Samuel Holland , Palmer Dabbelt , Albert Ou Subject: [PATCH v1 2/9] Revert "irqchip/sifive-plic: Avoid explicit cpumask allocation on stack" Date: Wed, 14 Aug 2024 16:56:34 +0200 Message-ID: <20240814145642.344485-3-emil.renner.berthing@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240814145642.344485-1-emil.renner.berthing@canonical.com> References: <20240814145642.344485-1-emil.renner.berthing@canonical.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240814_075653_056731_AFE6562E X-CRM114-Status: GOOD ( 11.75 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org This reverts commit a7fb69ffd7ce438a259b2f9fbcebc62f5caf2d4f. This is a prerequisite to reverting the patch converting the PLIC into a platform driver. Unfortunately this breaks booting the Allwinner D1 SoC. Fixes: 8ec99b033147 ("irqchip/sifive-plic: Convert PLIC driver into a platform driver") Signed-off-by: Emil Renner Berthing --- drivers/irqchip/irq-sifive-plic.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c index 8fb183ced1e7..f3d4cb9e34f7 100644 --- a/drivers/irqchip/irq-sifive-plic.c +++ b/drivers/irqchip/irq-sifive-plic.c @@ -164,12 +164,15 @@ static int plic_set_affinity(struct irq_data *d, const struct cpumask *mask_val, bool force) { unsigned int cpu; + struct cpumask amask; struct plic_priv *priv = irq_data_get_irq_chip_data(d); + cpumask_and(&amask, &priv->lmask, mask_val); + if (force) - cpu = cpumask_first_and(&priv->lmask, mask_val); + cpu = cpumask_first(&amask); else - cpu = cpumask_first_and_and(&priv->lmask, mask_val, cpu_online_mask); + cpu = cpumask_any_and(&amask, cpu_online_mask); if (cpu >= nr_cpu_ids) return -EINVAL; From patchwork Wed Aug 14 14:56:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Renner Berthing X-Patchwork-Id: 13763605 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 5168EC531DE for ; Wed, 14 Aug 2024 14:58:01 +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=TGTqgGHwShCWmPOljlqX+nexFBq7dv43rq8Q5aF3VuA=; b=QQR4d3XFAQ3qLO z9v7BQC6U7DXdPGt9K+z2pNfvBvVNgzpuWFGhFQhKlWo7iI6KHLwo82U9buGf0OHhmwSGx28v3bgD 9L64SOrCB9mc7DHYgT1kuVJAAQVgkqNejeu0PMSC1hyexfh9aH5m6PIANhCOFlJMhWdLA2fbWibpN Q7STAcEAxa4kh9KTWjM5ixuJUtCyAwYy2DCCeFT+X/riwPUKfVcjPL1N6t+Qen/p9+lR6DiZr9ZTR HwYGIbA57QIXUcOc0v6LanJWp0Ng7SrhbgEt2NG0mrOfL+UJmt1pM0re4iDzphsc3x6xa79cA+y9y Eq+3jVKjz4NMrAdpFJvg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seFRm-00000007OMA-35oU; Wed, 14 Aug 2024 14:57:58 +0000 Received: from smtp-relay-internal-0.canonical.com ([185.125.188.122]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seFQl-00000007O2c-1kgj for linux-riscv@lists.infradead.org; Wed, 14 Aug 2024 14:56:57 +0000 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id ACCE74596E for ; Wed, 14 Aug 2024 14:56:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1723647409; bh=BLF9xhELpEDy4F+zOs829324v9jnXI7dzpQV04pN/74=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cQpdFYXi5LPhq9jS69QNMfn9zwqe9/6CQvgpxMcI41EqqsfqPOs+oHwtQJjioc7ni w50DRCj1hiI9qtng0LReEwcobXSaODD2XLy4wGBgvpBkc/BAoNoK3COwFHTYt92EIa 44859Xxv1UlSXbSl4Zx7K8euCwk6mbvB4HPEXnPrCkeIyVFMupSDx0HDNzDhioBTcn qm2iePwkio++xoCbmWSNhKRhOO5t0qK8+SE7vNIlmIuTWnOjkj8gweTm0yvsVGCgQu ns2TJGNDBLW4AArpIIDNicE6fijIYfwObV+HngFxUBq4AOzQ+2H1BV9PsNdjY5rI0O ZotlhgK6cjRDA== Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a7aa3181bc2so480313666b.0 for ; Wed, 14 Aug 2024 07:56:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723647407; x=1724252207; 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=BLF9xhELpEDy4F+zOs829324v9jnXI7dzpQV04pN/74=; b=fkNcV9ZtWGkpv74jE4nVPi2nkf/ENkwdTxsEZXr+VeWxk7Y/TFpgchKac1SPsQ4AMW 0m78749lo/E54LzZHfZ6eW5u3Hz81T4vK4Yt6DFzcD/nsccHUws1FtrLVUrhJUoIgX7Y bJF9gfGhVC6jbfESLeT0+jP9HMFJhf5dZomE8795epRHcZZNAnUajPoicHXlVYsDzbgo f4JOVDk2+yMrQuGGRvSnjOCeNHVuaxJ+fOYEJ/I1aYeQ6/eVudfTyYV3UZrGHslkQWdI gnzM5rRgWbWxAvGHwFsJf3jCus6CCSYlJo/tIad+k8n3YXOgISa82omVKmWmPpjPo3d8 /csw== X-Forwarded-Encrypted: i=1; AJvYcCWdO+4ngumPKPHOT367XqAsoH+wGDjYoF0O6pbMpccjDkotsuOSbA46XpYBWAMyy58aVvWCOwwa7k0f0tRHqviCpXYjKsSARznHnLKzxhrb X-Gm-Message-State: AOJu0Yyfrok2qoBYLjHxqxxmVY0AJXfNwCDx04SiuschrSx7ihx3eh2z BWGXVGCD5Wr2HrxSAQZgHzWVl8R7jsKdhom3iEUpLbWg5aqbE9UPJUS0tobO52TMCcw0RwVupkU N5DVbEZO3/dERc3FxMssX1cDx6NVytQuQMA7dAvS3HB8ovdnzTtK0S8JG+n4MnFGYVAdfcapTst E2k9mKXg== X-Received: by 2002:a17:907:d2cc:b0:a7a:b73f:7584 with SMTP id a640c23a62f3a-a8366d5cb0bmr234838966b.34.1723647407410; Wed, 14 Aug 2024 07:56:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHCL8sD4kYOs9Y0VCnij/xL6fidS5/kQa/PnagADzJKqqhOA3GoZ+LuJZSindcfAjitSTS30g== X-Received: by 2002:a17:907:d2cc:b0:a7a:b73f:7584 with SMTP id a640c23a62f3a-a8366d5cb0bmr234836466b.34.1723647406648; Wed, 14 Aug 2024 07:56:46 -0700 (PDT) Received: from stitch.. ([2a01:4262:1ab:c:bbf4:eba3:898f:7501]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a80f411bdcbsm182316866b.105.2024.08.14.07.56.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 07:56:46 -0700 (PDT) From: Emil Renner Berthing To: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Anup Patel Cc: Thomas Gleixner , Paul Walmsley , Samuel Holland , Palmer Dabbelt , Albert Ou Subject: [PATCH v1 3/9] Revert "irqchip/sifive-plic: Improve locking safety by using irqsave/irqrestore" Date: Wed, 14 Aug 2024 16:56:35 +0200 Message-ID: <20240814145642.344485-4-emil.renner.berthing@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240814145642.344485-1-emil.renner.berthing@canonical.com> References: <20240814145642.344485-1-emil.renner.berthing@canonical.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240814_075655_762779_6D45BEEF X-CRM114-Status: GOOD ( 12.69 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org This reverts commit abb7205794900503d6358ef1fb645373753a794d. This is a prerequisite to reverting the patch converting the PLIC into a platform driver. Unfortunately this breaks booting the Allwinner D1 SoC. Fixes: 8ec99b033147 ("irqchip/sifive-plic: Convert PLIC driver into a platform driver") Signed-off-by: Emil Renner Berthing --- drivers/irqchip/irq-sifive-plic.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c index f3d4cb9e34f7..cbccd1da3ea1 100644 --- a/drivers/irqchip/irq-sifive-plic.c +++ b/drivers/irqchip/irq-sifive-plic.c @@ -103,11 +103,9 @@ static void __plic_toggle(void __iomem *enable_base, int hwirq, int enable) static void plic_toggle(struct plic_handler *handler, int hwirq, int enable) { - unsigned long flags; - - raw_spin_lock_irqsave(&handler->enable_lock, flags); + raw_spin_lock(&handler->enable_lock); __plic_toggle(handler->enable_base, hwirq, enable); - raw_spin_unlock_irqrestore(&handler->enable_lock, flags); + raw_spin_unlock(&handler->enable_lock); } static inline void plic_irq_toggle(const struct cpumask *mask, @@ -244,7 +242,6 @@ static int plic_irq_set_type(struct irq_data *d, unsigned int type) static int plic_irq_suspend(void) { unsigned int i, cpu; - unsigned long flags; u32 __iomem *reg; struct plic_priv *priv; @@ -262,12 +259,12 @@ static int plic_irq_suspend(void) if (!handler->present) continue; - raw_spin_lock_irqsave(&handler->enable_lock, flags); + raw_spin_lock(&handler->enable_lock); for (i = 0; i < DIV_ROUND_UP(priv->nr_irqs, 32); i++) { reg = handler->enable_base + i * sizeof(u32); handler->enable_save[i] = readl(reg); } - raw_spin_unlock_irqrestore(&handler->enable_lock, flags); + raw_spin_unlock(&handler->enable_lock); } return 0; @@ -276,7 +273,6 @@ static int plic_irq_suspend(void) static void plic_irq_resume(void) { unsigned int i, index, cpu; - unsigned long flags; u32 __iomem *reg; struct plic_priv *priv; @@ -294,12 +290,12 @@ static void plic_irq_resume(void) if (!handler->present) continue; - raw_spin_lock_irqsave(&handler->enable_lock, flags); + raw_spin_lock(&handler->enable_lock); for (i = 0; i < DIV_ROUND_UP(priv->nr_irqs, 32); i++) { reg = handler->enable_base + i * sizeof(u32); writel(handler->enable_save[i], reg); } - raw_spin_unlock_irqrestore(&handler->enable_lock, flags); + raw_spin_unlock(&handler->enable_lock); } } From patchwork Wed Aug 14 14:56:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Renner Berthing X-Patchwork-Id: 13763603 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 76505C52D7D for ; Wed, 14 Aug 2024 14:58: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=Avyf3l3dM278FuxwwIquAdfHAUCZm06HGAwwZibQyac=; b=0g5OqL8iErEgBt 3h7hw0kO+JqHnUP+PsAYvMr0NeHq0TQ/FLB6EjxC/9XDuxclEFU6H2VdaXXWuzHKsNEeytOiHQf/a kT6nmHqAlLCYPztkiU1XVMRvkwCtotA6K/sYOo1LUmWBLxPhjyNeS7tSN8b3L1LL7m2szhRprI8yT iEUWwaiH/gWhzN2C7BCCD9Y4xxJKu1qvBekO6Ab1YTuNTAt6ax4G8yk7RSReCb7BdGyrthQb0s7Lc rbh4Sx3Tgaw7W8HHfnE1mAhxr74HxD9RnX4r9r4UBoqcl7LdccQ/bD0Iwpw/SuFN6vG2m1EC4s51k Z5eQSeXhKQkAEl/v+JCg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seFRl-00000007OLC-1ZuA; Wed, 14 Aug 2024 14:57:57 +0000 Received: from smtp-relay-internal-1.canonical.com ([185.125.188.123]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seFQi-00000007O1p-3G6w for linux-riscv@lists.infradead.org; Wed, 14 Aug 2024 14:56:55 +0000 Received: from mail-lj1-f197.google.com (mail-lj1-f197.google.com [209.85.208.197]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id AB353402ED for ; Wed, 14 Aug 2024 14:56:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1723647409; bh=2pXv+ysc8ToXtQ+ey2s0xoldhLum5hMAS4b7voRBoVU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EylwTyxsIh2eCpMDk7Ujf7R8k8f7DvHbxaUouUtLmKXejCjRWA1Txkxc5jenfSi5b RGfaU8dUj1Kn0n/y2R7lSf/fHHQu6D5e3cDRzQJt4Qo1Mf+I2ZjImQRXANwvvotNn+ RgChsvMWKg2nqMyrWGp3JieLdKUnUqkStEbRk9QAF7pXck+yB8ePTwTHht2pdzMChE MHeBrgnzcz3fDtXl4gcJCUnPxqDFQtRJgtiw1sca6Z2SUwxdPRgwf/8Tap+hIpdcss VtX+pmkpEDHqgJJ5xecCmNlJvJ1oUei3QfZmJIH236FeXl4/VZu8gn3rgTclG9GgxL IjozPZ6KFn76Q== Received: by mail-lj1-f197.google.com with SMTP id 38308e7fff4ca-2ef3157ae4cso74104571fa.2 for ; Wed, 14 Aug 2024 07:56:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723647408; x=1724252208; 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=2pXv+ysc8ToXtQ+ey2s0xoldhLum5hMAS4b7voRBoVU=; b=HwpnA6WOnaIxOCW1oFxTzL58+o9DhNFMPuU8fD8dVJzzFBKlqr4S+0E2WDI+jOiDHu P0sHkJkidFDsZXtTSG8amz3jsCvufv8xcJNFiCeaIY4UlBYeDI4G2nIgrQtSsK/vN8Dr 2bSHyWN3UX/HqtNSUfYlEwcYio2P6rTLgPMSe0BGmll628IWetQRSukpkMeDtNQZbOCh p/Id0DMAnlHR8M6cA0PqADxf9jXi4F4FjaiDmXgBkb7j/BVlmKcScJMKRPS+QpDIl9tQ ErBiwDKyd715iT2c787AW6Hv/OzzTcQhkYKLPs2B9ttwM3fW02dLikX/iveJNsGT3Xyu KuyA== X-Forwarded-Encrypted: i=1; AJvYcCUGpQpsQ3+2z931hE08M+2DuyW/CmNXukZvZedvfcHqIjEo7c5egZjO0AKWWbUNH2COiBNE4Z4/JKreVqxYbZRJGpSeiwJJMGXijc9yEsdh X-Gm-Message-State: AOJu0Yxo4ls4Ix0YhhBSgikCJPdmNEV0Ai4urLqr0e6ByNBGPfFllvHe Dxus1lx8IJHx4hsXw58hQhIvno0dCCjSkbz4uzAh9qS+xHW9rqiupZXzqgrw/6yjeU+ZytW0sL5 4d9y62POmlGN8hGp3F31/KTlnJe1tz86QScYgPdLvcxCb1kiO/37Pk1gv0rtIwJmFk9Z9ehI2kA 07jMAuyg== X-Received: by 2002:a05:6512:3191:b0:52c:a20e:4da4 with SMTP id 2adb3069b0e04-532edbc05f7mr2571841e87.57.1723647408465; Wed, 14 Aug 2024 07:56:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF17QlVvCQ6SWsWAYWiNwbZ+WPFwxcRul+yZa2TRiM0FXs/GSQZrNmNRfbmzWrcCJByT8/6lw== X-Received: by 2002:a05:6512:3191:b0:52c:a20e:4da4 with SMTP id 2adb3069b0e04-532edbc05f7mr2571804e87.57.1723647407430; Wed, 14 Aug 2024 07:56:47 -0700 (PDT) Received: from stitch.. ([2a01:4262:1ab:c:bbf4:eba3:898f:7501]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a80f411bdcbsm182316866b.105.2024.08.14.07.56.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 07:56:47 -0700 (PDT) From: Emil Renner Berthing To: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Anup Patel Cc: Thomas Gleixner , Paul Walmsley , Samuel Holland , Palmer Dabbelt , Albert Ou Subject: [PATCH v1 4/9] Revert "irqchip/sifive-plic: Parse number of interrupts and contexts early in plic_probe()" Date: Wed, 14 Aug 2024 16:56:36 +0200 Message-ID: <20240814145642.344485-5-emil.renner.berthing@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240814145642.344485-1-emil.renner.berthing@canonical.com> References: <20240814145642.344485-1-emil.renner.berthing@canonical.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240814_075653_153795_BE19631B X-CRM114-Status: GOOD ( 15.65 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org This reverts commit 95652106478030f54620b1f0d28f78ab110b3212. This is a prerequisite to reverting the patch converting the PLIC into a platform driver. Unfortunately this breaks booting the Allwinner D1 SoC. Fixes: 8ec99b033147 ("irqchip/sifive-plic: Convert PLIC driver into a platform driver") Signed-off-by: Emil Renner Berthing --- drivers/irqchip/irq-sifive-plic.c | 43 +++++++------------------------ 1 file changed, 10 insertions(+), 33 deletions(-) diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c index cbccd1da3ea1..b4c4050a02fb 100644 --- a/drivers/irqchip/irq-sifive-plic.c +++ b/drivers/irqchip/irq-sifive-plic.c @@ -423,34 +423,6 @@ static const struct of_device_id plic_match[] = { {} }; -static int plic_parse_nr_irqs_and_contexts(struct platform_device *pdev, - u32 *nr_irqs, u32 *nr_contexts) -{ - struct device *dev = &pdev->dev; - int rc; - - /* - * Currently, only OF fwnode is supported so extend this - * function for ACPI support. - */ - if (!is_of_node(dev->fwnode)) - return -EINVAL; - - rc = of_property_read_u32(to_of_node(dev->fwnode), "riscv,ndev", nr_irqs); - if (rc) { - dev_err(dev, "riscv,ndev property not available\n"); - return rc; - } - - *nr_contexts = of_irq_count(to_of_node(dev->fwnode)); - if (WARN_ON(!(*nr_contexts))) { - dev_err(dev, "no PLIC context available\n"); - return -EINVAL; - } - - return 0; -} - static int plic_parse_context_parent(struct platform_device *pdev, u32 context, u32 *parent_hwirq, int *parent_cpu) { @@ -499,26 +471,31 @@ static int plic_probe(struct platform_device *pdev) plic_quirks = (unsigned long)id->data; } - error = plic_parse_nr_irqs_and_contexts(pdev, &nr_irqs, &nr_contexts); - if (error) - return error; - priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; priv->dev = dev; priv->plic_quirks = plic_quirks; - priv->nr_irqs = nr_irqs; priv->regs = devm_platform_ioremap_resource(pdev, 0); if (WARN_ON(!priv->regs)) return -EIO; + of_property_read_u32(to_of_node(dev->fwnode), "riscv,ndev", &nr_irqs); + if (WARN_ON(!nr_irqs)) + return -EINVAL; + + priv->nr_irqs = nr_irqs; + priv->prio_save = devm_bitmap_zalloc(dev, nr_irqs, GFP_KERNEL); if (!priv->prio_save) return -ENOMEM; + nr_contexts = of_irq_count(to_of_node(dev->fwnode)); + if (WARN_ON(!nr_contexts)) + return -EINVAL; + for (i = 0; i < nr_contexts; i++) { error = plic_parse_context_parent(pdev, i, &parent_hwirq, &cpu); if (error) { From patchwork Wed Aug 14 14:56:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Renner Berthing X-Patchwork-Id: 13763608 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 5A6E8C3DA4A for ; Wed, 14 Aug 2024 14:58: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=zihMuQGDg1FKSTdBTqwkCjkqSwBYLP11ilVLw7M2KkM=; b=1AlKOo7adibVxG ZUEvin78QfaoauYhn/peofGa5NU38r2ynfF1ou3Vqgn/Uq1Kn+CrUoOkM+h6Bmms0wodV67v4ZzoN DeLYP8My1ymFR4Ug/ht92CUtRSUtD2HWYqoNi93fiU1DZLW+TWHa+ycJV//ZFEXLLNlJxK0hYocdV 6zaWrmAisnAxTsrVUAe+y+LgohYTW6eS/40LyvCc1LyOZOTYyppiX3nX5xeDIlTeY6EtpmEoGgEDU BEDqnQGvLwDsHfI/iEekYqzSQhkoGQ5SdKhQAfQMWfV6TS8Uoa+BN6JRnr1vf4mjVZ+3fDKiJsk19 r2r4757IU11c0tnKn2AA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seFRr-00000007OQF-3nd1; Wed, 14 Aug 2024 14:58:03 +0000 Received: from smtp-relay-internal-0.canonical.com ([185.125.188.122]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seFQo-00000007O4E-0CiO for linux-riscv@lists.infradead.org; Wed, 14 Aug 2024 14:57:00 +0000 Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id CF1034463E for ; Wed, 14 Aug 2024 14:56:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1723647412; bh=IUM6jkgHqliS7TLynxdyuCPNYS9WvP3ZzPTH9v/4Y8U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KY/QEfG0HoBFxyAoG1kwFQdh/u9qtpMe6wZd19gd+1+5kV2S7NjcGSVvigW3uP29p B9i67jDe1vDAKpdNCB5PfiNECeWmDkyawOp899OhQ3cQ+5sAm5Y+0HJJNZ09AfXJ3O bI8/rVnZ63SqzOIl5bxOTg2cYnsWwFfuS9NdklGTjmKYUVfxUqNlKqU+RJ3y4GHeDT 76DRn+zJhHI61jhCeTphPw+HE7AV0GDCycegDFsLQS/VLR+090xB8mTcc/YZ3MIGuW AjyqazdYhl2E+UVn88n5qfac/kb6MpQPXmlXqH6W1+L64RyZyuvpw5KxL7o+7+1cHG 6Pcj5lwzksf7g== Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a7d2f42df2dso132712466b.1 for ; Wed, 14 Aug 2024 07:56:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723647409; x=1724252209; 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=IUM6jkgHqliS7TLynxdyuCPNYS9WvP3ZzPTH9v/4Y8U=; b=n/fS1Zb5n95dYIk0GlnWEYdyiSNAaxNI6sN1x70wm6cWxSzxmgdhPKioyN2h1by7Vh XCS00Jyug5Ar0uYpXS/cW6XP63kL0JUstL3wg9Wawqo+iluAexkMwz+4ZzjQYuxDaIXB /GE6nBdGPHwbpjiglXTsH8DNzjP0mmfY8+Tnwpez4RFqQlYXT16pmvLcBRsW7lA4rMFm dC1AjZuCkh3CmNvuzqAEKmrwEbMfAj9DQj//qPImPE3JRO43hIUuNsrdbQWeIAbZbYK5 iNTJxPjxtaBLORkPJhqjYTlaHsQm4yF1sFzCFo1VxK3igrxopRQIQjpU4iBdQhbwVMgA i9vQ== X-Forwarded-Encrypted: i=1; AJvYcCWgxUaF+2Nf0jx1qj4TSWX6YL/N/v6M4i7ZiHx+py2uTHcX/+V7hEt/kffhdoEbbG+W9gGEr/p2UWIk126ucLCuZIe5xDCU1KtYvHXldeZI X-Gm-Message-State: AOJu0Yz3d2aUer0/Rfwi+ntihMIixEFDLKSzvoCG/AVn6zDbNYhEy5Ts goe602D4iGmCzyitJKpujTJeJLzBCZRwYwd/vwcg2b8soyTrjaKIaJN00vQbRPvKbBfXZgMxAys brgUNpmbPThXmufoP9gm/YPWxQPwrwFbkJyn8dS6hFh7rd+pfY56qBJNern/9tglRCg4t+KbvNQ oP0UBs7w== X-Received: by 2002:a17:907:3201:b0:a7a:bcbc:f7f4 with SMTP id a640c23a62f3a-a836abb358emr234363966b.14.1723647409187; Wed, 14 Aug 2024 07:56:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEys6MrI5aQcVwmiLrXuNC8jHi0+dek+tdNfiAtj1CA05xQUkevZWjodULXyUBCHbZ9S/jcUg== X-Received: by 2002:a17:907:3201:b0:a7a:bcbc:f7f4 with SMTP id a640c23a62f3a-a836abb358emr234359466b.14.1723647408318; Wed, 14 Aug 2024 07:56:48 -0700 (PDT) Received: from stitch.. ([2a01:4262:1ab:c:bbf4:eba3:898f:7501]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a80f411bdcbsm182316866b.105.2024.08.14.07.56.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 07:56:47 -0700 (PDT) From: Emil Renner Berthing To: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Anup Patel Cc: Thomas Gleixner , Paul Walmsley , Samuel Holland , Palmer Dabbelt , Albert Ou Subject: [PATCH v1 5/9] Revert "irqchip/sifive-plic: Cleanup PLIC contexts upon irqdomain creation failure" Date: Wed, 14 Aug 2024 16:56:37 +0200 Message-ID: <20240814145642.344485-6-emil.renner.berthing@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240814145642.344485-1-emil.renner.berthing@canonical.com> References: <20240814145642.344485-1-emil.renner.berthing@canonical.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240814_075658_320996_A3120B63 X-CRM114-Status: GOOD ( 20.31 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org This reverts commit a15587277a246c388c83b1cd9cf7c1a868cd752f. This is a prerequisite to reverting the patch converting the PLIC into a platform driver. Unfortunately this breaks booting the Allwinner D1 SoC. Fixes: 8ec99b033147 ("irqchip/sifive-plic: Convert PLIC driver into a platform driver") Signed-off-by: Emil Renner Berthing --- drivers/irqchip/irq-sifive-plic.c | 73 +++++++++---------------------- 1 file changed, 20 insertions(+), 53 deletions(-) diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c index b4c4050a02fb..85e94b8f4c06 100644 --- a/drivers/irqchip/irq-sifive-plic.c +++ b/drivers/irqchip/irq-sifive-plic.c @@ -423,45 +423,17 @@ static const struct of_device_id plic_match[] = { {} }; -static int plic_parse_context_parent(struct platform_device *pdev, u32 context, - u32 *parent_hwirq, int *parent_cpu) -{ - struct device *dev = &pdev->dev; - struct of_phandle_args parent; - unsigned long hartid; - int rc; - - /* - * Currently, only OF fwnode is supported so extend this - * function for ACPI support. - */ - if (!is_of_node(dev->fwnode)) - return -EINVAL; - - rc = of_irq_parse_one(to_of_node(dev->fwnode), context, &parent); - if (rc) - return rc; - - rc = riscv_of_parent_hartid(parent.np, &hartid); - if (rc) - return rc; - - *parent_hwirq = parent.args[0]; - *parent_cpu = riscv_hartid_to_cpuid(hartid); - return 0; -} - static int plic_probe(struct platform_device *pdev) { - int error = 0, nr_contexts, nr_handlers = 0, cpu, i; + int error = 0, nr_contexts, nr_handlers = 0, i; struct device *dev = &pdev->dev; unsigned long plic_quirks = 0; struct plic_handler *handler; - u32 nr_irqs, parent_hwirq; struct irq_domain *domain; struct plic_priv *priv; - irq_hw_number_t hwirq; bool cpuhp_setup; + unsigned int cpu; + u32 nr_irqs; if (is_of_node(dev->fwnode)) { const struct of_device_id *id; @@ -497,9 +469,13 @@ static int plic_probe(struct platform_device *pdev) return -EINVAL; for (i = 0; i < nr_contexts; i++) { - error = plic_parse_context_parent(pdev, i, &parent_hwirq, &cpu); - if (error) { - dev_warn(dev, "hwirq for context%d not found\n", i); + struct of_phandle_args parent; + irq_hw_number_t hwirq; + int cpu; + unsigned long hartid; + + if (of_irq_parse_one(to_of_node(dev->fwnode), i, &parent)) { + dev_err(dev, "failed to parse parent for context %d.\n", i); continue; } @@ -507,7 +483,7 @@ static int plic_probe(struct platform_device *pdev) * Skip contexts other than external interrupts for our * privilege level. */ - if (parent_hwirq != RV_IRQ_EXT) { + if (parent.args[0] != RV_IRQ_EXT) { /* Disable S-mode enable bits if running in M-mode. */ if (IS_ENABLED(CONFIG_RISCV_M_MODE)) { void __iomem *enable_base = priv->regs + @@ -520,6 +496,13 @@ static int plic_probe(struct platform_device *pdev) continue; } + error = riscv_of_parent_hartid(parent.np, &hartid); + if (error < 0) { + dev_warn(dev, "failed to parse hart ID for context %d.\n", i); + continue; + } + + cpu = riscv_hartid_to_cpuid(hartid); if (cpu < 0) { dev_warn(dev, "Invalid cpuid for context %d\n", i); continue; @@ -557,7 +540,7 @@ static int plic_probe(struct platform_device *pdev) handler->enable_save = devm_kcalloc(dev, DIV_ROUND_UP(nr_irqs, 32), sizeof(*handler->enable_save), GFP_KERNEL); if (!handler->enable_save) - goto fail_cleanup_contexts; + return -ENOMEM; done: for (hwirq = 1; hwirq <= nr_irqs; hwirq++) { plic_toggle(handler, hwirq, 0); @@ -570,7 +553,7 @@ static int plic_probe(struct platform_device *pdev) priv->irqdomain = irq_domain_add_linear(to_of_node(dev->fwnode), nr_irqs + 1, &plic_irqdomain_ops, priv); if (WARN_ON(!priv->irqdomain)) - goto fail_cleanup_contexts; + return -ENOMEM; /* * We can have multiple PLIC instances so setup cpuhp state @@ -598,22 +581,6 @@ static int plic_probe(struct platform_device *pdev) dev_info(dev, "mapped %d interrupts with %d handlers for %d contexts.\n", nr_irqs, nr_handlers, nr_contexts); return 0; - -fail_cleanup_contexts: - for (i = 0; i < nr_contexts; i++) { - if (plic_parse_context_parent(pdev, i, &parent_hwirq, &cpu)) - continue; - if (parent_hwirq != RV_IRQ_EXT || cpu < 0) - continue; - - handler = per_cpu_ptr(&plic_handlers, cpu); - handler->present = false; - handler->hart_base = NULL; - handler->enable_base = NULL; - handler->enable_save = NULL; - handler->priv = NULL; - } - return -ENOMEM; } static struct platform_driver plic_driver = { From patchwork Wed Aug 14 14:56:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Renner Berthing X-Patchwork-Id: 13763606 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 527AAC3DA4A for ; Wed, 14 Aug 2024 14:58:03 +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=avy9Hh93s9+X/6NFSJQk4UeWOKDrhDvS+ECbY9UZat4=; b=k3uxzThM5jWYj7 43wXHG3xtF5EGSDK1NrPbxVLmBCI7RXkEJpsq7Gtp4U4yQZU623aoPJCTaLuFjNLnNMrgYvydeVJx AAEYd1mIdC6ZbdSetzEQKFZAWu0jLmV0J6uCDNqXt7ZLb6karW5jjGgBXr0kEbUuFSNoAPBo7NmBw qO0wRc0WExGGNDj90aWchUF5iGkEwEFD/TDXjqk+rtqRuo02SZCg600oJudYibRH8l0/Gg7SZgmYn dEdDoZkzcYbm/I1cj4IIQB1VvgOIRgZMRDDVFkTN38e35j0PzxEIDu6ZXnVaSIGbNdbb9DpLdy8Bh FhTLjuPgzPzuA+a0G0jg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seFRn-00000007OMy-48Ar; Wed, 14 Aug 2024 14:57:59 +0000 Received: from smtp-relay-internal-1.canonical.com ([185.125.188.123]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seFQm-00000007O3m-0XF8 for linux-riscv@lists.infradead.org; Wed, 14 Aug 2024 14:56:57 +0000 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id A4A5C411F4 for ; Wed, 14 Aug 2024 14:56:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1723647412; bh=CX0Ehp5ml6WOE9Qikg2fnkaf9KKI21cRzGrnDKkzd2k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gptT81efN3a8Y4n4joTH0sLMg9aSg/6oZATN3zbB/ryO0KbaFN0Dy2/i70Nzmhn90 bRysP83XSZQoTy2kJSFtJfz4iMe4cjyu01GdTj6JA/96ldGYDgrtfUodIl+hHM0iEV SgUrzRTaMVig2B9RKFlO/HNVhpb+jjRnpv7mhGsg0XqzbtgH5RN0vdH5UOxL97r7S5 ld5RwSdTm62lqf2TZT0bpfk9DjupXSQkHwIowp1YY0bFV1wXgT1jlxd5nGVWDMx1K1 AbOLSkOuJymkhFXjt2PPY26k17U297nqXC0kYy9gWx4rMZDtQEHbjSzhTj4DKw10Xv js1JmzF/zGD4w== Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a7aa7e86b5eso548628666b.2 for ; Wed, 14 Aug 2024 07:56:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723647410; x=1724252210; 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=CX0Ehp5ml6WOE9Qikg2fnkaf9KKI21cRzGrnDKkzd2k=; b=Har5Ude4WnH9WppHYOOSAM67aHJ12eyk+NxUMiqaygwiNnwyYmyDxTYokZhsBG4fdA kI2Udb5XRsoE9wnYiZr5eIE/j6CvPoe4O+EP4OUt+tacXv5ad47Wpxz6A5e+N92ce3JU WOXQ3AU23xcPRkRbteavEo9Vd6E1NW7R6vmobDhbm0HjS2J4attR3cuYpki4Vf1jAPAf EDDK6tzOf2Uw88e6Da1+mwjbw4SOKN+5v3SyCVWjW/4WQ3ft0fD5bjrW6G+GQNJ3kW2A CgMR+tFob7xdvA/3HB/TVMPeqTuP8k/hN4IqqYkr1oyJINjtgQTGP5WYMOsd9PX90QQS f2EQ== X-Forwarded-Encrypted: i=1; AJvYcCUAVASk37JH2cObQj7P7bxN+Ezdd1HNwrdZA32E8zsMBGi/6GtQ3iIjGiCj+d9TfodBWEKbGHQmbNdwojUnEnt2FzRNh0CZvAw4zouN5qOk X-Gm-Message-State: AOJu0YwYhSWoByCv7eM2eNOCwMFTPRilwDEh0OvEv5iRMvD9QPLoPzKc mSMy59JIyomcM+JfOyxN2jkICE/1hiSdLe6adMaz5+ioD7pBFT1uNFck55En8OXpRODNiYuBu6G aURxAja4prclLAcmYvbQaDHPU/fVJyNgVgCk+o+RceEN6Wmm4JnV5ayyCoK5g98jttHStMdcOwc y17ogttbQPFuffpA== X-Received: by 2002:a17:906:7952:b0:a7a:ab1a:2d64 with SMTP id a640c23a62f3a-a8367110460mr191610966b.58.1723647410130; Wed, 14 Aug 2024 07:56:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH8EoPiheZDl/XaOz+iEJprer/FvXWlwGIqv0DClmcSJg+8eKp8MwPZxtItNQsSjm8fghSEGg== X-Received: by 2002:a17:906:7952:b0:a7a:ab1a:2d64 with SMTP id a640c23a62f3a-a8367110460mr191607966b.58.1723647409411; Wed, 14 Aug 2024 07:56:49 -0700 (PDT) Received: from stitch.. ([2a01:4262:1ab:c:bbf4:eba3:898f:7501]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a80f411bdcbsm182316866b.105.2024.08.14.07.56.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 07:56:48 -0700 (PDT) From: Emil Renner Berthing To: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Anup Patel Cc: Thomas Gleixner , Paul Walmsley , Samuel Holland , Palmer Dabbelt , Albert Ou Subject: [PATCH v1 6/9] Revert "irqchip/sifive-plic: Use riscv_get_intc_hwnode() to get parent fwnode" Date: Wed, 14 Aug 2024 16:56:38 +0200 Message-ID: <20240814145642.344485-7-emil.renner.berthing@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240814145642.344485-1-emil.renner.berthing@canonical.com> References: <20240814145642.344485-1-emil.renner.berthing@canonical.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240814_075656_323367_1E1C02EB X-CRM114-Status: GOOD ( 13.22 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org This reverts commit 6c725f33d67b53f2d302c2c4509deae953fc6ade. This is a prerequisite to reverting the patch converting the PLIC into a platform driver. Unfortunately this breaks booting the Allwinner D1 SoC. Fixes: 8ec99b033147 ("irqchip/sifive-plic: Convert PLIC driver into a platform driver") Signed-off-by: Emil Renner Berthing --- drivers/irqchip/irq-sifive-plic.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c index 85e94b8f4c06..7dbc662a229c 100644 --- a/drivers/irqchip/irq-sifive-plic.c +++ b/drivers/irqchip/irq-sifive-plic.c @@ -429,7 +429,6 @@ static int plic_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; unsigned long plic_quirks = 0; struct plic_handler *handler; - struct irq_domain *domain; struct plic_priv *priv; bool cpuhp_setup; unsigned int cpu; @@ -509,11 +508,11 @@ static int plic_probe(struct platform_device *pdev) } /* Find parent domain and register chained handler */ - domain = irq_find_matching_fwnode(riscv_get_intc_hwnode(), DOMAIN_BUS_ANY); - if (!plic_parent_irq && domain) { - plic_parent_irq = irq_create_mapping(domain, RV_IRQ_EXT); + if (!plic_parent_irq && irq_find_host(parent.np)) { + plic_parent_irq = irq_of_parse_and_map(to_of_node(dev->fwnode), i); if (plic_parent_irq) - irq_set_chained_handler(plic_parent_irq, plic_handle_irq); + irq_set_chained_handler(plic_parent_irq, + plic_handle_irq); } /* From patchwork Wed Aug 14 14:56:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Renner Berthing X-Patchwork-Id: 13763609 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 31DACC52D7B for ; Wed, 14 Aug 2024 14:58:11 +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=MW43Z78oemPjFdmEEpEBIjAkLTtiEYhdqU4oDQ26OMc=; b=Ojhw2MQ82hZnCQ XIemuKzbfhaUSGY7gSVKC6GTD1H0YrnbFwtAS2mhHXHp5UNAltwR7bC/TOpjRqgyqbmU6pW6PSGX9 ellsAOwTgpTaA9HOhblNwZ/MHacgIw/zbiTavch9O/7qUNkD0WtWb/FdFb7qMEN2ym2Aw4bQeOi5x twFkIV6JLyl5vqq++GhRJCWfSVGb6GR3f7amW7wjG+tEIt7Tnvc7/nqoynD9z37PO8bbxqTBc1PlN rGzP+IzpN0uJ1XtQLDB5L5v3ZSgBaZ1zaBMRjaEpcfg3L0xdxH32Qw2rbtFtsYUhYSuc/zO3uJbHT 7RQW+YLmGiCrLl83AM1w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seFRu-00000007OSM-0D8g; Wed, 14 Aug 2024 14:58:06 +0000 Received: from smtp-relay-internal-0.canonical.com ([185.125.188.122]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seFQq-00000007O6U-3PLg for linux-riscv@lists.infradead.org; Wed, 14 Aug 2024 14:57:02 +0000 Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 6857845978 for ; Wed, 14 Aug 2024 14:56:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1723647416; bh=dOSvdt4T3jlTBcb6KodFmG9e7Ly2LfYMJaL7xOSj3eg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Kxif1l5Knw6FBDwv1BqcBfXRwzG44E7ZerrcSYDP0t0YE6sIJ5H0JEMbpj6BBVWJ4 n3Z7Ls5NK7sdZjJ30lRl6q4BW/KiPW0oqCePJttt4UONxn3Kjqr8vI3F8494lb5Tw9 z7he5a6q76UosSFZiOuFqoQ0nFsu+01rFO0MA3mB5Vejc3gUrOfxTnq1NWxNEBUjUO f8JhE0cS6kA20MU2x+NII/BL+Ly30ud9jVhASsGyLOnIZ2l/Mv31Ce2SHqkjHeZC2b gY2lAa95Reef3gh4ArgrohYk1dR+pRp0adsQmj4N9HpYJf6E5Iwb2NlG7/BytXu7Ly F3BLPguyONwOQ== Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-52fceed3473so6311556e87.0 for ; Wed, 14 Aug 2024 07:56:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723647411; x=1724252211; 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=dOSvdt4T3jlTBcb6KodFmG9e7Ly2LfYMJaL7xOSj3eg=; b=Q4sPQglOjmCb1Y/65qOG2MqTtPxFUaqt1NBD0kKn2yp6pNNHHaEuPmSee9bJG4cQom PByR4UgwANzEMSBx1eP82WFMTy32f+NjEJWAYiNzLxzf18ISJq0sWq6nyLJgAaokdE0x SKW1smekjwc/2CJ3CRsSCV7kOVif6xLGCTwbX4nFyP6Ezj++xypePqJEmhFATsqC7BcJ WmTaiSP6xYPRRPDEiXK/VKiIKEH+/9pSv6Ul5zaVpeYVv357MH11OQZ+/QseJ7zgLwKq qW4vZzpqY9ZBJEV0//0yvflWyYlX6aTzBirSy9Qp+/4jotQfslaFGJZwZlRwCI9CbgzL eb/A== X-Forwarded-Encrypted: i=1; AJvYcCVbGGvAiwZ4h4lICpXNHMMT/XBLAm6EhmLH95j/JdMcKGBDdoVXRxQsdD3FpF0+s0XIeVWbpn5oYp/AvGQi+kKv3uGlwTo0k6RrS1mvoKFT X-Gm-Message-State: AOJu0Yw76QjGwnhSVYI0Vmxyfzi8QA3lj4QUeIJrS+mv7Cuh2El17n6n /y+vu1S/6VkENeDsau4nv5m1Rl8ZNwPfreTc9X5ie3bRBDgl9FJbcI5rXfRx+gAbM4F6xe2arZh WyFp8DJwn/9vvwE0F53Tvd75eXEaX+Mz2zG1Og/D6qxcfBfsQWpyBCdAozr3MaIbFP1A4UcSZgo NszMI98A== X-Received: by 2002:a05:6512:3d9f:b0:52c:e119:7f1 with SMTP id 2adb3069b0e04-532edbbf2bbmr2673957e87.51.1723647411067; Wed, 14 Aug 2024 07:56:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFgFXAwyHjES6E7fkIaDAnivwak2wjYQiuQb0rFCs3xDtd1HCvI2yY+1dmem8aEkcG4O8KaeA== X-Received: by 2002:a05:6512:3d9f:b0:52c:e119:7f1 with SMTP id 2adb3069b0e04-532edbbf2bbmr2673932e87.51.1723647410263; Wed, 14 Aug 2024 07:56:50 -0700 (PDT) Received: from stitch.. ([2a01:4262:1ab:c:bbf4:eba3:898f:7501]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a80f411bdcbsm182316866b.105.2024.08.14.07.56.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 07:56:49 -0700 (PDT) From: Emil Renner Berthing To: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Anup Patel Cc: Thomas Gleixner , Paul Walmsley , Samuel Holland , Palmer Dabbelt , Albert Ou Subject: [PATCH v1 7/9] Revert "irqchip/sifive-plic: Use devm_xyz() for managed allocation" Date: Wed, 14 Aug 2024 16:56:39 +0200 Message-ID: <20240814145642.344485-8-emil.renner.berthing@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240814145642.344485-1-emil.renner.berthing@canonical.com> References: <20240814145642.344485-1-emil.renner.berthing@canonical.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240814_075701_023007_26AE38A4 X-CRM114-Status: GOOD ( 16.17 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org This reverts commit b68d0ff529a939a118ec52f271be8cad5d99e79a. This is a prerequisite to reverting the patch converting the PLIC into a platform driver. Unfortunately this breaks booting the Allwinner D1 SoC. Fixes: 8ec99b033147 ("irqchip/sifive-plic: Convert PLIC driver into a platform driver") Signed-off-by: Emil Renner Berthing --- drivers/irqchip/irq-sifive-plic.c | 49 +++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c index 7dbc662a229c..7cf06bbb3098 100644 --- a/drivers/irqchip/irq-sifive-plic.c +++ b/drivers/irqchip/irq-sifive-plic.c @@ -442,30 +442,39 @@ static int plic_probe(struct platform_device *pdev) plic_quirks = (unsigned long)id->data; } - priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; priv->dev = dev; priv->plic_quirks = plic_quirks; - priv->regs = devm_platform_ioremap_resource(pdev, 0); - if (WARN_ON(!priv->regs)) - return -EIO; + priv->regs = of_iomap(to_of_node(dev->fwnode), 0); + if (WARN_ON(!priv->regs)) { + error = -EIO; + goto out_free_priv; + } + error = -EINVAL; of_property_read_u32(to_of_node(dev->fwnode), "riscv,ndev", &nr_irqs); if (WARN_ON(!nr_irqs)) - return -EINVAL; + goto out_iounmap; priv->nr_irqs = nr_irqs; - priv->prio_save = devm_bitmap_zalloc(dev, nr_irqs, GFP_KERNEL); + priv->prio_save = bitmap_alloc(nr_irqs, GFP_KERNEL); if (!priv->prio_save) - return -ENOMEM; + goto out_free_priority_reg; nr_contexts = of_irq_count(to_of_node(dev->fwnode)); if (WARN_ON(!nr_contexts)) - return -EINVAL; + goto out_free_priority_reg; + + error = -ENOMEM; + priv->irqdomain = irq_domain_add_linear(to_of_node(dev->fwnode), nr_irqs + 1, + &plic_irqdomain_ops, priv); + if (WARN_ON(!priv->irqdomain)) + goto out_free_priority_reg; for (i = 0; i < nr_contexts; i++) { struct of_phandle_args parent; @@ -536,10 +545,10 @@ static int plic_probe(struct platform_device *pdev) i * CONTEXT_ENABLE_SIZE; handler->priv = priv; - handler->enable_save = devm_kcalloc(dev, DIV_ROUND_UP(nr_irqs, 32), - sizeof(*handler->enable_save), GFP_KERNEL); + handler->enable_save = kcalloc(DIV_ROUND_UP(nr_irqs, 32), + sizeof(*handler->enable_save), GFP_KERNEL); if (!handler->enable_save) - return -ENOMEM; + goto out_free_enable_reg; done: for (hwirq = 1; hwirq <= nr_irqs; hwirq++) { plic_toggle(handler, hwirq, 0); @@ -549,11 +558,6 @@ static int plic_probe(struct platform_device *pdev) nr_handlers++; } - priv->irqdomain = irq_domain_add_linear(to_of_node(dev->fwnode), nr_irqs + 1, - &plic_irqdomain_ops, priv); - if (WARN_ON(!priv->irqdomain)) - return -ENOMEM; - /* * We can have multiple PLIC instances so setup cpuhp state * and register syscore operations only once after context @@ -580,6 +584,19 @@ static int plic_probe(struct platform_device *pdev) dev_info(dev, "mapped %d interrupts with %d handlers for %d contexts.\n", nr_irqs, nr_handlers, nr_contexts); return 0; + +out_free_enable_reg: + for_each_cpu(cpu, cpu_present_mask) { + handler = per_cpu_ptr(&plic_handlers, cpu); + kfree(handler->enable_save); + } +out_free_priority_reg: + kfree(priv->prio_save); +out_iounmap: + iounmap(priv->regs); +out_free_priv: + kfree(priv); + return error; } static struct platform_driver plic_driver = { From patchwork Wed Aug 14 14:56:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Renner Berthing X-Patchwork-Id: 13763607 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 BC522C52D7B for ; Wed, 14 Aug 2024 14:58:04 +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=PBCNpMY0Cz5QDA22YnCQ0CZ3/TH1xeJ4Y69th/YxAk4=; b=JrWArVqIZ4Z/S8 Hbu9m28B+Xb5J6kW8U5XmacXSSzEWpnmFNJDYcXCogWdqU/dRC4vJ0MyJvQr6zl8j3oRCV6RlSrM5 gjs0VszET7T/+vsbno9bg+Kv8eWMDgYayxj2EVDJyQ0TNgK+lFVVcRYxNE2GqUXXEYoUZq9GIa0A/ Z36yju1UxdzRTWh1cs1fVkcRt3wzMC2DT4fRX6mPqaTxIYAzJh2hQQ15pryPZa7yygSi+M4rNRAaY F3yLkreN1hg0HvWerCSzWfsfkRbnSoehfDn69Tff7AtcRL2FCNB/BLH1LQdT3/OYCRpNGUa4Ph1Ez CxEDQVBj++kpYbn6c9BA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seFRp-00000007OOP-3JF4; Wed, 14 Aug 2024 14:58:01 +0000 Received: from smtp-relay-internal-1.canonical.com ([185.125.188.123]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seFQn-00000007O4F-260v for linux-riscv@lists.infradead.org; Wed, 14 Aug 2024 14:56:59 +0000 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id A399141236 for ; Wed, 14 Aug 2024 14:56:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1723647413; bh=gWgIkbru9J14+uAT7SsXnPIjWj2SSXnesiQDy0WXkBA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hd0qu165qcNd1CnIQKU3ij/j7WJ5nYe96WJoiIYACue+uzFDdoqgDOv3+BT/mM8v+ FNZSmBev7unTwxKBlHyG3CqYEdMgWW0SHmSp3gdkLpoMDThsAZzGwjV4rpZJxc+/ZE WX6RAmAUfgmv89TSbIijchj/I5XZ35XpdhtHYmYM4+eJIL9gwxxe0wPnlAj68OWVVZ hsiOCihXlE5L2YynTUwDotSvWYLJBfe8payWpTRe5QT0GoR/3mrMxllHaMJaxx1ZgK g+g4eL2gDdgpefXwO5n12NmfB2r79WD16jPW9fgnW3ahcfKBYAiGGsIPlXljpaWTXW 60Xk8Ccdhdhzw== Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a7d63fbf4afso646946566b.2 for ; Wed, 14 Aug 2024 07:56:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723647412; x=1724252212; 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=gWgIkbru9J14+uAT7SsXnPIjWj2SSXnesiQDy0WXkBA=; b=ZyfojVEkg9k5N6/4hd/QUTOmQa/EOVtBdV5+LZdOyZNWTQ8Xzph3ZpLm86NbwRVDzN G2pAIOXkQkYwZESKLRFaV4sjIVKhBR/E7slZiEtLMOwgzQSebw3h6/gDs8qk8wjD8UEH wy0Y4pHzNplwt1rHHBgvRwg+nKQ4gYqeljDZss3MtIWr5UFzfB6bDhxxe2QSdU2zMhes +tUKx6HOipy884FOqCnyJ15P3KZIz9x3WZZLevOF3URZ8VSLPk9Hwldld/YW51ZL76hK eFGc7mc60VNinFHrfROMZ53wzHryZHUIwWIONp2nGFoQRs2YuEfYyk0ogLTpwnBqNtjK cIpw== X-Forwarded-Encrypted: i=1; AJvYcCW7OttFrOhBEdfosLf1Krg4mxn5SkgzcD+jr5x51cbftJWyS1KqAh9DBqbdIJ706ZmmjL6L0stVB8QjZZr27QyASVAHhvuL6xliw9viF1ws X-Gm-Message-State: AOJu0YygPknw20YeHp1HHToqCuDiCzmHa4lGd5RkzJmCahEh2O55CLCx 4Xq9BWIMj193YQ24ZmDQq+4EMDGqZFiJ5mrz29sX2Fr245A3+AQW0IpkBUsTzh2e5N8Avhll+Il xtLWHdLc1XIg7tkEnJGjdPR+Gr31BYslvK51b+kogwUSlETtTGOZ6OZbinU/ioMLa+6IVq4vlRh ZbAWnw0A== X-Received: by 2002:a17:907:e211:b0:a7d:edb2:21f5 with SMTP id a640c23a62f3a-a8366c30b5bmr210882766b.12.1723647411980; Wed, 14 Aug 2024 07:56:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGh6y5MIdajZhV+9ZDD5gd/Pe4FLfBYyKgl9kFrMLGCKwzpnlebrJ2F89sA/4+Bqhck6YeZgQ== X-Received: by 2002:a17:907:e211:b0:a7d:edb2:21f5 with SMTP id a640c23a62f3a-a8366c30b5bmr210879766b.12.1723647411267; Wed, 14 Aug 2024 07:56:51 -0700 (PDT) Received: from stitch.. ([2a01:4262:1ab:c:bbf4:eba3:898f:7501]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a80f411bdcbsm182316866b.105.2024.08.14.07.56.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 07:56:50 -0700 (PDT) From: Emil Renner Berthing To: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Anup Patel Cc: Thomas Gleixner , Paul Walmsley , Samuel Holland , Palmer Dabbelt , Albert Ou Subject: [PATCH v1 8/9] Revert "irqchip/sifive-plic: Use dev_xyz() in-place of pr_xyz()" Date: Wed, 14 Aug 2024 16:56:40 +0200 Message-ID: <20240814145642.344485-9-emil.renner.berthing@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240814145642.344485-1-emil.renner.berthing@canonical.com> References: <20240814145642.344485-1-emil.renner.berthing@canonical.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240814_075657_796335_B2DEB242 X-CRM114-Status: GOOD ( 15.59 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org This reverts commit 25d862e183d4efeb5e8b9843d783c90aaae4b14a. This is a prerequisite to reverting the patch converting the PLIC into a platform driver. Unfortunately this breaks booting the Allwinner D1 SoC. Fixes: 8ec99b033147 ("irqchip/sifive-plic: Convert PLIC driver into a platform driver") Signed-off-by: Emil Renner Berthing --- drivers/irqchip/irq-sifive-plic.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c index 7cf06bbb3098..ac274e1166c3 100644 --- a/drivers/irqchip/irq-sifive-plic.c +++ b/drivers/irqchip/irq-sifive-plic.c @@ -3,6 +3,7 @@ * Copyright (C) 2017 SiFive * Copyright (C) 2018 Christoph Hellwig */ +#define pr_fmt(fmt) "plic: " fmt #include #include #include @@ -376,10 +377,9 @@ static void plic_handle_irq(struct irq_desc *desc) while ((hwirq = readl(claim))) { int err = generic_handle_domain_irq(handler->priv->irqdomain, hwirq); - if (unlikely(err)) { - dev_warn_ratelimited(handler->priv->dev, - "can't find mapping for hwirq %lu\n", hwirq); - } + if (unlikely(err)) + pr_warn_ratelimited("can't find mapping for hwirq %lu\n", + hwirq); } chained_irq_exit(chip, desc); @@ -407,7 +407,7 @@ static int plic_starting_cpu(unsigned int cpu) enable_percpu_irq(plic_parent_irq, irq_get_trigger_type(plic_parent_irq)); else - dev_warn(handler->priv->dev, "cpu%d: parent irq not available\n", cpu); + pr_warn("cpu%d: parent irq not available\n", cpu); plic_set_threshold(handler, PLIC_ENABLE_THRESHOLD); return 0; @@ -483,7 +483,7 @@ static int plic_probe(struct platform_device *pdev) unsigned long hartid; if (of_irq_parse_one(to_of_node(dev->fwnode), i, &parent)) { - dev_err(dev, "failed to parse parent for context %d.\n", i); + pr_err("failed to parse parent for context %d.\n", i); continue; } @@ -506,13 +506,13 @@ static int plic_probe(struct platform_device *pdev) error = riscv_of_parent_hartid(parent.np, &hartid); if (error < 0) { - dev_warn(dev, "failed to parse hart ID for context %d.\n", i); + pr_warn("failed to parse hart ID for context %d.\n", i); continue; } cpu = riscv_hartid_to_cpuid(hartid); if (cpu < 0) { - dev_warn(dev, "Invalid cpuid for context %d\n", i); + pr_warn("Invalid cpuid for context %d\n", i); continue; } @@ -531,7 +531,7 @@ static int plic_probe(struct platform_device *pdev) */ handler = per_cpu_ptr(&plic_handlers, cpu); if (handler->present) { - dev_warn(dev, "handler already present for context %d.\n", i); + pr_warn("handler already present for context %d.\n", i); plic_set_threshold(handler, PLIC_DISABLE_THRESHOLD); goto done; } @@ -581,8 +581,8 @@ static int plic_probe(struct platform_device *pdev) } } - dev_info(dev, "mapped %d interrupts with %d handlers for %d contexts.\n", - nr_irqs, nr_handlers, nr_contexts); + pr_info("%pOFP: mapped %d interrupts with %d handlers for %d contexts.\n", + to_of_node(dev->fwnode), nr_irqs, nr_handlers, nr_contexts); return 0; out_free_enable_reg: From patchwork Wed Aug 14 14:56:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Renner Berthing X-Patchwork-Id: 13763610 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 9E581C3DA4A for ; Wed, 14 Aug 2024 14:58:14 +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=QOH8QatUQRVVMzzmtOt3VXnyduG082SUQD/LaWMZCJs=; b=YhQKGdfWfHRBOc x+nLQi2rS0/U/67ZOZsL6bskPhBYx68S6tIDSt3ALtGHR6PZ9eyYanJczw8jN2d4xa/wN+Ehgfmai Ovx+0PQTPVzv5yea/DAYPGizTALwQKu4jc+5AyvqluwouqQT9sywWd0dzTnMEFp86jubtwFbtHmh0 Yj02JfzfbNqNB0fGQAIN9L3QsCte5iSWIiVFIgVqlytbsW3VON3LiqSjdksvtH3Hynin/e1ZxzUwI 6eZ5SvFqM/rNyF8gbhKzCZfazRnQhayHa+Tv5MND/TAPGv0g2drEgRHegrEUgIhA/bitzIapWmDeJ Jd9Bms3rzOs1kyCwDVIw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seFRy-00000007OVo-0nG5; Wed, 14 Aug 2024 14:58:10 +0000 Received: from smtp-relay-internal-0.canonical.com ([185.125.188.122]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seFQq-00000007O6Z-3QRE for linux-riscv@lists.infradead.org; Wed, 14 Aug 2024 14:57:03 +0000 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 81D2F4597C for ; Wed, 14 Aug 2024 14:56:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1723647417; bh=yjCwWNcb2RwBz1G+TBCUPH+94PCiJ1raP+HTH6kWRGU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qWKTCIXzF5FbcTl5TErntFpJRRt0vupjKJKQPx5CtjG6ItCDKQ2WueyyleigL+IWv MF6pWbd2+zNfjKlDZ3iHqe/ZCQLLZm9WN6BfcJ++JvyQlVICjuKdbP5FYFIYrTEMfz Houn23KiigVW27DEMEKpQo0VVsHjoKKa5LjUSZ99oAwZv+Ulc+ykfGaD1rFzPVCh3U MaL5NzZ7PJLJMIO2Lyq5+JirYCzOURCZDL1nSPEDnwaz6qf8JTBSvQlWmbo9+aJco9 M3tzYCEIXE1ttHeHlMeO2n/Yy5lWywZZd1LyjfHBSR8bBpv30vVUhN0k8EwpqMJglQ l8LlIBACmKIgQ== Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a7a8281dba5so558814366b.3 for ; Wed, 14 Aug 2024 07:56:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723647413; x=1724252213; 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=yjCwWNcb2RwBz1G+TBCUPH+94PCiJ1raP+HTH6kWRGU=; b=PGhVtrTejz/+1RgcmYoSiocNRBQepS9UPNr9iDt2JnSk8rAduR52LuldxkQBanbcBf +TMaYiD6Ogz4Cgn1EJmcUOGmXF7RFU+8NOqRo8T2EVb46YQQuX/1dKswZFtp6stSa0SP pMpdkkIJeGxCOeq54Y2d0AaempgasEeB4ndJD/1E04D8TH1zl6iK9I7hsaaRAJDZBHvZ alFncJ6NA3WkbOGcCRVhSXcOgo14MVcavrGgntkEGc3Y3zVpJZomrsJhfbsPp8Mzp8Ej e+jwabmrBnhDqyr3Qm5SA0PocT80ZDYefntfB4nvW1Wyv/eK8hKTPYU20VNBd5e+J52p SG7Q== X-Forwarded-Encrypted: i=1; AJvYcCXGSnyUHgo73HmHLCU4GADGH5fJBX6rHE3GLwDMIoB5k23JzblSM9bXr/Ioh6/XqE8PhhItxm0tm8e66wWhsf5EMC4GA4n7hYGOeI2nTzpP X-Gm-Message-State: AOJu0Ywee9tUWz/90dtWlU1Igc0VxAd13pzEOEjaNHD2LE7Na3vI8e9/ 0ozoQbhe/DWqSCGL/GXNA+4HNAe2Xj7Stn/lmrUQy9R75aliRTcAdbgAMA/dZms2XfFsXCmykei L7mF+oq5QrpxqWNYHSDnrFPKTLqFme+IH6W3WvPeXP8ylMVyA58begeFnuUfcXtsn2QtjjyE4qv wnU6vsEPSSkVcVEA== X-Received: by 2002:a17:906:d24f:b0:a7a:ae85:f24d with SMTP id a640c23a62f3a-a83670156afmr183670066b.51.1723647412768; Wed, 14 Aug 2024 07:56:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHHaDsSWoa2KsGlc6OyPJgRDW+q0rWS6QSZ3gIEWLEGWbf/cNuU3Zj/MyvRCW2i/aNyUts1xw== X-Received: by 2002:a17:906:d24f:b0:a7a:ae85:f24d with SMTP id a640c23a62f3a-a83670156afmr183667066b.51.1723647412019; Wed, 14 Aug 2024 07:56:52 -0700 (PDT) Received: from stitch.. ([2a01:4262:1ab:c:bbf4:eba3:898f:7501]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a80f411bdcbsm182316866b.105.2024.08.14.07.56.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 07:56:51 -0700 (PDT) From: Emil Renner Berthing To: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Anup Patel Cc: Thomas Gleixner , Paul Walmsley , Samuel Holland , Palmer Dabbelt , Albert Ou Subject: [PATCH v1 9/9] Revert "irqchip/sifive-plic: Convert PLIC driver into a platform driver" Date: Wed, 14 Aug 2024 16:56:41 +0200 Message-ID: <20240814145642.344485-10-emil.renner.berthing@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240814145642.344485-1-emil.renner.berthing@canonical.com> References: <20240814145642.344485-1-emil.renner.berthing@canonical.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240814_075701_020423_D1C7B30B X-CRM114-Status: GOOD ( 19.46 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org This reverts commit 8ec99b033147ef3bb8f0a560c24eb1baec3bc0be. This change makes the Allwinner D1 SoC lock up at boot as described in the thread below. Link: https://lore.kernel.org/linux-riscv/CAJM55Z9hGKo4784N3s3DhWw=nMRKZKcmvZ58x7uVBghExhoc9A@mail.gmail.com/ Fixes: 8ec99b033147 ("irqchip/sifive-plic: Convert PLIC driver into a platform driver") Signed-off-by: Emil Renner Berthing --- drivers/irqchip/irq-sifive-plic.c | 103 ++++++++++++------------------ 1 file changed, 41 insertions(+), 62 deletions(-) diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c index ac274e1166c3..bf0b40b0fad4 100644 --- a/drivers/irqchip/irq-sifive-plic.c +++ b/drivers/irqchip/irq-sifive-plic.c @@ -64,7 +64,6 @@ #define PLIC_QUIRK_EDGE_INTERRUPT 0 struct plic_priv { - struct device *dev; struct cpumask lmask; struct irq_domain *irqdomain; void __iomem *regs; @@ -413,50 +412,30 @@ static int plic_starting_cpu(unsigned int cpu) return 0; } -static const struct of_device_id plic_match[] = { - { .compatible = "sifive,plic-1.0.0" }, - { .compatible = "riscv,plic0" }, - { .compatible = "andestech,nceplic100", - .data = (const void *)BIT(PLIC_QUIRK_EDGE_INTERRUPT) }, - { .compatible = "thead,c900-plic", - .data = (const void *)BIT(PLIC_QUIRK_EDGE_INTERRUPT) }, - {} -}; - -static int plic_probe(struct platform_device *pdev) +static int __init __plic_init(struct device_node *node, + struct device_node *parent, + unsigned long plic_quirks) { int error = 0, nr_contexts, nr_handlers = 0, i; - struct device *dev = &pdev->dev; - unsigned long plic_quirks = 0; - struct plic_handler *handler; - struct plic_priv *priv; - bool cpuhp_setup; - unsigned int cpu; u32 nr_irqs; - - if (is_of_node(dev->fwnode)) { - const struct of_device_id *id; - - id = of_match_node(plic_match, to_of_node(dev->fwnode)); - if (id) - plic_quirks = (unsigned long)id->data; - } + struct plic_priv *priv; + struct plic_handler *handler; + unsigned int cpu; priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; - priv->dev = dev; priv->plic_quirks = plic_quirks; - priv->regs = of_iomap(to_of_node(dev->fwnode), 0); + priv->regs = of_iomap(node, 0); if (WARN_ON(!priv->regs)) { error = -EIO; goto out_free_priv; } error = -EINVAL; - of_property_read_u32(to_of_node(dev->fwnode), "riscv,ndev", &nr_irqs); + of_property_read_u32(node, "riscv,ndev", &nr_irqs); if (WARN_ON(!nr_irqs)) goto out_iounmap; @@ -466,13 +445,13 @@ static int plic_probe(struct platform_device *pdev) if (!priv->prio_save) goto out_free_priority_reg; - nr_contexts = of_irq_count(to_of_node(dev->fwnode)); + nr_contexts = of_irq_count(node); if (WARN_ON(!nr_contexts)) goto out_free_priority_reg; error = -ENOMEM; - priv->irqdomain = irq_domain_add_linear(to_of_node(dev->fwnode), nr_irqs + 1, - &plic_irqdomain_ops, priv); + priv->irqdomain = irq_domain_add_linear(node, nr_irqs + 1, + &plic_irqdomain_ops, priv); if (WARN_ON(!priv->irqdomain)) goto out_free_priority_reg; @@ -482,7 +461,7 @@ static int plic_probe(struct platform_device *pdev) int cpu; unsigned long hartid; - if (of_irq_parse_one(to_of_node(dev->fwnode), i, &parent)) { + if (of_irq_parse_one(node, i, &parent)) { pr_err("failed to parse parent for context %d.\n", i); continue; } @@ -518,7 +497,7 @@ static int plic_probe(struct platform_device *pdev) /* Find parent domain and register chained handler */ if (!plic_parent_irq && irq_find_host(parent.np)) { - plic_parent_irq = irq_of_parse_and_map(to_of_node(dev->fwnode), i); + plic_parent_irq = irq_of_parse_and_map(node, i); if (plic_parent_irq) irq_set_chained_handler(plic_parent_irq, plic_handle_irq); @@ -560,29 +539,20 @@ static int plic_probe(struct platform_device *pdev) /* * We can have multiple PLIC instances so setup cpuhp state - * and register syscore operations only once after context - * handlers of all online CPUs are initialized. + * and register syscore operations only when context handler + * for current/boot CPU is present. */ - if (!plic_cpuhp_setup_done) { - cpuhp_setup = true; - for_each_online_cpu(cpu) { - handler = per_cpu_ptr(&plic_handlers, cpu); - if (!handler->present) { - cpuhp_setup = false; - break; - } - } - if (cpuhp_setup) { - cpuhp_setup_state(CPUHP_AP_IRQ_SIFIVE_PLIC_STARTING, - "irqchip/sifive/plic:starting", - plic_starting_cpu, plic_dying_cpu); - register_syscore_ops(&plic_irq_syscore_ops); - plic_cpuhp_setup_done = true; - } + handler = this_cpu_ptr(&plic_handlers); + if (handler->present && !plic_cpuhp_setup_done) { + cpuhp_setup_state(CPUHP_AP_IRQ_SIFIVE_PLIC_STARTING, + "irqchip/sifive/plic:starting", + plic_starting_cpu, plic_dying_cpu); + register_syscore_ops(&plic_irq_syscore_ops); + plic_cpuhp_setup_done = true; } - pr_info("%pOFP: mapped %d interrupts with %d handlers for %d contexts.\n", - to_of_node(dev->fwnode), nr_irqs, nr_handlers, nr_contexts); + pr_info("%pOFP: mapped %d interrupts with %d handlers for" + " %d contexts.\n", node, nr_irqs, nr_handlers, nr_contexts); return 0; out_free_enable_reg: @@ -599,11 +569,20 @@ static int plic_probe(struct platform_device *pdev) return error; } -static struct platform_driver plic_driver = { - .driver = { - .name = "riscv-plic", - .of_match_table = plic_match, - }, - .probe = plic_probe, -}; -builtin_platform_driver(plic_driver); +static int __init plic_init(struct device_node *node, + struct device_node *parent) +{ + return __plic_init(node, parent, 0); +} + +IRQCHIP_DECLARE(sifive_plic, "sifive,plic-1.0.0", plic_init); +IRQCHIP_DECLARE(riscv_plic0, "riscv,plic0", plic_init); /* for legacy systems */ + +static int __init plic_edge_init(struct device_node *node, + struct device_node *parent) +{ + return __plic_init(node, parent, BIT(PLIC_QUIRK_EDGE_INTERRUPT)); +} + +IRQCHIP_DECLARE(andestech_nceplic100, "andestech,nceplic100", plic_edge_init); +IRQCHIP_DECLARE(thead_c900_plic, "thead,c900-plic", plic_edge_init);