From 055d58f1f9580bf06bea5e6a259c84f0de769b68 Mon Sep 17 00:00:00 2001 From: Olav Haugan Date: Fri, 26 Apr 2013 12:50:28 -0700 Subject: [PATCH] iommu: msm: Ensure power is on in pg fault handler There is a race condition between turning off the power to the IOMMU and accessing registers in the page fault handler. The iommu detach function might get called just after a page fault happens. The detach function will turn off the regulators to the IOMMU. Since the page fault handler is a threaded irq it might not run until after the detach call has turned off the regulators. Add a check in the page fault handler that power is still on before accessing any IOMMU registers. CRs-fixed: 480439 Change-Id: I3a4a5f4cb7bfa5e1418b68b1f9683df75e0f8038 Signed-off-by: Olav Haugan --- drivers/iommu/msm_iommu-v1.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/iommu/msm_iommu-v1.c b/drivers/iommu/msm_iommu-v1.c index 8a260030c24..8e68beb7e9b 100644 --- a/drivers/iommu/msm_iommu-v1.c +++ b/drivers/iommu/msm_iommu-v1.c @@ -804,6 +804,19 @@ irqreturn_t msm_iommu_fault_handler_v2(int irq, void *dev_id) ctx_drvdata = dev_get_drvdata(&pdev->dev); BUG_ON(!ctx_drvdata); + if (!drvdata->ctx_attach_count) { + pr_err("Unexpected IOMMU page fault!\n"); + pr_err("name = %s\n", drvdata->name); + pr_err("Power is OFF. Unable to read page fault information\n"); + /* + * We cannot determine which context bank caused the issue so + * we just return handled here to ensure IRQ handler code is + * happy + */ + ret = IRQ_HANDLED; + goto fail; + } + ret = __enable_clocks(drvdata); if (ret) { ret = IRQ_NONE;