[PATCH v3 2/2] OMAP: IOMMU: add support to callback during fault handling
From: Hiroshi DOYU <hidden>
Date: 2011-02-21 09:51:23
Also in:
linux-omap
From: ext David Cohen <redacted> Subject: Re: [PATCH v3 2/2] OMAP: IOMMU: add support to callback during fault handling Date: Mon, 21 Feb 2011 11:07:01 +0200
On Mon, Feb 21, 2011 at 10:18 AM, Hiroshi DOYU [off-list ref] wrote:quoted
From: David Cohen <redacted> Subject: [PATCH v3 2/2] OMAP: IOMMU: add support to callback during fault handling Date: Wed, 16 Feb 2011 21:35:51 +0200quoted
Add support to register an isr for IOMMU fault situations and adapt it to allow such (*isr)() to be used as fault callback. Drivers using IOMMU module might want to be informed when errors happen in order to debug it or react. Signed-off-by: David Cohen <redacted> --- ?arch/arm/mach-omap2/iommu2.c ? ? ? ? ? ?| ? 17 +++++++++- ?arch/arm/plat-omap/include/plat/iommu.h | ? 14 ++++++++- ?arch/arm/plat-omap/iommu.c ? ? ? ? ? ? ?| ? 52 ++++++++++++++++++++++--------- ?3 files changed, 65 insertions(+), 18 deletions(-)diff --git a/arch/arm/mach-omap2/iommu2.c b/arch/arm/mach-omap2/iommu2.c index 49a1e5e..adb083e 100644 --- a/arch/arm/mach-omap2/iommu2.c +++ b/arch/arm/mach-omap2/iommu2.c@@ -146,18 +146,31 @@ static void omap2_iommu_set_twl(struct iommu *obj, bool on)?static u32 omap2_iommu_fault_isr(struct iommu *obj, u32 *ra) ?{ ? ? ? u32 stat, da; + ? ? u32 errs = 0; ? ? ? stat = iommu_read_reg(obj, MMU_IRQSTATUS); ? ? ? stat &= MMU_IRQ_MASK; - ? ? if (!stat) + ? ? if (!stat) { + ? ? ? ? ? ? *ra = 0; ? ? ? ? ? ? ? return 0; + ? ? } ? ? ? da = iommu_read_reg(obj, MMU_FAULT_AD); ? ? ? *ra = da; + ? ? if (stat & MMU_IRQ_TLBMISS) + ? ? ? ? ? ? errs |= OMAP_IOMMU_ERR_TLB_MISS; + ? ? if (stat & MMU_IRQ_TRANSLATIONFAULT) + ? ? ? ? ? ? errs |= OMAP_IOMMU_ERR_TRANS_FAULT; + ? ? if (stat & MMU_IRQ_EMUMISS) + ? ? ? ? ? ? errs |= OMAP_IOMMU_ERR_EMU_MISS; + ? ? if (stat & MMU_IRQ_TABLEWALKFAULT) + ? ? ? ? ? ? errs |= OMAP_IOMMU_ERR_TBLWALK_FAULT; + ? ? if (stat & MMU_IRQ_MULTIHITFAULT) + ? ? ? ? ? ? errs |= OMAP_IOMMU_ERR_MULTIHIT_FAULT; ? ? ? iommu_write_reg(obj, stat, MMU_IRQSTATUS); - ? ? return stat; + ? ? return errs; ?} ?static void omap2_tlb_read_cr(struct iommu *obj, struct cr_regs *cr)diff --git a/arch/arm/plat-omap/include/plat/iommu.h b/arch/arm/plat-omap/include/plat/iommu.h index 19cbb5e..174f1b9 100644 --- a/arch/arm/plat-omap/include/plat/iommu.h +++ b/arch/arm/plat-omap/include/plat/iommu.h@@ -31,6 +31,7 @@ struct iommu {? ? ? struct clk ? ? ?*clk; ? ? ? void __iomem ? ?*regbase; ? ? ? struct device ? *dev; + ? ? void ? ? ? ? ? ?*isr_priv;Ideally I'd like to avoid having "isr_priv" in iommu since it's not used for iommu but client needs the place to pass its info to its custom handler. Any better idea?(*isr)() relies in the same situation, as it belongs to the client. Without this priv_data, it's necessary to create a global variable to store client's private data on client side. IMO, it is worse.
Ok, I see. Let's go with this. Thanks.