mt7601u_submit_rx() submits the RX buffers without holding dev->rx_lock, so the completion handler can run while the queue is only partially submitted. A buffer that completes that early is resubmitted by the RX tasklet ahead of the buffers that have not been submitted yet, and its next completion no longer matches rx_q.end: RX urb mismatch WARNING: ... at mt7601u_complete_rx The completion is then dropped and the buffer is not resubmitted. Submit the buffers under dev->rx_lock, as mt76u_submit_rx_buffers() does, so that no completion is processed until the whole queue is submitted and the URB order on the endpoint matches the queue order. Submissions are made with GFP_ATOMIC while the lock is held. Fixes: c869f77d6abb5 ("add mt7601u driver") Cc: stable@vger.kernel.org Co-developed-by: Bin Yu Signed-off-by: Bin Yu Co-developed-by: Cheng Wen Signed-off-by: Cheng Wen Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn> --- Changes in v2: - Serialise the initial submission instead of adding per-entry completion accounting. The accounting fixed the warning but could delay a buffer behind up to 15 later completions and deliver its frame out of order. --- drivers/net/wireless/mediatek/mt7601u/dma.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt7601u/dma.c b/drivers/net/wireless/mediatek/mt7601u/dma.c index 9a2e8b0511c7..1c8ddb8d9351 100644 --- a/drivers/net/wireless/mediatek/mt7601u/dma.c +++ b/drivers/net/wireless/mediatek/mt7601u/dma.c @@ -418,15 +418,23 @@ static int mt7601u_submit_rx_buf(struct mt7601u_dev *dev, static int mt7601u_submit_rx(struct mt7601u_dev *dev) { - int i, ret; + unsigned long flags; + int i, ret = 0; + /* Hold off completion handling until all buffers are submitted, + * otherwise a buffer that completes early is resubmitted by the RX + * tasklet ahead of the buffers that are not submitted yet and the + * completion order no longer matches the queue order. + */ + spin_lock_irqsave(&dev->rx_lock, flags); for (i = 0; i < dev->rx_q.entries; i++) { - ret = mt7601u_submit_rx_buf(dev, &dev->rx_q.e[i], GFP_KERNEL); + ret = mt7601u_submit_rx_buf(dev, &dev->rx_q.e[i], GFP_ATOMIC); if (ret) - return ret; + break; } + spin_unlock_irqrestore(&dev->rx_lock, flags); - return 0; + return ret; } static void mt7601u_free_rx(struct mt7601u_dev *dev) -- 2.34.1