901-phy-mdio-bitbang-prevent-rescheduling-during-command.patch 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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
  5. It seems some phys have some maximum timings for accessing the MDIO line,
  6. resulting in bit errors under cpu stress. Prevent this from happening by
  7. disabling interrupts when sending commands.
  8. Signed-off-by: Jonas Gorski <jogo@openwrt.org>
  9. ---
  10. drivers/net/phy/mdio-bitbang.c | 9 +++++++++
  11. 1 file changed, 9 insertions(+)
  12. --- a/drivers/net/phy/mdio-bitbang.c
  13. +++ b/drivers/net/phy/mdio-bitbang.c
  14. @@ -17,6 +17,7 @@
  15. * kind, whether express or implied.
  16. */
  17. +#include <linux/irqflags.h>
  18. #include <linux/module.h>
  19. #include <linux/mdio-bitbang.h>
  20. #include <linux/types.h>
  21. @@ -156,7 +157,9 @@ static int mdiobb_read(struct mii_bus *b
  22. {
  23. struct mdiobb_ctrl *ctrl = bus->priv;
  24. int ret, i;
  25. + long flags;
  26. + local_irq_save(flags);
  27. if (reg & MII_ADDR_C45) {
  28. reg = mdiobb_cmd_addr(ctrl, phy, reg);
  29. mdiobb_cmd(ctrl, MDIO_C45_READ, phy, reg);
  30. @@ -169,13 +172,17 @@ static int mdiobb_read(struct mii_bus *b
  31. ret = mdiobb_get_num(ctrl, 16);
  32. mdiobb_get_bit(ctrl);
  33. + local_irq_restore(flags);
  34. +
  35. return ret;
  36. }
  37. static int mdiobb_write(struct mii_bus *bus, int phy, int reg, u16 val)
  38. {
  39. struct mdiobb_ctrl *ctrl = bus->priv;
  40. + long flags;
  41. + local_irq_save(flags);
  42. if (reg & MII_ADDR_C45) {
  43. reg = mdiobb_cmd_addr(ctrl, phy, reg);
  44. mdiobb_cmd(ctrl, MDIO_C45_WRITE, phy, reg);
  45. @@ -190,6 +197,8 @@ static int mdiobb_write(struct mii_bus *
  46. ctrl->ops->set_mdio_dir(ctrl, 0);
  47. mdiobb_get_bit(ctrl);
  48. + local_irq_restore(flags);
  49. +
  50. return 0;
  51. }