mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Troy Mitchell" <troy.mitchell@linux.spacemit.com>
To: "Muhammad Bilal" <meatuni001@gmail.com>, <andrew+netdev@lunn.ch>
Cc: <davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>,
	<pabeni@redhat.com>, <dlan@kernel.org>, <wangruikang@iscas.ac.cn>,
	<vadim.fedorenko@linux.dev>, <maxime.chevallier@bootlin.com>,
	<troy.mitchell@linux.spacemit.com>, <netdev@vger.kernel.org>,
	<linux-riscv@infradead.org>, <spacemit@lists.linux.dev>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] net: spacemit: clear TX descriptor on fragment mapping failure
Date: Mon, 21 Sep 2026 22:00:08 +0800	[thread overview]
Message-ID: <DLL1RG8HO5F4.3SW5317Y4S1F8@linux.spacemit.com> (raw)
In-Reply-To: <20260919191937.271202-1-meatuni001@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1517 bytes --]

On Sun Sep 20, 2026 at 3:19 AM +08, Muhammad Bilal wrote:
> emac_tx_mem_map() writes TX_DESC_0_OWN into the ring descriptor for
> every slot beyond old_head as soon as that slot's memset()'d local
> copy is committed with "*tx_desc_addr = tx_desc", i.e. before the
> buffers for that slot have necessarily all been mapped successfully.
> If emac_tx_map_frag() then fails on a later fragment, the err_free_skb
> path calls emac_free_tx_buf() to unmap and drop the skb, but leaves
> the already-written descriptor memory untouched, and tx_ring->head is
> never advanced past old_head (the "tx_ring->head = head" store is
> skipped by the goto).
>
> So a slot between old_head and the rolled-back head can be left with
> TX_DESC_0_OWN set and buffer_addr_{1,2} pointing at DMA mappings that
> emac_free_tx_buf() just tore down, while software considers that slot
> free again. The next successful emac_tx_mem_map() call only rebuilds
> old_head itself; if the DMA engine auto-advances into the following
> descriptor once it finishes old_head's packet, it will fetch that
> stale, already-unmapped address.
>
> emac_tx_clean_desc() already treats emac_free_tx_buf() and clearing
> the descriptor as a pair when reclaiming completed descriptors; do
> the same in the mapping failure path.
>
> Fixes: bfec6d7f2001 ("net: spacemit: Add K1 Ethernet MAC")
> Signed-off-by: Muhammad Bilal <meatuni001@gmail.com>
Reviewed-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>


-- 
Troy Mitchell


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 248 bytes --]

  parent reply	other threads:[~2026-09-21 14:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-19 19:19 Muhammad Bilal
2026-09-21 11:17 ` Vivian Wang
2026-09-21 14:00 ` Troy Mitchell [this message]
2026-09-22 11:10 ` patchwork-bot+netdevbpf

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=DLL1RG8HO5F4.3SW5317Y4S1F8@linux.spacemit.com \
    --to=troy.mitchell@linux.spacemit.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=dlan@kernel.org \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@infradead.org \
    --cc=maxime.chevallier@bootlin.com \
    --cc=meatuni001@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=spacemit@lists.linux.dev \
    --cc=vadim.fedorenko@linux.dev \
    --cc=wangruikang@iscas.ac.cn \
    /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

all inboxes | Powered by JetHome®