Article View: linux.kernel.netdev
Article #25157Re: [PATCH net-next v3 1/2] net: stmmac: dwmac-motorcomm: remove the device at shutdown
From: netdev-bot+sashiko
Date: Tue, 01 Dec 2026 10:18
Date: Tue, 01 Dec 2026 10:18
158 lines
14041 bytes
14041 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1 (1)
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).
- [Medium] Remove can run twice on one bound device, ending in BUG_ON()
or a use-after-free.
- [Low] The commit message gives no user-visible symptom, yet the patch
carries a Fixes: tag.
Pre-existing issues:
- [Low] (Baseline decision: false; kept only because
requires_validation=true.) The concern is that the new shutdown path…
--
net: stmmac: dwmac-motorcomm: remove the device at shutdown
This patch points the pci_driver .shutdown callback of the Motorcomm
YT6801 glue driver at motorcomm_remove(). As a result,
stmmac_dvr_remove() runs at reboot, kexec and power-off. The intent is to
close the interface, stop the DMA and MAC, and drop the PHY before the
system goes down.
> No .shutdown here, so reboot, kexec and power-off leave the MAC and
> DMA running. This chip keeps its registers through S5 too.
[Severity: Low]
The patch carries a Fixes: tag. Could the commit message say what
user-visible symptom it fixes?
For kexec, pci_device_shutdown() already clears bus mastering after the
driver's shutdown hook, even when no .shutdown is set:
drivers/pci/pci-driver.c:pci_device_shutdown() {
...
if (kexec_in_progress && (pci_dev->current_state <= PCI_D3hot))
pci_clear_master(pci_dev);
}
The next kernel's motorcomm_probe() also calls motorcomm_reset() before
any other setup.
For a regular reboot, the comment in pci_device_shutdown() notes that
firmware stops device DMA anyway.
That leaves the S5 register retention case. What actually goes wrong
there? It could be stale DMA once firmware re-enables bus mastering,
extra standby power, or something else.
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c
> index 42f0b11a7b606..63ce2301a0f69 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c
> @@ -374,6 +374,7 @@ static struct pci_driver dwmac_motorcomm_pci_driver = {
> .id_table = dwmac_motorcomm_pci_id_table,
> .probe = motorcomm_probe,
> .remove = motorcomm_remove,
> + .shutdown = motorcomm_remove,
[Severity: Medium]
Can stmmac_dvr_remove() now run twice for the same bound device?
pci_device_shutdown() calls drv->shutdown() but leaves the driver bound.
The netdev comes from devm_alloc_etherdev_mqs(), so dev_get_drvdata()
still returns it afterwards. Any later .remove then runs the full
teardown again:
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:stmmac_dvr_remove() {
...
unregister_netdev(ndev);
...
phylink_destroy(priv->phylink);
...
destroy_workqueue(priv->wq);
mutex_destroy(&priv->lock);
mutex_destroy(&priv->est_lock);
bitmap_free(priv->af_xdp_zc_qps);
...
}
None of these pointers are cleared. Nothing records that the teardown
has already run.
Here are some ways .remove can follow .shutdown:
- A PCIe hot-unplug or link-down handled by pciehp or DPC between this
device's shutdown and its parent port's shutdown. device_shutdown()
holds device_lock only around each ->shutdown. Its own comment says
"device unplug events may also start pulling devices offline, even as
the system is shutting down".
- A sysfs unbind or rmmod racing with reboot, since userspace is not
frozen.
- A failed power-off. reboot(2) with LINUX_REBOOT_CMD_POWER_OFF does
kernel_power_off(); do_exit(0); so the system keeps running with the
driver bound but already torn down. A later unbind or rmmod then calls
.remove.
On the second pass, unregister_netdevice_many_notify() would hit:
BUG_ON(dev->reg_state != NETREG_REGISTERED);
phylink_destroy() and bitmap_free() would also double free, and
destroy_workqueue() would run on a freed workqueue.
Before this patch there was no .shutdown, so the teardown could only run
once.
The follow-up commit "net: stmmac: dwmac-motorcomm: support Wake-on-LAN
from S5" replaces this with a dedicated motorcomm_shutdown(). That
function still calls stmmac_dvr_remove() without a guard, and it may
leave the device in D3hot before a later remove. So the problem still
exists at the end of the series.
dwmac-sun8i is the only other stmmac glue driver with a shutdown hook. It
uses a narrower sun8i_dwmac_shutdown() instead of reusing remove. Would a
similar shutdown-specific handler avoid the double teardown here?
[Severity: Low]
This isn't a bug introduced by this patch, but the new shutdown path
leaves the YT6801 wake logic disarmed at power-off. motorcomm_init()
disables OOB WoL at probe:
drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c:motorcomm_init() {
...
writel(OOB_WOL_CTRL_DIS, priv->base + OOB_WOL_CTRL);
}
MAC PMT is not armed, PME_En is not set, and the device stays in D0, so
magic-packet wake from S5 still does not work.
Wake from S5 did not work before this patch either. stmmac arms PMT only
in stmmac_suspend(), and pci_wake_from_d3() was never called on
power-off.
The next commit in the series, "net: stmmac: dwmac-motorcomm: support
Wake-on-LAN from S5", fixes this. Its motorcomm_shutdown() first checks
that system_state == SYSTEM_POWER_OFF, the interface is running,
WAKE_MAGIC is set and device_may_wakeup() is true. If so, it:
- calls motorcomm_reset() to re-enable OOB WoL
- sets WOL_CTRL_PKT_EN
- calls pci_wake_from_d3(pdev, true)
- enters PCI_D3hot
That commit also documents 'wol u' as unsupported.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130101700.1715598-1-magnusleatti%40kernelriot.com
Technical Details
Message-ID:
<179612030127.3146.1025291153395765710@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lon.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374932-linux-kernel-netdev=dewy.ruReferences:
<20261130101700.1715598-2-magnusleatti@kernelriot.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374932-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v3 1/2] net: stmmac: dwmac-motorcomm: remove the device at shutdown Date: Tue, 01 Dec 2026 10:18:21 +0000 Organization: Usenet Network Message-ID: <179612030127.3146.1025291153395765710@kernel.org> References: <20261130101700.1715598-2-magnusleatti@kernelriot.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1683829"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:zcCebI0lM4Bbr8YYklEAwbX204o= sha256:avEbXTtaHBA6nEuSvLt1Y1eDynSEscBMGZg3t8xFAJY= sha1:NpuiHhZwrqMlSO88VS+LISH6twQ= sha256:l99sTlQ7yirl6doxOTY+WOjBIW2rH6q0P7SWYxvy6WY= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id CE1E7117323; Tue, 1 Dec 2026 13:18:50 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5Joxcy48BW69; Tue, 1 Dec 2026 13:18:47 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374932-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id D081711731F; Tue, 1 Dec 2026 13:18:38 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 18C29340F1; Tue, 1 Dec 2026 10:18:34 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796120309; b=quLo/ZOvCZqaM0K+zCp5eGj2+Bd1QT1SBkZ9gMof69mWTVs9gkS9RfVT0nKIJM6nbbEd UgC8fu5SKd44mmLgFA9BDNJsMqhQYTqdWUbfFbdKV0jZBkhEL7SAT2Of/x6R07L7Aix5t ocnxtVz9oAXWPq7FwSKiqbaeuUrgPglpGsYmU4flGQnunv8yvT0sYQt2qyr7/d3a4RQhM lZvVvhZ0uoVNI9u1ZSZwTM4RX46VnArB+NLUh/Umr1COBGCqlfWTkEBbBFWna77mccMKc Ul705hG3SXaol8Ar/ebl7ZaYxj0lwWPiLQ8L7NGIqswNXvCXfjf0N1fwPw9UFFkee8g== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796120309; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=STJpZbam8rhPbVCXFAL9lmRhjephAMXjOMkGR8b0cr8=; b=gbBmGwbH+wL9VHFHXItI4cPV2/U8IZGy/tYZIRBK/WI2+1q30qRbjj7+t44njSaK29QP 2TeYT3pewjlTPkDo2Tq//py+Re+t3dF6wTqPkD+LbhylOH0S+xa8jwcdnygTUD5FELzbV 8PEg8gcC5e2IdSwOLOPhbJ0FGZ2p61H66myTV0z0g0EOoluEjjV6gZEefsyLCgwtq0CTI 13+9n4+CdOTEA6DdimPkorhLYeG+5XMxdGHnknNRuJwlTIrasjPpi0bXZyYymAHvHg9vy h8zu+FT1Ld7Z3LW94pAGBHurjioyuz6lWUIqmjsMDJhg97x23Iesq7rmEGo3b69VibA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=G7a3vh+1; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E3F99606A325; Tue, 1 Dec 2026 10:18:28 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=G7a3vh+1 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796120303; b=HCXc8wm7QDIvSdkZEYg6w6dRsDtdzB51IrIknrfD2V/bLYdzBFAjM1we55K4r/kIfQ1y Mfa+hZpWSMlxSXaioaziu1p81la5hjtoJ3LFMAaSHnJN36cFgXI3w+n4j0eXO14LJvjof 3QPy0pymnlUAe6SAB0bPvOJNWck8AMA5OAt3MAOW2iFKEd63V3e+9Gf40XmH346oKgCSu 7eadNfky6zUENkVananLXMUwCR8vrhg8C/O+zbXe7kv9lFEgcBnTtP5kG0BSzd7j9028H BSTz91oLlIOzRzyEIB2JrWAgNze+W0ODn2HAGgVAoINEgH69W9TY8jSBqqvCyrR/FRg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796120303; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=STJpZbam8rhPbVCXFAL9lmRhjephAMXjOMkGR8b0cr8=; b=3NEVUCMZ+tz2sDGrlGD8i05XucbdrddsLxcrvIW1wPdGFnF6QMcQ503QSkZqBLvjLH8a QYfi+I2sSuJxBfqnlcFWgSWeUfX9QtFPAN1nIGJmb8ancfT3jGo0uwDb3P9wxQA9Tx2Lr bFrjS3DKLvm/l0FbUnfc6/sEYVMiP+Em49q9eSxaRS/85tpR9YEWWZ0S+U98bFSuUteVb /3Pjws6WW/pFU/0Zj4wVEqdaKU/vFlP/nf2PSQw7zUmAdoA9RyDUx9AaBgmRDTRrY1TaN 1pvDJCXMODY31xRvA5PQ0kV9nqsoQLcHql8XayzPjESAtGkvuG1VdTE0++k0Zj3tHOg== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=G7a3vh+1; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F9D0606A32C; Tue, 1 Dec 2026 10:18:22 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0B211F00897; Tue, 1 Dec 2026 10:18:21 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796120302; bh=STJpZbam8rhPbVCXFAL9lmRhjephAMXjOMkGR8b0cr8=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=G7a3vh+1KCTzmKGdO682Y+jJZ7of+askoCqPPjj1qcWnBSkShMns5n/KPzGmdFmgD AwgR/zlwcjh67mWA4nJXovOeOPU+dOGVJzZP8jEJxjBpRzsSjhP4B1P05s8bcvc6rV vQ65Lhe5rMFOF5erTAmf+y4NUwEm1H7+s+Ix2SAyPVj9jkfPFl4BJrZ5s03YFAeQc6 TzZpQAAOKj3nHOijQ2WmFqVSftgPALaWFlWRG8UuVZg/yGNRim5G/v3cR3cwrl9Qw0 /kucWky7ML7cbYL8eN4Qtu4agtNZTMTheUUcRWDUjqVBVJAa8fAPCb2uNxgyhcDOwC /4xblKQxWzgmw== X-Cc: me@ziyao.cc, maxime.chevallier@bootlin.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, saikrishnag@marvell.com, g.nespolino@gmail.com, netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-In-Reply-To: <20261130101700.1715598-2-magnusleatti@kernelriot.com> X-sashiko-severity: Medium X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list