From patchwork Wed Mar 26 18:38:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Gupta X-Patchwork-Id: 14030097 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2F7B8C36008 for ; Wed, 26 Mar 2025 13:51:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To: In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type: Subject:Date:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=VbIqE7IC6vIxpIXZJoa7BqK7zTm7yS9o2G8fp5SWkEQ=; b=dYSr3z3+GLd0DIsnHXIWfhcZ2F hj8qvuXPwh3yqcAXarEsX2qjyFLwyh2k06pLAyqRQgWCREgSwA9FL9iIdDwfM4q+rRH2XUYYDO0Yt BPdQ1os3BW3BH1XEdh7enthjB6zcztLYPb9soiHSFNp9uo/TelFVdi8reVnQ2a9srX7gjxL50CdeM ETr8b9xNu9xK/wqEhKiDQRTDSAKyCR1KkiTTlFuJKnjCp8yEzgFeHfWNleqrse+VeMZHyzVn+4Wc6 9ALH45QVT60W19OnR7JLhuM///8cxEQaKz5tMV7Dt/QuI2yciB7MFkdGwYD3szSKnJt+iG8+NQSek oWsPIbeQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.1 #2 (Red Hat Linux)) id 1txRAR-00000008bkf-0ye6; Wed, 26 Mar 2025 13:51:39 +0000 Received: from mail-northeuropeazlp170110001.outbound.protection.outlook.com ([2a01:111:f403:c200::1] helo=DB3PR0202CU003.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98.1 #2 (Red Hat Linux)) id 1txQqI-00000008Zaw-3ZYf for linux-arm-kernel@lists.infradead.org; Wed, 26 Mar 2025 13:30:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JOjtNhOpJxa+fN7Eb/bQftBFurG5niQg57wt2z7ZywlNI88WJOK/BcpajxYDiIxaOYBjWBndOqCMq6wDKoxF2LJ7YBxcSMVFnDtYkgZHmZhH9+10thQVQwWOll+n6hxS2XVULxoYtLOFq99aIlNxKwxcxP4xSGRSI4NGfhp3yIgzzaSnwnXKZBYRCIjzBITVu3xruIMxdRSdZZO8Bgwj1WyBwDIX74GRPd4fhy05CcjRBU94hAvBgrpEkk/Y+fZmMyzmW3iIC0qkIpVmbf8Z8ViZVEcUcBcBHO6u1J9Kivg0gclVpfQS4WsjTZaHBBstUYG1waMCMsACrUiWBqW11A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VbIqE7IC6vIxpIXZJoa7BqK7zTm7yS9o2G8fp5SWkEQ=; b=uUHS4hh3EXnsu86Se/fooArTY1PVePBc7W8IjmUEIpp6CpDLgmyNkAMcd8Wm9XRkFIQyAdNCjZ+OcVYXv5sMMF6k4pidxzFnZbBA1x+0Ox6m+N+S+fy9y5o16TR/DhMmDkbH0F4l/cbmuKlW8mBwAwbm0gTyY9o1uzc2+JcvQIbDyNjb/A8ldTvLir7qOnqFieqeaGDSxdzXFd4wPTB5OYcelzC9R17c6IteLLRRvhDEOHF8hUA+IhJzSfnR6EpoVcJl5oWamJ5XdarVpB1PBZMAiFq6zFEGTaFq5N2bqbCAKuajIUR3twrZupT9g9ElO2tZUY0f4GAEUwdbueMVUg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VbIqE7IC6vIxpIXZJoa7BqK7zTm7yS9o2G8fp5SWkEQ=; b=oAzoAHzKo/LapN8stB0wfFT9Yx+oa6HI1DCu8XY8Vzxio/YB/E8QpP8x97JobhWoQKtI1sAxYpxFuRhjeIVTHwuPRCgWHti+6lBpnr3cfpve/1uiCjbc3mdWc4nVuYZwE1ej9z54BQzUOjn6tKFxLL2VF3Nnr+fEWH/iF8PN/LphzDg5dHtgjWWE0VsiUBGwetdlFwNCZYk2noVJ+3wpYsiY7SbsnKZ3unKeLKAHnfZq/CpZ2qa+MYGQAwxD2DHUDHeI+CikglDSkghO4d2tpzL9GmDVOqh2d3IVKU8g6IAz4M9QjzRBkshE4DtM5bbW1y0zrQ5bgHE2MJ0O9hrAKg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8604.eurprd04.prod.outlook.com (2603:10a6:20b:43b::21) by AM9PR04MB8828.eurprd04.prod.outlook.com (2603:10a6:20b:40b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.44; Wed, 26 Mar 2025 13:15:14 +0000 Received: from AM9PR04MB8604.eurprd04.prod.outlook.com ([fe80::e751:223e:aa3d:5827]) by AM9PR04MB8604.eurprd04.prod.outlook.com ([fe80::e751:223e:aa3d:5827%5]) with mapi id 15.20.8534.043; Wed, 26 Mar 2025 13:15:14 +0000 From: Pankaj Gupta Date: Thu, 27 Mar 2025 00:08:01 +0530 Subject: [PATCH v14 5/6] firmware: imx: device context dedicated to priv Message-Id: <20250327-imx-se-if-v14-5-2219448932e4@nxp.com> References: <20250327-imx-se-if-v14-0-2219448932e4@nxp.com> In-Reply-To: <20250327-imx-se-if-v14-0-2219448932e4@nxp.com> To: Jonathan Corbet , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Pankaj Gupta Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1743014302; l=5512; i=pankaj.gupta@nxp.com; s=20240523; h=from:subject:message-id; bh=x46GPrAXCNE6NZYHZlvm+lLo6wiB7ucFqA87IFILO74=; b=16vpPmMS1/FEMy5Ys1yR/ewphQAVZlL5xZXFxVS9uNhnV0PZBpQACWzJak93nFmP3/XvCTfpk h8Qauacf7wKCqlUix4Ze7QvgKcOFfbvNlBoIbqvo3CTvJAjaevQNmVk X-Developer-Key: i=pankaj.gupta@nxp.com; a=ed25519; pk=OA0pBQoupy5lV0XfKzD8B0OOBVB6tpAoIf+0x1bYGRg= X-ClientProxiedBy: SG2P153CA0047.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c6::16) To AM9PR04MB8604.eurprd04.prod.outlook.com (2603:10a6:20b:43b::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8604:EE_|AM9PR04MB8828:EE_ X-MS-Office365-Filtering-Correlation-Id: d8313c92-722d-4344-b602-08dd6c683e95 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|52116014|1800799024|366016|38350700014; X-Microsoft-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KYIp9up8ulb/UJvd9cXtwOuc9uM4WCueNgqzX6l2IOnmLT/y?= =?utf-8?q?Y2gwoFYkzpoP4APjC9U/RsWt53fpjib+6/FWktSdk6BmpA939USNBpnGuU7+wX0+X?= =?utf-8?q?4jxCGRtzgPGwvZLT0xjk05SsdqSR8al4rDUtUHgjlYA4Ww6obXAHAos6VrIHoxLX7?= =?utf-8?q?Co2HUpVVpsJIA3q99b09owlxTsZGQImQZyIQrRxj/OGcgU3R0lmAzGluYV1bQ3JdD?= =?utf-8?q?zM4KS8DXAe0z7/wylbjJS9nw9Y/y1QGr/QRcO6+FlA2VvMXmDHSFcRi572weie3+6?= =?utf-8?q?ToHquY6Z16cEJUYE3wHS+o0RXE+MBCLDG3hOQwWUIyVb0vxxTKGXvQs192HZSDs+K?= =?utf-8?q?EFJhN0DVig2+fVVc52rv08ZLfniVQsURlwSyk9YjOZ4cH76xXW4AWeae7dILcFcAR?= =?utf-8?q?ZAAtAiJWHDpJ9oBQty2pSpz5vmMBNCUgoVnZ2shan0LvPsSTcUd48b4rAe8V/FepU?= =?utf-8?q?OnMeQlK05llxhPDgEXBnnyD5gW0vhXxCzgiPW15eI/E7VFqtixS9/Ft/P058hN4/m?= =?utf-8?q?ilRkPYVai2x?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8604.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(376014)(52116014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?Un+Jw39QvLcBzQGc8HUmtXZBWilk?= =?utf-8?q?HEfL+ksMv98qcX3dtPgMzjVVR49ShcnCpaDtdTfumC+yBi1dzJoiwDeWTHjeHyLOz?= =?utf-8?q?N6on8mxoao9J6yclypI2ZKDHxzqJe82o/1byqPhYA5M75lScC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Z/G2HkArOPO2z7U1iPv?= =?utf-8?q?XzDttpRVnwB6JjnoELMQgnQCt/7MVl79YGiKM/+MJfhuVEFhGD8+TXG+CJ66wcBlW?= =?utf-8?q?DCMNII3vN6dUBsDLvTImxG/N2ux++M6v0kEVuxQLhTrC/nbk1Dv/ILBuiLKftL36C?= =?utf-8?q?zaEqkbGTx244mmuPY4v4Gt2otJy/hX11n85R3NndKYsfJgTQkol331X3Dv0bqvAoU?= =?utf-8?q?vtMc4qabKm6H4Fq+Z1khudPU9CYK9jokVk48GsFxuXO0yFdVOuElTl2FnSmNm6wcM?= =?utf-8?q?94oVVLrXN0ws7Tk73O2DqK3mcDAG+r1gvqWu6h8rQfNOpaY9th+mARg6umzsBHk8Z?= =?utf-8?q?A39d1+n7DdWc9MWVWdfrwv42s719M8tPbNNpvTApgXsPHOJvTLB2BWyEVH13voDIk?= =?utf-8?q?vyEP2bOe9aGx/N3+/GBnngBAswgp5L+3Ith1Kt1YzroROpgxcBGrSl1txuyt+MbBg?= =?utf-8?q?rpE7xxTZmvOkz74okGzccd2mUbEAlX/s7PrfyFv4Xs7iFOeC3mHCZWiitpbY1K0CK?= =?utf-8?q?RGl4K9uLBLvH?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d8313c92-722d-4344-b602-08dd6c683e95 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8604.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Mar 2025 13:15:14.3537 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: dS9fsyqPpM/tmpa3L4DwT6QkvmiUUEJ/mQwQgpNFyA4VEa+VLo9CXFeWm8I9LjNPmGjvhEPqPULPeVsjwIDglg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8828 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250326_063051_029893_4E5C1EB0 X-CRM114-Status: GOOD ( 16.86 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Reviewed-by: Frank Li --- 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