Skip to content

Commit d2d00e1

Browse files
ShivaprasadGBhatjoergroedel
authored andcommitted
powerpc: iommu: Bring back table group release_ownership() call
The commit 2ad56ef ("powerpc/iommu: Setup a default domain and remove set_platform_dma_ops") refactored the code removing the set_platform_dma_ops(). It missed out the table group release_ownership() call which would have got called otherwise during the guest shutdown via vfio_group_detach_container(). On PPC64, this particular call actually sets up the 32-bit TCE table, and enables the 64-bit DMA bypass etc. Now after guest shutdown, the subsequent host driver (e.g megaraid-sas) probe post unbind from vfio-pci fails like, megaraid_sas 0031:01:00.0: Warning: IOMMU dma not supported: mask 0x7fffffffffffffff, table unavailable megaraid_sas 0031:01:00.0: Warning: IOMMU dma not supported: mask 0xffffffff, table unavailable megaraid_sas 0031:01:00.0: Failed to set DMA mask megaraid_sas 0031:01:00.0: Failed from megasas_init_fw 6539 The patch brings back the call to table_group release_ownership() call when switching back to PLATFORM domain from BLOCKED, while also separates the domain_ops for both. Fixes: 2ad56ef ("powerpc/iommu: Setup a default domain and remove set_platform_dma_ops") Signed-off-by: Shivaprasad G Bhat <sbhat@linux.ibm.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Link: https://lore.kernel.org/r/170628173462.3742.18330000394415935845.stgit@ltcd48-lp2.aus.stglab.ibm.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent fae6e66 commit d2d00e1

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
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)

0 commit comments

Comments
 (0)