Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1423186 > unrolled thread
| Started by | Vincent Palatin <vpalatin@chromium.org> |
|---|---|
| First post | 2016-06-15 18:10 +0200 |
| Last post | 2016-06-16 23:20 +0200 |
| Articles | 6 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH 2/3] net: stmmac: dwmac-rk: keep the PHY up for WoL Vincent Palatin <vpalatin@chromium.org> - 2016-06-15 18:10 +0200
[PATCH v2 0/3] net: stmmac: dwmac-rk: fixes for Wake-on-Lan on RK3288 Vincent Palatin <vpalatin@chromium.org> - 2016-06-15 20:40 +0200
[PATCH v2 2/3] net: stmmac: dwmac-rk: keep the PHY up for WoL Vincent Palatin <vpalatin@chromium.org> - 2016-06-15 20:40 +0200
[PATCH v2 1/3] net: stmmac: allow to split suspend/resume from init/exit callbacks Vincent Palatin <vpalatin@chromium.org> - 2016-06-15 20:40 +0200
[PATCH v2 3/3] ARM: dts: rockchip: add interrupt for Wake-on-Lan on RK3288 Vincent Palatin <vpalatin@chromium.org> - 2016-06-15 20:40 +0200
Re: [PATCH v2 0/3] net: stmmac: dwmac-rk: fixes for Wake-on-Lan on RK3288 David Miller <davem@davemloft.net> - 2016-06-16 23:20 +0200
| From | Vincent Palatin <vpalatin@chromium.org> |
|---|---|
| Date | 2016-06-15 18:10 +0200 |
| Subject | Re: [PATCH 2/3] net: stmmac: dwmac-rk: keep the PHY up for WoL |
| Message-ID | <rKly9-4Mc-3@gated-at.bofh.it> |
On Fri, Jun 10, 2016 at 6:57 PM, Heiko Stuebner <heiko@sntech.de> wrote:
> Am Freitag, 10. Juni 2016, 18:00:38 schrieb Vincent Palatin:
>> When suspending the machine, do not shutdown the external PHY by cutting
>> its regulator in the mac platform driver suspend code if Wake-on-Lan is
>> enabled, else it cannot wake us up.
>> In order to do this, split the suspend/resume callbacks from the
>> init/exit callbacks, so we can condition the power-down on the lack of
>> need to wake-up from the LAN but do it unconditionally when unloading the
>> module.
>>
>> Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
>> ---
>> drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 49
>> +++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 5
>> deletions(-)
>>
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
>> b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c index 0cd3ecf..fa05771
>> 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
>> @@ -46,6 +46,7 @@ struct rk_priv_data {
>> struct platform_device *pdev;
>> int phy_iface;
>> struct regulator *regulator;
>> + bool powered_down;
>> const struct rk_gmac_ops *ops;
>>
>> bool clk_enabled;
>> @@ -529,9 +530,8 @@ static struct rk_priv_data *rk_gmac_setup(struct
>> platform_device *pdev, return bsp_priv;
>> }
>>
>> -static int rk_gmac_init(struct platform_device *pdev, void *priv)
>> +static int rk_gmac_powerup(struct rk_priv_data *bsp_priv)
>> {
>> - struct rk_priv_data *bsp_priv = priv;
>> int ret;
>>
>> ret = phy_power_on(bsp_priv, true);
>> @@ -542,15 +542,52 @@ static int rk_gmac_init(struct platform_device
>> *pdev, void *priv) if (ret)
>> return ret;
>>
>> + bsp_priv->powered_down = true;
>> +
>> return 0;
>> }
>>
>> -static void rk_gmac_exit(struct platform_device *pdev, void *priv)
>> +static void rk_gmac_powerdown(struct rk_priv_data *gmac)
>> {
>> - struct rk_priv_data *gmac = priv;
>> -
>> phy_power_on(gmac, false);
>> gmac_clk_enable(gmac, false);
>> + gmac->powered_down = true;
>
> naming it gmac->suspended and doing all accesses in the suspend/resume
> callback might provide a nicer way? Now the check is in resume while the
> powerdown callback is setting it.
>
>> +}
>> +
>> +static int rk_gmac_init(struct platform_device *pdev, void *priv)
>> +{
>> + struct rk_priv_data *bsp_priv = priv;
>> +
>> + return rk_gmac_powerup(bsp_priv);
>> +}
>> +
>> +static void rk_gmac_exit(struct platform_device *pdev, void *priv)
>> +{
>> + struct rk_priv_data *bsp_priv = priv;
>> +
>> + rk_gmac_powerdown(bsp_priv);
>> +}
>> +
>> +static void rk_gmac_suspend(struct platform_device *pdev, void *priv)
>> +{
>> + struct rk_priv_data *bsp_priv = priv;
>> +
>> + /* Keep the PHY up if we use Wake-on-Lan. */
>> + if (device_may_wakeup(&pdev->dev))
>> + return;
>> +
>> + rk_gmac_powerdown(bsp_priv);
>
> aka do
> bsp_priv->suspended = true;
> here
>
>> +}
>> +
>> +static void rk_gmac_resume(struct platform_device *pdev, void *priv)
>> +{
>> + struct rk_priv_data *bsp_priv = priv;
>> +
>> + /* The PHY was up for Wake-on-Lan. */
>> + if (!bsp_priv->powered_down)
>> + return;
>> +
>> + rk_gmac_powerup(bsp_priv);
>
> missing something like
> bsp_priv->suspended = false;
>
> Right now it looks like your bsp_priv->powered_down will always be true
> after the first suspend with powerdown.
Yes I screw up badly, that's a good reason to use a more sensible name
for the variable.
>
>> }
>>
>> static void rk_fix_speed(void *priv, unsigned int speed)
>> @@ -591,6 +628,8 @@ static int rk_gmac_probe(struct platform_device *pdev)
>> plat_dat->init = rk_gmac_init;
>> plat_dat->exit = rk_gmac_exit;
>> plat_dat->fix_mac_speed = rk_fix_speed;
>> + plat_dat->suspend = rk_gmac_suspend;
>> + plat_dat->resume = rk_gmac_resume;
>>
>> plat_dat->bsp_priv = rk_gmac_setup(pdev, data);
>> if (IS_ERR(plat_dat->bsp_priv))
>> --
>> 2.8.0.rc3.226.g39d4020
>
[toc] | [next] | [standalone]
| From | Vincent Palatin <vpalatin@chromium.org> |
|---|---|
| Date | 2016-06-15 20:40 +0200 |
| Subject | [PATCH v2 0/3] net: stmmac: dwmac-rk: fixes for Wake-on-Lan on RK3288 |
| Message-ID | <rKnTj-668-5@gated-at.bofh.it> |
| In reply to | #1423186 |
In order to support Wake-On-Lan when using the RK3288 integrated MAC (with an external RGMII PHY), we need to avoid shutting down the regulator of the external PHY when the MAC is suspended as it's currently done in the MAC platform code. As a first step, create independant callbacks for suspend/resume rather than re-using exit/init callbacks. So the dwmac platform driver can behave differently on suspend where it might skip shutting the PHY and at module unloading. Then update the dwmac-rk driver to switch off the PHY regulator only if we are not planning to wake up from the LAN. Finally add the PMT interrupt to the MAC device tree configuration, so we can wake up the core from it when the PHY has received the magic packet. Changes since v1: * rename 'powered_down' variable into 'suspended'. * fix the logic recording the PHY suspended state according to Heiko comments. Vincent Palatin (3): net: stmmac: allow to split suspend/resume from init/exit callbacks net: stmmac: dwmac-rk: keep the PHY up for WoL ARM: dts: rockchip: add interrupt for Wake-on-Lan on RK3288 arch/arm/boot/dts/rk3288.dtsi | 5 ++- drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 48 +++++++++++++++++++--- .../net/ethernet/stmicro/stmmac/stmmac_platform.c | 8 +++- include/linux/stmmac.h | 2 + 4 files changed, 54 insertions(+), 9 deletions(-) -- 2.8.0.rc3.226.g39d4020
[toc] | [prev] | [next] | [standalone]
| From | Vincent Palatin <vpalatin@chromium.org> |
|---|---|
| Date | 2016-06-15 20:40 +0200 |
| Subject | [PATCH v2 2/3] net: stmmac: dwmac-rk: keep the PHY up for WoL |
| Message-ID | <rKnTj-668-23@gated-at.bofh.it> |
| In reply to | #1423312 |
When suspending the machine, do not shutdown the external PHY by cutting
its regulator in the mac platform driver suspend code if Wake-on-Lan is enabled,
else it cannot wake us up.
In order to do this, split the suspend/resume callbacks from the
init/exit callbacks, so we can condition the power-down on the lack of
need to wake-up from the LAN but do it unconditionally when unloading the
module.
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 48 +++++++++++++++++++++++---
1 file changed, 43 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
index 0cd3ecf..63c2e4f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
@@ -46,6 +46,7 @@ struct rk_priv_data {
struct platform_device *pdev;
int phy_iface;
struct regulator *regulator;
+ bool suspended;
const struct rk_gmac_ops *ops;
bool clk_enabled;
@@ -529,9 +530,8 @@ static struct rk_priv_data *rk_gmac_setup(struct platform_device *pdev,
return bsp_priv;
}
-static int rk_gmac_init(struct platform_device *pdev, void *priv)
+static int rk_gmac_powerup(struct rk_priv_data *bsp_priv)
{
- struct rk_priv_data *bsp_priv = priv;
int ret;
ret = phy_power_on(bsp_priv, true);
@@ -545,14 +545,50 @@ static int rk_gmac_init(struct platform_device *pdev, void *priv)
return 0;
}
-static void rk_gmac_exit(struct platform_device *pdev, void *priv)
+static void rk_gmac_powerdown(struct rk_priv_data *gmac)
{
- struct rk_priv_data *gmac = priv;
-
phy_power_on(gmac, false);
gmac_clk_enable(gmac, false);
}
+static int rk_gmac_init(struct platform_device *pdev, void *priv)
+{
+ struct rk_priv_data *bsp_priv = priv;
+
+ return rk_gmac_powerup(bsp_priv);
+}
+
+static void rk_gmac_exit(struct platform_device *pdev, void *priv)
+{
+ struct rk_priv_data *bsp_priv = priv;
+
+ rk_gmac_powerdown(bsp_priv);
+}
+
+static void rk_gmac_suspend(struct platform_device *pdev, void *priv)
+{
+ struct rk_priv_data *bsp_priv = priv;
+
+ /* Keep the PHY up if we use Wake-on-Lan. */
+ if (device_may_wakeup(&pdev->dev))
+ return;
+
+ rk_gmac_powerdown(bsp_priv);
+ bsp_priv->suspended = true;
+}
+
+static void rk_gmac_resume(struct platform_device *pdev, void *priv)
+{
+ struct rk_priv_data *bsp_priv = priv;
+
+ /* The PHY was up for Wake-on-Lan. */
+ if (!bsp_priv->suspended)
+ return;
+
+ rk_gmac_powerup(bsp_priv);
+ bsp_priv->suspended = false;
+}
+
static void rk_fix_speed(void *priv, unsigned int speed)
{
struct rk_priv_data *bsp_priv = priv;
@@ -591,6 +627,8 @@ static int rk_gmac_probe(struct platform_device *pdev)
plat_dat->init = rk_gmac_init;
plat_dat->exit = rk_gmac_exit;
plat_dat->fix_mac_speed = rk_fix_speed;
+ plat_dat->suspend = rk_gmac_suspend;
+ plat_dat->resume = rk_gmac_resume;
plat_dat->bsp_priv = rk_gmac_setup(pdev, data);
if (IS_ERR(plat_dat->bsp_priv))
--
2.8.0.rc3.226.g39d4020
[toc] | [prev] | [next] | [standalone]
| From | Vincent Palatin <vpalatin@chromium.org> |
|---|---|
| Date | 2016-06-15 20:40 +0200 |
| Subject | [PATCH v2 1/3] net: stmmac: allow to split suspend/resume from init/exit callbacks |
| Message-ID | <rKnTk-668-37@gated-at.bofh.it> |
| In reply to | #1423312 |
Let the stmmac platform drivers provide dedicated suspend and resume
callbacks rather than always re-using the init and exits callbacks.
If the driver does not provide the suspend or resume callback, we fall
back to the old behavior trying to use exit or init.
This allows a specific platform to perform only a partial power-down on
suspend if Wake-on-Lan is enabled but always perform the full shutdown
sequence if the module is unloaded.
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 8 ++++++--
include/linux/stmmac.h | 2 ++
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 409db91..a96714d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -411,7 +411,9 @@ static int stmmac_pltfr_suspend(struct device *dev)
struct platform_device *pdev = to_platform_device(dev);
ret = stmmac_suspend(dev);
- if (priv->plat->exit)
+ if (priv->plat->suspend)
+ priv->plat->suspend(pdev, priv->plat->bsp_priv);
+ else if (priv->plat->exit)
priv->plat->exit(pdev, priv->plat->bsp_priv);
return ret;
@@ -430,7 +432,9 @@ static int stmmac_pltfr_resume(struct device *dev)
struct stmmac_priv *priv = netdev_priv(ndev);
struct platform_device *pdev = to_platform_device(dev);
- if (priv->plat->init)
+ if (priv->plat->resume)
+ priv->plat->resume(pdev, priv->plat->bsp_priv);
+ else if (priv->plat->init)
priv->plat->init(pdev, priv->plat->bsp_priv);
return stmmac_resume(dev);
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index ffdaca9..0507dbf 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -135,6 +135,8 @@ struct plat_stmmacenet_data {
void (*bus_setup)(void __iomem *ioaddr);
int (*init)(struct platform_device *pdev, void *priv);
void (*exit)(struct platform_device *pdev, void *priv);
+ void (*suspend)(struct platform_device *pdev, void *priv);
+ void (*resume)(struct platform_device *pdev, void *priv);
void *bsp_priv;
struct stmmac_axi *axi;
int has_gmac4;
--
2.8.0.rc3.226.g39d4020
[toc] | [prev] | [next] | [standalone]
| From | Vincent Palatin <vpalatin@chromium.org> |
|---|---|
| Date | 2016-06-15 20:40 +0200 |
| Subject | [PATCH v2 3/3] ARM: dts: rockchip: add interrupt for Wake-on-Lan on RK3288 |
| Message-ID | <rKnTj-668-29@gated-at.bofh.it> |
| In reply to | #1423312 |
In order to use Wake-on-Lan on RK3288 integrated MAC, we need to wake-up
the CPU on the PMT interrupt when the MAC and the PHY are in low power mode.
Adding the interrupt declaration.
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
---
arch/arm/boot/dts/rk3288.dtsi | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/arm/boot/dts/rk3288.dtsi b/arch/arm/boot/dts/rk3288.dtsi
index 3b44ef3..3ebee53 100644
--- a/arch/arm/boot/dts/rk3288.dtsi
+++ b/arch/arm/boot/dts/rk3288.dtsi
@@ -539,8 +539,9 @@
gmac: ethernet@ff290000 {
compatible = "rockchip,rk3288-gmac";
reg = <0xff290000 0x10000>;
- interrupts = <GIC_SPI 27 IRQ_TYPE_LEVEL_HIGH>;
- interrupt-names = "macirq";
+ interrupts = <GIC_SPI 27 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 28 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-names = "macirq", "eth_wake_irq";
rockchip,grf = <&grf>;
clocks = <&cru SCLK_MAC>,
<&cru SCLK_MAC_RX>, <&cru SCLK_MAC_TX>,
--
2.8.0.rc3.226.g39d4020
[toc] | [prev] | [next] | [standalone]
| From | David Miller <davem@davemloft.net> |
|---|---|
| Date | 2016-06-16 23:20 +0200 |
| Subject | Re: [PATCH v2 0/3] net: stmmac: dwmac-rk: fixes for Wake-on-Lan on RK3288 |
| Message-ID | <rKMRH-4YX-11@gated-at.bofh.it> |
| In reply to | #1423312 |
From: Vincent Palatin <vpalatin@chromium.org> Date: Wed, 15 Jun 2016 11:32:20 -0700 > In order to support Wake-On-Lan when using the RK3288 integrated MAC > (with an external RGMII PHY), we need to avoid shutting down the regulator > of the external PHY when the MAC is suspended as it's currently done in the MAC > platform code. > As a first step, create independant callbacks for suspend/resume rather than > re-using exit/init callbacks. So the dwmac platform driver can behave differently > on suspend where it might skip shutting the PHY and at module unloading. > Then update the dwmac-rk driver to switch off the PHY regulator only if we are > not planning to wake up from the LAN. > Finally add the PMT interrupt to the MAC device tree configuration, so we can > wake up the core from it when the PHY has received the magic packet. > > Changes since v1: > * rename 'powered_down' variable into 'suspended'. > * fix the logic recording the PHY suspended state according to Heiko comments. Series applied to net-next, thanks.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web