From: Lorenzo Bianconi <lorenzo@kernel.org>
To: nbd@nbd.name
Cc: lorenzo.bianconi@redhat.com, linux-wireless@vger.kernel.org
Subject: Re: [PATCH] wifi: mt76: take into possible mt76_rx_token_consume failures
Date: Thu, 8 Dec 2022 11:41:56 +0100 [thread overview]
Message-ID: <Y5G/dH3vLLg//xL0@lore-desk> (raw)
In-Reply-To: <22857067961409cc4873a7c8b7aa6f18e3dbb324.1670449810.git.lorenzo@kernel.org>
[-- Attachment #1: Type: text/plain, Size: 3109 bytes --]
> Take into account possible error conditions of mt76_rx_token_consume
> routine in mt7915_mmio_wed_init_rx_buf() and mt76_dma_add_buf()
>
> Fixes: cd372b8c99c5 ("wifi: mt76: add WED RX support to mt76_dma_{add,get}_buf")
> Fixes: 4f831d18d12d ("wifi: mt76: mt7915: enable WED RX support")
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Hi Felix,
please drop this version, I will post a new one.
Regards,
Lorenzo
> ---
> drivers/net/wireless/mediatek/mt76/dma.c | 10 +++++++++-
> drivers/net/wireless/mediatek/mt76/mt7915/mmio.c | 7 +++++++
> drivers/net/wireless/mediatek/mt76/tx.c | 6 ++++--
> 3 files changed, 20 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c
> index e017d7529c2a..e1527a5a0b4d 100644
> --- a/drivers/net/wireless/mediatek/mt76/dma.c
> +++ b/drivers/net/wireless/mediatek/mt76/dma.c
> @@ -234,6 +234,9 @@ mt76_dma_add_buf(struct mt76_dev *dev, struct mt76_queue *q,
>
> rx_token = mt76_rx_token_consume(dev, (void *)skb, t,
> buf[0].addr);
> + if (rx_token < 0)
> + return -ENOMEM;
> +
> buf1 |= FIELD_PREP(MT_DMA_CTL_TOKEN, rx_token);
> ctrl = FIELD_PREP(MT_DMA_CTL_SD_LEN0, buf[0].len) |
> MT_DMA_CTL_TO_HOST;
> @@ -602,7 +605,12 @@ mt76_dma_rx_fill(struct mt76_dev *dev, struct mt76_queue *q)
> qbuf.addr = addr + offset;
> qbuf.len = len - offset;
> qbuf.skip_unmap = false;
> - mt76_dma_add_buf(dev, q, &qbuf, 1, 0, buf, t);
> + if (mt76_dma_add_buf(dev, q, &qbuf, 1, 0, buf, t) < 0) {
> + dma_unmap_single(dev->dma_dev, addr, len,
> + DMA_FROM_DEVICE);
> + skb_free_frag(buf);
> + break;
> + }
> frames++;
> }
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mmio.c b/drivers/net/wireless/mediatek/mt76/mt7915/mmio.c
> index 0a95c3da241b..8388e2a65853 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7915/mmio.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mmio.c
> @@ -653,6 +653,13 @@ static u32 mt7915_mmio_wed_init_rx_buf(struct mtk_wed_device *wed, int size)
>
> desc->buf0 = cpu_to_le32(phy_addr);
> token = mt76_rx_token_consume(&dev->mt76, ptr, t, phy_addr);
> + if (token < 0) {
> + dma_unmap_single(dev->mt76.dma_dev, phy_addr,
> + wed->wlan.rx_size, DMA_TO_DEVICE);
> + skb_free_frag(ptr);
> + goto unmap;
> + }
> +
> desc->token |= cpu_to_le32(FIELD_PREP(MT_DMA_CTL_TOKEN,
> token));
> desc++;
> diff --git a/drivers/net/wireless/mediatek/mt76/tx.c b/drivers/net/wireless/mediatek/mt76/tx.c
> index 24568b98ed9d..363d861a1d3e 100644
> --- a/drivers/net/wireless/mediatek/mt76/tx.c
> +++ b/drivers/net/wireless/mediatek/mt76/tx.c
> @@ -766,8 +766,10 @@ int mt76_rx_token_consume(struct mt76_dev *dev, void *ptr,
> GFP_ATOMIC);
> spin_unlock_bh(&dev->rx_token_lock);
>
> - t->ptr = ptr;
> - t->dma_addr = phys;
> + if (token >= 0) {
> + t->ptr = ptr;
> + t->dma_addr = phys;
> + }
>
> return token;
> }
> --
> 2.38.1
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
prev parent reply other threads:[~2022-12-08 10:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-07 21:51 [PATCH] wifi: mt76: take into possible mt76_rx_token_consume failures Lorenzo Bianconi
2022-12-08 10:41 ` Lorenzo Bianconi [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=Y5G/dH3vLLg//xL0@lore-desk \
--to=lorenzo@kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=lorenzo.bianconi@redhat.com \
--cc=nbd@nbd.name \
/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