[COMMON] media: mfc: fix the QoS calculation
authorJeonghee Kim <jhhhh.kim@samsung.com>
Tue, 19 Jun 2018 12:00:46 +0000 (21:00 +0900)
committerSunyoung Kang <sy0816.kang@samsung.com>
Mon, 23 Jul 2018 06:18:46 +0000 (15:18 +0900)
If too many instances are open,
'total_fps * sw_time' can exceed 1 second and total_mb value can be zero.
When the total_mb is zero,
we can't request a high QoS level in qos_on function
and QoS remove will be called unconditionally in qos_off function.
In order to defend this problem,
It has been modified to use max_mb value if SW time exceeds 1 second.

Change-Id: I833bc27b5c547c8d92c5eddc9f685d26677b179f
Signed-off-by: Jeonghee Kim <jhhhh.kim@samsung.com>
drivers/media/platform/exynos/mfc/s5p_mfc_qos.c

index 5b0cfcf452212c283a1c23199d9d8fb8e15b8df9..8655a4b1742342b9494f30736fdaafed70d5af47 100644 (file)
@@ -518,7 +518,10 @@ void s5p_mfc_qos_on(struct s5p_mfc_ctx *ctx)
                fw_time = qos_table[i].time_fw;
                sw_time = (MFC_DRV_TIME + fw_time);
 
-               total_mb = ((1000000 * hw_mb) / (1000000 - (total_fps * sw_time)));
+               if ((total_fps * sw_time) >= 1000000)
+                       total_mb = pdata->max_mb;
+               else
+                       total_mb = ((1000000 * hw_mb) / (1000000 - (total_fps * sw_time)));
 
                mfc_debug(4, "[QoS] table[%d] fw_time: %dus, hw_mb: %ld, "
                                "sw_time: %d, total_fps: %ld, total_mb: %ld\n",
@@ -598,7 +601,11 @@ void s5p_mfc_qos_off(struct s5p_mfc_ctx *ctx)
                fw_time = qos_table[i].time_fw;
                sw_time = (MFC_DRV_TIME + fw_time);
 
-               total_mb = ((1000000 * hw_mb) / (1000000 - (total_fps * sw_time)));
+               if ((total_fps * sw_time) >= 1000000)
+                       total_mb = pdata->max_mb;
+               else
+                       total_mb = ((1000000 * hw_mb) / (1000000 - (total_fps * sw_time)));
+
                mfc_debug(4, "[QoS] table[%d] fw_time: %dus, hw_mb: %ld, "
                                "sw_time: %d, total_fps: %ld, total_mb: %ld\n",
                                i, fw_time, hw_mb, sw_time, total_fps, total_mb);