Skip to content

Commit 91403d5

Browse files
committed
Merge tag 'iommu-fixes-v6.8-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu
Pull iommu fixes from Joerg Roedel: - Intel VT-d fixes for nested domain handling: - Cache invalidation for changes in a parent domain - Dirty tracking setting for parent and nested domains - Fix a constant-out-of-range warning - ARM SMMU fixes: - Fix CD allocation from atomic context when using SVA with SMMUv3 - Revert the conversion of SMMUv2 to domain_alloc_paging(), as it breaks the boot for Qualcomm MSM8996 devices - Restore SVA handle sharing in core code as it turned out there are still drivers relying on it * tag 'iommu-fixes-v6.8-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu: iommu/sva: Restore SVA handle sharing iommu/arm-smmu-v3: Do not use GFP_KERNEL under as spinlock iommu/vt-d: Fix constant-out-of-range warning iommu/vt-d: Set SSADE when attaching to a parent with dirty tracking iommu/vt-d: Add missing dirty tracking set for parent domain iommu/vt-d: Wrap the dirty tracking loop to be a helper iommu/vt-d: Remove domain parameter for intel_pasid_setup_dirty_tracking() iommu/vt-d: Add missing device iotlb flush for parent domain iommu/vt-d: Update iotlb in nested domain attach iommu/vt-d: Add missing iotlb flush for parent domain iommu/vt-d: Add __iommu_flush_iotlb_psi() iommu/vt-d: Track nested domains in parent Revert "iommu/arm-smmu: Convert to domain_alloc_paging()"
2 parents ac389bc + 65d4418 commit 91403d5

File tree

9 files changed

+225
-93
lines changed

9 files changed

