[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230822185632.RFC.v2.1.Ib87a2696f25414e0fc39cc22dc74e31a4415c2a1@changeid>
Date: Tue, 22 Aug 2023 18:56:57 +0800
From: Michael Shavit <mshavit@...gle.com>
To: iommu@...ts.linux.dev, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org
Cc: nicolinc@...dia.com, tina.zhang@...el.com,
jean-philippe@...aro.org, will@...nel.org, robin.murphy@....com,
jgg@...dia.com, Michael Shavit <mshavit@...gle.com>,
Dawei Li <set_pte_at@...look.com>,
Jason Gunthorpe <jgg@...pe.ca>, Joerg Roedel <joro@...tes.org>,
"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
Lu Baolu <baolu.lu@...ux.intel.com>,
Mark Brown <broonie@...nel.org>
Subject: [RFC PATCH v2 1/9] iommu/arm-smmu-v3: group attached devices by smmu
Always insert a new master in the devices_list besides other masters
that belong to the same smmu.
This allows code to batch commands by SMMU when iterating over masters
that a domain is attached to.
Signed-off-by: Michael Shavit <mshavit@...gle.com>
---
Changes in v2:
- New commit
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 22 ++++++++++++++++++---
1 file changed, 19 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 f17704c35858d..37b9223c145ba 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
@@ -2382,6 +2382,24 @@ static void arm_smmu_detach_dev(struct arm_smmu_master *master)
arm_smmu_write_ctx_desc(master, 0, NULL);
}
+static void arm_smmu_domain_device_list_add(struct arm_smmu_domain *smmu_domain,
+ struct arm_smmu_master *master)
+{
+ struct arm_smmu_master *iter;
+ unsigned long flags;
+
+ spin_lock_irqsave(&smmu_domain->devices_lock, flags);
+ if (list_empty(&smmu_domain->devices))
+ list_add(&master->domain_head, &smmu_domain->devices);
+ else {
+ list_for_each_entry(iter, &smmu_domain->devices, domain_head)
+ if (iter->smmu == master->smmu)
+ break;
+ list_add(&master->domain_head, &iter->domain_head);
+ }
+ spin_unlock_irqrestore(&smmu_domain->devices_lock, flags);
+}
+
static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
{
int ret = 0;
@@ -2435,9 +2453,7 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
if (smmu_domain->stage != ARM_SMMU_DOMAIN_BYPASS)
master->ats_enabled = arm_smmu_ats_supported(master);
- spin_lock_irqsave(&smmu_domain->devices_lock, flags);
- list_add(&master->domain_head, &smmu_domain->devices);
- spin_unlock_irqrestore(&smmu_domain->devices_lock, flags);
+ arm_smmu_domain_device_list_add(smmu_domain, master);
if (smmu_domain->stage == ARM_SMMU_DOMAIN_S1) {
if (!master->cd_table.cdtab) {
--
2.42.0.rc1.204.g551eb34607-goog
Powered by blists - more mailing lists