From nobody Sat Feb 7 15:11:48 2026 Received: from smtpbgjp3.qq.com (smtpbgjp3.qq.com [54.92.39.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 505681CAB3 for ; Mon, 20 Oct 2025 03:52:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=54.92.39.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760932325; cv=none; b=RXAWF496a8gDGHcCju/AGW3F407esXePMxQP8q813iJWLVxiI8afc12f/yNN61qIJq0B8cZalErIzer8b7hVDbkzIvDCuBuSCC4XrrXOW8oNIZZ0FfXkbY2q6w6AcuVoMfVImRqodblVnEDek3mE5axDwDP/mNku/bbOAwa/QLE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760932325; c=relaxed/simple; bh=uRvWV0R2c5iAFDC5+jFevLBgjxm1CeDDvGaWVsTm9N4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=JOZStaWUiF0voP2giyrx3oesy+FlQS1cDUNhgCBHsDixBxjrFuoxwc13KMLFRAr2ELr4mqwQKJJabuyqdHqxIqQ/tIpVunuvDJnJXdL4alputmJ3IitOA+ufcY2a5DoHNglc6Nu6AcvYuDbol/cb3MHFNd7WfWYjjgzbzGULkNg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.dev; spf=none smtp.mailfrom=linux.spacemit.com; arc=none smtp.client-ip=54.92.39.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.spacemit.com X-QQ-mid: zesmtpsz2t1760932206t517f9aae X-QQ-Originating-IP: wyKiwACbVfUQybFOMCCka2mwIAAqvRZ3aD4pA0CfH7g= Received: from = ( [14.123.254.135]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 20 Oct 2025 11:50:04 +0800 (CST) X-QQ-SSF: 0000000000000000000000000000000 X-QQ-GoodBg: 0 X-BIZMAIL-ID: 12576403627784975051 X-QQ-CSender: troy.mitchell@linux.spacemit.com Sender: troy.mitchell@linux.spacemit.com From: Troy Mitchell Date: Mon, 20 Oct 2025 11:49:45 +0800 Subject: [PATCH] irqchip/sifive-plic: use hartid as context_id in OF to fix AMP conflicts Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251020-fix-plic-amp-v1-1-defe2a99ab80@linux.dev> X-B4-Tracking: v=1; b=H4sIAFix9WgC/6tWKk4tykwtVrJSqFYqSi3LLM7MzwNyDHUUlJIzE vPSU3UzU4B8JSMDI1NDAyMD3bTMCt2CnMxk3cTcAl1zo6QUSxNLM8vkRBMloJaColSgPNi46Nj aWgAQINMfXgAAAA== X-Change-ID: 20251020-fix-plic-amp-72bd94969ca4 To: Thomas Gleixner , Paul Walmsley , Samuel Holland , Palmer Dabbelt , Albert Ou , Alexandre Ghiti Cc: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Troy Mitchell X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1760932204; l=3513; i=troy.mitchell@linux.dev; s=20250710; h=from:subject:message-id; bh=uRvWV0R2c5iAFDC5+jFevLBgjxm1CeDDvGaWVsTm9N4=; b=HHzy1uYczXIJW/omts5VBBri9mYOWiWOW+DYDjrvx8dopdpdMo1zEiQXk4Qakw29XkzJOaVEs 16ZpaRlKIdQAeWrg+MkaDF2ZPonk5M34NZ5sSZRrwZt9puicNXf0Ofy X-Developer-Key: i=troy.mitchell@linux.dev; a=ed25519; pk=lQa7BzLrq8DfZnChqmwJ5qQk8fP2USmY/4xZ2/MSsXc= X-QQ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qkCZClL6G0czSX4UV02L71ONzROuGuzpO37u+ubF050YeU3zhs4daGEmfmYqLuhIQER VtnIKqR5XCnzx0shJioUFkdvv5RsI3GJLHGgL7zQmqbuARYGGpRC2TqKghCTSqJG8zi9hJv 2CzpT3R3GqT X-QQ-XMRINFO: OWPUhxQsoeAVDbp3OJHYyFg= X-QQ-RECHKSPAM: 0 In asymmetric multi-processing (AMP) scenarios, the original PLIC driver used the context loop index 'i' as context_id for OF (device tree) platforms. This caused multiple contexts from different harts (e.g., core0 and core4) to share the same enable_base, leading to conflicts when initializing the PLIC. This patch resolves enable_base conflicts on AMP platforms while maintaining SMP/UP behavior. Signed-off-by: Troy Mitchell --- drivers/irqchip/irq-sifive-plic.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive= -plic.c index cbd7697bc14819cbe3b77096b26901b605491f75..79867afcd321e42ad837adb5c15= d0e1dc9e0e1b4 100644 --- a/drivers/irqchip/irq-sifive-plic.c +++ b/drivers/irqchip/irq-sifive-plic.c @@ -487,18 +487,18 @@ static int plic_parse_nr_irqs_and_contexts(struct fwn= ode_handle *fwnode, } =20 static int plic_parse_context_parent(struct fwnode_handle *fwnode, u32 con= text, - u32 *parent_hwirq, int *parent_cpu, u32 id) + u32 *parent_hwirq, int *parent_cpu, u32 id, + unsigned long *hartid) { struct of_phandle_args parent; - unsigned long hartid; int rc; =20 if (!is_of_node(fwnode)) { - hartid =3D acpi_rintc_ext_parent_to_hartid(id, context); - if (hartid =3D=3D INVALID_HARTID) + *hartid =3D acpi_rintc_ext_parent_to_hartid(id, context); + if (*hartid =3D=3D INVALID_HARTID) return -EINVAL; =20 - *parent_cpu =3D riscv_hartid_to_cpuid(hartid); + *parent_cpu =3D riscv_hartid_to_cpuid(*hartid); *parent_hwirq =3D RV_IRQ_EXT; return 0; } @@ -507,19 +507,19 @@ static int plic_parse_context_parent(struct fwnode_ha= ndle *fwnode, u32 context, if (rc) return rc; =20 - rc =3D riscv_of_parent_hartid(parent.np, &hartid); + rc =3D riscv_of_parent_hartid(parent.np, hartid); if (rc) return rc; =20 *parent_hwirq =3D parent.args[0]; - *parent_cpu =3D riscv_hartid_to_cpuid(hartid); + *parent_cpu =3D riscv_hartid_to_cpuid(*hartid); return 0; } =20 static int plic_probe(struct fwnode_handle *fwnode) { int error =3D 0, nr_contexts, nr_handlers =3D 0, cpu, i; - unsigned long plic_quirks =3D 0; + unsigned long plic_quirks =3D 0, hartid; struct plic_handler *handler; u32 nr_irqs, parent_hwirq; struct plic_priv *priv; @@ -569,14 +569,14 @@ static int plic_probe(struct fwnode_handle *fwnode) =20 for (i =3D 0; i < nr_contexts; i++) { error =3D plic_parse_context_parent(fwnode, i, &parent_hwirq, &cpu, - priv->acpi_plic_id); + priv->acpi_plic_id, &hartid); if (error) { pr_warn("%pfwP: hwirq for context%d not found\n", fwnode, i); continue; } =20 if (is_of_node(fwnode)) { - context_id =3D i; + context_id =3D hartid * 2 + i % 2; } else { context_id =3D acpi_rintc_get_plic_context(priv->acpi_plic_id, i); if (context_id =3D=3D INVALID_CONTEXT) { @@ -694,7 +694,8 @@ static int plic_probe(struct fwnode_handle *fwnode) =20 fail_cleanup_contexts: for (i =3D 0; i < nr_contexts; i++) { - if (plic_parse_context_parent(fwnode, i, &parent_hwirq, &cpu, priv->acpi= _plic_id)) + if (plic_parse_context_parent(fwnode, i, &parent_hwirq, &cpu, + priv->acpi_plic_id, &hartid)) continue; if (parent_hwirq !=3D RV_IRQ_EXT || cpu < 0) continue; --- base-commit: fdbc36b17e9f2fa24c940959e39df90f53ccce2b change-id: 20251020-fix-plic-amp-72bd94969ca4 Best regards, --=20 Troy Mitchell