From: Jeonghee Kim Date: Tue, 26 Jun 2018 02:23:31 +0000 (+0900) Subject: [COMMON] media: mfc: check low memory device X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=45d5b16a087431de0b75f2fb2cbe9680aaaa5508;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [COMMON] media: mfc: check low memory device Returns error if the total memory is less than 1.5GB and DPB size is too big to pass android.security.cts.StagefrightTest#testBug_37930177 Change-Id: I62f82f73ea49a490317e54faf80adf467474be70 Signed-off-by: Jeonghee Kim --- diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_common.h b/drivers/media/platform/exynos/mfc/s5p_mfc_common.h index ef3d98d7909d..0a919066cb18 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_common.h +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_common.h @@ -185,4 +185,8 @@ #define MFC_FEATURE_SUPPORT(dev, f) ((f).support && ((dev)->fw.date >= (f).version)) +/* Low memory check */ +#define IS_LOW_MEM (totalram_pages <= ((SZ_1G + SZ_512M) >> PAGE_SHIFT)) +#define SZ_600M (6 * 1024 * 1024) + #endif /* __S5P_MFC_COMMON_H */ diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_debugfs.c b/drivers/media/platform/exynos/mfc/s5p_mfc_debugfs.c index 55e17ff0710d..61f80a6bd5c8 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_debugfs.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_debugfs.c @@ -70,6 +70,7 @@ static int mfc_info_show(struct seq_file *s, void *unused) dev->pdata->support_10bit ? "supported" : "not supported", dev->pdata->support_422 ? "supported" : "not supported", dev->pdata->support_rgb ? "supported" : "not supported"); + seq_printf(s, "[LOWMEM] is_low_mem: %d\n", IS_LOW_MEM); if (dev->nal_q_handle) seq_printf(s, "[NAL-Q] state: %d\n", dev->nal_q_handle->nal_q_state); diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_dec.c b/drivers/media/platform/exynos/mfc/s5p_mfc_dec.c index 8ea96d3dc666..a28c70faff01 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_dec.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_dec.c @@ -314,6 +314,25 @@ static int vidioc_g_fmt_vid_cap_mplane(struct file *file, void *priv, rectangle. */ s5p_mfc_dec_calc_dpb_size(ctx); + if (IS_LOW_MEM) { + unsigned int dpb_size; + /* + * If total memory requirement is too big for this device, + * then it returns error. + * DPB size : Total plane size * the number of DPBs + * 5: the number of extra DPBs + * 3: the number of DPBs for Android framework + * 600MB: being used to return an error, + * when 8K resolution video clip is being tried to be decoded + */ + dpb_size = (ctx->raw_buf.total_plane_size * (ctx->dpb_count + 5 + 3)); + if (dpb_size > SZ_600M) { + mfc_info_ctx("required memory size is too big (%dx%d, dpb: %d)\n", + ctx->img_width, ctx->img_height, ctx->dpb_count); + return -EINVAL; + } + } + pix_fmt_mp->width = ctx->img_width; pix_fmt_mp->height = ctx->img_height; pix_fmt_mp->num_planes = ctx->dst_fmt->mem_planes;