From patchwork Sun Sep 27 21:59:46 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 3522 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mxe881.netcup.net (Postfix) with ESMTPS id 66DB61C3164 for ; Mon, 28 Sep 2026 00:02:39 +0200 (CEST) Authentication-Results: mxe881; dkim=pass header.d=gmail.com; spf=pass (sender IP is 172.232.135.74) smtp.mailfrom=linux-sunxi+bounces-26360-noreply=patchwork.local@lists.linux.dev smtp.helo=sto.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.232.135.74 as permitted sender) client-ip=172.232.135.74; envelope-from=linux-sunxi+bounces-26360-noreply=patchwork.local@lists.linux.dev; helo=sto.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sto.lore.kernel.org (Postfix) with ESMTP id 0817860640D for ; Sun, 27 Sep 2026 22:01:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 17E87449EA9; Sun, 27 Sep 2026 22:00:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WNlkVfif" X-Original-To: linux-sunxi@lists.linux.dev Received: from mail-oo2-f37.google.com (mail-oo2-f37.google.com [74.125.231.165]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 83F233CE4B5 for ; Sun, 27 Sep 2026 22:00:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.231.165 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790546423; cv=none; b=q46A8Jg+eYNC3otCi08OJSpPs1Q01ICFHQEbIGxCI/Ty1ppFspDk1ju3nBo39m8ePQ+uBDPYE+JYGIjFbrF6aNVWR8YnTn5JfULGLt2uJ1BTFLyttq4V7dTd/68VncOvvtHrXLzNYYHXvb1cHaCVQiD/On0c05l90FrHmVBTVgE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790546423; c=relaxed/simple; bh=hGe7opUWtd3dH+BdZuV25FvF4CrbbA/rtGiLv7Y7dx0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qzrMe0u9C38FBW/UwvTziT8gfXRd5tk8IwT/RoOOcg8VXqoNqtfEiKYOLSd3sYAV+zd7qTe9+dTv7PymNGPSA5DDU84BXnrJ1rW7PAIeFqye7G6IcRAOdeaBGp/F525TCvvtUk2kQTrp4X7iv2kJQwr+6zL9GxXDuQO7YPe4CiA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=WNlkVfif; arc=none smtp.client-ip=74.125.231.165 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oo2-f37.google.com with SMTP id 46e09a7af769-8137b129131so1604975a34.2 for ; Sun, 27 Sep 2026 15:00:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790546414; x=1791151214; darn=lists.linux.dev; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=83ThLbPC5Dd2yel01jjZwvC9Fqqb0286KBpR//NQh0A=; b=WNlkVfif4BaF2RVfexOqRtc7oZkfi5qxxkL2La79ZnDFdi7FzbSlI4POEhDu3r+V6h 1d8VVjG6aVIYHeOcmDU+vVYKRx4wf2yjft4II1ckzo6eF8Y7vHW9+pfzYfKO/pBR8Kyx 84JGDJ6Rr6NNmtyi9m3S/sjexL1STnaoo2ErhnJxp3vSyMA9BevGHsRtTpdlf79zLMq5 mfTN2uuDNRMfHVIfB2PdozkYJ/NO8hH99Blo09yt/20Ed5GV6+7KB+mMel+nGHpsctMK JrgshDQILsdQk7CU3UmFnKl6X7MqykD4GcJust7zdvpVcx2hkInTO2b9y+QLViaxfaus EHEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790546414; x=1791151214; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=83ThLbPC5Dd2yel01jjZwvC9Fqqb0286KBpR//NQh0A=; b=ExdXKof+qZbwGskxSaf/FcH7U0kWsTrvJmlKuXS+7QDWMHvjNICnz12sOgNi3yxOKX 6TbsBhcNl52naKRVpkKaMP95LxX2JHoWHWZs089BCI+K7XSiy9j9pktt/vDAa4vB4RfY fDiQii06mPrFnnzZ5KFhjJrUnyU1M8SkoCUN1nBL52SxIenb5BnL6ZAk1Forz4QKqgna OGkE28OG1tfc4s2pIVoTI9ewq1tLUz95f3b/Ra/JQ3f0PnZNAdxCxNMwL0hHJ5b0SKaV wM8ovxSkDKPaoAIauqcMkUdVQ53rTFLI7QTF6g3X/rWgBosaGcRkbZjK52uYn36Hq150 wF6g== X-Forwarded-Encrypted: i=1; AKwUvBxynUX3RMjqC1wBMP/Hxt32zz7HE3knB425xWZw89oHlmJUgLfWOBp/enl2MZPZw1TE7ODF7RQgmdGG8A==@lists.linux.dev X-Gm-Message-State: AFuF++k4H7Q2g4WAijg8b/pIc2lb7aWCVHY4qbRs94HpdL5evr8XaM9A hC9TGehpQXU5rP5Pwl1j7DiIWAiCDRwY4nBax5zu1J4dgrsudXNQQ+dQ X-Gm-Gg: AYBFou33XQq7lA3h6n3szjjFqAu1SujWmBdjyXdsfsFjynzr5KRuXlaCT8oJKd/TT7v 1iRGJSs2BuhevNAB3+ZCT/OXKe0iIDhFZd53zWEjKJALj0F0nArwkxqc9I0/z81+xHpXuhaRCvz 06dOWrYHvt+8lj6mjo9ZaV8amPw6axlmcRrzIAEhrRW9TpCaY+5U1eUDL1wl1u9Q+TcQAJIuRZQ giMoEqfpVFx4VrPEOPlKxTeWhoFLF9w3tvDmbEAgxmMo53rk5nOQK3AKUUa/B1bP+KusUg6CCYI UbUv+4G3d2HVc+b/U6u89kyQr/0JZl91niX6YJMxLkxzT5iUlNgeg4CZbQ1nFVIsurfQYTDbA7L IgrIORGUbcavafDSnEkK5/tcI1cTxApV6ILfg4kWmXtxphYyyiJd04/aiKzYVypHRHSMuqCHt7u Ftxqzz/lRLnIcHofDgw1uVmOCkkf+Yki0+rRF4Qe/Mn640o3VIT5/poMW33NJfQMcA3R41bqo7x Oa0pCj41oGD8hXWpHUir5JBDed6h0Qa5l7b5y86gzZ1vMPA+VNNieS9N83HM5GjO9nh7YEFbs3u hAS7sWYLpHixmrvJVfyYbk9lPKSu/JrjboboqeVFvc6SFnp/Or4lCfQ8KUxSCP7LYl+9XTRBv6U NxYwahVgtEUHLQoZ74b52 X-Received: by 2002:a05:6830:2992:b0:7fe:e653:9535 with SMTP id 46e09a7af769-81782989d7bmr12777689a34.16.1790546414159; Sun, 27 Sep 2026 15:00:14 -0700 (PDT) Received: from [127.0.1.1] (174-29-1-49.hlrn.qwest.net. [174.29.1.49]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-81b3de6f7e1sm4874147a34.22.2026.09.27.15.00.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2026 15:00:13 -0700 (PDT) From: James Hilliard Date: Sun, 27 Sep 2026 15:59:46 -0600 Subject: [PATCH net-next v5 11/19] net: stmmac: complete DMA configuration allocation unwind Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20260927-submit-stmmac-reset-fixes-v1-v5-11-feec6c14dd06@gmail.com> References: <20260927-submit-stmmac-reset-fixes-v1-v5-0-feec6c14dd06@gmail.com> In-Reply-To: <20260927-submit-stmmac-reset-fixes-v1-v5-0-feec6c14dd06@gmail.com> To: Russell King , Andrew Lunn , Heiner Kallweit , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Russell King (Oracle)" , Maxime Chevallier , Andrew Lunn , Maxime Coquelin , Alexandre Torgue , Christian Marangi , Tiezhu Yang , Huacai Chen , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Serge Semin , Suraj Jaiswal , Richard Cochran , Joao Pinto , Vladimir Oltean , Ong Boon Leong , Voon Weifeng , "Song, Yoong Siang" , Linus Walleij , Martin Blumenstingl , Magnus Karlsson , Maciej Fijalkowski , Simon Horman , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Thierry Reding , Jonathan Hunter , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Jose Abreu , Yao Zi , Philipp Zabel Cc: Richard Genoud , Alastair D'Silva , Maxime Ripard , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, bpf@vger.kernel.org, ZhaoJinming , Lorenzo Bianconi , Ding Hui , Linkui Xiao , Linkui Xiao , linux-tegra@vger.kernel.org, linux-sunxi@lists.linux.dev, James Hilliard X-Mailer: b4 0.15.2 X-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [4.34 / 15.00]; RBL_SENDERSCORE(2.00)[172.232.135.74:from]; SUSPICIOUS_RECIPS(1.50)[]; DMARC_POLICY_SOFTFAIL(1.00)[gmail.com : SPF not aligned (relaxed), No valid DKIM,none]; MAILLIST(-0.15)[generic]; BAD_REP_POLICIES(0.10)[]; MIME_GOOD(-0.10)[text/plain]; HAS_LIST_UNSUB(-0.01)[]; FREEMAIL_CC(0.00)[bootlin.com,d-silva.org,kernel.org,vger.kernel.org,st-md-mailman.stormreply.com,lists.infradead.org,uniontech.com,oss.qualcomm.com,163.com,kylinos.cn,126.com,lists.linux.dev,gmail.com]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc-20240116:i=1]; FROM_HAS_DN(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[sto.lore.kernel.org:rdns,sto.lore.kernel.org:helo]; PRECEDENCE_BULK(0.00)[]; FORGED_SENDER_MAILLIST(0.00)[]; TAGGED_RCPT(0.00)[kernel,netdev]; RCVD_COUNT_FIVE(0.00)[6]; FROM_NEQ_ENVFROM(0.00)[jameshilliard1@gmail.com,linux-sunxi@lists.linux.dev]; TAGGED_FROM(0.00)[bounces-26360-noreply=patchwork.local]; FREEMAIL_FROM(0.00)[gmail.com]; RCPT_COUNT_GT_50(0.00)[58]; R_SPF_ALLOW(0.00)[+ip4:172.232.135.74:c]; TO_DN_SOME(0.00)[]; ASN(0.00)[asn:63949, ipnet:172.232.128.0/19, country:SG]; FREEMAIL_TO(0.00)[armlinux.org.uk,lunn.ch,gmail.com,davemloft.net,google.com,kernel.org,redhat.com,bootlin.com,foss.st.com,loongson.cn,iogearbox.net,fomichev.me,quicinc.com,synopsys.com,nxp.com,intel.com,googlemail.com,nvidia.com,sholland.org,ziyao.cc,pengutronix.de]; MIME_TRACE(0.00)[0:+]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[] X-Rspamd-Queue-Id: 66DB61C3164 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= Build on Ding Hui's per-queue allocation cleanup. The combined RX/TX allocator still needs to release the successful RX allocation if TX allocation fails. Guard coherent frees after the per-queue unwind has already emptied a queue. Propagate RXQ memory-model registration errors instead of continuing with an unusable RXQ. Clear XSK RXQ bindings before the RXQ goes away and release any saved partial packet. The MTU transaction added later relies on preparation failures being fully unwound without touching the active configuration. Take ownership of saved partial RX state at poll entry by clearing the saved flag and skb pointer immediately. Preserve incomplete state if the next descriptor is still DMA-owned. A budget-one completion must not leave an already delivered or freed skb reachable by the new teardown cleanup. Fixes: 71fedb0198cb ("net: stmmac: break some functions into RX and TX scopes") Signed-off-by: James Hilliard --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 54 ++++++++++++++++------- 1 file changed, 37 insertions(+), 17 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 258de45d122c..bc19f8c19bb8 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1931,17 +1931,19 @@ static int __init_dma_rx_desc_rings(struct stmmac_priv *priv, rx_q->xsk_pool = stmmac_get_xsk_pool(priv, queue); if (rx_q->xsk_pool) { - WARN_ON(xdp_rxq_info_reg_mem_model(&rx_q->xdp_rxq, - MEM_TYPE_XSK_BUFF_POOL, - NULL)); + ret = xdp_rxq_info_reg_mem_model(&rx_q->xdp_rxq, + MEM_TYPE_XSK_BUFF_POOL, NULL); + if (ret) + return ret; netdev_info(priv->dev, "Register MEM_TYPE_XSK_BUFF_POOL RxQ-%d\n", queue); xsk_pool_set_rxq_info(rx_q->xsk_pool, &rx_q->xdp_rxq); } else { - WARN_ON(xdp_rxq_info_reg_mem_model(&rx_q->xdp_rxq, - MEM_TYPE_PAGE_POOL, - rx_q->page_pool)); + ret = xdp_rxq_info_reg_mem_model(&rx_q->xdp_rxq, + MEM_TYPE_PAGE_POOL, rx_q->page_pool); + if (ret) + return ret; netdev_info(priv->dev, "Register MEM_TYPE_PAGE_POOL RxQ-%d\n", queue); @@ -2003,6 +2005,8 @@ static int init_dma_rx_desc_rings(struct net_device *dev, dma_free_rx_skbufs(priv, dma_conf, queue); rx_q->buf_alloc_num = 0; + if (rx_q->xsk_pool) + xsk_pool_set_rxq_info(rx_q->xsk_pool, NULL); rx_q->xsk_pool = NULL; queue--; @@ -2188,10 +2192,16 @@ static void __free_dma_rx_desc_resources(struct stmmac_priv *priv, void *addr; /* Release the DMA RX socket buffers */ - if (rx_q->xsk_pool) + if (rx_q->xsk_pool) { dma_free_rx_xskbufs(priv, dma_conf, queue); - else + xsk_pool_set_rxq_info(rx_q->xsk_pool, NULL); + } else { dma_free_rx_skbufs(priv, dma_conf, queue); + } + if (rx_q->state_saved) + dev_kfree_skb_any(rx_q->state.skb); + rx_q->state.skb = NULL; + rx_q->state_saved = 0; rx_q->buf_alloc_num = 0; rx_q->xsk_pool = NULL; @@ -2204,7 +2214,8 @@ static void __free_dma_rx_desc_resources(struct stmmac_priv *priv, size = stmmac_get_rx_desc_size(priv) * dma_conf->dma_rx_size; - dma_free_coherent(priv->device, size, addr, rx_q->dma_rx_phy); + if (addr) + dma_free_coherent(priv->device, size, addr, rx_q->dma_rx_phy); rx_q->dma_erx = NULL; rx_q->dma_rx = NULL; rx_q->dma_rx_phy = 0; @@ -2259,7 +2270,8 @@ static void __free_dma_tx_desc_resources(struct stmmac_priv *priv, size = stmmac_get_tx_desc_size(priv, tx_q) * dma_conf->dma_tx_size; - dma_free_coherent(priv->device, size, addr, tx_q->dma_tx_phy); + if (addr) + dma_free_coherent(priv->device, size, addr, tx_q->dma_tx_phy); tx_q->dma_etx = NULL; tx_q->dma_entx = NULL; tx_q->dma_tx = NULL; @@ -2500,6 +2512,8 @@ static int alloc_dma_desc_resources(struct stmmac_priv *priv, return ret; ret = alloc_dma_tx_desc_resources(priv, dma_conf); + if (ret) + free_dma_rx_desc_resources(priv, dma_conf); return ret; } @@ -5822,6 +5836,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue) struct sk_buff *skb = NULL; struct stmmac_xdp_buff ctx; int xdp_status = 0; + bool in_progress = rx_q->state_saved; int bufsz; dma_dir = page_pool_get_dma_dir(rx_q->page_pool); @@ -5836,6 +5851,14 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue) stmmac_display_ring(priv, rx_head, priv->dma_conf.dma_rx_size, true, rx_q->dma_rx_phy, desc_size); } + if (in_progress) { + skb = rx_q->state.skb; + error = rx_q->state.error; + len = rx_q->state.len; + rx_q->state.skb = NULL; + rx_q->state_saved = false; + } + while (count < limit) { unsigned int buf1_len = 0, buf2_len = 0; enum pkt_hash_types hash_type; @@ -5844,12 +5867,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue) int entry; u32 hash; - if (!count && rx_q->state_saved) { - skb = rx_q->state.skb; - error = rx_q->state.error; - len = rx_q->state.len; - } else { - rx_q->state_saved = false; + if (!in_progress) { skb = NULL; error = 0; len = 0; @@ -5883,6 +5901,8 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue) prefetch(np); + in_progress = status & rx_not_ls; + if (priv->extend_desc) stmmac_rx_extended_status(priv, &priv->xstats, rx_q->dma_erx + entry); if (unlikely(status == discard_frame)) { @@ -6057,7 +6077,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue) count++; } - if (status & rx_not_ls || skb) { + if (in_progress || skb) { rx_q->state_saved = true; rx_q->state.skb = skb; rx_q->state.error = error;