All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Sondhauß, Jan" <Jan.Sondhauss@wago.com>
To: "grygorii.strashko@ti.com" <grygorii.strashko@ti.com>
Cc: "linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>,
	"Sondhauß, Jan" <Jan.Sondhauss@wago.com>
Subject: [PATCH] drivers: ethernet: cpsw: fix panic when interrupt coaleceing is set via ethtool
Date: Tue, 22 Mar 2022 06:32:53 +0000	[thread overview]
Message-ID: <20220322063221.28132-1-jan.sondhauss@wago.com> (raw)

cpsw_ethtool uses the power management in the begin and complete
functions of the ethtool_ops. The result of pm_runtime_get_sync was
returned unconditionally, which results in problems since the ethtool-
interface relies on 0 for success and negativ values for errors.
d43c65b05b84 (ethtool: runtime-resume netdev parent in ethnl_ops_begin)
introduced power management to the netlink implementation for the
ethtool interface and does not explicitly check for negative return
values.

As a result the pm_runtime_suspend function is called one-too-many
times in ethnl_ops_begin and that leads to an access violation when
the cpsw hardware is accessed after using
'ethtool -C eth-of-cpsw rx-usecs 1234'. To fix this the call to
pm_runtime_get_sync in cpsw_ethtool_op_begin is replaced with a call
to pm_runtime_resume_and_get as it provides a returnable error-code.

Signed-off-by: Jan Sondhauss <jan.sondhauss@wago.com>
---
 drivers/net/ethernet/ti/cpsw_ethtool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/ti/cpsw_ethtool.c b/drivers/net/ethernet/ti/cpsw_ethtool.c
index 158c8d3793f4..5eda20039cc1 100644
--- a/drivers/net/ethernet/ti/cpsw_ethtool.c
+++ b/drivers/net/ethernet/ti/cpsw_ethtool.c
@@ -364,7 +364,7 @@ int cpsw_ethtool_op_begin(struct net_device *ndev)
 	struct cpsw_common *cpsw = priv->cpsw;
 	int ret;
 
-	ret = pm_runtime_get_sync(cpsw->dev);
+	ret = pm_runtime_resume_and_get(cpsw->dev);
 	if (ret < 0) {
 		cpsw_err(priv, drv, "ethtool begin failed %d\n", ret);
 		pm_runtime_put_noidle(cpsw->dev);
-- 
2.35.1

             reply	other threads:[~2022-03-22  7:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-22  6:32 Sondhauß, Jan [this message]
2022-03-22 10:34 ` [PATCH] drivers: ethernet: cpsw: fix panic when interrupt coaleceing is set via ethtool Vignesh Raghavendra
2022-03-22 12:20   ` Sondhauß, Jan
2022-03-22 13:40     ` Vignesh Raghavendra
2022-03-22 14:24       ` Sondhauß, Jan

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=20220322063221.28132-1-jan.sondhauss@wago.com \
    --to=jan.sondhauss@wago.com \
    --cc=grygorii.strashko@ti.com \
    --cc=linux-omap@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.