Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp2979694rwo; Mon, 24 Jul 2023 04:37:18 -0700 (PDT) X-Google-Smtp-Source: APBJJlEwya9BgnNPL/vcDQtTjSnKlpfwlreu12X2ggfO+1FMPXp7CM3RGGFYV/0q5E9nBILAsQIA X-Received: by 2002:ac2:5de2:0:b0:4fb:8a92:4fba with SMTP id z2-20020ac25de2000000b004fb8a924fbamr4293677lfq.25.1690198637695; Mon, 24 Jul 2023 04:37:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690198637; cv=none; d=google.com; s=arc-20160816; b=gNVf6Bxw1NJtLggRgPveqCwCzmP0/nVwMWKYO8nWBeqPhclNCZdQwmXEWa1MFivWMW GLN6CBAVXDE0XMLQudB3tLwUsy4Q6dE4EffB2poBSnMzze+4PwGD5ilVCwo0H6p3XUOX o6jBryua4OL7ZZaPvzadbkT6n4bIqWun6RQRhmpr18CeaUg2Q5ZiGl16HeHmJmVgVwcu yA0u+n9dktKcdMD011j7A7S7sTFm8L0bbq9pzT+/01Iwox+gpE4AYkH/6Bg4yXh3Vtw4 zVsA1OVR/oLOBCNScatUWj0Vxmi4yzIkRhDY/hjjNl6hlkboNocHWAYYeduZ77j18GhS 7tFA== 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=MSZt7mHez9tNJy/98/Qfr0OOVK6jV7kKAFtTUhVHj+4=; fh=I1kzkF3xVqPlnTzZscyJGFILAmKO2peBtWa2j72B2p8=; b=dbz+V139NJ/DbZhUm/gbwRq5THK8K9Ey8EjTwikgdOQcaIanpa3v6ByItbIVBEt5Yp ol6pfmHfuNvavu0D0X904zv8Qc1umRpAwKeXfg5vIjuVTMnsbjMVlGtk8vBwrKAuYZcZ aoN43N5O5yoxsD4+ASpbJohSbtfrSLQjAo8lLNY86mJO3HqCI2yAtDcPf/hpfi8smjLt ZksL0SdW+Oc75zPsA1I3SZcR1UrjIe5W7kwe/ShndquCZCa+ytXvoKE3WGRNQfbmZIlB 8FbU3DJxzlVBPMHu8jXQNN1OHQhxNcPz0y3ueg4LemF0CgwbP/dyuETQIvcUiLSTpEyE ehrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=Zu3QSNlW; 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 j26-20020aa7c0da000000b0051de3796896si6348884edp.211.2023.07.24.04.36.52; Mon, 24 Jul 2023 04:37:17 -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=Zu3QSNlW; 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 S229576AbjGXLci (ORCPT + 99 others); Mon, 24 Jul 2023 07:32:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230092AbjGXLc3 (ORCPT ); Mon, 24 Jul 2023 07:32:29 -0400 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D4D61BC0 for ; Mon, 24 Jul 2023 04:32:00 -0700 (PDT) Received: by mail-io1-xd2a.google.com with SMTP id ca18e2360f4ac-7836272f36eso156583239f.1 for ; Mon, 24 Jul 2023 04:32:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1690198314; x=1690803114; 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=MSZt7mHez9tNJy/98/Qfr0OOVK6jV7kKAFtTUhVHj+4=; b=Zu3QSNlWTHcd8OApwq0U+bD1SZkTRkdgFVizZQ0Kx7en8kEJKrVeVocSG+Chv6CbDP 8nJtj3qZsoyDChCMF0DmJt+9YtpDu01OVSusMX7q1fmFDHxXKGJHDUXT48KQnY/TCtTY Ca4tZz8IH40wQVfKABxCYjCdDP7vUQYkYJOd7Yf3WR6gZXyp2TUWTTa0LsG27VSBw3R2 r7jG9Qg1XyuTpO0sUi1Wh1+fPVhFZ3yF82QJ+Ou5dSdQIMJA1iqQvaZXvmw88x3vkHvl UyLDohMJw2aqsCJU6kE0hyYX+REUCLzbiWUui1gaA2l+B1Cl80IYVjKJFyIGGaPsc+ep oupw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690198314; x=1690803114; 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=MSZt7mHez9tNJy/98/Qfr0OOVK6jV7kKAFtTUhVHj+4=; b=IbfNnqt9Dr/+nYRzgnawnUi8ubiInR7fQ2+2wU2P94402Ohap7npq+77i535q7iNcM 2bcwexsuJ2H6uEBQ8BLLQDgLogOhxPczl4J0Qlq4eLJfw8baHEp8XO++KurnbShT26tf h8a8zduaBb4pUehpyYmnKxuU0IcigX51wv7V6h69h0DOm6uE9B+fvD+f0ma6X35T0NLJ JDaCvNokERgzkG5ONlQin7B55O2IpSs56bKXg0GEh/OAM3lItze+SmG60x/Ul813/3O/ mfxaikI5/auk3vwaz8IIcMlJ8yjbo4DEb4be7u1I3LoPSYN2nE29IzNhpeCXn7dlYpTn RaRg== X-Gm-Message-State: ABy/qLaMqv6qzJkYs9hsu+qPjcmT37FITuM+9cMy6lybcbhRsSvpiOk2 URFbD+KM/jITEqcV0FAr9gk0h4FeDmw+1M30fXfL9w== X-Received: by 2002:a6b:7f0a:0:b0:76c:8877:861d with SMTP id l10-20020a6b7f0a000000b0076c8877861dmr7363380ioq.1.1690198313863; Mon, 24 Jul 2023 04:31:53 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Zong Li Date: Mon, 24 Jul 2023 19:31:42 +0800 Message-ID: Subject: Re: [PATCH 03/11] dt-bindings: Add RISC-V IOMMU bindings To: Anup Patel 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 6:02=E2=80=AFPM Anup Patel wrote: > > On Mon, Jul 24, 2023 at 1:33=E2=80=AFPM Zong Li wrot= e: > > > > 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 devices > > > 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,iom= mu.yaml > > > > > > diff --git a/Documentation/devicetree/bindings/iommu/riscv,iommu.yaml= 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 platfor= ms > > > + which can be a regular platform device or a PCI device connected t= o > > > + the host root port. > > > + > > > + The RISC-V IOMMU provides two stage translation, device directory = table, > > > + command queue and fault reporting as wired interrupt or MSIx event= for > > > + both PCI and platform devices. > > > + > > > + Visit https://github.com/riscv-non-isa/riscv-iommu for more detail= s. > > > + > > > +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 root = 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 MMI= O base > > > + address of registers. > > > + > > > + For RISC-V IOMMU as a PCI device, this represents the PCI-PCI = bridge > > > + details as described in Documentation/devicetree/bindings/pci/= pci.txt > > > + > > > + '#iommu-cells': > > > + const: 2 > > > + description: | > > > + Each IOMMU specifier represents the base device ID and number = of > > > + device IDs. > > > + > > > + interrupts: > > > + minItems: 1 > > > + maxItems: 16 > > > + description: > > > + The presence of this property implies that given RISC-V IOMMU = uses > > > + wired interrupts to notify the RISC-V HARTS (or CPUs). > > > + > > > + msi-parent: > > > + description: > > > + The presence of this property implies that given RISC-V IOMMU = uses > > > + MSIx to notify the RISC-V HARTs (or CPUs). This property shoul= d be > > > + considered only when the interrupts property is absent. > > > + > > > + dma-coherent: > > > + description: > > > + Present if page table walks and DMA accessed made by the RISC-= 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-coh= erent) > and not of the IOMMU. Other architectures (ARM and x86) never added such > 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 def= ault. > 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. > 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 0= x0 0x00010000>, > > > + <0x02000000 0x0 0x41000000 0x0 0x41000000 0x0= 0x3f000000>; > > > + > > > + #interrupt-cells =3D <0x1>; > > > + > > > + /* PCI_DEVICE(3) INT#(1) CONTROLLER(PHANDLE) CONTROLL= ER_DATA(2) */ > > > + interrupt-map =3D < 0x0 0x0 0x0 0x1 &aplic_smode 0x= 4 0x1>, > > > + < 0x800 0x0 0x0 0x1 &aplic_smode 0x5 = 0x1>, > > > + <0x1000 0x0 0x0 0x1 &aplic_smode 0x6 = 0x1>, > > > + <0x1800 0x0 0x0 0x1 &aplic_smode 0x7 = 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 immu2 = */ > > > + 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