@@ -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 :
@@ -2185,19 +2191,16 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
21852191 return 0 ;
21862192}
21872193
2188- static int arm_smmu_device_remove (struct platform_device * pdev )
2194+ static void arm_smmu_device_shutdown (struct platform_device * pdev )
21892195{
21902196 struct arm_smmu_device * smmu = platform_get_drvdata (pdev );
21912197
21922198 if (!smmu )
2193- return - ENODEV ;
2199+ return ;
21942200
21952201 if (!bitmap_empty (smmu -> context_map , ARM_SMMU_MAX_CBS ))
21962202 dev_notice (& pdev -> dev , "disabling translation\n" );
21972203
2198- iommu_device_unregister (& smmu -> iommu );
2199- iommu_device_sysfs_remove (& smmu -> iommu );
2200-
22012204 arm_smmu_rpm_get (smmu );
22022205 /* Turn the thing off */
22032206 arm_smmu_gr0_write (smmu , ARM_SMMU_GR0_sCR0 , ARM_SMMU_sCR0_CLIENTPD );
@@ -2209,12 +2212,21 @@ static int arm_smmu_device_remove(struct platform_device *pdev)
22092212 clk_bulk_disable (smmu -> num_clks , smmu -> clks );
22102213
22112214 clk_bulk_unprepare (smmu -> num_clks , smmu -> clks );
2212- return 0 ;
22132215}
22142216
2215- static void arm_smmu_device_shutdown (struct platform_device * pdev )
2217+ static int arm_smmu_device_remove (struct platform_device * pdev )
22162218{
2217- arm_smmu_device_remove (pdev );
2219+ struct arm_smmu_device * smmu = platform_get_drvdata (pdev );
2220+
2221+ if (!smmu )
2222+ return - ENODEV ;
2223+
2224+ iommu_device_unregister (& smmu -> iommu );
2225+ iommu_device_sysfs_remove (& smmu -> iommu );
2226+
2227+ arm_smmu_device_shutdown (pdev );
2228+
2229+ return 0 ;
22182230}
22192231
22202232static int __maybe_unused arm_smmu_runtime_resume (struct device * dev )
0 commit comments