public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Kiwoong Kim <kwmad.kim@samsung.com>,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	alim.akhtar@samsung.com, avri.altman@wdc.com, jejb@linux.ibm.com,
	martin.petersen@oracle.com, beanhuo@micron.com,
	sc.suh@samsung.com, hy50.seo@samsung.com, sh425.lee@samsung.com,
	kwangwon.min@samsung.com
Subject: Re: [RFC PATCH v1] ufs: poll HCS.UCRDY before issuing a UIC command
Date: Thu, 11 May 2023 08:22:26 +0300	[thread overview]
Message-ID: <08bc0186-4684-2321-65d8-4c2ae622acea@intel.com> (raw)
In-Reply-To: <1683620674-160173-1-git-send-email-kwmad.kim@samsung.com>

On 9/05/23 11:24, Kiwoong Kim wrote:
> With auto hibern8 enabled, UIC could be working
> for a while to process a hibern8 operation and HCI
> reports UIC not ready for a short term through HCS.UCRDY.
> And UFS driver can't recognize the operation.
> UFSHCI spec specifies UCRDY like this:
> whether the host controller is ready to process UIC COMMAND
> 
> The 'ready' could be seen as many different meanings. If the meaning
> includes not processing any request from HCI, processing a hibern8
> operation can be 'not ready'. In this situation, the driver needs to
> wait until the operations is completed.
> 
> Signed-off-by: Kiwoong Kim <kwmad.kim@samsung.com>
> ---
>  drivers/ufs/core/ufshcd.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index 96ce6af..fc79539 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -2368,7 +2368,18 @@ static inline int ufshcd_hba_capabilities(struct ufs_hba *hba)
>   */
>  static inline bool ufshcd_ready_for_uic_cmd(struct ufs_hba *hba)
>  {
> -	return ufshcd_readl(hba, REG_CONTROLLER_STATUS) & UIC_COMMAND_READY;
> +	ktime_t timeout = ktime_add_ms(ktime_get(), UIC_CMD_TIMEOUT);
> +	u32 val = 0;
> +
> +	do {
> +		val = ufshcd_readl(hba, REG_CONTROLLER_STATUS) &
> +			UIC_COMMAND_READY;
> +		if (val)
> +			break;
> +		usleep_range(500, 1000);

Pedantically, the sleep probably needs to be less than the
auto-hibernate idle timer period?

> +	} while (ktime_before(ktime_get(), timeout));

read_poll_timeout() would be a better choice for I/O polling

> +
> +	return val ? true : false;
>  }
>  
>  /**


  parent reply	other threads:[~2023-05-11  5:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20230509083312epcas2p375f77d18a9026f7d263750baf9c9a5bb@epcas2p3.samsung.com>
2023-05-09  8:24 ` [RFC PATCH v1] ufs: poll HCS.UCRDY before issuing a UIC command Kiwoong Kim
2023-05-10 10:14   ` Avri Altman
2023-05-16  3:30     ` Kiwoong Kim
2023-05-10 18:53   ` Bart Van Assche
2023-05-10 21:24   ` Bao D. Nguyen
2023-05-10 21:46     ` Bart Van Assche
2023-05-10 23:35     ` Kiwoong Kim
2023-05-16  3:28     ` Kiwoong Kim
2023-05-11  5:22   ` Adrian Hunter [this message]
2023-05-12  0:56     ` Kiwoong Kim

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=08bc0186-4684-2321-65d8-4c2ae622acea@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=alim.akhtar@samsung.com \
    --cc=avri.altman@wdc.com \
    --cc=beanhuo@micron.com \
    --cc=hy50.seo@samsung.com \
    --cc=jejb@linux.ibm.com \
    --cc=kwangwon.min@samsung.com \
    --cc=kwmad.kim@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=sc.suh@samsung.com \
    --cc=sh425.lee@samsung.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