+225
-93
lines changed

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,8 @@ arm_smmu_mmu_notifier_get(struct arm_smmu_domain *smmu_domain,
292292
struct mm_struct *mm)
293293
{
294294
int ret;
295-
unsigned long flags;
296295
struct arm_smmu_ctx_desc *cd;
297296
struct arm_smmu_mmu_notifier *smmu_mn;
298-
struct arm_smmu_master *master;
299297

300298
list_for_each_entry(smmu_mn, &smmu_domain->mmu_notifiers, list) {
301299
if (smmu_mn->mn.mm == mm) {
@@ -325,28 +323,9 @@ arm_smmu_mmu_notifier_get(struct arm_smmu_domain *smmu_domain,
325323
goto err_free_cd;
326324
}
327325

328-
spin_lock_irqsave(&smmu_domain->devices_lock, flags);
329-
list_for_each_entry(master, &smmu_domain->devices, domain_head) {
330-
ret = arm_smmu_write_ctx_desc(master, mm_get_enqcmd_pasid(mm),
331-
cd);
332-
if (ret) {
333-
list_for_each_entry_from_reverse(
334-
master, &smmu_domain->devices, domain_head)
335-
arm_smmu_write_ctx_desc(
336-
master, mm_get_enqcmd_pasid(mm), NULL);
337-
break;
338-
}
339-
}
340-
spin_unlock_irqrestore(&smmu_domain->devices_lock, flags);
341-
if (ret)
342-
goto err_put_notifier;
343-
344326
list_add(&smmu_mn->list, &smmu_domain->mmu_notifiers);
345327
return smmu_mn;
346328

347-
err_put_notifier:
348-
/* Frees smmu_mn */
349-
mmu_notifier_put(&smmu_mn->mn);
350329
err_free_cd:
351330
arm_smmu_free_shared_cd(cd);
352331
return ERR_PTR(ret);
@@ -363,9 +342,6 @@ static void arm_smmu_mmu_notifier_put(struct arm_smmu_mmu_notifier *smmu_mn)
363342

364343
list_del(&smmu_mn->list);
365344

366-
arm_smmu_update_ctx_desc_devices(smmu_domain, mm_get_enqcmd_pasid(mm),
367-
NULL);
368-
369345
/*
370346
* If we went through clear(), we've already invalidated, and no
371347
* new TLB entry can have been formed.
@@ -381,7 +357,8 @@ static void arm_smmu_mmu_notifier_put(struct arm_smmu_mmu_notifier *smmu_mn)
381357
arm_smmu_free_shared_cd(cd);
382358
}
383359

384-
static int __arm_smmu_sva_bind(struct device *dev, struct mm_struct *mm)
360+
static int __arm_smmu_sva_bind(struct device *dev, ioasid_t pasid,
361+
struct mm_struct *mm)
385362
{
386363
int ret;
387364
struct arm_smmu_bond *bond;
@@ -404,9 +381,15 @@ static int __arm_smmu_sva_bind(struct device *dev, struct mm_struct *mm)
404381
goto err_free_bond;
405382
}
406383

384+
ret = arm_smmu_write_ctx_desc(master, pasid, bond->smmu_mn->cd);
385+
if (ret)
386+
goto err_put_notifier;
387+
407388
list_add(&bond->list, &master->bonds);
408389
return 0;
409390

391+
err_put_notifier:
392+
arm_smmu_mmu_notifier_put(bond->smmu_mn);
410393
err_free_bond:
411394
kfree(bond);
412395
return ret;
@@ -568,6 +551,9 @@ void arm_smmu_sva_remove_dev_pasid(struct iommu_domain *domain,
568551
struct arm_smmu_master *master = dev_iommu_priv_get(dev);
569552

570553
mutex_lock(&sva_lock);
554+
555+
arm_smmu_write_ctx_desc(master, id, NULL);
556+
571557
list_for_each_entry(t, &master->bonds, list) {
572558
if (t->mm == mm) {
573559
bond = t;
@@ -590,7 +576,7 @@ static int arm_smmu_sva_set_dev_pasid(struct iommu_domain *domain,
590576
struct mm_struct *mm = domain->mm;
591577

592578
mutex_lock(&sva_lock);
593-
ret = __arm_smmu_sva_bind(dev, mm);
579+
ret = __arm_smmu_sva_bind(dev, id, mm);
594580
mutex_unlock(&sva_lock);
595581

596582
return ret;

drivers/iommu/arm/arm-smmu/arm-smmu.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -859,10 +859,14 @@ static void arm_smmu_destroy_domain_context(struct arm_smmu_domain *smmu_domain)
859859
arm_smmu_rpm_put(smmu);
860860
}
861861

862-
static struct iommu_domain *arm_smmu_domain_alloc_paging(struct device *dev)
862+
static struct iommu_domain *arm_smmu_domain_alloc(unsigned type)
863863
{
864864
struct arm_smmu_domain *smmu_domain;
865865

866+
if (type != IOMMU_DOMAIN_UNMANAGED) {
867+
if (using_legacy_binding || type != IOMMU_DOMAIN_DMA)
868+
return NULL;
869+
}
866870
/*
867871
* Allocate the domain and initialise some of its data structures.
868872
* We can't really do anything meaningful until we've added a
@@ -875,15 +879,6 @@ static struct iommu_domain *arm_smmu_domain_alloc_paging(struct device *dev)
875879
mutex_init(&smmu_domain->init_mutex);
876880
spin_lock_init(&smmu_domain->cb_lock);
877881

878-
if (dev) {
879-
struct arm_smmu_master_cfg *cfg = dev_iommu_priv_get(dev);
880-
881-
if (arm_smmu_init_domain_context(smmu_domain, cfg->smmu, dev)) {
882-
kfree(smmu_domain);
883-
return NULL;
884-
}
885-
}
886-
887882
return &smmu_domain->domain;
888883
}
889884

@@ -1600,7 +1595,7 @@ static struct iommu_ops arm_smmu_ops = {
16001595
.identity_domain = &arm_smmu_identity_domain,
16011596
.blocked_domain = &arm_smmu_blocked_domain,
16021597
.capable = arm_smmu_capable,
1603-
.domain_alloc_paging = arm_smmu_domain_alloc_paging,
1598+
.domain_alloc = arm_smmu_domain_alloc,
16041599
.probe_device = arm_smmu_probe_device,
16051600
.release_device = arm_smmu_release_device,
16061601
.probe_finalize = arm_smmu_probe_finalize,

0 commit comments

Comments
 (0)