Skip to content

Commit

Permalink
Merge tag 'iommu-fixes-v5.8-rc5' of git://git.kernel.org/pub/scm/linu…
Browse files Browse the repository at this point in the history
…x/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
  • Loading branch information
Linus Torvalds committed Jul 13, 2020
2 parents f81fdd0 + a082121 commit 0dc589d
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
1 change: 1 addition & 0 deletions drivers/iommu/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ config ROCKCHIP_IOMMU

config SUN50I_IOMMU
bool "Allwinner H6 IOMMU Support"
depends on HAS_DMA
depends on ARCH_SUNXI || COMPILE_TEST
select ARM_DMA_USE_IOMMU
select IOMMU_API
Expand Down
2 changes: 1 addition & 1 deletion drivers/iommu/amd/amd_iommu.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ extern int __init add_special_device(u8 type, u8 id, u16 *devid,
#ifdef CONFIG_DMI
void amd_iommu_apply_ivrs_quirks(void);
#else
static void amd_iommu_apply_ivrs_quirks(void) { }
static inline void amd_iommu_apply_ivrs_quirks(void) { }
#endif

#endif
2 changes: 1 addition & 1 deletion drivers/iommu/arm-smmu-qcom.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct qcom_smmu {
struct arm_smmu_device smmu;
};

static const struct of_device_id qcom_smmu_client_of_match[] = {
static const struct of_device_id qcom_smmu_client_of_match[] __maybe_unused = {
{ .compatible = "qcom,adreno" },
{ .compatible = "qcom,mdp4" },
{ .compatible = "qcom,mdss" },
Expand Down
2 changes: 1 addition & 1 deletion drivers/iommu/iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,10 @@ void iommu_release_device(struct device *dev)
return;

iommu_device_unlink(dev->iommu->iommu_dev, dev);
iommu_group_remove_device(dev);

ops->release_device(dev);

iommu_group_remove_device(dev);
module_put(ops->owner);
dev_iommu_free(dev);
}
Expand Down
8 changes: 3 additions & 5 deletions drivers/iommu/sun50i-iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,9 @@ static int sun50i_iommu_flush_all_tlb(struct sun50i_iommu *iommu)
IOMMU_TLB_FLUSH_MICRO_TLB(1) |
IOMMU_TLB_FLUSH_MICRO_TLB(0));

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

Expand Down Expand Up @@ -556,7 +556,6 @@ static size_t sun50i_iommu_unmap(struct iommu_domain *domain, unsigned long iova
{
struct sun50i_iommu_domain *sun50i_domain = to_sun50i_domain(domain);
phys_addr_t pt_phys;
dma_addr_t pte_dma;
u32 *pte_addr;
u32 dte;

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

pt_phys = sun50i_dte_get_pt_address(dte);
pte_addr = (u32 *)phys_to_virt(pt_phys) + sun50i_iova_get_pte_index(iova);
pte_dma = pt_phys + sun50i_iova_get_pte_index(iova) * PT_ENTRY_SIZE;

if (!sun50i_pte_is_page_valid(*pte_addr))
return 0;
Expand Down

0 comments on commit 0dc589d

Please sign in to comment.