| Message ID | 20261113-b4-sun8i-emac-ephy-defer-v1-1-12a8591702fe@gmail.com (mailing list archive) |
|---|---|
| State | New |
| Headers |
Return-Path: <linux-sunxi+bounces-27576-sunxi=pue.re@lists.linux.dev> X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mxe881.netcup.net (Postfix) with ESMTPS id A76071C4EB0 for <noreply@patchwork.local>; Fri, 13 Nov 2026 10:14:48 +0100 (CET) Authentication-Results: mxe881; dkim=pass header.d=kernel.org; spf=pass (sender IP is 172.105.105.114) smtp.mailfrom=linux-sunxi+bounces-27576-noreply=patchwork.local@lists.linux.dev smtp.helo=tor.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.105.105.114 as permitted sender) client-ip=172.105.105.114; envelope-from=linux-sunxi+bounces-27576-noreply=patchwork.local@lists.linux.dev; helo=tor.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id CFFEE1C2616 for <noreply@patchwork.local>; Fri, 13 Nov 2026 08:04:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 ARC-Seal: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794557041; b=kLq0TOP9n7bnXMaDXdoqx2MZ7+6p5+THXQtISIEZH7Fk0bMtySPHPB7uIEj7byb9nDYH PRgwolBlPvTZIa2FjPvcPGVc3PTofyi08HEPWN46L+oA/Q4ULV48J0zaFrFLJ0mZ5Lgj2 FKejS3wV5bao/sXuCWXlXbpQrHQz1Ach76TaLD0NT9EmzHLHJgxWa6S/W7lIKc4UQqpRN /8zeDtWKD86gya0y5E91DewLB59lyAp+/WPLXsvWUo6YeAMqam0eTi4NZs304ocBjQPla ZELXbvrEY567zFMd7XIPsrOonxuUzXaLphbU3OTLEwzLukMpVkBTaJHvVUt4CHTGoAQ== ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794557041; h=X-Original-To:Received:Received:DKIM-Signature:Received:From:Date: Subject:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type: Message-Id:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=9aTGmfKoZNcf7jTTJ6RvYLx/icbQQbPWjeg9zDfJi4c=; b=kSuf994ySdaK67n0vfEbgdjgPoikysp4qr3CnWiCRddyIonGISx7iHhx5/qPHb/yz1lk oEy6qj/z62oVJ2lAGSAc3puGd1n8RRMtm5hI3iYKsWYwMc1KT/BHZLva/d4XtTE6RvjUr k9x0MUIYmKA03HvggLOe6kuul2rNQ/PvvWPepCt7Ce0aW2yZ38P4tSr7nB/akHELNCajA EwNDnp57imgKCUzI/qZElpqKqPyIRlrY4aAO+uK7kgg4Y6/sv0PJfNNacHvqUZPr4I1Rc VTByTGlKGAd0p3NXYQL0TMXPZ9m4GDAyhtdB36rQiA4fYp425+nOlLJQlDJgeY2XfNA== ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Lshj+DVG; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 48926606A327; Fri, 13 Nov 2026 08:04:01 +0000 (UTC) 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=Lshj+DVG X-Original-To: linux-sunxi@lists.linux.dev Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794557041; b=kuerOzgeWAhMqB6GHgYVGaOvSRU8Sf6KXy1R1jgQG3PPOrlhDB/SpJ6UL8mCZKAZeFUB Pzx3bYIpOdW5JvZdC7hvXY9Am3AujhBSa4JFsgYg7H9/+Q7TPWH8YpQFkU/uamS9DpIDF 36NGfFid7s75wl+DYYcj0aDZ/GxqBUYz7ehNTOzsWWiWhS8DXf93Kj/cNsJrpGu6nHBA+ te3FZ2UJBVDohOYUKh/JMaAJQp7gw+kKOsNJSZ8fLlXxEmaTF5MYDEshbx+8F3kG7KRNJ D4wwOiuoRBPhdlvNbfS/rtOx6mqORhK+U9gSCh+LXgHD2iQ89VyuUxSM5RD+mRvpV4g== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794557041; h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Message-Id:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=9aTGmfKoZNcf7jTTJ6RvYLx/icbQQbPWjeg9zDfJi4c=; b=kSEYZSTkwUOdJ5lVhZjWMqQG+j6yf72Ra/YFQ9hjSXza5WodAYkBPJjDTNRdzQOYZ/m+ PFBsOk/SzhqdwsHJVacs+Wd+29LglANZcxTPX+cbRs3auZutY3HhHZt9cAAqcadM8JASI gvMpFZ530vfxaF6XSxi+kMxRDXPtPA761vcxi2OPfLUEYeQvWGRp5etgAzErACwNKo/xf xOKE6HBCdAxCLjFTgGeMAJPhzqzH3kS7ggu766L7vjpHhvCNZ/5omh9fApP+U+hg6Mr0k G7mHHANcRm5WhyJrDUKi0DZCc3USbk2VpYSiryXW7b5AVP3m5VUt6+jDgQEK1TcE00g== 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=Lshj+DVG; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 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 24E85606A31C; Fri, 13 Nov 2026 08:04:00 +0000 (UTC) Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1794557040; b=aDZ11lWe/UBD4fk0CacR1o9ZDEaMZaFxyLQeAW7m47XJpMaSmngp4V3KeBQlSFz7mQS9 ogatGEwlvzNIG2SQqCXWjEzicXtmEaOnUclk9cVskuioGs+ZPf11Lb8EowQ8k7Fu1wKNv DcBggL40GwPPRxmLUAApSKvdD6IWgYc6pZ6UBT+GK9+6Uixi3ls5gbA/4qW3Pi/BYCSsY 8fWwwrjkcie/1SMPzesi+Kx5hHDkZnULp8nIu7/3PaG6N5NloDxJzQjtSE80o0eHizWpz c7pAnlZi3nCRZjZTgOFqzdOOKb2zBDIzxXrmEVmhF828ZW0fihmaOILmlsRGTVFM9Fw== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1794557040; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Message-Id:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=9aTGmfKoZNcf7jTTJ6RvYLx/icbQQbPWjeg9zDfJi4c=; b=CLb78VPBIaQiDt4pdhTp3RCeRt4CCy+yrW/3ycyIxsSLIz0rZFt39u1PHamF0Zb57Pab 54tCQAJU+3ML/Iwv7wqA/GB/1JHu63fWP5GDja4s6lVcOhB7ikPjoa0YHxUvqfX++FFXA 3raYk1H3+s5biXYqUn1f7E9d+FOisz1ChGW2adSy3pZQGb9tACUWU0bnfX6PwiLmG0tY2 Ay/kdpYK/2BYlSDcnzpv5zfUpCPl+RQQHl04j1tyT/xucRlZU+ZI/Nqc4fAjS80t/Klq0 eKZDAPnUaohQMzuoRjNjkdMwEVzPl+4PxkCkmVVMNBLVFrRJ2Lvz0RhccE+5TYq6Bgg== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 2F37A1F000C4; Fri, 13 Nov 2026 08:04:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794557040; bh=9aTGmfKoZNcf7jTTJ6RvYLx/icbQQbPWjeg9zDfJi4c=; h=From:Date:Subject:To:Cc:Reply-To; b=Lshj+DVGf0XV1Tpuw1oQGOhRWKoxja3uypxUI7JFYTfBY8+dtB37Fy2nLiMssT9K2 SSdZ0e4mzTWtso4A41qtaq5r2MJGjo2dRlppLZ/nKEcNQze6rrPKCQv99zjmu56scS 6ckA3oqx6lXVo32UlKzoVwlPMEpeQXBXU5XfKLm6r4okwVZvmSUSwic6icDeot4bgB SbHdlqMQ/optq5iGe6ToRR4KJiDoOVCfPJcuJkMQZ062lG10A8KvFmEl8EFlN2ysGu D2MLbp05W31lVL6hfXBMeo95h+m8kvfBzOELSa0Nech0lWYNAynbCS7YBa6pHJQkAx J60EE6L/W3G0w== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 81E564769E; Fri, 13 Nov 2026 08:03:59 +0000 (UTC) From: Arun Iyengar via B4 Relay <devnull+aiyengar1990.gmail.com@kernel.org> Date: Fri, 13 Nov 2026 08:04:00 +0000 Subject: [PATCH net-next] net: stmmac: dwmac-sun8i: Defer probe when the EPHY clock is not ready X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: <linux-sunxi.lists.linux.dev> List-Post: <mailto:linux-sunxi@lists.linux.dev> List-Help: <mailto:linux-sunxi+help@lists.linux.dev> List-Subscribe: <mailto:linux-sunxi+subscribe@lists.linux.dev> List-Unsubscribe: <mailto:linux-sunxi+unsubscribe@lists.linux.dev> List-Owner: <mailto:linux-sunxi+owner@lists.linux.dev> Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Message-Id: <20261113-b4-sun8i-emac-ephy-defer-v1-1-12a8591702fe@gmail.com> X-B4-Tracking: v=1; b=H4sIAAAAAAAC/yWMwQ6CMBAFf4Xs2U0obQj4K8ZDKQ9ZEyvpFoMh/ LtVj5PJzE6KJFA6VzslvETlGQuYU0Vh9vEGlrEwNXXTGmMsD451jZ0wHj4wlvnNIyYkdl0dbG9 7h9ZTyZeESbbf+kIRmSO2TNe/0XW4I+TvmY7jAySUWp6GAAAA X-Change-ID: 20261113-b4-sun8i-emac-ephy-defer-480c39394e6a To: Maxime Chevallier <maxime.chevallier@bootlin.com>, Andrew Lunn <andrew+netdev@lunn.ch>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Maxime Coquelin <mcoquelin.stm32@gmail.com>, Alexandre Torgue <alexandre.torgue@foss.st.com>, Chen-Yu Tsai <wens@kernel.org>, Jernej Skrabec <jernej.skrabec@gmail.com>, Samuel Holland <samuel@sholland.org>, Corentin Labbe <clabbe.montjoie@gmail.com> Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Arun Iyengar <aiyengar1990@gmail.com> X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1794557039; l=2284; i=aiyengar1990@gmail.com; s=20261110; h=from:subject:message-id; bh=3vOWWV9l/RPEbbthTMkW1C/XCstj8pm3YVWcUELiCkk=; b=Zh00xt2IqE0H4WmqmMEFzkuWSzcVdr9Qa1Qf6eTGMm86i/HvyogK5dSaE/9LQJc9xcVZIiy9D Q9zA4UQMzy0DKdbTShY1TsZo15qzneFaut3ohv/froP6aUhibJFsMIG X-Developer-Key: i=aiyengar1990@gmail.com; a=ed25519; pk=zXpRgUTrhaFe6jLyPqbBy3ccfkj04w0g2690Wv3mg+0= X-Endpoint-Received: by B4 Relay for aiyengar1990@gmail.com/20261110 with auth_id=1480 X-Original-From: Arun Iyengar <aiyengar1990@gmail.com> Reply-To: aiyengar1990@gmail.com Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [3.31 / 15.00]; RBL_SENDERSCORE(2.00)[172.105.105.114:from]; SUSPICIOUS_RECIPS(1.50)[]; MAILLIST(-0.18)[generic]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; HAS_LIST_UNSUB(-0.01)[]; RCPT_COUNT_TWELVE(0.00)[18]; FREEMAIL_REPLYTO(0.00)[gmail.com]; TAGGED_RCPT(0.00)[netdev]; FROM_HAS_DN(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[sashiko.dev:url,tor.lore.kernel.org:helo,tor.lore.kernel.org:rdns]; REPLYTO_DOM_NEQ_FROM_DOM(0.00)[]; RCVD_COUNT_FIVE(0.00)[6]; FORGED_SENDER_MAILLIST(0.00)[]; FREEMAIL_CC(0.00)[vger.kernel.org,st-md-mailman.stormreply.com,lists.infradead.org,lists.linux.dev,gmail.com]; HAS_REPLYTO(0.00)[aiyengar1990@gmail.com]; R_DKIM_ALLOW(0.00)[kernel.org:s=k20260515]; ARC_ALLOW(0.00)[kernel.org:s=arc20260519:i=3]; DKIM_TRACE(0.00)[kernel.org:+]; DMARC_POLICY_ALLOW(0.00)[kernel.org,quarantine]; R_SPF_ALLOW(0.00)[+ip4:172.105.105.114]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[100.77.114.92:received,100.80.115.77:received,100.103.45.18:received]; TO_DN_SOME(0.00)[]; FROM_NEQ_ENVFROM(0.00)[devnull@kernel.org,linux-sunxi@lists.linux.dev]; FREEMAIL_TO(0.00)[bootlin.com,lunn.ch,davemloft.net,kernel.org,redhat.com,gmail.com,foss.st.com,sholland.org]; MIME_TRACE(0.00)[0:+]; TAGGED_FROM(0.00)[bounces-27576-noreply=patchwork.local,aiyengar1990.gmail.com]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; ASN(0.00)[asn:63949, ipnet:172.105.96.0/20, country:SG]; RCVD_TLS_LAST(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[172.105.105.114:from] X-Rspamd-Queue-Id: A76071C4EB0 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: INBOX |
| Series |
[net-next] net: stmmac: dwmac-sun8i: Defer probe when the EPHY clock is not ready
|
|
Commit Message
Arun Iyengar via B4 Relay
Nov. 13, 2026, 8:04 a.m. UTC
From: Arun Iyengar <aiyengar1990@gmail.com> get_ephy_nodes() skips an internal PHY node on any of_clk_get() error. If the EPHY clock provider is not registered yet, the node is skipped, the function returns -ENODEV and the probe fails for good. The reset lookup right below already returns -EPROBE_DEFER in this case. Return -EPROBE_DEFER for the clock too. Other clock errors still skip the node, as before. Fixes: 9f93ac8d4085 ("net-next: stmmac: Add dwmac-sun8i") Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com> --- Reported by the Sashiko review bot while it reviewed my MDIO mux error path fix for this driver: https://sashiko.dev/#/bug/linux-98384c14-541e-410e-a074-fff5e98b3820 Only the H3/H5 and V3s variants (soc_has_internal_phy) reach this code. With the in-tree device trees the EPHY clock comes from the same CCU as the EMAC clock and reset, so the EMAC probe already waits for that CCU and this cannot fail there. It matters when the EPHY clock comes from a provider that probes later. Build-tested only (W=1, arm64 and arm); I have no board with the internal PHY. This patch was developed with Claude (Anthropic) as a coding assistant: it checked the report against the code and wrote the fix and the commit message. I reviewed it. --- drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- base-commit: 573af801552999954caa8347e4490b04cf4763f0 change-id: 20261113-b4-sun8i-emac-ephy-defer-480c39394e6a Best regards, -- Arun Iyengar <aiyengar1990@gmail.com>
Comments
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider. Critical: 0 · High: 1 · Medium: 0 · Low: 0 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). - [High] The patch makes get_ephy_nodes() in drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c return -EPROBE_DEFER… -- net: stmmac: dwmac-sun8i: Defer probe when the EPHY clock is not ready With this patch, get_ephy_nodes() returns -EPROBE_DEFER when of_clk_get() on the internal PHY node returns -EPROBE_DEFER. Before, it skipped the node and the probe ended with -ENODEV. Other clock errors still skip the node. > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c > index 2ece7ba9dd73b..8163e49fa7ad0 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c > @@ -801,8 +801,13 @@ static int get_ephy_nodes(struct stmmac_priv *priv) > struct clk *ephy_clk; > > ephy_clk = of_clk_get(iphynode, 0); > - if (IS_ERR(ephy_clk)) > + if (IS_ERR(ephy_clk)) { > + if (PTR_ERR(ephy_clk) == -EPROBE_DEFER) { > + of_node_put(mdio_internal); > + return -EPROBE_DEFER; > + } > continue; > + } > gmac->rst_ephy = of_reset_control_get_exclusive(iphynode, NULL); > if (IS_ERR(gmac->rst_ephy)) { > ret = PTR_ERR(gmac->rst_ephy); [Severity: High] Does this deferral come too late in the probe? The only caller of get_ephy_nodes() is sun8i_dwmac_probe(), and it calls it after stmmac_pltfr_probe() has already run: sun8i_dwmac_probe() stmmac_pltfr_probe() sun8i_dwmac_init() (plat->init, enables the phy regulator) __stmmac_dvr_probe() deasserts the stmmac reset stmmac_mdio_register(ndev) register_netdev(ndev) pm_runtime_get_sync() get_ephy_nodes() return -EPROBE_DEFER goto dwmac_remove stmmac_pltfr_remove() sun8i_dwmac_unset_syscon() So when the new -EPROBE_DEFER is returned, the MDIO bus and an ethN netdev already exist as children of the platform device. Documentation/driver-api/driver-model/driver.rst says to defer as early as possible, and it also says: -EPROBE_DEFER must not be returned if probe() has already created child devices, even if those child devices are removed again in a cleanup path. The commit message describes an EPHY clock provider that probes later. In that case, wouldn't every deferred probe retry do all of the following? - power up the phy regulator - toggle the MAC reset - register and unregister the MDIO bus and an ethN interface that userspace can see - rewrite the syscon EMAC clock register driver_probe_device() also re-triggers deferred probing if deferred_trigger_count changes during a probe: drivers/base/dd.c:driver_probe_device() { ... if (trigger_count != atomic_read(&deferred_trigger_count) && !defer_all_probes) driver_deferred_probe_trigger(); ... } If another device binds during any attempt, this starts another full cycle. That can become the endless .probe() loop the documentation warns about. get_ephy_nodes() only uses priv->device->of_node and the sunxi_priv_data. None of the mdio-mux lookup, of_clk_get() or of_reset_control_get_exclusive() on the iphy node needs the MAC to be up. The "mux must be registered after parent MDIO" comment only seems to constrain sun8i_dwmac_register_mdio_mux(). Could the EPHY clock and reset lookup move into sun8i_dwmac_probe(), before stmmac_pltfr_probe()? The commit message uses the existing reset lookup deferral as precedent. That path returns -EPROBE_DEFER from the same late point. Would moving the lookup earlier fix both cases, instead of adding a second late deferral?
Hi, On 11/17/26 09:13, netdev-bot+sashiko@kernel.org wrote: > Thank you for your contribution! Sashiko AI review found 1 potential > issue(s) to consider. > > Critical: 0 · High: 1 · Medium: 0 · Low: 0 > > 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). > > - [High] The patch makes get_ephy_nodes() in > drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c return -EPROBE_DEFER… > > -- > > net: stmmac: dwmac-sun8i: Defer probe when the EPHY clock is not ready > > With this patch, get_ephy_nodes() returns -EPROBE_DEFER when of_clk_get() > on the internal PHY node returns -EPROBE_DEFER. Before, it skipped the > node and the probe ended with -ENODEV. Other clock errors still skip the > node. > >> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c >> index 2ece7ba9dd73b..8163e49fa7ad0 100644 >> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c >> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c >> @@ -801,8 +801,13 @@ static int get_ephy_nodes(struct stmmac_priv *priv) >> struct clk *ephy_clk; >> >> ephy_clk = of_clk_get(iphynode, 0); >> - if (IS_ERR(ephy_clk)) >> + if (IS_ERR(ephy_clk)) { >> + if (PTR_ERR(ephy_clk) == -EPROBE_DEFER) { >> + of_node_put(mdio_internal); >> + return -EPROBE_DEFER; >> + } >> continue; >> + } >> gmac->rst_ephy = of_reset_control_get_exclusive(iphynode, NULL); >> if (IS_ERR(gmac->rst_ephy)) { >> ret = PTR_ERR(gmac->rst_ephy); > > [Severity: High] > Does this deferral come too late in the probe? I agree with the bot here, this defer happens after the netdev is registered, which isn't great... And it's likely the PHY is on that mux'd bus, no ? Was this tested ? Doesn't it really work to return a probedefer so late ? This mdio mux logic should likely be reworked so that we register the mux in due time (i.e during the mdio init sequence, may be by hooking into stmmac_mdio_setup or something like that ?) Maxime
Hi Maxime, You and the bot are right: get_ephy_nodes() runs after stmmac_pltfr_probe() has registered the netdev, so the deferral comes too late. Yes, the internal and the external PHY are both behind the mux. stmmac attaches the PHY at open, so today the mux is registered only after the netdev is visible. It was build-tested only, as the notes said; I have no H3, H5 or V3s board with the internal PHY. I will drop this patch and move the mux registration into the MDIO setup, together with the probe and remove ordering that Chen-Yu raised on the mux use-after-free patch.
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c index 2ece7ba9dd73..8163e49fa7ad 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c @@ -801,8 +801,13 @@ static int get_ephy_nodes(struct stmmac_priv *priv) struct clk *ephy_clk; ephy_clk = of_clk_get(iphynode, 0); - if (IS_ERR(ephy_clk)) + if (IS_ERR(ephy_clk)) { + if (PTR_ERR(ephy_clk) == -EPROBE_DEFER) { + of_node_put(mdio_internal); + return -EPROBE_DEFER; + } continue; + } gmac->rst_ephy = of_reset_control_get_exclusive(iphynode, NULL); if (IS_ERR(gmac->rst_ephy)) { ret = PTR_ERR(gmac->rst_ephy);