Skip to content

Commit 0dc589d

Browse files
committed
Merge tag 'iommu-fixes-v5.8-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu
Pull iommu fixes from Joerg Roedel: - Fix a use-after-free of the device iommu-group. Found in the arm-smmu driver, but the fix is in generic code. - Fix for the new Allwinner IOMMU driver to use the atomic readl_timeout() variant in IO/TLB flushing code. - A couple of cleanups to fix various compile warnings. * tag 'iommu-fixes-v5.8-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu: iommu/arm-smmu: Mark qcom_smmu_client_of_match as possibly unused iommu: Fix use-after-free in iommu_release_device iommu/amd: Make amd_iommu_apply_ivrs_quirks() static inline iommu: SUN50I_IOMMU should depend on HAS_DMA iommu/sun50i: Remove unused variable iommu/sun50i: Change the readl timeout to the atomic variant
2 parents f81fdd0 + a082121 commit 0dc589d

File tree

5 files changed

+7
-8
lines changed

5 files changed

+7
-8
lines changed

drivers/iommu/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ config ROCKCHIP_IOMMU
305305

306306
config SUN50I_IOMMU
307307
bool "Allwinner H6 IOMMU Support"
308+
depends on HAS_DMA
308309
depends on ARCH_SUNXI || COMPILE_TEST
309310
select ARM_DMA_USE_IOMMU
310311
select IOMMU_API

drivers/iommu/amd/amd_iommu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ extern int __init add_special_device(u8 type, u8 id, u16 *devid,
102102
#ifdef CONFIG_DMI
103103
void amd_iommu_apply_ivrs_quirks(void);
104104
#else
105-
static void amd_iommu_apply_ivrs_quirks(void) { }
105+
static inline void amd_iommu_apply_ivrs_quirks(void) { }
106106
#endif
107107

108108
#endif

drivers/iommu/arm-smmu-qcom.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ struct qcom_smmu {
1212
struct arm_smmu_device smmu;
1313
};
1414

15-
static const struct of_device_id qcom_smmu_client_of_match[] = {
15+
static const struct of_device_id qcom_smmu_client_of_match[] __maybe_unused = {
1616
{ .compatible = "qcom,adreno" },
1717
{ .compatible = "qcom,mdp4" },
1818
{ .compatible = "qcom,mdss" },

drivers/iommu/iommu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,10 @@ void iommu_release_device(struct device *dev)
295295
return;
296296

297297
iommu_device_unlink(dev->iommu->iommu_dev, dev);
298-
iommu_group_remove_device(dev);
299298

300299
ops->release_device(dev);
301300

301+
iommu_group_remove_device(dev);
302302
module_put(ops->owner);
303303
dev_iommu_free(dev);
304304
}

drivers/iommu/sun50i-iommu.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,9 @@ static int sun50i_iommu_flush_all_tlb(struct sun50i_iommu *iommu)
313313
IOMMU_TLB_FLUSH_MICRO_TLB(1) |
314314
IOMMU_TLB_FLUSH_MICRO_TLB(0));
315315

316-
ret = readl_poll_timeout(iommu->base + IOMMU_TLB_FLUSH_REG,
317-
reg, !reg,
318-
1, 2000);
316+
ret = readl_poll_timeout_atomic(iommu->base + IOMMU_TLB_FLUSH_REG,
317+
reg, !reg,
318+
1, 2000);
319319
if (ret)
320320
dev_warn(iommu->dev, "TLB Flush timed out!\n");
321321

@@ -556,7 +556,6 @@ static size_t sun50i_iommu_unmap(struct iommu_domain *domain, unsigned long iova
556556
{
557557
struct sun50i_iommu_domain *sun50i_domain = to_sun50i_domain(domain);
558558
phys_addr_t pt_phys;
559-
dma_addr_t pte_dma;
560559
u32 *pte_addr;
561560
u32 dte;
562561

@@ -566,7 +565,6 @@ static size_t sun50i_iommu_unmap(struct iommu_domain *domain, unsigned long iova
566565

567566
pt_phys = sun50i_dte_get_pt_address(dte);
568567
pte_addr = (u32 *)phys_to_virt(pt_phys) + sun50i_iova_get_pte_index(iova);
569-
pte_dma = pt_phys + sun50i_iova_get_pte_index(iova) * PT_ENTRY_SIZE;
570568

571569
if (!sun50i_pte_is_page_valid(*pte_addr))
572570
return 0;

0 commit comments

Comments
 (0)