From: netdev-bot+sashiko@kernel.org
To: kaloz@kernel.org
Cc: tsbogend@alpha.franken.de, netdev@vger.kernel.org,
andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, linux-mips@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v2 1/2] net: sgi: ioc3-eth: apply the DMA attributes only to 64-bit addresses
Date: Thu, 19 Nov 2026 10:22:50 +0000 [thread overview]
Message-ID: <179508377005.3136.7735552086490209084@kernel.org> (raw)
In-Reply-To: <20261116102115.27574-2-kaloz@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 (1) · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] On 32-bit direct-window DMA addresses, the new helpers drop
all Bridge DMA attributes, and nothing provides them another way.
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but it is in
ioc3_init(), the function the patch changes.
--
net: sgi: ioc3-eth: apply the DMA attributes only to 64-bit addresses
This commit changes ioc3_map() so it leaves out the Bridge DMA attributes
when the DMA address has no target widget in bits 63:60, which is the case
for a 32-bit direct window address. It also replaces ERBAR_VAL with
ioc3_erbar(), which returns 0 for such addresses. ioc3_init() now picks
the ERBAR value from the RX ring DMA address. The goal is to prepare for
IP35 support, which will give the IOC3 window addresses.
> diff --git a/drivers/net/ethernet/sgi/ioc3-eth.c b/drivers/net/ethernet/sgi/ioc3-eth.c
> index 009f37105eafd..25139cf5ff62c 100644
> --- a/drivers/net/ethernet/sgi/ioc3-eth.c
> +++ b/drivers/net/ethernet/sgi/ioc3-eth.c
> @@ -152,19 +152,37 @@ static inline int ioc3_alloc_skb(struct ioc3_private *ip, struct sk_buff **skb,
> }
>
> #ifdef CONFIG_PCI_XTALK_BRIDGE
> +/* A Bridge 64-bit direct-mapped DMA address carries the target widget in
> + * bits 63:60 and the DMA attributes below it. An address in the 32-bit
> + * direct window carries neither, so attributes OR-ed onto one form a
> + * 64-bit address aimed at widget 0.
> + */
> static inline unsigned long ioc3_map(dma_addr_t addr, unsigned long attr)
> {
> + if (!(addr & PCI64_ATTR_TARG_MASK))
> + return addr;
> +
> return (addr & ~PCI64_ATTR_BAR) | attr;
> }
>
> -#define ERBAR_VAL (ERBAR_BARRIER_BIT << ERBAR_RXBARR_SHIFT)
> +/* The RX barrier's upper address bits follow the same form. */
> +static inline u32 ioc3_erbar(dma_addr_t addr)
> +{
> + if (!(addr & PCI64_ATTR_TARG_MASK))
> + return 0;
> +
> + return ERBAR_BARRIER_BIT << ERBAR_RXBARR_SHIFT;
> +}
[Severity: Medium]
For a 32-bit direct window address, ioc3_map() now returns the bare
address and ioc3_erbar() returns 0. Where do the dropped attributes come
from in that case?
Three attributes are lost. ioc3_rx() and ioc3_alloc_rx_bufs() lose
PCI64_ATTR_BAR on the RX buffer pointers. ioc3_start() loses
PCI64_ATTR_PREC on the ring bases. ioc3_start_xmit() loses PCI64_ATTR_PREF
on the TX buffer pointers.
For 32-bit direct DMA the Bridge takes these from the per-slot Device(x)
register (BRIDGE_DEV_PREF, BRIDGE_DEV_PRECISE and BRIDGE_DEV_BARRIER in
BRIDGE_DEV_D32_BITS). The only code in the tree that writes
b_device[slot] is bridge_probe(), and it sets only the swap bit:
arch/mips/pci/pci-xtalk-bridge.c:bridge_probe() {
...
bridge_set(bc, b_device[slot].reg, BRIDGE_DEV_SWAP_DIR);
...
}
ERBAR is now 0 as well. What, then, orders the ERXBUF w0 valid-word store
after the payload stores? ioc3_rx() trusts that word before it reads the
frame:
while (w0 & ERXBUF_V) {
err = be32_to_cpu(rxb->err); /* It's valid ... */
Could the CPU see ERXBUF_V before the payload has landed, and pass a stale
or truncated frame up the stack?
There is a separate question about ioc3_init(), which picks the ERBAR
value from the coherent ring address:
writel(ioc3_erbar(ip->rxr_dma), ®s->erbar);
ERBAR applies to the last store into each RX buffer. Those buffers are
separate streaming mappings from ioc3_alloc_skb(). ioc3_map() decides per
address, so suppose the ring gets a 64-bit address and an RX buffer gets a
window address. Wouldn't ERBAR still OR the barrier attribute into the
upper bits of that buffer's last store, which gives the widget 0 address
this patch is meant to avoid? This assumes the IOC3 ORs ERBAR onto the
upper address bits.
None of this can be reached on in-tree platforms. phys_to_dma() returns
bc->baddr + paddr, and baddr has a non-zero target nibble on both IP27 and
IP30. Whether it triggers depends on how the IP35 support maps DMA and
programs Device(x).
The commit message also doesn't say that the RX barrier is turned off for
window addresses, or what replaces it. Could that be added?
> #else
> static inline unsigned long ioc3_map(dma_addr_t addr, unsigned long attr)
> {
[ ... ]
> @@ -727,7 +745,7 @@ static void ioc3_init(struct net_device *dev)
> readl(®s->emcr);
>
> /* Misc registers */
> - writel(ERBAR_VAL, ®s->erbar);
> + writel(ioc3_erbar(ip->rxr_dma), ®s->erbar);
[Severity: High]
This isn't a bug introduced by this patch, but ioc3_init() starts with a
synchronous timer delete, and both error-recovery callers hold
ip->ioc3_lock when they call it:
ioc3_init() {
timer_delete_sync(&ip->ioc3_timer); /* Kill if running */
...
}
ioc3_error() runs from the hardirq handler ioc3_interrupt() and does:
spin_lock(&ip->ioc3_lock);
...
ioc3_init(dev);
ioc3_timeout() does the same thing with spin_lock_irq(). The timer
callback takes the same lock:
ioc3_timer()
mii_check_media()
ioc3_setup_duplex()
spin_lock_irq(&ip->ioc3_lock);
Can this deadlock on SMP?
CPU A
ioc3_timer()
ioc3_setup_duplex()
spin_lock_irq(&ip->ioc3_lock) <- spins on the lock CPU B holds
CPU B
ioc3_error() or ioc3_timeout()
spin_lock(&ip->ioc3_lock)
ioc3_init()
timer_delete_sync() <- waits for CPU A's callback
Also, ioc3eth_probe() sets up the timer without TIMER_IRQSAFE:
timer_setup(&ip->ioc3_timer, ioc3_timer, 0);
So won't every hardirq call through ioc3_error() hit this check in
__timer_delete_sync()?
WARN_ON(in_hardirq() && !(timer->flags & TIMER_IRQSAFE));
ioc3_error() runs on EISR_RXOFLO or EISR_RXBUFOFLO, so incoming traffic
that outruns the RX ring is enough to trigger it.
Last, ioc3_error() calls ioc3_mii_init() but not ioc3_mii_start(), unlike
ioc3_timeout(). If the timer is never re-armed, does link and duplex
monitoring stop after an error recovery?
> readl(®s->etcdc); /* Clear on read */
> writel(15, ®s->ercsr); /* RX low watermark */
> writel(0, ®s->ertr); /* Interrupt immediately */
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116102115.27574-1-kaloz%40kernel.org
next prev parent reply other threads:[~2026-11-19 10:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 10:21 [PATCH net-next v2 0/2] net: sgi: ioc3-eth: two changes for the IOC3 on SGI IP35 machines Imre Kaloz
2026-11-16 10:21 ` [PATCH net-next v2 1/2] net: sgi: ioc3-eth: apply the DMA attributes only to 64-bit addresses Imre Kaloz
2026-11-19 10:22 ` netdev-bot+sashiko [this message]
2026-11-16 10:21 ` [PATCH net-next v2 2/2] net: sgi: ioc3-eth: take the MAC address from a device property Imre Kaloz
2026-11-19 10:22 ` netdev-bot+sashiko
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=179508377005.3136.7735552086490209084@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=kaloz@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=tsbogend@alpha.franken.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
all inboxes | Powered by JetHome®