net: phy: marvell: clear wol event before setting it
Subsystems (3)
PATCH 1/1 net: phy: marvell: clear wol event before setting it
From: Jingju Hou <[email protected]>
If WOL event happened once, the LED[2] interrupt pin will not be cleared unless reading the CSISR register. So clear the WOL event before enabling it.
--- drivers/net/phy/marvell.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/net/phy/marvell.c +9 -0
@@ -115,6 +115,9 @@/* WOL Event Interrupt Enable */ #define MII_88E1318S_PHY_CSIER_WOL_EIE BIT(7) +/* Copper Specific Interrupt Status Register */ +#define MII_88E1318S_PHY_CSISR 0x13 +/* LED Timer Control Register */ #define MII_88E1318S_PHY_LED_TCR 0x12#define MII_88E1318S_PHY_LED_TCR_FORCE_INT BIT(15)
@@ -1393,6 +1396,12 @@ static int m88e1318_set_wol(struct phy_device *phydev,if (err <0 ) goto error; +/* If WOL event happened once, the LED[2] interrupt pin +* will not be cleared unless reading the CSISR register. +* So clear the WOL event first before enabling it. +*/ +phy_read (phydev,MII_88E1318S_PHY_CSISR ); +/* Enable the WOL interrupt */ err =__phy_modify (phydev,MII_88E1318S_PHY_CSIER ,0 ,MII_88E1318S_PHY_CSIER_WOL_EIE );
Signature · 1 line
2.17.0
Hi,
Quoted 26 lines
-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Jisheng Zhang
Sent: Thursday, April 19, 2018 1:33 PM
To: Andrew Lunn <[email protected]>; Florian Fainelli <[email protected]>; David S. Miller <[email protected]>
Cc: [email protected]; [email protected]; Jingju Hou <[email protected]>
Subject: [PATCH] net: phy: marvell: clear wol event before setting itFrom: Jingju Hou <[email protected]>
If WOL event happened once, the LED[2] interrupt pin will not be cleared unless reading the CSISR register. So clear the WOL event before enabling it.
Signed-off-by Jingju Hou <[email protected]>Signed-off-by Jisheng Zhang <[email protected]>--- drivers/net/phy/marvell.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/net/phy/marvell.c index renamed from drivers/net/phy/marvell.c +0
-0
c22e8e383247..b6abe1cbc84b100644
drivers/net/phy/marvell.c line 120
Quoted 6 lines
drivers/net/phy/marvell.c +3
-0@@ -115,6 +115,9 @@/* WOL Event Interrupt Enable */ #define MII_88E1318S_PHY_CSIER_WOL_EIE BIT(7) +/* Copper Specific Interrupt Status Register */ +#define MII_88E1318S_PHY_CSISR 0x13 +
There is already macro to represent this register - MII_M1011_IEVENT. Do we need this macro ?
drivers/net/phy/marvell.c static int m88e1318_set_wol(struct phy_device · line 1404
Quoted 13 lines
drivers/net/phy/marvell.c +5
-0/* LED Timer Control Register */ #define MII_88E1318S_PHY_LED_TCR 0x12#define MII_88E1318S_PHY_LED_TCR_FORCE_INT BIT(15)@@ -1393,6 +1396,12 @@ static int m88e1318_set_wol(struct phy_device *phydev, if (err < 0) goto error; +/* If WOL event happened once, the LED[2] interrupt pin +* will not be cleared unless reading the CSISR register. +* So clear the WOL event first before enabling it. +*/ +phy_read (phydev,MII_88E1318S_PHY_CSISR );
This part of the operation already taken care by ack_interrupt and did_interrupt [....]
.ack_interrupt = &marvell_ack_interrupt,
.did_interrupt = &m88e1121_did_interrupt,
[...]
If at all WOL event occurred marvell_ack_interrupt will take care of clearing the interrupt status register. Am I missing anything here ?
Quoted 5 lines
drivers/net/phy/marvell.c +0
-1/* Enable the WOL interrupt */ err =__phy_modify (phydev,MII_88E1318S_PHY_CSIER ,0 ,MII_88E1318S_PHY_CSIER_WOL_EIE ); --2.17.0
Hi,
Quoted 31 lines · On Thu, 19 Apr 2018 08:38:45 +0000 Bhadram Varka wrote:
Hi,
Quoted 29 lines
-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Jisheng Zhang
Sent: Thursday, April 19, 2018 1:33 PM
To: Andrew Lunn <[email protected]>; Florian Fainelli <[email protected]>; David S. Miller <[email protected]>
Cc: [email protected]; [email protected]; Jingju Hou <[email protected]>
Subject: [PATCH] net: phy: marvell: clear wol event before setting itFrom: Jingju Hou <[email protected]>
If WOL event happened once, the LED[2] interrupt pin will not be cleared unless reading the CSISR register. So clear the WOL event before enabling it.
Signed-off-by Jingju Hou <[email protected]>Signed-off-by Jisheng Zhang <[email protected]>--- drivers/net/phy/marvell.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/net/phy/marvell.c index renamed from drivers/net/phy/marvell.c +0
-0
c22e8e383247..b6abe1cbc84b100644drivers/net/phy/marvell.c +0
-0@@ -115,6 +115,9 @@/* WOL Event Interrupt Enable */ #define MII_88E1318S_PHY_CSIER_WOL_EIE BIT(7)
Quoted 5 lines
drivers/net/phy/marvell.c line 120
Quoted 3 lines
drivers/net/phy/marvell.c +3
-0+/* Copper Specific Interrupt Status Register */ +#define MII_88E1318S_PHY_CSISR 0x13 +There is already macro to represent this register -
MII_M1011_IEVENT. Do we need this macro ?
Good point. Will use MII_M1011_IEVENT instead in v2.
Quoted 21 lines
Quoted 5 lines
drivers/net/phy/marvell.c +0
-0/* LED Timer Control Register */ #define MII_88E1318S_PHY_LED_TCR 0x12#define MII_88E1318S_PHY_LED_TCR_FORCE_INT BIT(15)drivers/net/phy/marvell.c static int m88e1318_set_wol(struct phy_device · line 1404
Quoted 9 lines
drivers/net/phy/marvell.c +5
-0@@ -1393,6 +1396,12 @@ static int m88e1318_set_wol(struct phy_device *phydev, if (err < 0) goto error; +/* If WOL event happened once, the LED[2] interrupt pin +* will not be cleared unless reading the CSISR register. +* So clear the WOL event first before enabling it. +*/ +phy_read (phydev,MII_88E1318S_PHY_CSISR );This part of the operation already taken care by
ack_interruptanddid_interrupt[....]
.ack_interrupt =&marvell_ack_interrupt,
.did_interrupt =&m88e1121_did_interrupt,
[...]
Quoted 2 lines
If at all WOL event occurred
marvell_ack_interruptwill take care of clearing the interrupt status register. Am I missing anything here ?
If there's no valid irq for phy, the ack_interrupt/did_interrupt won't be called.
Thanks
Hi,
Quoted 74 lines
-----Original Message-----
From: Jisheng Zhang <[email protected]>
Sent: Thursday, April 19, 2018 2:24 PM
To: Bhadram Varka <[email protected]>
Cc: Andrew Lunn <[email protected]>; Florian Fainelli <[email protected]>; David S. Miller <[email protected]>; [email protected]; linux- [email protected]; Jingju Hou <[email protected]>
Subject: Re: [PATCH] net: phy: marvell: clear wol event before setting itHi,
Quoted 17 lines · On Thu, 19 Apr 2018 08:38:45 +0000 Bhadram Varka wrote:
Hi,
Quoted 15 lines
-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Jisheng Zhang
Sent: Thursday, April 19, 2018 1:33 PM
To: Andrew Lunn <[email protected]>; Florian Fainelli <[email protected]>; David S. Miller <[email protected]>
Cc: [email protected]; [email protected]; Jingju Hou <[email protected]>
Subject: [PATCH] net: phy: marvell: clear wol event before setting itFrom: Jingju Hou <[email protected]>
If WOL event happened once, the LED[2] interrupt pin will not be cleared unless reading the CSISR register. So clear the WOL event before
enabling it.
Quoted 15 lines
Quoted 15 lines
Signed-off-by Jingju Hou <[email protected]>Signed-off-by Jisheng Zhang <[email protected]>--- drivers/net/phy/marvell.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/net/phy/marvell.c +0
-0@@ -115,6 +115,9 @@/* WOL Event Interrupt Enable */ #define MII_88E1318S_PHY_CSIER_WOL_EIE BIT(7)Quoted 5 lines
drivers/net/phy/marvell.c line 120
Quoted 3 lines
drivers/net/phy/marvell.c +3
-0+/* Copper Specific Interrupt Status Register */ +#define MII_88E1318S_PHY_CSISR 0x13 +There is already macro to represent this register -
MII_M1011_IEVENT. Do weneed this macro ?
Good point. Will use
MII_M1011_IEVENTinstead in v2.Quoted 19 lines
Quoted 5 lines
drivers/net/phy/marvell.c +0
-0/* LED Timer Control Register */ #define MII_88E1318S_PHY_LED_TCR 0x12#define MII_88E1318S_PHY_LED_TCR_FORCE_INT BIT(15)drivers/net/phy/marvell.c static int m88e1318_set_wol(struct phy_device · line 1404
Quoted 9 lines
drivers/net/phy/marvell.c +5
-0@@ -1393,6 +1396,12 @@ static int m88e1318_set_wol(struct phy_device *phydev, if (err < 0) goto error; +/* If WOL event happened once, the LED[2] interrupt pin +* will not be cleared unless reading the CSISR register. +* So clear the WOL event first before enabling it. +*/ +phy_read (phydev,MII_88E1318S_PHY_CSISR );This part of the operation already taken care by
ack_interruptanddid_interrupt[....] .ack_interrupt =&marvell_ack_interrupt, .did_interrupt =&m88e1121_did_interrupt, [...]
Quoted 5 lines
Quoted 1 line
If at all WOL event occurred
marvell_ack_interruptwill take care of clearing theinterrupt status register.
Quoted 1 line
Am I missing anything here ?
If there's no valid irq for phy, the ack_interrupt/did_interrupt won't be called.
Which means that the PHY is not having Interrupt pin ?
Generally through PHY interrupt will wake up the system right. If there is no interrupt pin then how the system will wake up the from suspend for the magic packet.?
Thanks!
Quoted 76 lines · On Thu, 19 Apr 2018 09:00:40 +0000 Bhadram Varka wrote:
Hi,
Quoted 74 lines
-----Original Message-----
From: Jisheng Zhang <[email protected]>
Sent: Thursday, April 19, 2018 2:24 PM
To: Bhadram Varka <[email protected]>
Cc: Andrew Lunn <[email protected]>; Florian Fainelli <[email protected]>; David S. Miller <[email protected]>; [email protected]; linux- [email protected]; Jingju Hou <[email protected]>
Subject: Re: [PATCH] net: phy: marvell: clear wol event before setting itHi,
Quoted 17 lines · On Thu, 19 Apr 2018 08:38:45 +0000 Bhadram Varka wrote:
Hi,
Quoted 15 lines
-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Jisheng Zhang
Sent: Thursday, April 19, 2018 1:33 PM
To: Andrew Lunn <[email protected]>; Florian Fainelli <[email protected]>; David S. Miller <[email protected]>
Cc: [email protected]; [email protected]; Jingju Hou <[email protected]>
Subject: [PATCH] net: phy: marvell: clear wol event before setting itFrom: Jingju Hou <[email protected]>
If WOL event happened once, the LED[2] interrupt pin will not be cleared unless reading the CSISR register. So clear the WOL event before
enabling it.
Quoted 15 lines
Quoted 15 lines
Signed-off-by Jingju Hou <[email protected]>Signed-off-by Jisheng Zhang <[email protected]>--- drivers/net/phy/marvell.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/net/phy/marvell.c +0
-0@@ -115,6 +115,9 @@/* WOL Event Interrupt Enable */ #define MII_88E1318S_PHY_CSIER_WOL_EIE BIT(7)Quoted 5 lines
drivers/net/phy/marvell.c line 120
Quoted 3 lines
drivers/net/phy/marvell.c +3
-0+/* Copper Specific Interrupt Status Register */ +#define MII_88E1318S_PHY_CSISR 0x13 +There is already macro to represent this register -
MII_M1011_IEVENT. Do weneed this macro ?
Good point. Will use
MII_M1011_IEVENTinstead in v2.Quoted 19 lines
Quoted 5 lines
drivers/net/phy/marvell.c +0
-0/* LED Timer Control Register */ #define MII_88E1318S_PHY_LED_TCR 0x12#define MII_88E1318S_PHY_LED_TCR_FORCE_INT BIT(15)drivers/net/phy/marvell.c static int m88e1318_set_wol(struct phy_device · line 1404
Quoted 9 lines
drivers/net/phy/marvell.c +5
-0@@ -1393,6 +1396,12 @@ static int m88e1318_set_wol(struct phy_device *phydev, if (err < 0) goto error; +/* If WOL event happened once, the LED[2] interrupt pin +* will not be cleared unless reading the CSISR register. +* So clear the WOL event first before enabling it. +*/ +phy_read (phydev,MII_88E1318S_PHY_CSISR );This part of the operation already taken care by
ack_interruptanddid_interrupt[....] .ack_interrupt =&marvell_ack_interrupt, .did_interrupt =&m88e1121_did_interrupt, [...]
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
If at all WOL event occurred
marvell_ack_interruptwill take care of clearing theinterrupt status register.
Quoted 1 line
Am I missing anything here ?
If there's no valid irq for phy, the ack_interrupt/did_interrupt won't be called.
Which means that the PHY is not having Interrupt pin ?
No valid irq doesn't mean "not having interrupt pin". they are different
Quoted 3 lines
Generally through PHY interrupt will wake up the system right. If there is no interrupt pin then how the system will wake up the from suspend for the magic packet.?
IIRC, the phy irq isn't necessary for WOL. The phy interrupt pin isn't necessarily taken as "interrupt"
PS: Did you use outlook as your email client? it's not suitable for kernel mail list.
Thanks
HiJisheng,
Quoted 75 lines · Jisheng Zhang
Quoted 73 lines · On Thu, 19 Apr 2018 09:00:40 +0000 Bhadram Varka wrote:
Hi,
Quoted 71 lines
-----Original Message-----
From: Jisheng Zhang <[email protected]>
Sent: Thursday, April 19, 2018 2:24 PM
To: Bhadram Varka <[email protected]>
Cc: Andrew Lunn <[email protected]>; Florian Fainelli <[email protected]>; David S. Miller <[email protected]>; [email protected]; linux- [email protected]; Jingju Hou <[email protected]>
Subject: Re: [PATCH] net: phy: marvell: clear wol event before setting itHi,
Quoted 17 lines · On Thu, 19 Apr 2018 08:38:45 +0000 Bhadram Varka wrote:
Hi,
Quoted 15 lines
-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Jisheng Zhang
Sent: Thursday, April 19, 2018 1:33 PM
To: Andrew Lunn <[email protected]>; Florian Fainelli <[email protected]>; David S. Miller <[email protected]>
Cc: [email protected]; [email protected]; Jingju Hou <[email protected]>
Subject: [PATCH] net: phy: marvell: clear wol event before setting itFrom: Jingju Hou <[email protected]>
If WOL event happened once, the LED[2] interrupt pin will not be cleared unless reading the CSISR register. So clear the WOL event before
enabling it.
Quoted 14 lines
Quoted 14 lines
Signed-off-by Jingju Hou <[email protected]>Signed-off-by Jisheng Zhang <[email protected]>--- drivers/net/phy/marvell.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/net/phy/marvell.c +0
-0@@ -115,6 +115,9 @@/* WOL Event Interrupt Enable */ #define MII_88E1318S_PHY_CSIER_WOL_EIE BIT(7)Quoted 4 lines
drivers/net/phy/marvell.c line 120
Quoted 3 lines
drivers/net/phy/marvell.c +3
-0+/* Copper Specific Interrupt Status Register */ +#define MII_88E1318S_PHY_CSISR 0x13 +There is already macro to represent this register -
MII_M1011_IEVENT. Do weneed this macro ?
Good point. Will use
MII_M1011_IEVENTinstead in v2.Quoted 18 lines
Quoted 5 lines
drivers/net/phy/marvell.c +0
-0/* LED Timer Control Register */ #define MII_88E1318S_PHY_LED_TCR 0x12#define MII_88E1318S_PHY_LED_TCR_FORCE_INT BIT(15)drivers/net/phy/marvell.c static int m88e1318_set_wol(struct phy_device · line 1404
Quoted 9 lines
drivers/net/phy/marvell.c +5
-0@@ -1393,6 +1396,12 @@ static int m88e1318_set_wol(struct phy_device *phydev, if (err < 0) goto error; +/* If WOL event happened once, the LED[2] interrupt pin +* will not be cleared unless reading the CSISR register. +* So clear the WOL event first before enabling it. +*/ +phy_read (phydev,MII_88E1318S_PHY_CSISR );This part of the operation already taken care by
ack_interruptanddid_interrupt[....] .ack_interrupt =&marvell_ack_interrupt, .did_interrupt =&m88e1121_did_interrupt, [...]
Quoted 6 lines
Quoted 5 lines
Quoted 4 lines
Quoted 1 line
If at all WOL event occurred
marvell_ack_interruptwill take care of clearing theinterrupt status register.
Quoted 1 line
Am I missing anything here ?
If there's no valid irq for phy, the ack_interrupt/did_interrupt won't be called.
Which means that the PHY is not having Interrupt pin ?
No valid irq doesn't mean "not having interrupt pin". they are different
Okay. If there is WoL event through magic packet then its valid irq for the PHY right. Then phy_interrupt will be called from there ack/did_interrupts will be called. So it clears WoL interrupt.
Quoted 5 lines
Quoted 3 lines
Generally through PHY interrupt will wake up the system right. If there is no interrupt pin then how the system will wake up the from suspend for the magic packet.?
IIRC, the phy irq isn't necessary for WOL. The phy interrupt pin isn't necessarily taken as "interrupt"
Please correct me if I am wrong. In this case how the system will wake up from the SC7.There has to be wake capable irq/gpio pin to do this operation.
Thanks,
Bhadram.
Andrew Lunn
maintainerQuoted 5 lines
Quoted 2 lines
IIRC, the phy irq isn't necessary for WOL. The phy interrupt pin isn't necessarily taken as "interrupt"
Please correct me if I am wrong. In this case how the system will wake up from the SC7.There has to be wake capable irq/gpio pin to do this operation.
Hi Bhadram
I've seem implementations where the line from the PHY is connected to the power supply. It simply turns the power on. No interrupt needed.
Andrew
Andrew Lunn
maintainerQuoted 27 lines · Jisheng Zhang
From: Jingju Hou <[email protected]>
If WOL event happened once, the LED[2] interrupt pin will not be cleared unless reading the CSISR register. So clear the WOL event before enabling it.
Signed-off-by Jingju Hou <[email protected]>Signed-off-by Jisheng Zhang <[email protected]>--- drivers/net/phy/marvell.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/net/phy/marvell.c +3
-0@@ -115,6 +115,9 @@/* WOL Event Interrupt Enable */ #define MII_88E1318S_PHY_CSIER_WOL_EIE BIT(7) +/* Copper Specific Interrupt Status Register */ +#define MII_88E1318S_PHY_CSISR 0x13 +/* LED Timer Control Register */ #define MII_88E1318S_PHY_LED_TCR 0x12#define MII_88E1318S_PHY_LED_TCR_FORCE_INT BIT(15)
drivers/net/phy/marvell.c static int m88e1318_set_wol(struct phy_device *phydev, · line 1404
Quoted 9 lines
drivers/net/phy/marvell.c +6
-0@@ -1393,6 +1396,12 @@ static int m88e1318_set_wol(struct phy_device *phydev,if (err <0 ) goto error; +/* If WOL event happened once, the LED[2] interrupt pin +* will not be cleared unless reading the CSISR register. +* So clear the WOL event first before enabling it. +*/ +phy_read (phydev,MII_88E1318S_PHY_CSISR ); +
Hi Jisheng
The problem with this is, you could be clearing a real interrupt, link down/up etc. If interrupts are in use, i think the normal interrupt handling will clear the WOL interrupt? So can you make this read conditional on !phy_interrupt_is_valid()?
Andrew
Hi,
Quoted 39 lines · Andrew Lunn
Quoted 27 lines · Jisheng Zhang
From: Jingju Hou <[email protected]>
If WOL event happened once, the LED[2] interrupt pin will not be cleared unless reading the CSISR register. So clear the WOL event before enabling it.
Signed-off-by Jingju Hou <[email protected]>Signed-off-by Jisheng Zhang <[email protected]>--- drivers/net/phy/marvell.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/net/phy/marvell.c +3
-0@@ -115,6 +115,9 @@/* WOL Event Interrupt Enable */ #define MII_88E1318S_PHY_CSIER_WOL_EIE BIT(7) +/* Copper Specific Interrupt Status Register */ +#define MII_88E1318S_PHY_CSISR 0x13 +/* LED Timer Control Register */ #define MII_88E1318S_PHY_LED_TCR 0x12#define MII_88E1318S_PHY_LED_TCR_FORCE_INT BIT(15)drivers/net/phy/marvell.c static int m88e1318_set_wol(struct phy_device *phydev, · line 1404
Quoted 9 lines
drivers/net/phy/marvell.c +6
-0@@ -1393,6 +1396,12 @@ static int m88e1318_set_wol(struct phy_device *phydev,if (err <0 ) goto error; +/* If WOL event happened once, the LED[2] interrupt pin +* will not be cleared unless reading the CSISR register. +* So clear the WOL event first before enabling it. +*/ +phy_read (phydev,MII_88E1318S_PHY_CSISR ); +Hi Jisheng
Quoted 4 lines
The problem with this is, you could be clearing a real interrupt, link down/up etc. If interrupts are in use, i think the normal interrupt handling will clear the WOL interrupt? So can you make this read conditional on !phy_interrupt_is_valid()?
So this will clear WoL interrupt bit from Copper Interrupt status register.
How about clearing WoL status (Page 17, register 17) for every WOL event ?
Observed that once WoL event occurred for magic packet then for next magic packet WoL event is not asserted. Need to explicitly clear WOL status so that WOL interrupt will be generated by the HW.
Thanks,
Bhadram.
Thanks,
Bhadram
Hi,
Quoted 42 lines · On Thu, 26 Apr 2018 11:10:21 +0530 Bhadram Varka wrote:
Hi,
Quoted 39 lines · Andrew Lunn
Quoted 27 lines · Jisheng Zhang
From: Jingju Hou <[email protected]>
If WOL event happened once, the LED[2] interrupt pin will not be cleared unless reading the CSISR register. So clear the WOL event before enabling it.
Signed-off-by Jingju Hou <[email protected]>Signed-off-by Jisheng Zhang <[email protected]>--- drivers/net/phy/marvell.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/net/phy/marvell.c +3
-0@@ -115,6 +115,9 @@/* WOL Event Interrupt Enable */ #define MII_88E1318S_PHY_CSIER_WOL_EIE BIT(7) +/* Copper Specific Interrupt Status Register */ +#define MII_88E1318S_PHY_CSISR 0x13 +/* LED Timer Control Register */ #define MII_88E1318S_PHY_LED_TCR 0x12#define MII_88E1318S_PHY_LED_TCR_FORCE_INT BIT(15)drivers/net/phy/marvell.c static int m88e1318_set_wol(struct phy_device *phydev, · line 1404
Quoted 9 lines
drivers/net/phy/marvell.c +6
-0@@ -1393,6 +1396,12 @@ static int m88e1318_set_wol(struct phy_device *phydev,if (err <0 ) goto error; +/* If WOL event happened once, the LED[2] interrupt pin +* will not be cleared unless reading the CSISR register. +* So clear the WOL event first before enabling it. +*/ +phy_read (phydev,MII_88E1318S_PHY_CSISR ); +Hi Jisheng
Quoted 8 lines
Quoted 4 lines
The problem with this is, you could be clearing a real interrupt, link down/up etc. If interrupts are in use, i think the normal interrupt handling will clear the WOL interrupt? So can you make this read conditional on !phy_interrupt_is_valid()?
So this will clear WoL interrupt bit from Copper Interrupt status register.
How about clearing WoL status (Page 17, register 17) for every WOL event ?
This is already properly done by setting MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS in m88e1318_set_wol()
Thanks
Hi,
Quoted 50 lines · Jisheng Zhang
Hi,
Quoted 46 lines · On Thu, 26 Apr 2018 11:10:21 +0530 Bhadram Varka wrote:
Hi,
Quoted 43 lines · Andrew Lunn
Quoted 27 lines · Jisheng Zhang
From: Jingju Hou <[email protected]>
If WOL event happened once, the LED[2] interrupt pin will not be cleared unless reading the CSISR register. So clear the WOL event before enabling it.
Signed-off-by Jingju Hou <[email protected]>Signed-off-by Jisheng Zhang <[email protected]>--- drivers/net/phy/marvell.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/net/phy/marvell.c +3
-0@@ -115,6 +115,9 @@/* WOL Event Interrupt Enable */ #define MII_88E1318S_PHY_CSIER_WOL_EIE BIT(7) +/* Copper Specific Interrupt Status Register */ +#define MII_88E1318S_PHY_CSISR 0x13 +/* LED Timer Control Register */ #define MII_88E1318S_PHY_LED_TCR 0x12#define MII_88E1318S_PHY_LED_TCR_FORCE_INT BIT(15)drivers/net/phy/marvell.c static int m88e1318_set_wol(struct phy_device *phydev, · line 1404
Quoted 9 lines
drivers/net/phy/marvell.c +6
-0@@ -1393,6 +1396,12 @@ static int m88e1318_set_wol(struct phy_device *phydev,if (err <0 ) goto error; +/* If WOL event happened once, the LED[2] interrupt pin +* will not be cleared unless reading the CSISR register. +* So clear the WOL event first before enabling it. +*/ +phy_read (phydev,MII_88E1318S_PHY_CSISR ); +Hi Jisheng
The problem with this is, you could be clearing a real interrupt, link down/up etc. If interrupts are in use, i think the normal interrupt handling will clear the WOL interrupt? So can you make this read conditional on !phy_interrupt_is_valid()?
Quoted 6 lines
Quoted 4 lines
So this will clear WoL interrupt bit from Copper Interrupt status register.
How about clearing WoL status (Page 17, register 17) for every WOL event ?
This is already properly done by setting
MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUSinm88e1318_set_wol()
This part of the code executes only when we enable WOL through ethtool (ethtool -s eth0 wol g)
Lets say once WOL enabled through magic packet - HW generates WOL interrupt once magic packet received. The problem that I see here is that for the next immediate magic packet I don't see WOL interrupt generated by the HW. I need to explicitly clear WOL status for HW to generate WOL interrupt.
Hi,
Quoted 55 lines · Bhadram Varka
Hi,
Quoted 53 lines · Jisheng Zhang
Hi,
Quoted 49 lines · On Thu, 26 Apr 2018 11:10:21 +0530 Bhadram Varka wrote:
Hi,
Quoted 38 lines · Andrew Lunn
Quoted 29 lines · Jisheng Zhang
From: Jingju Hou <[email protected]>
If WOL event happened once, the LED[2] interrupt pin will not be cleared unless reading the CSISR register. So clear the WOL event before enabling it.
Signed-off-by Jingju Hou <[email protected]>Signed-off-by Jisheng Zhang <[email protected]>---
drivers/net/phy/marvell.c| 9 +++++++++1 file changed, 9 insertions(+)drivers/net/phy/marvell.c +0
-0@@ -115,6 +115,9 @@ /* WOL Event Interrupt Enable */ #define MII_88E1318S_PHY_CSIER_WOL_EIE BIT(7)+/* Copper Specific Interrupt Status Register */
drivers/net/phy/marvell.c +2
-0+#define MII_88E1318S_PHY_CSISR 0x13 +/* LED Timer Control Register */
#define MII_88E1318S_PHY_LED_TCR0x12#defineMII_88E1318S_PHY_LED_TCR_FORCE_INTBIT(15)drivers/net/phy/marvell.c +0
-0@@ -1393,6 +1396,12 @@ static int m88e1318_set_wol(struct phy_device *phydev, if (err < 0) goto error;Quoted 6 lines
+ /* If WOL event happened once, the LED[2] interrupt pin + * will not be cleared unless reading the CSISR register. + * So clear the WOL event first before enabling it. + */
+phy_read(phydev, MII_88E1318S_PHY_CSISR);
+Hi Jisheng
Quoted 4 lines
The problem with this is, you could be clearing a real interrupt, link down/up etc. If interrupts are in use, i think the normal interrupt handling will clear the WOL interrupt? So can you make this read conditional on !phy_interrupt_is_valid()?
So this will clear WoL interrupt bit from Copper Interrupt status register.
How about clearing WoL status (Page 17, register 17) for every WOL event ?
Quoted 7 lines
Quoted 2 lines
This is already properly done by setting
MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUSinm88e1318_set_wol()This part of the code executes only when we enable WOL through ethtool (ethtool -s eth0 wol g)
Lets say once WOL enabled through magic packet - HW generates WOL interrupt once magic packet received. The problem that I see here is that for the next immediate magic packet I don't see WOL interrupt generated by the HW. I need to explicitly clear WOL status for HW to generate WOL interrupt.
With the below patch I see WOL event interrupt for every magic packet that HW receives...
drivers/net/phy/marvell.c +0 -0
@@ -55,6 +55,7 @@
#define MII_M1011_IEVENT 0x13
#define MII_M1011_IEVENT_CLEAR 0x0000
+#define MII_M1011_IEVENT_WOL_EVENT BIT(7)
#define MII_M1011_IMASK 0x12
- #define MII_M1011_IMASK_INIT 0x6400
+ #define MII_M1011_IMASK_INIT 0x6480
@@ -195,13 +196,40 @@ struct marvell_priv {
bool copper;
};
+static int marvell_clear_wol_status(struct phy_device *phydev) +{
+ int err, temp, oldpage;
+
+ oldpage = phy_read(phydev, MII_MARVELL_PHY_PAGE); + if (oldpage < 0)
+ return oldpage;
+
+ err = phy_write(phydev, MII_MARVELL_PHY_PAGE,
+ MII_88E1318S_PHY_WOL_PAGE);
+ if (err < 0)
+ return err;
+
+ /*
+ * Clear WOL status so that for next WOL event + * interrupt will be generated by HW
+ */
+ temp = phy_read(phydev, MII_88E1318S_PHY_WOL_CTRL); + temp |= MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS; + err = phy_write(phydev, MII_88E1318S_PHY_WOL_CTRL, temp); + if (err < 0)
+ return err;
+
+
+ phy_write(phydev, MII_MARVELL_PHY_PAGE, oldpage); +
+ return 0;
+}
+
static int marvell_ack_interrupt(struct phy_device *phydev) {
int err;
/* Clear the interrupts by reading the reg */ err = phy_read(phydev, MII_M1011_IEVENT); -
if (err < 0)
return err;
@@ -1454,12 +1482,18 @@ static int marvell_aneg_done(struct phy_device *phydev)
static int m88e1121_did_interrupt(struct phy_device *phydev) {
- int imask;
+ int imask, err;
imask = phy_read(phydev, MII_M1011_IEVENT);
- if (imask & MII_M1011_IMASK_INIT)
+ if (imask & MII_M1011_IMASK_INIT) {
+ if (imask & MII_M1011_IEVENT_WOL_EVENT) { + err = marvell_clear_wol_status(phydev); + if (err < 0)
+ return 0;
+ }
return 1;
+ }
return 0;
}
Quoted 79 lines · On Thu, 26 Apr 2018 12:39:59 +0530 Bhadram Varka wrote:
Quoted 39 lines
Quoted 33 lines
Quoted 33 lines
Quoted 26 lines
Quoted 18 lines
drivers/net/phy/marvell.c +0
-0@@ -115,6 +115,9 @@ /* WOL Event Interrupt Enable */ #define MII_88E1318S_PHY_CSIER_WOL_EIE BIT(7)+/* Copper Specific Interrupt Status Register */
drivers/net/phy/marvell.c +2
-0+#define MII_88E1318S_PHY_CSISR 0x13 +/* LED Timer Control Register */
#define MII_88E1318S_PHY_LED_TCR0x12#defineMII_88E1318S_PHY_LED_TCR_FORCE_INTBIT(15)drivers/net/phy/marvell.c +0
-0@@ -1393,6 +1396,12 @@ static int m88e1318_set_wol(struct phy_device *phydev, if (err < 0) goto error;Quoted 6 lines
+ /* If WOL event happened once, the LED[2] interrupt pin + * will not be cleared unless reading the CSISR register. + * So clear the WOL event first before enabling it. + */
+phy_read(phydev, MII_88E1318S_PHY_CSISR);
+Hi Jisheng
Quoted 4 lines
The problem with this is, you could be clearing a real interrupt, link down/up etc. If interrupts are in use, i think the normal interrupt handling will clear the WOL interrupt? So can you make this read conditional on !phy_interrupt_is_valid()?
So this will clear WoL interrupt bit from Copper Interrupt status register.
Quoted 6 lines
Quoted 3 lines
How about clearing WoL status (Page 17, register 17) for every WOL event ?
This is already properly done by setting
MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS
inm88e1318_set_wol()Quoted 8 lines
This part of the code executes only when we enable WOL through ethtool (ethtool -s eth0 wol g)
Lets say once WOL enabled through magic packet - HW generates WOL interrupt once magic packet received.
The problem that I see here is that for the next immediate magic packet I don't see WOL interrupt generated by the HW.
I need to explicitly clear WOL status for HW to generate WOL interrupt.With the below patch I see WOL event interrupt for every magic packet that HW receives...
drivers/net/phy/marvell.c +12
-1@@ -55,6 +55,7 @@ #define MII_M1011_IEVENT 0x13 #define MII_M1011_IEVENT_CLEAR 0x0000 +#define MII_M1011_IEVENT_WOL_EVENT BIT(7) #define MII_M1011_IMASK 0x12 -#define MII_M1011_IMASK_INIT 0x6400 +#define MII_M1011_IMASK_INIT 0x6480@@ -195,13 +196,40 @@ struct marvell_priv { bool copper; }; +static int marvell_clear_wol_status (struct phy_device *phydev) +{ + int err, temp, oldpage; + + oldpage = phy_read(phydev, MII_MARVELL_PHY_PAGE); + if (oldpage < 0) + return oldpage; + + err = phy_write(phydev, MII_MARVELL_PHY_PAGE, + MII_88E1318S_PHY_WOL_PAGE);
drivers/net/phy/marvell.c struct marvell_priv { · line 218
Quoted 10 lines
drivers/net/phy/marvell.c +10
-0+ if (err < 0) + return err; + + /* + * Clear WOL status so that for next WOL event + * interrupt will be generated by HW + */ + temp = phy_read(phydev, MII_88E1318S_PHY_WOL_CTRL); + temp |= MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS; + err = phy_write(phydev, MII_88E1318S_PHY_WOL_CTRL, temp);
is it better to reuse __phy_write()?
Quoted 41 lines
drivers/net/phy/marvell.c +17
-3+ if (err < 0) + return err; + + + phy_write(phydev, MII_MARVELL_PHY_PAGE, oldpage); + + return 0; +} + static int marvell_ack_interrupt(struct phy_device *phydev) { int err; /* Clear the interrupts by reading the reg */ err = phy_read(phydev, MII_M1011_IEVENT); - if (err < 0) return err;@@ -1454,12 +1482,18 @@ static int marvell_aneg_done(struct phy_device *phydev) static int m88e1121_did_interrupt(struct phy_device *phydev) { - int imask; + int imask, err; imask = phy_read(phydev, MII_M1011_IEVENT); - if (imask & MII_M1011_IMASK_INIT) + if (imask & MII_M1011_IMASK_INIT) { + if (imask & MII_M1011_IEVENT_WOL_EVENT) { + err = marvell_clear_wol_status(phydev); + if (err < 0) + return 0; + } return 1; + } return 0;}
Andrew Lunn
maintainerQuoted 32 lines
Quoted 32 lines
drivers/net/phy/marvell.c +16
-1@@ -55,6 +55,7 @@ #define MII_M1011_IEVENT 0x13 #define MII_M1011_IEVENT_CLEAR 0x0000 +#define MII_M1011_IEVENT_WOL_EVENT BIT(7) #define MII_M1011_IMASK 0x12 -#define MII_M1011_IMASK_INIT 0x6400 +#define MII_M1011_IMASK_INIT 0x6480@@ -195,13 +196,40 @@ struct marvell_priv { bool copper; }; +static int marvell_clear_wol_status (struct phy_device *phydev) +{ + int err, temp, oldpage; + + oldpage = phy_read(phydev, MII_MARVELL_PHY_PAGE); + if (oldpage < 0) + return oldpage; + + err = phy_write(phydev, MII_MARVELL_PHY_PAGE, + MII_88E1318S_PHY_WOL_PAGE); + if (err < 0) + return err; + + /*
Quoted 8 lines
drivers/net/phy/marvell.c struct marvell_priv { · line 218
Quoted 6 lines
drivers/net/phy/marvell.c +6
-0+* Clear WOL status so that for next WOL event +* interrupt will be generated by HW +*/ + temp = phy_read(phydev, MII_88E1318S_PHY_WOL_CTRL); + temp |= MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS; + err = phy_write(phydev, MII_88E1318S_PHY_WOL_CTRL, temp);is it better to reuse
__phy_write()?
phy_modify_paged() would be the best function to use.
Andrew
Quoted 10 lines · On Thu, 26 Apr 2018 11:56:33 +0530 Bhadram Varka wrote:
Hi,
Quoted 8 lines · Jisheng Zhang
Hi,
Quoted 4 lines · On Thu, 26 Apr 2018 11:10:21 +0530 Bhadram Varka wrote:
Hi,
Quoted 1 line · Andrew Lunn
On Thu, Apr 19, 2018 at 04:02:32PM +0800, Jisheng Zhang wrote:
<snip>
Quoted 21 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
drivers/net/phy/marvell.c static int m88e1318_set_wol(struct phy_device *phydev, · line 1404
Quoted 9 lines
if (err < 0) goto error;drivers/net/phy/marvell.c +6
-0+/* If WOL event happened once, the LED[2] interrupt pin +* will not be cleared unless reading the CSISR register. +* So clear the WOL event first before enabling it. +*/ +phy_read (phydev,MII_88E1318S_PHY_CSISR ); +Hi Jisheng
The problem with this is, you could be clearing a real interrupt, link down/up etc. If interrupts are in use, i think the normal interrupt handling will clear the WOL interrupt? So can you make this read conditional on !phy_interrupt_is_valid()?
Quoted 6 lines
Quoted 4 lines
So this will clear WoL interrupt bit from Copper Interrupt status register.
How about clearing WoL status (Page 17, register 17) for every WOL event ?
This is already properly done by setting
MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUSinm88e1318_set_wol()
Quoted 7 lines
This part of the code executes only when we enable WOL through ethtool (ethtool -s eth0 wol g)
Lets say once WOL enabled through magic packet - HW generates WOL interrupt once magic packet received.
The problem that I see here is that for the next immediate magic packet I don't see WOL interrupt generated by the HW.
hmm, so you want a "stick" WOL feature, I dunno whether Linux kernel requires WOL should be "stick".
Andrew Lunn
maintainerQuoted 2 lines
hmm, so you want a "stick" WOL feature, I dunno whether Linux kernel requires WOL should be "stick".
I see two different cases:
Suspend/resume: The WoL state in the kernel is probably kept across such a cycle. If so, you would expect another suspend/resume to also work, without needs to reconfigure it.
Boot from powered off: If the interrupt just enables the power supply, it is possible to wake up after a shutdown. There is no state kept, so WoL will be disabled in the kernel. So WoL should also be disabled in the hardware.
Andrew
Hi Andrew/Jisheng,
Quoted 7 lines · Andrew Lunn
Quoted 2 lines
hmm, so you want a "stick" WOL feature, I dunno whether Linux kernel requires WOL should be "stick".
I see two different cases:
Suspend/resume: The WoL state in the kernel is probably kept across such a cycle. If so, you would expect another suspend/resume to also work, without needs to reconfigure it.
Trying this scenario (suspend/resume) from my side. In this case WoL should be enabled in the HW. For Marvell PHY to generate WoL interrupt we need to clear WoL status. Above mentioned change required to make this happen. Please share your thoughts on this.
Quoted 7 lines
Boot from powered off: If the interrupt just enables the power supply, it is possible to wake up after a shutdown. There is no state kept, so WoL will be disabled in the kernel. So WoL should also be disabled in the hardware.
Andrew
Quoted 7 lines · On Fri, 27 Apr 2018 09:22:34 +0530 Bhadram Varka wrote:
Hi Andrew/Jisheng,
Quoted 4 lines · Andrew Lunn
Quoted 2 lines
hmm, so you want a "stick" WOL feature, I dunno whether Linux kernel requires WOL should be "stick".
I see two different cases:
Quoted 8 lines
Quoted 3 lines
Suspend/resume: The WoL state in the kernel is probably kept across such a cycle. If so, you would expect another suspend/resume to also work, without needs to reconfigure it.
Trying this scenario (suspend/resume) from my side. In this case WoL should be enabled in the HW. For Marvell PHY to generate WoL interrupt we need to clear WoL status.
Above mentioned change required to make this happen. Please share your thoughts on this.
I'm fine with that patch. Maybe you could send out a patch?
Thanks