public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ping-Ke Shih <pkshih@realtek.com>
To: Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
	"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"jernej.skrabec@gmail.com" <jernej.skrabec@gmail.com>,
	"ulf.hansson@linaro.org" <ulf.hansson@linaro.org>,
	"kvalo@kernel.org" <kvalo@kernel.org>,
	"tony0620emma@gmail.com" <tony0620emma@gmail.com>,
	"Lukas F . Hartmann" <lukas@mntre.com>
Subject: RE: [PATCH v2] wifi: rtw88: sdio: Honor the host max_req_size in the RX path
Date: Mon, 7 Aug 2023 00:41:01 +0000	[thread overview]
Message-ID: <42e6d455aaa34c68ba8d50ec22a17b79@realtek.com> (raw)
In-Reply-To: <20230806181656.2072792-1-martin.blumenstingl@googlemail.com>



> -----Original Message-----
> From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> Sent: Monday, August 7, 2023 2:17 AM
> To: linux-wireless@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org; jernej.skrabec@gmail.com; Ping-Ke Shih <pkshih@realtek.com>;
> ulf.hansson@linaro.org; kvalo@kernel.org; tony0620emma@gmail.com; Martin Blumenstingl
> <martin.blumenstingl@googlemail.com>; Lukas F . Hartmann <lukas@mntre.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


      reply	other threads:[~2023-08-07  0:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-06 18:16 [PATCH v2] wifi: rtw88: sdio: Honor the host max_req_size in the RX path Martin Blumenstingl
2023-08-07  0:41 ` Ping-Ke Shih [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=42e6d455aaa34c68ba8d50ec22a17b79@realtek.com \
    --to=pkshih@realtek.com \
    --cc=jernej.skrabec@gmail.com \
    --cc=kvalo@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lukas@mntre.com \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=tony0620emma@gmail.com \
    --cc=ulf.hansson@linaro.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