net: phy: realtek: Dummy IRQ calls for RTL8366RB [Linux 5.0]

net: phy: realtek: Dummy IRQ calls for RTL8366RB [Linux 5.0]

This Linux kernel change "net: phy: realtek: Dummy IRQ calls for RTL8366RB" is included in the Linux 5.0 release. This change is authored by Linus Walleij <linus.walleij [at] linaro.org> on Sun Feb 24 01:11:15 2019 +0100. The commit for this change in Linux stable tree is 4c8e045 (patch).

net: phy: realtek: Dummy IRQ calls for RTL8366RB

This fixes a regression introduced by
commit 0d2e778e38e0ddffab4bb2b0e9ed2ad5165c4bf7
"net: phy: replace PHY_HAS_INTERRUPT with a check for
config_intr and ack_interrupt".

This assumes that a PHY cannot trigger interrupt unless
it has .config_intr() or .ack_interrupt() implemented.
A later patch makes the code assume both need to be
implemented for interrupts to be present.

But this PHY (which is inside a DSA) will happily
fire interrupts without either callback.

Implement dummy callbacks for .config_intr() and
.ack_interrupt() in the phy header to fix this.

Tested on the RTL8366RB on D-Link DIR-685.

Fixes: 0d2e778e38e0 ("net: phy: replace PHY_HAS_INTERRUPT with a check for config_intr and ack_interrupt")
Cc: Heiner Kallweit <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
Reviewed-by: Andrew Lunn <[email protected]>
Signed-off-by: David S. Miller <[email protected]>

There are 15 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/net/phy/realtek.c | 7 +++++++
 include/linux/phy.h       | 8 ++++++++
 2 files changed, 15 insertions(+)

diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
index c6010fb..cb4a230 100644
--- a/drivers/net/phy/realtek.c
+++ b/drivers/net/phy/realtek.c
@@ -282,6 +282,13 @@ static int rtl8366rb_config_init(struct phy_device *phydev)
        .name       = "RTL8366RB Gigabit Ethernet",
        .features   = PHY_GBIT_FEATURES,
        .config_init    = &rtl8366rb_config_init,
+       /* These interrupts are handled by the irq controller
+        * embedded inside the RTL8366RB, they get unmasked when the
+        * irq is requested and ACKed by reading the status register,
+        * which is done by the irqchip code.
+        */
+       .ack_interrupt  = genphy_no_ack_interrupt,
+       .config_intr    = genphy_no_config_intr,
        .suspend    = genphy_suspend,
        .resume     = genphy_resume,
    },
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 127fcc9..333b56d 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -992,6 +992,14 @@ static inline int genphy_no_soft_reset(struct phy_device *phydev)
 {
    return 0;
 }
+static inline int genphy_no_ack_interrupt(struct phy_device *phydev)
+{
+   return 0;
+}
+static inline int genphy_no_config_intr(struct phy_device *phydev)
+{
+   return 0;
+}
 int genphy_read_mmd_unsupported(struct phy_device *phdev, int devad,
                u16 regnum);
 int genphy_write_mmd_unsupported(struct phy_device *phdev, int devnum,

Leave a Reply

Your email address will not be published. Required fields are marked *