Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'rswitch-add-pm-ops'

Yoshihiro Shimoda says:

====================
rswitch: Add PM ops

This patch is based on the latest net-next.git / next branch.
After applied this patch with the following patches, the system can
enter/exit Suspend to Idle without any error:
https://git.kernel.org/pub/scm/linux/kernel/git/phy/linux-phy.git/commit/?h=next&id=aa4c0bbf820ddb9dd8105a403aa12df57b9e5129
https://git.kernel.org/pub/scm/linux/kernel/git/phy/linux-phy.git/commit/?h=next&id=1a5361189b7acac15b9b086b2300a11b7aa84c06
====================

Link: https://lore.kernel.org/r/20231017113402.849735-1-yoshihiro.shimoda.uh@renesas.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

+50 -5
+49 -4
drivers/net/ethernet/renesas/rswitch.c
··· 17 17 #include <linux/of_net.h> 18 18 #include <linux/phy/phy.h> 19 19 #include <linux/platform_device.h> 20 + #include <linux/pm.h> 20 21 #include <linux/pm_runtime.h> 21 22 #include <linux/rtnetlink.h> 22 23 #include <linux/slab.h> ··· 1316 1315 if (!phydev) 1317 1316 goto out; 1318 1317 __set_bit(rdev->etha->phy_interface, phydev->host_interfaces); 1318 + phydev->mac_managed_pm = true; 1319 1319 1320 1320 phydev = of_phy_connect(rdev->ndev, phy, rswitch_adjust_link, 0, 1321 1321 rdev->etha->phy_interface); ··· 1407 1405 1408 1406 static int rswitch_ether_port_init_all(struct rswitch_private *priv) 1409 1407 { 1410 - int i, err; 1408 + unsigned int i; 1409 + int err; 1411 1410 1412 1411 rswitch_for_each_enabled_port(priv, i) { 1413 1412 err = rswitch_ether_port_init_one(priv->rdev[i]); ··· 1789 1786 1790 1787 static int rswitch_init(struct rswitch_private *priv) 1791 1788 { 1792 - int i, err; 1789 + unsigned int i; 1790 + int err; 1793 1791 1794 1792 for (i = 0; i < RSWITCH_NUM_PORTS; i++) 1795 1793 rswitch_etha_init(priv, i); ··· 1820 1816 for (i = 0; i < RSWITCH_NUM_PORTS; i++) { 1821 1817 err = rswitch_device_alloc(priv, i); 1822 1818 if (err < 0) { 1823 - for (i--; i >= 0; i--) 1819 + for (; i-- > 0; ) 1824 1820 rswitch_device_free(priv, i); 1825 1821 goto err_device_alloc; 1826 1822 } ··· 1963 1959 1964 1960 static void rswitch_deinit(struct rswitch_private *priv) 1965 1961 { 1966 - int i; 1962 + unsigned int i; 1967 1963 1968 1964 rswitch_gwca_hw_deinit(priv); 1969 1965 rcar_gen4_ptp_unregister(priv->ptp_priv); ··· 1997 1993 platform_set_drvdata(pdev, NULL); 1998 1994 } 1999 1995 1996 + static int renesas_eth_sw_suspend(struct device *dev) 1997 + { 1998 + struct rswitch_private *priv = dev_get_drvdata(dev); 1999 + struct net_device *ndev; 2000 + unsigned int i; 2001 + 2002 + rswitch_for_each_enabled_port(priv, i) { 2003 + ndev = priv->rdev[i]->ndev; 2004 + if (netif_running(ndev)) { 2005 + netif_device_detach(ndev); 2006 + rswitch_stop(ndev); 2007 + } 2008 + if (priv->rdev[i]->serdes->init_count) 2009 + phy_exit(priv->rdev[i]->serdes); 2010 + } 2011 + 2012 + return 0; 2013 + } 2014 + 2015 + static int renesas_eth_sw_resume(struct device *dev) 2016 + { 2017 + struct rswitch_private *priv = dev_get_drvdata(dev); 2018 + struct net_device *ndev; 2019 + unsigned int i; 2020 + 2021 + rswitch_for_each_enabled_port(priv, i) { 2022 + phy_init(priv->rdev[i]->serdes); 2023 + ndev = priv->rdev[i]->ndev; 2024 + if (netif_running(ndev)) { 2025 + rswitch_open(ndev); 2026 + netif_device_attach(ndev); 2027 + } 2028 + } 2029 + 2030 + return 0; 2031 + } 2032 + 2033 + static DEFINE_SIMPLE_DEV_PM_OPS(renesas_eth_sw_pm_ops, renesas_eth_sw_suspend, 2034 + renesas_eth_sw_resume); 2035 + 2000 2036 static struct platform_driver renesas_eth_sw_driver_platform = { 2001 2037 .probe = renesas_eth_sw_probe, 2002 2038 .remove_new = renesas_eth_sw_remove, 2003 2039 .driver = { 2004 2040 .name = "renesas_eth_sw", 2041 + .pm = pm_sleep_ptr(&renesas_eth_sw_pm_ops), 2005 2042 .of_match_table = renesas_eth_sw_of_table, 2006 2043 } 2007 2044 };
+1 -1
drivers/net/ethernet/renesas/rswitch.h
··· 20 20 else 21 21 22 22 #define rswitch_for_each_enabled_port_continue_reverse(priv, i) \ 23 - for (i--; i >= 0; i--) \ 23 + for (; i-- > 0; ) \ 24 24 if (priv->rdev[i]->disabled) \ 25 25 continue; \ 26 26 else