Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp570544rwb; Tue, 25 Jul 2023 22:09:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlEy6VKlJ9rtDw70IzYpWHj+O3xbsQqvRV7tFDF6HGOmnmCDsNi2DHJl9RAB4q+uZNOXPqza X-Received: by 2002:a17:903:32c5:b0:1bb:377f:8cbf with SMTP id i5-20020a17090332c500b001bb377f8cbfmr1579078plr.16.1690348149354; Tue, 25 Jul 2023 22:09:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690348149; cv=none; d=google.com; s=arc-20160816; b=lJxVLa+QtyINNXkEbDmiBHtVWdk1vj7lmXGyTvYkMbHaYan0htE/Fim76NgKfopXDM uAf1ArrjhPu9tGBEt09G9JyL4X6o8dpRGiKCjwq+t8IYDUrNs9futMr9gWAdBxpMDgzp KHx+0nuti5rKAwwm85hov15P7Cwt3ebgDbM4YSrGijeHiXbkZeMvSop+U16bl0N95kzq //QbMdaMAouvm913SnBNiBSoA7Q/4emldcOGlHR7cOkInrS4tP39qsD1AP6Jw+1hvgxM FVapK914GAOoQMfgjR28B3s0FXoaS1tVbuBb2WaFCYeq/UCSzXDM3YoTW3YQ6opJYEC2 KBVg== 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=lavfuE2py63kVqVG37hnlHpSBQOco6qEbPDbyiaGHr8=; fh=fkL0/DlI12QByvB73rk7/7wy4jHHBB6/KObnqrWRfJc=; b=SVQPvOn4lPPIFi1J1ckSDmhEkziqoZ4c4Vr/mM2EZxN2zPOd+FgDH4jAp7rO0Aq5KK dQPljGXek/NLnddsFAZATAht82TWsmYT+hBYlUXMWDwQEw5JHO+oc7/s5O+N5RRBEc/1 J3YvSvTJofNqFEk8GKFvOjtIFUbCWsAqV1+ab/8D3WPRoItU/f6l4ZNsF/OXEBtNxgj6 Mob3JWi9NY9fFCZpSZwIhEVRFBViyaU54NqZRMj++/xfigP13W1nFHKwuW5aNubuj7/1 Ytah2ogIY7JEHj5zg9kLImdYJCoPStq7OMj/we/id+LoS3/REoxlbGsEV8famC+9fr50 QgLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=KqNnFaBv; 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 k70-20020a633d49000000b00563e87fdac4si298633pga.128.2023.07.25.22.08.56; Tue, 25 Jul 2023 22:09:09 -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=KqNnFaBv; 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 S231967AbjGZE2D (ORCPT + 99 others); Wed, 26 Jul 2023 00:28:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231764AbjGZE1k (ORCPT ); Wed, 26 Jul 2023 00:27:40 -0400 Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77BBB1FF2 for ; Tue, 25 Jul 2023 21:26:26 -0700 (PDT) Received: by mail-il1-x132.google.com with SMTP id e9e14a558f8ab-34617b29276so1468815ab.0 for ; Tue, 25 Jul 2023 21:26:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1690345586; x=1690950386; 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=lavfuE2py63kVqVG37hnlHpSBQOco6qEbPDbyiaGHr8=; b=KqNnFaBvS8w7I7Srdl6Jvzm1b1m8LmOq6bK3MqaoIGO2Jsq06v9TC8TZKZ/LI8J5wR 6G2uTZ5CofCxhiBDp8OUDQd4uGKXq+Ghy2JQLWqdNQaSuf3sx3bg+KWKkXxjuGn1k6Ns UAv/ymipwkhEjgru0+r9KINywii/CVWwNkj99dIaqLBjW8xQ59aBZs53xoxVyyhcAHXG /F435bvD/JsfH7CxoLctneRrgi3Cx0VedSUIQ6syZ8+BbEoPh+mVGrW1ugwLiHPeIb/Q fryDob8lF1DUfKrl6BRvkBu1j9fUe6VHD9dwTt7rDNExgRE09b0GNE59iwA8dgsQAceg 7m0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690345586; x=1690950386; 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=lavfuE2py63kVqVG37hnlHpSBQOco6qEbPDbyiaGHr8=; b=iFdwBfzws/LKig8T3SKakIsG/9V9sQCN4STtiCiRBlzJTHV4rSfA8UKpNO3ftgKYA8 ZPChLvF4KwQcPKS0uvO+SIeIU+ftug1kFDATDqARTf6CTJpqVFHbsZc3PjqT26mksrW4 V3DuqWIfV9XBQNB9fJO2Y2TVXSRn6zc2OaR1fbAG5KndBSguL41ulkyj876fRJXSQnIO wVJs2oJQnoYrEJw8Ko6waO7/d2xPQLXxnhRgota/ZLEaYda13o61O7UMh7j3rKhBvvzY aJizRw6iUSqApv5aKeomV6UHfUO645L15NuHu2kX0ohZXQZ2rzD8rhcF17QwgGj4GPTb H9RQ== X-Gm-Message-State: ABy/qLYy7GAYwYmukcWs2MSR10xfSaZcfQBzI1GpSdf4uAuCp6hknGIp 3S/mXZ5QQn9XFo/1i38dIyduGPAxtvwNCe8egyUVIw== X-Received: by 2002:a05:6e02:1c2a:b0:346:63f1:a96f with SMTP id m10-20020a056e021c2a00b0034663f1a96fmr3000190ilh.2.1690345585840; Tue, 25 Jul 2023 21:26:25 -0700 (PDT) MIME-Version: 1.0 References: <592edb17-7fa4-3b5b-2803-e8c50c322eee@linux.intel.com> In-Reply-To: <592edb17-7fa4-3b5b-2803-e8c50c322eee@linux.intel.com> From: Zong Li Date: Wed, 26 Jul 2023 12:26:14 +0800 Message-ID: Subject: Re: [PATCH 03/11] dt-bindings: Add RISC-V IOMMU bindings To: Baolu Lu Cc: Anup Patel , 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_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Wed, Jul 26, 2023 at 11:21=E2=80=AFAM Baolu Lu wrote: > > On 2023/7/24 21:23, Zong Li wrote: > >>>>> 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 dm= a-coherent) > >>>> 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 Q= COM > >>>> 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 b= y default. > >>>> > >>> 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 IOMM= U > >>> 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 indicate= s > >>> the phandle of devices wishing to set bypass mode, somewhat similar t= o > >>> 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 le= vel, > >> which clearly indicates that defining a RISC-V specific property is no= t 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 > >> > > That is indeed one way to approach it, and we can modify the > > compatible string when we want to change the mode. However, it would > > be preferable to explore a more flexible approach to achieve this > > goal. By doing so, we can avoid hard coding anything in the driver or > > having to rebuild the kernel whenever we want to change the mode for > > certain devices. While I have considered extending a cell in the > > 'iommus' property to indicate a device's desire to set bypass mode, it > > doesn't comply with the iommu documentation and could lead to > > ambiguous definitions. > > Hard coding the matching strings in the iommu driver is definitely not a > preferable way. A feasible solution from current code's point of view is > that platform opt-in the device's special requirements through DT or > ACPI. And in the def_domain_type callback, let the iommu core know that, > hence it can allocate a right type of domain for the device. > > Thoughts? > It would be nice if we can deal with it at this time. As we discussed earlier, we might need to consider how to indicate that, such as putting a property in device side or iommu side, and whether we need to define it in generic dt-binding instead of RISC-V specific dt-binding. > Best regards, > baolu