From: Ping-Ke Shih <pkshih@realtek.com>
To: "luka.gejak@linux.dev" <luka.gejak@linux.dev>,
"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Michael Straube" <straube.linux@gmail.com>,
Bitterblue Smith <rtl8821cerfe2@gmail.com>,
Peter Robinson <pbrobinson@gmail.com>,
"Hans de Goede" <johannes.goede@oss.qualcomm.com>
Subject: RE: [PATCH v7 4/6] wifi: rtw88: sdio: track free TX pages and OQT credits for RTL8723BS
Date: Tue, 25 Aug 2026 06:12:58 +0000 [thread overview]
Message-ID: <17c3c1f641fe41c4bfacb989af4b75a6@realtek.com> (raw)
In-Reply-To: <20260820090412.19574-5-luka.gejak@linux.dev>
luka.gejak@linux.dev <luka.gejak@linux.dev> wrote:
[...]
> static int rtw_sdio_write_port(struct rtw_dev *rtwdev, struct sk_buff *skb,
> enum rtw_tx_queue_type queue)
> {
> struct rtw_sdio *rtwsdio = (struct rtw_sdio *)rtwdev->priv;
> + bool rtl8723bs = rtw_is_8723bs(rtwdev);
> + unsigned int pages;
> + size_t write_size;
> bool bus_claim;
> size_t txsize;
> u32 txaddr;
> @@ -645,31 +837,73 @@ static int rtw_sdio_write_port(struct rtw_dev *rtwdev, struct sk_buff *skb,
> if (!txaddr)
> return -EINVAL;
>
> - txsize = sdio_align_size(rtwsdio->sdio_func, skb->len);
> + if (rtl8723bs) {
> + txsize = round_up(skb->len, 4);
> + write_size = txsize > RTW_SDIO_BLOCK_SIZE ?
> + round_up(txsize, RTW_SDIO_BLOCK_SIZE) : txsize;
> +
> + /*
> + * __skb_pad() zeroes the padding without moving skb->len and
> + * reallocates when the skb is cloned or short on tailroom,
> + * so the padding can never land in a buffer a clone still
> + * shares. It must not free the skb on failure: both callers
> + * still own it, one requeues it and the other frees it.
> + */
I think you only need to note 'not free the skb on failure'.
> + if (write_size > skb->len) {
And move comment here to note __skb_pad().
By the way, we can have a local variable 'pad_size = write_size > skb->len'.
Then,
if (pad_size) {
ret = __skb_pad( ..., pad_size, ...);
...
}
> + ret = __skb_pad(skb, write_size - skb->len, false);
> + if (ret)
> + return ret;
> + }
> + } else {
> + txsize = sdio_align_size(rtwsdio->sdio_func, skb->len);
> + write_size = txsize;
> + }
> +
> + /*
> + * The free page check, the output queue wait and the accounting
> + * after the transfer must not interleave with another writer: the
> + * TX worker and the H2C path run concurrently, and two writers that
> + * both pass the checks can claim the same pages and output queue
> + * entry, after which the chip silently discards whichever transfer
> + * arrives second.
> + */
Not sure if the comment along declaration of tx_credit_lock is enough?
If so, maybe we don't need this comment.
> + if (rtl8723bs)
> + mutex_lock(&rtwsdio->tx_credit_lock);
guard(mutex)(&rtwsdio->tx_credit_lock);
I think you can add lockdep_assert_held() to the places the locks (mutex)
must be held, and run test if somewhere throw warning (must not).
>
> ret = rtw_sdio_check_free_txpg(rtwdev, queue, txsize);
> if (ret)
> - return ret;
> + goto out_unlock;
> +
> + if (rtl8723bs) {
> + ret = rtw_sdio_8723bs_wait_tx_oqt(rtwdev);
> + if (ret)
> + goto out_unlock;
> + }
>
> if (!IS_ALIGNED((unsigned long)skb->data, RTW_SDIO_DATA_PTR_ALIGN))
> rtw_warn(rtwdev, "Got unaligned SKB in %s() for queue %u\n",
> __func__, queue);
>
> bus_claim = rtw_sdio_bus_claim_needed(rtwsdio);
> -
> if (bus_claim)
> sdio_claim_host(rtwsdio->sdio_func);
> -
> - ret = sdio_memcpy_toio(rtwsdio->sdio_func, txaddr, skb->data, txsize);
> -
> + ret = sdio_memcpy_toio(rtwsdio->sdio_func, txaddr, skb->data,
> + write_size);
> if (bus_claim)
> sdio_release_host(rtwsdio->sdio_func);
>
> - if (ret)
> + if (ret) {
> rtw_warn(rtwdev,
> "Failed to write %zu byte(s) to SDIO port 0x%08x",
> - txsize, txaddr);
> + write_size, txaddr);
> + } else if (rtl8723bs) {
> + pages = DIV_ROUND_UP(txsize, rtwdev->chip->page_size);
> + rtw_sdio_8723bs_consume_txpg(rtwdev, queue, pages);
> + }
>
> +out_unlock:
> + if (rtl8723bs)
> + mutex_unlock(&rtwsdio->tx_credit_lock);
> return ret;
> }
>
[...]
next prev parent reply other threads:[~2026-08-25 6:13 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-20 9:04 [PATCH v7 0/6] wifi: rtw88: preparations for RTL8723B/RTL8723BS luka.gejak
2026-08-20 9:04 ` [PATCH v7 1/6] wifi: rtw88: add the RTL8723B chip type and SDIO helper luka.gejak
2026-08-20 9:04 ` [PATCH v7 2/6] wifi: rtw88: rx: mark zero length packets on RTL8723BS luka.gejak
2026-08-20 9:04 ` [PATCH v7 3/6] wifi: rtw88: tx: extend the TX report purge timeout to RTL8723BS luka.gejak
2026-08-20 9:04 ` [PATCH v7 4/6] wifi: rtw88: sdio: track free TX pages and OQT credits for RTL8723BS luka.gejak
2026-08-25 6:12 ` Ping-Ke Shih [this message]
2026-08-25 7:20 ` Luka Gejak
2026-08-25 7:25 ` Ping-Ke Shih
2026-08-25 7:33 ` Luka Gejak
2026-08-25 7:50 ` Ping-Ke Shih
2026-08-25 8:07 ` Luka Gejak
2026-08-25 8:22 ` Ping-Ke Shih
2026-08-25 8:32 ` Luka Gejak
2026-08-25 8:38 ` Ping-Ke Shih
2026-08-25 8:42 ` Luka Gejak
2026-08-25 8:49 ` Ping-Ke Shih
2026-08-20 9:04 ` [PATCH v7 5/6] wifi: rtw88: sdio: set up RX aggregation and interrupts " luka.gejak
2026-08-20 9:04 ` [PATCH v7 6/6] wifi: rtw88: sdio: add TX back-pressure and retry on page starvation luka.gejak
2026-08-25 6:36 ` Ping-Ke Shih
2026-08-25 7:22 ` Luka Gejak
2026-08-25 8:27 ` Ping-Ke Shih
2026-08-22 16:51 ` [PATCH v7 0/6] wifi: rtw88: preparations for RTL8723B/RTL8723BS Luka Gejak
2026-08-23 6:00 ` Luka Gejak
2026-08-25 7:08 ` Ping-Ke Shih
2026-08-25 7:27 ` Luka Gejak
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=17c3c1f641fe41c4bfacb989af4b75a6@realtek.com \
--to=pkshih@realtek.com \
--cc=johannes.goede@oss.qualcomm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=luka.gejak@linux.dev \
--cc=pbrobinson@gmail.com \
--cc=rtl8821cerfe2@gmail.com \
--cc=straube.linux@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.