netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v2 0/2] sh_eth: Fix reboot crash
@ 2021-01-18 15:06 Geert Uytterhoeven
  2021-01-18 15:06 ` [PATCH net v2 1/2] mdio-bitbang: Export mdiobb_{read,write}() Geert Uytterhoeven
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Geert Uytterhoeven @ 2021-01-18 15:06 UTC (permalink / raw)
  To: Sergei Shtylyov, David S . Miller, Jakub Kicinski, Andrew Lunn,
	Heiner Kallweit, Florian Fainelli, Russell King, Ioana Ciornei,
	Wolfram Sang
  Cc: netdev, linux-renesas-soc, linux-kernel, Geert Uytterhoeven

	Hi,

This patch fixes a regression v5.11-rc1, where rebooting while a sh_eth
device is not opened will cause a crash.

Changes compared to v1:
  - Export mdiobb_{read,write}(),
  - Call mdiobb_{read,write}() now they are exported,
  - Use mii_bus.parent to avoid bb_info.dev copy,
  - Drop RFC state.

Alternatively, mdio-bitbang could provide Runtime PM-aware wrappers
itself, and use them either manually (through a new parameter to
alloc_mdio_bitbang(), or a new alloc_mdio_bitbang_*() function), or
automatically (e.g. if pm_runtime_enabled() returns true).  Note that
the latter requires a "struct device *" parameter to operate on.
Currently there are only two drivers that call alloc_mdio_bitbang() and
use Runtime PM: the Renesas sh_eth and ravb drivers.  This series fixes
the former, while the latter is not affected (it keeps the device
powered all the time between driver probe and driver unbind, and
changing that seems to be non-trivial).

Thanks for your comments!

Geert Uytterhoeven (2):
  net: mdio-bitbang: Export mdiobb_{read,write}()
  sh_eth: Make PHY access aware of Runtime PM to fix reboot crash

 drivers/net/ethernet/renesas/sh_eth.c | 26 ++++++++++++++++++++++++++
 drivers/net/mdio/mdio-bitbang.c       |  6 ++++--
 include/linux/mdio-bitbang.h          |  3 +++
 3 files changed, 33 insertions(+), 2 deletions(-)

-- 
2.25.1

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH net v2 1/2] mdio-bitbang: Export mdiobb_{read,write}()
  2021-01-18 15:06 [PATCH net v2 0/2] sh_eth: Fix reboot crash Geert Uytterhoeven
@ 2021-01-18 15:06 ` Geert Uytterhoeven
  2021-01-18 19:58   ` Wolfram Sang
  2021-01-18 20:40   ` Florian Fainelli
  2021-01-18 15:06 ` [PATCH net v2 2/2] sh_eth: Make PHY access aware of Runtime PM to fix reboot crash Geert Uytterhoeven
  2021-01-19 20:30 ` [PATCH net v2 0/2] sh_eth: Fix " patchwork-bot+netdevbpf
  2 siblings, 2 replies; 9+ messages in thread
From: Geert Uytterhoeven @ 2021-01-18 15:06 UTC (permalink / raw)
  To: Sergei Shtylyov, David S . Miller, Jakub Kicinski, Andrew Lunn,
	Heiner Kallweit, Florian Fainelli, Russell King, Ioana Ciornei,
	Wolfram Sang
  Cc: netdev, linux-renesas-soc, linux-kernel, Geert Uytterhoeven

Export mdiobb_read() and mdiobb_write(), so Ethernet controller drivers
can call them from their MDIO read/write wrappers.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.
---
 drivers/net/mdio/mdio-bitbang.c | 6 ++++--
 include/linux/mdio-bitbang.h    | 3 +++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/mdio/mdio-bitbang.c b/drivers/net/mdio/mdio-bitbang.c
index 5136275c8e7399fb..d3915f83185430e9 100644
--- a/drivers/net/mdio/mdio-bitbang.c
+++ b/drivers/net/mdio/mdio-bitbang.c
@@ -149,7 +149,7 @@ static int mdiobb_cmd_addr(struct mdiobb_ctrl *ctrl, int phy, u32 addr)
 	return dev_addr;
 }
 
