lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231213094055.446611-1-sakari.ailus@linux.intel.com>
Date:   Wed, 13 Dec 2023 11:40:55 +0200
From:   Sakari Ailus <sakari.ailus@...ux.intel.com>
To:     linux-kernel@...r.kernel.org
Cc:     gregkh@...uxfoundation.org, alexander.usyskin@...el.com,
        tomas.winkler@...el.com, Arnd Bergmann <arnd@...db.de>,
        wentong.wu@...el.com
Subject: [PATCH 1/1] mei: vsc: Rework firmware image names

Rework firmware image names with the users in mind---there's no need for
variation between firmware names, apart from connected sensors. All
supported SoCs use the same firmware, too.

Use a single set of firmware binaries and assume they'll be found under
intel/vsc directory.

Signed-off-by: Sakari Ailus <sakari.ailus@...ux.intel.com>
Tested-by: Wentong Wu <wentong.wu@...el.com>
---
Hi folks,

The firmware isn't in linux-firmware yet (I'm working on it). The name can
still be changed as this hasn't made its way to a release yet.

 drivers/misc/mei/vsc-fw-loader.c | 72 +++++---------------------------
 1 file changed, 10 insertions(+), 62 deletions(-)

diff --git a/drivers/misc/mei/vsc-fw-loader.c b/drivers/misc/mei/vsc-fw-loader.c
index 3e151f06e85b..ffa4ccd96a10 100644
--- a/drivers/misc/mei/vsc-fw-loader.c
+++ b/drivers/misc/mei/vsc-fw-loader.c
@@ -27,9 +27,6 @@
 #define VSC_EFUSE_ADDR			(VSC_ADDR_BASE + 0x038)
 #define VSC_STRAP_ADDR			(VSC_ADDR_BASE + 0x100)
 
-#define VSC_STRAP_KEY_SRC_MASK		BIT(0)
-#define VSC_STRAP_KEY_SRC_PRODUCT	1
-
 #define VSC_MAINSTEPPING_VERSION_MASK	GENMASK(7, 4)
 #define VSC_MAINSTEPPING_VERSION_A	0
 
@@ -49,22 +46,15 @@
 #define VSC_ROM_PKG_SIZE		256u
 #define VSC_FW_PKG_SIZE			512u
 
-#define VSC_CSI_IMAGE_NAME_FMT		"ivsc_fw_a1.bin"
-#define VSC_CSI_IMAGE_NAME_FMT_PROD	"ivsc_fw_a1_%s.bin"
-#define VSC_ACE_IMAGE_NAME_FMT		"ivsc_pkg_%s_0_a1.bin"
-#define VSC_ACE_IMAGE_NAME_FMT_PROD	"ivsc_pkg_%s_0_a1_%s.bin"
-#define VSC_CFG_IMAGE_NAME_FMT		"ivsc_skucfg_%s_0_1_a1.bin"
-#define VSC_CFG_IMAGE_NAME_FMT_PROD	"ivsc_skucfg_%s_0_1_a1_%s.bin"
+#define VSC_IMAGE_DIR			"intel/vsc/"
 
-#define VSC_IMAGE_FOLDER_FMT		"vsc/soc_a1"
-#define VSC_IMAGE_FOLDER_FMT_PROD	"vsc/soc_a1_%s"
+#define VSC_CSI_IMAGE_NAME		VSC_IMAGE_DIR "ivsc_fw.bin"
+#define VSC_ACE_IMAGE_NAME_FMT		VSC_IMAGE_DIR "ivsc_pkg_%s_0.bin"
+#define VSC_CFG_IMAGE_NAME_FMT		VSC_IMAGE_DIR "ivsc_skucfg_%s_0_1.bin"
 
-#define VSC_IMAGE_NAME_MAX_LEN		64
-#define VSC_IMAGE_PATH_MAX_LEN		128
+#define VSC_IMAGE_PATH_MAX_LEN		64
 
 #define VSC_SENSOR_NAME_MAX_LEN		16
