[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID:
<DU2PR04MB8599D0CC5EFE125D4B29AA9895A8A@DU2PR04MB8599.eurprd04.prod.outlook.com>
Date: Thu, 18 Dec 2025 09:45:45 +0000
From: Pankaj Gupta <pankaj.gupta@....com>
To: Jonathan Corbet <corbet@....net>, Rob Herring <robh@...nel.org>, Krzysztof
Kozlowski <krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>, Shawn Guo
<shawnguo@...nel.org>, Sascha Hauer <s.hauer@...gutronix.de>, Pengutronix
Kernel Team <kernel@...gutronix.de>, Fabio Estevam <festevam@...il.com>
CC: "linux-doc@...r.kernel.org" <linux-doc@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
"imx@...ts.linux.dev" <imx@...ts.linux.dev>,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>, Frank Li <frank.li@....com>
Subject: RE: [PATCH v22 5/7] firmware: drivers: imx: adds miscdev
> +static int se_ioctl_cmd_snd_rcv_rsp_handler(struct se_if_device_ctx
> *dev_ctx,
> + u64 arg)
> +{
> + struct se_ioctl_cmd_snd_rcv_rsp_info cmd_snd_rcv_rsp_info = {0};
> + struct se_if_priv *priv = dev_ctx->priv;
> + int err = 0;
> +
> + if (copy_from_user(&cmd_snd_rcv_rsp_info, (u8 __user *)arg,
> + sizeof(cmd_snd_rcv_rsp_info))) {
> + dev_err(priv->dev,
> + "%s: Failed to copy cmd_snd_rcv_rsp_info from user.",
> + dev_ctx->devname);
> + err = -EFAULT;
> + goto exit;
> + }
> +
> + if (cmd_snd_rcv_rsp_info.tx_buf_sz < SE_MU_HDR_SZ) {
> + dev_err(priv->dev, "%s: User buffer too small(%d < %d)",
> + dev_ctx->devname, cmd_snd_rcv_rsp_info.tx_buf_sz,
> SE_MU_HDR_SZ);
> + err = -ENOSPC;
> + goto exit;
> + }
> +
> + err = se_chk_tx_msg_hdr(priv, (struct se_msg_hdr
> *)cmd_snd_rcv_rsp_info.tx_buf);
> + if (err)
> + goto exit;
> +
> + struct se_api_msg *rx_msg __free(kfree) =
> + kzalloc(cmd_snd_rcv_rsp_info.rx_buf_sz, GFP_KERNEL);
> + if (!rx_msg) {
> + err = -ENOMEM;
> + goto exit;
> + }
> +
> + struct se_api_msg *tx_msg __free(kfree) =
> + memdup_user(cmd_snd_rcv_rsp_info.tx_buf,
> + cmd_snd_rcv_rsp_info.tx_buf_sz);
> + if (IS_ERR(tx_msg)) {
> + err = PTR_ERR(tx_msg);
> + goto exit;
> + }
> +
> + if (tx_msg->header.tag != priv->if_defs->cmd_tag) {
> + err = -EINVAL;
> + goto exit;
> + }
> +
> + if (tx_msg->header.ver == priv->if_defs->fw_api_ver &&
> + get_load_fw_instance(priv)->is_fw_tobe_loaded) {
> + err = se_load_firmware(priv);
> + if (err) {
> + dev_err(priv->dev, "Could not send msg as FW is not
> loaded.");
> + err = -EPERM;
> + goto exit;
> + }
> + }
> + set_se_rcv_msg_timeout(priv, SE_RCV_MSG_LONG_TIMEOUT);
> +
> + err = ele_msg_send_rcv(dev_ctx, tx_msg,
> cmd_snd_rcv_rsp_info.tx_buf_sz,
> + rx_msg, cmd_snd_rcv_rsp_info.rx_buf_sz);
> + if (err < 0)
> + goto exit;
> +
> + dev_dbg(priv->dev, "%s: %s %s.", dev_ctx->devname, __func__,
> + "message received, start transmit to user");
> +
> + /* We may need to copy the output data to user before
> + * delivering the completion message.
> + */
> + err = se_dev_ctx_cpy_out_data(dev_ctx);
> + if (err < 0)
> + goto exit;
> +
> + /* Copy data from the buffer */
> + print_hex_dump_debug("to user ", DUMP_PREFIX_OFFSET, 4, 4,
> rx_msg,
> + cmd_snd_rcv_rsp_info.rx_buf_sz, false);
> +
> + if (copy_to_user(cmd_snd_rcv_rsp_info.rx_buf, rx_msg,
> + cmd_snd_rcv_rsp_info.rx_buf_sz)) {
> + dev_err(priv->dev, "%s: Failed to copy to user.", dev_ctx-
> >devname);
> + err = -EFAULT;
> + }
> +
> +exit:
> +
> + /* shared memory is allocated before this IOCTL */
> + se_dev_ctx_shared_mem_cleanup(dev_ctx);
> +
> + if (copy_to_user((void __user *)arg, &cmd_snd_rcv_rsp_info,
> + sizeof(cmd_snd_rcv_rsp_info))) {
> + dev_err(priv->dev, "%s: Failed to copy cmd_snd_rcv_rsp_info
> from user.",
> + dev_ctx->devname);
> + err = -EFAULT;
> + }
> +
> + kfree(tx_msg);
> + kfree(rx_msg);
This needs to be removed.
Will fix this in v23.
> + return err;
> +}
Powered by blists - more mailing lists