-static int mdiobb_read(struct mii_bus *bus, int phy, int reg)
+int mdiobb_read(struct mii_bus *bus, int phy, int reg)
 {
 	struct mdiobb_ctrl *ctrl = bus->priv;
 	int ret, i;
@@ -180,8 +180,9 @@ static int mdiobb_read(struct mii_bus *bus, int phy, int reg)
 	mdiobb_get_bit(ctrl);
 	return ret;
 }
+EXPORT_SYMBOL(mdiobb_read);
 
-static int mdiobb_write(struct mii_bus *bus, int phy, int reg, u16 val)
+int mdiobb_write(struct mii_bus *bus, int phy, int reg, u16 val)
 {
 	struct mdiobb_ctrl *ctrl = bus->priv;
 
@@ -201,6 +202,7 @@ static int mdiobb_write(struct mii_bus *bus, int phy, int reg, u16 val)
 	mdiobb_get_bit(ctrl);
 	return 0;
 }
+EXPORT_SYMBOL(mdiobb_write);
 
 struct mii_bus *alloc_mdio_bitbang(struct mdiobb_ctrl *ctrl)
 {
diff --git a/include/linux/mdio-bitbang.h b/include/linux/mdio-bitbang.h
index 5d71e8a8500f5ed1..aca4dc037b70b728 100644
--- a/include/linux/mdio-bitbang.h
+++ b/include/linux/mdio-bitbang.h
@@ -35,6 +35,9 @@ struct mdiobb_ctrl {
 	const struct mdiobb_ops *ops;
 };
 
+int mdiobb_read(struct mii_bus *bus, int phy, int reg);
+int mdiobb_write(struct mii_bus *bus, int phy, int reg, u16 val);
+
 /* The returned bus is not yet registered with the phy layer. */
 struct mii_bus *alloc_mdio_bitbang(struct mdiobb_ctrl *ctrl);
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH net v2 2/2] sh_eth: Make PHY access aware of Runtime PM to fix reboot crash
  2021-01-18 15:06 [PATCH net v2 0/2] sh_eth: Fix reboot crash Geert Uytterhoeven
  2021-01-18 15:06 ` [PATCH net v2 1/2] mdio-bitbang: Export mdiobb_{read,write}() Geert Uytterhoeven
@ 2021-01-18 15:06 ` Geert Uytterhoeven
  2021-01-18 19:58   ` Wolfram Sang
                     ` (2 more replies)
  2021-01-19 20:30 ` [PATCH net v2 0/2] sh_eth: Fix " patchwork-bot+netdevbpf
  2 siblings, 3 replies; 9+ messages in thread
From: Geert Uytterhoeven @ 2021-01-18 15:06 UTC (permalink / raw)
  To: Sergei Shtylyov, David S . Miller, Jakub Kicinski, Andrew Lunn,
	Heiner Kallweit, Florian Fainelli, Russell King, Ioana Ciornei,
	Wolfram Sang
  Cc: netdev, linux-renesas-soc, linux-kernel, Geert Uytterhoeven

Wolfram reports that his R-Car H2-based Lager board can no longer be
rebooted in v5.11-rc1, as it crashes with an imprecise external abort.
The issue can be reproduced on other boards (e.g. Koelsch with R-Car
M2-W) too, if CONFIG_IP_PNP is disabled, and the Ethernet interface is
down at reboot time:

    Unhandled fault: imprecise external abort (0x1406) at 0x00000000
    pgd = (ptrval)
    [00000000] *pgd=422b6835, *pte=00000000, *ppte=00000000
    Internal error: : 1406 [#1] ARM
    Modules linked in:
    CPU: 0 PID: 1105 Comm: init Tainted: G        W         5.10.0-rc1-00402-ge2f016cf7751 #1048
    Hardware name: Generic R-Car Gen2 (Flattened Device Tree)
    PC is at sh_mdio_ctrl+0x44/0x60
    LR is at sh_mmd_ctrl+0x20/0x24
    ...
    Backtrace:
    [<c0451f30>] (sh_mdio_ctrl) from [<c0451fd4>] (sh_mmd_ctrl+0x20/0x24)
     r7:0000001f r6:00000020 r5:00000002 r4:c22a1dc4
    [<c0451fb4>] (sh_mmd_ctrl) from [<c044fc18>] (mdiobb_cmd+0x38/0xa8)
    [<c044fbe0>] (mdiobb_cmd) from [<c044feb8>] (mdiobb_read+0x58/0xdc)
     r9:c229f844 r8:c0c329dc r7:c221e000 r6:00000001 r5:c22a1dc4 r4:00000001
    [<c044fe60>] (mdiobb_read) from [<c044c854>] (__mdiobus_read+0x74/0xe0)
     r7:0000001f r6:00000001 r5:c221e000 r4:c221e000
    [<c044c7e0>] (__mdiobus_read) from [<c044c9d8>] (mdiobus_read+0x40/0x54)
     r7:0000001f r6:00000001 r5:c221e000 r4:c221e458
    [<c044c998>] (mdiobus_read) from [<c044d678>] (phy_read+0x1c/0x20)
     r7:ffffe000 r6:c221e470 r5:00000200 r4:c229f800
    [<c044d65c>] (phy_read) from [<c044d94c>] (kszphy_config_intr+0x44/0x80)
    [<c044d908>] (kszphy_config_intr) from [<c044694c>] (phy_disable_interrupts+0x44/0x50)
     r5:c229f800 r4:c229f800
    [<c0446908>] (phy_disable_interrupts) from [<c0449370>] (phy_shutdown+0x18/0x1c)
     r5:c229f800 r4:c229f804
    [<c0449358>] (phy_shutdown) from [<c040066c>] (device_shutdown+0x168/0x1f8)
    [<c0400504>] (device_shutdown) from [<c013de44>] (kernel_restart_prepare+0x3c/0x48)
     r9:c22d2000 r8:c0100264 r7:c0b0d034 r6:00000000 r5:4321fedc r4:00000000
    [<c013de08>] (kernel_restart_prepare) from [<c013dee0>] (kernel_restart+0x1c/0x60)
    [<c013dec4>] (kernel_restart) from [<c013e1d8>] (__do_sys_reboot+0x168/0x208)
     r5:4321fedc r4:01234567
    [<c013e070>] (__do_sys_reboot) from [<c013e2e8>] (sys_reboot+0x18/0x1c)
     r7:00000058 r6:00000000 r5:00000000 r4:00000000
    [<c013e2d0>] (sys_reboot) from [<c0100060>] (ret_fast_syscall+0x0/0x54)

As of commit e2f016cf775129c0 ("net: phy: add a shutdown procedure"),
system reboot calls phy_disable_interrupts() during shutdown.  As this
happens unconditionally, the PHY registers may be accessed while the
device is suspended, causing undefined behavior, which may crash the
system.

Fix this by wrapping the PHY bitbang accessors in the sh_eth driver by
wrappers that take care of Runtime PM, to resume the device when needed.

Reported-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Suggested-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - Call mdiobb_{read,write}() now they are exported,
  - Use mii_bus.parent to avoid bb_info.dev copy,
  - Drop RFC state.
---
 drivers/net/ethernet/renesas/sh_eth.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index c633046329352601..9b52d350e21a9f2b 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -3034,6 +3034,28 @@ static int sh_mdio_release(struct sh_eth_private *mdp)
 	return 0;
 }
 
+static int sh_mdiobb_read(struct mii_bus *bus, int phy, int reg)
+{
+	int res;
+
+	pm_runtime_get_sync(bus->parent);
+	res = mdiobb_read(bus, phy, reg);
+	pm_runtime_put(bus->parent);
+
+	return res;
+}
+
+static int sh_mdiobb_write(struct mii_bus *bus, int phy, int reg, u16 val)
+{
+	int res;
+
+	pm_runtime_get_sync(bus->parent);
+	res = mdiobb_write(bus, phy, reg, val);
+	pm_runtime_put(bus->parent);
+
+	return res;
+}
+
 /* MDIO bus init function */
 static int sh_mdio_init(struct sh_eth_private *mdp,
 			struct sh_eth_plat_data *pd)
@@ -3058,6 +3080,10 @@ static int sh_mdio_init(struct sh_eth_private *mdp,
 	if (!mdp->mii_bus)
 		return -ENOMEM;
 
+	/* Wrap accessors with Runtime PM-aware ops */
+	mdp->mii_bus->read = sh_mdiobb_read;
+	mdp->mii_bus->write = sh_mdiobb_write;
+
 	/* Hook up MII support for ethtool */
 	mdp->mii_bus->name = "sh_mii";
 	mdp->mii_bus->parent = dev;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH net v2 1/2] mdio-bitbang: Export mdiobb_{read,write}()
  2021-01-18 15:06 ` [PATCH net v2 1/2] mdio-bitbang: Export mdiobb_{read,write}() Geert Uytterhoeven
