devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Grygorii Strashko <grygorii.strashko@ti.com>
To: "David S. Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org, Mugunthan V N <mugunthanvnm@ti.com>
Cc: Sekhar Nori <nsekhar@ti.com>,
	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,
	Grygorii Strashko <grygorii.strashko@ti.com>
Subject: [PATCH v2 04/15] drivers: net: cpsw: ethtool: fix accessing to suspended device
Date: Fri, 24 Jun 2016 21:23:44 +0300	[thread overview]
Message-ID: <20160624182355.23515-5-grygorii.strashko@ti.com> (raw)
In-Reply-To: <20160624182355.23515-1-grygorii.strashko@ti.com>

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.

ethtool callbcaks which need to access CPSW registers now:
.set_coalesce(), .get_ethtool_stats(), .set_pauseparam(), .get_regs()

Hence, fix it by adding .begin()/.complete() ethtool callbacks, which
will be called before/after each ethtool operation runs, and do CPSW
RPM handling in these callbacks. That way CPSW will be active while
handling ethtool requests.

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
---
 drivers/net/ethernet/ti/cpsw.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index ba81d4e..5fea986 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -1907,10 +1907,33 @@ static int cpsw_set_pauseparam(struct net_device *ndev,
 	priv->tx_pause = pause->tx_pause ? true : false;
 
 	for_each_slave(priv, _cpsw_adjust_link, priv, &link);
-
 	return 0;
 }
 
+static int cpsw_ethtool_op_begin(struct net_device *ndev)
+{
+	struct cpsw_priv *priv = netdev_priv(ndev);
+	int ret;
+
+	ret = pm_runtime_get_sync(&priv->pdev->dev);
+	if (ret < 0) {
+		cpsw_err(priv, drv, "ethtool begin failed %d\n", ret);
+		pm_runtime_put_noidle(&priv->pdev->dev);
+	}
+
+	return ret;
+}
+
+static void cpsw_ethtool_op_complete(struct net_device *ndev)
+{
+	struct cpsw_priv *priv = netdev_priv(ndev);
+	int ret;
+
+	ret = pm_runtime_put(&priv->pdev->dev);
+	if (ret < 0)
+		cpsw_err(priv, drv, "ethtool complete failed %d\n", ret);
+}
+
 static const struct ethtool_ops cpsw_ethtool_ops = {
 	.get_drvinfo	= cpsw_get_drvinfo,
 	.get_msglevel	= cpsw_get_msglevel,
@@ -1930,6 +1953,8 @@ static const struct ethtool_ops cpsw_ethtool_ops = {
 	.set_wol	= cpsw_set_wol,
 	.get_regs_len	= cpsw_get_regs_len,
 	.get_regs	= cpsw_get_regs,
+	.begin		= cpsw_ethtool_op_begin,
+	.complete	= cpsw_ethtool_op_complete,
 };
 
 static void cpsw_slave_init(struct cpsw_slave *slave, struct cpsw_priv *priv,
-- 
2.9.0

  parent reply	other threads:[~2016-06-24 18:23 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-24 18:23 [PATCH v2 00/15] drivers: net: cpsw: improve runtime pm Grygorii Strashko
2016-06-24 18:23 ` [PATCH v2 01/15] drivers: net: cpsw: fix suspend when all ethX devices are down Grygorii Strashko
2016-06-24 18:23 ` [PATCH v2 02/15] drivers: net: cpsw: check return code from pm runtime calls Grygorii Strashko
2016-06-24 18:23 ` [PATCH v2 03/15] drivers: net: cpsw: remove pm runtime calls from suspend callbacks Grygorii Strashko
2016-06-24 18:23 ` Grygorii Strashko [this message]
2016-06-24 18:23 ` [PATCH v2 05/15] drivers: net: cpsw: ndev: fix accessing to suspended device Grygorii Strashko
2016-06-24 18:23 ` [PATCH v2 06/15] drivers: net: davinci_mdio: do pm runtime initialization later in probe Grygorii Strashko
2016-06-24 18:23 ` [PATCH v2 07/15] drivers: net: davinci_mdio: remove pm runtime calls from suspend callbacks Grygorii Strashko
2016-06-24 18:23 ` [PATCH v2 08/15] drivers: net: davinci_mdio: drop suspended and lock fields from mdio_data Grygorii Strashko
2016-06-24 18:23 ` [PATCH v2 09/15] drivers: net: davinci_mdio: split reset function on init_clk and enable Grygorii Strashko
2016-06-24 18:23 ` [PATCH v2 10/15] drivers: net: davinci_mdio: add pm runtime callbacks Grygorii Strashko
2016-06-24 18:23 ` [PATCH v2 11/15] drivers: net: davinci_mdio: implement pm runtime auto mode Grygorii Strashko
2016-06-24 18:23 ` [PATCH v2 12/15] net: davinci_mdio: document missed "ti,am4372-mdio" compat string Grygorii Strashko
2016-06-24 18:23 ` [PATCH v2 13/15] net: davinci_mdio: introduce "ti,cpsw-mdio" " Grygorii Strashko
2016-06-24 18:23 ` [PATCH v2 14/15] drivers: net: davinci_mdio: enable pm runtime auto for ti cpsw-mdio Grygorii Strashko
2016-06-24 18:23 ` [PATCH v2 15/15] ARM: dts: am335x/am437x/dra7: use new "ti,cpsw-mdio" compat string Grygorii Strashko
2016-06-27  9:18 ` [PATCH v2 00/15] drivers: net: cpsw: improve runtime pm Mugunthan V N
     [not found] ` <20160624182355.23515-1-grygorii.strashko-l0cyMroinI0@public.gmane.org>
2016-06-28 12:58   ` David Miller

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=20160624182355.23515-5-grygorii.strashko@ti.com \
    --to=grygorii.strashko@ti.com \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --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).