RE: [PATCH v11 5/7] se_ctrl.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ran "b4 send --reflect"
But it sent to all.
Please ignore.

-----Original Message-----
From: Pankaj Gupta
Sent: Monday, January 20, 2025 2:46 PM
To: Jonathan Corbet <corbet@xxxxxxx>; Rob Herring <robh@xxxxxxxxxx>; Krzysztof 
Kozlowski <krzk+dt@xxxxxxxxxx>; Conor Dooley <conor+dt@xxxxxxxxxx>; Shawn Guo 
<shawnguo@xxxxxxxxxx>; Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>; Pengutronix 
Kernel Team <kernel@xxxxxxxxxxxxxx>; Fabio Estevam <festevam@xxxxxxxxx>; 
Pankaj Gupta <pankaj.gupta@xxxxxxx>
Cc: linux-doc@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx; 
devicetree@xxxxxxxxxxxxxxx; imx@xxxxxxxxxxxxxxx; 
linux-arm-kernel@xxxxxxxxxxxxxxxxxxx
Subject: [PATCH v11 5/7] se_ctrl.c

Signed-off-by: Pankaj Gupta <pankaj.gupta@xxxxxxx>
---
 drivers/firmware/imx/se_ctrl.c | 62 
++++++++++++++++++++----------------------
 1 file changed, 30 insertions(+), 32 deletions(-)

diff --git a/drivers/firmware/imx/se_ctrl.c b/drivers/firmware/imx/se_ctrl.c 
index 7260a9f93e06..7f6b9199e6ac 100644
--- a/drivers/firmware/imx/se_ctrl.c
+++ b/drivers/firmware/imx/se_ctrl.c
@@ -42,7 +42,7 @@ struct se_fw_img_name {  struct se_fw_load_info {
 	const struct se_fw_img_name *se_fw_img_nm;
 	bool is_fw_loaded;
-	bool handle_susp_resm;
+	bool imem_mgmt;
 	struct se_imem_buf imem;
 };

@@ -73,7 +73,7 @@ static struct se_var_info var_se_info = {
 	.soc_rev = 0,
 	.load_fw = {
 		.is_fw_loaded = true,
-		.handle_susp_resm = false,
+		.imem_mgmt = false,
 	},
 };

@@ -140,10 +140,15 @@ static const struct of_device_id se_match[] = {
 	{},
 };

+static struct se_fw_load_info *get_load_fw_instance(struct se_if_priv
+*priv) {
+	return &var_se_info.load_fw;
+}
+
 static int se_soc_info(struct se_if_priv *priv)  {
-	const struct se_if_node_info_list *info_list
-			= device_get_match_data(priv->dev);
+	const struct se_if_node_info_list *info_list = 
device_get_match_data(priv->dev);
+	struct se_fw_load_info *load_fw = get_load_fw_instance(priv);
 	struct soc_device_attribute *attr;
 	struct ele_dev_info *s_info;
 	struct soc_device *sdev;
@@ -164,6 +169,7 @@ static int se_soc_info(struct se_if_priv *priv)
 		}
 		s_info = (void *)data;
 		var_se_info.soc_rev = s_info->d_info.soc_rev;
+		load_fw->imem.state = s_info->d_addn_info.imem_state;
 	} else {
 		dev_err(priv->dev, "Failed to fetch SoC revision.");
 		if (info_list->soc_register)
@@ -219,11 +225,6 @@ static int se_soc_info(struct se_if_priv *priv)
 	return 0;
 }

-static struct se_fw_load_info *get_load_fw_instance(struct se_if_priv 
*priv) -{
-	return &var_se_info.load_fw;
-}
-
 static int se_load_firmware(struct se_if_priv *priv)  {
 	struct se_fw_load_info *load_fw = get_load_fw_instance(priv); @@ -237,21 
+238,9 @@ static int se_load_firmware(struct se_if_priv *priv)
 		return 0;

 	se_img_file_to_load = load_fw->se_fw_img_nm->seco_fw_nm_in_rfs;
-	if (load_fw->se_fw_img_nm->prim_fw_nm_in_rfs) {
-		/* allocate buffer where SE store encrypted IMEM */
-		load_fw->imem.buf = dmam_alloc_coherent(priv->dev, ELE_IMEM_SIZE,
-							&load_fw->imem.phyaddr,
-							GFP_KERNEL);
-		if (!load_fw->imem.buf) {
-			dev_err(priv->dev,
-				"dmam-alloc-failed: To store encr-IMEM.\n");
-			ret = -ENOMEM;
-			goto exit;
-		}
-		if (load_fw->imem.state == ELE_IMEM_STATE_BAD)
-			se_img_file_to_load
-					= load_fw->se_fw_img_nm->prim_fw_nm_in_rfs;
-	}
+	if (load_fw->se_fw_img_nm->prim_fw_nm_in_rfs &&
+			load_fw->imem.state == ELE_IMEM_STATE_BAD)
+		se_img_file_to_load = load_fw->se_fw_img_nm->prim_fw_nm_in_rfs;

 	do {
 		ret = request_firmware(&fw, se_img_file_to_load, priv->dev); @@ -467,8 
+456,21 @@ static int se_if_probe(struct platform_device *pdev)
 			info_list->se_fw_img_nm.seco_fw_nm_in_rfs) {
 		load_fw = get_load_fw_instance(priv);
 		load_fw->se_fw_img_nm = &info_list->se_fw_img_nm;
-
 		load_fw->is_fw_loaded = false;
+
+		if (info_list->se_fw_img_nm.prim_fw_nm_in_rfs) {
+			/* allocate buffer where SE store encrypted IMEM */
+			load_fw->imem.buf = dmam_alloc_coherent(priv->dev, ELE_IMEM_SIZE,
+								&load_fw->imem.phyaddr,
+								GFP_KERNEL);
+			if (!load_fw->imem.buf) {
+				dev_err(priv->dev,
+					"dmam-alloc-failed: To store encr-IMEM.\n");
+				ret = -ENOMEM;
+				goto exit;
+			}
+			load_fw->imem_mgmt = true;
+		}
 	}
 	dev_info(dev, "i.MX secure-enclave: %s%d interface to firmware, 
configured.\n",
 			SE_TYPE_STR_HSM,
@@ -494,13 +496,9 @@ static int se_suspend(struct device *dev)

 	load_fw = get_load_fw_instance(priv);

-	if (load_fw->handle_susp_resm) {
+	if (load_fw->imem_mgmt)
 		ret = se_save_imem_state(priv, &load_fw->imem);
-		if (ret < 0)
-			goto exit;
-		load_fw->imem.size = ret;
-	}
-exit:
+
 	return ret;
 }

@@ -511,7 +509,7 @@ static int se_resume(struct device *dev)

 	load_fw = get_load_fw_instance(priv);

-	if (load_fw->handle_susp_resm)
+	if (load_fw->imem_mgmt)
 		se_restore_imem_state(priv, &load_fw->imem);

 	return 0;

--
2.34.1

Attachment: smime.p7s
Description: S/MIME cryptographic signature


[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux