Re: [PATCH v3 8/9] mailbox: mediatek: Add CMDQ secure mailbox driver

From: CK Hu (胡俊光)
Date: Tue Dec 26 2023 - 01:46:22 EST


Hi, Jason:

On Fri, 2023-12-22 at 12:52 +0800, Jason-JH.Lin wrote:
> To support secure video path feature, GCE have to read/write
> registgers
> in the secure world. GCE will enable the secure access permission to
> the
> HW who wants to access the secure content buffer.
>
> Add CMDQ secure mailbox driver to make CMDQ client user is able to
> sending their HW settings to the secure world. So that GCE can
> execute
> all instructions to configure HW in the secure world.
>
> Signed-off-by: Jason-JH.Lin <jason-jh.lin@xxxxxxxxxxxx>
> ---

[snip]

> +
> +static int cmdq_sec_session_init(struct cmdq_sec_context *context)
> +{
> + int err = 0;
> +
> + if (context->state >= IWC_SES_OPENED) {
> + pr_debug("session opened:%u", context->state);
> + return 0;
> + }
> +
> + switch (context->state) {
> + case IWC_INIT:
> + err = cmdq_sec_init_context(&context->tee_ctx);
> + if (err)
> + return err;
> + context->state = IWC_CONTEXT_INITED;
> + fallthrough;
> + case IWC_CONTEXT_INITED:
> + if (context->iwc_msg) {
> + pr_err("iwcMessage not NULL:%p", context-
> >iwc_msg);
> + return -EINVAL;
> + }
> +
> + err = cmdq_sec_allocate_wsm(&context->tee_ctx,
> &context->iwc_msg,
> + sizeof(struct
> iwc_cmdq_message_t));
> + if (err)
> + return err;
> +
> + context->state = IWC_WSM_ALLOCATED;
> + fallthrough;

Squash cmdq_sec_session_init() into cmdq_sec_mbox_of_xlate() and drop
the context->state.

Regards,
CK

> + case IWC_WSM_ALLOCATED:
> + err = cmdq_sec_open_session(&context->tee_ctx, context-
> >iwc_msg);
> + if (err)
> + return err;
> +
> + context->state = IWC_SES_OPENED;
> + fallthrough;
> + default:
> + break;
> + }
> +
> + return 0;
> +}
> +