Article View: linux.kernel.netdev
Article #20844Re: [PATCH net] net: ibm: emac: attach the fixed-link PHY with of_phy_connect()
From: Linkui Xiao
Date: Mon, 23 Nov 2026 09:20
Date: Mon, 23 Nov 2026 09:20
59 lines
11464 bytes
11464 bytes
Thanks for the review. All three issues are legitimate; v2 is a two patch
series posted as a new thread, [PATCH net v2 0/2].
- [High] The fixed-link PHY is attached but never detached.
Fixed in 1/2. emac_remove() and err_detach_tah in emac_probe() now call
phy_disconnect() and of_phy_deregister_fixed_link(), so the stale
attached_dev, the NUM_FP slot, the of_node reference and the module
references are all released. emac_remove() already unregisters the netdev
before this point, and phy_detach_internal() explicitly allows detaching
without RTNL once dev is unregistered, so the suspend use-after-free on
the stale attached_dev is gone.
The rebind analysis is correct: without the disconnect the second
of_phy_find_device() returns the still-attached PHY and phy_attach_direct()
fails with -EBUSY. Adding phy_disconnect() also stops the PHY, which the
phy-handle path never did - emac_mdio_init_phy() calls phy_start() and
nothing calls phy_stop().
You are also right that "the rest of the driver already treats
dev->phy.address < 0 as no PHY to poll, so nothing else changes" was too
strong, since the attach state does change. That claim is gone from the v2
commit message.
- [Medium] of_phy_connect() failure leaves the fixed PHY registered.
Fixed in 1/2: the failure branch calls of_phy_deregister_fixed_link(np)
before returning. The teardown paths guard the call with
of_phy_is_fixed_link(), which is the pattern ravb, nixge, davinci_emac and
cpsw use; of_phy_deregister_fixed_link() is also a no-op when no fixed PHY
is registered, so reaching it twice is safe.
- [Medium] emac_adjust_link() copies SPEED_UNKNOWN/DUPLEX_UNKNOWN.
This one is worse than "the old code behaved the same way", so thank you
for pushing on it. The regression comes from d99b408ed8e5 ("net: phy:
fixed_phy: remove not needed initialization of phy_device members"), which
stopped copying the device tree status into the phy_device on the
assumption that the state machine fills those members in once the PHY is
started. EMAC never starts it on the fixed-link path, so emac_configure()
builds MR1 without EMAC_MR1_FDE and without EMAC_MR1_MF_1000 /
EMAC_MR1_MF_100, and flow control is left off.
Fixed in 2/2 with phy_read_status() after the attach, which is what
emac_mdio_read_link() already does on the phy-handle path. The fixed PHY
is bound to genphy, so genphy_read_status() resolves speed, duplex and
pause from the BMSR/LPA/STAT1000/ESTATUS registers that swphy_read_reg()
emulates out of the device tree status. phy_read_status() rather than
phy_start() because a fixed link cannot change and there is no reason to
run the state machine for it.
Cross compiled for powerpc with W=1 out of ppc44x_defconfig, clean. No
hardware here, so no runtime test.
Regards,
Linkui
pw-bot: cr
Technical Details
Message-ID:
<20261123092053.743714-1-xiaolinkui@126.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369182-linux-kernel-netdev=dewy.ruReferences:
<20261112075321.3903875-1-xiaolinkui@126.com> <179483706662.3136.12689489417547730312@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369182-linux-kernel-netdev=dewy.ru From: xiaolinkui@126.com (Linkui Xiao) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] net: ibm: emac: attach the fixed-link PHY with of_phy_connect() Date: Mon, 23 Nov 2026 17:20:53 +0800 Organization: Usenet Network Message-ID: <20261123092053.743714-1-xiaolinkui@126.com> References: <20261112075321.3903875-1-xiaolinkui@126.com> <179483706662.3136.12689489417547730312@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3836632"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:NJSpyB7EOLSB42ok6qeck+tp00I= sha256:Y6snzLy15Gnf8UtbbFEYOnvv8mYHuRUj1k2Cb4lETLY= sha1:HoUh/Ze63hvWbpd6h9lSLBUiiI0= sha256:Suj60BZ0O3AjhQ42HUmdDfwfNmey5/PKAIznfz71ezk= 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 D7BA4125D98; Mon, 23 Nov 2026 12:22:22 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.048 X-Spam-Status: No, score=-3.048 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=126.com 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 8hG7hSq5_0wT; Mon, 23 Nov 2026 12:22:19 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-369182-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=126.com X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 12342125D95; Mon, 23 Nov 2026 12:22:08 +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 CCF9431430; Mon, 23 Nov 2026 09:22:04 +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=1795425723; b=DJ/gGYeX3a5ZIndE7KaIan0WskUjwgvZ1rtNZPPS/kPipfLialGtc2OVOD6fCZzFN1rD NrGxfsqfGfwh050Plx70dbIyg2M65t9BWeuDuf7mBeOnUrQ/7687zPjURuPgWmIQgZgah +NKxIl+j/0+tpmvK9syZC24knQREhYXobFmo/0sS+4OTh5p2+idVYmlWLvsyYXq9Wv1FX k40erWJBzu5pziaXNPAqlYo/qp15tUwIjTTPz6Y7JaK9a4zOgqinb/LO3Hhy2GeL/IT38 92n9Q7ZrL+tfxavF+P0Qq52/3rVnpIjj6DXN4jKlxw+XCERR0omnUJe4eYQsTYoLMyA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795425723; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:From:To: Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Transfer-Encoding:X-CM-TRANSID:X-Coremail-Antispam: X-CM-SenderInfo; bh=eIbFUnpQzf9CL+kQRcEu/bBGQBOvyQr5xT5bgYpH8ro=; b=pkVcTT6LD7I5DnsdPhbBpUOII3uAwqwVhk6Ay+X9f+FoxpUUEw46ypUEreWuL4tdOjft G2WGMpwv+tLETdaU9oTlWqu/2dHa1SGwSzGzLVpXAytqycyZ8fe2NMTNPkz8vjR/TpjfC p5HEr8HwiADjwJZB7JHRxsiSYiku/BMgApV611i6YM+dQnU9AgUYow3Hh6F+aMSit7TkO HPq74hy0elMbN4mPz8r+3CvCijI/iJhDbdfZOzRF/Y4a3Qcj83LFMZqBEYKdZX6oc1VY9 DuXfGPQ3ybngyz9PFf9TU55QqJfcArwp0sjEftyLW96m3iv9s0YEGCliH/U1HQBLppw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=leeu3TLY; dmarc=pass header.from=126.com; spf=pass smtp.mailfrom=126.com; 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 D0399606A333; Mon, 23 Nov 2026 09:22:03 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=leeu3TLY X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=220.197.31.9 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795425723; b=i2T/rr5L9LU2WiUfsp0PW4jlHR7PcPgFi2EEXw+sSwJDkYNeY9YCGh8b+ARySV5Y4LEs ILzYrqmM0GSLdGgjS1sO593Wc6xIbKJOZPVu4Iphi0TLqBFgjqaygiGb0iRdr2hkkesSk F5nEP27+AkmWA9Kf9LaXA1llNuvjoug4eMGkyq3lZUWgT+VsqKTKlQxSmJdSlYBP7ffQQ aQMkt05ca3+jdLnT7JZQYBMFcD1eSbkE+5sDwW7HY0NvdCB4dlppTlemWDZz6jWwbKxsx m5dMp/MyFPAZmqjjjqHCE30YKjrtmN0u0/MuqMTMEn15qf+SVli8L8kJLcagzgsqkTQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795425723; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-CM-TRANSID:X-Coremail-Antispam: X-CM-SenderInfo; bh=eIbFUnpQzf9CL+kQRcEu/bBGQBOvyQr5xT5bgYpH8ro=; b=DO6TM29oWYdicw3LOWqbHw3G/7Pm0fCYfMq0lA53HXIYBPwBW2jt1Km5WuVHcLy1Nl7V ZMTDqAeDdXN0vdVY+vwEwStIHZp8KmrJXzCEA8/RvncIGTXYIgsjzyanAim9ipuqqVxkp r/4Kbj9uGcmfy9iXG+qh66CWZC7ZWcejSAq0khtlSy/rRTdVVgpEeLJb7zOBQfF7tekwj G2L8yzZUrBrs45xt6S0BaGt/23x4lhunKu2sjJxiv9fG4jRgEj+S7yGYlrDYVH+k2eZzf h1MbKyUTNuju/3zuTgffa12dcWSvw0j83inPZrG0W82kL7t14sJE06JJvl7S6dc1Urg== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=126.com; spf=pass smtp.mailfrom=126.com; dkim=pass header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=leeu3TLY; arc=none smtp.remote-ip=220.197.31.9 X-Received: from m16.mail.126.com (m16.mail.126.com [220.197.31.9]) (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.subspace.kernel.org (Postfix) with ESMTPS id C3B83606A31F; Mon, 23 Nov 2026 09:21:59 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C3B83606A31F X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=126.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=126.com X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=eI bFUnpQzf9CL+kQRcEu/bBGQBOvyQr5xT5bgYpH8ro=; b=leeu3TLY9zSwD5MLER FnyTVmvJmE0OHOHwK/FePtPVKQPzZBx7zW+6UNu61uC5euhBbBiQcYfPN9Jj1ldA /mkRildSOTbjQgqYp2U8ymtO+zp7THEC7W4pwJmwj4Q7hKd5ec+W56DKgKO11tnS 7KvVwjLaucfOOnBbtJ2EVfeGA= X-Received: from localhost.localdomain (unknown []) by gzsmtp4 (Coremail) with SMTP id PykvCgCHrzx4BQRrXxDDDw--.13815S2; Mon, 23 Nov 2026 17:20:56 +0800 (CST) X-Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, rosenp@gmail.com, jacob.e.keller@intel.com, daniel.machon@microchip.com, chunkeey@gmail.com, kees+treewide@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, xiaolinkui@kylinos.cn, Linkui Xiao <xiaolinkui@126.com> X-Mailer: git-send-email 2.25.1 X-In-Reply-To: <179483706662.3136.12689489417547730312@kernel.org> 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 X-CM-TRANSID: PykvCgCHrzx4BQRrXxDDDw--.13815S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxJw1ftFy3XF4kGFW7Kw4kJFb_yoW5WFy3pa 9aqFykAryDGFWS9F4DuFy5GryrCr4xJa4jyFyFgr4a93Z8GryfAFWrKa4UtFyYyas7Ja4j vF18Gas3AFWDJaDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0JUwmiiUUUUU= X-CM-SenderInfo: p0ld0z5lqn3xa6rslhhfrp/xtbBqRg7EmsEBXhEVgAA3Y