From: Florian Fainelli <f.fainelli@gmail.com>
To: Grygorii Strashko <grygorii.strashko@ti.com>,
"David S. Miller" <davem@davemloft.net>,
netdev@vger.kernel.org, Sekhar Nori <nsekhar@ti.com>,
Mugunthan V N <mugunthanvnm@ti.com>
Cc: linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org,
Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>,
Rob Herring <robh+dt@kernel.org>,
devicetree@vger.kernel.org
Subject: Re: [PATCH 04/15] drivers: net: cpsw: ethtool: fix accessing to suspended device
Date: Wed, 15 Jun 2016 09:14:07 -0700 [thread overview]
Message-ID: <57617ECF.2010902@gmail.com> (raw)
In-Reply-To: <20160615115603.4897-5-grygorii.strashko@ti.com>
On 06/15/2016 04:55 AM, Grygorii Strashko wrote:
> The CPSW might be suspended by RPM if all ethX interfaces are down,
> but it still could be accesible through ethtool interfce. In this case
> ethtool operations, requiring registers access, will cause L3 errors and
> CPSW crash.
>
> Hence, fix it by adding RPM get/put calls in ethtool callbcaks which
> can access CPSW registers: .set_coalesce(), .get_ethtool_stats(),
> .set_pauseparam(), .get_regs()
Provided that you implement an ethtool_ops::begin, it will be called
before each ethtool operation runs, so that could allow you to eliminate
some of the duplication here. Conversely ethtool_ops::end terminates
each operation and can be used for that purpose.
>
> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
> ---
> drivers/net/ethernet/ti/cpsw.c | 36 +++++++++++++++++++++++++++++++++++-
> 1 file changed, 35 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
> index ba81d4e..1ba0c09 100644
> --- a/drivers/net/ethernet/ti/cpsw.c
> +++ b/drivers/net/ethernet/ti/cpsw.c
> @@ -931,6 +931,13 @@ static int cpsw_set_coalesce(struct net_device *ndev,
> u32 prescale = 0;
> u32 addnl_dvdr = 1;
> u32 coal_intvl = 0;
> + int ret;
> +
> + ret = pm_runtime_get_sync(&priv->pdev->dev);
> + if (ret < 0) {
> + pm_runtime_put_noidle(&priv->pdev->dev);
> + return ret;
> + }
>
> coal_intvl = coal->rx_coalesce_usecs;
>
> @@ -985,6 +992,8 @@ update_return:
> priv->coal_intvl = coal_intvl;
> }
>
> + pm_runtime_put(&priv->pdev->dev);
> +
> return 0;
> }
>
> @@ -1022,7 +1031,13 @@ static void cpsw_get_ethtool_stats(struct net_device *ndev,
> struct cpdma_chan_stats tx_stats;
> u32 val;
> u8 *p;
> - int i;
> + int i, ret;
> +
> + ret = pm_runtime_get_sync(&priv->pdev->dev);
> + if (ret < 0) {
> + pm_runtime_put_noidle(&priv->pdev->dev);
> + return;
> + }
>
> /* Collect Davinci CPDMA stats for Rx and Tx Channel */
> cpdma_chan_get_stats(priv->rxch, &rx_stats);
> @@ -1049,6 +1064,8 @@ static void cpsw_get_ethtool_stats(struct net_device *ndev,
> break;
> }
> }
> +
> + pm_runtime_put(&priv->pdev->dev);
> }
>
> static int cpsw_common_res_usage_state(struct cpsw_priv *priv)
> @@ -1780,11 +1797,20 @@ static void cpsw_get_regs(struct net_device *ndev,
> {
> struct cpsw_priv *priv = netdev_priv(ndev);
> u32 *reg = p;
> + int ret;
> +
> + ret = pm_runtime_get_sync(&priv->pdev->dev);
> + if (ret < 0) {
> + pm_runtime_put_noidle(&priv->pdev->dev);
> + return;
> + }
>
> /* update CPSW IP version */
> regs->version = priv->version;
>
> cpsw_ale_dump(priv->ale, reg);
> +
> + pm_runtime_put(&priv->pdev->dev);
> }
>
> static void cpsw_get_drvinfo(struct net_device *ndev,
> @@ -1902,12 +1928,20 @@ static int cpsw_set_pauseparam(struct net_device *ndev,
> {
> struct cpsw_priv *priv = netdev_priv(ndev);
> bool link;
> + int ret;
> +
> + ret = pm_runtime_get_sync(&priv->pdev->dev);
> + if (ret < 0) {
> + pm_runtime_put_noidle(&priv->pdev->dev);
> + return ret;
> + }
>
> priv->rx_pause = pause->rx_pause ? true : false;
> priv->tx_pause = pause->tx_pause ? true : false;
>
> for_each_slave(priv, _cpsw_adjust_link, priv, &link);
>
> + pm_runtime_put(&priv->pdev->dev);
> return 0;
> }
>
>
--
Florian
next prev parent reply other threads:[~2016-06-15 16:14 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-15 11:55 [PATCH 00/15] drivers: net: cpsw: improve runtime pm Grygorii Strashko
2016-06-15 11:55 ` [PATCH 01/15] drivers: net: cpsw: fix suspend when all ethX devices are down Grygorii Strashko
2016-06-15 11:55 ` [PATCH 02/15] drivers: net: cpsw: check return code from pm runtime calls Grygorii Strashko
2016-06-15 11:55 ` [PATCH 03/15] drivers: net: cpsw: remove pm runtime calls from suspend callbacks Grygorii Strashko
2016-06-15 11:55 ` [PATCH 04/15] drivers: net: cpsw: ethtool: fix accessing to suspended device Grygorii Strashko
2016-06-15 16:14 ` Florian Fainelli [this message]
2016-06-15 16:45 ` Grygorii Strashko
2016-06-16 12:48 ` Ivan Khoronzhuk
2016-06-16 13:32 ` Ivan Khoronzhuk
2016-06-15 11:55 ` [PATCH 05/15] drivers: net: cpsw: ndev: " Grygorii Strashko
2016-06-15 11:55 ` [PATCH 06/15] drivers: net: davinci_mdio: do pm runtime initialization later in probe Grygorii Strashko
2016-06-15 11:55 ` [PATCH 07/15] drivers: net: davinci_mdio: remove pm runtime calls from suspend callbacks Grygorii Strashko
2016-06-15 11:55 ` [PATCH 08/15] drivers: net: davinci_mdio: drop suspended and lock fields from mdio_data Grygorii Strashko
2016-06-15 11:55 ` [PATCH 09/15] drivers: net: davinci_mdio: split reset function on init_clk and enable Grygorii Strashko
2016-06-15 11:55 ` [PATCH 10/15] drivers: net: davinci_mdio: add pm runtime callbacks Grygorii Strashko
2016-06-15 11:55 ` [PATCH 11/15] drivers: net: davinci_mdio: implement pm runtime auto mode Grygorii Strashko
2016-06-15 11:56 ` [PATCH 12/15] net: davinci_mdio: document missed "ti,am4372-mdio" compat string Grygorii Strashko
2016-06-19 14:35 ` Rob Herring
2016-06-22 10:26 ` Grygorii Strashko
2016-06-15 11:56 ` [PATCH 13/15] net: davinci_mdio: introduce "ti,cpsw-mdio" " Grygorii Strashko
2016-06-15 11:56 ` [PATCH 14/15] drivers: net: davinci_mdio: enable pm runtime auto for ti cpsw-mdio Grygorii Strashko
2016-06-15 13:48 ` kbuild test robot
2016-06-15 11:56 ` [PATCH 15/15] ARM: dts: am335x/am437x/dra7: use new "ti,cpsw-mdio" compat string Grygorii Strashko
2016-06-21 11:34 ` Tony Lindgren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=57617ECF.2010902@gmail.com \
--to=f.fainelli@gmail.com \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=grygorii.strashko@ti.com \
--cc=ivan.khoronzhuk@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=mugunthanvnm@ti.com \
--cc=netdev@vger.kernel.org \
--cc=nsekhar@ti.com \
--cc=robh+dt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).