From patchwork Wed Jun 15 11:55:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grygorii Strashko X-Patchwork-Id: 9178263 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B010D604DB for ; Wed, 15 Jun 2016 11:59:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9EA7926A7B for ; Wed, 15 Jun 2016 11:59:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 90846280E0; Wed, 15 Jun 2016 11:59:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3112926A7B for ; Wed, 15 Jun 2016 11:59:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932759AbcFOL40 (ORCPT ); Wed, 15 Jun 2016 07:56:26 -0400 Received: from bear.ext.ti.com ([198.47.19.11]:60494 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932362AbcFOL4V (ORCPT ); Wed, 15 Jun 2016 07:56:21 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id u5FBuHhV026833; Wed, 15 Jun 2016 06:56:17 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id u5FBuHoJ008882; Wed, 15 Jun 2016 06:56:17 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.294.0; Wed, 15 Jun 2016 06:56:16 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id u5FBuGNu029827; Wed, 15 Jun 2016 06:56:16 -0500 From: Grygorii Strashko To: "David S. Miller" , , Sekhar Nori , Mugunthan V N CC: , , Ivan Khoronzhuk , Rob Herring , , Grygorii Strashko Subject: [PATCH 04/15] drivers: net: cpsw: ethtool: fix accessing to suspended device Date: Wed, 15 Jun 2016 14:55:52 +0300 Message-ID: <20160615115603.4897-5-grygorii.strashko@ti.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20160615115603.4897-1-grygorii.strashko@ti.com> References: <20160615115603.4897-1-grygorii.strashko@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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() Signed-off-by: Grygorii Strashko --- 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; }