Skip to content

Commit ac9c5e9

Browse files
rmurphy-armjoergroedel
authored andcommitted
iommu/arm-smmu: Report IOMMU_CAP_CACHE_COHERENCY even betterer
Although it's vanishingly unlikely that anyone would integrate an SMMU within a coherent interconnect without also making the pagetable walk interface coherent, the same effect happens if a coherent SMMU fails to advertise CTTW correctly. This turns out to be the case on some popular NXP SoCs, where VFIO started failing the IOMMU_CAP_CACHE_COHERENCY test, even though IOMMU_CACHE *was* previously achieving the desired effect anyway thanks to the underlying integration. While those SoCs stand to gain some more general benefits from a firmware update to override CTTW correctly in DT/ACPI, it's also easy to work around this in Linux as well, to avoid imposing too much on affected users - since the upstream client devices *are* correctly marked as coherent, we can trivially infer their coherent paths through the SMMU as well. Reported-by: Vladimir Oltean <[email protected]> Fixes: df198b3 ("iommu/arm-smmu: Report IOMMU_CAP_CACHE_COHERENCY better") Signed-off-by: Robin Murphy <[email protected]> Tested-by: Vladimir Oltean <[email protected]> Link: https://lore.kernel.org/r/d6dc41952961e5c7b21acac08a8bf1eb0f69e124.1671123115.git.robin.murphy@arm.com Signed-off-by: Will Deacon <[email protected]>
1 parent b7bfaa7 commit ac9c5e9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,8 +1316,14 @@ static bool arm_smmu_capable(struct device *dev, enum iommu_cap cap)
13161316

13171317
switch (cap) {
13181318
case IOMMU_CAP_CACHE_COHERENCY:
1319-
/* Assume that a coherent TCU implies coherent TBUs */
1320-
return cfg->smmu->features & ARM_SMMU_FEAT_COHERENT_WALK;
1319+
/*
1320+
* It's overwhelmingly the case in practice that when the pagetable
1321+
* walk interface is connected to a coherent interconnect, all the
1322+
* translation interfaces are too. Furthermore if the device is
1323+
* natively coherent, then its translation interface must also be.
1324+
*/
1325+
return cfg->smmu->features & ARM_SMMU_FEAT_COHERENT_WALK ||
1326+
device_get_dma_attr(dev) == DEV_DMA_COHERENT;
13211327
case IOMMU_CAP_NOEXEC:
13221328
return true;
13231329
default:

0 commit comments

Comments
 (0)