From 5a61fdb4c13b8fde7c6806b67989448d4ffd5607 Mon Sep 17 00:00:00 2001 From: Cho KyongHo Date: Fri, 10 Apr 2015 19:12:51 +0900 Subject: [PATCH] [COMMON] media: smfc: add System MMU fault handler Change-Id: Idb1a7cebb4dccb043dc834ceb4daacb5cdd7e983 Signed-off-by: Cho KyongHo --- drivers/media/platform/exynos/smfc/smfc.c | 18 ++++++++++++++++++ drivers/media/platform/exynos/smfc/smfc.h | 3 +++ 2 files changed, 21 insertions(+) diff --git a/drivers/media/platform/exynos/smfc/smfc.c b/drivers/media/platform/exynos/smfc/smfc.c index 579f67336994..b19494f0231c 100644 --- a/drivers/media/platform/exynos/smfc/smfc.c +++ b/drivers/media/platform/exynos/smfc/smfc.c @@ -283,6 +283,8 @@ static irqreturn_t exynos_smfc_irq_handler(int irq, void *priv) u32 streamsize = smfc_get_streamsize(smfc); u32 thumb_streamsize = smfc_get_2nd_streamsize(smfc); + smfc->flags &= ~SMFC_DEV_RUNNING; + if (!smfc_hwstatus_okay(smfc, ctx)) { smfc_dump_registers(smfc); state = VB2_BUF_STATE_ERROR; @@ -1144,6 +1146,8 @@ static void smfc_m2m_device_run(void *priv) smfc_hwconfigure_image(ctx); smfc_configure_secondary_image(ctx); smfc_hwconfigure_start(ctx); + + ctx->smfc->flags |= SMFC_DEV_RUNNING; } static void smfc_m2m_job_abort(void *priv) @@ -1284,6 +1288,18 @@ err_clk: return ret; } +static int __attribute__((unused)) smfc_iommu_fault_handler( + struct iommu_domain *domain, struct device *dev, + unsigned long fault_addr, int fault_flags, void *token) +{ + struct smfc_dev *smfc = token; + + if (smfc->flags & SMFC_DEV_RUNNING) + smfc_dump_registers(smfc); + + return 0; +} + static int exynos_smfc_probe(struct platform_device *pdev) { struct smfc_dev *smfc; @@ -1337,6 +1353,8 @@ static int exynos_smfc_probe(struct platform_device *pdev) if (ret < 0) return ret; + iovmm_set_fault_handler(&pdev->dev, smfc_iommu_fault_handler, smfc); + ret = iovmm_activate(&pdev->dev); if (ret < 0) return ret; diff --git a/drivers/media/platform/exynos/smfc/smfc.h b/drivers/media/platform/exynos/smfc/smfc.h index dbe63674083d..5ff118c78d61 100644 --- a/drivers/media/platform/exynos/smfc/smfc.h +++ b/drivers/media/platform/exynos/smfc/smfc.h @@ -41,6 +41,8 @@ static inline bool is_jpeg(const struct smfc_image_format *fmt) return fmt->bpp_buf[0] == 0; } +#define SMFC_DEV_RUNNING (1 << 0) + struct smfc_dev { struct v4l2_device v4l2_dev; struct video_device *videodev; @@ -50,6 +52,7 @@ struct smfc_dev { struct mutex video_device_mutex; int device_id; u32 hwver; + u32 flags; struct clk *clk_gate; struct clk *clk_gate2; /* available if clk_gate is valid */ -- 2.20.1