1 From 66e584435ac0de6e0abeb6d7166fe4fe25d6bb73 Mon Sep 17 00:00:00 2001
2 From: Jonas Gorski <jogo@openwrt.org>
3 Date: Tue, 16 Jun 2015 13:15:08 +0200
4 Subject: [PATCH] phy/mdio-bitbang: prevent rescheduling during command
6 It seems some phys have some maximum timings for accessing the MDIO line,
7 resulting in bit errors under cpu stress. Prevent this from happening by
8 disabling interrupts when sending commands.
10 Signed-off-by: Jonas Gorski <jogo@openwrt.org>
12 drivers/net/phy/mdio-bitbang.c | 9 +++++++++
13 1 file changed, 9 insertions(+)
15 Index: linux-4.14.18/drivers/net/phy/mdio-bitbang.c
16 ===================================================================
17 --- linux-4.14.18.orig/drivers/net/phy/mdio-bitbang.c
18 +++ linux-4.14.18/drivers/net/phy/mdio-bitbang.c
20 * kind, whether express or implied.
23 +#include <linux/irqflags.h>
24 #include <linux/module.h>
25 #include <linux/mdio-bitbang.h>
26 #include <linux/types.h>
27 @@ -156,7 +157,9 @@ static int mdiobb_read(struct mii_bus *b
29 struct mdiobb_ctrl *ctrl = bus->priv;
31 + unsigned long flags;
33 + local_irq_save(flags);
34 if (reg & MII_ADDR_C45) {
35 reg = mdiobb_cmd_addr(ctrl, phy, reg);
36 mdiobb_cmd(ctrl, MDIO_C45_READ, phy, reg);
37 @@ -169,13 +172,17 @@ static int mdiobb_read(struct mii_bus *b
39 ret = mdiobb_get_num(ctrl, 16);
41 + local_irq_restore(flags);
46 static int mdiobb_write(struct mii_bus *bus, int phy, int reg, u16 val)
48 struct mdiobb_ctrl *ctrl = bus->priv;
49 + unsigned long flags;
51 + local_irq_save(flags);
52 if (reg & MII_ADDR_C45) {
53 reg = mdiobb_cmd_addr(ctrl, phy, reg);
54 mdiobb_cmd(ctrl, MDIO_C45_WRITE, phy, reg);
55 @@ -190,6 +197,8 @@ static int mdiobb_write(struct mii_bus *
57 ctrl->ops->set_mdio_dir(ctrl, 0);
59 + local_irq_restore(flags);