@ 2021-01-18 19:58   ` Wolfram Sang
  2021-01-18 20:40   ` Florian Fainelli
  1 sibling, 0 replies; 9+ messages in thread
From: Wolfram Sang @ 2021-01-18 19:58 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Sergei Shtylyov, David S . Miller, Jakub Kicinski, Andrew Lunn,
	Heiner Kallweit, Florian Fainelli, Russell King, Ioana Ciornei,
	netdev, linux-renesas-soc, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 329 bytes --]

On Mon, Jan 18, 2021 at 04:06:55PM +0100, Geert Uytterhoeven wrote:
> Export mdiobb_read() and mdiobb_write(), so Ethernet controller drivers
> can call them from their MDIO read/write wrappers.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net v2 2/2] sh_eth: Make PHY access aware of Runtime PM to fix reboot crash
  2021-01-18 15:06 ` [PATCH net v2 2/2] sh_eth: Make PHY access aware of Runtime PM to fix reboot crash Geert Uytterhoeven
@ 2021-01-18 19:58   ` Wolfram Sang
  2021-01-18 20:40   ` Florian Fainelli
  2021-01-18 21:21   ` Andrew Lunn
  2 siblings, 0 replies; 9+ messages in thread
From: Wolfram Sang @ 2021-01-18 19:58 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Sergei Shtylyov, David S . Miller, Jakub Kicinski, Andrew Lunn,
	Heiner Kallweit, Florian Fainelli, Russell King, Ioana Ciornei,
	netdev, linux-renesas-soc, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 3396 bytes --]

