From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 28450C369DC for ; Tue, 29 Apr 2025 21:47:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=EjhyY3r971ECUhfqqbl7u+2Mh/jYqDkZEBXpIERaB8I=; b=JfXD+pUuFPxrqK8Zk8ObIW4CCe LANpqFU7faomgoghZXuA2Ziyjm0LJ8260ldUIPqtrpqQp0s8KBvb18Ic9r2lEw403Favefl3yYhfL X48s4RrXxiE26LapLszk0Y6CJr5ekvK3JS8tJfFFvhBVw/0F2hNwcku2bdNsIzP1Q1seeZ8IIUji8 TeEvDD4SHpEFM8GB7vGFmrtPYMf0dQxwxehuIoJZPmD7F7cx4fQiVZKnnT3cpm1Zs4aBy1vxor952 UR/UlyT7z6clvcWeMW2d1pcuXgZEcdRrZyKKgctqeDpZEdDvEJoaOVTO4CIofX0xqGjqyTjhjtY83 di+ReV2Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1u9sn4-0000000Atfm-41bx; Tue, 29 Apr 2025 21:46:58 +0000 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1u9skO-0000000AtJC-2n7Q for linux-arm-kernel@lists.infradead.org; Tue, 29 Apr 2025 21:44:13 +0000 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-2240aad70f2so241885ad.0 for ; Tue, 29 Apr 2025 14:44:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1745963052; x=1746567852; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=EjhyY3r971ECUhfqqbl7u+2Mh/jYqDkZEBXpIERaB8I=; b=lbcNd4USNheHm6D9fJX2uFf/Edcpu2FhvPIus1IX8bO84k/2DU4DjT5J6UjBo8A3Ng Qwr9umrgL61zdaVxvv4LiFBIbIS2KNp2HIhYZzHMRnj7y3xtsIO6sUY9mAdtkLO23q/J X57zKxb6E4gumxv2j2ZRDb2jQPI7/aYpYML+wKxxpQWZc4jmAwRuZEKrmQXas/dp3Qmh ii3bmZZbQZpstre8y1zXlWmEfdMPSl5XXQmfqoWdY+LnSUXz96CX6a/a2YP3rtIltG2M QtKF9QZXt/fjUso2Y8tdYTP6MnRv2NSNzQy0ijWXrfMTyUk06ED9tvqd7AXCuJTypSJS rJJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745963052; x=1746567852; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=EjhyY3r971ECUhfqqbl7u+2Mh/jYqDkZEBXpIERaB8I=; b=DKt27BvNlJmXapU8H6n/HCJvucReFhJbJIH71hfZHJbpLpUWSCfP79A15w0+fH2+pU nuBZcha9K8+JIuUObrfCBR99ZR2wOidMGh9NZHTa+5HH/MQoyLhHj/is9luvJ4oG+J8v wEe51NDuwLi8QrvF40AbYBE9wrKankT3ibiNyfyPLBdkdy1/ZDSwN8Du3woB8RsnnT9C 06hIJdti3KG2Nn21RXX9fi5GguDP7F/ymurSh4dG20Zu24EI9GRNhAyCRdVbjDgctn0W lRxOg1t9SizDNrtOB/gDsjdnYjs+PdyT7Af/a/hyNiZBsvLWBTM/7M30errbwhF6wMTT zkFg== X-Forwarded-Encrypted: i=1; AJvYcCUtDQCoNwcvAHysFMM2WQ9ifpFBHS0rhzVOU+dVlIsF9CHQcV4i5I2EgDKJlAmLmYs5tQBvjO6zM5zoXumLLlsZ@lists.infradead.org X-Gm-Message-State: AOJu0YyzULut6GNmLP00Qc0pPbmR/PdX+Y9ttL0LrLom+4nshzVjgbAA XVFSKWSfC0wxfNLcvhMREW1NAjZPSb2HfD1yDo32vTtfaFr1PnM68TvQ5kE/FQ== X-Gm-Gg: ASbGncuF6TtafOs8rf2zem61tmHXvVuHldm2ZBwP/P/s2fzfv/uBS7BGdeNndMY2UsQ MctQXIe9tojlRcaFaUbRNJxYTtVJqOyLhUOff/63aA8ysOsH7TyCOj9BFehXLzd7FhdhdSaH1ji 7fCAHXuytVsAg0kpH1FRJcd1q+Lng6sbapi4DcIy0bVmH2qjc2efj0AHh+ZeUPakuBji6HoMaCc EahdGU1+oF/0mK9aAJlt5PWf62TDKHndTdazQEi+rZCKDo8hTPgkZghZYrKh/66FDS8oaho5mgr RLtp2jsEG33gNwZgoLLBgnKxSDaAlAbvx5XsKVplPUCJ5BsH+Wx/WV2wjZeXx/Mn+8hnTPdw X-Google-Smtp-Source: AGHT+IGRVChNm/D/6XmLJRuqupUIJJIIhE6A6CeVKWfGeNxHpzqOmQegP9ON+cIaJRAsz/EcrzoqDw== X-Received: by 2002:a17:902:db12:b0:224:6c8:8d84 with SMTP id d9443c01a7336-22df3f77cffmr1031875ad.4.1745963051511; Tue, 29 Apr 2025 14:44:11 -0700 (PDT) Received: from google.com (2.210.143.34.bc.googleusercontent.com. [34.143.210.2]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-30a34a5f86esm25958a91.44.2025.04.29.14.44.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Apr 2025 14:44:11 -0700 (PDT) Date: Tue, 29 Apr 2025 21:44:00 +0000 From: Pranjal Shrivastava To: Nicolin Chen Cc: jgg@nvidia.com, kevin.tian@intel.com, corbet@lwn.net, will@kernel.org, bagasdotme@gmail.com, robin.murphy@arm.com, joro@8bytes.org, thierry.reding@gmail.com, vdumpa@nvidia.com, jonathanh@nvidia.com, shuah@kernel.org, jsnitsel@redhat.com, nathan@kernel.org, peterz@infradead.org, yi.l.liu@intel.com, mshavit@google.com, zhangzekun11@huawei.com, iommu@lists.linux.dev, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-tegra@vger.kernel.org, linux-kselftest@vger.kernel.org, patches@lists.linux.dev, mochs@nvidia.com, alok.a.tiwari@oracle.com, vasant.hegde@amd.com Subject: Re: [PATCH v2 17/22] iommu/arm-smmu-v3-iommufd: Support implementation-defined hw_info Message-ID: References: <56f048cdc9cd8bf1569434633d709d07a78e9430.1745646960.git.nicolinc@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <56f048cdc9cd8bf1569434633d709d07a78e9430.1745646960.git.nicolinc@nvidia.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250429_144412_713521_BE3F280F X-CRM114-Status: GOOD ( 26.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Apr 25, 2025 at 10:58:12PM -0700, Nicolin Chen wrote: > Repurpose the @__reserved field in the struct iommu_hw_info_arm_smmuv3, > to an HW implementation-defined field @impl. > > This will be used by Tegra241 CMDQV implementation on top of a standard > ARM SMMUv3 IOMMU. The @impl will be only valid if @flags is set with an > implementation-defined flag. > > Thus in the driver-level, add an hw_info impl op that will return such > a flag to use the impl field. > > Signed-off-by: Nicolin Chen Reviewed-by: Pranjal Shrivastava > --- > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 1 + > include/uapi/linux/iommufd.h | 4 ++-- > .../iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c | 16 +++++++++++++--- > 3 files changed, 16 insertions(+), 5 deletions(-) > > 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 a5835af72417..bab7a9ce1283 100644 > --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h > @@ -726,6 +726,7 @@ struct arm_smmu_impl_ops { > struct arm_smmu_domain *smmu_domain, struct iommufd_ctx *ictx, > unsigned int viommu_type, > const struct iommu_user_data *user_data); > + u32 (*hw_info)(struct arm_smmu_device *smmu, u32 *impl); > }; > > /* An SMMUv3 instance */ > diff --git a/include/uapi/linux/iommufd.h b/include/uapi/linux/iommufd.h > index 06a763fda47f..b2614f0f1547 100644 > --- a/include/uapi/linux/iommufd.h > +++ b/include/uapi/linux/iommufd.h > @@ -554,7 +554,7 @@ struct iommu_hw_info_vtd { > * (IOMMU_HW_INFO_TYPE_ARM_SMMUV3) > * > * @flags: Must be set to 0 > - * @__reserved: Must be 0 > + * @impl: Must be 0 > * @idr: Implemented features for ARM SMMU Non-secure programming interface > * @iidr: Information about the implementation and implementer of ARM SMMU, > * and architecture version supported > @@ -585,7 +585,7 @@ struct iommu_hw_info_vtd { > */ > struct iommu_hw_info_arm_smmuv3 { > __u32 flags; > - __u32 __reserved; > + __u32 impl; > __u32 idr[6]; > __u32 iidr; > __u32 aidr; > diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c > index a8a78131702d..63861c60b615 100644 > --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c > @@ -10,7 +10,9 @@ > void *arm_smmu_hw_info(struct device *dev, u32 *length, u32 *type) > { > struct arm_smmu_master *master = dev_iommu_priv_get(dev); > + struct arm_smmu_device *smmu = master->smmu; > struct iommu_hw_info_arm_smmuv3 *info; > + u32 flags = 0, impl = 0; > u32 __iomem *base_idr; > unsigned int i; > > @@ -18,15 +20,23 @@ void *arm_smmu_hw_info(struct device *dev, u32 *length, u32 *type) > if (!info) > return ERR_PTR(-ENOMEM); > > - base_idr = master->smmu->base + ARM_SMMU_IDR0; > + base_idr = smmu->base + ARM_SMMU_IDR0; > for (i = 0; i <= 5; i++) > info->idr[i] = readl_relaxed(base_idr + i); > - info->iidr = readl_relaxed(master->smmu->base + ARM_SMMU_IIDR); > - info->aidr = readl_relaxed(master->smmu->base + ARM_SMMU_AIDR); > + info->iidr = readl_relaxed(smmu->base + ARM_SMMU_IIDR); > + info->aidr = readl_relaxed(smmu->base + ARM_SMMU_AIDR); > > *length = sizeof(*info); > *type = IOMMU_HW_INFO_TYPE_ARM_SMMUV3; > > + if (smmu->impl_ops && smmu->impl_ops->hw_info) { > + flags = smmu->impl_ops->hw_info(smmu, &impl); > + if (flags) { > + info->impl = impl; > + info->flags |= flags; > + } > + } > + > return info; > } > > -- > 2.43.0 >