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: <CAPDyKFpn5xB50eTomNM=4LbFDX4r154iY2Qk8GBiYb+vor0kbA@mail.gmail.com>
Date: Wed, 9 Apr 2025 15:04:37 +0200
From: Ulf Hansson <ulf.hansson@...aro.org>
To: Ricky Wu <ricky_wu@...ltek.com>
Cc: linux-kernel@...r.kernel.org, linux-mmc@...r.kernel.org, 
	viro@...iv.linux.org.uk
Subject: Re: [PATCH] mmc: rtsx: usb add 74 clocks in poweron flow

On Tue, 1 Apr 2025 at 04:51, Ricky Wu <ricky_wu@...ltek.com> wrote:
>
> SD spec definition:
> "Host provides at least 74 Clocks before issuing first command"
> After 1ms for the voltage stable then start issuing the Clock signals
>
> add if statement to issue/stop the clock signal to card:
> The power state from POWER_OFF to POWER_UP issue the signal to card,
> POWER_UP to POWER_ON stop the signal
>
> add 100ms delay in power_on to make sure the power cycle complete

Why 100ms? That sounds a lot to me?

Is this fixing a real problem or is just trying to better follow the spec?

>
> Signed-off-by: Ricky Wu <ricky_wu@...ltek.com>
> ---
>  drivers/mmc/host/rtsx_usb_sdmmc.c | 28 +++++++++++++++++++++++++---
>  1 file changed, 25 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mmc/host/rtsx_usb_sdmmc.c b/drivers/mmc/host/rtsx_usb_sdmmc.c
> index d229c2b83ea9..e5820b2bb380 100644
> --- a/drivers/mmc/host/rtsx_usb_sdmmc.c
> +++ b/drivers/mmc/host/rtsx_usb_sdmmc.c
> @@ -48,7 +48,7 @@ struct rtsx_usb_sdmmc {
>         bool                    ddr_mode;
>
>         unsigned char           power_mode;
> -
> +       unsigned char           prev_power_mode;
>  #ifdef RTSX_USB_USE_LEDS_CLASS
>         struct led_classdev     led;
>         char                    led_name[32];
> @@ -952,6 +952,8 @@ static int sd_power_on(struct rtsx_usb_sdmmc *host)
>         struct rtsx_ucr *ucr = host->ucr;
>         int err;
>
> +       msleep(100);
> +
>         dev_dbg(sdmmc_dev(host), "%s\n", __func__);
>         rtsx_usb_init_cmd(ucr);
>         rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_SELECT, 0x07, SD_MOD_SEL);
> @@ -1014,6 +1016,16 @@ static int sd_set_power_mode(struct rtsx_usb_sdmmc *host,
>                 unsigned char power_mode)
>  {
>         int err;
> +       int power_mode_temp;
> +       struct rtsx_ucr *ucr = host->ucr;
> +
> +       power_mode_temp = power_mode;
> +
> +       if ((power_mode == MMC_POWER_ON) && (host->power_mode == MMC_POWER_ON) &&
> +                       (host->prev_power_mode == MMC_POWER_UP)) {
> +               host->prev_power_mode = MMC_POWER_ON;
> +               rtsx_usb_write_register(ucr, SD_BUS_STAT, SD_CLK_TOGGLE_EN, 0x00);
> +       }
>
>         if (power_mode != MMC_POWER_OFF)
>                 power_mode = MMC_POWER_ON;
> @@ -1029,9 +1041,18 @@ static int sd_set_power_mode(struct rtsx_usb_sdmmc *host,
>                 err = sd_power_on(host);
>         }
>
> -       if (!err)
> -               host->power_mode = power_mode;
> +       if (!err) {
> +               if ((power_mode_temp == MMC_POWER_UP) && (host->power_mode == MMC_POWER_OFF)) {
> +                       host->prev_power_mode = MMC_POWER_UP;
> +                       rtsx_usb_write_register(ucr, SD_BUS_STAT, SD_CLK_TOGGLE_EN,
> +                                       SD_CLK_TOGGLE_EN);
> +               }
> +
> +               if ((power_mode_temp == MMC_POWER_OFF) && (host->power_mode == MMC_POWER_ON))
> +                       host->prev_power_mode = MMC_POWER_OFF;
>
> +               host->power_mode = power_mode;
> +       }
>         return err;
>  }
>
> @@ -1316,6 +1337,7 @@ static void rtsx_usb_init_host(struct rtsx_usb_sdmmc *host)
>         mmc->max_req_size = 524288;
>
>         host->power_mode = MMC_POWER_OFF;
> +       host->prev_power_mode = MMC_POWER_OFF;
>  }
>
>  static int rtsx_usb_sdmmc_drv_probe(struct platform_device *pdev)
> --
> 2.25.1
>

Kind regards
Uffe

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