On Mon, Jan 18, 2021 at 04:06:56PM +0100, Geert Uytterhoeven wrote:
> Wolfram reports that his R-Car H2-based Lager board can no longer be
> rebooted in v5.11-rc1, as it crashes with an imprecise external abort.
> The issue can be reproduced on other boards (e.g. Koelsch with R-Car
> M2-W) too, if CONFIG_IP_PNP is disabled, and the Ethernet interface is
> down at reboot time:
> 
>     Unhandled fault: imprecise external abort (0x1406) at 0x00000000
>     pgd = (ptrval)
>     [00000000] *pgd=422b6835, *pte=00000000, *ppte=00000000
>     Internal error: : 1406 [#1] ARM
>     Modules linked in:
>     CPU: 0 PID: 1105 Comm: init Tainted: G        W         5.10.0-rc1-00402-ge2f016cf7751 #1048
>     Hardware name: Generic R-Car Gen2 (Flattened Device Tree)
>     PC is at sh_mdio_ctrl+0x44/0x60
>     LR is at sh_mmd_ctrl+0x20/0x24
>     ...
>     Backtrace:
>     [<c0451f30>] (sh_mdio_ctrl) from [<c0451fd4>] (sh_mmd_ctrl+0x20/0x24)
>      r7:0000001f r6:00000020 r5:00000002 r4:c22a1dc4
>     [<c0451fb4>] (sh_mmd_ctrl) from [<c044fc18>] (mdiobb_cmd+0x38/0xa8)
>     [<c044fbe0>] (mdiobb_cmd) from [<c044feb8>] (mdiobb_read+0x58/0xdc)
>      r9:c229f844 r8:c0c329dc r7:c221e000 r6:00000001 r5:c22a1dc4 r4:00000001
>     [<c044fe60>] (mdiobb_read) from [<c044c854>] (__mdiobus_read+0x74/0xe0)
>      r7:0000001f r6:00000001 r5:c221e000 r4:c221e000
>     [<c044c7e0>] (__mdiobus_read) from [<c044c9d8>] (mdiobus_read+0x40/0x54)
>      r7:0000001f r6:00000001 r5:c221e000 r4:c221e458
>     [<c044c998>] (mdiobus_read) from [<c044d678>] (phy_read+0x1c/0x20)
>      r7:ffffe000 r6:c221e470 r5:00000200 r4:c229f800
>     [<c044d65c>] (phy_read) from [<c044d94c>] (kszphy_config_intr+0x44/0x80)
>     [<c044d908>] (kszphy_config_intr) from [<c044694c>] (phy_disable_interrupts+0x44/0x50)
>      r5:c229f800 r4:c229f800
>     [<c0446908>] (phy_disable_interrupts) from [<c0449370>] (phy_shutdown+0x18/0x1c)
>      r5:c229f800 r4:c229f804
>     [<c0449358>] (phy_shutdown) from [<c040066c>] (device_shutdown+0x168/0x1f8)
>     [<c0400504>] (device_shutdown) from [<c013de44>] (kernel_restart_prepare+0x3c/0x48)
>      r9:c22d2000 r8:c0100264 r7:c0b0d034 r6:00000000 r5:4321fedc r4:00000000
>     [<c013de08>] (kernel_restart_prepare) from [<c013dee0>] (kernel_restart+0x1c/0x60)
>     [<c013dec4>] (kernel_restart) from [<c013e1d8>] (__do_sys_reboot+0x168/0x208)
>      r5:4321fedc r4:01234567
>     [<c013e070>] (__do_sys_reboot) from [<c013e2e8>] (sys_reboot+0x18/0x1c)
>      r7:00000058 r6:00000000 r5:00000000 r4:00000000
>     [<c013e2d0>] (sys_reboot) from [<c0100060>] (ret_fast_syscall+0x0/0x54)
> 
> As of commit e2f016cf775129c0 ("net: phy: add a shutdown procedure"),
> system reboot calls phy_disable_interrupts() during shutdown.  As this
> happens unconditionally, the PHY registers may be accessed while the
> device is suspended, causing undefined behavior, which may crash the
> system.
> 
> Fix this by wrapping the PHY bitbang accessors in the sh_eth driver by
> wrappers that take care of Runtime PM, to resume the device when needed.
> 
> Reported-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Suggested-by: Andrew Lunn <andrew@lunn.ch>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Thanks for debugging and fixing this, Geert!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net v2 1/2] mdio-bitbang: Export mdiobb_{read,write}()
  2021-01-18 15:06 ` [PATCH net v2 1/2] mdio-bitbang: Export mdiobb_{read,write}() Geert Uytterhoeven
  2021-01-18 19:58   ` Wolfram Sang
