From 462e0614ac9f1504c8821b98bde0c7a0b80079a0 Mon Sep 17 00:00:00 2001 From: Sunyoung Kang Date: Thu, 6 Dec 2018 15:03:11 +0900 Subject: [PATCH] [RAMEN9610-10029][COMMON] media: mfc: use smc call for MMCache flush The MFC driver can flush only normal data. But the secure OS can flush the all normal and secure data in the MMCache. This changes to use smc call to flush MMCache. Change-Id: I92f6905d83e6a48b780b6eac8a42387daf17b01b Signed-off-by: Sunyoung Kang --- drivers/media/platform/exynos/mfc/mfc.c | 9 +++++ .../media/platform/exynos/mfc/mfc_mmcache.c | 38 ++++--------------- .../media/platform/exynos/mfc/mfc_mmcache.h | 2 + 3 files changed, 19 insertions(+), 30 deletions(-) diff --git a/drivers/media/platform/exynos/mfc/mfc.c b/drivers/media/platform/exynos/mfc/mfc.c index acf17a55c57f..adab73d812c0 100644 --- a/drivers/media/platform/exynos/mfc/mfc.c +++ b/drivers/media/platform/exynos/mfc/mfc.c @@ -1587,6 +1587,12 @@ static int mfc_suspend(struct device *device) } ret = mfc_run_sleep(dev); + + if (dev->has_mmcache && dev->mmcache.is_on_status) { + mfc_invalidate_mmcache(dev); + mfc_mmcache_disable(dev); + } + mfc_release_hwlock_dev(dev); return ret; @@ -1614,6 +1620,9 @@ static int mfc_resume(struct device *device) return -EBUSY; } + if (dev->has_mmcache && (dev->mmcache.is_on_status == 0)) + mfc_mmcache_enable(dev); + ret = mfc_run_wakeup(dev); mfc_release_hwlock_dev(dev); diff --git a/drivers/media/platform/exynos/mfc/mfc_mmcache.c b/drivers/media/platform/exynos/mfc/mfc_mmcache.c index 624478d11a45..d3fa09e5db1b 100644 --- a/drivers/media/platform/exynos/mfc/mfc_mmcache.c +++ b/drivers/media/platform/exynos/mfc/mfc_mmcache.c @@ -10,6 +10,8 @@ * (at your option) any later version. */ +#include + #include "mfc_mmcache.h" #include "mfc_reg_api.h" @@ -190,39 +192,15 @@ void mfc_mmcache_disable(struct mfc_dev *dev) void mfc_invalidate_mmcache(struct mfc_dev *dev) { - void __iomem *addr; - unsigned int data; - unsigned long timeout; + int ret; mfc_debug_enter(); - addr = dev->mmcache.base + MMCACHE_INVALIDATE; - data = MMCACHE_INVALIDATE_VALUE; - - mfc_debug(2, "[MMCACHE] before write 0x%X: (0x%08llX) 0x%X\n", - data, (unsigned long long)(addr), - MMCACHE_READL(MMCACHE_INVALIDATE)); - - MMCACHE_WRITEL(data, MMCACHE_INVALIDATE); - - mfc_debug(2, "[MMCACHE] after write 0x%X: (0x%08llX) 0x%X\n", - data, (unsigned long long)(addr), - MMCACHE_READL(MMCACHE_INVALIDATE)); - - addr = dev->mmcache.base + MMCACHE_INVALIDATE_STATUS; - - timeout = jiffies + msecs_to_jiffies(MMCACHE_INVAL_TIMEOUT); - while (1) { - if (MMCACHE_READL(MMCACHE_INVALIDATE_STATUS) == 0) { - mfc_debug(2, "[MMCACHE] invalidate done: (0x%08llX) 0x%X\n", - (unsigned long long)(addr), __raw_readl(addr)); - break; - } - if (time_after(jiffies, timeout)) { - mfc_err_dev("[MMCACHE] Timeout while invalidation\n"); - call_dop(dev, dump_and_stop_debug_mode, dev); - break; - } + /* The secure OS can flush all normal and secure data */ + ret = exynos_smc(SMC_CMD_MM_CACHE_OPERATION, MMCACHE_GROUP2, 0x0, 0x0); + if (ret != DRMDRV_OK) { + mfc_err_dev("[MMCACHE] Fail to invalidation %x\n", ret); + call_dop(dev, dump_and_stop_debug_mode, dev); } mfc_debug(2, "[MMCACHE] invalidated\n"); diff --git a/drivers/media/platform/exynos/mfc/mfc_mmcache.h b/drivers/media/platform/exynos/mfc/mfc_mmcache.h index bcfa770e835e..61f6b427a5e9 100644 --- a/drivers/media/platform/exynos/mfc/mfc_mmcache.h +++ b/drivers/media/platform/exynos/mfc/mfc_mmcache.h @@ -27,6 +27,8 @@ #define MMCACHE_CG_CONTROL_VALUE 0x7FF #define MMCACHE_INVALIDATE_VALUE 0x41 +#define MMCACHE_GROUP2 0x2 + /* Need HW lock to call this function */ void mfc_mmcache_enable(struct mfc_dev *dev); -- 2.20.1