Skip to content

Commit bbbf11e

Browse files
jgunthorpewilldeacon
authored andcommitted
iommu/arm-smmu: Implement IOMMU_DOMAIN_BLOCKED
Using the same design as IDENTITY setup a S2CR_TYPE_FAULT s2cr for the device. Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Link: https://lore.kernel.org/r/3-v2-c86cc8c2230e+160bb-smmu_newapi_jgg@nvidia.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent 22bb7b4 commit bbbf11e

1 file changed

Lines changed: 25 additions & 3 deletions

File tree

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

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,8 +1164,8 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
11641164
return ret;
11651165
}
11661166

1167-
static int arm_smmu_attach_dev_identity(struct iommu_domain *domain,
1168-
struct device *dev)
1167+
static int arm_smmu_attach_dev_type(struct device *dev,
1168+
enum arm_smmu_s2cr_type type)
11691169
{
11701170
struct arm_smmu_master_cfg *cfg = dev_iommu_priv_get(dev);
11711171
struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
@@ -1180,12 +1180,18 @@ static int arm_smmu_attach_dev_identity(struct iommu_domain *domain,
11801180
if (ret < 0)
11811181
return ret;
11821182

1183-
arm_smmu_master_install_s2crs(cfg, S2CR_TYPE_BYPASS, 0, fwspec);
1183+
arm_smmu_master_install_s2crs(cfg, type, 0, fwspec);
11841184
arm_smmu_rpm_use_autosuspend(smmu);
11851185
arm_smmu_rpm_put(smmu);
11861186
return 0;
11871187
}
11881188

1189+
static int arm_smmu_attach_dev_identity(struct iommu_domain *domain,
1190+
struct device *dev)
1191+
{
1192+
return arm_smmu_attach_dev_type(dev, S2CR_TYPE_BYPASS);
1193+
}
1194+
11891195
static const struct iommu_domain_ops arm_smmu_identity_ops = {
11901196
.attach_dev = arm_smmu_attach_dev_identity,
11911197
};
@@ -1195,6 +1201,21 @@ static struct iommu_domain arm_smmu_identity_domain = {
11951201
.ops = &arm_smmu_identity_ops,
11961202
};
11971203

1204+
static int arm_smmu_attach_dev_blocked(struct iommu_domain *domain,
1205+
struct device *dev)
1206+
{
1207+
return arm_smmu_attach_dev_type(dev, S2CR_TYPE_FAULT);
1208+
}
1209+
1210+
static const struct iommu_domain_ops arm_smmu_blocked_ops = {
1211+
.attach_dev = arm_smmu_attach_dev_blocked,
1212+
};
1213+
1214+
static struct iommu_domain arm_smmu_blocked_domain = {
1215+
.type = IOMMU_DOMAIN_BLOCKED,
1216+
.ops = &arm_smmu_blocked_ops,
1217+
};
1218+
11981219
static int arm_smmu_map_pages(struct iommu_domain *domain, unsigned long iova,
11991220
phys_addr_t paddr, size_t pgsize, size_t pgcount,
12001221
int prot, gfp_t gfp, size_t *mapped)
@@ -1582,6 +1603,7 @@ static int arm_smmu_def_domain_type(struct device *dev)
15821603

15831604
static struct iommu_ops arm_smmu_ops = {
15841605
.identity_domain = &arm_smmu_identity_domain,
1606+
.blocked_domain = &arm_smmu_blocked_domain,
15851607
.capable = arm_smmu_capable,
15861608
.domain_alloc = arm_smmu_domain_alloc,
15871609
.probe_device = arm_smmu_probe_device,

0 commit comments

Comments
 (0)