From 336fdc586ca71924a943e660ad4b2c7fa407818b Mon Sep 17 00:00:00 2001 From: Suraj Jaiswal Date: Wed, 17 Mar 2021 22:48:09 +0530 Subject: [PATCH] net: stmmac: Low power management optimization Do not check for oldlink, always check for phydev link when we suspend and resume the device. Change-Id: I9cad2a1ecc3aea62b1b005ba09b3e7f21a07349f Acked-by: Nagarjuna Chaganti Signed-off-by: Suraj Jaiswal --- .../stmicro/stmmac/dwmac-qcom-ethqos.c | 42 +++++++++---------- .../stmicro/stmmac/dwmac-qcom-ethqos.h | 5 ++- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c index 3193dc2799be..3183782e2e74 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c @@ -911,33 +911,31 @@ static void qcom_ethqos_phy_suspend_clks(struct qcom_ethqos *ethqos) ETHQOSINFO("Exit\n"); } -static bool qcom_ethqos_is_phy_link_up(struct qcom_ethqos *ethqos, - struct net_device *ndev) +inline void *qcom_ethqos_get_priv(struct qcom_ethqos *ethqos) { - if (!ethqos) { - ETHQOSINFO("ethqos addr is NULL"); - return false; - } + struct platform_device *pdev = ethqos->pdev; + struct net_device *dev = platform_get_drvdata(pdev); + struct stmmac_priv *priv = netdev_priv(dev); - if (!ndev) { - ETHQOSINFO("dev addr is NULL"); - return false; - } - - /* PHY driver initializes phydev->link=1. - * So, phydev->link is 1 even on booup with no PHY connected. - * phydev->link is valid only after adjust_link is called once. - * Use (pdata->oldlink != -1) to indicate phy link is not up - */ - return (ethqos->oldlink != -1 && ndev->phydev && ndev->phydev->link); + return priv; } -static void qcom_ethqos_phy_resume_clks(struct qcom_ethqos *ethqos, - struct net_device *ndev) +inline bool qcom_ethqos_is_phy_link_up(struct qcom_ethqos *ethqos) +{ + /* PHY driver initializes phydev->link=1. + * So, phydev->link is 1 even on bootup with no PHY connected. + * phydev->link is valid only after adjust_link is called once. + */ + struct stmmac_priv *priv = qcom_ethqos_get_priv(ethqos); + + return (priv->dev->phydev && priv->dev->phydev->link); +} + +static void qcom_ethqos_phy_resume_clks(struct qcom_ethqos *ethqos) { ETHQOSINFO("Enter\n"); - if (qcom_ethqos_is_phy_link_up(ethqos, ndev)) + if (qcom_ethqos_is_phy_link_up(ethqos)) ethqos_update_rgmii_clk_and_bus_cfg(ethqos, ethqos->speed); else ethqos_update_rgmii_clk_and_bus_cfg(ethqos, SPEED_10); @@ -1022,7 +1020,7 @@ static int qcom_ethqos_probe(struct platform_device *pdev) } ethqos->pdev = pdev; - ethqos->oldlink = -1; + ethqos_init_reqgulators(ethqos); ethqos_init_gpio(ethqos); @@ -1202,7 +1200,7 @@ static int qcom_ethqos_resume(struct device *dev) return -EINVAL; } - qcom_ethqos_phy_resume_clks(ethqos, ndev); + qcom_ethqos_phy_resume_clks(ethqos); ret = stmmac_resume(dev); diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.h b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.h index 87f1834a0c99..cf675a3f810a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.h @@ -146,7 +146,6 @@ struct qcom_ethqos { unsigned long avb_class_a_intr_cnt; unsigned long avb_class_b_intr_cnt; - int oldlink; /* saving state for Wake-on-LAN */ int wolopts; /* state of enabled wol options in PHY*/ @@ -157,7 +156,6 @@ struct qcom_ethqos { int clks_suspended; /* Structure which holds done and wait members */ struct completion clk_enable_done; - }; struct pps_cfg { @@ -193,6 +191,9 @@ int create_pps_interrupt_device_node(dev_t *pps_dev_t, struct cdev **pps_cdev, struct class **pps_class, char *pps_dev_node_name); +bool qcom_ethqos_is_phy_link_up(struct qcom_ethqos *ethqos); +void *qcom_ethqos_get_priv(struct qcom_ethqos *ethqos); + int ppsout_config(struct stmmac_priv *priv, struct ifr_data_struct *req); u16 dwmac_qcom_select_queue(struct net_device *dev,