[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <fd1b869f32664210ac29e3d0ca916f1a535233b3.1723061378.git.nicolinc@nvidia.com>
Date: Wed, 7 Aug 2024 13:10:55 -0700
From: Nicolin Chen <nicolinc@...dia.com>
To: <jgg@...dia.com>, <kevin.tian@...el.com>, <will@...nel.org>
CC: <joro@...tes.org>, <suravee.suthikulpanit@....com>,
<robin.murphy@....com>, <dwmw2@...radead.org>, <baolu.lu@...ux.intel.com>,
<shuah@...nel.org>, <linux-kernel@...r.kernel.org>, <iommu@...ts.linux.dev>,
<linux-arm-kernel@...ts.infradead.org>, <linux-kselftest@...r.kernel.org>
Subject: [PATCH v1 14/16] iommu/arm-smmu-v3: Extract an __arm_smmu_cache_invalidate_user helper
Extract a helper accepting an s2_parent input directly so the following
patch can take advantage of it for viommu's cache invalidate callback,
which doesn't have a nested domain but a viommu object linked to an S2
parent domain.
Signed-off-by: Nicolin Chen <nicolinc@...dia.com>
---
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 24 ++++++++++++++-------
1 file changed, 16 insertions(+), 8 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 558cf3bb24e0..ec76377d505c 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
@@ -3227,10 +3227,10 @@ static void arm_smmu_domain_nested_free(struct iommu_domain *domain)
* Enforce the VMID on the command.
*/
static int
-arm_smmu_convert_user_cmd(struct arm_smmu_nested_domain *nested_domain,
+arm_smmu_convert_user_cmd(struct arm_smmu_domain *s2_parent,
struct iommu_hwpt_arm_smmuv3_invalidate *cmd)
{
- u16 vmid = nested_domain->s2_parent->s2_cfg.vmid;
+ u16 vmid = s2_parent->s2_cfg.vmid;
cmd->cmd[0] = le64_to_cpu(cmd->cmd[0]);
cmd->cmd[1] = le64_to_cpu(cmd->cmd[1]);
@@ -3255,12 +3255,10 @@ arm_smmu_convert_user_cmd(struct arm_smmu_nested_domain *nested_domain,
return 0;
}
-static int arm_smmu_cache_invalidate_user(struct iommu_domain *domain,
- struct iommu_user_data_array *array)
+static int __arm_smmu_cache_invalidate_user(struct arm_smmu_domain *s2_parent,
+ struct iommu_user_data_array *array)
{
- struct arm_smmu_nested_domain *nested_domain =
- container_of(domain, struct arm_smmu_nested_domain, domain);
- struct arm_smmu_device *smmu = nested_domain->s2_parent->smmu;
+ struct arm_smmu_device *smmu = s2_parent->smmu;
struct iommu_hwpt_arm_smmuv3_invalidate *last_batch;
struct iommu_hwpt_arm_smmuv3_invalidate *cmds;
struct iommu_hwpt_arm_smmuv3_invalidate *cur;
@@ -3282,7 +3280,7 @@ static int arm_smmu_cache_invalidate_user(struct iommu_domain *domain,
last_batch = cmds;
while (cur != end) {
- ret = arm_smmu_convert_user_cmd(nested_domain, cur);
+ ret = arm_smmu_convert_user_cmd(s2_parent, cur);
if (ret)
goto out;
@@ -3305,6 +3303,16 @@ static int arm_smmu_cache_invalidate_user(struct iommu_domain *domain,
return ret;
}
+static int arm_smmu_cache_invalidate_user(struct iommu_domain *domain,
+ struct iommu_user_data_array *array)
+{
+ struct arm_smmu_nested_domain *nested_domain =
+ container_of(domain, struct arm_smmu_nested_domain, domain);
+
+ return __arm_smmu_cache_invalidate_user(
+ nested_domain->s2_parent, array);
+}
+
static struct iommu_domain *
arm_smmu_get_msi_mapping_domain(struct iommu_domain *domain)
{
--
2.43.0
Powered by blists - more mailing lists