@ 2021-01-18 20:40   ` Florian Fainelli
  1 sibling, 0 replies; 9+ messages in thread
From: Florian Fainelli @ 2021-01-18 20:40 UTC (permalink / raw)
  To: Geert Uytterhoeven, Sergei Shtylyov, David S . Miller,
	Jakub Kicinski, Andrew Lunn, Heiner Kallweit, Russell King,
	Ioana Ciornei, Wolfram Sang
  Cc: netdev, linux-renesas-soc, linux-kernel



On 1/18/2021 7:06 AM, Geert Uytterhoeven wrote:
> Export mdiobb_read() and mdiobb_write(), so Ethernet controller drivers
> can call them from their MDIO read/write wrappers.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net v2 2/2] sh_eth: Make PHY access aware of Runtime PM to fix reboot crash
  2021-01-18 15:06 ` [PATCH net v2 2/2] sh_eth: Make PHY access aware of Runtime PM to fix reboot crash Geert Uytterhoeven
  2021-01-18 19:58   ` Wolfram Sang
@ 2021-01-18 20:40   ` Florian Fainelli
  2021-01-18 21:21   ` Andrew Lunn
  2 siblings, 0 replies; 9+ messages in thread
From: Florian Fainelli @ 2021-01-18 20:40 UTC (permalink / raw)
  To: Geert Uytterhoeven, Sergei Shtylyov, David S . Miller,
	Jakub Kicinski, Andrew Lunn, Heiner Kallweit, Russell King,
	Ioana Ciornei, Wolfram Sang
  Cc: netdev, linux-renesas-soc, linux-kernel



On 1/18/2021 7:06 AM, Geert Uytterhoeven wrote:
> Wolfram reports that his R-Car H2-based Lager board can no longer be
> rebooted in v5.11-rc1, as it crashes with an imprecise external abort.
> The issue can be reproduced on other boards (e.g. Koelsch with R-Car
> M2-W) too, if CONFIG_IP_PNP is disabled, and the Ethernet interface is
> down at reboot time:
> 
>     Unhandled fault: imprecise external abort (0x1406) at 0x00000000
>     pgd = (ptrval)
>     [00000000] *pgd=422b6835, *pte=00000000, *ppte=00000000
>     Internal error: : 1406 [#1] ARM
>     Modules linked in:
>     CPU: 0 PID: 1105 Comm: init Tainted: G        W         5.10.0-rc1-00402-ge2f016cf7751 #1048
>     Hardware name: Generic R-Car Gen2 (Flattened Device Tree)
>     PC is at sh_mdio_ctrl+0x44/0x60
>     LR is at sh_mmd_ctrl+0x20/0x24
>     ...
>     Backtrace:
>     [<c0451f30>] (sh_mdio_ctrl) from [<c0451fd4>] (sh_mmd_ctrl+0x20/0x24)
>      r7:0000001f r6:00000020 r5:00000002 r4:c22a1dc4
>     [<c0451fb4>] (sh_mmd_ctrl) from [<c044fc18>] (mdiobb_cmd+0x38/0xa8)
>     [<c044fbe0>] (mdiobb_cmd) from [<c044feb8>] (mdiobb_read+0x58/0xdc)
>      r9:c229f844 r8:c0c329dc r7:c221e000 r6:00000001 r5:c22a1dc4 r4:00000001
>     [<c044fe60>] (mdiobb_read) from [<c044c854>] (__mdiobus_read+0x74/0xe0)
>      r7:0000001f r6:00000001 r5:c221e000 r4:c221e000
>     [<c044c7e0>] (__mdiobus_read) from [<c044c9d8>] (mdiobus_read+0x40/0x54)
>      r7:0000001f r6:00000001 r5:c221e000 r4:c221e458
>     [<c044c998>] (mdiobus_read) from [<c044d678>] (phy_read+0x1c/0x20)
>      r7:ffffe000 r6:c221e470 r5:00000200 r4:c229f800
>     [<c044d65c>] (phy_read) from [<c044d94c>] (kszphy_config_intr+0x44/0x80)
>     [<c044d908>] (kszphy_config_intr) from [<c044694c>] (phy_disable_interrupts+0x44/0x50)
>      r5:c229f800 r4:c229f800
>     [<c0446908>] (phy_disable_interrupts) from [<c0449370>] (phy_shutdown+0x18/0x1c)
>      r5:c229f800 r4:c229f804
>     [<c0449358>] (phy_shutdown) from [<c040066c>] (device_shutdown+0x168/0x1f8)
>     [<c0400504>] (device_shutdown) from [<c013de44>] (kernel_restart_prepare+0x3c/0x48)
>      r9:c22d2000 r8:c0100264 r7:c0b0d034 r6:00000000 r5:4321fedc r4:00000000
>     [<c013de08>] (kernel_restart_prepare) from [<c013dee0>] (kernel_restart+0x1c/0x60)
>     [<c013dec4>] (kernel_restart) from [<c013e1d8>] (__do_sys_reboot+0x168/0x208)
>      r5:4321fedc r4:01234567
>     [<c013e070>] (__do_sys_reboot) from [<c013e2e8>] (sys_reboot+0x18/0x1c)
>      r7:00000058 r6:00000000 r5:00000000 r4:00000000
>     [<c013e2d0>] (sys_reboot) from [<c0100060>] (ret_fast_syscall+0x0/0x54)
> 
> As of commit e2f016cf775129c0 ("net: phy: add a shutdown procedure"),
> system reboot calls phy_disable_interrupts() during shutdown.  As this
> happens unconditionally, the PHY registers may be accessed while the
> device is suspended, causing undefined behavior, which may crash the
> system.
> 
> Fix this by wrapping the PHY bitbang accessors in the sh_eth driver by
> wrappers that take care of Runtime PM, to resume the device when needed.
> 
> Reported-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Suggested-by: Andrew Lunn <andrew@lunn.ch>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net v2 2/2] sh_eth: Make PHY access aware of Runtime PM to fix reboot crash
  2021-01-18 15:06 ` [PATCH net v2 2/2] sh_eth: Make PHY access aware of Runtime PM to fix reboot crash Geert Uytterhoeven
  2021-01-18 19:58   ` Wolfram Sang
  2021-01-18 20:40   ` Florian Fainelli
