From: Ping-Ke Shih <pkshih@realtek.com>
To: Bitterblue Smith <rtl8821cerfe2@gmail.com>,
"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>
Cc: Sascha Hauer <sha@pengutronix.de>
Subject: RE: rtw88: alloc_skb(32768, GFP_ATOMIC) fails, driver gets stuck
Date: Tue, 1 Oct 2024 01:25:59 +0000 [thread overview]
Message-ID: <ff98c33e797c4df3aee29a46229ee7ee@realtek.com> (raw)
In-Reply-To: <baca0d5d-072e-4003-ab4a-ecc524d6b89b@gmail.com>
Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
>
> alloc_skb fails (silently) therefore the RX URB is not submitted
> ever again. There are only 4 RX URBs.
Though only 4 RX URB, it might be possible more than 4 RX skb.
In rtw_usb_read_port_complete(), queue RX skb into rtwusb->rx_queue, and kick
off rx_work. It means some RX skb are inflight, but not sure how many.
>
> static void rtw_usb_rx_resubmit(struct rtw_usb *rtwusb, struct rx_usb_ctrl_block *rxcb)
> {
> struct rtw_dev *rtwdev = rtwusb->rtwdev;
> int error;
>
> rxcb->rx_skb = alloc_skb(RTW_USB_MAX_RECVBUF_SZ, GFP_ATOMIC);
> if (!rxcb->rx_skb)
> return;
>
> usb_fill_bulk_urb(rxcb->rx_urb, rtwusb->udev,
> usb_rcvbulkpipe(rtwusb->udev, rtwusb->pipe_in),
> rxcb->rx_skb->data, RTW_USB_MAX_RECVBUF_SZ,
> rtw_usb_read_port_complete, rxcb);
>
> error = usb_submit_urb(rxcb->rx_urb, GFP_ATOMIC);
>
> I added an error message there:
>
> rxcb->rx_skb = alloc_skb(RTW_USB_MAX_RECVBUF_SZ, GFP_ATOMIC);
> if (!rxcb->rx_skb) {
> rtw_err(rtwdev, "failed to allocate rx_skb\n");
> return;
> }
My first thought is to change GFP_ATOMIC to GFP_KERNEL, but kernel documentation
notes that
"NEVER SLEEP IN A COMPLETION HANDLER. These are often called in atomic context."
However, I feel it is possible to do rtw_usb_rx_resubmit() in a work.
Another thought is to allocate a new skb with size urb->actual_length, and
copy received data to the new skb, and queue to rtwusb->rx_queue. Then reuse
the original rx_skb. This thought is based on what urb->actual_length would
be smaller than RTW_USB_MAX_RECVBUF_SZ, but not very sure if this is fact.
next prev parent reply other threads:[~2024-10-01 1:26 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-25 11:46 rtw88: USB devices randomly stop receiving anything Bitterblue Smith
2024-09-26 13:04 ` petter
2024-09-26 16:51 ` Bitterblue Smith
2024-09-27 6:44 ` petter
2024-09-29 11:43 ` Bitterblue Smith
2024-09-30 20:56 ` rtw88: alloc_skb(32768, GFP_ATOMIC) fails, driver gets stuck Bitterblue Smith
2024-10-01 1:25 ` Ping-Ke Shih [this message]
2024-10-07 22:03 ` Bitterblue Smith
2024-10-02 10:58 ` Kalle Valo
2024-10-03 4:26 ` Ping-Ke Shih
2024-10-06 15:43 ` Michał Pecio
2024-10-07 22:04 ` Bitterblue Smith
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=ff98c33e797c4df3aee29a46229ee7ee@realtek.com \
--to=pkshih@realtek.com \
--cc=linux-wireless@vger.kernel.org \
--cc=rtl8821cerfe2@gmail.com \
--cc=sha@pengutronix.de \
/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;
as well as URLs for NNTP newsgroup(s).