Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 32757297 authored by Sunil Paidimarri's avatar Sunil Paidimarri Committed by Gerrit - the friendly Code Review server
Browse files

net: stmmac: optimization and updation of phydev



Addition of parameter phydev in stmmac data structure to
avoid costly operation of fetching the phydev, fetch phydev and
store the phydev during mdio register.
Fetching the phydev from stmmac priv as and when required.

Change-Id: I7fe0c81cdc2b8ef12f2292029bad260618430763
Acked-by: default avatarAbhishek Chauhan <abchauha@qti.qualcomm.com>
Signed-off-by: default avatarSunil Paidimarri <hisunil@codeaurora.org>
parent 7f32c71f
Loading
Loading
Loading
Loading
+19 −23
Original line number Diff line number Diff line
@@ -1007,9 +1007,7 @@ static int ethqos_phy_intr_enable(struct qcom_ethqos *ethqos)
			  ethqos->phy_intr);
		return ret;
	}
#ifdef CONFIG_MSM_BOOT_TIME_MARKER
	place_marker("M - Phy IRQ interrupt enabled");
#endif

	phy_intr_en = true;
	return ret;
}
@@ -1472,10 +1470,6 @@ static void qcom_ethqos_bringup_iface(struct work_struct *work)
	if (dev_change_flags(ndev, ndev->flags | IFF_UP) < 0)
		ETHQOSINFO("ERROR\n");

#ifdef CONFIG_MSM_BOOT_TIME_MARKER
	place_marker("M - Device flag changed to UP ");
#endif

	rtnl_unlock();

	ETHQOSINFO("exit\n");
@@ -1484,24 +1478,23 @@ static void qcom_ethqos_bringup_iface(struct work_struct *work)
void qcom_ethqos_request_phy_wol(struct plat_stmmacenet_data *plat)
{
	struct qcom_ethqos *ethqos = plat->bsp_priv;
	struct platform_device *pdev = ethqos->pdev;
	struct net_device *ndev = platform_get_drvdata(pdev);
	struct stmmac_priv *priv = qcom_ethqos_get_priv(ethqos);

	ethqos->phy_wol_supported = 0;
	ethqos->phy_wol_wolopts = 0;
	/* Check if phydev is valid*/
	/* Check and enable Wake-on-LAN functionality in PHY*/

	if (ndev->phydev) {
	if (priv->phydev) {
		struct ethtool_wolinfo wol = {.cmd = ETHTOOL_GWOL};

		wol.supported = 0;
		wol.wolopts = 0;
		ETHQOSINFO("phydev addr: 0x%pK\n", ndev->phydev);
		phy_ethtool_get_wol(ndev->phydev, &wol);
		ETHQOSINFO("phydev addr: 0x%pK\n", priv->phydev);
		phy_ethtool_get_wol(priv->phydev, &wol);
		ethqos->phy_wol_supported = wol.supported;
		ETHQOSINFO("Get WoL[0x%x] in %s\n", wol.supported,
			   ndev->phydev->drv->name);
			   priv->phydev->drv->name);

	/* Try to enable supported Wake-on-LAN features in PHY*/
		if (wol.supported) {
@@ -1510,7 +1503,7 @@ void qcom_ethqos_request_phy_wol(struct plat_stmmacenet_data *plat)
			wol.cmd = ETHTOOL_SWOL;
			wol.wolopts = wol.supported;

			if (!phy_ethtool_set_wol(ndev->phydev, &wol)) {
			if (!phy_ethtool_set_wol(priv->phydev, &wol)) {
				ethqos->phy_wol_wolopts = wol.wolopts;

				enable_irq_wake(ethqos->phy_intr);
@@ -1518,11 +1511,11 @@ void qcom_ethqos_request_phy_wol(struct plat_stmmacenet_data *plat)

				ETHQOSINFO("Enabled WoL[0x%x] in %s\n",
					   wol.wolopts,
					   ndev->phydev->drv->name);
					   priv->phydev->drv->name);
			} else {
				ETHQOSINFO("Disabled WoL[0x%x] in %s\n",
					   wol.wolopts,
					   ndev->phydev->drv->name);
					   priv->phydev->drv->name);
			}
		}
	}
@@ -1634,7 +1627,6 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
	struct net_device *ndev;
	struct stmmac_priv *priv;
	int ret;
	struct phy_device *phydev;

#ifdef CONFIG_MSM_BOOT_TIME_MARKER
	place_marker("M - Ethernet probe start");
