[v4,5/5] firmware: qcom_scm: Add multiple download mode support

Message ID 1679935281-18445-6-git-send-email-quic_mojha@quicinc.com
State New
Headers
Series Refactor to support multiple download mode |

Commit Message

Mukesh Ojha March 27, 2023, 4:41 p.m. UTC
  Currently, scm driver only supports full dump when download
mode is selected. Add support to enable minidump as well both
dump(full dump + minidump).

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 drivers/firmware/qcom_scm.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
  

Comments

Bjorn Andersson March 27, 2023, 6:27 p.m. UTC | #1
On Mon, Mar 27, 2023 at 10:11:21PM +0530, Mukesh Ojha wrote:
> Currently, scm driver only supports full dump when download
> mode is selected. Add support to enable minidump as well both
> dump(full dump + minidump).
> 
> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
> ---
>  drivers/firmware/qcom_scm.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c
> index 0c94429..19315d0 100644
> --- a/drivers/firmware/qcom_scm.c
> +++ b/drivers/firmware/qcom_scm.c
> @@ -32,6 +32,8 @@ static u32 download_mode;
>  
>  #define QCOM_DOWNLOAD_MODE_MASK 0x30
>  #define QCOM_DOWNLOAD_FULLDUMP	0x1
> +#define QCOM_DOWNLOAD_MINIDUMP  0x2
> +#define QCOM_DOWNLOAD_BOTHDUMP	(QCOM_DOWNLOAD_FULLDUMP | QCOM_DOWNLOAD_MINIDUMP)
>  #define QCOM_DOWNLOAD_NODUMP	0x0
>  
>  struct qcom_scm {
> @@ -1421,13 +1423,16 @@ static irqreturn_t qcom_scm_irq_handler(int irq, void *data)
>  	return IRQ_HANDLED;
>  }
>  
> -
>  static int get_download_mode(char *buffer, const struct kernel_param *kp)
>  {
>  	int len = 0;
>  
>  	if (download_mode == QCOM_DOWNLOAD_FULLDUMP)
>  		len = sysfs_emit(buffer, "full\n");
> +	else if (download_mode == QCOM_DOWNLOAD_MINIDUMP)
> +		len = sysfs_emit(buffer, "mini\n");
> +	else if (download_mode == QCOM_DOWNLOAD_BOTHDUMP)
> +		len = sysfs_emit(buffer, "both\n");
>  	else if (download_mode == QCOM_DOWNLOAD_NODUMP)
>  		len = sysfs_emit(buffer, "off\n");
>  
> @@ -1440,6 +1445,10 @@ static int set_download_mode(const char *val, const struct kernel_param *kp)
>  
>  	if (!strncmp(val, "full", strlen("full"))) {
>  		download_mode = QCOM_DOWNLOAD_FULLDUMP;
> +	} else if (!strncmp(val, "mini", strlen("mini"))) {
> +		download_mode = QCOM_DOWNLOAD_MINIDUMP;
> +	} else if (!strncmp(val, "both", strlen("both"))) {

"both" isn't very future proof...

How about allowing mini,full? You don't need to do string tokenizing
etc, just strcmp mini,full (and full,mini if you want to be fancy)...

Regards,
Bjorn

> +		download_mode = QCOM_DOWNLOAD_BOTHDUMP;
>  	} else if (!strncmp(val, "off", strlen("off"))) {
>  		download_mode = QCOM_DOWNLOAD_NODUMP;
>  	} else if (kstrtouint(val, 0, &download_mode) ||
> @@ -1462,7 +1471,7 @@ static const struct kernel_param_ops download_mode_param_ops = {
>  
>  module_param_cb(download_mode, &download_mode_param_ops, NULL, 0644);
>  MODULE_PARM_DESC(download_mode,
> -		 "Download mode: off/full or 0/1 for existing users");
> +		 "download mode: off/full/mini/both(full+mini) or 0/1 for existing users");
>  
>  static int qcom_scm_probe(struct platform_device *pdev)
>  {
> -- 
> 2.7.4
>
  
Mukesh Ojha March 28, 2023, 8:20 a.m. UTC | #2
On 3/27/2023 11:57 PM, Bjorn Andersson wrote:
> On Mon, Mar 27, 2023 at 10:11:21PM +0530, Mukesh Ojha wrote:
>> Currently, scm driver only supports full dump when download
>> mode is selected. Add support to enable minidump as well both
>> dump(full dump + minidump).
>>
>> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
>> ---
>>   drivers/firmware/qcom_scm.c | 13 +++++++++++--
>>   1 file changed, 11 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c
>> index 0c94429..19315d0 100644
>> --- a/drivers/firmware/qcom_scm.c
>> +++ b/drivers/firmware/qcom_scm.c
>> @@ -32,6 +32,8 @@ static u32 download_mode;
>>   
>>   #define QCOM_DOWNLOAD_MODE_MASK 0x30
>>   #define QCOM_DOWNLOAD_FULLDUMP	0x1
>> +#define QCOM_DOWNLOAD_MINIDUMP  0x2
>> +#define QCOM_DOWNLOAD_BOTHDUMP	(QCOM_DOWNLOAD_FULLDUMP | QCOM_DOWNLOAD_MINIDUMP)
>>   #define QCOM_DOWNLOAD_NODUMP	0x0
>>   
>>   struct qcom_scm {
>> @@ -1421,13 +1423,16 @@ static irqreturn_t qcom_scm_irq_handler(int irq, void *data)
>>   	return IRQ_HANDLED;
>>   }
>>   
>> -
>>   static int get_download_mode(char *buffer, const struct kernel_param *kp)
>>   {
>>   	int len = 0;
>>   
>>   	if (download_mode == QCOM_DOWNLOAD_FULLDUMP)
>>   		len = sysfs_emit(buffer, "full\n");
>> +	else if (download_mode == QCOM_DOWNLOAD_MINIDUMP)
>> +		len = sysfs_emit(buffer, "mini\n");
>> +	else if (download_mode == QCOM_DOWNLOAD_BOTHDUMP)
>> +		len = sysfs_emit(buffer, "both\n");
>>   	else if (download_mode == QCOM_DOWNLOAD_NODUMP)
>>   		len = sysfs_emit(buffer, "off\n");
>>   
>> @@ -1440,6 +1445,10 @@ static int set_download_mode(const char *val, const struct kernel_param *kp)
>>   
>>   	if (!strncmp(val, "full", strlen("full"))) {
>>   		download_mode = QCOM_DOWNLOAD_FULLDUMP;
>> +	} else if (!strncmp(val, "mini", strlen("mini"))) {
>> +		download_mode = QCOM_DOWNLOAD_MINIDUMP;
>> +	} else if (!strncmp(val, "both", strlen("both"))) {
> 
> "both" isn't very future proof...
> 
> How about allowing mini,full? You don't need to do string tokenizing
> etc, just strcmp mini,full (and full,mini if you want to be fancy)...
> 

Thanks for the suggestion, this looks good.
I have applied the changes.

-- Mukesh

> Regards,
> Bjorn
> 
>> +		download_mode = QCOM_DOWNLOAD_BOTHDUMP;
>>   	} else if (!strncmp(val, "off", strlen("off"))) {
>>   		download_mode = QCOM_DOWNLOAD_NODUMP;
>>   	} else if (kstrtouint(val, 0, &download_mode) ||
>> @@ -1462,7 +1471,7 @@ static const struct kernel_param_ops download_mode_param_ops = {
>>   
>>   module_param_cb(download_mode, &download_mode_param_ops, NULL, 0644);
>>   MODULE_PARM_DESC(download_mode,
>> -		 "Download mode: off/full or 0/1 for existing users");
>> +		 "download mode: off/full/mini/both(full+mini) or 0/1 for existing users");
>>   
>>   static int qcom_scm_probe(struct platform_device *pdev)
>>   {
>> -- 
>> 2.7.4
>>
  

Patch

diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c
index 0c94429..19315d0 100644
--- a/drivers/firmware/qcom_scm.c
+++ b/drivers/firmware/qcom_scm.c
@@ -32,6 +32,8 @@  static u32 download_mode;
 
 #define QCOM_DOWNLOAD_MODE_MASK 0x30
 #define QCOM_DOWNLOAD_FULLDUMP	0x1
+#define QCOM_DOWNLOAD_MINIDUMP  0x2
+#define QCOM_DOWNLOAD_BOTHDUMP	(QCOM_DOWNLOAD_FULLDUMP | QCOM_DOWNLOAD_MINIDUMP)
 #define QCOM_DOWNLOAD_NODUMP	0x0
 
 struct qcom_scm {
@@ -1421,13 +1423,16 @@  static irqreturn_t qcom_scm_irq_handler(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
-
 static int get_download_mode(char *buffer, const struct kernel_param *kp)
 {
 	int len = 0;
 
 	if (download_mode == QCOM_DOWNLOAD_FULLDUMP)
 		len = sysfs_emit(buffer, "full\n");
+	else if (download_mode == QCOM_DOWNLOAD_MINIDUMP)
+		len = sysfs_emit(buffer, "mini\n");
+	else if (download_mode == QCOM_DOWNLOAD_BOTHDUMP)
+		len = sysfs_emit(buffer, "both\n");
 	else if (download_mode == QCOM_DOWNLOAD_NODUMP)
 		len = sysfs_emit(buffer, "off\n");
 
@@ -1440,6 +1445,10 @@  static int set_download_mode(const char *val, const struct kernel_param *kp)
 
 	if (!strncmp(val, "full", strlen("full"))) {
 		download_mode = QCOM_DOWNLOAD_FULLDUMP;
+	} else if (!strncmp(val, "mini", strlen("mini"))) {
+		download_mode = QCOM_DOWNLOAD_MINIDUMP;
+	} else if (!strncmp(val, "both", strlen("both"))) {
+		download_mode = QCOM_DOWNLOAD_BOTHDUMP;
 	} else if (!strncmp(val, "off", strlen("off"))) {
 		download_mode = QCOM_DOWNLOAD_NODUMP;
 	} else if (kstrtouint(val, 0, &download_mode) ||
@@ -1462,7 +1471,7 @@  static const struct kernel_param_ops download_mode_param_ops = {
 
 module_param_cb(download_mode, &download_mode_param_ops, NULL, 0644);
 MODULE_PARM_DESC(download_mode,
-		 "Download mode: off/full or 0/1 for existing users");
+		 "download mode: off/full/mini/both(full+mini) or 0/1 for existing users");
 
 static int qcom_scm_probe(struct platform_device *pdev)
 {