Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp12564rwn; Wed, 7 Sep 2022 11:39:09 -0700 (PDT) X-Google-Smtp-Source: AA6agR4eGSQrxGW1qdzi2kkjINrCFRoZW/gDfFr3Z9NoIXUPbRYxkU5kAEHEr5XP+2ahL2sykLBj X-Received: by 2002:a17:906:9746:b0:74f:945a:5d41 with SMTP id o6-20020a170906974600b0074f945a5d41mr3272183ejy.63.1662575948822; Wed, 07 Sep 2022 11:39:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662575948; cv=none; d=google.com; s=arc-20160816; b=JThpgOkPBYyYz0cbyggyNxY09p+t3Gk9ULx7mp0Jbq8RS3C5lgGFmzaPSPeGQpwn3t VwJfhrvnjRa5taw1/ddwhizxottQnukL0dnBUz8ubOXnTy1Ixuptcjl58dO7kZAMVAro 0Pzw809OPvnrgrRjQyUxOxyGvMqeibddaqu0/GaWdQ+vGs0NEO0eyzVMAeE4q1T/9dbX Md/Z+3/zGx+e0gq+yvItZOk4MLZn/Qfi44Gk3oQwLNPpOCp3Uo2Bs2LzXmWt3Eg4l4zJ Kf/4qOMGGd+ykoJGiMbShtU3o2FqNbMSFwvAp7k1Y1XRVJw433Sf+6O8xqqPWefM92tY H40Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=t1RT2GVL7So8FRxhttvNmfTvwaG7wye3XjohR9wIDto=; b=IwwNGVmfluaLaqxpfIkhBmEiOeHdFkO/7mgNii+QLKxYzqt39QOOBCMg7940Bx7Ryf oGDtPGEKsInfaz9r8HFZV0Cl52TqHKM4LOGbfISaexpmP6zdF9Go4EZY+uGvQSMkxVT0 Jo+zIfchSZ/VwPad/gpKS8t/T98L55+oKRTamf7DzWOBeIWmIYJkEoXjja792Wq04u/o d0+ea6MXCOhHwK1U7tp/7cVu4/b//Fp40OoK+1fU4D9LPVxSO2ukFyaIf2g6TD5DPj8L Qjfx7ljLYIhZlCwxLwOvwKe5m98BNPbS+apLvWUIm4RHqHZMkYDXF8tQ13k385L7gHI2 saLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=d+pqtCM7; 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=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w3-20020a056402268300b004488842d88esi13962942edd.13.2022.09.07.11.38.44; Wed, 07 Sep 2022 11:39:08 -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=@google.com header.s=20210112 header.b=d+pqtCM7; 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=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229566AbiIGSZd (ORCPT + 99 others); Wed, 7 Sep 2022 14:25:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229630AbiIGSZ3 (ORCPT ); Wed, 7 Sep 2022 14:25:29 -0400 Received: from mail-yb1-xb2e.google.com (mail-yb1-xb2e.google.com [IPv6:2607:f8b0:4864:20::b2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9556DB2CCE for ; Wed, 7 Sep 2022 11:25:27 -0700 (PDT) Received: by mail-yb1-xb2e.google.com with SMTP id a67so11144988ybb.3 for ; Wed, 07 Sep 2022 11:25:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=t1RT2GVL7So8FRxhttvNmfTvwaG7wye3XjohR9wIDto=; b=d+pqtCM7emIqHqqcL0FHUBGevoq1D8aCT3LyylUG8lQcnvelI9T0US5vu7KwGPVIz5 mzmXu8yMHa9xjZQzxqTF0/OFT6/PbcNpNEbMVWHQnSUEWUa9uberuGAQO/UfPpx5mNoE 8IDPGgqmMCtXrV1CSCjdVYO83arausSfcFTWgtHvxSZSQ7yJF0wgjKzWER5gVVJH6zl1 v9bx+QXgNeTUfPfAxLV0r78mUzP8aWPtsX7iEPZCtL7BOr3YEcBUoMhKNX/kqUr7B+XQ BOZgcuBdvMpanoRIG32KLgFjh9qtARUy+mu3yK6NIznET5lMXvuweEY0jSuS6p13b8bp gk5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=t1RT2GVL7So8FRxhttvNmfTvwaG7wye3XjohR9wIDto=; b=cwTtvcpd0/Qr36oHbyQWQDA/iR0j62ppnq9W/Jbywzc8FiBH88rgl8qn5XhtD28opD NfS7AOUaZReb0xuv9ZptF6zk8Duu4xqt3t7AlM65544pzhNsgxNewTWRlj4KDuISeWlH WRIptJVH7YBGfpuejWnLob8fJvsRceKpzD6sRt1GVKV+jQIKxgGUpvRYwHnfvfPmz9L3 jjPvdA/c/Fb2s+Z9ar4sCDsSjmJv1n2YHPTQ3WuPKI/Zl91X2Z6TzlTN/n/Xl79dkPTf NQGiL0T/ZKoWy9QRNx+4wHYDOeawAkD6qLfalQvmN5zWZgl6vj0myMaaXfeiFxyaT6ti NnmQ== X-Gm-Message-State: ACgBeo0ZTW0DvjaAjXoI2y4wpsQ1pRQnYPzfKdlGoLgORhoHWkkpDi9f 4abWB87085Lf3KcWB8SoFnYlDVACkAs5LXN5VlvKRg== X-Received: by 2002:a25:3cc4:0:b0:696:5790:438d with SMTP id j187-20020a253cc4000000b006965790438dmr3664251yba.563.1662575126653; Wed, 07 Sep 2022 11:25:26 -0700 (PDT) MIME-Version: 1.0 References: <20220803122655.100254-1-nipun.gupta@amd.com> <20220906134801.4079497-1-nipun.gupta@amd.com> <20220906134801.4079497-4-nipun.gupta@amd.com> In-Reply-To: From: Saravana Kannan Date: Wed, 7 Sep 2022 11:24:50 -0700 Message-ID: Subject: Re: [RFC PATCH v3 3/7] iommu/arm-smmu-v3: support ops registration for CDX bus To: Robin Murphy Cc: "Gupta, Nipun" , "robh+dt@kernel.org" , "krzysztof.kozlowski+dt@linaro.org" , "gregkh@linuxfoundation.org" , "rafael@kernel.org" , "eric.auger@redhat.com" , "alex.williamson@redhat.com" , "cohuck@redhat.com" , "Gupta, Puneet (DCG-ENG)" , "song.bao.hua@hisilicon.com" , "mchehab+huawei@kernel.org" , "maz@kernel.org" , "f.fainelli@gmail.com" , "jeffrey.l.hugo@gmail.com" , "Michael.Srba@seznam.cz" , "mani@kernel.org" , "yishaih@nvidia.com" , "jgg@ziepe.ca" , "jgg@nvidia.com" , "will@kernel.org" , "joro@8bytes.org" , "masahiroy@kernel.org" , "ndesaulniers@google.com" , "linux-arm-kernel@lists.infradead.org" , "linux-kbuild@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "devicetree@vger.kernel.org" , "kvm@vger.kernel.org" , "okaya@kernel.org" , "Anand, Harpreet" , "Agarwal, Nikhil" , "Simek, Michal" , "Radovanovic, Aleksandar" , "git (AMD-Xilinx)" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable 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, Sep 7, 2022 at 1:27 AM Robin Murphy wrote: > > On 2022-09-07 04:17, Gupta, Nipun wrote: > > [AMD Official Use Only - General] > > > > > > > >> -----Original Message----- > >> From: Saravana Kannan > >> Sent: Wednesday, September 7, 2022 5:41 AM > >> To: Gupta, Nipun > >> Cc: robh+dt@kernel.org; krzysztof.kozlowski+dt@linaro.org; > >> gregkh@linuxfoundation.org; rafael@kernel.org; eric.auger@redhat.com; > >> alex.williamson@redhat.com; cohuck@redhat.com; Gupta, Puneet (DCG-ENG) > >> ; song.bao.hua@hisilicon.com; > >> mchehab+huawei@kernel.org; maz@kernel.org; f.fainelli@gmail.com; > >> jeffrey.l.hugo@gmail.com; Michael.Srba@seznam.cz; mani@kernel.org; > >> yishaih@nvidia.com; jgg@ziepe.ca; jgg@nvidia.com; robin.murphy@arm.com; > >> will@kernel.org; joro@8bytes.org; masahiroy@kernel.org; > >> ndesaulniers@google.com; linux-arm-kernel@lists.infradead.org; linux- > >> kbuild@vger.kernel.org; linux-kernel@vger.kernel.org; > >> devicetree@vger.kernel.org; kvm@vger.kernel.org; okaya@kernel.org; Anand, > >> Harpreet ; Agarwal, Nikhil > >> ; Simek, Michal ; > >> Radovanovic, Aleksandar ; git (AMD-Xilinx) > >> > >> Subject: Re: [RFC PATCH v3 3/7] iommu/arm-smmu-v3: support ops registration > >> for CDX bus > >> > >> [CAUTION: External Email] > >> > >> On Tue, Sep 6, 2022 at 6:48 AM Nipun Gupta wrote: > >>> > >>> With new CDX bus supported for AMD FPGA devices on ARM > >>> platform, the bus requires registration for the SMMU v3 > >>> driver. > >>> > >>> Signed-off-by: Nipun Gupta > >>> --- > >>> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 16 ++++++++++++++-- > >>> 1 file changed, 14 insertions(+), 2 deletions(-) > >>> > >>> diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > >> b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > >>> index d32b02336411..8ec9f2baf12d 100644 > >>> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > >>> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > >>> @@ -29,6 +29,7 @@ > >>> #include > >>> > >>> #include > >>> +#include > >>> > >>> #include "arm-smmu-v3.h" > >>> #include "../../iommu-sva-lib.h" > >>> @@ -3690,16 +3691,27 @@ static int arm_smmu_set_bus_ops(struct > >> iommu_ops *ops) > >>> if (err) > >>> goto err_reset_pci_ops; > >>> } > >>> +#endif > >>> +#ifdef CONFIG_CDX_BUS > >>> + if (cdx_bus_type.iommu_ops != ops) { > >>> + err = bus_set_iommu(&cdx_bus_type, ops); > >>> + if (err) > >>> + goto err_reset_amba_ops; > >>> + } > >> > >> I'm not an expert on IOMMUs, so apologies if the question is stupid. > >> > >> Why does the CDX bus need special treatment here (like PCI) when there > >> are so many other busses (eg: I2C, SPI, etc) that don't need any > >> changes here? > > > > AFAIU, the devices on I2C/SPI does not use SMMU. Apart from PCI/AMBA, > > FSL-MC is another similar bus (on SMMUv2) which uses SMMU ops. > > > > The devices here are behind SMMU. Robin can kindly correct or add > > more here from SMMU perspective. > > Indeed, there is no need to describe and handle how DMA may or may not > be translated for I2C/SPI/USB/etc. because they are not DMA-capable > buses (in those cases the relevant bus *controller* often does DMA, but > it does that for itself as the platform/PCI/etc. device it is). Ok this is what I was guessing was the reason, but didn't want to make that assumption. So if there are other cases like AMBA, FSL-MC where the devices can do direct DMA, why do those buses not need a #ifdef section in this function like CDX? Or put another way, why does CDX need special treatment? > Note that I have a series pending[1] that will make this patch a whole > lot simpler. Thanks for the pointer. I'll make some comments in that series about bus notifiers. -Saravana > > Thanks, > Robin. > > [1] > https://lore.kernel.org/linux-iommu/cover.1660572783.git.robin.murphy@arm.com/T/#t > > > > > Thanks, > > Nipun > > > >> > >> -Saravana > >> > >>> #endif > >>> if (platform_bus_type.iommu_ops != ops) { > >>> err = bus_set_iommu(&platform_bus_type, ops); > >>> if (err) > >>> - goto err_reset_amba_ops; > >>> + goto err_reset_cdx_ops; > >>> } > >>> > >>> return 0; > >>> > >>> -err_reset_amba_ops: > >>> +err_reset_cdx_ops: > >>> +#ifdef CONFIG_CDX_BUS > >>> + bus_set_iommu(&cdx_bus_type, NULL); > >>> +#endif > >>> +err_reset_amba_ops: __maybe_unused; > >>> #ifdef CONFIG_ARM_AMBA > >>> bus_set_iommu(&amba_bustype, NULL); > >>> #endif > >>> -- > >>> 2.25.1 > >>>