@ 2021-01-18 21:21   ` Andrew Lunn
  2 siblings, 0 replies; 9+ messages in thread
From: Andrew Lunn @ 2021-01-18 21:21 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Sergei Shtylyov, David S . Miller, Jakub Kicinski,
	Heiner Kallweit, Florian Fainelli, Russell King, Ioana Ciornei,
	Wolfram Sang, netdev, linux-renesas-soc, linux-kernel

On Mon, Jan 18, 2021 at 04:06:56PM +0100, Geert Uytterhoeven wrote:
> Wolfram reports that his R-Car H2-based Lager board can no longer be
> rebooted in v5.11-rc1, as it crashes with an imprecise external abort.
> The issue can be reproduced on other boards (e.g. Koelsch with R-Car
> M2-W) too, if CONFIG_IP_PNP is disabled, and the Ethernet interface is
> down at reboot time:
> 
>     Unhandled fault: imprecise external abort (0x1406) at 0x00000000
>     pgd = (ptrval)
>     [00000000] *pgd=422b6835, *pte=00000000, *ppte=00000000
>     Internal error: : 1406 [#1] ARM
>     Modules linked in:
>     CPU: 0 PID: 1105 Comm: init Tainted: G        W         5.10.0-rc1-00402-ge2f016cf7751 #1048
>     Hardware name: Generic R-Car Gen2 (Flattened Device Tree)
>     PC is at sh_mdio_ctrl+0x44/0x60
>     LR is at sh_mmd_ctrl+0x20/0x24
>     ...
>     Backtrace:
>     [<c0451f30>] (sh_mdio_ctrl) from [<c0451fd4>] (sh_mmd_ctrl+0x20/0x24)
>      r7:0000001f r6:00000020 r5:00000002 r4:c22a1dc4
>     [<c0451fb4>] (sh_mmd_ctrl) from [<c044fc18>] (mdiobb_cmd+0x38/0xa8)
>     [<c044fbe0>] (mdiobb_cmd) from [<c044feb8>] (mdiobb_read+0x58/0xdc)
>      r9:c229f844 r8:c0c329dc r7:c221e000 r6:00000001 r5:c22a1dc4 r4:00000001
>     [<c044fe60>] (mdiobb_read) from [<c044c854>] (__mdiobus_read+0x74/0xe0)
>      r7:0000001f r6:00000001 r5:c221e000 r4:c221e000
>     [<c044c7e0>] (__mdiobus_read) from [<c044c9d8>] (mdiobus_read+0x40/0x54)
>      r7:0000001f r6:00000001 r5:c221e000 r4:c221e458
>     [<c044c998>] (mdiobus_read) from [<c044d678>] (phy_read+0x1c/0x20)
>      r7:ffffe000 r6:c221e470 r5:00000200 r4:c229f800
>     [<c044d65c>] (phy_read) from [<c044d94c>] (kszphy_config_intr+0x44/0x80)
>     [<c044d908>] (kszphy_config_intr) from [<c044694c>] (phy_disable_interrupts+0x44/0x50)
>      r5:c229f800 r4:c229f800
>     [<c0446908>] (phy_disable_interrupts) from [<c0449370>] (phy_shutdown+0x18/0x1c)
>      r5:c229f800 r4:c229f804
>     [<c0449358>] (phy_shutdown) from [<c040066c>] (device_shutdown+0x168/0x1f8)
>     [<c0400504>] (device_shutdown) from [<c013de44>] (kernel_restart_prepare+0x3c/0x48)
>      r9:c22d2000 r8:c0100264 r7:c0b0d034 r6:00000000 r5:4321fedc r4:00000000
>     [<c013de08>] (kernel_restart_prepare) from [<c013dee0>] (kernel_restart+0x1c/0x60)
>     [<c013dec4>] (kernel_restart) from [<c013e1d8>] (__do_sys_reboot+0x168/0x208)
>      r5:4321fedc r4:01234567
>     [<c013e070>] (__do_sys_reboot) from [<c013e2e8>] (sys_reboot+0x18/0x1c)
>      r7:00000058 r6:00000000 r5:00000000 r4:00000000
>     [<c013e2d0>] (sys_reboot) from [<c0100060>] (ret_fast_syscall+0x0/0x54)
> 
> As of commit e2f016cf775129c0 ("net: phy: add a shutdown procedure"),
> system reboot calls phy_disable_interrupts() during shutdown.  As this
> happens unconditionally, the PHY registers may be accessed while the
> device is suspended, causing undefined behavior, which may crash the
> system.
> 
> Fix this by wrapping the PHY bitbang accessors in the sh_eth driver by
> wrappers that take care of Runtime PM, to resume the device when needed.
> 
> Reported-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Suggested-by: Andrew Lunn <andrew@lunn.ch>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net v2 0/2] sh_eth: Fix reboot crash
  2021-01-18 15:06 [PATCH net v2 0/2] sh_eth: Fix reboot crash Geert Uytterhoeven
  2021-01-18 15:06 ` [PATCH net v2 1/2] mdio-bitbang: Export mdiobb_{read,write}() Geert Uytterhoeven
  2021-01-18 15:06 ` [PATCH net v2 2/2] sh_eth: Make PHY access aware of Runtime PM to fix reboot crash Geert Uytterhoeven
@ 2021-01-19 20:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 9+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-01-19 20:30 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: sergei.shtylyov, davem, kuba, andrew, hkallweit1, f.fainelli,
	linux, ioana.ciornei, wsa+renesas, netdev, linux-renesas-soc,
	linux-kernel

Hello:

This series was applied to netdev/net.git (refs/heads/master):

On Mon, 18 Jan 2021 16:06:54 +0100 you wrote:
> Hi,
> 
> This patch fixes a regression v5.11-rc1, where rebooting while a sh_eth
> device is not opened will cause a crash.
> 
> Changes compared to v1:
>   - Export mdiobb_{read,write}(),
>   - Call mdiobb_{read,write}() now they are exported,
>   - Use mii_bus.parent to avoid bb_info.dev copy,
>   - Drop RFC state.
> 
> [...]

Here is the summary with links:
  - [net,v2,1/2] mdio-bitbang: Export mdiobb_{read,write}()
    https://git.kernel.org/netdev/net/c/8eed01b5ca9c
  - [net,v2,2/2] sh_eth: Make PHY access aware of Runtime PM to fix reboot crash
    https://git.kernel.org/netdev/net/c/02cae02a7de1

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-01-19 20:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-18 15:06 [PATCH net v2 0/2] sh_eth: Fix reboot crash Geert Uytterhoeven
2021-01-18 15:06 ` [PATCH net v2 1/2] mdio-bitbang: Export mdiobb_{read,write}() Geert Uytterhoeven
2021-01-18 19:58   ` Wolfram Sang
2021-01-18 20:40   ` Florian Fainelli
2021-01-18 15:06 ` [PATCH net v2 2/2] sh_eth: Make PHY access aware of Runtime PM to fix reboot crash Geert Uytterhoeven
2021-01-18 19:58   ` Wolfram Sang
2021-01-18 20:40   ` Florian Fainelli
2021-01-18 21:21   ` Andrew Lunn
2021-01-19 20:30 ` [PATCH net v2 0/2] sh_eth: Fix " patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).