lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ff33de4f-d111-4499-afff-231baaccf61c@acm.org>
Date: Fri, 20 Sep 2024 11:23:37 -0700
From: Bart Van Assche <bvanassche@....org>
To: Avri Altman <avri.altman@....com>,
 "Martin K . Petersen" <martin.petersen@...cle.com>
Cc: linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] scsi: ufs: Do not open code read_poll_timeout

On 9/19/24 4:24 AM, Avri Altman wrote:
> ufshcd_wait_for_register practically does just that - replace with
> read_poll_timeout.
> 
> Signed-off-by: Avri Altman <avri.altman@....com>
> ---
>   drivers/ufs/core/ufshcd.c | 22 ++++++----------------
>   1 file changed, 6 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index 8ea5a82503a9..e9d06fab5f45 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -739,25 +739,15 @@ EXPORT_SYMBOL_GPL(ufshcd_delay_us);
>    * Return: -ETIMEDOUT on error, zero on success.
>    */
>   static int ufshcd_wait_for_register(struct ufs_hba *hba, u32 reg, u32 mask,
> -				u32 val, unsigned long interval_us,
> -				unsigned long timeout_ms)
> +				    u32 val, unsigned long interval_us,
> +				    unsigned long timeout_ms)
>   {
> -	int err = 0;
> -	unsigned long timeout = jiffies + msecs_to_jiffies(timeout_ms);
> -
> -	/* ignore bits that we don't intend to wait on */
> -	val = val & mask;
> +	u32 v;
>   
> -	while ((ufshcd_readl(hba, reg) & mask) != val) {
> -		usleep_range(interval_us, interval_us + 50);
> -		if (time_after(jiffies, timeout)) {
> -			if ((ufshcd_readl(hba, reg) & mask) != val)
> -				err = -ETIMEDOUT;
> -			break;
> -		}
> -	}
> +	val &= mask; /* ignore bits that we don't intend to wait on */
>   
> -	return err;
> +	return read_poll_timeout(ufshcd_readl, v, (v & mask) == val,
> +				 interval_us, timeout_ms * 1000, false, hba, reg);
>   }
>   
>   /**

Has it been considered to remove the ufshcd_wait_for_register() function
and to use read_poll_timeout() directly in the
ufshcd_wait_for_register() callers? The above patch makes
ufshcd_wait_for_register() so short that it's probably better to remove
this function entirely.

Thanks,

Bart.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