<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/drivers/net/phy/phy_device.c, branch v6.18.21</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v6.18.21</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v6.18.21'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2026-03-12T11:09:40+00:00</updated>
<entry>
<title>net: phy: register phy led_triggers during probe to avoid AB-BA deadlock</title>
<updated>2026-03-12T11:09:40+00:00</updated>
<author>
<name>Andrew Lunn</name>
<email>andrew@lunn.ch</email>
</author>
<published>2026-02-22T15:26:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=2764dcb3c35de4410f642afc62cf979727470575'/>
<id>urn:sha1:2764dcb3c35de4410f642afc62cf979727470575</id>
<content type='text'>
commit c8dbdc6e380e7e96a51706db3e4b7870d8a9402d upstream.

There is an AB-BA deadlock when both LEDS_TRIGGER_NETDEV and
LED_TRIGGER_PHY are enabled:

[ 1362.049207] [&lt;8054e4b8&gt;] led_trigger_register+0x5c/0x1fc             &lt;-- Trying to get lock "triggers_list_lock" via down_write(&amp;triggers_list_lock);
[ 1362.054536] [&lt;80662830&gt;] phy_led_triggers_register+0xd0/0x234
[ 1362.060329] [&lt;8065e200&gt;] phy_attach_direct+0x33c/0x40c
[ 1362.065489] [&lt;80651fc4&gt;] phylink_fwnode_phy_connect+0x15c/0x23c
[ 1362.071480] [&lt;8066ee18&gt;] mtk_open+0x7c/0xba0
[ 1362.075849] [&lt;806d714c&gt;] __dev_open+0x280/0x2b0
[ 1362.080384] [&lt;806d7668&gt;] __dev_change_flags+0x244/0x24c
[ 1362.085598] [&lt;806d7698&gt;] dev_change_flags+0x28/0x78
[ 1362.090528] [&lt;807150e4&gt;] dev_ioctl+0x4c0/0x654                       &lt;-- Hold lock "rtnl_mutex" by calling rtnl_lock();
[ 1362.094985] [&lt;80694360&gt;] sock_ioctl+0x2f4/0x4e0
[ 1362.099567] [&lt;802e9c4c&gt;] sys_ioctl+0x32c/0xd8c
[ 1362.104022] [&lt;80014504&gt;] syscall_common+0x34/0x58

Here LED_TRIGGER_PHY is registering LED triggers during phy_attach
while holding RTNL and then taking triggers_list_lock.

[ 1362.191101] [&lt;806c2640&gt;] register_netdevice_notifier+0x60/0x168      &lt;-- Trying to get lock "rtnl_mutex" via rtnl_lock();
[ 1362.197073] [&lt;805504ac&gt;] netdev_trig_activate+0x194/0x1e4
[ 1362.202490] [&lt;8054e28c&gt;] led_trigger_set+0x1d4/0x360                 &lt;-- Hold lock "triggers_list_lock" by down_read(&amp;triggers_list_lock);
[ 1362.207511] [&lt;8054eb38&gt;] led_trigger_write+0xd8/0x14c
[ 1362.212566] [&lt;80381d98&gt;] sysfs_kf_bin_write+0x80/0xbc
[ 1362.217688] [&lt;8037fcd8&gt;] kernfs_fop_write_iter+0x17c/0x28c
[ 1362.223174] [&lt;802cbd70&gt;] vfs_write+0x21c/0x3c4
[ 1362.227712] [&lt;802cc0c4&gt;] ksys_write+0x78/0x12c
[ 1362.232164] [&lt;80014504&gt;] syscall_common+0x34/0x58

Here LEDS_TRIGGER_NETDEV is being enabled on an LED. It first takes
triggers_list_lock and then RTNL. A classical AB-BA deadlock.

phy_led_triggers_registers() does not require the RTNL, it does not
make any calls into the network stack which require protection. There
is also no requirement the PHY has been attached to a MAC, the
triggers only make use of phydev state. This allows the call to
phy_led_triggers_registers() to be placed elsewhere. PHY probe() and
release() don't hold RTNL, so solving the AB-BA deadlock.

