2023-05-24 11:26:37 +00:00
|
|
|
From 66e584435ac0de6e0abeb6d7166fe4fe25d6bb73 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Jonas Gorski <jogo@openwrt.org>
|
|
|
|
Date: Tue, 16 Jun 2015 13:15:08 +0200
|
|
|
|
Subject: [PATCH] phy/mdio-bitbang: prevent rescheduling during command
|
|
|
|
|
|
|
|
It seems some phys have some maximum timings for accessing the MDIO line,
|
|
|
|
resulting in bit errors under cpu stress. Prevent this from happening by
|
|
|
|
disabling interrupts when sending commands.
|
|
|
|
|
|
|
|
Signed-off-by: Jonas Gorski <jogo@openwrt.org>
|
|
|
|
---
|
|
|
|
drivers/net/mdio/mdio-bitbang.c | 9 +++++++++
|
|
|
|
1 file changed, 9 insertions(+)
|
|
|
|
|
|
|
|
--- a/drivers/net/mdio/mdio-bitbang.c
|
|
|
|
+++ b/drivers/net/mdio/mdio-bitbang.c
|
|
|
|
@@ -14,6 +14,7 @@
|
|
|
|
* Vitaly Bordug <vbordug@ru.mvista.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
+#include <linux/irqflags.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/mdio-bitbang.h>
|
|
|
|
#include <linux/module.h>
|
2024-03-16 00:39:16 +00:00
|
|
|
@@ -161,22 +162,32 @@ static int mdiobb_read_common(struct mii
|
|
|
|
|
|
|
|
int mdiobb_read_c22(struct mii_bus *bus, int phy, int reg)
|
2023-05-24 11:26:37 +00:00
|
|
|
{
|
2024-03-16 00:39:16 +00:00
|
|
|
+ int ret;
|
|
|
|
+ unsigned long flags;
|
2023-05-24 11:26:37 +00:00
|
|
|
struct mdiobb_ctrl *ctrl = bus->priv;
|
2024-03-16 00:39:16 +00:00
|
|
|
|
|
|
|
+ local_irq_save(flags);
|
|
|
|
mdiobb_cmd(ctrl, ctrl->op_c22_read, phy, reg);
|
|
|
|
|
|
|
|
- return mdiobb_read_common(bus, phy);
|
|
|
|
+ ret = mdiobb_read_common(bus, phy);
|
|
|
|
+ local_irq_restore(flags);
|
|
|
|
+ return ret;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(mdiobb_read_c22);
|
|
|
|
|
|
|
|
int mdiobb_read_c45(struct mii_bus *bus, int phy, int devad, int reg)
|
|
|
|
{
|
|
|
|
+ int ret;
|
2023-05-24 11:26:37 +00:00
|
|
|
+ unsigned long flags;
|
2024-03-16 00:39:16 +00:00
|
|
|
struct mdiobb_ctrl *ctrl = bus->priv;
|
2023-05-24 11:26:37 +00:00
|
|
|
|
|
|
|
+ local_irq_save(flags);
|
2024-03-16 00:39:16 +00:00
|
|
|
mdiobb_cmd_addr(ctrl, phy, devad, reg);
|
|
|
|
mdiobb_cmd(ctrl, MDIO_C45_READ, phy, devad);
|
2023-05-24 11:26:37 +00:00
|
|
|
|
2024-03-16 00:39:16 +00:00
|
|
|
- return mdiobb_read_common(bus, phy);
|
|
|
|
+ ret = mdiobb_read_common(bus, phy);
|
2023-05-24 11:26:37 +00:00
|
|
|
+ local_irq_restore(flags);
|
2024-03-16 00:39:16 +00:00
|
|
|
+ return ret;
|
2023-05-24 11:26:37 +00:00
|
|
|
}
|
2024-03-16 00:39:16 +00:00
|
|
|
EXPORT_SYMBOL(mdiobb_read_c45);
|
|
|
|
|
|
|
|
@@ -197,22 +208,32 @@ static int mdiobb_write_common(struct mi
|
|
|
|
|
|
|
|
int mdiobb_write_c22(struct mii_bus *bus, int phy, int reg, u16 val)
|
2023-05-24 11:26:37 +00:00
|
|
|
{
|
2024-03-16 00:39:16 +00:00
|
|
|
+ int ret;
|
|
|
|
+ unsigned long flags;
|
2023-05-24 11:26:37 +00:00
|
|
|
struct mdiobb_ctrl *ctrl = bus->priv;
|
2024-03-16 00:39:16 +00:00
|
|
|
|
|
|
|
+ local_irq_save(flags);
|
|
|
|
mdiobb_cmd(ctrl, ctrl->op_c22_write, phy, reg);
|
|
|
|
|
|
|
|
- return mdiobb_write_common(bus, val);
|
|
|
|
+ ret = mdiobb_write_common(bus, val);
|
|
|
|
+ local_irq_restore(flags);
|
|
|
|
+ return ret;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(mdiobb_write_c22);
|
|
|
|
|
|
|
|
int mdiobb_write_c45(struct mii_bus *bus, int phy, int devad, int reg, u16 val)
|
|
|
|
{
|
|
|
|
+ int ret;
|
2023-05-24 11:26:37 +00:00
|
|
|
+ unsigned long flags;
|
2024-03-16 00:39:16 +00:00
|
|
|
struct mdiobb_ctrl *ctrl = bus->priv;
|
2023-05-24 11:26:37 +00:00
|
|
|
|
|
|
|
+ local_irq_save(flags);
|
2024-03-16 00:39:16 +00:00
|
|
|
mdiobb_cmd_addr(ctrl, phy, devad, reg);
|
|
|
|
mdiobb_cmd(ctrl, MDIO_C45_WRITE, phy, devad);
|
2023-05-24 11:26:37 +00:00
|
|
|
|
2024-03-16 00:39:16 +00:00
|
|
|
- return mdiobb_write_common(bus, val);
|
|
|
|
+ ret = mdiobb_write_common(bus, val);
|
2023-05-24 11:26:37 +00:00
|
|
|
+ local_irq_restore(flags);
|
2024-03-16 00:39:16 +00:00
|
|
|
+ return ret;
|
2023-05-24 11:26:37 +00:00
|
|
|
}
|
2024-03-16 00:39:16 +00:00
|
|
|
EXPORT_SYMBOL(mdiobb_write_c45);
|
|
|
|
|