This adds memset '0' to the firmware memory except fw code region.
And also this change to do not use the memory clear by ION allocator
because the firmware performs the memory clear. Since the firmware can not
clear the stack area by itself, it is only cleared by the driver.
Change-Id: Ifea58165d562280b5459c39852f21f34501c4370
Signed-off-by: Sunyoung Kang <sy0816.kang@samsung.com>
return -EINVAL;
}
+ /* This adds to clear with '0' for firmware memory except code region. */
+ mfc_debug(4, "[F/W] memset before memcpy for normal fw\n");
+ memset((dev->fw_buf.vaddr + fw_blob->size), 0, (firmware_size - fw_blob->size));
memcpy(dev->fw_buf.vaddr, fw_blob->data, fw_blob->size);
if (dev->drm_fw_buf.vaddr) {
+ mfc_debug(4, "[F/W] memset before memcpy for secure fw\n");
+ memset((dev->drm_fw_buf.vaddr + fw_blob->size), 0, (firmware_size - fw_blob->size));
memcpy(dev->drm_fw_buf.vaddr, fw_blob->data, fw_blob->size);
mfc_debug(4, "[F/W] copy firmware to secure region\n");
}
MFC_WRITEL(reg, MFC_REG_CODEC_CONTROL);
mfc_debug(2, "Requested codec mode: %d\n", ctx->codec_mode);
- MFC_WRITEL(ctx->codec_mode, MFC_REG_CODEC_TYPE);
+ reg = ctx->codec_mode & MFC_REG_CODEC_TYPE_MASK;
+ reg |= (0x1 << MFC_REG_CLEAR_CTX_MEM_SHIFT);
+ mfc_debug(2, "Enable to clear context memory: %#x\n", reg);
+ MFC_WRITEL(reg, MFC_REG_CODEC_TYPE);
+
MFC_WRITEL(ctx->instance_ctx_buf.daddr, MFC_REG_CONTEXT_MEM_ADDR);
MFC_WRITEL(ctx->instance_ctx_buf.size, MFC_REG_CONTEXT_MEM_SIZE);
if (ctx->type == MFCINST_DECODER)
struct mfc_special_buf *special_buf)
{
struct mfc_ctx *ctx = dev->ctx[dev->curr_ctx];
- int flag;
+ int flag = ION_FLAG_NOZEROED;
const char *heapname;
switch (special_buf->buftype) {
case MFCBUF_NORMAL:
heapname = "ion_system_heap";
- flag = 0;
break;
case MFCBUF_NORMAL_FW:
heapname = "vnfw_heap";
- flag = 0;
break;
case MFCBUF_DRM:
heapname = "vframe_heap";
- flag = ION_FLAG_PROTECTED;
+ flag |= ION_FLAG_PROTECTED;
break;
case MFCBUF_DRM_FW:
heapname = "vfw_heap";
- flag = ION_FLAG_PROTECTED;
+ flag |= ION_FLAG_PROTECTED;
break;
default:
heapname = "unknown";
#define MFC_REG_CODEC_BPG_DEC 32
#define MFC_REG_CODEC_BPG_ENC 33
+/* 0xF00C: MFC_REG_CODEC_TYPE */
+#define MFC_REG_CLEAR_CTX_MEM_SHIFT 16
+#define MFC_REG_CODEC_TYPE_MASK 0xFFFF
+
/* 0xF028: MFC_REG_MFC_VERSION */
#define MFC_REG_MFC_VER_MASK 0xFFFFFFFF
#define MFC_REG_MFC_VER_SHFT 0