On Nov 24, Felix Fietkau wrote: > While MT76_MCU_RESET is set, mt76_dma_tx_queue_skb_raw() drops a > command with the error of a full ring or a failed DMA mapping. The SDIO > path queues the command, reports success and skips it. The USB path > sends it. The caller thus cannot tell such a command from one whose > answer the reset cut off. > > Do not send a command that starts while the bit is set. Return an error > that no other step of the send gives. The interrupt path can set the > bit after this test. Return the same error from the raw TX of the DMA > path for that case. > > Signed-off-by: Felix Fietkau Reviewed-by: Lorenzo Bianconi > --- > drivers/net/wireless/mediatek/mt76/dma.c | 6 ++++-- > drivers/net/wireless/mediatek/mt76/mcu.c | 6 ++++++ > 2 files changed, 10 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c > index 8c0403820299..f5203f39e6b1 100644 > --- a/drivers/net/wireless/mediatek/mt76/dma.c > +++ b/drivers/net/wireless/mediatek/mt76/dma.c > @@ -637,8 +637,10 @@ mt76_dma_tx_queue_skb_raw(struct mt76_dev *dev, struct mt76_queue *q, > struct mt76_queue_buf buf = {}; > dma_addr_t addr; > > - if (test_bit(MT76_MCU_RESET, &dev->phy.state)) > - goto error; > + if (test_bit(MT76_MCU_RESET, &dev->phy.state)) { > + dev_kfree_skb(skb); > + return -ESHUTDOWN; > + } > > if (q->queued + 1 >= q->ndesc - 1) > goto error; > diff --git a/drivers/net/wireless/mediatek/mt76/mcu.c b/drivers/net/wireless/mediatek/mt76/mcu.c > index 7149b2f7aafd..e19fd1bbd911 100644 > --- a/drivers/net/wireless/mediatek/mt76/mcu.c > +++ b/drivers/net/wireless/mediatek/mt76/mcu.c > @@ -91,6 +91,12 @@ int mt76_mcu_skb_send_and_get_msg(struct mt76_dev *dev, struct sk_buff *skb, > goto out; > } > > + if (test_bit(MT76_MCU_RESET, &dev->phy.state)) { > + orig_skb = skb; > + ret = -ESHUTDOWN; > + goto out; > + } > + > if (dev->mcu_ops->mcu_skb_prepare_msg) { > orig_skb = skb; > ret = dev->mcu_ops->mcu_skb_prepare_msg(dev, skb, cmd, &seq); > -- > 2.47.3 > >