From 34c6371a975f2b7ef4bc28a584eda6ccf7f14807 Mon Sep 17 00:00:00 2001 From: Hemanth Rachakonda Date: Wed, 26 Mar 2025 11:20:14 -0700 Subject: [PATCH 1/4] Fix for larger memory buffer Signed-off-by: Hemanth Rachakonda --- drivers/misc/icvs/intel_cvs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/misc/icvs/intel_cvs.c b/drivers/misc/icvs/intel_cvs.c index d1d33f3..0aa8886 100644 --- a/drivers/misc/icvs/intel_cvs.c +++ b/drivers/misc/icvs/intel_cvs.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "cvs_gpio.h" #include "intel_cvs_update.h" @@ -210,6 +211,8 @@ static void cvs_i2c_remove(struct i2c_client *i2c) } cvs_exit(icvs); } + if(cvs->fw_buffer) + vfree(cvs->fw_buffer); devm_kfree(&i2c->dev, icvs); } } @@ -525,7 +528,7 @@ static ssize_t cvs_ctrl_data_pre_store(struct device *dev, cvs->fw_buffer_size = fw_bin_size; cvs->max_flashtime_ms = cvs->plugin_to_cvs.max_flash_time; cvs->fw_update_retries = cvs->plugin_to_cvs.max_fwupd_retry_count; - cvs->fw_buffer = devm_kzalloc(cvs->dev, cvs->fw_buffer_size, GFP_KERNEL); + cvs->fw_buffer = vmalloc(cvs->fw_buffer_size); if (IS_ERR_OR_NULL(cvs->fw_buffer)) { dev_err(cvs->dev, "%s:No memory for fw_buffer", __func__); From 37640b1450a7d4553f26ed40f7b62c5b369f9131 Mon Sep 17 00:00:00 2001 From: Hemanth Rachakonda Date: Wed, 26 Mar 2025 12:16:19 -0700 Subject: [PATCH 2/4] Fix coding style Signed-off-by: Hemanth Rachakonda --- drivers/misc/icvs/intel_cvs.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/misc/icvs/intel_cvs.c b/drivers/misc/icvs/intel_cvs.c index 0aa8886..31348ba 100644 --- a/drivers/misc/icvs/intel_cvs.c +++ b/drivers/misc/icvs/intel_cvs.c @@ -211,8 +211,9 @@ static void cvs_i2c_remove(struct i2c_client *i2c) } cvs_exit(icvs); } - if(cvs->fw_buffer) - vfree(cvs->fw_buffer); + if (cvs->fw_buffer) + vfree(cvs->fw_buffer); + devm_kfree(&i2c->dev, icvs); } } @@ -528,7 +529,7 @@ static ssize_t cvs_ctrl_data_pre_store(struct device *dev, cvs->fw_buffer_size = fw_bin_size; cvs->max_flashtime_ms = cvs->plugin_to_cvs.max_flash_time; cvs->fw_update_retries = cvs->plugin_to_cvs.max_fwupd_retry_count; - cvs->fw_buffer = vmalloc(cvs->fw_buffer_size); + cvs->fw_buffer = vmalloc(cvs->fw_buffer_size); if (IS_ERR_OR_NULL(cvs->fw_buffer)) { dev_err(cvs->dev, "%s:No memory for fw_buffer", __func__); From f4102c2a08e65c829c43522e08aa32cc2b6a67f4 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Wed, 9 Apr 2025 19:44:19 +0100 Subject: [PATCH 3/4] drivers: icvs: add __packed attribute to ctrl_data_fwupd struct (#21) The layout of both structs cannot be optimized by the compiler as this is exported as a binary blob into sysfs using memcpy. This fixes updating the firwmare using fwupd. Signed-off-by: Richard Hughes --- include/linux/intel_cvs.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/intel_cvs.h b/include/linux/intel_cvs.h index cfa6569..582d641 100644 --- a/include/linux/intel_cvs.h +++ b/include/linux/intel_cvs.h @@ -136,7 +136,7 @@ struct cvs_to_plugin_interface { u16 pid; int opid; int dev_capabilities; -}; +} __packed; /* Params updated by CVS plugin */ struct plugin_to_cvs_interface { @@ -144,7 +144,7 @@ struct plugin_to_cvs_interface { int max_flash_time; /*milli sec*/ int max_fwupd_retry_count; int fw_bin_fd; /*file descriptor*/ -}; +} __packed; /* FW update status Info */ struct ctrl_data_fwupd { @@ -156,7 +156,7 @@ struct ctrl_data_fwupd { bool fw_dl_finshed; /* 0:PASS, Non-zero error code. Read only after fw_dl finished=1 */ int fw_dl_status_code; -}; +} __packed; struct intel_cvs { struct device *dev; From c50541caed9b48a82e7ab3a7b983577f545e3055 Mon Sep 17 00:00:00 2001 From: Hemanth Rachakonda Date: Fri, 11 Apr 2025 12:45:52 -0700 Subject: [PATCH 4/4] Revert "drivers: icvs: add __packed attribute to ctrl_data_fwupd struct (#21)" This reverts commit f4102c2a08e65c829c43522e08aa32cc2b6a67f4. --- include/linux/intel_cvs.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/intel_cvs.h b/include/linux/intel_cvs.h index 582d641..cfa6569 100644 --- a/include/linux/intel_cvs.h +++ b/include/linux/intel_cvs.h @@ -136,7 +136,7 @@ struct cvs_to_plugin_interface { u16 pid; int opid; int dev_capabilities; -} __packed; +}; /* Params updated by CVS plugin */ struct plugin_to_cvs_interface { @@ -144,7 +144,7 @@ struct plugin_to_cvs_interface { int max_flash_time; /*milli sec*/ int max_fwupd_retry_count; int fw_bin_fd; /*file descriptor*/ -} __packed; +}; /* FW update status Info */ struct ctrl_data_fwupd { @@ -156,7 +156,7 @@ struct ctrl_data_fwupd { bool fw_dl_finshed; /* 0:PASS, Non-zero error code. Read only after fw_dl finished=1 */ int fw_dl_status_code; -} __packed; +}; struct intel_cvs { struct device *dev;