* [PATCH net-next v2] net: phy: broadcom: Register dummy IRQ handler
@ 2023-05-25 17:59 Florian Fainelli
2023-05-26 7:37 ` Simon Horman
2023-05-26 11:20 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Florian Fainelli @ 2023-05-25 17:59 UTC (permalink / raw)
To: netdev
Cc: Florian Fainelli, Doug Berger,
Broadcom internal kernel review list, Andrew Lunn,
Heiner Kallweit, Russell King, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, open list
[-- Attachment #1: Type: text/plain, Size: 3383 bytes --]
In order to have our interrupt descriptor fully setup and in particular
the action, ensure that we register a full fledged interrupt handler.
This also allow us to set the interrupt polarity and flow through the
same call.
This is specifically necessary for kernel/irq/pm.c::suspend_device_irq
to set the interrupt descriptor to the IRQD_WAKEUP_ARMED state and
enable the interrupt for wake-up since it was still in a disabled state.
Without an interrupt descriptor we would have ran into cases where the
wake-up interrupt is not capable of waking up the system, specifically
if we resumed the system ACPI S5 using the Ethernet PHY. In that case
the Ethernet PHY interrupt would be pending by the time the kernel
booted, which it would acknowledge but then we could never use it as
a wake-up source again.
Fixes: 8baddaa9d4ba ("net: phy: broadcom: Add support for Wake-on-LAN")
Suggested-by: Doug Berger <doug.berger@broadcom.com>
Debugged-by: Doug Berger <doug.berger@broadcom.com>
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
Changes in v2:
- provided more details about the mechanics of wake-up interrupts arming
- added a Debugged-by tag for Doug since he really whispered the
solution to my keyboard
drivers/net/phy/bcm-phy-lib.c | 6 ++++++
drivers/net/phy/bcm-phy-lib.h | 2 ++
drivers/net/phy/broadcom.c | 9 ++++++++-
3 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/drivers/net/phy/bcm-phy-lib.c b/drivers/net/phy/bcm-phy-lib.c
index 27c57f6ab211..5603d0a9ce96 100644
--- a/drivers/net/phy/bcm-phy-lib.c
+++ b/drivers/net/phy/bcm-phy-lib.c
@@ -1028,6 +1028,12 @@ void bcm_phy_get_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol)
}
EXPORT_SYMBOL_GPL(bcm_phy_get_wol);
+irqreturn_t bcm_phy_wol_isr(int irq, void *dev_id)
+{
+ return IRQ_HANDLED;
+}
+EXPORT_SYMBOL_GPL(bcm_phy_wol_isr);
+
MODULE_DESCRIPTION("Broadcom PHY Library");
MODULE_LICENSE("GPL v2");
MODULE_AUTHOR("Broadcom Corporation");
diff --git a/drivers/net/phy/bcm-phy-lib.h b/drivers/net/phy/bcm-phy-lib.h
index c6fed43ec913..2f30ce0cab0e 100644
--- a/drivers/net/phy/bcm-phy-lib.h
+++ b/drivers/net/phy/bcm-phy-lib.h
@@ -8,6 +8,7 @@
#include <linux/brcmphy.h>
#include <linux/phy.h>
+#include <linux/interrupt.h>
struct ethtool_wolinfo;
@@ -115,5 +116,6 @@ static inline void bcm_ptp_stop(struct bcm_ptp_private *priv)
int bcm_phy_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol);
void bcm_phy_get_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol);
+irqreturn_t bcm_phy_wol_isr(int irq, void *dev_id);
#endif /* _LINUX_BCM_PHY_LIB_H */
diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c
index 418e6bc0e998..822c8b01dc53 100644
--- a/drivers/net/phy/broadcom.c
+++ b/drivers/net/phy/broadcom.c
@@ -927,7 +927,14 @@ static int bcm54xx_phy_probe(struct phy_device *phydev)
if (!IS_ERR(wakeup_gpio)) {
priv->wake_irq = gpiod_to_irq(wakeup_gpio);
- ret = irq_set_irq_type(priv->wake_irq, IRQ_TYPE_LEVEL_LOW);
+
+ /* Dummy interrupt handler which is not enabled but is provided
+ * in order for the interrupt descriptor to be fully set-up.
+ */
+ ret = devm_request_irq(&phydev->mdio.dev, priv->wake_irq,
+ bcm_phy_wol_isr,
+ IRQF_TRIGGER_LOW | IRQF_NO_AUTOEN,
+ dev_name(&phydev->mdio.dev), phydev);
if (ret)
return ret;
}
--
2.34.1
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4221 bytes --]
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next v2] net: phy: broadcom: Register dummy IRQ handler
2023-05-25 17:59 [PATCH net-next v2] net: phy: broadcom: Register dummy IRQ handler Florian Fainelli
@ 2023-05-26 7:37 ` Simon Horman
2023-05-26 11:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2023-05-26 7:37 UTC (permalink / raw)
To: Florian Fainelli
Cc: netdev, Doug Berger, Broadcom internal kernel review list,
Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, open list
On Thu, May 25, 2023 at 10:59:15AM -0700, Florian Fainelli wrote:
> In order to have our interrupt descriptor fully setup and in particular
> the action, ensure that we register a full fledged interrupt handler.
> This also allow us to set the interrupt polarity and flow through the
> same call.
>
> This is specifically necessary for kernel/irq/pm.c::suspend_device_irq
> to set the interrupt descriptor to the IRQD_WAKEUP_ARMED state and
> enable the interrupt for wake-up since it was still in a disabled state.
>
> Without an interrupt descriptor we would have ran into cases where the
> wake-up interrupt is not capable of waking up the system, specifically
> if we resumed the system ACPI S5 using the Ethernet PHY. In that case
> the Ethernet PHY interrupt would be pending by the time the kernel
> booted, which it would acknowledge but then we could never use it as
> a wake-up source again.
>
> Fixes: 8baddaa9d4ba ("net: phy: broadcom: Add support for Wake-on-LAN")
> Suggested-by: Doug Berger <doug.berger@broadcom.com>
> Debugged-by: Doug Berger <doug.berger@broadcom.com>
> Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next v2] net: phy: broadcom: Register dummy IRQ handler
2023-05-25 17:59 [PATCH net-next v2] net: phy: broadcom: Register dummy IRQ handler Florian Fainelli
2023-05-26 7:37 ` Simon Horman
@ 2023-05-26 11:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-05-26 11:20 UTC (permalink / raw)
To: Florian Fainelli
Cc: netdev, doug.berger, bcm-kernel-feedback-list, andrew, hkallweit1,
linux, davem, edumazet, kuba, pabeni, simon.horman, linux-kernel
Hello:
This patch was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:
On Thu, 25 May 2023 10:59:15 -0700 you wrote:
> In order to have our interrupt descriptor fully setup and in particular
> the action, ensure that we register a full fledged interrupt handler.
> This also allow us to set the interrupt polarity and flow through the
> same call.
>
> This is specifically necessary for kernel/irq/pm.c::suspend_device_irq
> to set the interrupt descriptor to the IRQD_WAKEUP_ARMED state and
> enable the interrupt for wake-up since it was still in a disabled state.
>
> [...]
Here is the summary with links:
- [net-next,v2] net: phy: broadcom: Register dummy IRQ handler
https://git.kernel.org/netdev/net-next/c/4781e965e655
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-05-26 11:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-25 17:59 [PATCH net-next v2] net: phy: broadcom: Register dummy IRQ handler Florian Fainelli
2023-05-26 7:37 ` Simon Horman
2023-05-26 11:20 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).