linux-stable/drivers/net/mdio
Vladimir Oltean 01ab2d123e net: mdio: don't defer probe forever if PHY IRQ provider is missing
[ Upstream commit 74befa447e ]

When a driver for an interrupt controller is missing, of_irq_get()
returns -EPROBE_DEFER ad infinitum, causing
fwnode_mdiobus_phy_device_register(), and ultimately, the entire
of_mdiobus_register() call, to fail. In turn, any phy_connect() call
towards a PHY on this MDIO bus will also fail.

This is not what is expected to happen, because the PHY library falls
back to poll mode when of_irq_get() returns a hard error code, and the
MDIO bus, PHY and attached Ethernet controller work fine, albeit
suboptimally, when the PHY library polls for link status. However,
-EPROBE_DEFER has special handling given the assumption that at some
point probe deferral will stop, and the driver for the supplier will
kick in and create the IRQ domain.

Reasons for which the interrupt controller may be missing:

- It is not yet written. This may happen if a more recent DT blob (with
  an interrupt-parent for the PHY) is used to boot an old kernel where
  the driver didn't exist, and that kernel worked with the
  vintage-correct DT blob using poll mode.

- It is compiled out. Behavior is the same as above.

- It is compiled as a module. The kernel will wait for a number of
  seconds specified in the "deferred_probe_timeout" boot parameter for
  user space to load the required module. The current default is 0,
  which times out at the end of initcalls. It is possible that this
  might cause regressions unless users adjust this boot parameter.

The proposed solution is to use the driver_deferred_probe_check_state()
helper function provided by the driver core, which gives up after some
-EPROBE_DEFER attempts, taking "deferred_probe_timeout" into consideration.
The return code is changed from -EPROBE_DEFER into -ENODEV or
-ETIMEDOUT, depending on whether the kernel is compiled with support for
modules or not.

Fixes: 66bdede495 ("of_mdio: Fix broken PHY IRQ in case of probe deferral")
Suggested-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/20220407165538.4084809-1-vladimir.oltean@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-04-20 09:36:13 +02:00
..
acpi_mdio.c net: mdio: Add ACPI support code for mdio 2021-06-11 13:08:53 -07:00
fwnode_mdio.c net: mdio: don't defer probe forever if PHY IRQ provider is missing 2022-04-20 09:36:13 +02:00
Kconfig net: mdio: mscc-miim: Add depend of REGMAP_MMIO on MDIO_MSCC_MIIM 2021-12-01 18:46:54 -08:00
Makefile net: mdio: Add ACPI support code for mdio 2021-06-11 13:08:53 -07:00
mdio-aspeed.c net: mdio: aspeed: Add missing MODULE_DEVICE_TABLE 2022-02-09 12:15:21 +00:00
mdio-bcm-iproc.c
mdio-bcm-unimac.c net: mdio: Fix spelling mistakes 2021-06-01 17:05:05 -07:00
mdio-bitbang.c net: phy: Add support for microchip SMI0 MDIO bus 2021-04-27 14:13:24 -07:00
mdio-cavium.c net: mdio: Alphabetically sort header inclusion 2021-03-16 11:10:00 -07:00
mdio-cavium.h
mdio-gpio.c net: phy: Add support for microchip SMI0 MDIO bus 2021-04-27 14:13:24 -07:00
mdio-hisi-femac.c
mdio-i2c.c
mdio-ipq4019.c net: mdio-ipq4019: add delay after clock enable 2022-02-21 13:04:53 +00:00
mdio-ipq8064.c net: mdio: ipq8064: replace ioremap() with devm_ioremap() 2021-11-29 12:02:49 +00:00
mdio-moxart.c net: phy: rename PHY_IGNORE_INTERRUPT to PHY_MAC_INTERRUPT 2021-02-15 15:20:49 -08:00
mdio-mscc-miim.c net: phy: mscc-miim: reject clause 45 register accesses 2022-04-13 19:27:32 +02:00
mdio-mux-bcm-iproc.c net: mido: mdio-mux-bcm-iproc: Use devm_platform_get_and_ioremap_resource() 2021-06-10 13:59:37 -07:00
mdio-mux-bcm6368.c net: mdio: Add BCM6368 MDIO mux bus controller 2021-03-16 11:52:18 -07:00
mdio-mux-gpio.c net: mdio: Alphabetically sort header inclusion 2021-03-16 11:10:00 -07:00
mdio-mux-meson-g12a.c net: mdio: Fix spelling mistakes 2021-06-01 17:05:05 -07:00
mdio-mux-mmioreg.c net: mdio: Alphabetically sort header inclusion 2021-03-16 11:10:00 -07:00
mdio-mux-multiplexer.c net: mdio: Alphabetically sort header inclusion 2021-03-16 11:10:00 -07:00
mdio-mux.c net: mdio-mux: Handle -EPROBE_DEFER correctly 2021-08-18 10:48:52 +01:00
mdio-mvusb.c
mdio-octeon.c net: mdio: octeon: Fix some double free issues 2021-05-13 15:43:52 -07:00
mdio-sun4i.c
mdio-thunder.c net: mdio: thunder: Fix a double free issue in the .remove function 2021-05-13 13:13:34 -07:00
mdio-xgene.c net: mdio: Alphabetically sort header inclusion 2021-03-16 11:10:00 -07:00
of_mdio.c net: mdio: use device_set_node() to setup both fwnode and of 2021-06-17 12:06:52 -07:00