[PATCH v21 5/7] firmware: drivers: imx: adds miscdev

Pankaj Gupta pankaj.gupta at nxp.com
Wed Dec 17 00:40:03 PST 2025


> > Adds the driver for communication interface to secure-enclave, that
> > enables exchanging messages with NXP secure enclave HW IP(s) like
> > EdgeLock Enclave, from:
> > - User-Space Applications via character driver.
> >
> > ABI documentation for the NXP secure-enclave driver.
> >
> > User-space library using this driver:
> > - i.MX Secure Enclave library:
> >   -- URL: https://github.com/nxp-imx/imx-secure-enclave.git,
> > - i.MX Secure Middle-Ware:
> >   -- URL: https://github.com/nxp-imx/imx-smw.git
> >
> > Following checks are performed on the incoming msg-header, to block
> > exchanging invalid arbitrary commands:
> > - maximum allowed words,
> > - check if command-tag & response-tag are valid
> > - version,
> > - command id validation check, to allow limited base-line API(s)
> >   and restrict following:
> >   - exchanging power management commands.
> >   - reset requests.
> >   - BBSM configuration requests.
> >   - re-initializing the FW.
> >   - RNG init
> >   - CAAM resource release management
> >   - SE's internal memory management.
> > from user-space.
> >
> > Signed-off-by: Pankaj Gupta <pankaj.gupta at nxp.com>
> > Reviewed-by: Frank Li <Frank.Li at nxp.com>
> > ---
> > changes from v20 to v21
> > - removed "__free(kfree)" & added kfree();
> 
> KK's means is that correctly use __free according to cleanup.h.
> 
> fun()
> {
> 	...
> 	some code logic
> 	...
> 
> 	struct .... __free(kfree) rx_msg =
> kzalloc(cmd_snd_rcv_rsp_info.rx_buf_sz, GFP_KERNEL);
> 	...
> }
> 
> Frank

Hi Krzysztof, Hi Frank,

Thank you for the review comments.

I misunderstood earlier and removed __free(kfree) in v21, thinking it was not preferred.
After revisiting your feedback, I see the intent is to use __free(kfree) correctly as per cleanup.h guidelines for automatic cleanup instead of manual kfree() calls.

I will revert the previous change and update the patch to follow the recommended pattern:
-  strucivt se_api_msg *tx_msg __free(kfree) = kzalloc (XXXXX, GFP_KERNEL);
-  Make sure the source files has: #include <linux/cleanup.h>

This will be included in v22 along with a clear comment disposition referencing your suggestion.
Thanks for clarifying and for your guidance.

Best regards,
Pankaj Gupta



More information about the linux-arm-kernel mailing list