From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B67E64A5ED6; Fri, 25 Sep 2026 13:59:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790344795; cv=none; b=e0NH0ibpzT3B5CR1t7Ng0hZpr0Zbdztj9IpADiIW1cGRVCqRmO1mjgGuWSVUutKa5VR59bST9rA10KduJFXtgVgz+YTYhu8APsIPX73DUVtSga+ncMKwPIuoM4iRhE76pF3uI54dw6GyF7IA50RDqSJEE9j597mPUQIBnpOVUpI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790344795; c=relaxed/simple; bh=rxgqcxMBzyiCaShIe6oKqSQwEXJpXEvJGCpXStURPY8=; h=From:Subject:Date:Message-Id:MIME-Version:Content-Type:To:Cc; b=gG5A0h+FQ9MnP764oKMxvCMeGDhVnqDcztwExdH+Ob3KTsEdKhXao+AopCrhXDULGr6XIDkyTqdWlj4fuGmeHUbNuOGEHmj/0wNvesltSxMDIqtEJcRt1O8sy7h+FTL8zYMkMZESmv9m/tlAurzljZgq9jGrDM7CuEIfz24nCcI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=ayToTLTg; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="ayToTLTg" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 8D8C5C653F6; Fri, 25 Sep 2026 14:00:36 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id AD9D46073B; Fri, 25 Sep 2026 13:59:48 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 00A77103293B6; Fri, 25 Sep 2026 15:59:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1790344783; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding; bh=XS8Dc0EYvbktyBpK0cidB0SJsr+eMfdYCTUgJ32Ne9E=; b=ayToTLTgy2T2GLhsJemTzmA4zW9w+BidfcpCFU68eFsTsQ5wkby7iOuBP6o+NPDzvHsvpm KhZHeVkRTwkiA5wcXlVBQGmyiBWktzkb4FXH+dvUe0VWvyrdUeswvmZBtsxLVPCsw+/ESh thbhBvhe0ztRpQtr1vGaPT0+iM7HoSXwlMAFupH6SBVkVhx4/DoEh37eamffvn+/Lhpz8l 8E5J1K+xrJnZHdOUZGgKyAV9nvE006doTyOGr5Ys1RjF7sy3jF/037kRGKI63Og9zjdils ioMVV3sGgySJmlxx1nnOspCOWPs2uPOiDRDMjgVF9wIXvzm/djhMk9v5kNNEsw== From: =?utf-8?q?Th=C3=A9o_Lebrun?= Subject: [PATCH net v2 0/3] net: macb: fix close races (and RX refill error handling) Date: Fri, 25 Sep 2026 15:59:33 +0200 Message-Id: <20260925-macb-close-v2-0-360efa565914@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-B4-Tracking: v=1; b=H4sIAAAAAAAC/3WNQQ6CMBREr2L+2pq2KLauvIdhwW8/UgOtaSvRE O4u4MpElzOZ92aERNFRgtNmhEiDSy74OcjtBkxb+ysxZ+cMksuSa6FYXxtkpguJmEW0ssA9qkb CDNwjNe65yi7gKUP1KdMDb2TyollmrUs5xNd6OYh1/Ms+CMaZlMJqUeJRl+KMIeTO+Z0J/eL5C /EDFdKQVkoUX1A1TdMbvigzrfIAAAA= X-Change-ID: 20260918-macb-close-dbbd23b4b8f2 To: Conor Dooley , Andrew Lunn , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Simon Horman , Sean Anderson , Antoine Tenart , Eric Dumazet , Nicolas Ferre , Russell King Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Nicolai Buchwitz , Vladimir Kondratiev , Gregory CLEMENT , Tawfik Bayouk , Thomas Petazzoni , Maxime Chevallier , =?utf-8?q?Th=C3=A9o_Lebrun?= , stable@vger.kernel.org X-Mailer: b4 0.15.2 X-Last-TLS-Session-Version: TLSv1.3 The context-swapping series [0] has been ongoing for a while. The most interesting part is a proper hardware shutdown sequence, which is truly lacking in other parts of the MACB driver: at close, at suspend and in the HRESP error task. Instead of introducing that sequence for a new feature, apply it now to fix the main offender, the close path. That fixes the races listed in patch 3 and will allow the sequence to be reused later. The first two patches are also fixes, but not related to the shutdown sequence: they address allocation-failure codepaths. They are sent alongside patch 3 because they touch the same code and would cause merge conflicts if applied separately. Now, let me list issues I'm aware of that we do *not* fix here, to make the scope explicit: - HRESP task should sync with all other contexts. It frees buffers under the feet of the whole driver. The hardware shutdown sequence will help. - Suspend callback is also racy with BH primitives. We'll be able to reuse the hardware shutdown sequence. - Even if we assume tasks are frozen, the phylink ops aren't and might trigger between suspend and resume callbacks. Here we need to (1) early return in phylink ops and (2) at resume put the HW in its proper state according to phylink ops that occured. - Alloc failure codepaths aren't perfect outside open. Hardware and ring buffers are left in a sad state. We can probably do better. [0]: https://lore.kernel.org/all/20260812-macb-context-v9-0-7ddbf5f715e0@bootlin.com/ --- Changes in v2: - P1: ensure gem_rx() and macb_rx_pending() don't consume the descriptors where alloc failed. - P2: gem_rx_refill() now only propagates an error if zero descriptors are ready. We tolerate partial refill hoping the next one will help. - P2: we do *NOT* fix the set_ringparam codepath reported by Sashiko. Proper implementation will come with context swapping which will reuse the infra put in place in P3. - P3: the hresp_err_bh_work/tx_lpi_work Sashiko-reported race has been fixed in a standalone, *NOT* here. https://lore.kernel.org/netdev/20260925-macb-netdev-register-race-v1-1-752f90ce1c39@bootlin.com/ - Take 2x Reviewed-by: Nicolai. - Rebase onto latest net/main (11536ee3d3e0), nothing to report. - Link to v1: https://patch.msgid.link/20260918-macb-close-v1-0-05e32ce98813@bootlin.com - Nicolai's v1 reviews (duplicate thread): https://patch.msgid.link/20260918-macb-close-v1-0-221d916b7961@bootlin.com To: Conor Dooley To: Andrew Lunn To: "David S. Miller" To: Jakub Kicinski To: Paolo Abeni To: Simon Horman To: Sean Anderson To: Antoine Tenart To: Eric Dumazet To: Nicolas Ferre To: Russell King Cc: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: Nicolai Buchwitz Cc: Vladimir Kondratiev Cc: Gregory CLEMENT Cc: Tawfik Bayouk Cc: Thomas Petazzoni Cc: Maxime Chevallier Signed-off-by: Théo Lebrun --- Théo Lebrun (3): net: macb: never give hardware a NULL RX buffer net: macb: propagate RX ring refill errors net: macb: quiesce IRQs and drain BH on interface close drivers/net/ethernet/cadence/macb.h | 7 +- drivers/net/ethernet/cadence/macb_main.c | 133 ++++++++++++++++++++++++------- 2 files changed, 112 insertions(+), 28 deletions(-) --- base-commit: 7c416e8f8423e6fe9b48e0b9c174bd902789f8db change-id: 20260918-macb-close-dbbd23b4b8f2 Best regards, -- Théo Lebrun