Reported-by: Shiji Yang &lt;yangshiji66@outlook.com&gt;
Closes: https://lore.kernel.org/all/OS7PR01MB13602B128BA1AD3FA38B6D1FFBC69A@OS7PR01MB13602.jpnprd01.prod.outlook.com/
Fixes: 06f502f57d0d ("leds: trigger: Introduce a NETDEV trigger")
Cc: stable@vger.kernel.org
Signed-off-by: Andrew Lunn &lt;andrew@lunn.ch&gt;
Tested-by: Shiji Yang &lt;yangshiji66@outlook.com&gt;
Link: https://patch.msgid.link/20260222152601.1978655-1-andrew@lunn.ch
Signed-off-by: Paolo Abeni &lt;pabeni@redhat.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>net: phy: annotate linkmode initializers as not used after init phase</title>
<updated>2025-09-30T11:17:31+00:00</updated>
<author>
<name>Heiner Kallweit</name>
<email>hkallweit1@gmail.com</email>
</author>
<published>2025-09-27T19:57:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=49ac3d7826936b30eaa5dbe1bec6dad58f7d2476'/>
<id>urn:sha1:49ac3d7826936b30eaa5dbe1bec6dad58f7d2476</id>
<content type='text'>
Code and data used from phy_init() only, can be annotated accordingly.

Signed-off-by: Heiner Kallweit &lt;hkallweit1@gmail.com&gt;
Link: https://patch.msgid.link/5fb9c41b-bf44-4915-a3c3-f20952fce6de@gmail.com
Signed-off-by: Paolo Abeni &lt;pabeni@redhat.com&gt;

