Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: m-malladi@ti.com
Cc: marco.crivellari@suse.com, kees+treewide@kernel.org,
	laixiangwu@cmss.chinamobile.com, philippe.schenker@impulsing.ch,
	haokexin@gmail.com, devnexen@gmail.com, horms@kernel.org,
	sdf@fomichev.me, john.fastabend@gmail.com, hawk@kernel.org,
	daniel@iogearbox.net, ast@kernel.org, pabeni@redhat.com,
	kuba@kernel.org, edumazet@kernel.org, davem@davemloft.net,
	andrew+netdev@lunn.ch, bpf@vger.kernel.org,
	netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	srk@ti.com, vigneshr@ti.com, rogerq@kernel.org,
	danishanwar@ti.com
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 13:25:12 +0000	[thread overview]
Message-ID: <179639071239.3146.7243377057709644659@kernel.org> (raw)
In-Reply-To: <20261203121447.2605779-2-m-malladi@ti.com>

Thank you for your contribution! Sashiko AI review found 23 potential
issue(s) to consider.

Critical: 0 · High: 8 · Medium: 10 · Low: 5

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).

- [High] NULL pointer dereference on every SR1 interface open.
- [High] emac_ndo_stop() now runs bitmap_zero(emac->xsk_queues, ...) at
  icssg_prueth.c:1170, and emac_ndo_open() does the same at :1075.
- [High] Unbalanced NAPI disable leads to an ifdown hang.
- [High] The rewritten SR1 management channel gives each mgm flow its own
  FDQ (rx_flow_cfg.ring_rxfdq0_id = K3_RINGACC_RING_ID_ANY per flow, so…
- [High] In SR1 emac_ndo_open(), a failure of
  prueth_prepare_rx_flow(emac, PRUETH_RX_FLOW_DATA_SR1) does 'goto stop'.
- [High] In SR1 emac_ndo_open(), a failure of the newly added second
  prueth_sr1_prepare_rx_mgm_flow(TIMESTAMP) call, or of…
- [High] prueth_xsk_pool_enable() and prueth_xsk_pool_disable() now tear
  down one flow with prueth_destroy_rxq(emac, qid) while the shared UDMA…
- [High] net: ti: icssg: undefined icssg_rxnfc_rule_* calls break build
  and linking
- [Medium] On AM654 SR2 (UDMAP, am654_icssg_pdata), emac_get_channels()
  advertises max_rx = ICSSG_MAX_RFLOWS (8) and emac_set_channels()…
- [Medium] SR1 data flows 0..2 are no longer serviced.
- [Medium] The patch silently fixes two real SR1 bugs in
  prueth_process_rx_mgm().
- [Medium] In the SR1 emac_ndo_open() error path, the 'free_rx_irq:'
  label calls prueth_ndev_del_rx_napi(emac, 1).
- [Medium] The per-flow 'bool irq_disabled' is an ad-hoc flag used to
  keep disable_irq/enable_irq balanced.
- [Medium] In the SR1 emac_ndo_stop(),
  page_pool_destroy(flows[PRUETH_RX_FLOW_DATA_SR1].pg_pool) runs at…
- [Medium] With up to 8 RX flows, each with its own NAPI and IRQ that can
  run on different CPUs, emac_rx_packet() and emac_dispatch_skb_zc()…
- [Medium] net: ti: icssg: SR1 emac_ndo_open() skips mgm reset on partial
  setup error
- [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
- [Low] The commit message does not match the diff.
- [Low] On SR1, emac_get_channels() reports ch->max_rx = 1 but
  ch->rx_count = emac->rx_flow_num, which is PRUETH_MAX_RX_FLOWS_SR1 (4)…
- [Low] On SR1, emac_rx_packet() calls skb_record_rx_queue(skb, flow_id)
  with flow_id = PRUETH_RX_FLOW_DATA_SR1 (3), which sets queue_mapping…
- [Low] prueth_sr1_prepare_rx_mgm_flow() compares the mgm descriptor
  pool's availability (PRUETH_MAX_RX_MGM_DESC_SR1 * 2 = 16) against…
- [Low] The patch adds per-flow RX coalescing state
  (prueth_rx_flow.rx_pace_timeout_ns for 8 flows) and multiple RX…

--

net: ti: icssg-prueth: Add multi-flow RX support with per-flow NAPI

This commit raises the ICSSG driver from one RX flow per EMAC to up to
eight. Each flow gets its own NAPI, hrtimer, IRQ, page pool, XDP rxq and
AF_XDP pool, and all flows share one UDMA channel and descriptor pool. It
also replaces xsk_qid with an xsk_queues bitmap and open-codes the SR1
management channel setup in icssg_prueth_sr1.c.

> Extend ICSSG driver to support up to 8 independent RX flows per EMAC
> (PRUETH_MAX_RX_FLOWS 1 --> 8), enabling ethtool queue steering via set_rxnfc.

[Severity: Low]
Does this describe this patch accurately? It adds no .set_rxnfc or
.get_rxnfc callback. Those seem to arrive in the follow-up commit "net:
ti: icssg-prueth: Add ethtool RX flow classification support".

This patch does already add the rxnfc structures and prototypes in
icssg_prueth.h. It also calls icssg_rxnfc_rule_init(),
icssg_rxnfc_rule_restore() and icssg_rxnfc_rule_cleanup() from
prueth_netdev_init(), emac_ndo_open() and prueth_netdev_exit().

Would that plumbing fit better in the classification commit?

The patch also removes PRUETH_MODULE_DESCRIPTION and
ICSSG_CTRL_RGMII_ID_MODE, and moves PRUETH_MAX_TX_QUEUES into
icssg_config.h. The commit message mentions none of these.

> - ndev->stats.rx_errors/rx_dropped use plain RMW from concurrent NAPIs;
>   per-cpu stats refactor deferred.

The per-packet rx_bytes and rx_packets updates in emac_rx_packet() and
emac_dispatch_skb_zc() race the same way. Should this limitation list
them too?

> 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

[ ... ]

> @@ -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);

[Severity: Low]
On SR1, flow_id here is PRUETH_RX_FLOW_DATA_SR1 (3), so queue_mapping
becomes 4. The SR1 prueth_netdev_init() still allocates the netdev with
alloc_etherdev_mq(sizeof(*emac), num_tx_chn), which gives a single RX
queue. The SR1 emac_ndo_open() never calls netif_set_real_num_rx_queues().

Is recording an RX queue index outside the registered range intended?
get_rps_cpu() and netif_get_rxqueue() quietly fall back to queue 0, so
per-queue RPS/RFS see the wrong queue.

> +	napi_gro_receive(&emac->rx_chns.flows[flow_id].napi_rx, skb);
>  	ndev->stats.rx_bytes += pkt_len;
>  	ndev->stats.rx_packets++;

[Severity: Medium]
There can now be up to eight flows, each with its own NAPI and IRQ, and
they can run on different CPUs. Can these plain read-modify-write updates
of the shared ndev->stats lose increments?

The same applies to rx_dropped and rx_errors here and in
emac_dispatch_skb_zc(). Before this patch a single RX NAPI serialized
these updates.

The netdev already uses NETDEV_PCPU_STAT_TSTATS. Could
dev_sw_netstats_rx_add() be used for the per-packet counters?

[ ... ]

> @@ -1436,50 +1507,38 @@ EXPORT_SYMBOL_GPL(prueth_cleanup_tx_ts);
>  
>  int icssg_napi_rx_poll(struct napi_struct *napi_rx, int budget)
>  {
> -	struct prueth_emac *emac = prueth_napi_to_emac(napi_rx);
> -	int rx_flow = emac->is_sr1 ?
> -		PRUETH_RX_FLOW_DATA_SR1 : PRUETH_RX_FLOW_DATA;
> -	int flow = emac->is_sr1 ?
> -		PRUETH_MAX_RX_FLOWS_SR1 : PRUETH_MAX_RX_FLOWS;
> -	struct prueth_rx_chn *rx_chn = &emac->rx_chns;
> +	struct prueth_rx_flow *rx_flow = prueth_napi_to_rx_chn(napi_rx);
> +	struct prueth_emac *emac = rx_flow->emac;
>  	int xdp_state_or = 0;
>  	int num_rx = 0;
> -	int cur_budget;
>  	u32 xdp_state;
>  	int ret;
>  
> -	while (flow--) {
> -		if (rx_chn->xsk_pool) {
> -			num_rx = emac_rx_packet_zc(emac, flow, budget);
> -		} else {
> -			cur_budget = budget - num_rx;
> -
> -			while (cur_budget--) {
> -				ret = emac_rx_packet(emac, flow, &xdp_state);
> -				xdp_state_or |= xdp_state;
> -				if (ret)
> -					break;
> -				num_rx++;
> -			}
> +	if (rx_flow->xsk_pool) {
> +		num_rx = emac_rx_packet_zc(emac, rx_flow->id, budget);
> +	} else {
> +		while (budget - num_rx > 0) {
> +			ret = emac_rx_packet(emac, rx_flow->id, &xdp_state);
> +			xdp_state_or |= xdp_state;
> +			if (ret)
> +				break;
> +			num_rx++;
>  		}
> -
> -		if (num_rx >= budget)
> -			break;
>  	}

[Severity: Medium]
Are SR1 data flows 0..2 still serviced after this change? Previously the
SR1 poll looped over all PRUETH_MAX_RX_FLOWS_SR1 flows. Now each NAPI polls
only its own flow.

prueth_ndev_add_rx_napi() requests IRQs for all four flows. The SR1
emac_ndo_open(), however, only creates a page pool for
flows[PRUETH_RX_FLOW_DATA_SR1] and only enables that flow's NAPI.

Suppose the firmware completes a frame on flow 0..2. prueth_rx_irq()
disables the IRQ, and napi_schedule() does nothing on the never-enabled
NAPI, so nothing ever pops the RXCQ entry.

Could this keep consuming shared FDQ descriptors until flow 3 starves? At
ifdown, could it also leave descriptors outstanding when
k3_cppi_desc_pool_destroy() runs, and so reach the BUG_ON in
gen_pool_destroy()?

[ ... ]

> 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

[ ... ]

> @@ -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;

[Severity: Medium]
Can more than one RX flow actually come up on AM654 SR2 (UDMAP)? The UDMAP
RX channel is single_fdq. prueth_init_rx_chns() binds flows 1..N to flow
0's FDQ with K3_RINGACC_RING_SHARED. k3_ringacc_ring_cfg() returns early
when use_count != 1, so the shared ring keeps flow 0's size of
PRUETH_MAX_RX_DESC.

prueth_prepare_rx_flow() for flow 0 fills that ring with 512 descriptors.
For flow 1 the desc_avail check passes, because the pool holds 512 * N.
The first push then fails with -ENOMEM because the ring is full, so
prueth_create_rxqs() unwinds and ndo_open fails.

On AM654 SR2, "ethtool -L ethX rx 2" followed by ifup would leave the
interface unable to come up. The commit message says multi-flow on AM654
is deferred. Should max_rx stay at 1 on UDMAP until then?

>  	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: Low]
On SR1, rx_flow_num is PRUETH_MAX_RX_FLOWS_SR1 (4), set in both
prueth_netdev_init() and emac_ndo_open(), while max_rx is 1. "ethtool -l"
would then show a current value above the maximum.

The ethtool core starts from the get_channels() values and rejects
rx_count > max_rx. Doesn't that mean "ethtool -L ethX tx N" without an rx
argument now fails with -EINVAL on SR1?

[ ... ]

> @@ -264,7 +271,8 @@ static int emac_set_coalesce(struct net_device *ndev,
>  		coal->tx_coalesce_usecs = ICSSG_MIN_COALESCE_USECS;
>  	}
>  
> -	emac->rx_pace_timeout_ns = coal->rx_coalesce_usecs * 1000;
> +	for (i = 0; i < PRUETH_MAX_RX_FLOWS; i++)
> +		rx_chn->flows[i].rx_pace_timeout_ns = coal->rx_coalesce_usecs * 1000;
>  	tx_chn->tx_pace_timeout_ns = coal->tx_coalesce_usecs * 1000;

[Severity: Low]
Now that RX coalescing is per flow, should emac_get_per_queue_coalesce()
and emac_set_per_queue_coalesce() handle it as well? Both still bound the
queue by PRUETH_MAX_TX_QUEUES and only touch tx_coalesce_usecs.

As a result, a per-queue rx-usecs request on queues 1..3 returns success
but has no effect, and RX queues 4..7 are rejected with -EINVAL.

> 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

[ ... ]

> @@ -921,7 +866,39 @@ static void prueth_destroy_txq(struct prueth_emac *emac)
>  	}
>  }
>  
> -static void prueth_destroy_rxq(struct prueth_emac *emac)
> +static void prueth_destroy_rxq(struct prueth_emac *emac, int qid)
> +{
> +	struct prueth_rx_chn *rx_chn = &emac->rx_chns;
> +	struct prueth_rx_flow *flow = &rx_chn->flows[qid];
> +	dma_addr_t desc_dma;
> +
> +	napi_disable(&flow->napi_rx);
> +	hrtimer_cancel(&flow->rx_hrtimer);
> +
> +	/* k3_udma_glue_reset_rx_chn() only drains the FDQ; it resets the
> +	 * completion ring (RXCQ) without freeing descriptors still in it.
> +	 * Teardown posts TDCM only to flow 0's RXCQ; flows 1..N have no
> +	 * NAPI trigger to drain their RXCQs. Drain each flow's RXCQ here
> +	 * so page_pool_destroy() finds no inflight pages.
> +	 */
> +	while (!k3_udma_glue_pop_rx_chn(rx_chn->rx_chn, qid, &desc_dma)) {
> +		if (!cppi5_desc_is_tdcm(desc_dma))
> +			prueth_rx_cleanup(rx_chn, desc_dma);
> +	}
> +
> +	k3_udma_glue_reset_rx_chn(rx_chn->rx_chn, flow->id, rx_chn,
> +				  prueth_rx_cleanup);

[Severity: High]
When prueth_xsk_pool_enable() or prueth_xsk_pool_disable() calls this,
the shared UDMA RX channel is still enabled. Nothing calls
k3_udma_glue_tdown_rx_chn() or disables the channel, and
prueth_create_rxq() does not re-enable it. Is it safe to drain and reset
the rings of a live channel here?

A descriptor can complete after the drain loop but before the RXCQ reset
inside k3_udma_glue_reset_rx_chn(). That reset is k3_ringacc_ring_reset(),
which runs no cleanup, so the descriptor is dropped without being freed.

It then stays allocated in desc_pool, and the next ndo_stop reaches
k3_cppi_desc_pool_destroy() with outstanding descriptors, which hits the
BUG_ON in gen_pool_destroy(). Its page also keeps the old page_pool in
flight.

The FDQ popped here is still being consumed by the DMA engine. The commit
message also notes that UDMA may have prefetched FDQ descriptors, which
could complete later with stale swdata.

The baseline did a full channel teardown, waited for the TDCM, and then
disabled and re-enabled the channel. So this also affects the default
rx_flow_num == 1 XSK case.

[ ... ]

> @@ -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)
>  {

[ ... ]

> +	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);
> +	}
> +	return 0;

[Severity: Medium]
Can this lead to unbalanced enable_irq() calls? irq_disabled is written
from prueth_rx_irq() (hardirq), emac_rx_timer_callback(), the NAPI poll,
and now here from process context. There is no lock and no atomic
test-and-clear.

The flag is never reset across close/open. It stays true if the IRQ fired
after napi_disable(), or if prueth_destroy_rxq() cancelled a pending
pacing hrtimer. free_irq() followed by request_irq() resets the IRQ depth
to 0, so this enable_irq() on the next open would trigger the "Unbalanced
enable for IRQ" warning.

In the XSK enable/disable path, the flow's NAPI may also complete on
another CPU right after napi_enable(). Both sides can then see
irq_disabled == true and both call enable_irq().

prueth_sr1_reset_rx_mgm_chn() uses the same flag. After the disable path
it leaves the mgm flows with irq_disabled = true, and open does not reset
it. From the second SR1 stop on, disable_irq() is skipped while the mgm
rings are reset.

[ ... ]

> @@ -1136,6 +1167,8 @@ static int emac_ndo_stop(struct net_device *ndev)
>  	struct prueth_emac *emac = netdev_priv(ndev);
>  	struct prueth *prueth = emac->prueth;
>  
> +	bitmap_zero(emac->xsk_queues, PRUETH_MAX_RX_FLOWS);
> +

[Severity: High]
Does clearing xsk_queues here, and again in emac_ndo_open(), leave XSK
pools DMA-mapped with no way to unmap them? The XSK core keeps the pool
bound across ifdown, because xsk_notifier only acts on NETDEV_UNREGISTER.

When the AF_XDP socket is closed later:

xp_disable_drv_zc()
  emac_ndo_bpf(XDP_SETUP_XSK_POOL, pool = NULL)
    prueth_xsk_pool_disable()
        if (!test_bit(queue_id, emac->xsk_queues)) {
            ...
            return -EINVAL;

xsk_pool_dma_unmap() is skipped, and xp_disable_drv_zc() hits
WARN(1, "Failed to disable zero-copy!"). The mapping made by
xsk_pool_dma_map() is never released, even after the umem pages are
freed.

After ifdown/ifup, rx_flow->xsk_pool and tx_chn->xsk_pool are also NULL,
so the driver silently stops servicing the still-bound socket.

Before this patch ndo_stop did not touch xsk_qid, so bind, ifdown and
close unmapped correctly.

[ ... ]

> @@ -1544,27 +1598,29 @@ static int prueth_xsk_pool_disable(struct prueth_emac *emac, u16 queue_id)
>  		ret = icssg_set_port_state(emac, ICSSG_EMAC_PORT_DISABLE);
>  		if (ret)
>  			return ret;
> -		prueth_destroy_rxq(emac);
> +		prueth_destroy_rxq(emac, queue_id);
>  	}
>  
>  	xsk_pool_dma_unmap(pool, PRUETH_RX_DMA_ATTR);
> -	emac->xsk_qid = -EINVAL;
> +	clear_bit(queue_id, emac->xsk_queues);
>  	prueth_set_xsk_pool(emac, 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]
What happens on the ifdown that this message recommends? prueth_destroy_rxq()
has already run napi_disable() on this flow, and the err: path in
prueth_create_rxq() skips napi_enable(). Later:

emac_ndo_stop()
  prueth_destroy_rxqs()
    prueth_destroy_rxq()
      napi_disable(&flow->napi_rx);

This calls napi_disable() a second time on the same NAPI.
NAPI_STATE_SCHED stays set on a disabled NAPI, so napi_disable_locked()
spins forever while holding the netdev lock and RTNL.

The best-effort prueth_create_rxq() in the err_napi path of
prueth_xsk_pool_enable() has the same problem when it fails. If the
failed queue is flow 0, the RX TDCM would never be popped either.

[ ... ]

> 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
> @@ -303,10 +303,10 @@ static struct page *prueth_process_rx_mgm(struct prueth_emac *emac,
>  	page = swdata->data.page;
>  	cppi5_hdesc_get_obuf(desc_rx, &buf_dma, &buf_dma_len);
>  
> -	dma_unmap_single(rx_chn->dma_dev, buf_dma, buf_dma_len, DMA_FROM_DEVICE);
> +	page_pool_dma_sync_for_cpu(rx_chn->flows[flow_id].pg_pool, page, 0, PAGE_SIZE);
>  	k3_cppi_desc_pool_free(rx_chn->desc_pool, desc_rx);
>  
> -	new_page = page_pool_dev_alloc_pages(rx_chn->pg_pool);
> +	new_page = page_pool_dev_alloc_pages(rx_chn->flows[flow_id].pg_pool);
>  	/* if allocation fails we drop the packet but push the
>  	 * descriptor back to the ring with old skb to prevent a stall
>  	 */
> @@ -319,14 +319,123 @@ static struct page *prueth_process_rx_mgm(struct prueth_emac *emac,
>  	}
>  
>  	/* queue another 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]
With several flows sharing rx_chn->desc_pool, the free count of the
whole pool no longer tells how many buffers this flow can post.
Whenever another flow holds fewer than PRUETH_MAX_RX_DESC descriptors,
avail_desc is non-zero even when this flow's 512-entry FDQ is already
full. A second XSK flow whose fill ring is not full is one example.

prueth_rx_alloc_zc() then allocates an xdp_buff and a descriptor, and
k3_udma_glue_push_rx_chn() fails with -ENOMEM because the ring is
full. As a result:

- a netdev_err() is logged on every poll
- the buffer is handed back with xsk_buff_free()
- need_wakeup is set because ret < alloc_budget

So userspace keeps kicking NAPI into the same failure. This happens on
AM64x PKTDMA, where each flow has its own FDQ, even with only one NAPI
running.

The concurrent case also hits page-pool flows. emac_rx_packet() frees
its descriptor with k3_cppi_desc_pool_free() before
prueth_dma_rx_push_mapped() allocates the replacement. An XSK flow
refilling on another CPU can take that descriptor in between.

The page-pool flow then hits WARN_ON(ret < 0) and recycles new_page.
It permanently loses one posted buffer, since it only refills
one-for-one on completions.

The commit message defers this together with the AM654 FDQ work, but
this patch already enables multiple flows on AM64x. Could the refill
budget be bounded per flow, for example by tracking how many buffers
each flow has posted? Or should each flow get its own share of the
descriptor pool?

[Severity: Medium]
These hunks fix two existing SR1 bugs in prueth_process_rx_mgm(). The old
dma_unmap_single() unmapped a page owned by a PP_FLAG_DMA_MAP page_pool.
The old refill pushed into the data channel (&emac->rx_chns) instead of
the management channel.

The commit message mentions neither fix, and there is no Fixes: tag.
Could they be split into a separate patch so stable kernels pick them up?

[ ... ]

> +	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++) {

[Severity: Low]
Should this compare against the mgm sizes instead? The mgm descriptor
pool holds PRUETH_MAX_RX_MGM_DESC_SR1 * 2 = 16 entries. Comparing against
PRUETH_MAX_RX_DESC (512) makes this warning fire on every SR1 open.

The loop then pushes 16 buffers into an FDQ sized
PRUETH_MAX_RX_MGM_DESC_SR1 (8). The 9th push fails, so "failed to push rx
mgm buf" is also logged on every open.

[ ... ]

> @@ -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]
Where is emac->xsk_queues allocated for SR1? devm_bitmap_zalloc() is only
called from the SR2 prueth_netdev_init() in icssg_prueth.c. The SR1
prueth_netdev_init() in this file never allocates it, so the pointer is
NULL in the zeroed netdev_priv.

With nbits = 8, bitmap_zero() compiles to *dst = 0. Wouldn't every SR1
ifup oops here?

[ ... ]

> +		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;

[Severity: High]
This gives each mgm flow its own FDQ. k3-udma-glue still marks UDMAP
channels single_fdq, so k3_udma_glue_reset_rx_chn() skips the FDQ drain
for every flow except flow 0:

	if (rx_chn->single_fdq && flow_num)
		goto do_reset;

prueth_sr1_prepare_rx_mgm_flow() fills the TIMESTAMP flow's FDQ, and
prueth_sr1_reset_rx_mgm_chn() then never drains it.

Could prueth_sr1_cleanup_rx_mgm_chn() then call page_pool_destroy() with
pages in flight and k3_cppi_desc_pool_destroy() with 8 descriptors
outstanding? That would hit the BUG_ON in gen_pool_destroy() on every SR1
ifdown.

The baseline shared flow 0's FDQ across the mgm flows, which matched
single_fdq.

[ ... ]

> @@ -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;

[Severity: High]
Does this goto leak flows[PRUETH_RX_FLOW_DATA_SR1].pg_pool? The new
page_pool_destroy() sits under reset_rx_chn:, and prueth_cleanup_rx_chns()
no longer destroys page pools.

The failure can also happen partway through the push loop. In that case
prueth_prepare_rx_flow() calls k3_udma_glue_reset_rx_chn() for flow 3
under err_free_pushed. On UDMAP that call skips the FDQ drain
(single_fdq && flow_num), and the stop path never resets rx_chns.

Wouldn't cleanup_rx then call k3_cppi_desc_pool_destroy() with
descriptors still allocated and hit the BUG_ON in gen_pool_destroy()?

>  
> -	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]
If prueth_sr1_prepare_rx_mgm_flow() fails here for the TIMESTAMP flow,
or k3_udma_glue_enable_rx_chn() on rx_mgm_chn fails just below, the
RESPONSE flow has already pushed pages and descriptors into its FDQ.
Both branches jump to reset_rx_chn:, which skips
prueth_sr1_reset_rx_mgm_chn().

Nothing drains rx_mgm_chn before prueth_sr1_cleanup_rx_mgm_chn() runs.
It then destroys flows[0].pg_pool with pages still in flight and calls
k3_cppi_desc_pool_destroy() with descriptors still allocated. That
trips the WARN there and the BUG_ON in gen_pool_destroy().

Should both branches go to reset_rx_mgm_chn: instead? That label calls
prueth_sr1_reset_rx_mgm_chn(emac, true), which also disables a channel
that was never enabled. Is that harmless here, or does this unwind
need a reset-only step?

[Severity: High]
The TIMESTAMP flow setup can fail here, for example if page_pool_create()
fails. By then the RESPONSE flow's FDQ is already filled. Jumping to
reset_rx_chn: skips prueth_sr1_reset_rx_mgm_chn().

Does anything drain those descriptors and pages before
prueth_sr1_cleanup_rx_mgm_chn() destroys the page pool and the mgm
descriptor pool? Without that, this also looks like it reaches the
BUG_ON in gen_pool_destroy().

The k3_udma_glue_enable_rx_chn(emac->rx_mgm_chn.rx_chn) failure already
used this label before the patch. The new call adds another failure
point, reached after the RESPONSE flow has been filled.

[ ... ]

> @@ -612,27 +817,29 @@ static int emac_ndo_open(struct net_device *ndev)
>  	 */
>  	prueth_reset_tx_chan(emac, i, false);
>  reset_rx_mgm_chn:

[ ... ]

>  free_rx_irq:
> -	free_irq(emac->rx_chns.irq[rx_flow], emac);
> +	prueth_ndev_del_rx_napi(emac, 1);

[Severity: Medium]
prueth_ndev_add_rx_napi() registered a NAPI, hrtimer and IRQ for every
flow up to emac->rx_flow_num (PRUETH_MAX_RX_FLOWS_SR1), but only flow 0
is torn down here. Doesn't this leave the IRQs and NAPIs for flows 1..3,
including data flow 3, registered?

The next open's request_irq() would then fail with -EBUSY. After
free_netdev(), those handlers would also keep a dev_id pointing into the
freed netdev_priv. emac_ndo_stop() passes PRUETH_MAX_RX_FLOWS_SR1 here.

[ ... ]

> @@ -683,16 +888,20 @@ static int emac_ndo_stop(struct net_device *ndev)
>  	for (i = 0; i < emac->tx_ch_num; i++)
>  		napi_disable(&emac->tx_chns[i].napi_tx);
>  
> -	max_rx_flows = PRUETH_MAX_RX_FLOWS_SR1;
>  	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: Medium]
The data flow's page pool was created with
pp_params.napi = &rx_flow->napi_rx, but it is destroyed here before that
NAPI is disabled. Doesn't page_pool_destroy() ->
page_pool_disable_direct_recycling() -> napi_assert_will_not_race() warn
when the NAPI is still enabled and idle?

A NAPI run during this window could also reach emac_rx_packet() after
the pool has been destroyed and pg_pool set to NULL.

Before the patch, prueth_cleanup_rx_chns() destroyed the pool after
napi_disable(). Should page_pool_destroy() move after this napi_disable()?

[ ... ]

> @@ -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);
>  
>  	pruss_release_mem_region(prueth->pruss, &emac->dram);
>  	free_netdev(emac->ndev);

[Severity: High]
This patch calls three rxnfc functions:

- icssg_rxnfc_rule_init() from prueth_netdev_init()
- icssg_rxnfc_rule_restore() from emac_ndo_open()
- icssg_rxnfc_rule_cleanup() from prueth_netdev_exit()

It also declares them in icssg_prueth.h. None of them is defined until
patch 2/2.

icssg_common.o is linked into icssg.o for both CONFIG_TI_ICSSG_PRUETH
and CONFIG_TI_ICSSG_PRUETH_SR1. Doesn't this patch on its own then fail
to link with undefined symbols for both drivers? That breaks bisection
through the series.

Could the following move into the classification patch, so this one
builds on its own?

- the rxnfc declarations
- struct prueth_rxnfc and the rxnfc member of struct prueth_emac
- these three calls

[ ... ]

> @@ -1488,59 +1547,81 @@ int icssg_napi_rx_poll(struct napi_struct *napi_rx, int budget)
>  }
>  EXPORT_SYMBOL_GPL(icssg_napi_rx_poll);
>  
> -int prueth_prepare_rx_chan(struct prueth_emac *emac,
> -			   struct prueth_rx_chn *chn,
> -			   int buf_size)
> +int prueth_prepare_rx_flow(struct prueth_emac *emac,
> +			   int flow)
>  {
> +	int buf_size = PRUETH_MAX_PKT_SIZE;
> +	struct prueth_rx_flow *rx_flow;
> +	struct prueth_rx_chn *rx_chn;
> +	struct page_pool *pool;
>  	struct page *page;
>  	int desc_avail;
>  	int i, ret;
>  
> -	desc_avail = k3_cppi_desc_pool_avail(chn->desc_pool);
> -	if (desc_avail < chn->descs_num)
> -		netdev_warn(emac->ndev,
> -			    "not enough RX descriptors available %d < %d\n",
> -			    desc_avail, chn->descs_num);
> +	rx_chn = &emac->rx_chns;
> +	rx_flow = &emac->rx_chns.flows[flow];
>  
> -	if (chn->xsk_pool) {
> -		/* get pages from xsk_pool and push to RX ring
> -		 * queue as much as possible
> +	if (rx_flow->xsk_pool) {
> +		/* XSK zero-copy: buffers come from the XSK fill ring, no page
> +		 * pool needed.  Push up to PRUETH_MAX_RX_DESC XSK buffers.
>  		 */
> -		ret = prueth_rx_alloc_zc(emac, desc_avail);
> -		if (!ret)
> -			goto recycle_alloc_pg;
> -	} else {
> -		for (i = 0; i < desc_avail; i++) {
> -			/* NOTE: we're not using memory efficiently here.
> -			 * 1 full page (4KB?) used here instead of
> -			 * PRUETH_MAX_PKT_SIZE (~1.5KB?)
> -			 */
> -			page = page_pool_dev_alloc_pages(chn->pg_pool);
> -			if (!page) {
> -				netdev_err(emac->ndev, "couldn't allocate rx page\n");
> -				ret = -ENOMEM;
> -				goto recycle_alloc_pg;
> -			}
> +		desc_avail = k3_cppi_desc_pool_avail(rx_chn->desc_pool);
> +		if (desc_avail < PRUETH_MAX_RX_DESC) {
> +			netdev_err(emac->ndev,
> +				   "not enough RX descriptors available %d < %d\n",
> +				   desc_avail, PRUETH_MAX_RX_DESC);
> +			return -ENOSPC;
> +		}
>  
> -			ret = prueth_dma_rx_push_mapped(emac, chn, page, buf_size);
> -			if (ret < 0) {
> -				netdev_err(emac->ndev,
> -					   "cannot submit page for rx chan %s ret %d\n",
> -					   chn->name, ret);
> -				page_pool_recycle_direct(chn->pg_pool, page);
> -				goto recycle_alloc_pg;
> -			}
> +		prueth_rx_alloc_zc(emac, flow, PRUETH_MAX_RX_DESC);
> +		return 0;
> +	}
> +
> +	pool = prueth_create_page_pool(emac, rx_chn->dma_dev, rx_chn->descs_num, rx_flow);
> +	if (IS_ERR(pool))
> +		return PTR_ERR(pool);
> +
> +	rx_flow->pg_pool = pool;
> +
> +	desc_avail = k3_cppi_desc_pool_avail(rx_chn->desc_pool);
> +	if (desc_avail < PRUETH_MAX_RX_DESC) {
> +		netdev_err(emac->ndev,
> +			   "not enough RX descriptors available %d < %d\n",
> +			   desc_avail, PRUETH_MAX_RX_DESC);
> +		ret = -ENOSPC;
> +		goto err_free_pushed;
> +	}
> +
> +	for (i = 0; i < PRUETH_MAX_RX_DESC; ++i) {
> +		page = page_pool_dev_alloc_pages(pool);
> +		if (!page) {
> +			netdev_err(emac->ndev, "couldn't allocate rx page\n");
> +			ret = -ENOMEM;
> +			goto err_free_pushed;
> +		}
> +
> +		ret = prueth_dma_rx_push_mapped(emac, rx_chn, page, buf_size, flow);
> +		if (ret < 0) {
> +			netdev_err(emac->ndev,
> +				   "cannot submit skb for rx chan %s ret %d\n",
> +				   rx_flow->name, ret);
> +			page_pool_recycle_direct(pool, page);
> +			goto err_free_pushed;
>  		}
>  	}
>  
>  	return 0;
>  
> -recycle_alloc_pg:
> -	prueth_reset_rx_chan(&emac->rx_chns, PRUETH_MAX_RX_FLOWS, false);
> -
> +err_free_pushed:
> +	/* i pages were successfully pushed to the ring.  Reset the channel
> +	 * to drain them back and recycle via prueth_rx_cleanup before the
> +	 * caller destroys the page pool.
> +	 */
> +	k3_udma_glue_reset_rx_chn(rx_chn->rx_chn, flow, rx_chn,
> +				   prueth_rx_cleanup);
>  	return ret;
>  }
> -EXPORT_SYMBOL_GPL(prueth_prepare_rx_chan);
> +EXPORT_SYMBOL_GPL(prueth_prepare_rx_flow);
>  
>  void prueth_reset_tx_chan(struct prueth_emac *emac, int ch_num,
>  			  bool free_skb)

[Severity: Medium]
prueth_init_rx_chns() now sets rx_chn->descs_num to
PRUETH_MAX_RX_DESC * rx_flow_num for the shared descriptor pool. This
call passes that total as the pool_size of every per-flow page pool,
but each flow only ever posts PRUETH_MAX_RX_DESC pages.

page_pool_init() sizes the ptr_ring from pool_size. With 8 flows, each
flow gets a 4096-entry ring, and its pool can keep up to 4096 recycled
pages DMA-mapped.

With 4 KiB pages that is up to 128 MiB per port rather than 16 MiB,
and it grows with the square of the flow count. On SR1, rx_flow_num is
PRUETH_MAX_RX_FLOWS_SR1, so the one data flow's pool is sized 2048
instead of 512.

Should this pass PRUETH_MAX_RX_DESC instead?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203121447.2605779-1-m-malladi%40ti.com


  reply	other threads:[~2026-12-04 13:26 UTC|newest]

Thread overview: 5+ 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 13:25   ` netdev-bot+sashiko [this message]
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 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=179639071239.3146.7243377057709644659@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=danishanwar@ti.com \
    --cc=davem@davemloft.net \
    --cc=devnexen@gmail.com \
    --cc=edumazet@kernel.org \
    --cc=haokexin@gmail.com \
    --cc=hawk@kernel.org \
    --cc=horms@kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=kees+treewide@kernel.org \
    --cc=kuba@kernel.org \
    --cc=laixiangwu@cmss.chinamobile.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=m-malladi@ti.com \
    --cc=marco.crivellari@suse.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=philippe.schenker@impulsing.ch \
    --cc=rogerq@kernel.org \
    --cc=sdf@fomichev.me \
    --cc=srk@ti.com \
    --cc=vigneshr@ti.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