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: <d16537da-8256-f7ed-677d-011654c62bd4@rock-chips.com>
Date:   Fri, 7 May 2021 09:48:32 +0800
From:   Shawn Lin <shawn.lin@...k-chips.com>
To:     Ulf Hansson <ulf.hansson@...aro.org>, linux-mmc@...r.kernel.org,
        Adrian Hunter <adrian.hunter@...el.com>
Cc:     shawn.lin@...k-chips.com, Linus Walleij <linus.walleij@...aro.org>,
        Wolfram Sang <wsa+renesas@...g-engineering.com>,
        Avri Altman <avri.altman@....com>,
        Masami Hiramatsu <masami.hiramatsu@...aro.org>,
        linux-block@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 03/11] mmc: core: Re-structure some code in
 __mmc_poll_for_busy()

On 2021/5/5 0:12, Ulf Hansson wrote:
> To make the code a bit more understandable, let's move the check about
> whether polling is allowed or not, out to the caller instead. In this way,
> we can also drop the send_status in-parameter, so let's do that.

Everytime I check the parameters for busy polling, I have to look very
closely to make sure what the true or false stands for. So reducing the
parameters here make sense.

Reviewed-by: Shawn Lin <shawn.lin@...k-chips.com>

> 
> Signed-off-by: Ulf Hansson <ulf.hansson@...aro.org>
> ---
>   drivers/mmc/core/mmc_ops.c | 27 +++++++++++++--------------
>   1 file changed, 13 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
> index 66ae699a410f..ccaee1cb7ff5 100644
> --- a/drivers/mmc/core/mmc_ops.c
> +++ b/drivers/mmc/core/mmc_ops.c
> @@ -465,8 +465,7 @@ static int mmc_busy_status(struct mmc_card *card, bool retry_crc_err,
>   }
>   
>   static int __mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms,
> -			       bool send_status, bool retry_crc_err,
> -			       enum mmc_busy_cmd busy_cmd)
> +			       bool retry_crc_err, enum mmc_busy_cmd busy_cmd)
>   {
>   	struct mmc_host *host = card->host;
>   	int err;
> @@ -475,16 +474,6 @@ static int __mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms,
>   	bool expired = false;
>   	bool busy = false;
>   
> -	/*
> -	 * In cases when not allowed to poll by using CMD13 or because we aren't
> -	 * capable of polling by using ->card_busy(), then rely on waiting the
> -	 * stated timeout to be sufficient.
> -	 */
> -	if (!send_status && !host->ops->card_busy) {
> -		mmc_delay(timeout_ms);
> -		return 0;
> -	}
> -
>   	timeout = jiffies + msecs_to_jiffies(timeout_ms) + 1;
>   	do {
>   		/*
> @@ -518,7 +507,7 @@ static int __mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms,
>   int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms,
>   		      enum mmc_busy_cmd busy_cmd)
>   {
> -	return __mmc_poll_for_busy(card, timeout_ms, true, false, busy_cmd);
> +	return __mmc_poll_for_busy(card, timeout_ms, false, busy_cmd);
>   }
>   
>   bool mmc_prepare_busy_cmd(struct mmc_host *host, struct mmc_command *cmd,
> @@ -591,8 +580,18 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
>   		mmc_host_is_spi(host))
>   		goto out_tim;
>   
> +	/*
> +	 * If the host doesn't support HW polling via the ->card_busy() ops and
> +	 * when it's not allowed to poll by using CMD13, then we need to rely on
> +	 * waiting the stated timeout to be sufficient.
> +	 */
> +	if (!send_status && !host->ops->card_busy) {
> +		mmc_delay(timeout_ms);
> +		goto out_tim;
> +	}
> +
>   	/* Let's try to poll to find out when the command is completed. */
> -	err = __mmc_poll_for_busy(card, timeout_ms, send_status, retry_crc_err,
> +	err = __mmc_poll_for_busy(card, timeout_ms, retry_crc_err,
>   				  MMC_BUSY_CMD6);
>   	if (err)
>   		goto out;
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