Skip to content

Commit 52acd7d

Browse files
shamiali2008willdeacon
authored andcommitted
iommu/arm-smmu-v3: Add support for domain_alloc_user fn
This will be used by iommufd for allocating usr managed domains and is also required when we add support for iommufd based dirty tracking support. Reviewed-by: Jason Gunthorpe <[email protected]> Reviewed-by: Nicolin Chen <[email protected]> Reviewed-by: Kevin Tian <[email protected]> Signed-off-by: Shameer Kolothum <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 9796cf9 commit 52acd7d

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

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

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ module_param(disable_msipolling, bool, 0444);
3636
MODULE_PARM_DESC(disable_msipolling,
3737
"Disable MSI-based polling for CMD_SYNC completion.");
3838

39+
static struct iommu_ops arm_smmu_ops;
40+
3941
enum arm_smmu_msi_index {
4042
EVTQ_MSI_INDEX,
4143
GERROR_MSI_INDEX,
@@ -3020,6 +3022,34 @@ static struct iommu_domain arm_smmu_blocked_domain = {
30203022
.ops = &arm_smmu_blocked_ops,
30213023
};
30223024

3025+
static struct iommu_domain *
3026+
arm_smmu_domain_alloc_user(struct device *dev, u32 flags,
3027+
struct iommu_domain *parent,
3028+
const struct iommu_user_data *user_data)
3029+
{
3030+
struct arm_smmu_master *master = dev_iommu_priv_get(dev);
3031+
struct arm_smmu_domain *smmu_domain;
3032+
int ret;
3033+
3034+
if (flags || parent || user_data)
3035+
return ERR_PTR(-EOPNOTSUPP);
3036+
3037+
smmu_domain = arm_smmu_domain_alloc();
3038+
if (!smmu_domain)
3039+
return ERR_PTR(-ENOMEM);
3040+
3041+
smmu_domain->domain.type = IOMMU_DOMAIN_UNMANAGED;
3042+
smmu_domain->domain.ops = arm_smmu_ops.default_domain_ops;
3043+
ret = arm_smmu_domain_finalise(smmu_domain, master->smmu);
3044+
if (ret)
3045+
goto err_free;
3046+
return &smmu_domain->domain;
3047+
3048+
err_free:
3049+
kfree(smmu_domain);
3050+
return ERR_PTR(ret);
3051+
}
3052+
30233053
static int arm_smmu_map_pages(struct iommu_domain *domain, unsigned long iova,
30243054
phys_addr_t paddr, size_t pgsize, size_t pgcount,
30253055
int prot, gfp_t gfp, size_t *mapped)
@@ -3190,8 +3220,6 @@ static void arm_smmu_remove_master(struct arm_smmu_master *master)
31903220
kfree(master->streams);
31913221
}
31923222

3193-
static struct iommu_ops arm_smmu_ops;
3194-
31953223
static struct iommu_device *arm_smmu_probe_device(struct device *dev)
31963224
{
31973225
int ret;
@@ -3399,6 +3427,7 @@ static struct iommu_ops arm_smmu_ops = {
33993427
.capable = arm_smmu_capable,
34003428
.domain_alloc_paging = arm_smmu_domain_alloc_paging,
34013429
.domain_alloc_sva = arm_smmu_sva_domain_alloc,
3430+
.domain_alloc_user = arm_smmu_domain_alloc_user,
34023431
.probe_device = arm_smmu_probe_device,
34033432
.release_device = arm_smmu_release_device,
34043433
.device_group = arm_smmu_device_group,

0 commit comments

Comments
 (0)