mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Vamshi Gajjela <vamshigajjela@google.com>,
	Alim Akhtar <alim.akhtar@samsung.com>,
	Avri Altman <avri.altman@wdc.com>
Cc: Yaniv Gardi <ygardi@codeaurora.org>,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH] scsi: ufs: core: Fix hba->last_dme_cmd_tstamp timestamp updating logic
Date: Mon, 29 Jul 2024 11:26:51 -0700	[thread overview]
Message-ID: <2bb22490-6209-4104-ae97-59d73fcb1d6d@acm.org> (raw)
In-Reply-To: <20240724135126.1786126-1-vamshigajjela@google.com>

On 7/24/24 6:51 AM, Vamshi Gajjela wrote:
> The ufshcd_add_delay_before_dme_cmd() always introduces a delay of
> MIN_DELAY_BEFORE_DME_CMDS_US between DME commands even when it's not
> required. The delay is added when the UFS host controller supplies the
> quirk UFSHCD_QUIRK_DELAY_BEFORE_DME_CMDS.
> 
> Fix the logic to update hba->last_dme_cmd_tstamp to ensure subsequent
> DME commands have the correct delay in the range of 0 to
> MIN_DELAY_BEFORE_DME_CMDS_US.
> 
> Update the timestamp at the end of the function to ensure it captures
> the latest time after any necessary delay has been applied.
> 
> Signed-off-by: Vamshi Gajjela <vamshigajjela@google.com>
> Fixes: cad2e03d8607 ("ufs: add support to allow non standard behaviours (quirks)")
> Cc: stable@vger.kernel.org
> ---
>   drivers/ufs/core/ufshcd.c | 11 ++++++++---
>   1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index dc757ba47522..406bda1585f6 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -4090,11 +4090,16 @@ static inline void ufshcd_add_delay_before_dme_cmd(struct ufs_hba *hba)
>   			min_sleep_time_us =
>   				MIN_DELAY_BEFORE_DME_CMDS_US - delta;
>   		else
> -			return; /* no more delay required */
> +			min_sleep_time_us = 0; /* no more delay required */
>   	}
>   
> -	/* allow sleep for extra 50us if needed */
> -	usleep_range(min_sleep_time_us, min_sleep_time_us + 50);
> +	if (min_sleep_time_us > 0) {
> +		/* allow sleep for extra 50us if needed */
> +		usleep_range(min_sleep_time_us, min_sleep_time_us + 50);
> +	}
> +
> +	/* update the last_dme_cmd_tstamp */
> +	hba->last_dme_cmd_tstamp = ktime_get();
>   }

Reviewed-by: Bart Van Assche <bvanassche@acm.org>

      reply	other threads:[~2024-07-29 18:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-24 13:51 Vamshi Gajjela
2024-07-29 18:26 ` 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=2bb22490-6209-4104-ae97-59d73fcb1d6d@acm.org \
    --to=bvanassche@acm.org \
    --cc=alim.akhtar@samsung.com \
    --cc=avri.altman@wdc.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=vamshigajjela@google.com \
    --cc=ygardi@codeaurora.org \
    /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

all inboxes | Powered by JetHome®