Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@nxp.com>
To: Pankaj Gupta <pankaj.gupta@nxp.com>
Cc: Jonathan Corbet <corbet@lwn.net>, Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Shawn Guo <shawnguo@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org, imx@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v14 5/6] firmware: imx: device context dedicated to priv
Date: Wed, 26 Mar 2025 11:34:41 -0400	[thread overview]
Message-ID: <Z+QekQVacwA4YEix@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20250327-imx-se-if-v14-5-2219448932e4@nxp.com>

On Thu, Mar 27, 2025 at 12:08:01AM +0530, Pankaj Gupta wrote:
> Add priv_dev_ctx to prepare enabling misc-device context
> based send-receive path, to communicate with FW.
>
> No functionality change.
>
> Signed-off-by: Pankaj Gupta <pankaj.gupta@nxp.com>
> ---

Reviewed-by: Frank Li <Frank.Li@nxp.com>

>  drivers/firmware/imx/ele_base_msg.c | 10 +++++-----
>  drivers/firmware/imx/ele_common.c   |  3 ++-
>  drivers/firmware/imx/ele_common.h   |  2 +-
>  drivers/firmware/imx/se_ctrl.c      | 31 +++++++++++++++++++++++++++++++
>  drivers/firmware/imx/se_ctrl.h      |  8 ++++++++
>  5 files changed, 47 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/firmware/imx/ele_base_msg.c b/drivers/firmware/imx/ele_base_msg.c
> index 3839c93f8212..c07c21f1fbbd 100644
> --- a/drivers/firmware/imx/ele_base_msg.c
> +++ b/drivers/firmware/imx/ele_base_msg.c
> @@ -62,7 +62,7 @@ int ele_get_info(struct se_if_priv *priv, struct ele_dev_info *s_info)
>  	tx_msg->data[0] = upper_32_bits(get_info_addr);
>  	tx_msg->data[1] = lower_32_bits(get_info_addr);
>  	tx_msg->data[2] = sizeof(*s_info);
> -	ret = ele_msg_send_rcv(priv,
> +	ret = ele_msg_send_rcv(priv->priv_dev_ctx,
>  			       tx_msg,
>  			       ELE_GET_INFO_REQ_MSG_SZ,
>  			       rx_msg,
> @@ -122,7 +122,7 @@ int ele_ping(struct se_if_priv *priv)
>  		return ret;
>  	}
>
> -	ret = ele_msg_send_rcv(priv,
> +	ret = ele_msg_send_rcv(priv->priv_dev_ctx,
>  			       tx_msg,
>  			       ELE_PING_REQ_SZ,
>  			       rx_msg,
> @@ -174,7 +174,7 @@ int ele_service_swap(struct se_if_priv *priv,
>  	if (!tx_msg->data[4])
>  		return -EINVAL;
>
> -	ret = ele_msg_send_rcv(priv,
> +	ret = ele_msg_send_rcv(priv->priv_dev_ctx,
>  			       tx_msg,
>  			       ELE_SERVICE_SWAP_REQ_MSG_SZ,
>  			       rx_msg,
> @@ -227,7 +227,7 @@ int ele_fw_authenticate(struct se_if_priv *priv, phys_addr_t addr)
>  	tx_msg->data[0] = lower_32_bits(addr);
>  	tx_msg->data[2] = addr;
>
> -	ret = ele_msg_send_rcv(priv,
> +	ret = ele_msg_send_rcv(priv->priv_dev_ctx,
>  			       tx_msg,
>  			       ELE_FW_AUTH_REQ_SZ,
>  			       rx_msg,
> @@ -275,7 +275,7 @@ int ele_debug_dump(struct se_if_priv *priv)
>  	do {
>  		memset(rx_msg, 0x0, ELE_DEBUG_DUMP_RSP_SZ);
>
> -		ret = ele_msg_send_rcv(priv,
> +		ret = ele_msg_send_rcv(priv->priv_dev_ctx,
>  				       tx_msg,
>  				       ELE_DEBUG_DUMP_REQ_SZ,
>  				       rx_msg,
> diff --git a/drivers/firmware/imx/ele_common.c b/drivers/firmware/imx/ele_common.c
> index be4dabeeb64c..f75a8237e353 100644
> --- a/drivers/firmware/imx/ele_common.c
> +++ b/drivers/firmware/imx/ele_common.c
> @@ -89,12 +89,13 @@ int ele_msg_send(struct se_if_priv *priv,
>  }
>
>  /* API used for send/receive blocking call. */
> -int ele_msg_send_rcv(struct se_if_priv *priv,
> +int ele_msg_send_rcv(struct se_if_device_ctx *dev_ctx,
>  		     void *tx_msg,
>  		     int tx_msg_sz,
>  		     void *rx_msg,
>  		     int exp_rx_msg_sz)
>  {
> +	struct se_if_priv *priv = dev_ctx->priv;
>  	int err;
>
>  	guard(mutex)(&priv->se_if_cmd_lock);
> diff --git a/drivers/firmware/imx/ele_common.h b/drivers/firmware/imx/ele_common.h
> index c95e45123b5b..a6bf93f0048f 100644
> --- a/drivers/firmware/imx/ele_common.h
> +++ b/drivers/firmware/imx/ele_common.h
> @@ -18,7 +18,7 @@ int ele_msg_rcv(struct se_if_priv *priv,
>  int ele_msg_send(struct se_if_priv *priv,
>  		 void *tx_msg,
>  		 int tx_msg_sz);
> -int ele_msg_send_rcv(struct se_if_priv *priv,
> +int ele_msg_send_rcv(struct se_if_device_ctx *dev_ctx,
>  		     void *tx_msg,
>  		     int tx_msg_sz,
>  		     void *rx_msg,
> diff --git a/drivers/firmware/imx/se_ctrl.c b/drivers/firmware/imx/se_ctrl.c
> index be381980fec0..144a727bbfe0 100644
> --- a/drivers/firmware/imx/se_ctrl.c
> +++ b/drivers/firmware/imx/se_ctrl.c
> @@ -191,6 +191,31 @@ static int get_se_soc_info(struct se_if_priv *priv, const struct se_soc_info *se
>  	return 0;
>  }
>
> +static int init_misc_device_context(struct se_if_priv *priv, int ch_id,
> +				    struct se_if_device_ctx **new_dev_ctx)
> +{
> +	struct se_if_device_ctx *dev_ctx;
> +	int ret = 0;
> +
> +	dev_ctx = devm_kzalloc(priv->dev, sizeof(*dev_ctx), GFP_KERNEL);
> +
> +	if (!dev_ctx)
> +		return -ENOMEM;
> +
> +	dev_ctx->priv = priv;
> +
> +	dev_ctx->devname = devm_kasprintf(priv->dev, GFP_KERNEL, "%s%d_ch%d",
> +					  SE_TYPE_STR_HSM,
> +					  priv->if_defs->se_instance_id,
> +					  ch_id);
> +	if (!dev_ctx->devname)
> +		return -ENOMEM;
> +
> +	*new_dev_ctx = dev_ctx;
> +
> +	return ret;
> +}
> +
>  /* interface for managed res to free a mailbox channel */
>  static void if_mbox_free_channel(void *mbox_chan)
>  {
> @@ -317,6 +342,12 @@ static int se_if_probe(struct platform_device *pdev)
>  					    "Failed to init reserved memory region.");
>  	}
>
> +	ret = init_misc_device_context(priv, 0, &priv->priv_dev_ctx);
> +	if (ret)
> +		return dev_err_probe(dev, ret,
> +				     "Failed[0x%x] to create device contexts.",
> +				     ret);
> +
>  	if (if_node->if_defs.se_if_type == SE_TYPE_ID_HSM) {
>  		ret = get_se_soc_info(priv, se_info);
>  		if (ret)
> diff --git a/drivers/firmware/imx/se_ctrl.h b/drivers/firmware/imx/se_ctrl.h
> index 177623f3890e..f0893c5c9145 100644
> --- a/drivers/firmware/imx/se_ctrl.h
> +++ b/drivers/firmware/imx/se_ctrl.h
> @@ -35,6 +35,12 @@ struct se_imem_buf {
>  	u32 state;
>  };
>
> +/* Private struct for each char device instance. */
> +struct se_if_device_ctx {
> +	struct se_if_priv *priv;
> +	const char *devname;
> +};
> +
>  /* Header of the messages exchange with the EdgeLock Enclave */
>  struct se_msg_hdr {
>  	u8 ver;
> @@ -79,6 +85,8 @@ struct se_if_priv {
>
>  	struct gen_pool *mem_pool;
>  	const struct se_if_defines *if_defs;
> +
> +	struct se_if_device_ctx *priv_dev_ctx;
>  };
>
>  #endif
>
> --
> 2.43.0
>


  reply	other threads:[~2025-03-26 16:02 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-26 18:37 [PATCH v14 0/6] v14: firmware: imx: driver for NXP secure-enclave Pankaj Gupta
2025-03-26 15:04 ` Frank Li
2025-03-26 18:37 ` [PATCH v14 1/6] Documentation/firmware: add imx/se to other_interfaces Pankaj Gupta
2025-03-26 18:37 ` [PATCH v14 2/6] dt-bindings: arm: fsl: add imx-se-fw binding doc Pankaj Gupta
2025-03-26 18:37 ` [PATCH v14 3/6] arm64: dts: imx8ulp-evk: add nxp secure enclave firmware Pankaj Gupta
2025-03-26 15:03   ` Frank Li
2025-03-26 18:38 ` [PATCH v14 4/6] firmware: imx: add driver for NXP EdgeLock Enclave Pankaj Gupta
2025-03-26 15:33   ` Frank Li
2025-04-01 11:51     ` Pankaj Gupta
     [not found]     ` <AM9PR04MB86040127423D0A657103589D95AC2@AM9PR04MB8604.eurprd04.prod.outlook.com>
2025-04-02  6:14       ` Pankaj Gupta
     [not found]     ` <AM9PR04MB86048345C11F8878146AFE9A95AC2@AM9PR04MB8604.eurprd04.prod.outlook.com>
2025-04-02  6:15       ` Pankaj Gupta
     [not found]     ` <AM9PR04MB8604C02C27C8C43FF89B95DC95AC2@AM9PR04MB8604.eurprd04.prod.outlook.com>
2025-04-02  6:15       ` Pankaj Gupta
2025-04-02 21:20         ` Frank Li
2025-04-03  5:02           ` Pankaj Gupta
2025-04-04 16:50             ` Frank Li
2025-03-26 18:38 ` [PATCH v14 5/6] firmware: imx: device context dedicated to priv Pankaj Gupta
2025-03-26 15:34   ` Frank Li [this message]
2025-03-26 18:38 ` [PATCH v14 6/6] firmware: drivers: imx: adds miscdev Pankaj Gupta
2025-03-26 16:00   ` Frank Li
     [not found]     ` <AM9PR04MB8604940F813742ACA6CA307595AC2@AM9PR04MB8604.eurprd04.prod.outlook.com>
2025-04-02  6:19       ` Pankaj Gupta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z+QekQVacwA4YEix@lizhi-Precision-Tower-5810 \
    --to=frank.li@nxp.com \
    --cc=conor+dt@kernel.org \
    --cc=corbet@lwn.net \
    --cc=devicetree@vger.kernel.org \
    --cc=festevam@gmail.com \
    --cc=imx@lists.linux.dev \
    --cc=kernel@pengutronix.de \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pankaj.gupta@nxp.com \
    --cc=robh@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox