Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp2407434rdg; Mon, 14 Aug 2023 01:08:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHkGrWBn1YUXRV9Ha8aCPBvYZwwVJeSRgfiZ8ZZgD+uHWEnLpYBuoZqMB//UqZIIgLaJJM1 X-Received: by 2002:a17:902:eccf:b0:1bc:4415:3c1 with SMTP id a15-20020a170902eccf00b001bc441503c1mr16642252plh.7.1692000509868; Mon, 14 Aug 2023 01:08:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692000509; cv=none; d=google.com; s=arc-20160816; b=uIQ+75AdO2A/D31Z3KkF2WqeMrnHrY2H8t/Pj+R3OYAoETrWKyzThFiKDPpQKe8prK 808UD4saLVvAVNgHMzOJ8GjjxZp313xqag2rWfxIa0hHvmzFvClHQN1C2xW03oSfhHED TzYPyy3l9Aj6r+TDNBafK2PzDeKS/6F+emPbZ0E4ZU4eS6C11DUl0g9hqVr2UN9mHSZm nySl9plcTZ23uhbkJvX/mB4fD2w2038LFm3/3kD4kRi/zTxkss5WrtQj/2UBK9Ilqt03 V04lqqXShmi1v/icIiRJBF+ti5ukzDb39gFWxqLdRdortQCFtkv4r1jCXc60VO2skosm aEyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=j/77JVQ6SRauXOW8b0KyMolSxYaNuLZkMQtli22d1Tk=; fh=5H5aXWuurCbQdDPwZ7fHhfVDc7XXaKZ+MAan9mFZpMI=; b=yFRu+GB3BOmk56HAq78OTbvIWkppBg/habdKrjFnmBhoptwc9xQfrAEUXo27FTUc7r Uas8n/ImB5OxhlYQrTD1R6MvK3UrX+AuonUDCOxGFacQUryTgbQTOHN9TMipfDx6zkJR VRi0CKCs2d3n/q0FuRljWJyGG4VkJ7f0WbbvfAP7XlyGbhEnU7LDK7Z5KfhF9TszRTDT /17B7+wH1BneqF+W0hq3ioqaRjb6Oqek4LBUohbD1wE+5UehJ/d+R38qeK2XTFtY4pnv RWgElNuDgKW6K3KKZn2TUQFphaQ4i7P30Mr0emmQ9BWxWCQC9wnXDY0/dIzLysbTRH9H uKQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b="lOf/R5gG"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k7-20020a170902c40700b001bb0fb5e06csi8155222plk.483.2023.08.14.01.08.17; Mon, 14 Aug 2023 01:08:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b="lOf/R5gG"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233862AbjHNGoU (ORCPT + 99 others); Mon, 14 Aug 2023 02:44:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233325AbjHNGoL (ORCPT ); Mon, 14 Aug 2023 02:44:11 -0400 Received: from mail-vk1-xa31.google.com (mail-vk1-xa31.google.com [IPv6:2607:f8b0:4864:20::a31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A9D3E5D for ; Sun, 13 Aug 2023 23:44:08 -0700 (PDT) Received: by mail-vk1-xa31.google.com with SMTP id 71dfb90a1353d-48719e50231so2651128e0c.0 for ; Sun, 13 Aug 2023 23:44:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1691995447; x=1692600247; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=j/77JVQ6SRauXOW8b0KyMolSxYaNuLZkMQtli22d1Tk=; b=lOf/R5gG9ICXR5lHM0CHhvn74rBfCH3VtPDp1UDu8zT/i83ZbdnIjeB21MhFvJZwnZ Ep7GKqhxCjWZYJ/JVILibu/Z4tePMuhvC+EiU6LLBAcYmQ1qU4xPUIjNMopFUl+R235T WLq0dE2x1zZwEGdiCbjlprH8LvFza/C1tMJjvTX16mFCUnWMP4j5Ii8DbtGYxPAsW+6P yc2nAHOAEhyqu0FaF9gDC3FqRkRHK2CajbzMngC2C2GMGV9r4LRFG3y/iRg0yQ+80z2i ChriRLjOdRBCbgk1cs9TLo5LsA9IgkTQpRUkTK5jUFAnLl7SHhz5qHI1EFz9vtu6W5Tl wd1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691995447; x=1692600247; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=j/77JVQ6SRauXOW8b0KyMolSxYaNuLZkMQtli22d1Tk=; b=jxWcRjj1y2Zdyrwp/ylaZP5eJ+rqXHjpOKx8r/b39jTYVOYtQmG8R/VMbC9eRBNcCz gITNuH0CWUeVo4ab9tOsERrE+QZSFhLp2o3vcsryd56gcDdVIyWy7jZvMAE0R0QIzNkD KDbXXM5pWR9ITWU9DswkY+Rgf76Qbg8V3/6baojXZTR6lVAAm2xakCCXHwMgYZRyJfOi 8LBpjJT8YFDjHiMav6JfPyLMY+3sk/3Xdu6wMojuVRW2AeOWKstIU9OTW01UWUEulRxH V9t9KuW9MmboT2sbCRAxMsweF1UKMZ322cs3oRZY+6ft2iPECsp8tSMTAwyvUW2hGJl5 YPuA== X-Gm-Message-State: AOJu0Yxy171aYN6Q3tBXDqBLlnaorpg5whygUzmZpLrumauyKvJNUCBt /8b1gz/N7IHkOwcOXVeE+6qanRHs4ps3zkhA8EEV6Q== X-Received: by 2002:a1f:a7cc:0:b0:487:d927:38f0 with SMTP id q195-20020a1fa7cc000000b00487d92738f0mr4764608vke.5.1691995447315; Sun, 13 Aug 2023 23:44:07 -0700 (PDT) MIME-Version: 1.0 References: <20230802150018.327079-1-apatel@ventanamicro.com> <20230802150018.327079-12-apatel@ventanamicro.com> In-Reply-To: From: Vincent Chen Date: Mon, 14 Aug 2023 14:43:56 +0800 Message-ID: Subject: Re: [PATCH v7 11/15] dt-bindings: interrupt-controller: Add RISC-V advanced PLIC To: Anup Patel Cc: Palmer Dabbelt , Paul Walmsley , Thomas Gleixner , Marc Zyngier , Rob Herring , Krzysztof Kozlowski , Frank Rowand , Conor Dooley , devicetree@vger.kernel.org, Saravana Kannan , Anup Patel , linux-kernel@vger.kernel.org, Conor Dooley , Atish Patra , linux-riscv@lists.infradead.org, Andrew Jones Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Aug 12, 2023 at 10:59=E2=80=AFAM Anup Patel wrote: > > On Thu, Aug 10, 2023 at 4:59=E2=80=AFPM Vincent Chen wrote: > > > > > > > > On Thu, Aug 10, 2023 at 4:08=E2=80=AFPM Anup Patel wrote: > >> > >> On Thu, Aug 10, 2023 at 1:31=E2=80=AFPM Vincent Chen wrote: > >> > > >> > > >> > > >> > On Wed, Aug 2, 2023 at 11:02=E2=80=AFPM Anup Patel wrote: > >> >> > >> >> We add DT bindings document for RISC-V advanced platform level inte= rrupt > >> >> controller (APLIC) defined by the RISC-V advanced interrupt archite= cture > >> >> (AIA) specification. > >> >> > >> >> Signed-off-by: Anup Patel > >> >> Reviewed-by: Conor Dooley > >> >> --- > >> >> .../interrupt-controller/riscv,aplic.yaml | 172 ++++++++++++++= ++++ > >> >> 1 file changed, 172 insertions(+) > >> >> create mode 100644 Documentation/devicetree/bindings/interrupt-con= troller/riscv,aplic.yaml > >> >> > >> >> diff --git a/Documentation/devicetree/bindings/interrupt-controller= /riscv,aplic.yaml b/Documentation/devicetree/bindings/interrupt-controller/= riscv,aplic.yaml > >> >> new file mode 100644 > >> >> index 000000000000..190a6499c932 > >> >> --- /dev/null > >> >> +++ b/Documentation/devicetree/bindings/interrupt-controller/riscv,= aplic.yaml > >> >> @@ -0,0 +1,172 @@ > >> >> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > >> >> +%YAML 1.2 > >> >> +--- > >> >> +$id: http://devicetree.org/schemas/interrupt-controller/riscv,apli= c.yaml# > >> >> +$schema: http://devicetree.org/meta-schemas/core.yaml# > >> >> + > >> >> +title: RISC-V Advanced Platform Level Interrupt Controller (APLIC) > >> >> + > >> >> +maintainers: > >> >> + - Anup Patel > >> >> + > >> >> +description: > >> >> + The RISC-V advanced interrupt architecture (AIA) defines an adva= nced > >> >> + platform level interrupt controller (APLIC) for handling wired i= nterrupts > >> >> + in a RISC-V platform. The RISC-V AIA specification can be found = at > >> >> + https://github.com/riscv/riscv-aia. > >> >> + > >> >> + The RISC-V APLIC is implemented as hierarchical APLIC domains wh= ere all > >> >> + interrupt sources connect to the root APLIC domain and a parent = APLIC > >> >> + domain can delegate interrupt sources to it's child APLIC domain= s. There > >> >> + is one device tree node for each APLIC domain. > >> >> + > >> >> +allOf: > >> >> + - $ref: /schemas/interrupt-controller.yaml# > >> >> + > >> >> +properties: > >> >> + compatible: > >> >> + items: > >> >> + - enum: > >> >> + - qemu,aplic > >> >> + - const: riscv,aplic > >> >> + > >> >> + reg: > >> >> + maxItems: 1 > >> >> + > >> >> + interrupt-controller: true > >> >> + > >> >> + "#interrupt-cells": > >> >> + const: 2 > >> >> + > >> >> + interrupts-extended: > >> >> + minItems: 1 > >> >> + maxItems: 16384 > >> >> + description: > >> >> + Given APLIC domain directly injects external interrupts to a= set of > >> >> + RISC-V HARTS (or CPUs). Each node pointed to should be a ris= cv,cpu-intc > >> >> + node, which has a CPU node (i.e. RISC-V HART) as parent. > >> >> + > >> >> + msi-parent: > >> >> + description: > >> >> + Given APLIC domain forwards wired interrupts as MSIs to a AI= A incoming > >> >> + message signaled interrupt controller (IMSIC). If both "msi-= parent" and > >> >> + "interrupts-extended" properties are present then it means t= he APLIC > >> >> + domain supports both MSI mode and Direct mode in HW. In this= case, the > >> >> + APLIC driver has to choose between MSI mode or Direct mode. > >> >> + > >> >> + riscv,num-sources: > >> >> + $ref: /schemas/types.yaml#/definitions/uint32 > >> >> + minimum: 1 > >> >> + maximum: 1023 > >> >> + description: > >> >> + Specifies the number of wired interrupt sources supported by= this > >> >> + APLIC domain. > >> >> + > >> >> + riscv,children: > >> >> + $ref: /schemas/types.yaml#/definitions/phandle-array > >> >> + minItems: 1 > >> >> + maxItems: 1024 > >> >> + items: > >> >> + maxItems: 1 > >> >> + description: > >> >> + A list of child APLIC domains for the given APLIC domain. Ea= ch child > >> >> + APLIC domain is assigned a child index in increasing order, = with the > >> >> + first child APLIC domain assigned child index 0. The APLIC d= omain child > >> >> + index is used by firmware to delegate interrupts from the gi= ven APLIC > >> >> + domain to a particular child APLIC domain. > >> >> + > >> >> + riscv,delegation: > >> >> + $ref: /schemas/types.yaml#/definitions/phandle-array > >> >> + minItems: 1 > >> >> + maxItems: 1024 > >> >> + items: > >> >> + items: > >> >> + - description: child APLIC domain phandle > >> >> + - description: first interrupt number of the parent APLIC = domain (inclusive) > >> >> + - description: last interrupt number of the parent APLIC d= omain (inclusive) > >> >> + description: > >> >> + A interrupt delegation list where each entry is a triple con= sisting > >> >> + of child APLIC domain phandle, first interrupt number of the= parent > >> >> + APLIC domain, and last interrupt number of the parent APLIC = domain. > >> >> + Firmware must configure interrupt delegation registers based= on > >> >> + interrupt delegation list. > >> >> + > >> >> +dependencies: > >> >> + riscv,delegation: [ "riscv,children" ] > >> >> + > >> >> +required: > >> >> + - compatible > >> >> + - reg > >> >> + - interrupt-controller > >> >> + - "#interrupt-cells" > >> >> + - riscv,num-sources > >> >> + > >> >> +anyOf: > >> >> + - required: > >> >> + - interrupts-extended > >> >> + - required: > >> >> + - msi-parent > >> >> + > >> >> +unevaluatedProperties: false > >> >> + > >> >> +examples: > >> >> + - | > >> >> + // Example 1 (APLIC domains directly injecting interrupt to HA= RTs): > >> >> + > >> >> + interrupt-controller@c000000 { > >> >> + compatible =3D "qemu,aplic", "riscv,aplic"; > >> >> + interrupts-extended =3D <&cpu1_intc 11>, > >> >> + <&cpu2_intc 11>, > >> >> + <&cpu3_intc 11>, > >> >> + <&cpu4_intc 11>; > >> >> + reg =3D <0xc000000 0x4080>; > >> >> + interrupt-controller; > >> >> + #interrupt-cells =3D <2>; > >> >> + riscv,num-sources =3D <63>; > >> >> + riscv,children =3D <&aplic1>, <&aplic2>; > >> >> + riscv,delegation =3D <&aplic1 1 63>; > >> >> + }; > >> >> + > >> >> + aplic1: interrupt-controller@d000000 { > >> >> + compatible =3D "qemu,aplic", "riscv,aplic"; > >> >> + interrupts-extended =3D <&cpu1_intc 9>, > >> >> + <&cpu2_intc 9>; > >> >> + reg =3D <0xd000000 0x4080>; > >> >> + interrupt-controller; > >> >> + #interrupt-cells =3D <2>; > >> >> + riscv,num-sources =3D <63>; > >> >> + }; > >> >> + > >> >> + aplic2: interrupt-controller@e000000 { > >> >> + compatible =3D "qemu,aplic", "riscv,aplic"; > >> >> + interrupts-extended =3D <&cpu3_intc 9>, > >> >> + <&cpu4_intc 9>; > >> >> + reg =3D <0xe000000 0x4080>; > >> >> + interrupt-controller; > >> >> + #interrupt-cells =3D <2>; > >> >> + riscv,num-sources =3D <63>; > >> >> + }; > >> >> + > >> > > >> > > >> > Hi Anup, > >> > I have some thoughts regarding the APLIC DTS node. While I understan= d that it might be a bit late to discuss this matter within the v7 patch (s= orry for this), I hope you could still consider the following idea. > >> > > >> > For example 1, my understanding is that each APLIC DTS node represen= ts an interrupt domain. IIUC, in physical, these tree Interrupt domains sho= uld belong to an APLIC device so the M-mode IRQ domain can delegate interru= pts to the child domain. Given this perspective, wrapping all interrupt dom= ain DTS nodes with another DTS node seems to present the real scene more cl= early. Maybe we can add "simple-bus" to the compatible property of this wra= pped DTS node, so it still can be compatible with your driver implementatio= ns. Therefore, example 1 may become the following. > >> > > >> > interrupt-controller { > >> > compatible =3D "riscv,aplics", "simple-bus"; > >> > ranges; > >> > aplic0: interrupt-domain@c000000 { > >> > compatible =3D "qemu,aplic", "riscv,aplic"; > >> > interrupts-extended =3D <&cpu1_intc 11>, > >> > <&cpu2_intc 11>, > >> > <&cpu3_intc 11>, > >> > <&cpu4_intc 11>; > >> > reg =3D <0xc000000 0x4080>; > >> > interrupt-controller; > >> > #interrupt-cells =3D <2>; > >> > riscv,num-sources =3D <63>; > >> > riscv,children =3D <&aplic1>, <&aplic2>; > >> > riscv,delegation =3D <&aplic1 1 63>; > >> > }; > >> > > >> > aplic1: interrupt-domain@d000000 { > >> > compatible =3D "qemu,aplic", "riscv,aplic"; > >> > interrupts-extended =3D <&cpu1_intc 9>, > >> > <&cpu2_intc 9>; > >> > reg =3D <0xd000000 0x4080>; > >> > interrupt-controller; > >> > #interrupt-cells =3D <2>; > >> > riscv,num-sources =3D <63>; > >> > }; > >> > > >> > aplic2: interrupt-domain@e000000 { > >> > compatible =3D "qemu,aplic", "riscv,aplic"; > >> > interrupts-extended =3D <&cpu3_intc 9>, > >> > <&cpu4_intc 9>; > >> > reg =3D <0xe000000 0x4080>; > >> > interrupt-controller; > >> > #interrupt-cells =3D <2>; > >> > riscv,num-sources =3D <63>; > >> > }; > >> > }; > >> > Is it feasible for you? > >> > >> This clubbing of APLIC domains and placing them close to each > >> other is a platform implementation choice. On multi-die or multi-socke= t > >> systems the APIC domains can be really far apart on different physical > >> dies so the clubbing you suggest is not always true. > >> > >> Regards, > >> Anup > >> > > IIUC, I think my suggestion might be able to apply to this scenario if = these interrupt domains belong to the same APLIC device. For this scenario,= one thing I am concerned about is that the MMIO region of other devices lo= cates between interrupt domains. However, currently, I have not found that = the DTS specification explicitly prohibits it. Do you have the same concern= ? > > One APLIC device implementing multiple APLIC domains is perfectly fine > and there is nothing in this DT bindings which prevents that. > > We can always group multiple APLIC domain DT nodes under another DT > node but we don't need any special DT bindings for such grouping and > the APLIC driver does not need to be aware of this grouping. Further, > the AIA spec does not mandate grouping of APLIC domains under one > APLIC device. > > Like I said previously, the grouping of APLIC domains under one DT > node is implementation/platform specific. > I understood. Thanks for your reply. Thanks, Vincent > Regards, > Anup > > > > > Thanks, > > Vincent > >> > >> > > >> > Thanks, > >> > Vincent > >> > > >> >> > >> >> + - | > >> >> + // Example 2 (APLIC domains forwarding interrupts as MSIs): > >> >> + > >> >> + interrupt-controller@c000000 { > >> >> + compatible =3D "qemu,aplic", "riscv,aplic"; > >> >> + msi-parent =3D <&imsic_mlevel>; > >> >> + reg =3D <0xc000000 0x4000>; > >> >> + interrupt-controller; > >> >> + #interrupt-cells =3D <2>; > >> >> + riscv,num-sources =3D <63>; > >> >> + riscv,children =3D <&aplic3>; > >> >> + riscv,delegation =3D <&aplic3 1 63>; > >> >> + }; > >> >> + > >> >> + aplic3: interrupt-controller@d000000 { > >> >> + compatible =3D "qemu,aplic", "riscv,aplic"; > >> >> + msi-parent =3D <&imsic_slevel>; > >> >> + reg =3D <0xd000000 0x4000>; > >> >> + interrupt-controller; > >> >> + #interrupt-cells =3D <2>; > >> >> + riscv,num-sources =3D <63>; > >> >> + }; > >> >> +... > >> >> -- > >> >> 2.34.1 > >> >> > >> >> > >> >> _______________________________________________ > >> >> linux-riscv mailing list > >> >> linux-riscv@lists.infradead.org > >> >> http://lists.infradead.org/mailman/listinfo/linux-riscv