Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp2973898rdb; Tue, 12 Sep 2023 19:38:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHTyuPCJL8JvFf2cKJR3Te74SQfwRBTSVswCdeuNkJqEhShVYkVu4o39F3VAvtVJrglHoLS X-Received: by 2002:a05:6870:178d:b0:1bf:8c9a:9a2c with SMTP id r13-20020a056870178d00b001bf8c9a9a2cmr1556475oae.15.1694572689429; Tue, 12 Sep 2023 19:38:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694572689; cv=none; d=google.com; s=arc-20160816; b=frnO0LxYM3WhTdRwAXlf6ohUTnoc/taNFKWD8Z0cB5tagYuIS6Dpx6YF09rF2ysHZS PQrzEJdSMk3mTXHp3CLriqZkVU/6QLSYwukyYneSTGet0MrVJtZJoFga6BbdP4Ah7KCp 05JnkMPWqJxmTqkLGCf0/4GP7I3S4B5sDegS9+RFJcZjJlVJPYA+fkBm+OZTlsb3esmx qQ+DAjJqXwZhDJVGRhcEpjAAIXdBJxRAzYMF80nfBKTgGYSwD9HeCQh7eKMgrqkSFhF4 3/e29uu/4j1RvCZXjqjmZ8fbowhRxEQntcMm80z6PwNQhJOCWyJjXTgpMvSQxVOUqcKe 6liw== 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=67MJC2d5J2erEiZgw/Tl5J0vIH9+tJ2KcoKs7uxuLf4=; fh=MIxjoNZhntBUh/WMn1/YcnGp1nS2WjwOPx5iNl9Vki0=; b=jVHGjbzABKFJ3QbLkQyHBiOx/SQ1Vo2reL4oNGvT5VLIAarMK9zqj3JZmglUybQ/1M G2J3+/ZCGpRbzgBQfrkden773ebJ/yXR6Edi3e8f+yVsMP8nyT01FNxUTCBRM2Bz2Xei gv5jre994ip3ZkkazBwkpxlbNIFe04W5/KoWsQWsfU+CUqVuAWpgk9JrNCA78TPQyDqj ZvDUd86Ep5VX+VTzXr/Uz8N0A4R8YgmNrOCLAfZ2DYBdPSIHU8yRP1Laz0Uy/Ic/ODcZ Cc6IIrgIWJczUglia/Psg+o1V717G6dAEoWHxPWTt/IeMIGQ9ntih1MLxphbBBfHRJF4 WSWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=EpiYcrhg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id m1-20020a656a01000000b00564bfbb19easi9639059pgu.472.2023.09.12.19.38.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 19:38:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=EpiYcrhg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 82BEC81FAD9A; Tue, 12 Sep 2023 15:13:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234427AbjILWNl (ORCPT + 99 others); Tue, 12 Sep 2023 18:13:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231844AbjILWNk (ORCPT ); Tue, 12 Sep 2023 18:13:40 -0400 Received: from mail-qv1-xf32.google.com (mail-qv1-xf32.google.com [IPv6:2607:f8b0:4864:20::f32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C13C110D9 for ; Tue, 12 Sep 2023 15:13:36 -0700 (PDT) Received: by mail-qv1-xf32.google.com with SMTP id 6a1803df08f44-64b3ae681d1so33516696d6.0 for ; Tue, 12 Sep 2023 15:13:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694556816; x=1695161616; darn=vger.kernel.org; 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=67MJC2d5J2erEiZgw/Tl5J0vIH9+tJ2KcoKs7uxuLf4=; b=EpiYcrhg/PH37kXIdurkb0lPgiswsvyOR8lYCltxswcP7hT8SmNHGOWfr9Kwt7/0K2 j+yzdyfjHMfFQ5U0KROclEp4U4+1Mo30n7pGlFn4RNGvTdVN9jPTAZIL7IKCex7/f4qp 43PHJlkLW7vM2lvmMMpxvfmGXNpOlYgd/BRfuKj1o/dIn3jO5OnS+wr6Gkf6mt1jXGkx S/WxhVKS0a8vmtP4M/7k3Njne69Px4JHLVYdMGtvVa4KeB1+I8jiiP7a/jTyL0GQmOne xyAfVL7TAFRCyJByEAF0yaGRgK1gXfxe7eyndE/IExAQ1aKB72+GX48ul2EMD3gN9ewE MG1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694556816; x=1695161616; 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=67MJC2d5J2erEiZgw/Tl5J0vIH9+tJ2KcoKs7uxuLf4=; b=f7o/7CMH5x4m3gYScnltozS0TAI8jAn0TUZYmbrAiN7Fryadr2A8i/ZilAkkmQ1fq/ SJgYsFMkC3w4l45CQujatOfqDtOCcebYY5k7sCBslvalWGzPWGFytuekNtt2cKpbjrrB voB3WRhd13MA+6yKZJr5/u+YMIw+zAgP+dPyD2078lx1idkxOGtJ2VDLQxCM0h2IHT9L lyryESKU/6M6U1kaYNZF6bAOoBH0LOSW3r1u/SGjGpNNG9p7yHRvfd3xrgyl3cKTz/IE /GHv3/MYWByZAq3dmRDoClUUgqz9c5eIxZ72SXrHo5mectplnYGuAMVNyVdYBU8gsw+l kDYw== X-Gm-Message-State: AOJu0Ywz0ajeldzEnNmI1+zPpUbs+H9CXfVs0yyKhKRQ3WrFYLJlWnMd Ae2gTgmE+875nhceZNoIm2KvM6Lt0nqpBj19DGOwlQ== X-Received: by 2002:a05:6214:29ee:b0:64f:8213:197d with SMTP id jv14-20020a05621429ee00b0064f8213197dmr983778qvb.33.1694556815805; Tue, 12 Sep 2023 15:13:35 -0700 (PDT) MIME-Version: 1.0 References: <20230627033326.5236-1-nicolinc@nvidia.com> In-Reply-To: <20230627033326.5236-1-nicolinc@nvidia.com> From: Aahil Awatramani Date: Tue, 12 Sep 2023 15:13:25 -0700 Message-ID: Subject: Re: [PATCH v1] iommu/arm-smmu-v3: Allow default substream bypass with a pasid support To: Nicolin Chen Cc: robin.murphy@arm.com, will@kernel.org, jgg@nvidia.com, joro@8bytes.org, shameerali.kolothum.thodi@huawei.com, yangyicong@hisilicon.com, jean-philippe@linaro.org, linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Tue, 12 Sep 2023 15:13:42 -0700 (PDT) X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email We have a use-case for this patch to help in avoiding the map/unmap overhead in some cases but still maintaining support for PASIDs. Thanks. On Tue, Sep 12, 2023 at 1:30=E2=80=AFPM Nicolin Chen = wrote: > > When an iommu_domain is set to IOMMU_DOMAIN_IDENTITY, the driver would > skip the allocation of a CD table and set the CONFIG field of the STE > to STRTAB_STE_0_CFG_BYPASS. This works well for devices that only have > one substream, i.e. PASID disabled. > > However, there could be a use case, for a pasid capable device, that > allows bypassing the translation at the default substream while still > enabling the pasid feature, which means the driver should not skip the > allocation of a CD table nor simply bypass the CONFIG field. Instead, > the S1DSS field should be set to STRTAB_STE_1_S1DSS_BYPASS and the > SHCFG field should be set to STRTAB_STE_1_SHCFG_INCOMING. > > Add s1dss and shcfg in struct arm_smmu_s1_cfg, to allow configurations > in the finalise() to support that use case. Then, set them accordingly > depending on the iommu_domain->type and the master->ssid_bits. > > Also, add STRTAB_STE_1_SHCFG_NONSHAREABLE of the default configuration > to distinguish from STRTAB_STE_1_SHCFG_INCOMING of the bypass one. > > Signed-off-by: Nicolin Chen > --- > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 18 +++++++++++++++--- > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 3 +++ > 2 files changed, 18 insertions(+), 3 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 9b0dc3505601..8dc7934a0175 100644 > --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > @@ -1350,11 +1350,12 @@ static void arm_smmu_write_strtab_ent(struct arm_= smmu_master *master, u32 sid, > > BUG_ON(ste_live); > dst[1] =3D cpu_to_le64( > - FIELD_PREP(STRTAB_STE_1_S1DSS, STRTAB_STE_1_S1DS= S_SSID0) | > + FIELD_PREP(STRTAB_STE_1_S1DSS, s1_cfg->s1dss) | > FIELD_PREP(STRTAB_STE_1_S1CIR, STRTAB_STE_1_S1C_= CACHE_WBRA) | > FIELD_PREP(STRTAB_STE_1_S1COR, STRTAB_STE_1_S1C_= CACHE_WBRA) | > FIELD_PREP(STRTAB_STE_1_S1CSH, ARM_SMMU_SH_ISH) = | > - FIELD_PREP(STRTAB_STE_1_STRW, strw)); > + FIELD_PREP(STRTAB_STE_1_STRW, strw) | > + FIELD_PREP(STRTAB_STE_1_SHCFG, s1_cfg->shcfg)); > > if (smmu->features & ARM_SMMU_FEAT_STALLS && > !master->stall_enabled) > @@ -2119,6 +2120,13 @@ static int arm_smmu_domain_finalise_s1(struct arm_= smmu_domain *smmu_domain, > goto out_unlock; > > cfg->s1cdmax =3D master->ssid_bits; > + if (smmu_domain->domain.type =3D=3D IOMMU_DOMAIN_IDENTITY) { > + cfg->s1dss =3D STRTAB_STE_1_S1DSS_BYPASS; > + cfg->shcfg =3D STRTAB_STE_1_SHCFG_INCOMING; > + } else { > + cfg->s1dss =3D STRTAB_STE_1_S1DSS_SSID0; > + cfg->shcfg =3D STRTAB_STE_1_SHCFG_NONSHAREABLE; > + } > > smmu_domain->stall_enabled =3D master->stall_enabled; > > @@ -2198,7 +2206,11 @@ static int arm_smmu_domain_finalise(struct iommu_d= omain *domain, > struct arm_smmu_domain *smmu_domain =3D to_smmu_domain(domain); > struct arm_smmu_device *smmu =3D smmu_domain->smmu; > > - if (domain->type =3D=3D IOMMU_DOMAIN_IDENTITY) { > + /* > + * A master with a pasid capability might need a CD table, so onl= y set > + * ARM_SMMU_DOMAIN_BYPASS if IOMMU_DOMAIN_IDENTITY and non-pasid = master > + */ > + if (domain->type =3D=3D IOMMU_DOMAIN_IDENTITY && !master->ssid_bi= ts) { > smmu_domain->stage =3D ARM_SMMU_DOMAIN_BYPASS; > return 0; > } > diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h b/drivers/iommu/= arm/arm-smmu-v3/arm-smmu-v3.h > index dcab85698a4e..8052d02770d0 100644 > --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h > @@ -244,6 +244,7 @@ > #define STRTAB_STE_1_STRW_EL2 2UL > > #define STRTAB_STE_1_SHCFG GENMASK_ULL(45, 44) > +#define STRTAB_STE_1_SHCFG_NONSHAREABLE 0UL > #define STRTAB_STE_1_SHCFG_INCOMING 1UL > > #define STRTAB_STE_2_S2VMID GENMASK_ULL(15, 0) > @@ -601,6 +602,8 @@ struct arm_smmu_s1_cfg { > struct arm_smmu_ctx_desc_cfg cdcfg; > struct arm_smmu_ctx_desc cd; > u8 s1fmt; > + u8 s1dss; > + u8 shcfg; > u8 s1cdmax; > }; > > -- > 2.41.0 >