mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 12:52:29 -04:00
iommu/rockchip: Clear stale page faults before enabling stall
Boot firmware can leave an IOMMU bank in PAGE_FAULT_ACTIVE before the driver has configured paging: PAGE_FAULT_ACTIVE=1 STALL_ACTIVE=0 IDLE=1 Such a bank ignores CMD_ENABLE_STALL and never reaches STALL_ACTIVE, so rk_iommu_enable_stall()'s readx_poll_timeout() spins until it times out (seen on the RK3576 NPU, whose MMUs share this poll across banks). Rather than special-casing these banks in the stall path, acknowledge the stale fault with CMD_PAGE_FAULT_DONE before enabling stall, so every bank starts from a clean state and the normal stall sequence applies to all of them. Banks without a pending fault are untouched. Signed-off-by: Jiaxing Hu <gahing@gahingwoo.com> Signed-off-by: Will Deacon <will@kernel.org>
This commit is contained in:
@@ -418,6 +418,19 @@ static int rk_iommu_enable_stall(struct rk_iommu *iommu)
|
||||
if (!rk_iommu_is_paging_enabled(iommu))
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* Boot firmware can leave a bank in PAGE_FAULT_ACTIVE with no handler
|
||||
* (PAGE_FAULT_ACTIVE & !STALL_ACTIVE & IDLE). Such a bank ignores
|
||||
* CMD_ENABLE_STALL and never reaches STALL_ACTIVE, timing out the poll
|
||||
* below. Acknowledge any stale fault first so every bank starts clean.
|
||||
*/
|
||||
for (i = 0; i < iommu->num_mmu; i++) {
|
||||
if (rk_iommu_read(iommu->bases[i], RK_MMU_STATUS) &
|
||||
RK_MMU_STATUS_PAGE_FAULT_ACTIVE)
|
||||
writel(RK_MMU_CMD_PAGE_FAULT_DONE,
|
||||
iommu->bases[i] + RK_MMU_COMMAND);
|
||||
}
|
||||
|
||||
rk_iommu_command(iommu, RK_MMU_CMD_ENABLE_STALL);
|
||||
|
||||
ret = readx_poll_timeout(rk_iommu_is_stall_active, iommu, val,
|
||||
|
||||
Reference in New Issue
Block a user