public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Brian Masney <bmasney@redhat.com>
To: Mukesh Ojha <quic_mojha@quicinc.com>
Cc: agross@kernel.org, andersson@kernel.org,
	konrad.dybcio@linaro.org, linux-arm-msm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/4] firmware: qcom_scm: Refactor code to support multiple download mode
Date: Thu, 23 Feb 2023 07:25:30 -0500	[thread overview]
Message-ID: <Y/dbOtOHHAihhw87@x1> (raw)
In-Reply-To: <1676990381-18184-4-git-send-email-quic_mojha@quicinc.com>

On Tue, Feb 21, 2023 at 08:09:40PM +0530, Mukesh Ojha wrote:
> Currently on Qualcomm SoC, download_mode is enabled if
> CONFIG_QCOM_SCM_DOWNLOAD_MODE_DEFAULT is selected. Refactor
> the code such that it supports multiple download modes and
> drop the config.
> 
> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
> ---
>  drivers/firmware/Kconfig    | 11 -----------
>  drivers/firmware/qcom_scm.c | 45 +++++++++++++++++++++++++++++++++++++++------
>  include/linux/qcom_scm.h    |  4 ++++
>  3 files changed, 43 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig
> index b59e304..ff7e9f3 100644
> --- a/drivers/firmware/Kconfig
> +++ b/drivers/firmware/Kconfig
> @@ -215,17 +215,6 @@ config MTK_ADSP_IPC
>  config QCOM_SCM
>  	tristate
>  
> -config QCOM_SCM_DOWNLOAD_MODE_DEFAULT
> -	bool "Qualcomm download mode enabled by default"
> -	depends on QCOM_SCM
> -	help
> -	  A device with "download mode" enabled will upon an unexpected
> -	  warm-restart enter a special debug mode that allows the user to
> -	  "download" memory content over USB for offline postmortem analysis.
> -	  The feature can be enabled/disabled on the kernel command line.
> -
> -	  Say Y here to enable "download mode" by default.
> -
>  config SYSFB
>  	bool
>  	select BOOT_VESA_SUPPORT
> diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c
> index c376ba8..4975d3c 100644
> --- a/drivers/firmware/qcom_scm.c
> +++ b/drivers/firmware/qcom_scm.c
> @@ -20,8 +20,43 @@
>  
>  #include "qcom_scm.h"
>  
> -static bool download_mode = IS_ENABLED(CONFIG_QCOM_SCM_DOWNLOAD_MODE_DEFAULT);
> -module_param(download_mode, bool, 0);
> +static unsigned int download_mode;
> +static struct qcom_scm *__scm;

Add newline. Also, moving __scm wasn't called out in the commit
description.

> +static void qcom_scm_set_download_mode(bool enable);
> +static int set_dload_mode(const char *val, const struct kernel_param *kp)

Can set_dload_mode() be placed after qcom_scm_set_download_mode() so
that you don't need to declare it before hand.

> +{
> +	int ret;
> +	int old_mode = download_mode;
> +
> +	ret = param_set_int(val, kp);
> +	if (ret)
> +		return ret;
> +
> +	switch (download_mode) {
> +	case QCOM_DOWNLOAD_FULLDUMP:
> +		if (__scm)
> +			qcom_scm_set_download_mode(true);
> +		break;
> +	case QCOM_DOWNLOAD_NODUMP:
> +		if (__scm)
> +			qcom_scm_set_download_mode(false);
> +		break;
> +	default:
> +		pr_err("unknown download mode\n");
> +		download_mode = old_mode;
> +		return -EINVAL;

param_set_int() has been called already and has the invalid value. I
think the param_set_int() should be called after the download mode has
been set successfully.

> +	}
> +
> +	return 0;
> +}
> +
> +static const struct kernel_param_ops dload_mode_param_ops = {
> +	.set = set_dload_mode,
> +	.get = param_get_hexint,
> +};
> +module_param_cb(download_mode, &dload_mode_param_ops, &download_mode, 0644);
> +MODULE_PARM_DESC(download_mode,
> +		 "Download mode: 0x0=no dump mode (default), 0x10=full dump mode");
>  
>  #define SCM_HAS_CORE_CLK	BIT(0)
>  #define SCM_HAS_IFACE_CLK	BIT(1)
> @@ -70,8 +105,6 @@ static const char * const qcom_scm_convention_names[] = {
>  	[SMC_CONVENTION_LEGACY] = "smc legacy",
>  };
>  
> -static struct qcom_scm *__scm;
> -
>  static int qcom_scm_clk_enable(void)
>  {
>  	int ret;
> @@ -435,8 +468,8 @@ static void qcom_scm_set_download_mode(bool enable)
>  		}
>  
>  		ret = qcom_scm_io_writel(__scm->dload_mode_addr, enable ?
> -				dload_addr_val | QCOM_SCM_BOOT_SET_DLOAD_MODE :
> -				dload_addr_val & ~(QCOM_SCM_BOOT_SET_DLOAD_MODE));
> +				((dload_addr_val & ~QCOM_DOWNLOAD_MODE_MASK) | download_mode) :
> +				dload_addr_val & ~QCOM_DOWNLOAD_MODE_MASK);

These two lines were introduced in an earlier patch in this series. Why
not just introduce the QCOM_DOWNLOAD_MODE_MASK there?

Brian


  reply	other threads:[~2023-02-23 12:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-21 14:39 [PATCH 0/4] Refactor to support multiple download mode Mukesh Ojha
2023-02-21 14:39 ` [PATCH 1/4] firmware: qcom_scm: Clear download bit during reboot Mukesh Ojha
2023-02-21 14:39 ` [PATCH 2/4] firmware: scm: Modify only the DLOAD bit in TCSR register for download mode Mukesh Ojha
2023-02-23 11:48   ` Brian Masney
2023-02-23 14:14   ` Bjorn Andersson
2023-02-21 14:39 ` [PATCH 3/4] firmware: qcom_scm: Refactor code to support multiple " Mukesh Ojha
2023-02-23 12:25   ` Brian Masney [this message]
2023-02-23 14:36   ` Bjorn Andersson
2023-02-21 14:39 ` [PATCH 4/4] firmware: qcom_scm: Add multiple download mode support Mukesh Ojha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y/dbOtOHHAihhw87@x1 \
    --to=bmasney@redhat.com \
    --cc=agross@kernel.org \
    --cc=andersson@kernel.org \
    --cc=konrad.dybcio@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=quic_mojha@quicinc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox