From: Jakub Kicinski <kuba@kernel.org>
To: xuanzhuo@linux.alibaba.com
Cc: Jakub Kicinski <kuba@kernel.org>,
davem@davemloft.net, netdev@vger.kernel.org, andrew@lunn.ch,
andrew+netdev@lunn.ch, dust.li@linux.alibaba.com,
pabeni@redhat.com, vadim.fedorenko@linux.dev, dong100@mucse.com,
guwen@linux.alibaba.com, lorenzo@kernel.org, edumazet@google.com,
lulie@linux.alibaba.com, lukas.bulwahn@redhat.com
Subject: Re: [net-next,v20,4/6] eea: create/destroy rx,tx queues for netdevice open and stop
Date: Mon, 19 Jan 2026 14:42:17 -0800 [thread overview]
Message-ID: <20260119224217.1362965-1-kuba@kernel.org> (raw)
In-Reply-To: <20260115031042.104164-5-xuanzhuo@linux.alibaba.com>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
eea: create/destroy rx,tx queues for netdevice open and stop
This commit adds netdevice open and stop operations for the EEA driver,
including TX and RX queue allocation/deallocation and NAPI setup.
> diff --git a/drivers/net/ethernet/alibaba/eea/eea_tx.c b/drivers/net/ethernet/alibaba/eea/eea_tx.c
> new file mode 100644
> index 000000000000..f3e648960918
> --- /dev/null
> +++ b/drivers/net/ethernet/alibaba/eea/eea_tx.c
[ ... ]
> +static void eea_tx_meta_put_and_unmap(struct eea_net_tx *tx,
> + struct eea_tx_meta *meta)
> +{
> + struct eea_tx_meta *head;
> +
> + head = meta;
> +
> + while (true) {
> + dma_unmap_single(tx->dma_dev, meta->dma_addr,
> + meta->dma_len, DMA_TO_DEVICE);
> +
> + meta->data = NULL;
> +
> + if (meta->next) {
> + meta = meta->next;
> + continue;
> + }
> +
> + break;
> + }
> +
> + meta->next = tx->free;
> + tx->free = head;
> +}
> +
> +static void eea_meta_free_xmit(struct eea_net_tx *tx,
> + struct eea_tx_meta *meta,
> + bool in_napi,
> + struct eea_tx_cdesc *desc,
> + struct eea_sq_free_stats *stats)
> +{
> + struct sk_buff *skb = meta->skb;
> +
> + if (!skb) {
> + netdev_err(tx->enet->netdev,
> + "tx meta->skb is null. id %d num: %d\n",
> + meta->id, meta->num);
> + return;
> + }
> +
> + if (unlikely((skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) && desc)) {
> + struct skb_shared_hwtstamps ts = {};
> +
> + ts.hwtstamp = EEA_DESC_TS(desc) + tx->enet->hw_ts_offset;
> + skb_tstamp_tx(skb, &ts);
> + }
> +
> + stats->bytes += meta->skb->len;
> + napi_consume_skb(meta->skb, in_napi);
> +}
[ ... ]
> +static u32 eea_clean_tx(struct eea_net_tx *tx)
> +{
> + struct eea_sq_free_stats stats = {0};
> + struct eea_tx_cdesc *desc;
> + struct eea_tx_meta *meta;
> +
> + while ((desc = ering_cq_get_desc(tx->ering))) {
> + ++stats.packets;
> +
> + meta = &tx->meta[le16_to_cpu(desc->id)];
> +
> + eea_meta_free_xmit(tx, meta, true, desc, &stats);
> +
> + ering_cq_ack_desc(tx->ering, meta->num);
> + eea_tx_meta_put_and_unmap(tx, meta);
> + }
> +
> + return stats.packets;
> +}
[ ... ]
> +static int eea_tx_post_skb(struct eea_net_tx *tx, struct sk_buff *skb)
> +{
> + const struct skb_shared_info *shinfo = skb_shinfo(skb);
> + u32 hlen = skb_headlen(skb);
> + struct eea_tx_meta *meta;
> + dma_addr_t addr;
> + int i, err;
> + u16 flags;
> +
> + addr = dma_map_single(tx->dma_dev, skb->data, hlen, DMA_TO_DEVICE);
> + if (unlikely(dma_mapping_error(tx->dma_dev, addr)))
> + return -ENOMEM;
[ ... ]
> +static void eea_free_meta(struct eea_net_tx *tx, struct eea_net_cfg *cfg)
> +{
> + struct eea_sq_free_stats stats;
> + struct eea_tx_meta *meta;
> + int i;
> +
> + while ((meta = eea_tx_meta_get(tx)))
> + meta->skb = NULL;
> +
> + for (i = 0; i < cfg->tx_ring_depth; i++) {
> + meta = &tx->meta[i];
> +
> + if (!meta->skb)
> + continue;
> +
> + eea_meta_free_xmit(tx, meta, false, NULL, &stats);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
In eea_clean_tx(), after calling eea_meta_free_xmit(), there is a call to
eea_tx_meta_put_and_unmap() which performs dma_unmap_single() for the DMA
mappings.
Here in eea_free_meta(), only eea_meta_free_xmit() is called but
eea_tx_meta_put_and_unmap() is not. The DMA mappings created in
eea_tx_post_skb() via dma_map_single() and skb_frag_dma_map() would not
be unmapped when the device is closed with pending TX packets. Does this
leak DMA mappings?
> +
> + meta->skb = NULL;
> + }
> +
> + kvfree(tx->meta);
> + tx->meta = NULL;
> +}
--
pw-bot: cr
next prev parent reply other threads:[~2026-01-19 22:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-15 3:10 [PATCH net-next v20 0/6] eea: Add basic driver framework for Alibaba Elastic Ethernet Adaptor Xuan Zhuo
2026-01-15 3:10 ` [PATCH net-next v20 1/6] eea: introduce PCI framework Xuan Zhuo
2026-01-15 3:10 ` [PATCH net-next v20 2/6] eea: introduce ring and descriptor structures Xuan Zhuo
2026-01-15 3:10 ` [PATCH net-next v20 3/6] eea: probe the netdevice and create adminq Xuan Zhuo
2026-01-15 3:10 ` [PATCH net-next v20 4/6] eea: create/destroy rx,tx queues for netdevice open and stop Xuan Zhuo
2026-01-19 22:42 ` Jakub Kicinski [this message]
2026-01-15 3:10 ` [PATCH net-next v20 5/6] eea: introduce ethtool support Xuan Zhuo
2026-01-15 3:10 ` [PATCH net-next v20 6/6] eea: introduce callback for ndo_get_stats64 Xuan Zhuo
2026-01-19 22:42 ` [net-next,v20,6/6] " Jakub Kicinski
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=20260119224217.1362965-1-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=dong100@mucse.com \
--cc=dust.li@linux.alibaba.com \
--cc=edumazet@google.com \
--cc=guwen@linux.alibaba.com \
--cc=lorenzo@kernel.org \
--cc=lukas.bulwahn@redhat.com \
--cc=lulie@linux.alibaba.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=vadim.fedorenko@linux.dev \
--cc=xuanzhuo@linux.alibaba.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