[PATCH v2 3/5] misc: fastrpc: Add CRC support using invokeV2 request
Dmitry Baryshkov
dmitry.baryshkov at linaro.org
Wed Jan 29 10:41:51 UTC 2025
On Mon, Jan 27, 2025 at 10:12:37AM +0530, Ekansh Gupta wrote:
> InvokeV2 request is intended to support multiple enhanced invoke
> requests like CRC check, performance counter enablement and polling
> mode for RPC invocations. CRC check is getting enabled as part of
> this patch. CRC check for input and output argument helps in ensuring
> data consistency over a remote call. If user intends to enable CRC
> check, first local user CRC is calculated at user end and a CRC buffer
> is passed to DSP to capture remote CRC values. DSP is expected to
> write to the remote CRC buffer which is then compared at user level
> with the local CRC values.
>
> Signed-off-by: Ekansh Gupta <quic_ekangupt at quicinc.com>
> ---
> drivers/misc/fastrpc.c | 78 ++++++++++++++++++++++++++++++-------
> include/uapi/misc/fastrpc.h | 7 ++++
> 2 files changed, 70 insertions(+), 15 deletions(-)
>
> +
> +static int fastrpc_invokev2(struct fastrpc_user *fl, char __user *argp)
> +{
> + struct fastrpc_ctx_args *cargs;
> + struct fastrpc_invoke_v2 inv2;
> + int i, err;
> +
> + if (copy_from_user(&inv2, argp, sizeof(inv2)))
> + return -EFAULT;
> +
> + /* Check if all reserved fields are zero */
> + for (i = 0; i < 16; i++) {
Noticed this while reviewing next patch. No. Nak. Never. Who makes sure
that this magic 16 is the same as the actual size of an array? Please
always use ARRAY_SIZE in such cases.
> + if (inv2.reserved[i] != 0)
> + return -EINVAL;
> }
>
> - cargs->args = args;
> - err = fastrpc_internal_invoke(fl, false, inv.handle, inv.sc, cargs);
> - kfree(args);
> + cargs = kzalloc(sizeof(*cargs), GFP_KERNEL);
> + if (!cargs)
> + return -ENOMEM;
> +
> + cargs->crc = (void __user *)(uintptr_t)inv2.crc;
> +
> + err = fastrpc_remote_invoke(fl, &inv2.inv, cargs);
> kfree(cargs);
>
> return err;
--
With best wishes
Dmitry
More information about the dri-devel
mailing list