[PATCH v4 08/13] iommu/arm-smmu-v3: Add helper for atc invalidation

From: Michael Shavit
Date: Wed Jun 21 2023 - 02:45:46 EST


This will be used to invalidate ATC entries made on an SSID for a master
when detaching a domain with pasid.

Signed-off-by: Michael Shavit <mshavit@xxxxxxxxxx>
---
v1->v2: Make use of arm_smmu_atc_inv_cmd_set_ssid
---
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

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 65e2dfd28b7d8..0a5e875abda86 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
@@ -1784,13 +1784,15 @@ arm_smmu_atc_inv_to_cmd(unsigned long iova, size_t size,
cmd->atc.size = log2_span;
}

-static int arm_smmu_atc_inv_master(struct arm_smmu_master *master)
+static int arm_smmu_atc_inv_master_ssid(struct arm_smmu_master *master,
+ int ssid)
{
int i;
struct arm_smmu_cmdq_ent cmd;
struct arm_smmu_cmdq_batch cmds;

arm_smmu_atc_inv_to_cmd(0, 0, &cmd);
+ arm_smmu_atc_inv_cmd_set_ssid(ssid, &cmd);
cmds.num = 0;
for (i = 0; i < master->num_streams; i++) {
cmd.atc.sid = master->streams[i].id;
@@ -1800,6 +1802,11 @@ static int arm_smmu_atc_inv_master(struct arm_smmu_master *master)
return arm_smmu_cmdq_batch_submit(master->smmu, &cmds);
}

+static int arm_smmu_atc_inv_master(struct arm_smmu_master *master)
+{
+ return arm_smmu_atc_inv_master_ssid(master, 0);
+}
+
/*
* If ssid is non-zero, issue atc invalidations with the given ssid instead of
* the one the domain is attached to. This is used by SVA since it's pasid
--
2.41.0.162.gfafddb0af9-goog