linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Anjana Hari <quic_ahari@quicinc.com>,
	agross@kernel.org, andersson@kernel.org, jejb@linux.ibm.com,
	martin.petersen@oracle.com
Cc: alim.akhtar@samsung.com, avri.altman@wdc.com,
	konrad.dybcio@linaro.org, linux-scsi@vger.kernel.org,
	linux-kernel@vger.kernel.org, quic_narepall@quicinc.com,
	quic_nitirawa@quicinc.com, quic_rampraka@quicinc.com
Subject: Re: [PATCH v3 0/1] scsi: ufs: Add hibernation callbacks
Date: Fri, 20 Jan 2023 13:12:08 -0800	[thread overview]
Message-ID: <9330ae10-de30-89be-cf53-f50db9610532@acm.org> (raw)
In-Reply-To: <20230120113321.30433-1-quic_ahari@quicinc.com>

On 1/20/23 03:33, Anjana Hari wrote:
>   - Note to Bart: Regrading the comment to pass "restore" as an
>   argument instead of adding a new member to ufs_hba structure, adding
>   new function argument in core file (ufshcd.c) is forcing us to make
>   changes to other vendor files to fix the compilation errors. Hence
>   we have retained our original change. Please let us know your inputs
>   on this. 
Storing state information in a structure member that can be passed as a
function argument makes code harder to read and to maintain than
necessary. Please address my request before this patch goes upstream. I'm
concerned if someone would try to address my request after this patch went
upstream that there would be no motivation from your side to help with
testing the refactoring patch.

I think the patch below shows that it is easy to eliminate the new 'restore'
member variable. Please note that the patch below has not been tested in any
way.

---
  drivers/ufs/core/ufshcd.c | 48 +++++++++++++++++++--------------------
  include/ufs/ufshcd.h      |  3 ---
  2 files changed, 23 insertions(+), 28 deletions(-)

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 19608f3a38f9..b5cfbc1fccc6 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -9801,34 +9801,11 @@ static int ufshcd_resume(struct ufs_hba *hba)
  	/* enable the host irq as host controller would be active soon */
  	ufshcd_enable_irq(hba);

-	if (hba->restore) {
-		/* Configure UTRL and UTMRL base address registers */
-		ufshcd_writel(hba, lower_32_bits(hba->utrdl_dma_addr),
-			      REG_UTP_TRANSFER_REQ_LIST_BASE_L);
-		ufshcd_writel(hba, upper_32_bits(hba->utrdl_dma_addr),
-			      REG_UTP_TRANSFER_REQ_LIST_BASE_H);
-		ufshcd_writel(hba, lower_32_bits(hba->utmrdl_dma_addr),
-			      REG_UTP_TASK_REQ_LIST_BASE_L);
-		ufshcd_writel(hba, upper_32_bits(hba->utmrdl_dma_addr),
-			      REG_UTP_TASK_REQ_LIST_BASE_H);
-		/* Make sure that UTRL and UTMRL base address registers
-		 * are updated with the latest queue addresses. Only after
-		 * updating these addresses, we can queue the new commands.
-		 */
-		mb();
-	}
-
-	/* Resuming from hibernate, assume that link was OFF */
-	if (hba->restore)
-		ufshcd_set_link_off(hba);
-
  	goto out;

  disable_vreg:
  	ufshcd_vreg_set_lpm(hba);
  out:
-	if (hba->restore)
-		hba->restore = false;

  	if (ret)
  		ufshcd_update_evt_hist(hba, UFS_EVT_RESUME_ERR, (u32)ret);
@@ -10012,10 +9989,31 @@ int ufshcd_system_restore(struct device *dev)
  {

  	struct ufs_hba *hba = dev_get_drvdata(dev);
+	int ret;

-	hba->restore = true;
-	return ufshcd_system_resume(dev);
+	ret = ufshcd_system_resume(dev);
+	if (ret)
+		return ret;
+
+	/* Configure UTRL and UTMRL base address registers */
+	ufshcd_writel(hba, lower_32_bits(hba->utrdl_dma_addr),
+		      REG_UTP_TRANSFER_REQ_LIST_BASE_L);
+	ufshcd_writel(hba, upper_32_bits(hba->utrdl_dma_addr),
+		      REG_UTP_TRANSFER_REQ_LIST_BASE_H);
+	ufshcd_writel(hba, lower_32_bits(hba->utmrdl_dma_addr),
+		      REG_UTP_TASK_REQ_LIST_BASE_L);
+	ufshcd_writel(hba, upper_32_bits(hba->utmrdl_dma_addr),
+		      REG_UTP_TASK_REQ_LIST_BASE_H);
+	/* Make sure that UTRL and UTMRL base address registers
+	 * are updated with the latest queue addresses. Only after
+	 * updating these addresses, we can queue the new commands.
+	 */
+	mb();

+	/* Resuming from hibernate, assume that link was OFF */
+	ufshcd_set_link_off(hba);
+
+	return 0;
  }
  EXPORT_SYMBOL_GPL(ufshcd_system_restore);

diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h
index 6f50390ca262..1d6dd13e1651 100644
--- a/include/ufs/ufshcd.h
+++ b/include/ufs/ufshcd.h
@@ -1071,9 +1071,6 @@ struct ufs_hba {
  	struct ufs_hw_queue *uhq;
  	struct ufs_hw_queue *dev_cmd_queue;
  	struct ufshcd_mcq_opr_info_t mcq_opr[OPR_MAX];
-
-	/* Distinguish between resume and restore */
-	bool restore;
  };

  /**


      parent reply	other threads:[~2023-01-20 21:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-20 11:33 [PATCH v3 0/1] scsi: ufs: Add hibernation callbacks Anjana Hari
2023-01-20 11:33 ` [PATCH v3 1/1] " Anjana Hari
2023-01-20 21:27   ` Bart Van Assche
2023-01-21  4:42   ` kernel test robot
2023-01-21  4:42   ` kernel test robot
2023-01-20 21:12 ` Bart Van Assche [this message]

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=9330ae10-de30-89be-cf53-f50db9610532@acm.org \
    --to=bvanassche@acm.org \
    --cc=agross@kernel.org \
    --cc=alim.akhtar@samsung.com \
    --cc=andersson@kernel.org \
    --cc=avri.altman@wdc.com \
    --cc=jejb@linux.ibm.com \
    --cc=konrad.dybcio@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=quic_ahari@quicinc.com \
    --cc=quic_narepall@quicinc.com \
    --cc=quic_nitirawa@quicinc.com \
    --cc=quic_rampraka@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;
as well as URLs for NNTP newsgroup(s).