From nobody Thu Feb 12 23:08:44 2026 Received: from esa3.hc555-34.eu.iphmx.com (esa3.hc555-34.eu.iphmx.com [207.54.77.50]) (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 7A577190477 for ; Thu, 2 Jan 2025 09:43:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=207.54.77.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735810983; cv=none; b=irD7QAco1J5JweeV/+SKpq++jDZ4i5Wr4wyDVdhWL/gR4rbhrrp5ZUnwnKYDOEYVkQH/c9WNQsiVn/r1xFEhISoh1zvsxQK65gJzxls5PyeyMNgsH+5+/pi7asG5m5sLo6qByvIyggc99bfrHVMjBkT2tKnyQU+NiDorqnBzoxE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735810983; c=relaxed/simple; bh=DZuH0P4u6QKI0PKdsHIC6lASS4fQsi4VxU0oXp8o5pU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LExRszV32+WSONnDBcl1XIzr/66okRo8mnUfxzLsdX8wgWotjT7LebCU3eCCFi+K8bp83bGIAsaOZHoitVk8ot01FFCtElU3Db4PcFmoioaOZorl8MBeFebiZm93fbpEunSt3zYr7OhfuwUwOZy6yxoEd7VkO15XxXckaGn9j6g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mobileye.com; spf=pass smtp.mailfrom=mobileye.com; dkim=fail (0-bit key) header.d=mobileye.com header.i=@mobileye.com header.b=s6QFFxjG reason="key not found in DNS"; arc=none smtp.client-ip=207.54.77.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mobileye.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mobileye.com Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=mobileye.com header.i=@mobileye.com header.b="s6QFFxjG" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mobileye.com; i=@mobileye.com; q=dns/txt; s=MoEyIP; t=1735810981; x=1767346981; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DZuH0P4u6QKI0PKdsHIC6lASS4fQsi4VxU0oXp8o5pU=; b=s6QFFxjGkG19UyCERL/oQpi5m3y2WLCjByz0Ou69tnUD8vGvhHTsbHYZ tQm5s88AJ5N0o3CU9BYrjZEeTyxr7f4+f7QX3ZsiTVPIyQvJxKCbSkEdb +pEpc1M5KDZygw4k6ZZWvFLiR3LmHwBkMPFVplwJSqwAWh47/PjJcHLkj bhyO3JeKFiYHT6XSzW7RMwdgG5wBAKu+NymSW2c8E1rw6UH+bO2R5HtVT BrEG8V1FFYqUx+GPuxC4+6gIiF3oQJwPjJjx9b+cXKqxgmjouyOqh77bE RFTdSEZCA8loefX5/2RAvuR0x9oGPGswyzkJwtq8CjYV2BPRVTvbg/qCk Q==; X-CSE-ConnectionGUID: a2ENIJ1NQM6gR20s+tL5bg== X-CSE-MsgGUID: 8RrgfPfMQ3iWm03IQUo+ew== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from unknown (HELO ces04_data.me-crop.lan) ([146.255.191.134]) by esa3.hc555-34.eu.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2025 11:41:47 +0200 X-CSE-ConnectionGUID: XIzWEho7TBGEChEjX1VO/g== X-CSE-MsgGUID: /dQztNDhRyCZ0jgqSeNhHg== Received: from unknown (HELO epgd022.me-corp.lan) ([10.154.54.1]) by ces04_data.me-crop.lan with SMTP; 02 Jan 2025 11:41:45 +0200 Received: by epgd022.me-corp.lan (sSMTP sendmail emulation); Thu, 02 Jan 2025 11:41:46 +0200 From: Vladimir Kondratiev To: Anup Patel , Thomas Gleixner , Paul Walmsley , Palmer Dabbelt , Albert Ou , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Vladimir Kondratiev Subject: [PATCH 1/2] dt-bindings: interrupt-controller: add risc-v,aplic hart indexes Date: Thu, 2 Jan 2025 11:41:15 +0200 Message-ID: <20250102094116.3847894-2-vladimir.kondratiev@mobileye.com> In-Reply-To: <20250102094116.3847894-1-vladimir.kondratiev@mobileye.com> References: <20250102094116.3847894-1-vladimir.kondratiev@mobileye.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Document optional property "riscv,hart-index" Signed-off-by: Vladimir Kondratiev --- .../bindings/interrupt-controller/riscv,aplic.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Documentation/devicetree/bindings/interrupt-controller/riscv,a= plic.yaml b/Documentation/devicetree/bindings/interrupt-controller/riscv,ap= lic.yaml index 190a6499c932..e163c8de3524 100644 --- a/Documentation/devicetree/bindings/interrupt-controller/riscv,aplic.ya= ml +++ b/Documentation/devicetree/bindings/interrupt-controller/riscv,aplic.ya= ml @@ -91,6 +91,14 @@ properties: Firmware must configure interrupt delegation registers based on interrupt delegation list. =20 + riscv,hart-index: + $ref: /schemas/types.yaml#/definitions/uint32-array + minItems: 1 + maxItems: 16384 + description: + A list of hart indexes that APLIC should use to address each hart + that is mentioned in the "interrupts-extended" + dependencies: riscv,delegation: [ "riscv,children" ] =20 --=20 2.43.0 From nobody Thu Feb 12 23:08:44 2026 Received: from esa4.hc555-34.eu.iphmx.com (esa4.hc555-34.eu.iphmx.com [207.54.77.171]) (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 CAFC4190051 for ; Thu, 2 Jan 2025 09:42:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=207.54.77.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735810982; cv=none; b=KEgxj6e61gX5kPyiHpFQFsmVsW/1LU3D0t1sO4e7y2HzBk05COrKMt7q/hhEIpAf4EONZTOaVY+LDr86r8BQgPLJsFQ6ALTE7069uaN3F/C0KCMIufT1qC0gycuUgSSrii7WRsp7AGr3f/QTgl5IgdaQXCl0OsRPpW0WJWNbRQM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735810982; c=relaxed/simple; bh=4t8VRWBETfBHW77McqW8Ea3Z0LsArFzRtuIQqVimBZk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=a/J43FXBMYFN8/3LeBtfqC8+tK+Skva5OkS9Zi5BpyaVVeGh+FJJIiUkiCdXuXlqkj02uuMnnPBoABovgsG2eAaadCpaGpzoXvkLKF78E7VOaGFrr38KCn/P0n6XHf3/9PPxPMlH3OA+a0ShHl1GJQTPLZpaf4nJV2KRYBCB9vw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mobileye.com; spf=pass smtp.mailfrom=mobileye.com; dkim=fail (0-bit key) header.d=mobileye.com header.i=@mobileye.com header.b=VuE1OmUe reason="key not found in DNS"; arc=none smtp.client-ip=207.54.77.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mobileye.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mobileye.com Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=mobileye.com header.i=@mobileye.com header.b="VuE1OmUe" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mobileye.com; i=@mobileye.com; q=dns/txt; s=MoEyIP; t=1735810979; x=1767346979; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4t8VRWBETfBHW77McqW8Ea3Z0LsArFzRtuIQqVimBZk=; b=VuE1OmUeon65EZxymXIyA+5jw6OTRk0TCCNyWGSOYJUsPM8RzcpEeXYU aTGRnyNFZfKGOixOSbL6gXhxdIPJ9R7/FOAY23FdSBexXDx7fX2OoQ36y Edkb+5OlxbZTGIZ9/yOwL3oowGsLQzFiQmtX4Lw9Is4y/bvBRcIRWGYRf sfi0Li/jijcBkAuZs8K+XY8uAxB1cWK/cZIZpKEMGE3s3dPAWaxmAC29T KWDwmV1xF3lVXKyXAmZh4DHKrTdCCaOZfhi8efDbLEBfLGSdIYrFQ9a9d s/F+y6kms7PHRFTktL+aWD7lsdJFA4UUr6PVgNO8UNYpd+lwKMnGJFCl6 w==; X-CSE-ConnectionGUID: Vf9b9X9pRKGxRnW0AmxrrA== X-CSE-MsgGUID: EiiqvMh9RcaoSkwy+TdE1A== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from unknown (HELO ces02_data.me-corp.lan) ([146.255.191.134]) by esa4.hc555-34.eu.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2025 11:41:48 +0200 X-CSE-ConnectionGUID: S5I1yFsdS8Ca0oSz2MxrJg== X-CSE-MsgGUID: QJ+VloP1QfSYRflZblHiRg== Received: from unknown (HELO epgd022.me-corp.lan) ([10.154.54.6]) by ces02_data.me-corp.lan with SMTP; 02 Jan 2025 11:41:46 +0200 Received: by epgd022.me-corp.lan (sSMTP sendmail emulation); Thu, 02 Jan 2025 11:41:47 +0200 From: Vladimir Kondratiev To: Anup Patel , Thomas Gleixner , Paul Walmsley , Palmer Dabbelt , Albert Ou , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Vladimir Kondratiev Subject: [PATCH 2/2] irqchip/riscv-aplic: add support for hart indexes Date: Thu, 2 Jan 2025 11:41:16 +0200 Message-ID: <20250102094116.3847894-3-vladimir.kondratiev@mobileye.com> In-Reply-To: <20250102094116.3847894-1-vladimir.kondratiev@mobileye.com> References: <20250102094116.3847894-1-vladimir.kondratiev@mobileye.com> 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 Risc-V APLIC specification defines "hart index" in [1]: Within a given interrupt domain, each of the domain=E2=80=99s harts has a unique index number in the range 0 to 214 =E2=88=92 1 (=3D 16,383). The ind= ex number a domain associates with a hart may or may not have any relationship to the unique hart identifier (=E2=80=9Chart ID=E2=80=9D) that= the RISC-V Privileged Architecture assigns to the hart. Two different interrupt domains may employ entirely different index numbers for the same set of harts. Support arbitrary hart indexes specified in optional APLIC property "riscv,hart-index" that should be array of u32 elements, one per interrupt target. If this property not specified, fallback is to use hart ids, with hart index for each APLIC to be (hartid - hartid0) where hartid0 is hart id for the 1-st target. [1]: https://github.com/riscv/riscv-aia Signed-off-by: Vladimir Kondratiev --- drivers/irqchip/irq-riscv-aplic-direct.c | 25 ++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/irq-riscv-aplic-direct.c b/drivers/irqchip/irq= -riscv-aplic-direct.c index 7cd6b646774b..80c82e34e894 100644 --- a/drivers/irqchip/irq-riscv-aplic-direct.c +++ b/drivers/irqchip/irq-riscv-aplic-direct.c @@ -221,12 +221,15 @@ static int aplic_direct_parse_parent_hwirq(struct dev= ice *dev, u32 index, =20 int aplic_direct_setup(struct device *dev, void __iomem *regs) { + static const char *prop_hart_index =3D "riscv,hart-index"; int i, j, rc, cpu, current_cpu, setup_count =3D 0; struct aplic_direct *direct; struct irq_domain *domain; struct aplic_priv *priv; struct aplic_idc *idc; unsigned long hartid; + unsigned long hartid0; + u32 *hart_index =3D NULL; u32 v, hwirq; =20 direct =3D devm_kzalloc(dev, sizeof(*direct), GFP_KERNEL); @@ -240,6 +243,22 @@ int aplic_direct_setup(struct device *dev, void __iome= m *regs) return rc; } =20 + rc =3D device_property_count_u32(dev, prop_hart_index); + if (rc =3D=3D -ENODATA) + rc =3D 0; + if (rc > 0 && rc !=3D priv->nr_idcs) + rc =3D -EOVERFLOW; + if (rc > 0) { + hart_index =3D devm_kcalloc(dev, priv->nr_idcs, sizeof(*hart_index), GFP= _KERNEL); + if (!hart_index) + return -ENOMEM; + rc =3D device_property_read_u32_array(dev, prop_hart_index, + hart_index, priv->nr_idcs); + } + if (rc < 0) { + dev_err(dev, "APLIC property \"%s\" error %pe\n", prop_hart_index, ERR_P= TR(rc)); + return rc; + } /* Setup per-CPU IDC and target CPU mask */ current_cpu =3D get_cpu(); for (i =3D 0; i < priv->nr_idcs; i++) { @@ -249,6 +268,8 @@ int aplic_direct_setup(struct device *dev, void __iomem= *regs) continue; } =20 + if (i =3D=3D 0) + hartid0 =3D hartid; /* * Skip interrupts other than external interrupts for * current privilege level. @@ -265,8 +286,8 @@ int aplic_direct_setup(struct device *dev, void __iomem= *regs) cpumask_set_cpu(cpu, &direct->lmask); =20 idc =3D per_cpu_ptr(&aplic_idcs, cpu); - idc->hart_index =3D i; - idc->regs =3D priv->regs + APLIC_IDC_BASE + i * APLIC_IDC_SIZE; + idc->hart_index =3D hart_index ? hart_index[i] : hartid - hartid0; + idc->regs =3D priv->regs + APLIC_IDC_BASE + idc->hart_index * APLIC_IDC_= SIZE; idc->direct =3D direct; =20 aplic_idc_set_delivery(idc, true); --=20 2.43.0