Skip to content

Commit 4f18d3f

Browse files
committed
Merge tag 'iommu-fixes-v6.8-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu
Pul iommu fixes from Joerg Roedel: - Make iommu_ops->default_domain work without CONFIG_IOMMU_DMA to fix initialization of FSL-PAMU devices - Fix for Tegra fbdev initialization failure - Fix for a VFIO device unbinding failure on PowerPC * tag 'iommu-fixes-v6.8-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu: powerpc: iommu: Bring back table group release_ownership() call drm/tegra: Do not assume that a NULL domain means no DMA IOMMU iommu: Allow ops->default_domain to work when !CONFIG_IOMMU_DMA
2 parents 6897cea + d2d00e1 commit 4f18d3f

File tree

3 files changed

+43
-15
lines changed

3 files changed

+43
-15
lines changed

arch/powerpc/kernel/iommu.c

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,20 +1287,20 @@ spapr_tce_platform_iommu_attach_dev(struct iommu_domain *platform_domain,
12871287
struct iommu_domain *domain = iommu_get_domain_for_dev(dev);
12881288
struct iommu_group *grp = iommu_group_get(dev);
12891289
struct iommu_table_group *table_group;
1290-
int ret = -EINVAL;
12911290

12921291
/* At first attach the ownership is already set */
12931292
if (!domain)
12941293
return 0;
12951294

1296-
if (!grp)
1297-
return -ENODEV;
1298-
12991295
table_group = iommu_group_get_iommudata(grp);
1300-
ret = table_group->ops->take_ownership(table_group);
1296+
/*
1297+
* The domain being set to PLATFORM from earlier
1298+
* BLOCKED. The table_group ownership has to be released.
1299+
*/
1300+
table_group->ops->release_ownership(table_group);
13011301
iommu_group_put(grp);
13021302

1303-
return ret;
1303+
return 0;
13041304
}
13051305

13061306
static const struct iommu_domain_ops spapr_tce_platform_domain_ops = {
@@ -1312,13 +1312,32 @@ static struct iommu_domain spapr_tce_platform_domain = {
13121312
.ops = &spapr_tce_platform_domain_ops,
13131313
};
13141314

1315-
static struct iommu_domain spapr_tce_blocked_domain = {
1316-
.type = IOMMU_DOMAIN_BLOCKED,
1315+
static int
1316+
spapr_tce_blocked_iommu_attach_dev(struct iommu_domain *platform_domain,
1317+
struct device *dev)
1318+
{
1319+
struct iommu_group *grp = iommu_group_get(dev);
1320+
struct iommu_table_group *table_group;
1321+
int ret = -EINVAL;
1322+
13171323
/*
13181324
* FIXME: SPAPR mixes blocked and platform behaviors, the blocked domain
13191325
* also sets the dma_api ops
13201326
*/
1321-
.ops = &spapr_tce_platform_domain_ops,
1327+
table_group = iommu_group_get_iommudata(grp);
1328+
ret = table_group->ops->take_ownership(table_group);
1329+
iommu_group_put(grp);
1330+
1331+
return ret;
1332+
}
1333+
1334+
static const struct iommu_domain_ops spapr_tce_blocked_domain_ops = {
1335+
.attach_dev = spapr_tce_blocked_iommu_attach_dev,
1336+
};
1337+
1338+
static struct iommu_domain spapr_tce_blocked_domain = {
1339+
.type = IOMMU_DOMAIN_BLOCKED,
1340+
.ops = &spapr_tce_blocked_domain_ops,
13221341
};
13231342

13241343
static bool spapr_tce_iommu_capable(struct device *dev, enum iommu_cap cap)

drivers/gpu/drm/tegra/drm.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,8 @@ int host1x_client_iommu_attach(struct host1x_client *client)
960960
* not the shared IOMMU domain, don't try to attach it to a different
961961
* domain. This allows using the IOMMU-backed DMA API.
962962
*/
963-
if (domain && domain != tegra->domain)
963+
if (domain && domain->type != IOMMU_DOMAIN_IDENTITY &&
964+
domain != tegra->domain)
964965
return 0;
965966

966967
if (tegra->domain) {

drivers/iommu/iommu.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,7 +1799,7 @@ iommu_group_alloc_default_domain(struct iommu_group *group, int req_type)
17991799
* domain. Do not use in new drivers.
18001800
*/
18011801
if (ops->default_domain) {
1802-
if (req_type)
1802+
if (req_type != ops->default_domain->type)
18031803
return ERR_PTR(-EINVAL);
18041804
return ops->default_domain;
18051805
}
@@ -1871,10 +1871,18 @@ static int iommu_get_def_domain_type(struct iommu_group *group,
18711871
const struct iommu_ops *ops = dev_iommu_ops(dev);
18721872
int type;
18731873

1874-
if (!ops->def_domain_type)
1875-
return cur_type;
1876-
1877-
type = ops->def_domain_type(dev);
1874+
if (ops->default_domain) {
1875+
/*
1876+
* Drivers that declare a global static default_domain will
1877+
* always choose that.
1878+
*/
1879+
type = ops->default_domain->type;
1880+
} else {
1881+
if (ops->def_domain_type)
1882+
type = ops->def_domain_type(dev);
1883+
else
1884+
return cur_type;
1885+
}
18781886
if (!type || cur_type == type)
18791887
return cur_type;
18801888
if (!cur_type)

0 commit comments

Comments
 (0)