From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796481473; b=yZ4h0nQn3GASCtPvllFZBvtZXkUj5iXDkdfrzGPMcksJQKRel3dMYf5JD2NQ9y7YRezg Xylm/yIBDty3PA9YCUYLA2c+mT0tZUPxL6fDp6deYyUqtxWX8qVIw704/ieVqRAsJW35x i3MxDskXcy3FPxhWM04vmgEJigvcyS6f4wWo2n3YzaV9BW0FtR4xQmwMjhLTCRdx9psqt BU7+1kDc9kO1ArstHCruDR+addv+Bn2AsLpR1nqYN5egekwwlIvl9e1UeLdPxma5lmHBv VHYnm+n9DM5zoZhWoktrKRc3XgPug/hekWmAM4dTi5sA813M40D/08IV/SgBVemCWVg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796481473; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=iQyNXAcj+nOWiofo5h/vZ1X8KHisBdazLx0Pk5rV5Ak=; b=c3gqIotAGuZHAQfmRq16o70ObEMb+VlNKUiws6WsU93wBPPJerSijjXAJ3eI8Grq9V4A x1XzcGPi5L3elcCgrUTjjU5OOpSnFfbN25wBP5EWEDmkiStlEYgBM5WX14aAquZV8+oiy n48vMqg+pO0ii0WYkw/1Ox2jctv3mHcBNUzSrscsXBhJ5wHXoHFM/eMXNgZ0AejO3rwsQ mLczofVGm+w7ESTnsUiv/9Xj/3fe5Duw5AiZP7mkxJX9e9ei0kkvvXHBZgb+lJnGOGs6X QxZB+KvwNnptjYHbN6oHUYpmaB6VzfLrichUTBC8VtpOMOwMY+GiR3bnV6HKY2VZjHw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Nf8pdtrS; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5CAFC606A322 for ; Sat, 5 Dec 2026 14:37:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Nf8pdtrS Received: by smtp.kernel.org (Postfix) with ESMTPSA id B948B1F0092B; Sat, 5 Dec 2026 14:37:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796481472; bh=iQyNXAcj+nOWiofo5h/vZ1X8KHisBdazLx0Pk5rV5Ak=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=Nf8pdtrSI3Rw1HvlVc+FNNxrG/gaUzuWjgGo166FDl1pYLBlyDiYsx7SWFQ8Sz4xG Wa3G3LxjDJzEo00HkCX5WsEwNI3SH6mtvmd2nsw+rTkI8MOMe0p+4xAI8mbZTMOaWj zgizwWPo8tPX2DrZXsJ9f2VuvNtTI1w3jdpw+JSM2zNkuzimYmf9UQvF4zhV/6vu3L Tr4O52OO8yWDGCMAVR1YSPLoJ8BXd4jBveyZLe3kK+YW3v1x8GQccKjSOGBQTarrE7 psZvvgrgc35VyPuMcwBfRHnqGlmSi5y2Amqce7xnF5JMOwCRQR33Wvclj7WYeyC57A IHKt7fFZ1crIA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [RFC PATCH net-next 2/2] net: ethernet: broadcom: Add BCMBCA SYSTEMPORT driver Reply-To: sashiko-reviews@lists.linux.dev To: "Wadim Mueller" Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org In-Reply-To: <20261204143652.386911-3-wafgo01@gmail.com> References: <20261204143652.386911-1-wafgo01@gmail.com> <20261204143652.386911-3-wafgo01@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 14:37:52 +0000 X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 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 =3D container_of(napi, struct bcmbca_syspor= t, rx_napi); > + struct net_device *ndev =3D priv->ndev; > + int done =3D 0; > + u16 pindex; > + > + pindex =3D sysport_readl(priv, RDMA_PINDEX(0)); [ ... ] > + ndev->stats.rx_packets++; > + ndev->stats.rx_bytes +=3D 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_stat= s, dev_get_stats() reads ndev->stats via atomic_long_read() in netdev_stats_to_stats64(). Plain ++ and +=3D 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 memo= ry 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 =3D container_of(napi, struct bcmbca_syspor= t, tx_napi); > + struct net_device *ndev =3D priv->ndev; > + unsigned int pkts =3D 0, bytes =3D 0; > + u16 hw_cons; > + > + dma_rmb(); > + hw_cons =3D le16_to_cpu(READ_ONCE(priv->csb[0])); > + > + while (priv->tx_cons !=3D hw_cons) { > + struct sysport_tx_slot *slot; > + > + slot =3D &priv->tx_slots[priv->tx_cons & (TX_RING_SIZE - 1)]; > + dma_unmap_single(priv->dev, slot->dma, slot->len, DMA_TO_DEVICE); > + bytes +=3D slot->len; > + pkts++; > + napi_consume_skb(slot->skb, budget); > + slot->skb =3D 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, loa= ds 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 +=3D pkts; > + ndev->stats.tx_bytes +=3D 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 =3D 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)) >=3D 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) >=3D SIZE - 1 sysport_tx_poll() drains all descriptors tx_cons =3D tx_prod netif_queue_stopped() =3D=3D 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 manu= al 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 n= ot 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 =3D 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 mapp= ed RX buffers programmed, and err_rings bypasses sysport_dma_stop(priv), riski= ng DMA use-after-free when sysport_free_rings() unmaps and frees them. Jumping to err_dma instead ensures DMA is stopped first. [ ... ] > + ret =3D request_irq(priv->irq_rx, sysport_rx_isr, 0, "sysport-rx", priv= ); > + if (ret) > + goto err_phy; > + ret =3D 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 i= t. [ ... ] > +static const struct net_device_ops sysport_netdev_ops =3D { > + .ndo_open =3D sysport_open, > + .ndo_stop =3D sysport_stop, > + .ndo_start_xmit =3D sysport_xmit, > + .ndo_set_mac_address =3D sysport_set_mac_address, > + .ndo_validate_addr =3D eth_validate_addr, > + .ndo_eth_ioctl =3D 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. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204143652.3869= 11-1-wafgo01@gmail.com?part=3D2