[RAMEN9610-10029][COMMON] media: mfc: use smc call for MMCache flush
authorSunyoung Kang <sy0816.kang@samsung.com>
Thu, 6 Dec 2018 06:03:11 +0000 (15:03 +0900)
committerhskang <hs1218.kang@samsung.com>
Fri, 28 Dec 2018 09:54:37 +0000 (18:54 +0900)
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 <sy0816.kang@samsung.com>
drivers/media/platform/exynos/mfc/mfc.c
drivers/media/platform/exynos/mfc/mfc_mmcache.c
drivers/media/platform/exynos/mfc/mfc_mmcache.h

index acf17a55c57f7adfd4ee230e31696f58ce4b0aa2..adab73d812c0896f4cd34874b699af0b35e744c3 100644 (file)
@@ -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);
 
index 624478d11a45acbed35602ee54878c62d51abf8f..d3fa09e5db1be979365acd18171481ce523c754b 100644 (file)
@@ -10,6 +10,8 @@
  * (at your option) any later version.
  */
 
+#include <linux/smc.h>
+
 #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");
index bcfa770e835e568972dfb5871a4296b42d90e973..61f6b427a5e95daaf711f3a05e8cc660cb3a20be 100644 (file)
@@ -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);