From: sashiko-bot@kernel.org
To: "Wadim Mueller" <wafgo01@gmail.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [RFC PATCH net-next 2/2] net: ethernet: broadcom: Add BCMBCA SYSTEMPORT driver
Date: Sat, 05 Dec 2026 14:37:52 +0000 [thread overview]
Message-ID: <sashiko-outbox-251636@kernel.org> (raw)
In-Reply-To: <20261204143652.386911-3-wafgo01@gmail.com>
Thank you for your contribution! Sashiko AI review found 14 potential
issues to consider:
- [High] net: bcmbca_sysport: TX queue stop/wake race and missing
tx_cons ordering
- [High] net: bcmbca_sysport: intrl2_ack() after NAPI poll drops RX and
TX interrupts
- [High] net: bcmbca_sysport: unmasked INTRL2 bits and request_irq()
before napi_enable()
- [High] net: bcmbca_sysport: dma_wmb() with writel_relaxed() for
RDMA_CINDEX(0)
- [Medium] net: bcmbca_sysport: DMA rings freed while RDMA/TDMA remain
active on open error
- [Medium] net: bcmbca_sysport: sysport_stop() masks INTRL2 before
napi_disable()
- [Medium] net: bcmbca_sysport: misplaced dma_rmb() before reading
csb[0] in sysport_tx_poll()
- [Medium] net: bcmbca_sysport: non-atomic 32-bit ndev->stats updates
race with dev_get_stats()
- [Medium] net: bcmbca_sysport: redundant spin_lock_bh() in
sysport_xmit() breaks netpoll
- [Medium] net: bcmbca_sysport: missing UMAC_MAX_FRAME_LEN setup in
sysport_hw_init()
- [Medium] net: bcmbca_sysport: missing ndo_set_rx_mode breaks
promiscuous mode
- [Medium] net: bcmbca_sysport: inverted clear mask ~0xff00U in
sysport_rmw()
- [Medium] net: bcmbca_sysport: misplaced dma_rmb() before csb read in
sysport_tx_poll()
- [Low] net: bcmbca_sysport: missing tx_dropped count on skb_put_padto()
failure
--
commit 83a74249758ec80b0f1497252bcdae8214cd9ef7
Author: Wadim Mueller <wafgo01@gmail.com>
net: ethernet: broadcom: Add BCMBCA SYSTEMPORT driver
This commit adds a new Ethernet driver for the Broadcom BCMBCA SYSTEMPORT
controller in BCM47622 family SoCs, supporting one RX queue and one TX ring
with UniMAC, phylink, and DDR descriptor rings.
> diff --git a/drivers/net/ethernet/broadcom/bcmbca_sysport.c b/drivers/net/ethernet/broadcom/bcmbca_sysport.c
> new file mode 100644
> index 0000000000000..27816de88ecbd
> --- /dev/null
> +++ b/drivers/net/ethernet/broadcom/bcmbca_sysport.c
> @@ -0,0 +1,891 @@
[ ... ]
> +static int sysport_rx_poll(struct napi_struct *napi, int budget)
> +{
> + struct bcmbca_sysport *priv = container_of(napi, struct bcmbca_sysport, rx_napi);
> + struct net_device *ndev = priv->ndev;
> + int done = 0;
> + u16 pindex;
> +
> + pindex = sysport_readl(priv, RDMA_PINDEX(0));
[ ... ]
> + ndev->stats.rx_packets++;
> + ndev->stats.rx_bytes += len;
> + napi_gro_receive(napi, skb);
> +next:
> + priv->rx_cons++;
> + done++;
> + }
[Severity: Medium]
Do these plain ndev->stats updates race with dev_get_stats() and wrap on
32-bit ARM?
Because sysport_netdev_ops defines neither ndo_get_stats64 nor ndo_get_stats,
dev_get_stats() reads ndev->stats via atomic_long_read() in
netdev_stats_to_stats64(). Plain ++ and += updates in sysport_rx_poll(),
sysport_tx_poll(), and sysport_xmit() violate the netdevice.h contract, and
32-bit rx_bytes/tx_bytes counters wrap every 4 GiB on BCM47622.
Implementing ndo_get_stats64 with u64_stats_sync counters (or using
DEV_STATS_INC()/DEV_STATS_ADD() for drop/error counters) avoids both issues.
> + dma_wmb();
> + sysport_writel(priv, priv->rx_cons, RDMA_CINDEX(0));
[Severity: High]
Does dma_wmb() order the coherent priv->rx_ring descriptor writes ahead of
the writel_relaxed() inside sysport_writel() on ARM?
Per Documentation/memory-barriers.txt, dma_wmb() does not order normal memory
writes against MMIO writes (on 32-bit ARM it is only dmb(oshst), whereas
writel() executes wmb()). The RDMA_CINDEX(0) doorbell can reach hardware
before the new RX descriptors are visible in DDR, letting RDMA DMA into a
previously unmapped buffer.
Using writel(priv->rx_cons, priv->base + RDMA_CINDEX(0)) here, as
sysport_xmit() already does for the TX doorbell, ensures proper ordering.
> + if (done < budget && napi_complete_done(napi, done)) {
> + intrl2_ack(priv, 0);
> + intrl2_unmask(priv, 0);
> + }
[Severity: High]
Can calling intrl2_ack() after polling drop RX and TX completion interrupts?
RDMA_PINDEX(0) is sampled once at the start of sysport_rx_poll(). Any frame
that arrives during the poll advances RDMA_PINDEX(0) and latches BIT(0) in
INTRL2(0), which intrl2_ack(priv, 0) then clears right before unmasking,
stranding the frame in the RX ring until another packet arrives.
sysport_tx_poll() has the same bug with priv->csb[0] and intrl2_ack(priv, 1),
which can leave TX SKBs unfreed and a stopped TX queue permanently wedged.
Acknowledging INTRL2 before reading RDMA_PINDEX(0) or priv->csb[0] and only
calling intrl2_unmask() after napi_complete_done() (as bcmsysport.c does)
avoids losing latched interrupts.
[ ... ]
> +static int sysport_tx_poll(struct napi_struct *napi, int budget)
> +{
> + struct bcmbca_sysport *priv = container_of(napi, struct bcmbca_sysport, tx_napi);
> + struct net_device *ndev = priv->ndev;
> + unsigned int pkts = 0, bytes = 0;
> + u16 hw_cons;
> +
> + dma_rmb();
> + hw_cons = le16_to_cpu(READ_ONCE(priv->csb[0]));
> +
> + while (priv->tx_cons != hw_cons) {
> + struct sysport_tx_slot *slot;
> +
> + slot = &priv->tx_slots[priv->tx_cons & (TX_RING_SIZE - 1)];
> + dma_unmap_single(priv->dev, slot->dma, slot->len, DMA_TO_DEVICE);
> + bytes += slot->len;
> + pkts++;
> + napi_consume_skb(slot->skb, budget);
> + slot->skb = NULL;
> + priv->tx_cons++;
> + }
[Severity: Medium]
Is dma_rmb() on the wrong side of the priv->csb[0] read?
Because priv->tx_slots is indexed by priv->tx_cons rather than hw_cons, loads
of slot->dma, slot->len, and slot->skb have only a control dependency on
hw_cons. On weakly ordered ARM/ARM64 CPUs, those loads can speculatively
read stale slot values before priv->csb[0] is observed, causing an invalid
dma_unmap_single() and leaking the newly transmitted SKB and DMA mapping.
Moving dma_rmb() to immediately after reading priv->csb[0] orders the
completion index load ahead of the tx_slots[] reads.
> + ndev->stats.tx_packets += pkts;
> + ndev->stats.tx_bytes += bytes;
> + netdev_completed_queue(ndev, pkts, bytes);
[Severity: Medium]
With dma_rmb() placed before READ_ONCE(priv->csb[0]), can
netdev_completed_queue() observe a stale dql->num_queued?
On SMP ARM/ARM64, dql_completed() reads dql->num_queued with only a control
dependency on hw_cons. If that load is reordered ahead of priv->csb[0],
dql_completed() can see a smaller num_queued than the bytes just completed
and panic at BUG_ON(count > num_queued - dql->num_completed).
[ ... ]
> +static netdev_tx_t sysport_xmit(struct sk_buff *skb, struct net_device *ndev)
> +{
> + struct bcmbca_sysport *priv = netdev_priv(ndev);
> + struct sysport_tx_desc *desc;
> + struct sysport_tx_slot *slot;
> + unsigned int idx;
> + dma_addr_t dma;
> +
> + if (skb_put_padto(skb, ETH_ZLEN))
> + return NETDEV_TX_OK;
[Severity: Low]
Should this failure path increment tx_dropped?
skb_put_padto() frees the skb on allocation failure without updating
ndev->stats.tx_dropped, and returning NETDEV_TX_OK tells the core the frame
was handled, unlike the dma_mapping_error() path right below.
[ ... ]
> + spin_lock_bh(&priv->tx_lock);
[Severity: Medium]
Will spin_lock_bh(&priv->tx_lock) break netpoll and add redundant locking on
every TX packet?
Because NETIF_F_LLTX is not set, the networking core already serializes
sysport_xmit() with HARD_TX_LOCK, and no other function acquires tx_lock.
When netpoll transmits via netpoll_send_skb_on_dev() or queue_process(),
local IRQs are disabled; spin_unlock_bh() calls __local_bh_enable_ip(),
which trips WARN_ON_ONCE(in_hardirq()) and lockdep_assert_irqs_enabled(),
and can run do_softirq() and re-enable IRQs.
Removing priv->tx_lock fixes the netpoll violation and avoids unnecessary
atomic overhead on the TX hot path.
[ ... ]
> + if ((u16)(priv->tx_prod - READ_ONCE(priv->tx_cons)) >= TX_RING_SIZE - 1)
> + netif_stop_queue(ndev);
> +
> + spin_unlock_bh(&priv->tx_lock);
> + return NETDEV_TX_OK;
> +}
[Severity: High]
Can this stop/wake sequence permanently stall the TX queue on SMP?
sysport_xmit() stops the queue without a barrier and post-stop re-check of
priv->tx_cons, while sysport_tx_poll() never takes priv->tx_lock and checks
netif_queue_stopped() without a guaranteed barrier when CONFIG_BQL is off:
CPU0 CPU1
sysport_xmit()
(tx_prod - tx_cons) >= SIZE - 1
sysport_tx_poll()
drains all descriptors
tx_cons = tx_prod
netif_queue_stopped() == false
napi_complete_done()
netif_stop_queue(ndev) <-- queue stuck stopped, no TX IRQ pending
Because ndo_tx_timeout is not implemented, TX stays deadlocked until a manual
ifdown/ifup.
Separately, sysport_tx_poll() advances priv->tx_cons with a plain increment
instead of smp_store_release() paired with smp_load_acquire(), so on weakly
ordered ARM CPUs sysport_xmit() can observe the new tx_cons and overwrite a
slot before sysport_tx_poll() finishes unmapping it. sysport_xmit() also
writes priv->tx_slots[idx] without checking that space is available first.
Pairing smp_store_release()/smp_load_acquire() on priv->tx_cons and using
netif_txq_maybe_stop() with netif_txq_completed_wake() resolves these races.
[ ... ]
> + /* RX/TX are enabled in mac_link_up */
> + umac_writel(priv, CMD_SW_RESET, UMAC_CMD);
> + usleep_range(10, 20);
> + umac_writel(priv, 0, UMAC_CMD);
> + sysport_set_mac(priv, priv->ndev->dev_addr);
[Severity: Medium]
Should sysport_hw_init() program UMAC_MAX_FRAME_LEN?
Without writing UMAC_MAX_FRAME_LEN, UniMAC stays at its 1518-byte reset
default (or prior bootloader state). Because bcmbca_sysport_probe() does not
set NETIF_F_VLAN_CHALLENGED, 802.1Q VLAN interfaces inherit MTU 1500 and
produce 1522-byte frames on the wire, which UniMAC flags as oversize and
hardware discards with RBUF_BAD_PKT_DISCARD enabled.
[ ... ]
> + sysport_rmw(priv, TOPCTRL_MISC_CNTL, ~0xff00U, 0x800);
[Severity: Medium]
Is ~0xff00U inverted here?
sysport_rmw() negates its clr argument internally via (val & ~clr) | set, so
passing ~0xff00U computes (val & 0xff00U) | 0x800. That clears bits 31:16
and bits 7:0 (where bcmsysport.h defines SYS_CLK_SEL and TDMA_EOP_SEL in
MISC_CNTL) while leaving bits 15:8 uncleared before ORing 0x800.
[ ... ]
> + ret = sysport_hw_init(priv);
> + if (ret)
> + goto err_rings;
[Severity: Medium]
If sysport_hw_init() times out waiting for TDMA_STATUS (or RDMA_STATUS),
does jumping to err_rings free the DMA rings while RDMA/TDMA remain enabled?
At that point RDMA_EN is already active with priv->rx_ring_dma and the mapped
RX buffers programmed, and err_rings bypasses sysport_dma_stop(priv), risking
DMA use-after-free when sysport_free_rings() unmaps and frees them. Jumping
to err_dma instead ensures DMA is stopped first.
[ ... ]
> + ret = request_irq(priv->irq_rx, sysport_rx_isr, 0, "sysport-rx", priv);
> + if (ret)
> + goto err_phy;
> + ret = request_irq(priv->irq_tx, sysport_tx_isr, 0, "sysport-tx", priv);
> + if (ret)
> + goto err_irq_rx;
> +
> + napi_enable(&priv->rx_napi);
> + napi_enable(&priv->tx_napi);
[Severity: High]
Can unmasked INTRL2 bits or requesting IRQs before napi_enable() wedge the
CPU or drop initial interrupts?
Neither probe nor sysport_hw_init() masks and clears all 32 bits of INTRL2(0)
and INTRL2(1), while sysport_rx_isr() and sysport_tx_isr() only mask/clear
BIT(0) and unconditionally return IRQ_HANDLED without checking
INTRL2_CPU_STATUS. On level-triggered interrupts, any bit in 1..31 left
unmasked and pending by the bootloader triggers an infinite hard-IRQ storm.
Additionally, calling request_irq() after DMA is enabled but before
napi_enable() allows an immediate BIT(0) interrupt to call napi_schedule() as
a no-op, and the subsequent intrl2_ack() then clears the event. Masking and
clearing all 32 INTRL2 bits in sysport_hw_init() and calling napi_enable()
before request_irq() avoids both problems.
[ ... ]
> + intrl2_mask(priv, 0);
> + intrl2_mask(priv, 1);
> + napi_disable(&priv->rx_napi);
> + napi_disable(&priv->tx_napi);
> + free_irq(priv->irq_rx, priv);
> + free_irq(priv->irq_tx, priv);
> +
> + sysport_dma_stop(priv);
[Severity: Medium]
Can a running NAPI poll unmask INTRL2 after sysport_stop() masks it?
CPU0 CPU1
sysport_stop()
intrl2_mask(priv, 0)
sysport_rx_poll()
napi_complete_done()
intrl2_unmask(priv, 0) <-- re-enabled
napi_disable(&priv->rx_napi)
free_irq(priv->irq_rx, priv)
Because napi_complete_done() clears NAPIF_STATE_SCHED before intrl2_unmask()
runs, napi_disable() can return while INTRL2 is left unmasked in hardware
across free_irq() and into the next sysport_open(). Masking INTRL2 after
napi_disable() and free_irq() prevents a concurrent poll from re-enabling it.
[ ... ]
> +static const struct net_device_ops sysport_netdev_ops = {
> + .ndo_open = sysport_open,
> + .ndo_stop = sysport_stop,
> + .ndo_start_xmit = sysport_xmit,
> + .ndo_set_mac_address = sysport_set_mac_address,
> + .ndo_validate_addr = eth_validate_addr,
> + .ndo_eth_ioctl = sysport_ioctl,
> +};
[Severity: Medium]
Without .ndo_set_rx_mode, does promiscuous mode work on this interface?
sysport_hw_init() clears CMD_PROMISC in UMAC_CMD and programs station MAC
filtering via UMAC_MAC0/UMAC_MAC1. Without .ndo_set_rx_mode to toggle
CMD_PROMISC, bridging, macvlan, and tcpdump report IFF_PROMISC as enabled
while hardware still drops frames not matching ndev->dev_addr, and
SIOCADDMULTI/SIOCDELMULTI fail with -EINVAL.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204143652.386911-1-wafgo01@gmail.com?part=2
next prev parent reply other threads:[~2026-12-05 14:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 14:36 [RFC PATCH net-next 0/2] Add Broadcom BCMBCA SYSTEMPORT driver Wadim Mueller
2026-12-04 14:36 ` [RFC PATCH net-next 1/2] dt-bindings: net: Add Broadcom BCMBCA SYSTEMPORT Wadim Mueller
2026-12-04 14:36 ` [RFC PATCH net-next 2/2] net: ethernet: broadcom: Add BCMBCA SYSTEMPORT driver Wadim Mueller
2026-12-05 14:37 ` sashiko-bot [this message]
2026-12-05 3:22 ` [RFC PATCH net-next 0/2] Add Broadcom " Florian Fainelli
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=sashiko-outbox-251636@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=wafgo01@gmail.com \
/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