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] [day] [month] [year] [list]
Message-ID: <42e6d455aaa34c68ba8d50ec22a17b79@realtek.com>
Date:   Mon, 7 Aug 2023 00:41:01 +0000
From:   Ping-Ke Shih <pkshih@...ltek.com>
To:     Martin Blumenstingl <martin.blumenstingl@...glemail.com>,
        "linux-wireless@...r.kernel.org" <linux-wireless@...r.kernel.org>
CC:     "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "jernej.skrabec@...il.com" <jernej.skrabec@...il.com>,
        "ulf.hansson@...aro.org" <ulf.hansson@...aro.org>,
        "kvalo@...nel.org" <kvalo@...nel.org>,
        "tony0620emma@...il.com" <tony0620emma@...il.com>,
        "Lukas F . Hartmann" <lukas@...re.com>
Subject: RE: [PATCH v2] wifi: rtw88: sdio: Honor the host max_req_size in the RX path



> -----Original Message-----
> From: Martin Blumenstingl <martin.blumenstingl@...glemail.com>
> Sent: Monday, August 7, 2023 2:17 AM
> To: linux-wireless@...r.kernel.org
> Cc: linux-kernel@...r.kernel.org; jernej.skrabec@...il.com; Ping-Ke Shih <pkshih@...ltek.com>;
> ulf.hansson@...aro.org; kvalo@...nel.org; tony0620emma@...il.com; Martin Blumenstingl
> <martin.blumenstingl@...glemail.com>; Lukas F . Hartmann <lukas@...re.com>
> Subject: [PATCH v2] wifi: rtw88: sdio: Honor the host max_req_size in the RX path
> 

[...]

> 
> 
>  drivers/net/wireless/realtek/rtw88/sdio.c | 30 +++++++++++++++++------
>  1 file changed, 23 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/net/wireless/realtek/rtw88/sdio.c b/drivers/net/wireless/realtek/rtw88/sdio.c
> index 2c1fb2dabd40..553b7e68ca3b 100644
> --- a/drivers/net/wireless/realtek/rtw88/sdio.c
> +++ b/drivers/net/wireless/realtek/rtw88/sdio.c
> @@ -500,19 +500,35 @@ static u32 rtw_sdio_get_tx_addr(struct rtw_dev *rtwdev, size_t size,
>  static int rtw_sdio_read_port(struct rtw_dev *rtwdev, u8 *buf, size_t count)
>  {
>         struct rtw_sdio *rtwsdio = (struct rtw_sdio *)rtwdev->priv;
> +       struct mmc_host *host = rtwsdio->sdio_func->card->host;
>         bool bus_claim = rtw_sdio_bus_claim_needed(rtwsdio);
>         u32 rxaddr = rtwsdio->rx_addr++;
> -       int ret;
> +       int ret = 0, err = 0;

nit: no need initializer of 'err'

> +       size_t bytes;
> 
>         if (bus_claim)
>                 sdio_claim_host(rtwsdio->sdio_func);
> 
> -       ret = sdio_memcpy_fromio(rtwsdio->sdio_func, buf,
> -                                RTW_SDIO_ADDR_RX_RX0FF_GEN(rxaddr), count);
> -       if (ret)
> -               rtw_warn(rtwdev,
> -                        "Failed to read %zu byte(s) from SDIO port 0x%08x",
> -                        count, rxaddr);
> +       while (count > 0) {
> +               bytes = min_t(size_t, host->max_req_size, count);
> +
> +               err = sdio_memcpy_fromio(rtwsdio->sdio_func, buf,
> +                                        RTW_SDIO_ADDR_RX_RX0FF_GEN(rxaddr),
> +                                        bytes);
> +               if (err) {
> +                       rtw_warn(rtwdev,
> +                                "Failed to read %zu byte(s) from SDIO port 0x%08x: %d",
> +                                bytes, rxaddr, err);
> +                       ret = err;

I think this intends to return an error to callers if one error presents among
N times read. Would you like to point out this in comment as well? Because I want
to say we don't need 'err' at first glance, but this is indeed needed. 

> +                       /* Don't stop here - instead drain the remaining data
> +                        * from the card's buffer, else the card will return
> +                        * corrupt data for the next rtw_sdio_read_port() call.
> +                        */
> +               }
> +
> +               count -= bytes;
> +               buf += bytes;
> +       }
> 
>         if (bus_claim)
>                 sdio_release_host(rtwsdio->sdio_func);
> --
> 2.41.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