-#define VSC_IMAGE_FOLDER_NAME_MAX_LEN	32
-#define VSC_IMAGE_NAME_SUFFIX_MAX_LEN	8
 
 /* command id */
 enum {
@@ -223,10 +213,7 @@ struct vsc_img_frag {
  * @rx_buf: rx buffer
  * @option: command option
  * @count: total image count
- * @key_src: key source
- * @folder: image folder
  * @sensor_name: camera sensor name
- * @suffix: image name suffix
  * @frags: image fragments
  */
 struct vsc_fw_loader {
@@ -242,11 +229,8 @@ struct vsc_fw_loader {
 
 	u16 option;
 	u16 count;
-	u32 key_src;
 
-	char folder[VSC_IMAGE_FOLDER_NAME_MAX_LEN];
 	char sensor_name[VSC_SENSOR_NAME_MAX_LEN];
-	char suffix[VSC_IMAGE_NAME_SUFFIX_MAX_LEN];
 
 	struct vsc_img_frag frags[VSC_IMG_FRAG_MAX];
 };
@@ -378,33 +362,18 @@ static int vsc_identify_silicon(struct vsc_fw_loader *fw_loader)
 	if (ack->token != VSC_TOKEN_DUMP_RESP)
 		return -EINVAL;
 
-	fw_loader->key_src = FIELD_GET(VSC_STRAP_KEY_SRC_MASK, ack->payload[2]);
-
-	if (fw_loader->key_src == VSC_STRAP_KEY_SRC_PRODUCT)
-		strscpy(fw_loader->suffix, "prod", sizeof(fw_loader->suffix));
-
 	return 0;
 }
 
 static int vsc_identify_csi_image(struct vsc_fw_loader *fw_loader)
 {
-	char path[VSC_IMAGE_PATH_MAX_LEN];
-	char name[VSC_IMAGE_NAME_MAX_LEN];
 	const struct firmware *image;
 	struct vsc_fw_sign *sign;
 	struct vsc_img *img;
 	unsigned int i;
 	int ret;
 
-	if (fw_loader->key_src == VSC_STRAP_KEY_SRC_PRODUCT)
-		snprintf(name, sizeof(name), VSC_CSI_IMAGE_NAME_FMT_PROD,
-			 fw_loader->suffix);
-	else
-		snprintf(name, sizeof(name), VSC_CSI_IMAGE_NAME_FMT);
-
-	snprintf(path, sizeof(path), "%s/%s", fw_loader->folder, name);
-
-	ret = request_firmware(&image, path, fw_loader->dev);
+	ret = request_firmware(&image, VSC_CSI_IMAGE_NAME, fw_loader->dev);
 	if (ret)
 		return ret;
 
@@ -480,21 +449,14 @@ static int vsc_identify_csi_image(struct vsc_fw_loader *fw_loader)
 static int vsc_identify_ace_image(struct vsc_fw_loader *fw_loader)
 {
 	char path[VSC_IMAGE_PATH_MAX_LEN];
-	char name[VSC_IMAGE_NAME_MAX_LEN];
 	const struct firmware *image;
 	struct vsc_fw_sign *sign;
 	struct vsc_img *img;
 	unsigned int i;
 	int ret;
 
-	if (fw_loader->key_src == VSC_STRAP_KEY_SRC_PRODUCT)
-		snprintf(name, sizeof(name), VSC_ACE_IMAGE_NAME_FMT_PROD,
-			 fw_loader->sensor_name, fw_loader->suffix);
-	else
-		snprintf(name, sizeof(name), VSC_ACE_IMAGE_NAME_FMT,
-			 fw_loader->sensor_name);
-
-	snprintf(path, sizeof(path), "%s/%s", fw_loader->folder, name);
+	snprintf(path, sizeof(path), VSC_ACE_IMAGE_NAME_FMT,
+		 fw_loader->sensor_name);
 
 	ret = request_firmware(&image, path, fw_loader->dev);
 	if (ret)
@@ -571,19 +533,12 @@ static int vsc_identify_cfg_image(struct vsc_fw_loader *fw_loader)
 {
 	struct vsc_img_frag *frag = &fw_loader->frags[VSC_IMG_SKU_CFG_FRAG];
 	char path[VSC_IMAGE_PATH_MAX_LEN];
-	char name[VSC_IMAGE_NAME_MAX_LEN];
 	const struct firmware *image;
 	u32 size;
 	int ret;
 
-	if (fw_loader->key_src == VSC_STRAP_KEY_SRC_PRODUCT)
-		snprintf(name, sizeof(name), VSC_CFG_IMAGE_NAME_FMT_PROD,
-			 fw_loader->sensor_name, fw_loader->suffix);
-	else
-		snprintf(name, sizeof(name), VSC_CFG_IMAGE_NAME_FMT,
-			 fw_loader->sensor_name);
-
-	snprintf(path, sizeof(path), "%s/%s", fw_loader->folder, name);
+	snprintf(path, sizeof(path), VSC_CFG_IMAGE_NAME_FMT,
+		 fw_loader->sensor_name);
 
 	ret = request_firmware(&image, path, fw_loader->dev);
 	if (ret)
@@ -786,13 +741,6 @@ int vsc_tp_init(struct vsc_tp *tp, struct device *dev)
 	if (ret)
 		return ret;
 
-	if (fw_loader->key_src == VSC_STRAP_KEY_SRC_PRODUCT)
-		snprintf(fw_loader->folder, sizeof(fw_loader->folder),
-			 VSC_IMAGE_FOLDER_FMT_PROD, fw_loader->suffix);
-	else
-		snprintf(fw_loader->folder, sizeof(fw_loader->folder),
-			 VSC_IMAGE_FOLDER_FMT);
-
 	ret = vsc_identify_csi_image(fw_loader);
 	if (ret)
 		return ret;
-- 
2.39.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