Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp3053594rwo; Mon, 24 Jul 2023 05:42:55 -0700 (PDT) X-Google-Smtp-Source: APBJJlH86UVpafiRjhWQPhMxGas4f2KhE+CwaXs6rZt6AGenhfv5zB2i9FI49r4VscRn6gY8pzOi X-Received: by 2002:a05:6870:73c7:b0:1b7:6bf6:60cb with SMTP id a7-20020a05687073c700b001b76bf660cbmr10201022oan.55.1690202574864; Mon, 24 Jul 2023 05:42:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690202574; cv=none; d=google.com; s=arc-20160816; b=EJ5IImPeHEf9w3tabpsUBDKTW74d8uDr9jTJPxp/O7UzbMQJkPNRIuyYLsQlzEv0qW 5Hp6ZN9OIElQWn+6kKucwwjdXv+6ocnbz/nBaNyuY7n4H8i9C995cjBki6CPOQMKkUbr cvFBPR/i2QMvFacdNfip4mokzWeDNLglCtd/qm0DlxxsKlpNiYbxQf7eL56+pzblBiN0 TGr9RQuHt6XDEnFp+mJNEn+V6O/jqtgkrV96B43AMprTLfHXI2w5EbL33kmtM3d4VvCU fgoIsc74+CY5iSIFO7PRGi0H4j3Ne1r0kHz1NapStRiWSPBvBCShrg8+BlcsAZSPekxd JAgA== 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=Fjh0h6en9trTPq3UL6xtT9eD9xJ+RZwfXGu7HnVOnQM=; fh=i86dNHzUtBJUwL1Mrhr9mHgzxycNBrvCSvfEPOfonyo=; b=Gxs3wCnQ+4TXE2NEm+1RIKzG0nUCcLqRz/7AUBai1XdWIoIQ7IqiRwXSS/3RaGWyRq 6ez11UdiJ0G5EpsTD4u7c/nZrJPUXyaZq8A46ejXxXAfjARmlCOgfzCuloxk1X8lNPcI JScvoAPocmP57LB71r0h2TksFPLDTqQ/+/vkF5ogMxhgpl32cQn3ig6CrtVj2gTyaYUH cuOND8oJkQ98PPp034M5wxOSkpFtvbj15p06oEMusI1V/qDDA6Z7hJLnahOffPVMsl6f dURPllvLRfxGfDk3GClqikvW1NJnkZXM0KUl8f75JVx9OeQpXoKCNWrGi69svF4dG4yl qc6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=fYpwhXgp; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fj19-20020a056a003a1300b0066871b54e15si9030931pfb.359.2023.07.24.05.42.41; Mon, 24 Jul 2023 05:42:54 -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=@ventanamicro.com header.s=google header.b=fYpwhXgp; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230106AbjGXMKb (ORCPT + 99 others); Mon, 24 Jul 2023 08:10:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229477AbjGXMK3 (ORCPT ); Mon, 24 Jul 2023 08:10:29 -0400 Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 809671A1 for ; Mon, 24 Jul 2023 05:10:27 -0700 (PDT) Received: by mail-io1-xd32.google.com with SMTP id ca18e2360f4ac-77acb04309dso252378739f.2 for ; Mon, 24 Jul 2023 05:10:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1690200627; x=1690805427; 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=Fjh0h6en9trTPq3UL6xtT9eD9xJ+RZwfXGu7HnVOnQM=; b=fYpwhXgpj4aiqH/g8yiXHfVqiyT8cx/IiuHsRtC8KDhdP49xFR6I8sIPSLmkdbyjYW 9Aga0bhsoBnNsDFcyMveR1f1GqvPZLfEVk8x8hn3k/c2eJJ4e5+G3QYLRRs51tPDO75w C38sUSOCVVvBdqUbk7lvQagQdXrXqKVt2rR2bHPU57UWAJFyWt9yY2TEQIgEltibT5Lt irKnxL2l6WdudyetcGF6vrnHZYW8fp1yBnx+DweHUsV1/CuKB2CoCxndOyM988esSk8+ H/4wkbx0xbb/yMOKzeZQKLrOBd3lfZqNuW9W0pdWCXxfDNmn+4e0PDdmeUO59XSxt+Tp DbHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690200627; x=1690805427; 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=Fjh0h6en9trTPq3UL6xtT9eD9xJ+RZwfXGu7HnVOnQM=; b=buvdBW2wpo3ly29cB+DYGQCK6I+8MWUF560CQj9SuZZplDP83ZJpK5U0q/Snk1H//R Hf5hKaZu+PJgy+k+C41lR+ZpMV23TBLayZoG6dDFQq1Euqw8YoX4OaVmNIjNrwnsdwKN Sbj+ot/qITc9Y64S8e8+l9wwrn6K3nus1hTeahMEO9VFEhValTs4VAXk7FS5McygJwTj vDAWvCoNvEuPWQRIprMGmlivjHcVPoDJmmCAyN+mIp4pUBEfb+7nqdUXsLUQAYHq1TXh /CqLBmJ0GA8ZMnp8yfYGDHGneFzCfJ6waVtaFNlm7eRUzUiOPN9EP+xFaj3Lo5FIpRtp h0Ig== X-Gm-Message-State: ABy/qLb+BKw3bVd9FHgPXGv+PXm+8s0vBW/YbO9+35vM5vDIVv8IZpbd uHZpUztXzYk0hk8AxB4cPheBPJ2zLzDHDRMcI7ETUQ== X-Received: by 2002:a05:6e02:1090:b0:348:8b32:7ca3 with SMTP id r16-20020a056e02109000b003488b327ca3mr8136105ilj.5.1690200626675; Mon, 24 Jul 2023 05:10:26 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Anup Patel Date: Mon, 24 Jul 2023 17:40:14 +0530 Message-ID: Subject: Re: [PATCH 03/11] dt-bindings: Add RISC-V IOMMU bindings To: Zong Li Cc: Tomasz Jeznach , Joerg Roedel , Will Deacon , Robin Murphy , Paul Walmsley , Albert Ou , linux@rivosinc.com, linux-kernel@vger.kernel.org, Sebastien Boeuf , iommu@lists.linux.dev, Palmer Dabbelt , Nick Kossifidis , linux-riscv@lists.infradead.org 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_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Mon, Jul 24, 2023 at 5:01=E2=80=AFPM Zong Li wrote: > > On Mon, Jul 24, 2023 at 6:02=E2=80=AFPM Anup Patel wrote: > > > > On Mon, Jul 24, 2023 at 1:33=E2=80=AFPM Zong Li wr= ote: > > > > > > On Thu, Jul 20, 2023 at 3:35=E2=80=AFAM Tomasz Jeznach wrote: > > > > > > > > From: Anup Patel > > > > > > > > We add DT bindings document for RISC-V IOMMU platform and PCI devic= es > > > > defined by the RISC-V IOMMU specification. > > > > > > > > Signed-off-by: Anup Patel > > > > --- > > > > .../bindings/iommu/riscv,iommu.yaml | 146 ++++++++++++++= ++++ > > > > 1 file changed, 146 insertions(+) > > > > create mode 100644 Documentation/devicetree/bindings/iommu/riscv,i= ommu.yaml > > > > > > > > diff --git a/Documentation/devicetree/bindings/iommu/riscv,iommu.ya= ml b/Documentation/devicetree/bindings/iommu/riscv,iommu.yaml > > > > new file mode 100644 > > > > index 000000000000..8a9aedb61768 > > > > --- /dev/null > > > > +++ b/Documentation/devicetree/bindings/iommu/riscv,iommu.yaml > > > > @@ -0,0 +1,146 @@ > > > > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > > > > +%YAML 1.2 > > > > +--- > > > > +$id: http://devicetree.org/schemas/iommu/riscv,iommu.yaml# > > > > +$schema: http://devicetree.org/meta-schemas/core.yaml# > > > > + > > > > +title: RISC-V IOMMU Implementation > > > > + > > > > +maintainers: > > > > + - Tomasz Jeznach > > > > + > > > > +description: > > > > + The RISC-V IOMMU specificaiton defines an IOMMU for RISC-V platf= orms > > > > + which can be a regular platform device or a PCI device connected= to > > > > + the host root port. > > > > + > > > > + The RISC-V IOMMU provides two stage translation, device director= y table, > > > > + command queue and fault reporting as wired interrupt or MSIx eve= nt for > > > > + both PCI and platform devices. > > > > + > > > > + Visit https://github.com/riscv-non-isa/riscv-iommu for more deta= ils. > > > > + > > > > +properties: > > > > + compatible: > > > > + oneOf: > > > > + - description: RISC-V IOMMU as a platform device > > > > + items: > > > > + - enum: > > > > + - vendor,chip-iommu > > > > + - const: riscv,iommu > > > > + > > > > + - description: RISC-V IOMMU as a PCI device connected to roo= t port > > > > + items: > > > > + - enum: > > > > + - vendor,chip-pci-iommu > > > > + - const: riscv,pci-iommu > > > > + > > > > + reg: > > > > + maxItems: 1 > > > > + description: > > > > + For RISC-V IOMMU as a platform device, this represents the M= MIO base > > > > + address of registers. > > > > + > > > > + For RISC-V IOMMU as a PCI device, this represents the PCI-PC= I bridge > > > > + details as described in Documentation/devicetree/bindings/pc= i/pci.txt > > > > + > > > > + '#iommu-cells': > > > > + const: 2 > > > > + description: | > > > > + Each IOMMU specifier represents the base device ID and numbe= r of > > > > + device IDs. > > > > + > > > > + interrupts: > > > > + minItems: 1 > > > > + maxItems: 16 > > > > + description: > > > > + The presence of this property implies that given RISC-V IOMM= U uses > > > > + wired interrupts to notify the RISC-V HARTS (or CPUs). > > > > + > > > > + msi-parent: > > > > + description: > > > > + The presence of this property implies that given RISC-V IOMM= U uses > > > > + MSIx to notify the RISC-V HARTs (or CPUs). This property sho= uld be > > > > + considered only when the interrupts property is absent. > > > > + > > > > + dma-coherent: > > > > + description: > > > > + Present if page table walks and DMA accessed made by the RIS= C-V IOMMU > > > > + are cache coherent with the CPU. > > > > + > > > > + power-domains: > > > > + maxItems: 1 > > > > + > > > > > > In RISC-V IOMMU, certain devices can be set to bypass mode when the > > > IOMMU is in translation mode. To identify the devices that require > > > bypass mode by default, does it be sensible to add a property to > > > indicate this behavior? > > > > Bypass mode for a device is a property of that device (similar to dma-c= oherent) > > and not of the IOMMU. Other architectures (ARM and x86) never added suc= h > > a device property for bypass mode so I guess it is NOT ADVISABLE to do = it. > > > > If this is REALLY required then we can do something similar to the QCOM > > SMMU driver where they have a whitelist of devices which are allowed to > > be in bypass mode (i.e. IOMMU_DOMAIN_IDENTITY) based their device > > compatible string and any device outside this whitelist is blocked by d= efault. > > > > I have considered that adding the property of bypass mode to that > device would be more appropriate. However, if we want to define this > property for the device, it might need to go through the generic IOMMU > dt-bindings, but I'm not sure if other IOMMU devices need this. I am > bringing up this topic here because I would like to explore if there > are any solutions on the IOMMU side, such as a property that indicates > the phandle of devices wishing to set bypass mode, somewhat similar to > the whitelist you mentioned earlier. Do you think we should address > this? After all, this is a case of RISC-V IOMMU supported. Bypass mode is a common feature across IOMMUs. Other IOMMUs don't have a special property for bypass mode at device-level or at IOMMU level, which clearly indicates that defining a RISC-V specific property is not the right way to go. The real question is how do we set IOMMU_DOMAIN_IDENTITY (i.e. bypass/identity domain) as the default domain for certain devices ? One possible option is to implement def_domain_type() IOMMU operation for RISC-V IOMMU which will return IOMMU_DOMAIN_IDENTITY for certain devices based on compatible string matching (i.e. whitelist of devices). As an example, refer qcom_smmu_def_domain_type() of drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c Regards, Anup > > > Regards, > > Anup > > > > > > > > > +required: > > > > + - compatible > > > > + - reg > > > > + - '#iommu-cells' > > > > + > > > > +additionalProperties: false > > > > + > > > > +examples: > > > > + - | > > > > + /* Example 1 (IOMMU platform device with wired interrupts) */ > > > > + immu1: iommu@1bccd000 { > > > > + compatible =3D "vendor,chip-iommu", "riscv,iommu"; > > > > + reg =3D <0x1bccd000 0x1000>; > > > > + interrupt-parent =3D <&aplic_smode>; > > > > + interrupts =3D <32 4>, <33 4>, <34 4>, <35 4>; > > > > + #iommu-cells =3D <2>; > > > > + }; > > > > + > > > > + /* Device with two IOMMU device IDs, 0 and 7 */ > > > > + master1 { > > > > + iommus =3D <&immu1 0 1>, <&immu1 7 1>; > > > > + }; > > > > + > > > > + - | > > > > + /* Example 2 (IOMMU platform device with MSIs) */ > > > > + immu2: iommu@1bcdd000 { > > > > + compatible =3D "vendor,chip-iommu", "riscv,iommu"; > > > > + reg =3D <0x1bccd000 0x1000>; > > > > + msi-parent =3D <&imsics_smode>; > > > > + #iommu-cells =3D <2>; > > > > + }; > > > > + > > > > + bus { > > > > + #address-cells =3D <2>; > > > > + #size-cells =3D <2>; > > > > + > > > > + /* Device with IOMMU device IDs ranging from 32 to 64 */ > > > > + master1 { > > > > + iommus =3D <&immu2 32 32>; > > > > + }; > > > > + > > > > + pcie@40000000 { > > > > + compatible =3D "pci-host-cam-generic"; > > > > + device_type =3D "pci"; > > > > + #address-cells =3D <3>; > > > > + #size-cells =3D <2>; > > > > + bus-range =3D <0x0 0x1>; > > > > + > > > > + /* CPU_PHYSICAL(2) SIZE(2) */ > > > > + reg =3D <0x0 0x40000000 0x0 0x1000000>; > > > > + > > > > + /* BUS_ADDRESS(3) CPU_PHYSICAL(2) SIZE(2) */ > > > > + ranges =3D <0x01000000 0x0 0x01000000 0x0 0x01000000 = 0x0 0x00010000>, > > > > + <0x02000000 0x0 0x41000000 0x0 0x41000000 0= x0 0x3f000000>; > > > > + > > > > + #interrupt-cells =3D <0x1>; > > > > + > > > > + /* PCI_DEVICE(3) INT#(1) CONTROLLER(PHANDLE) CONTRO= LLER_DATA(2) */ > > > > + interrupt-map =3D < 0x0 0x0 0x0 0x1 &aplic_smode = 0x4 0x1>, > > > > + < 0x800 0x0 0x0 0x1 &aplic_smode 0x= 5 0x1>, > > > > + <0x1000 0x0 0x0 0x1 &aplic_smode 0x= 6 0x1>, > > > > + <0x1800 0x0 0x0 0x1 &aplic_smode 0x= 7 0x1>; > > > > + > > > > + /* PCI_DEVICE(3) INT#(1) */ > > > > + interrupt-map-mask =3D <0xf800 0x0 0x0 0x7>; > > > > + > > > > + msi-parent =3D <&imsics_smode>; > > > > + > > > > + /* Devices with bus number 0-127 are mastered via immu= 2 */ > > > > + iommu-map =3D <0x0000 &immu2 0x0000 0x8000>; > > > > + }; > > > > + }; > > > > +... > > > > -- > > > > 2.34.1 > > > > > > > > > > > > _______________________________________________ > > > > linux-riscv mailing list > > > > linux-riscv@lists.infradead.org > > > > http://lists.infradead.org/mailman/listinfo/linux-riscv