From: sashiko-bot@kernel.org
To: "Meghana Malladi" <m-malladi@ti.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net-next v2 1/2] net: ti: icssg-prueth: Add multi-flow RX support with per-flow NAPI
Date: Fri, 04 Dec 2026 12:44:46 +0000 [thread overview]
Message-ID: <sashiko-outbox-249830@kernel.org> (raw)
In-Reply-To: <20261203121447.2605779-2-m-malladi@ti.com>
Thank you for your contribution! Sashiko AI review found 28 potential
issues to consider:
- [High] net: ti: icssg: undefined icssg_rxnfc_rule_* calls break build
and linking
- [High] net: ti: icssg: AM654 UDMAP exposes 8 RX flows despite shared
512-entry FDQ
- [High] net: ti: icssg: zeroing xsk_queues on open/stop leaks XSK DMA
mappings
- [High] net: ti: icssg: double napi_disable() deadlock after XSK queue
create error
- [High] net: ti: icssg: per-flow XSK teardown frees buffers while UDMA
RX is active
- [High] net: ti: icssg: NULL deref on emac->xsk_queues in SR1
emac_ndo_open()
- [High] net: ti: icssg: SR1 emac_ndo_stop() destroys page_pool before
napi_disable()
- [High] net: ti: icssg: SR1 rx_mgm_chn leaks flow 1 FDQ buffers on
UDMAP single_fdq
- [High] net: ti: icssg-prueth: SR1 registers IRQs for
unprepared/disabled RX flows 0..2
- [Medium] net: ti: icssg: stale/racy flow->irq_disabled causes
unbalanced enable_irq()
- [Medium] net: ti: icssg-sr1: stale mgm flow->irq_disabled skips
disable_irq() on stop
- [Medium] net: ti: icssg: per-flow page_pool sized to total
rx_chn->descs_num
- [Medium] net: ti: icssg: emac_rx_packet_zc() refill uses shared
desc_pool avail
- [Medium] net: ti: icssg: unsynchronized concurrent ndev->stats writes
across RX NAPIs
- [Medium] net: ti: icssg: shared rx_chn->desc_pool gen_pool contends
across RX NAPIs
- [Medium] net: ti: icssg: prueth_xsk_pool_enable() error unmaps pool
with live TX NAPI
- [Medium] net: ti: icssg: stale SR1 mgm flow->irq_disabled skips
disable_irq() on stop
- [Medium] net: ti: icssg: SR1 prueth_sr1_prepare_rx_mgm_flow()
overflows 8-entry FDQ
- [Medium] net: ti: icssg: SR1 emac_ndo_open() error path deletes only 1
of 4 RX NAPIs
- [Medium] net: ti: icssg: SR1 emac_ndo_open() leaks page_pool on RX
prepare failure
- [Medium] net: ti: icssg: SR1 emac_ndo_open() skips mgm reset on
partial setup error
- [Medium] net: ti: icssg-prueth: SR1 stale irq_disabled skips
disable_irq() on re-close
- [Medium] net: ti: icssg-prueth: stale/racy flow->irq_disabled causes
bad enable_irq()
- [Medium] net: ti: icssg-prueth: SR1 records out-of-range RX queue 3 on
1-queue netdev
- [Medium] net: ti: icssg: emac_rx_packet() records out-of-range RX
queue on SR1.0
- [Medium] net: ti: icssg: emac_get_channels() reports rx_count > max_rx
on SR1
- [Low] net: ti: icssg: prueth_ndev_del_rx_napi() calls netif_napi_del()
in loop
- [Low] net: ti: icssg: emac_get_channels() reports rx_count 4 > max_rx
1 on SR1
--
commit d48a43c55ee89f865fc4ca3c4ae7110625497ddd
Author: Meghana Malladi <m-malladi@ti.com>
net: ti: icssg-prueth: Add multi-flow RX support with per-flow NAPI
This commit extends the TI ICSSG Ethernet driver to support up to 8 RX
flows per EMAC with per-flow NAPI, hrtimers, page pools, and AF_XDP
pools, and updates the SR1.0 driver and ethtool channel callbacks for
the restructured RX channel layout.
> diff --git a/drivers/net/ethernet/ti/icssg/icssg_common.c b/drivers/net/ethernet/ti/icssg/icssg_common.c
> index 4a7d1a6f470b1..fc7e7847580f8 100644
> --- a/drivers/net/ethernet/ti/icssg/icssg_common.c
> +++ b/drivers/net/ethernet/ti/icssg/icssg_common.c
[ ... ]
> @@ -79,6 +77,21 @@ void prueth_cleanup_tx_chns(struct prueth_emac *emac)
> }
> EXPORT_SYMBOL_GPL(prueth_cleanup_tx_chns);
>
> +void prueth_ndev_del_rx_napi(struct prueth_emac *emac, int num)
> +{
> + int i;
> +
> + for (i = 0; i < num; i++) {
> + struct prueth_rx_flow *rx_flow = &emac->rx_chns.flows[i];
> +
> + hrtimer_cancel(&rx_flow->rx_hrtimer);
> + if (rx_flow->irq)
> + free_irq(rx_flow->irq, &rx_flow->napi_rx);
> + netif_napi_del(&rx_flow->napi_rx);
> + }
> +}
> +EXPORT_SYMBOL_GPL(prueth_ndev_del_rx_napi);
[Severity: Low]
Should this loop call __netif_napi_del() and follow the loop with a single
synchronize_net()? Calling netif_napi_del() per flow serializes up to 8
RCU grace periods under rtnl_lock() on every stop or open-error unwind.
[ ... ]
> @@ -584,9 +627,14 @@ int prueth_init_rx_chns(struct prueth_emac *emac,
> K3_UDMA_GLUE_SRC_TAG_LO_USE_REMOTE_SRC_TAG,
> };
>
> + flow = &rx_chn->flows[i];
> + flow->emac = emac;
> + flow->id = i;
> + flow->irq = -EINVAL;
[Severity: Medium]
Does flow->irq_disabled stay stale across an interface stop and reopen?
Neither prueth_init_rx_chns() nor prueth_ndev_del_rx_napi() clears
flow->irq_disabled. If emac_ndo_stop() cancels an armed rx_hrtimer while
flow->irq_disabled is true, the next emac_ndo_open() requests the IRQ in
the enabled state and prueth_create_rxq() then calls an unbalanced
enable_irq(). Additionally, emac_set_coalesce() does not cancel an armed
rx_hrtimer, allowing icssg_napi_rx_poll() and emac_rx_timer_callback() to
race on checking and clearing rx_flow->irq_disabled.
[ ... ]
> @@ -1022,13 +1087,13 @@ static int emac_rx_packet_zc(struct prueth_emac *emac, u32 flow_id,
> avail_desc = k3_cppi_desc_pool_avail(rx_chn->desc_pool);
> alloc_budget = min_t(int, budget, avail_desc);
>
> - ret = prueth_rx_alloc_zc(emac, alloc_budget);
> + ret = prueth_rx_alloc_zc(emac, flow_id, alloc_budget);
>
> - if (xsk_uses_need_wakeup(rx_chn->xsk_pool)) {
> + if (xsk_uses_need_wakeup(rx_flow->xsk_pool)) {
> if (ret < alloc_budget)
> - xsk_set_rx_need_wakeup(rx_chn->xsk_pool);
> + xsk_set_rx_need_wakeup(rx_flow->xsk_pool);
> else
> - xsk_clear_rx_need_wakeup(rx_chn->xsk_pool);
> + xsk_clear_rx_need_wakeup(rx_flow->xsk_pool);
> }
[Severity: Medium]
Can computing alloc_budget from the shared rx_chn->desc_pool overflow
flow_id's 512-entry FDQ ring on PKTDMA (AM64x)?
Whenever another flow holds fewer than 512 descriptors, avail_desc is
non-zero even if flow_id's FDQ is full, so prueth_rx_alloc_zc() pushes past
the ring limit, hits -ENOMEM with netdev_err() spam, drops popped fill-ring
frames, and spuriously sets xsk_set_rx_need_wakeup(). Concurrently, an XSK
flow can also claim a descriptor just freed by emac_rx_packet() on another
CPU, causing the page-pool flow to hit WARN_ON(ret < 0) and permanently
lose a posted RX buffer.
[ ... ]
> @@ -1132,15 +1198,16 @@ static int emac_rx_packet(struct prueth_emac *emac, u32 flow_id, u32 *xdp_state)
> skb->protocol = eth_type_trans(skb, ndev);
>
> skb_mark_for_recycle(skb);
> - napi_gro_receive(&emac->napi_rx, skb);
> + skb_record_rx_queue(skb, flow_id);
> + napi_gro_receive(&emac->rx_chns.flows[flow_id].napi_rx, skb);
> ndev->stats.rx_bytes += pkt_len;
> ndev->stats.rx_packets++;
>
> requeue:
> k3_cppi_desc_pool_free(rx_chn->desc_pool, desc_rx);
> /* queue another RX DMA */
> - ret = prueth_dma_rx_push_mapped(emac, &emac->rx_chns, new_page,
> - PRUETH_MAX_PKT_SIZE);
> + ret = prueth_dma_rx_push_mapped(emac, rx_chn, new_page,
> + PRUETH_MAX_PKT_SIZE, flow_id);
[Severity: Medium]
Does skb_record_rx_queue(skb, flow_id) record an out-of-range queue index
on SR1.0?
SR1.0 allocates its netdev with a single RX queue (real_num_rx_queues == 1)
while receiving data on flow_id == PRUETH_RX_FLOW_DATA_SR1 (3). In
get_rps_cpu(), index >= dev->real_num_rx_queues aborts early, silently
disabling RPS/RFS for all SR1.0 traffic.
[Severity: Medium]
Are the plain RMW updates to ndev->stats.rx_bytes and ndev->stats.rx_packets
here (and in emac_dispatch_skb_zc()) both racy and unused?
With up to 8 concurrent RX NAPIs, these per-packet writes bounce the shared
ndev->stats cacheline across CPUs even though icssg_ndo_get_stats64() reads
rx_bytes and rx_packets from hardware MIIG counters instead. The plain RMW
updates to ndev->stats.rx_dropped and ndev->stats.rx_errors also race
across NAPIs and lose increments.
[Severity: Medium]
Will freeing desc_rx to the shared rx_chn->desc_pool and immediately
reallocating it in prueth_dma_rx_push_mapped() limit multi-flow RX scaling?
With up to 8 concurrent RX NAPIs sharing a 4096-entry gen_pool, every
packet runs a first-fit bitmap scan and atomic chunk->avail updates across
CPUs. Reusing desc_rx directly in emac_rx_packet() (or using per-flow
descriptor pools on PKTDMA) would avoid this contention.
[ ... ]
> @@ -1488,59 +1547,81 @@ int prueth_prepare_rx_chan(struct prueth_emac *emac,
>
> - if (chn->xsk_pool) {
> - /* get pages from xsk_pool and push to RX ring
> - * queue as much as possible
> + pool = prueth_create_page_pool(emac, rx_chn->dma_dev, rx_chn->descs_num, rx_flow);
> + if (IS_ERR(pool))
> + return PTR_ERR(pool);
[Severity: Medium]
Should prueth_create_page_pool() receive PRUETH_MAX_RX_DESC instead of
rx_chn->descs_num?
Because rx_chn->descs_num is scaled by flow_id_num, each of the 8 per-flow
page pools allocates a 4096-entry ptr_ring (up to 128 MiB of cached pages
per port instead of 16 MiB), and SR1.0 over-sizes its single data flow pool
by 4x.
[ ... ]
> @@ -1752,7 +1837,9 @@ void prueth_netdev_exit(struct prueth *prueth,
> if (of_phy_is_fixed_link(emac->phy_node))
> of_phy_deregister_fixed_link(emac->phy_node);
>
> - netif_napi_del(&emac->napi_rx);
> + /* Free any rules added while the interface was down */
> + if (!emac->is_sr1)
> + icssg_rxnfc_rule_cleanup(emac);
[Severity: High]
Does this break building and linking for both CONFIG_TI_ICSSG_PRUETH and
CONFIG_TI_ICSSG_PRUETH_SR1?
icssg_rxnfc_rule_cleanup(), icssg_rxnfc_rule_init(), and
icssg_rxnfc_rule_restore() are declared in icssg_prueth.h and called here
and in icssg_prueth.c, but they are not defined until commit "net: ti:
icssg-prueth: Add ethtool RX flow classification support". Moving these
declarations, struct fields, and calls into that patch would keep this
commit bisectable.
> diff --git a/drivers/net/ethernet/ti/icssg/icssg_ethtool.c b/drivers/net/ethernet/ti/icssg/icssg_ethtool.c
> index b715af21d23ac..8af4bba62efa7 100644
> --- a/drivers/net/ethernet/ti/icssg/icssg_ethtool.c
> +++ b/drivers/net/ethernet/ti/icssg/icssg_ethtool.c
> @@ -140,13 +140,14 @@ static int emac_set_channels(struct net_device *ndev,
> {
> struct prueth_emac *emac = netdev_priv(ndev);
>
> - /* Check if interface is up. Can change the num queues when
> - * the interface is down.
> + /* Check if interface is up. Can't change the num queues when
> + * the interface is up.
> */
> if (netif_running(emac->ndev))
> return -EBUSY;
>
> emac->tx_ch_num = ch->tx_count;
> + emac->rx_flow_num = ch->rx_count;
[Severity: Medium]
Can emac_set_channels() drift emac->rx_flow_num on SR1.0 and reject valid
ethtool -L requests?
On SR1.0, emac_get_channels() reports max_rx = 1 with rx_count = 4
(PRUETH_MAX_RX_FLOWS_SR1). ethnl_set_channels() and ethtool_set_channels()
reject requests with -EINVAL when rx_count stays 4, ethtool -L rx 1 fails
with -EBUSY while up instead of being a no-op, and running it while down
overwrites emac->rx_flow_num to 1 until emac_ndo_open() silently resets it
back to 4.
> @@ -159,15 +160,17 @@ static void emac_get_channels(struct net_device *ndev,
> {
> struct prueth_emac *emac = netdev_priv(ndev);
>
> - ch->max_rx = 1;
> + ch->max_rx = ICSSG_MAX_RFLOWS;
> ch->max_tx = PRUETH_MAX_TX_QUEUES;
>
> /* Disable multiple TX channels due to timeouts
> * when using more than one queue */
> - if (emac->is_sr1)
> + if (emac->is_sr1) {
> + ch->max_rx = 1;
> ch->max_tx = 1;
> + }
>
> - ch->rx_count = 1;
> + ch->rx_count = emac->rx_flow_num;
[Severity: High]
Does setting ch->max_rx = ICSSG_MAX_RFLOWS for all !emac->is_sr1 devices
expose 8 RX flows on AM654 SR2.0 (ti,am654-icssg-prueth) despite UDMAP's
shared 512-entry FDQ?
On AM654 SR2.0, k3_udma_glue_request_rx_chn() sets single_fdq = true, so
all flows share one 512-entry FDQ ring. Setting rx_count > 1 causes
emac_ndo_open() to fail deterministically with -ENOMEM on flow 1, leaks
pages on error unwind and teardown because k3_udma_glue_reset_rx_chn()
skips draining when single_fdq && flow_num, and allows unlocked concurrent
k3_ringacc_ring_push() calls on the shared FDQ.
[Severity: Low]
Should ch->rx_count be normalized to 1 when emac->is_sr1 is set? Because
emac->rx_flow_num is PRUETH_MAX_RX_FLOWS_SR1 (4), ethtool -l reports
rx_count = 4 exceeding max_rx = 1.
> diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.c b/drivers/net/ethernet/ti/icssg/icssg_prueth.c
> index 9bb67e185a3ea..bda6d92a8158d 100644
> --- a/drivers/net/ethernet/ti/icssg/icssg_prueth.c
> +++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.c
[ ... ]
> @@ -978,27 +947,81 @@ static int prueth_create_txq(struct prueth_emac *emac)
> return ret;
> }
>
> -static int prueth_create_rxq(struct prueth_emac *emac)
> +static int prueth_create_rxq(struct prueth_emac *emac, int id)
> {
> + struct prueth_rx_chn *rx_chn = &emac->rx_chns;
> + struct prueth_rx_flow *flow = &rx_chn->flows[id];
> + struct xdp_rxq_info *rxq = &flow->xdp_rxq;
> int ret;
[ ... ]
> + napi_enable(&flow->napi_rx);
> + /* Re-enable IRQ now that NAPI is live. IRQ may have been left
> + * disabled by hrtimer coalescing or a previous destroy_rxq.
> + */
> + if (flow->irq_disabled) {
> + flow->irq_disabled = false;
> + enable_irq(flow->irq);
> + }
[Severity: Medium]
Can checking flow->irq_disabled after napi_enable() race with
prueth_rx_irq() and leave the RX IRQ permanently disabled?
When prueth_create_rxq() runs on a live shared RX channel (such as during
XSK pool enable/disable), prueth_rx_irq() sets irq_disabled = true before
calling disable_irq_nosync():
CPU0 CPU1
prueth_create_rxq()
napi_enable(&flow->napi_rx)
prueth_rx_irq()
rx_flow->irq_disabled = true
if (flow->irq_disabled)
flow->irq_disabled = false
enable_irq(flow->irq) <-- unbalanced enable_irq()
disable_irq_nosync(irq)
napi_schedule(napi_rx)
Because flow->irq_disabled is now false, icssg_napi_rx_poll() will never
re-enable the IRQ, stalling RX on that queue until reset. Re-enabling the
IRQ before napi_enable() (or synchronizing with the IRQ) avoids this race.
[ ... ]
> @@ -1042,9 +1068,13 @@ static int emac_ndo_open(struct net_device *ndev)
> return ret;
> }
>
> - max_rx_flows = PRUETH_MAX_RX_FLOWS;
> - ret = prueth_init_rx_chns(emac, &emac->rx_chns, "rx",
> - max_rx_flows, PRUETH_MAX_RX_DESC);
> + /* Clear XSK state on open: any pool bound while interface was down
> + * is no longer valid. User must re-enable AF_XDP after bringing
> + * the interface up.
> + */
> + bitmap_zero(emac->xsk_queues, PRUETH_MAX_RX_FLOWS);
[Severity: High]
Does clearing emac->xsk_queues in emac_ndo_open() and emac_ndo_stop() leak
XSK DMA mappings and trigger a kernel WARN on socket close?
Core AF_XDP keeps zero-copy pools bound across interface down/up and
suspend/resume cycles. When the socket later closes, xp_disable_drv_zc()
calls prueth_xsk_pool_disable(), which hits !test_bit(queue_id,
emac->xsk_queues) and returns -EINVAL before xsk_pool_dma_unmap(),
emitting WARN(1, "Failed to disable zero-copy!") and leaking the DMA
mappings.
[ ... ]
> @@ -1490,45 +1523,66 @@ static int prueth_xsk_pool_enable(struct prueth_emac *emac,
> if (netif_running(emac->ndev)) {
> /* stop packets from wire for graceful teardown */
> ret = icssg_set_port_state(emac, ICSSG_EMAC_PORT_DISABLE);
> - if (ret)
> + if (ret) {
> + xsk_pool_dma_unmap(pool, PRUETH_RX_DMA_ATTR);
> return ret;
> - prueth_destroy_rxq(emac);
> + }
> + prueth_destroy_rxq(emac, queue_id);
> }
[Severity: High]
Can calling prueth_destroy_rxq() while the shared UDMA RX channel is still
enabled cause DMA use-after-free?
ICSSG_EMAC_PORT_DISABLE stops new frames from the wire, but does not flush
in-flight frames or descriptors already prefetched by UDMA from the FDQ.
Destroying flow->pg_pool here (or calling xsk_pool_dma_unmap() in
prueth_xsk_pool_disable()) lets UDMA write into freed or unmapped memory
and leaks any prefetched descriptors from rx_chn->desc_pool.
> +err_napi:
> + clear_bit(queue_id, emac->xsk_queues);
> + prueth_set_xsk_pool(emac, queue_id);
> + xsk_pool_dma_unmap(pool, PRUETH_RX_DMA_ATTR);
[Severity: Medium]
Can this error path unmap the XSK pool while TX NAPI is still using it?
prueth_set_xsk_pool() already published pool into tx_chn->xsk_pool while
tx_chn->napi_tx is live:
CPU0 CPU1
prueth_xsk_pool_enable()
prueth_set_xsk_pool()
emac_napi_tx_poll()
emac_tx_complete_packets()
if (tx_chn->xsk_pool)
err_napi:
prueth_set_xsk_pool() /* NULL */
xsk_pool_dma_unmap(pool, ...)
emac_xsk_xmit_zc()
<-- use-after-free on dma_pages
Disabling or synchronizing with tx_chn->napi_tx before unmapping pool would
close this window.
> @@ -1544,27 +1598,29 @@ static int prueth_xsk_pool_disable(struct prueth_emac *emac, u16 queue_id)
[ ... ]
> if (netif_running(emac->ndev)) {
> - ret = prueth_create_rxq(emac);
> - if (ret) {
> - netdev_err(emac->ndev, "Failed to create RX queue: %d\n", ret);
> - return ret;
> - }
> - ret = icssg_set_port_state(emac, ICSSG_EMAC_PORT_FORWARD);
> - if (ret) {
> - prueth_destroy_rxq(emac);
> - return ret;
> - }
> + ret = prueth_create_rxq(emac, queue_id);
> + if (ret)
> + netdev_err(emac->ndev,
> + "failed to recreate RX queue %d after XSK disable; bring interface down to recover: %d\n",
> + queue_id, ret);
[Severity: High]
Does a failure in prueth_create_rxq() here (or in prueth_xsk_pool_enable()
at err_napi:) cause a permanent deadlock on the next interface down?
prueth_destroy_rxq() already called napi_disable(&flow->napi_rx), and when
prueth_create_rxq() fails it returns without calling napi_enable(). When
the user brings the interface down to recover, emac_ndo_stop() ->
prueth_destroy_rxqs() -> prueth_destroy_rxq() calls napi_disable() a second
time, spinning forever in napi_disable_locked() while holding netdev_lock()
and rtnl_lock(). In prueth_xsk_pool_enable()'s err_napi: path, a failure
also leaves ICSSG_EMAC_PORT_FORWARD disabled across all flows.
> diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c b/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c
> index 21a14b3bc889b..c166977b424ef 100644
> --- a/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c
> +++ b/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c
[ ... ]
> @@ -319,14 +319,123 @@ static struct page *prueth_process_rx_mgm(struct prueth_emac *emac,
[ ... ]
> + desc_avail = k3_cppi_desc_pool_avail(rx_chn->desc_pool);
> + if (desc_avail < PRUETH_MAX_RX_DESC)
> + netdev_warn(emac->ndev,
> + "not enough RX descriptors available %d < %d\n",
> + desc_avail, PRUETH_MAX_RX_DESC);
> +
> + for (i = 0; i < desc_avail; i++) {
> + page = page_pool_dev_alloc_pages(rx_flow->pg_pool);
> + if (!page)
> + break;
> +
> + ret = prueth_dma_rx_push_mapped(emac, rx_chn, page, buf_len, flow);
> + if (ret < 0) {
> + page_pool_recycle_direct(rx_flow->pg_pool, page);
> + netdev_err(emac->ndev, "failed to push rx mgm buf %d\n", ret);
> + break;
> + }
> + }
> +
> + return 0;
> +}
[Severity: Medium]
Does prueth_sr1_prepare_rx_mgm_flow() overflow flow 0's 8-entry FDQ ring on
every SR1.0 open?
rx_mgm_chn.desc_pool has 16 descriptors (8 per flow), while each flow's FDQ
ring holds PRUETH_MAX_RX_MGM_DESC_SR1 (8). Comparing against
PRUETH_MAX_RX_DESC (512) always logs a warning, looping up to desc_avail
(16) overflows flow 0's ring with -ENOMEM on iteration 8, and breaking out
returns 0 even if zero buffers were pushed.
[ ... ]
> +static void prueth_sr1_reset_rx_mgm_chn(struct prueth_emac *emac, bool disable)
> +{
> + struct prueth_rx_chn *chn = &emac->rx_mgm_chn;
> + struct prueth_rx_flow *flow;
> + int i;
> +
> + /* Disable mgm IRQs before UDMA reset to prevent handler re-entry */
> + for (i = 0; i < PRUETH_MAX_RX_MGM_FLOWS_SR1; i++) {
> + flow = &chn->flows[i];
> + if (flow->irq <= 0)
> + continue;
> + if (!flow->irq_disabled) {
> + disable_irq(flow->irq);
> + flow->irq_disabled = true;
> + }
> + }
[Severity: Medium]
Will stale flow->irq_disabled skip disable_irq() on the second SR1.0
emac_ndo_stop()?
When called with disable == true, this sets flow->irq_disabled = true and
neither prueth_sr1_cleanup_rx_mgm_chn() nor the next emac_ndo_open() resets
it to false. On the next stop, disable_irq() is skipped, letting the
threaded management IRQ handlers run concurrently with
k3_udma_glue_reset_rx_chn() and k3_udma_glue_disable_rx_chn().
[ ... ]
> @@ -514,37 +629,123 @@ static int emac_ndo_open(struct net_device *ndev)
> return ret;
> }
>
> - max_rx_flows = PRUETH_MAX_RX_FLOWS_SR1;
> - ret = prueth_init_rx_chns(emac, &emac->rx_chns, "rx",
> - max_rx_flows, PRUETH_MAX_RX_DESC);
> + emac->rx_flow_num = PRUETH_MAX_RX_FLOWS_SR1;
> +
> + /* Clear XSK state on open: any pool bound while interface was down
> + * is no longer valid. User must re-enable AF_XDP after bringing
> + * the interface up.
> + */
> + bitmap_zero(emac->xsk_queues, PRUETH_MAX_RX_FLOWS);
[Severity: High]
Does this unconditionally dereference a NULL pointer on SR1.0?
icssg_prueth_sr1.c:prueth_netdev_init() never allocates emac->xsk_queues,
so bitmap_zero() writes through NULL on every SR1.0 interface open.
Embedding DECLARE_BITMAP(xsk_queues, PRUETH_MAX_RX_FLOWS) in struct
prueth_emac (or removing this call on SR1.0) avoids the NULL dereference.
[ ... ]
> + flow = &emac->rx_mgm_chn.flows[i];
> + flow->emac = emac;
> + flow->id = i;
> + flow->irq = -EINVAL;
> +
> + rx_flow_cfg.ring_rxfdq0_id = K3_RINGACC_RING_ID_ANY;
> + rx_flow_cfg.rx_cfg.size = PRUETH_MAX_RX_MGM_DESC_SR1;
> + rx_flow_cfg.rxfdq_cfg.size = PRUETH_MAX_RX_MGM_DESC_SR1;
[Severity: Medium]
Should this loop also reset flow->irq_disabled = false? Without resetting
it on reopen, request_threaded_irq() enables the management IRQs while
flow->irq_disabled remains true from a previous stop, defeating the IRQ
disable guard in prueth_sr1_reset_rx_mgm_chn().
[Severity: High]
Does hardcoding K3_RINGACC_RING_ID_ANY here leak all 8 pages and CPPI
descriptors on management flow 1 during SR1.0 teardown?
AM654 SR1.0 uses UDMAP where k3_udma_glue_request_rx_chn() sets
single_fdq = true. Allocating a separate FDQ ring for flow 1 causes
k3_udma_glue_reset_rx_chn() to skip draining it (single_fdq && flow_num),
leaking its pages and firing WARN() in k3_cppi_desc_pool_destroy().
[ ... ]
> + /* Data NAPI and IRQ registration via common API */
> + ret = prueth_ndev_add_rx_napi(emac);
> if (ret) {
> - dev_err(dev, "unable to request RX IRQ\n");
> + dev_err(dev, "unable to add rx napi\n");
> goto cleanup_napi;
> }
[Severity: High]
Does calling prueth_ndev_add_rx_napi() register live IRQs for unprepared
SR1.0 flows 0..2?
With emac->rx_flow_num = PRUETH_MAX_RX_FLOWS_SR1 (4), this registers NAPIs
and requests IRQs for flows 0..3, while emac_ndo_open() only prepares and
enables NAPI for flow 3 (PRUETH_RX_FLOW_DATA_SR1) and icssg_napi_rx_poll()
no longer drains flows 0..2. Any packet arriving on flows 0..2 fires
prueth_rx_irq(), disables the IRQ, fails to schedule the disabled NAPI, and
stalls that flow.
[ ... ]
> @@ -570,11 +771,15 @@ static int emac_ndo_open(struct net_device *ndev)
> icssg_mii_update_mtu(prueth->mii_rt, slice, ndev->max_mtu);
>
> /* Prepare RX */
> - ret = prueth_prepare_rx_chan(emac, &emac->rx_chns, PRUETH_MAX_PKT_SIZE);
> + ret = prueth_prepare_rx_flow(emac, PRUETH_RX_FLOW_DATA_SR1);
> if (ret)
> goto stop;
>
> - ret = prueth_prepare_rx_chan(emac, &emac->rx_mgm_chn, 64);
> + ret = prueth_sr1_prepare_rx_mgm_flow(emac, PRUETH_RX_MGM_FLOW_RESPONSE_SR1, 64);
> + if (ret)
> + goto reset_rx_chn;
> +
> + ret = prueth_sr1_prepare_rx_mgm_flow(emac, PRUETH_RX_MGM_FLOW_TIMESTAMP_SR1, 64);
> if (ret)
> goto reset_rx_chn;
[Severity: Medium]
Does jumping to stop: on prueth_prepare_rx_flow() failure leak
flows[PRUETH_RX_FLOW_DATA_SR1].pg_pool and any already-pushed buffers?
prueth_prepare_rx_flow() leaves destroying pg_pool to the caller, and its
err_free_pushed: path passes flow == 3 to k3_udma_glue_reset_rx_chn(),
which skips draining the shared FDQ on UDMAP (single_fdq == true).
Bypassing reset_rx_chn: therefore leaks the page pool, pushed pages, and
CPPI descriptors.
[Severity: Medium]
When packets arrive on PRUETH_RX_FLOW_DATA_SR1 (3), does emac_rx_packet()
record an out-of-range RX queue mapping for SR1.0's 1-queue netdev?
Because SR1.0 calls alloc_etherdev_mq(..., 1), skb_record_rx_queue(skb, 3)
sets skb->queue_mapping to 4 while real_num_rx_queues is 1, breaking
RPS/RFS in get_rps_cpu() and exposing an invalid queue index to XPS and
BPF. Skipping skb_record_rx_queue() (or recording 0) when emac->is_sr1 is
set would preserve SR1.0 behavior.
[Severity: Medium]
If preparing PRUETH_RX_MGM_FLOW_TIMESTAMP_SR1 or enabling
emac->rx_mgm_chn.rx_chn fails, should both jump to reset_rx_mgm_chn:
instead of reset_rx_chn:? Skipping reset_rx_mgm_chn: leaves flow 0's
pushed pages and CPPI descriptors undrained when
prueth_sr1_cleanup_rx_mgm_chn() runs, triggering WARN() in
k3_cppi_desc_pool_destroy().
[ ... ]
> @@ -612,27 +817,29 @@ static int emac_ndo_open(struct net_device *ndev)
[ ... ]
> free_rx_irq:
> - free_irq(emac->rx_chns.irq[rx_flow], emac);
> + prueth_ndev_del_rx_napi(emac, 1);
[Severity: Medium]
Does passing 1 instead of PRUETH_MAX_RX_FLOWS_SR1 leak 3 RX IRQs and NAPI
registrations on SR1.0 open failure? prueth_ndev_add_rx_napi() registered
4 flows, so flows 1..3 remain registered while cleanup_rx releases the UDMA
channel.
[ ... ]
> @@ -683,16 +888,20 @@ static int emac_ndo_stop(struct net_device *ndev)
[ ... ]
> k3_udma_glue_tdown_rx_chn(emac->rx_chns.rx_chn, true);
>
> - prueth_reset_rx_chan(&emac->rx_chns, max_rx_flows, true);
> + prueth_reset_rx_chan(emac, true);
> +
> + if (emac->rx_chns.flows[PRUETH_RX_FLOW_DATA_SR1].pg_pool) {
> + page_pool_destroy(emac->rx_chns.flows[PRUETH_RX_FLOW_DATA_SR1].pg_pool);
> + emac->rx_chns.flows[PRUETH_RX_FLOW_DATA_SR1].pg_pool = NULL;
> + }
> +
> /* Teardown RX MGM channel */
> k3_udma_glue_tdown_rx_chn(emac->rx_mgm_chn.rx_chn, true);
> - prueth_reset_rx_chan(&emac->rx_mgm_chn,
> - PRUETH_MAX_RX_MGM_FLOWS_SR1, true);
> + prueth_sr1_reset_rx_mgm_chn(emac, true);
>
> - napi_disable(&emac->napi_rx);
> + napi_disable(&emac->rx_chns.flows[PRUETH_RX_FLOW_DATA_SR1].napi_rx);
[Severity: High]
Does destroying the data flow's page_pool before napi_disable() trigger a
use-after-free and a WARN in napi_assert_will_not_race()?
Because prueth_create_page_pool() binds pp_params.napi to
&rx_flow->napi_rx, page_pool_destroy() checks napi_assert_will_not_race()
and warns deterministically while NAPI is still enabled. Concurrently,
icssg_napi_rx_poll() -> emac_rx_packet() can dereference the destroyed or
NULL rx_flow->pg_pool while racing with prueth_reset_rx_chan().
[Severity: Medium]
On a second emac_ndo_stop() after reopening an SR1.0 interface, can
prueth_sr1_reset_rx_mgm_chn(emac, true) race with the threaded management
IRQ handlers on rx_mgm_chn?
Because flow->irq_disabled stays true from the first stop,
prueth_sr1_reset_rx_mgm_chn() skips disable_irq(), allowing
prueth_rx_mgm_rsp_thread() and prueth_rx_mgm_ts_thread_sr1() to run
concurrently with k3_udma_glue_reset_rx_chn() -> prueth_rx_cleanup() on the
UDMA rings and lockless page_pool caches.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203121447.2605779-1-m-malladi@ti.com?part=1
next prev parent reply other threads:[~2026-12-04 12:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 12:14 [PATCH net-next v2 0/2] net: ti: icssg: Multi-flow RX and ethtool RX flow classification Meghana Malladi
2026-12-03 12:14 ` [PATCH net-next v2 1/2] net: ti: icssg-prueth: Add multi-flow RX support with per-flow NAPI Meghana Malladi
2026-12-04 12:44 ` sashiko-bot [this message]
2026-12-04 13:25 ` netdev-bot+sashiko
2026-12-03 12:14 ` [PATCH net-next v2 2/2] net: ti: icssg-prueth: Add ethtool RX flow classification support Meghana Malladi
2026-12-04 12:44 ` sashiko-bot
2026-12-04 13:25 ` 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=sashiko-outbox-249830@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=m-malladi@ti.com \
--cc=sashiko-reviews@lists.linux.dev \
/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