</content>
</entry>
<entry>
<title>net: phy: stop exporting phy_driver_unregister</title>
<updated>2025-09-30T11:17:16+00:00</updated>
<author>
<name>Heiner Kallweit</name>
<email>hkallweit1@gmail.com</email>
</author>
<published>2025-09-27T19:52:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=e211c463b748c4e2e8364c10bc216ca775fcc943'/>
<id>urn:sha1:e211c463b748c4e2e8364c10bc216ca775fcc943</id>
<content type='text'>
After 42e2a9e11a1d ("net: phy: dp83640: improve phydev and driver
removal handling") we can stop exporting also phy_driver_unregister().

Signed-off-by: Heiner Kallweit &lt;hkallweit1@gmail.com&gt;
Link: https://patch.msgid.link/2bab950e-4b70-4030-b997-03f48379586f@gmail.com
Signed-off-by: Paolo Abeni &lt;pabeni@redhat.com&gt;

</content>
</entry>
<entry>
<title>net: phy: stop exporting phy_driver_register</title>
<updated>2025-09-23T23:58:42+00:00</updated>
<author>
<name>Heiner Kallweit</name>
<email>hkallweit1@gmail.com</email>
</author>
<published>2025-09-20T21:34:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=092263a03105539b8dfe74c59be4c6cce1304d5f'/>
<id>urn:sha1:092263a03105539b8dfe74c59be4c6cce1304d5f</id>
<content type='text'>
phy_driver_register() isn't used outside phy_device.c any longer,
so we can stop exporting it.

Signed-off-by: Heiner Kallweit &lt;hkallweit1@gmail.com&gt;
Link: https://patch.msgid.link/dff44b83-4a85-4fff-bf6b-f12efd97b56e@gmail.com
Signed-off-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
</content>
</entry>
<entry>
<title>net: phy: fix phy_uses_state_machine()</title>
<updated>2025-09-09T23:33:19+00:00</updated>
<author>
<name>Russell King (Oracle)</name>
<email>rmk+kernel@armlinux.org.uk</email>
</author>
<published>2025-09-07T20:44:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=e0d1c55501d377163eb57feed863777ed1c973ad'/>
<id>urn:sha1:e0d1c55501d377163eb57feed863777ed1c973ad</id>
<content type='text'>
The blamed commit changed the conditions which phylib uses to stop
and start the state machine in the suspend and resume paths, and
while improving it, has caused two issues.

The original code used this test:

	phydev-&gt;attached_dev &amp;&amp; phydev-&gt;adjust_link

and if true, the paths would handle the PHY state machine. This test
evaluates true for normal drivers that are using phylib directly
while the PHY is attached to the network device, but false in all
other cases, which include the following cases:

- when the PHY has never been attached to a network device.
- when the PHY has been detached from a network device (as phy_detach()
   sets phydev-&gt;attached_dev to NULL, phy_disconnect() calls
   phy_detach() and additionally sets phydev-&gt;adjust_link NULL.)
- when phylink is using the driver (as phydev-&gt;adjust_link is NULL.)

Only the third case was incorrect, and the blamed commit attempted to
fix this by changing this test to (simplified for brevity, see
phy_uses_state_machine()):

	phydev-&gt;phy_link_change == phy_link_change ?
		phydev-&gt;attached_dev &amp;&amp; phydev-&gt;adjust_link : true

However, this also incorrectly evaluates true in the first two cases.

Fix the first case by ensuring that phy_uses_state_machine() returns
false when phydev-&gt;phy_link_change is NULL.

Fix the second case by ensuring that phydev-&gt;phy_link_change is set to
NULL when phy_detach() is called.

Reported-by: Xu Yang &lt;xu.yang_2@nxp.com&gt;
Link: https://lore.kernel.org/r/20250806082931.3289134-1-xu.yang_2@nxp.com
Fixes: fc75ea20ffb4 ("net: phy: allow MDIO bus PM ops to start/stop state machine for phylink-controlled PHY")
Signed-off-by: Russell King (Oracle) &lt;rmk+kernel@armlinux.org.uk&gt;
Reviewed-by: Vladimir Oltean &lt;vladimir.oltean@nxp.com&gt;
Link: https://patch.msgid.link/E1uvMEz-00000003Aoe-3qWe@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
</content>
</entry>
<entry>
<title>net: phy: Don't register LEDs for genphy</title>
<updated>2025-07-15T00:54:06+00:00</updated>
<author>
<name>Sean Anderson</name>
<email>sean.anderson@linux.dev</email>
</author>
<published>2025-07-10T20:14:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=a44312d58e78cfe8f0e72435101b7a9187b21d46'/>
<id>urn:sha1:a44312d58e78cfe8f0e72435101b7a9187b21d46</id>
<content type='text'>
If a PHY has no driver, the genphy driver is probed/removed directly in
phy_attach/detach. If the PHY's ofnode has an "leds" subnode, then the
LEDs will be (un)registered when probing/removing the genphy driver.
This could occur if the leds are for a non-generic driver that isn't
loaded for whatever reason. Synchronously removing the PHY device in
phy_detach leads to the following deadlock:

rtnl_lock()
ndo_close()
    ...
    phy_detach()
        phy_remove()
            phy_leds_unregister()
                led_classdev_unregister()
                    led_trigger_set()
                        netdev_trigger_deactivate()
                            unregister_netdevice_notifier()
                                rtnl_lock()

There is a corresponding deadlock on the open/register side of things
(and that one is reported by lockdep), but it requires a race while this
one is deterministic. Regular drivers do not have this problem since
they are probed asynchronously (without RTNL held).

Generic PHYs do not support LEDs anyway, so don't bother registering
them.

[JakubL this is a net-next version of
 commit f0f2b992d818 ("net: phy: Don't register LEDs for genphy"),
 which uses APIs removed in -next.]

Signed-off-by: Sean Anderson &lt;sean.anderson@linux.dev&gt;
Link: https://patch.msgid.link/20250710201454.1280277-1-sean.anderson@linux.dev
Signed-off-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
</content>
</entry>
<entry>
<title>net: phy: Add c45_phy_ids sysfs directory entry</title>
<updated>2025-06-17T13:11:51+00:00</updated>
<author>
<name>Yajun Deng</name>
<email>yajun.deng@linux.dev</email>
</author>
<published>2025-06-13T13:19:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=170e4e3944aa39accf64d869b27c187f8c08abc7'/>
<id>urn:sha1:170e4e3944aa39accf64d869b27c187f8c08abc7</id>
<content type='text'>
The phy_id field only shows the PHY ID of the C22 device, and the C45
device did not store its PHY ID in this field.

Add a new phy_mmd_group, and export the mmd&lt;n&gt;_device_id for the C45
device. These files are invisible to the C22 device.

Signed-off-by: Yajun Deng &lt;yajun.deng@linux.dev&gt;
Reviewed-by: Andrew Lunn &lt;andrew@lunn.ch&gt;
Link: https://patch.msgid.link/20250613131903.2961-1-yajun.deng@linux.dev
Signed-off-by: Paolo Abeni &lt;pabeni@redhat.com&gt;

</content>
</entry>
<entry>
<title>net: phy: remove phy_driver_is_genphy_10g</title>
<updated>2025-06-17T01:15:16+00:00</updated>
<author>
<name>Heiner Kallweit</name>
<email>hkallweit1@gmail.com</email>
</author>
<published>2025-06-14T20:32:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=42ed7f7e94da01391d3519ffb5747698d2be0a67'/>
<id>urn:sha1:42ed7f7e94da01391d3519ffb5747698d2be0a67</id>
<content type='text'>
Remove now unused function phy_driver_is_genphy_10g().

Signed-off-by: Heiner Kallweit &lt;hkallweit1@gmail.com&gt;
Reviewed-by: Russell King (Oracle) &lt;rmk+kernel@armlinux.org.uk&gt;
Link: https://patch.msgid.link/49b0589a-9604-4ee9-add5-28fbbbe2c2f3@gmail.com
Signed-off-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
</content>
</entry>
<entry>
<title>net: phy: improve phy_driver_is_genphy</title>
<updated>2025-06-17T01:15:16+00:00</updated>
<author>
<name>Heiner Kallweit</name>
<email>hkallweit1@gmail.com</email>
</author>
<published>2025-06-14T20:31:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=59e74c92e67e2951d829f9b0d78c5dc1df7c4c88'/>
<id>urn:sha1:59e74c92e67e2951d829f9b0d78c5dc1df7c4c88</id>
<content type='text'>
Use new flag phydev-&gt;is_genphy_driven to simplify this function.
Note that this includes a minor functional change:
Now this function returns true if ANY of the genphy drivers
is bound to the PHY device.

We have only one user in DSA driver mt7530, and there the
functional change doesn't matter.

Signed-off-by: Heiner Kallweit &lt;hkallweit1@gmail.com&gt;
Reviewed-by: Russell King (Oracle) &lt;rmk+kernel@armlinux.org.uk&gt;
Link: https://patch.msgid.link/c9ac3a7d-262a-425d-9153-97fe3ca6280a@gmail.com
Signed-off-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
</content>
</entry>
<entry>
<title>net: phy: add flag is_genphy_driven to struct phy_device</title>
<updated>2025-06-17T01:15:16+00:00</updated>
<author>
<name>Heiner Kallweit</name>
<email>hkallweit1@gmail.com</email>
</author>
<published>2025-06-14T20:30:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=2796ff1e3dcae7a3568f8e428ec9d32a8ee2fb36'/>
<id>urn:sha1:2796ff1e3dcae7a3568f8e428ec9d32a8ee2fb36</id>
<content type='text'>
In order to get rid of phy_driver_is_genphy() and
phy_driver_is_genphy_10g(), as first step add and use a flag
phydev-&gt;is_genphy_driven.

Signed-off-by: Heiner Kallweit &lt;hkallweit1@gmail.com&gt;
Reviewed-by: Russell King (Oracle) &lt;rmk+kernel@armlinux.org.uk&gt;
Link: https://patch.msgid.link/3f3ad6dc-402e-4915-8d5a-2306b6d5562b@gmail.com
Signed-off-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
</content>
</entry>
</feed>
