Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753318AbcK0Gkn (ORCPT ); Sun, 27 Nov 2016 01:40:43 -0500 Received: from mail-db5eur01on0050.outbound.protection.outlook.com ([104.47.2.50]:43744 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751542AbcK0Gke (ORCPT ); Sun, 27 Nov 2016 01:40:34 -0500 From: Andy Duan To: Nikita Yushchenko , "David S. Miller" , Troy Kisky , "Andrew Lunn" , Eric Nelson , Philippe Reynes , Johannes Berg , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Chris Healy Subject: RE: [PATCH] net: fec: turn on device when extracting statistics Thread-Topic: [PATCH] net: fec: turn on device when extracting statistics Thread-Index: AQHSRwMGVs/dvWhfyU+xKeBfll/EHKDsXnyw Date: Sun, 27 Nov 2016 06:25:54 +0000 Message-ID: References: <1480068120-22137-1-git-send-email-nikita.yoush@cogentembedded.com> In-Reply-To: <1480068120-22137-1-git-send-email-nikita.yoush@cogentembedded.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=fugang.duan@nxp.com; x-originating-ip: [199.59.225.131] x-microsoft-exchange-diagnostics: 1;AM4PR0401MB2259;7:LhiG5NP9HouAPPheyRh39f3yIDtHVg1eI0GGuTNDYuhL2U8oxl3V0uptAjIvljS34aircjWSmL82j1+Q6c6ZRvtSkL93buWq0/BSbZH3WJrAVHGX0UGeoS7yt9VwpNCBTQGe8hLi69MTr9q2f0Qep3AULfOa5SYQs5QTZetZ++coUELtJw+5BBkI14JonFRmI1KhIX2ZRoG2cvj7yYfusvGEtSEAvyOu0ZuCn5Kf7B57aqrfoV/QC0AssfwcEoAATBp1gLeQ3CWWrILNO4xRXeMytivrdgf2SoKfX6+JtgVNCLoFNeuvXYyjQxw/wMjl/6nuUte+RR+Pp/gAnGayagLQkhCgl431bn5Bh/DV8zE= x-ms-office365-filtering-correlation-id: 67554fe3-483a-4840-cc1c-08d4168e3e35 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:AM4PR0401MB2259; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(9452136761055)(185117386973197); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6045199)(6040361)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026)(6041248)(6046074)(20161123564025)(20161123562025)(20161123555025)(20161123560025);SRVR:AM4PR0401MB2259;BCL:0;PCL:0;RULEID:;SRVR:AM4PR0401MB2259; x-forefront-prvs: 0139052FDB x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(7916002)(377454003)(189002)(199003)(39380400001)(4326007)(81166006)(106116001)(81156014)(68736007)(8936002)(106356001)(101416001)(39060400001)(54356999)(39410400001)(77096006)(2501003)(2950100002)(105586002)(66066001)(76576001)(189998001)(9686002)(38730400001)(6116002)(86362001)(7736002)(74316002)(5660300001)(76176999)(3846002)(8676002)(229853002)(102836003)(39450400002)(305945005)(50986999)(39400400001)(3660700001)(5001770100001)(6506003)(92566002)(97736004)(122556002)(7416002)(7846002)(2900100001)(3280700002)(7696004)(2906002)(33656002)(2201001);DIR:OUT;SFP:1101;SCL:1;SRVR:AM4PR0401MB2259;H:AM4PR0401MB2260.eurprd04.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Nov 2016 06:25:54.9531 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0401MB2259 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id uAR6em3v018866 Content-Length: 2253 Lines: 59 From: Nikita Yushchenko Sent: Friday, November 25, 2016 6:02 PM >To: Andy Duan ; David S. Miller >; Troy Kisky ; >Andrew Lunn ; Eric Nelson ; Philippe >Reynes ; Johannes Berg ; >netdev@vger.kernel.org; linux-kernel@vger.kernel.org >Cc: Chris Healy ; Nikita Yushchenko > >Subject: [PATCH] net: fec: turn on device when extracting statistics > >Execution 'ethtool -S' on fec device that is down causes OOPS on Vybrid >board: > >Unhandled fault: external abort on non-linefetch (0x1008) at 0xe0898200 pgd >= ddecc000 [e0898200] *pgd=9e406811, *pte=400d1653, *ppte=400d1453 >Internal error: : 1008 [#1] SMP ARM ... > >Reason of OOPS is that fec_enet_get_ethtool_stats() accesses fec registers >while IPG clock is stopped by PM. > >Fix that by wrapping statistics extraction into pm_runtime_get_sync() ... >pm_runtime_put_autosuspend() braces. > >Signed-off-by: Nikita Yushchenko >--- Acked-by: Fugang Duan > drivers/net/ethernet/freescale/fec_main.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > >diff --git a/drivers/net/ethernet/freescale/fec_main.c >b/drivers/net/ethernet/freescale/fec_main.c >index 5aa9d4ded214..9c7592b80ce8 100644 >--- a/drivers/net/ethernet/freescale/fec_main.c >+++ b/drivers/net/ethernet/freescale/fec_main.c >@@ -2317,10 +2317,19 @@ static void fec_enet_get_ethtool_stats(struct >net_device *dev, > struct ethtool_stats *stats, u64 *data) { > struct fec_enet_private *fep = netdev_priv(dev); >- int i; >+ int i, ret; >+ >+ ret = pm_runtime_get_sync(&fep->pdev->dev); >+ if (IS_ERR_VALUE(ret)) { >+ memset(data, 0, sizeof(*data) * ARRAY_SIZE(fec_stats)); >+ return; >+ } > > for (i = 0; i < ARRAY_SIZE(fec_stats); i++) > data[i] = readl(fep->hwp + fec_stats[i].offset); >+ >+ pm_runtime_mark_last_busy(&fep->pdev->dev); >+ pm_runtime_put_autosuspend(&fep->pdev->dev); > } > > static void fec_enet_get_strings(struct net_device *netdev, >-- >2.1.4