Skip to content

Commit 327e10b

Browse files
jgunthorpewilldeacon
authored andcommitted
iommu/arm-smmu-v3: Convert to domain_alloc_paging()
Now that the BLOCKED and IDENTITY behaviors are managed with their own domains change to the domain_alloc_paging() op. For now SVA remains using the old interface, eventually it will get its own op that can pass in the device and mm_struct which will let us have a sane lifetime for the mmu_notifier. Call arm_smmu_domain_finalise() early if dev is available. Tested-by: Shameer Kolothum <[email protected]> Tested-by: Nicolin Chen <[email protected]> Tested-by: Moritz Fischer <[email protected]> Reviewed-by: Nicolin Chen <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent d8cd200 commit 327e10b

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

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

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2197,14 +2197,15 @@ static bool arm_smmu_capable(struct device *dev, enum iommu_cap cap)
21972197

21982198
static struct iommu_domain *arm_smmu_domain_alloc(unsigned type)
21992199
{
2200-
struct arm_smmu_domain *smmu_domain;
22012200

22022201
if (type == IOMMU_DOMAIN_SVA)
22032202
return arm_smmu_sva_domain_alloc();
2203+
return ERR_PTR(-EOPNOTSUPP);
2204+
}
22042205

2205-
if (type != IOMMU_DOMAIN_UNMANAGED &&
2206-
type != IOMMU_DOMAIN_DMA)
2207-
return NULL;
2206+
static struct iommu_domain *arm_smmu_domain_alloc_paging(struct device *dev)
2207+
{
2208+
struct arm_smmu_domain *smmu_domain;
22082209

22092210
/*
22102211
* Allocate the domain and initialise some of its data structures.
@@ -2213,13 +2214,23 @@ static struct iommu_domain *arm_smmu_domain_alloc(unsigned type)
22132214
*/
22142215
smmu_domain = kzalloc(sizeof(*smmu_domain), GFP_KERNEL);
22152216
if (!smmu_domain)
2216-
return NULL;
2217+
return ERR_PTR(-ENOMEM);
22172218

22182219
mutex_init(&smmu_domain->init_mutex);
22192220
INIT_LIST_HEAD(&smmu_domain->devices);
22202221
spin_lock_init(&smmu_domain->devices_lock);
22212222
INIT_LIST_HEAD(&smmu_domain->mmu_notifiers);
22222223

2224+
if (dev) {
2225+
struct arm_smmu_master *master = dev_iommu_priv_get(dev);
2226+
int ret;
2227+
2228+
ret = arm_smmu_domain_finalise(smmu_domain, master->smmu);
2229+
if (ret) {
2230+
kfree(smmu_domain);
2231+
return ERR_PTR(ret);
2232+
}
2233+
}
22232234
return &smmu_domain->domain;
22242235
}
22252236

@@ -3083,6 +3094,7 @@ static struct iommu_ops arm_smmu_ops = {
30833094
.blocked_domain = &arm_smmu_blocked_domain,
30843095
.capable = arm_smmu_capable,
30853096
.domain_alloc = arm_smmu_domain_alloc,
3097+
.domain_alloc_paging = arm_smmu_domain_alloc_paging,
30863098
.probe_device = arm_smmu_probe_device,
30873099
.release_device = arm_smmu_release_device,
30883100
.device_group = arm_smmu_device_group,

0 commit comments

Comments
 (0)