Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: mana: Drop TX skb on post_work_request failure and unmap resources

Drop TX packets when posting the work request fails and ensure DMA
mappings are always cleaned up.

Signed-off-by: Aditya Garg <gargaditya@linux.microsoft.com>
Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
Link: https://patch.msgid.link/1763464269-10431-3-git-send-email-gargaditya@linux.microsoft.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Aditya Garg and committed by
Jakub Kicinski
45120304 934fa943

+5 -9
+1 -5
drivers/net/ethernet/microsoft/mana/gdma_main.c
··· 1300 1300 struct gdma_posted_wqe_info *wqe_info) 1301 1301 { 1302 1302 u32 client_oob_size = wqe_req->inline_oob_size; 1303 - struct gdma_context *gc; 1304 1303 u32 sgl_data_size; 1305 1304 u32 max_wqe_size; 1306 1305 u32 wqe_size; ··· 1329 1330 if (wqe_size > max_wqe_size) 1330 1331 return -EINVAL; 1331 1332 1332 - if (wq->monitor_avl_buf && wqe_size > mana_gd_wq_avail_space(wq)) { 1333 - gc = wq->gdma_dev->gdma_context; 1334 - dev_err(gc->dev, "unsuccessful flow control!\n"); 1333 + if (wq->monitor_avl_buf && wqe_size > mana_gd_wq_avail_space(wq)) 1335 1334 return -ENOSPC; 1336 - } 1337 1335 1338 1336 if (wqe_info) 1339 1337 wqe_info->wqe_size_in_bu = wqe_size / GDMA_WQE_BU_SIZE;
+3 -4
drivers/net/ethernet/microsoft/mana/mana_en.c
··· 492 492 493 493 if (err) { 494 494 (void)skb_dequeue_tail(&txq->pending_skbs); 495 + mana_unmap_skb(skb, apc); 495 496 netdev_warn(ndev, "Failed to post TX OOB: %d\n", err); 496 - err = NETDEV_TX_BUSY; 497 - goto tx_busy; 497 + goto free_sgl_ptr; 498 498 } 499 499 500 500 err = NETDEV_TX_OK; ··· 514 514 tx_stats->bytes += len + ((num_gso_seg - 1) * gso_hs); 515 515 u64_stats_update_end(&tx_stats->syncp); 516 516 517 - tx_busy: 518 517 if (netif_tx_queue_stopped(net_txq) && mana_can_tx(gdma_sq)) { 519 518 netif_tx_wake_queue(net_txq); 520 519 apc->eth_stats.wake_queue++; ··· 1686 1687 return 0; 1687 1688 } 1688 1689 1689 - static void mana_unmap_skb(struct sk_buff *skb, struct mana_port_context *apc) 1690 + void mana_unmap_skb(struct sk_buff *skb, struct mana_port_context *apc) 1690 1691 { 1691 1692 struct mana_skb_head *ash = (struct mana_skb_head *)skb->head; 1692 1693 struct gdma_context *gc = apc->ac->gdma_dev->gdma_context;
+1
include/net/mana/mana.h
··· 593 593 void mana_query_phy_stats(struct mana_port_context *apc); 594 594 int mana_pre_alloc_rxbufs(struct mana_port_context *apc, int mtu, int num_queues); 595 595 void mana_pre_dealloc_rxbufs(struct mana_port_context *apc); 596 + void mana_unmap_skb(struct sk_buff *skb, struct mana_port_context *apc); 596 597 597 598 extern const struct ethtool_ops mana_ethtool_ops; 598 599 extern struct dentry *mana_debugfs_root;