@@ -1789,13 +1781,13 @@ static int qcom_ethqos_probe(struct platform_device *pdev)

	ndev = dev_get_drvdata(&ethqos->pdev->dev);
	priv = netdev_priv(ndev);
	phydev = mdiobus_get_phy(priv->mii, priv->plat->phy_addr);
	if (phydev && phydev->drv &&
	    phydev->drv->config_intr &&
		!phydev->drv->config_intr(phydev)) {

	if (priv->phydev && priv->phydev->drv &&
	    priv->phydev->drv->config_intr &&
		!priv->phydev->drv->config_intr(priv->phydev)) {
		qcom_ethqos_request_phy_wol(priv->plat);
		phydev->irq = PHY_IGNORE_INTERRUPT;
		phydev->interrupts =  PHY_INTERRUPT_ENABLED;
		priv->phydev->irq = PHY_IGNORE_INTERRUPT;
		priv->phydev->interrupts =  PHY_INTERRUPT_ENABLED;
	} else {
		ETHQOSERR("config_phy_intr configuration failed");
	}
@@ -1815,6 +1807,10 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
	ethqos_ipa_offload_event_handler(ethqos, EV_PROBE_INIT);
	priv->hw->mac->map_mtl_to_dma(priv->hw, 0, 1); //change
#endif

#ifdef CONFIG_MSM_BOOT_TIME_MARKER
	place_marker("M - Ethernet probe end");
#endif
	return ret;

err_clk:
+1 −1
Original line number Diff line number Diff line
@@ -102,7 +102,7 @@ struct stmmac_priv {
	struct net_device *dev;
	struct device *device;
	struct mac_device_info *hw;

	struct phy_device *phydev;
	/* Mutex lock */
	struct mutex lock;

+38 −30
Original line number Diff line number Diff line
@@ -949,6 +949,8 @@ static int stmmac_init_phy(struct net_device *dev)
	struct stmmac_priv *priv = netdev_priv(dev);
	u32 tx_cnt = priv->plat->tx_queues_to_use;
	struct phy_device *phydev;
	char phy_id_fmt[MII_BUS_ID_SIZE + 3];
	char bus_id[MII_BUS_ID_SIZE];
	int interface = priv->plat->interface;
	int max_speed = priv->plat->max_speed;
	int ret = 0;
@@ -957,8 +959,38 @@ static int stmmac_init_phy(struct net_device *dev)
	priv->speed = SPEED_UNKNOWN;
	priv->oldduplex = DUPLEX_UNKNOWN;

	phydev = mdiobus_get_phy(priv->mii, priv->plat->phy_addr);
	if (priv->plat->early_eth && priv->phydev) {
		phydev = priv->phydev;
		phydev->skip_sw_reset = true;
		ret = phy_connect_direct(dev, phydev,
					 &stmmac_adjust_link, interface);
		if (ret) {
			pr_info("phy_connect_direct failed\n");
			return ret;
		}
	} else {
		if (priv->plat->phy_node) {
			phydev = of_phy_connect(dev,
						priv->plat->phy_node,
						&stmmac_adjust_link,
						0, interface);
		} else {
			snprintf(bus_id, MII_BUS_ID_SIZE, "stmmac-%x",
				 priv->plat->bus_id);

			snprintf(phy_id_fmt,
				 MII_BUS_ID_SIZE + 3, PHY_ID_FMT, bus_id,
				 priv->plat->phy_addr);

			netdev_dbg(priv->dev,
				   "%s: trying to attach to %s\n", __func__,
				   phy_id_fmt);

			phydev = phy_connect(dev,
					     phy_id_fmt,
					     &stmmac_adjust_link,
					     interface);
		}

		if (IS_ERR_OR_NULL(phydev)) {
			netdev_err(priv->dev, "Could not attach to PHY\n");
@@ -967,25 +999,8 @@ static int stmmac_init_phy(struct net_device *dev)

			return PTR_ERR(phydev);
		}

	phydev->skip_sw_reset = true;

	ret = phy_connect_direct(dev, phydev, &stmmac_adjust_link, interface);

	if (ret) {
		pr_info("phy_connect_direct failed\n");
		return ret;
	}
	/* Broken HW is sometimes missing the pull-up resistor on the
	 * MDIO line, which results in reads to non-existent devices returning
	 * 0 rather than 0xffff. Catch this here and treat 0 as a non-existent
	 * device as well.
	 * Note: phydev->phy_id is the result of reading the UID PHY registers.
	 */
	if (!priv->plat->phy_node && phydev->phy_id == 0) {
		phy_disconnect(phydev);
		return -ENODEV;
	}

	pr_info(" qcom-ethqos: %s early eth setting stmmac init\n",
				 __func__);

@@ -1005,9 +1020,6 @@ static int stmmac_init_phy(struct net_device *dev)
				       SUPPORTED_100baseT_Half |
				       SUPPORTED_10baseT_Half);

#ifdef CONFIG_MSM_BOOT_TIME_MARKER
place_marker("M - Init Phy device");
#endif
	/* Early ethernet settings to bring up link in 100M,
	 * Auto neg Off with full duplex link.
	 */
@@ -2695,10 +2707,6 @@ static int stmmac_open(struct net_device *dev)
	struct stmmac_priv *priv = netdev_priv(dev);
	int ret;

#ifdef CONFIG_MSM_BOOT_TIME_MARKER
	place_marker("M - Stmmac open called");
#endif

	if (priv->hw->pcs != STMMAC_PCS_RGMII &&
	    priv->hw->pcs != STMMAC_PCS_TBI &&
	    priv->hw->pcs != STMMAC_PCS_RTBI) {
+1 −0
Original line number Diff line number Diff line
@@ -271,6 +271,7 @@ int stmmac_mdio_register(struct net_device *ndev)
		if (priv->plat->phy_addr == -1)
			priv->plat->phy_addr = addr;

		priv->phydev = phydev;
		phy_attached_info(phydev);
		found = 1;
	}