openwrt/target/linux/ath79/patches-6.6/721-phy-mdio-bitbang-prevent-rescheduling-during-command.patch
Shiji Yang 872fe7e9f9 ath79: refresh 6.6 kernel patches
Some APIs have been changed. Porting them to the new kernel 6.6
version to fix the compile error.

Removed upstreamed:
	010-v6.4-gpio-ath79-Convert-to-immutable-irq_chip.patch[1]

Manually rebased:
	700-phy-add-ath79-usb-phys.patch
	721-phy-mdio-bitbang-prevent-rescheduling-during-command.patch. ref:[2]

[1] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-6.6.y&id=b11ce7e48121a02ceedec9f4dfcab4f2bee8f35f
[2] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-6.6.y&id=002dd3de097c778a74ae9e47e598bea6ad055af0

Signed-off-by: Shiji Yang <yangshiji66@qq.com>
2024-05-09 23:53:02 +02:00

95 lines
2.5 KiB
Diff

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>
@@ -161,22 +162,32 @@ static int mdiobb_read_common(struct mii
int mdiobb_read_c22(struct mii_bus *bus, int phy, int reg)
{
+ int ret;
+ unsigned long flags;
struct mdiobb_ctrl *ctrl = bus->priv;
+ 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;
+ unsigned long flags;
struct mdiobb_ctrl *ctrl = bus->priv;
+ local_irq_save(flags);
mdiobb_cmd_addr(ctrl, phy, devad, reg);
mdiobb_cmd(ctrl, MDIO_C45_READ, phy, devad);
- return mdiobb_read_common(bus, phy);
+ ret = mdiobb_read_common(bus, phy);
+ local_irq_restore(flags);
+ return ret;
}
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)
{
+ int ret;
+ unsigned long flags;
struct mdiobb_ctrl *ctrl = bus->priv;
+ 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;
+ unsigned long flags;
struct mdiobb_ctrl *ctrl = bus->priv;
+ local_irq_save(flags);
mdiobb_cmd_addr(ctrl, phy, devad, reg);
mdiobb_cmd(ctrl, MDIO_C45_WRITE, phy, devad);
- return mdiobb_write_common(bus, val);
+ ret = mdiobb_write_common(bus, val);
+ local_irq_restore(flags);
+ return ret;
}
EXPORT_SYMBOL(mdiobb_write_c45);