Skip to content

Commit f675692

Browse files
committed
Merge tag 'arm-smmu-updates' of git://git.kernel.org/pub/scm/linux/kernel/git/will/linux into arm/smmu
Arm SMMU updates for 6.9 - Device-tree binding updates for a bunch of Qualcomm SoCs - SMMUv2: * Support for Qualcomm X1E80100 MDSS - SMMUv3: * Significant rework of the driver's STE manipulation and domain handling code. This is the initial part of a larger scale rework aiming to improve the driver's implementation of the IOMMU API in preparation for hooking up IOMMUFD support.
2 parents 54be6c6 + 327e10b commit f675692

File tree

6 files changed

+522
-274
lines changed

6 files changed

+522
-274
lines changed

Documentation/devicetree/bindings/iommu/arm,smmu.yaml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ properties:
8383
- description: Qcom Adreno GPUs implementing "qcom,smmu-500" and "arm,mmu-500"
8484
items:
8585
- enum:
86+
- qcom,qcm2290-smmu-500
8687
- qcom,sa8775p-smmu-500
8788
- qcom,sc7280-smmu-500
8889
- qcom,sc8280xp-smmu-500
@@ -93,6 +94,7 @@ properties:
9394
- qcom,sm8350-smmu-500
9495
- qcom,sm8450-smmu-500
9596
- qcom,sm8550-smmu-500
97+
- qcom,sm8650-smmu-500
9698
- const: qcom,adreno-smmu
9799
- const: qcom,smmu-500
98100
- const: arm,mmu-500
@@ -462,6 +464,7 @@ allOf:
462464
compatible:
463465
items:
464466
- enum:
467+
- qcom,qcm2290-smmu-500
465468
- qcom,sm6115-smmu-500
466469
- qcom,sm6125-smmu-500
467470
- const: qcom,adreno-smmu
@@ -484,7 +487,12 @@ allOf:
484487
- if:
485488
properties:
486489
compatible:
487-
const: qcom,sm8450-smmu-500
490+
items:
491+
- const: qcom,sm8450-smmu-500
492+
- const: qcom,adreno-smmu
493+
- const: qcom,smmu-500
494+
- const: arm,mmu-500
495+
488496
then:
489497
properties:
490498
clock-names:
@@ -508,7 +516,13 @@ allOf:
508516
- if:
509517
properties:
510518
compatible:
511-
const: qcom,sm8550-smmu-500
519+
items:
520+
- enum:
521+
- qcom,sm8550-smmu-500
522+
- qcom,sm8650-smmu-500
523+
- const: qcom,adreno-smmu
524+
- const: qcom,smmu-500
525+
- const: arm,mmu-500
512526
then:
513527
properties:
514528
clock-names:
@@ -534,7 +548,6 @@ allOf:
534548
- cavium,smmu-v2
535549
- marvell,ap806-smmu-500
536550
- nvidia,smmu-500
537-
- qcom,qcm2290-smmu-500
538551
- qcom,qdu1000-smmu-500
539552
- qcom,sc7180-smmu-500
540553
- qcom,sc8180x-smmu-500
@@ -544,7 +557,6 @@ allOf:
544557
- qcom,sdx65-smmu-500
545558
- qcom,sm6350-smmu-500
546559
- qcom,sm6375-smmu-500
547-
- qcom,sm8650-smmu-500
548560
- qcom,x1e80100-smmu-500
549561
then:
550562
properties:

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

Lines changed: 19 additions & 27 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,13 +357,20 @@ 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;
388365
struct arm_smmu_master *master = dev_iommu_priv_get(dev);
389366
struct iommu_domain *domain = iommu_get_domain_for_dev(dev);
390-
struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
367+
struct arm_smmu_domain *smmu_domain;
368+
369+
if (!(domain->type & __IOMMU_DOMAIN_PAGING))
370+
return -ENODEV;
371+
smmu_domain = to_smmu_domain(domain);
372+
if (smmu_domain->stage != ARM_SMMU_DOMAIN_S1)
373+
return -ENODEV;
391374

392375
if (!master || !master->sva_enabled)
393376
return -ENODEV;
@@ -404,9 +387,15 @@ static int __arm_smmu_sva_bind(struct device *dev, struct mm_struct *mm)
404387
goto err_free_bond;
405388
}
406389

390+
ret = arm_smmu_write_ctx_desc(master, pasid, bond->smmu_mn->cd);
391+
if (ret)
392+
goto err_put_notifier;
393+
407394
list_add(&bond->list, &master->bonds);
408395
return 0;
409396

397+
err_put_notifier:
398+
arm_smmu_mmu_notifier_put(bond->smmu_mn);
410399
err_free_bond:
411400
kfree(bond);
412401
return ret;
@@ -568,6 +557,9 @@ void arm_smmu_sva_remove_dev_pasid(struct iommu_domain *domain,
568557
struct arm_smmu_master *master = dev_iommu_priv_get(dev);
569558

570559
mutex_lock(&sva_lock);
560+
561+
arm_smmu_write_ctx_desc(master, id, NULL);
562+
571563
list_for_each_entry(t, &master->bonds, list) {
572564
if (t->mm == mm) {
573565
bond = t;
@@ -590,7 +582,7 @@ static int arm_smmu_sva_set_dev_pasid(struct iommu_domain *domain,
590582
struct mm_struct *mm = domain->mm;
591583

592584
mutex_lock(&sva_lock);
593-
ret = __arm_smmu_sva_bind(dev, mm);
585+
ret = __arm_smmu_sva_bind(dev, id, mm);
594586
mutex_unlock(&sva_lock);
595587

596588
return ret;

0 commit comments

Comments
 (0)