Received: by 10.223.164.202 with SMTP id h10csp400316wrb; Tue, 14 Nov 2017 03:28:56 -0800 (PST) X-Google-Smtp-Source: AGs4zMZiG4iqdlP2GLLz4K6rbeJwM8zuMC3o98h09SellRD2mlvtaXnc8tmoWTVn+6g9k9kBtxWa X-Received: by 10.84.233.69 with SMTP id k5mr12328507plt.189.1510658936733; Tue, 14 Nov 2017 03:28:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510658936; cv=none; d=google.com; s=arc-20160816; b=L8pnWmsBCCZj9k0/aXUBhjD3nbU6/WOoHW3YzqQMSRgAFaZD6367z7l10h7F2Gn5gY nxqbIb4u2Yy7IhoIPjs0zBfHLmfzJ74+d1C/+x6EpcYwPbA/T7mREl5XC7qZWKv0W9NP zrIFj7wyklXZ8l/xwahVsLmXJHdmB59IJPQ7uNVm29jflMF6VFx8vsf64zWrsEtlAh9G lkjJz3dVeTBhO9jsD0Xmo2e2cr1OCeBpbaBcX57xhV/OiR9bCLRDVb+pQguskJ739AEV fZ0golflN1UanxF//uDe9jESzbRW7R8s12XQASsaqqcwIaKl6OHCivnsVjtRodnUP95W lEzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=niRmWA8YyTdOoAf6aegFVNChp6UeK/09kamfbNCyVMc=; b=jimSUHT81G/skwiDrFYX+LU2ZDYtDSutm95WnMJU3rZ57w4M8XRI5K/L2sruDww6OU ir/YA89Q1uTh9P9xKwFZ5Nq7g94kISuMkO4dJetDoDPWdqQi0kf++mXKBsgnbM195jyj P2uy/nWP1py8WUHHrz/iuOjl3jh7E3+VxKdt2USKXhepmttDF2s20ym3+VWIMwCq2SxX 1wKvfW5jExug3osxpvV/qzjXUGVNHKxbymfqSSOnBfGp9YDJfjvUcuOL0XYR9+K3wmfy r9sFBoa4uUyRvnnaaqp5Tzk9L/MTT2x7LrFyh2T0n2lxS6Ax048/I5m7AZ/eO2UiHFLd rCQw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k70si9519651pgd.551.2017.11.14.03.28.44; Tue, 14 Nov 2017 03:28:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754758AbdKNKQZ (ORCPT + 87 others); Tue, 14 Nov 2017 05:16:25 -0500 Received: from bastet.se.axis.com ([195.60.68.11]:34748 "EHLO bastet.se.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754051AbdKNKQF (ORCPT ); Tue, 14 Nov 2017 05:16:05 -0500 Received: from localhost (localhost [127.0.0.1]) by bastet.se.axis.com (Postfix) with ESMTP id 72A4718431; Tue, 14 Nov 2017 11:16:03 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at bastet.se.axis.com Received: from bastet.se.axis.com ([IPv6:::ffff:127.0.0.1]) by localhost (bastet.se.axis.com [::ffff:127.0.0.1]) (amavisd-new, port 10024) with LMTP id UdATMG8_B_R6; Tue, 14 Nov 2017 11:16:02 +0100 (CET) Received: from boulder03.se.axis.com (boulder03.se.axis.com [10.0.8.17]) by bastet.se.axis.com (Postfix) with ESMTPS id A092518111; Tue, 14 Nov 2017 11:16:02 +0100 (CET) Received: from boulder03.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 817FC1E098; Tue, 14 Nov 2017 11:16:02 +0100 (CET) Received: from boulder03.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 750E11E096; Tue, 14 Nov 2017 11:16:02 +0100 (CET) Received: from thoth.se.axis.com (unknown [10.0.2.173]) by boulder03.se.axis.com (Postfix) with ESMTP; Tue, 14 Nov 2017 11:16:02 +0100 (CET) Received: from lnxartpec1.se.axis.com (lnxartpec1.se.axis.com [10.88.4.10]) by thoth.se.axis.com (Postfix) with ESMTP id 68D22453; Tue, 14 Nov 2017 11:16:02 +0100 (CET) Received: by lnxartpec1.se.axis.com (Postfix, from userid 20283) id 620B6400F9; Tue, 14 Nov 2017 11:16:02 +0100 (CET) From: Niklas Cassel To: Giuseppe Cavallaro , Alexandre Torgue Cc: Niklas Cassel , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2] net: stmmac: fix LPI transitioning for dwmac4 Date: Tue, 14 Nov 2017 11:15:54 +0100 Message-Id: <20171114101555.18902-1-niklas.cassel@axis.com> X-Mailer: git-send-email 2.14.2 X-TM-AS-GCONF: 00 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The LPI transitioning logic in stmmac_main uses priv->tx_path_in_lpi_mode to enter/exit LPI. However, priv->tx_path_in_lpi_mode is assigned using the return value from host_irq_status(). So for dwmac4, priv->tx_path_in_lpi_mode was always false, so stmmac_tx_clean() would always try to put us in eee mode, and stmmac_xmit() would never take us out of eee mode. To fix this, make host_irq_status() read and return the LPI irq status also for dwmac4. This also increments the existing LPI counters, so that ethtool --statistics shows LPI transitions also for dwmac4. For dwmac1000, irqs are enabled/disabled using the register named "Interrupt Mask Register", and thus setting a bit disables that specific irq. For dwmac4 the matching register is named "MAC_Interrupt_Enable", and thus setting a bit enables that specific irq. Looking at dwmac1000_core.c, the irqs that are always enabled are: LPI and PMT. Looking at dwmac4_core.c, the irqs that are always enabled are: PMT. To be able to read the LPI irq status, we need to enable the LPI irq also for dwmac4. Signed-off-by: Niklas Cassel --- Changes since v1: Fixed two typos in the commit message. drivers/net/ethernet/stmicro/stmmac/dwmac4.h | 7 ++++++- drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h index aeda3ab2d761..789dad8a07b5 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h @@ -98,7 +98,7 @@ #define GMAC_PCS_IRQ_DEFAULT (GMAC_INT_RGSMIIS | GMAC_INT_PCS_LINK | \ GMAC_INT_PCS_ANE) -#define GMAC_INT_DEFAULT_MASK GMAC_INT_PMT_EN +#define GMAC_INT_DEFAULT_MASK (GMAC_INT_PMT_EN | GMAC_INT_LPI_EN) enum dwmac4_irq_status { time_stamp_irq = 0x00001000, @@ -106,6 +106,7 @@ enum dwmac4_irq_status { mmc_tx_irq = 0x00000400, mmc_rx_irq = 0x00000200, mmc_irq = 0x00000100, + lpi_irq = 0x00000020, pmt_irq = 0x00000010, }; @@ -132,6 +133,10 @@ enum power_event { #define GMAC4_LPI_CTRL_STATUS_LPITXA BIT(19) /* Enable LPI TX Automate */ #define GMAC4_LPI_CTRL_STATUS_PLS BIT(17) /* PHY Link Status */ #define GMAC4_LPI_CTRL_STATUS_LPIEN BIT(16) /* LPI Enable */ +#define GMAC4_LPI_CTRL_STATUS_RLPIEX BIT(3) /* Receive LPI Exit */ +#define GMAC4_LPI_CTRL_STATUS_RLPIEN BIT(2) /* Receive LPI Entry */ +#define GMAC4_LPI_CTRL_STATUS_TLPIEX BIT(1) /* Transmit LPI Exit */ +#define GMAC4_LPI_CTRL_STATUS_TLPIEN BIT(0) /* Transmit LPI Entry */ /* MAC Debug bitmap */ #define GMAC_DEBUG_TFCSTS_MASK GENMASK(18, 17) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index 2f7d7ec59962..f3ed8f7853eb 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -580,6 +580,25 @@ static int dwmac4_irq_status(struct mac_device_info *hw, x->irq_receive_pmt_irq_n++; } + /* MAC tx/rx EEE LPI entry/exit interrupts */ + if (intr_status & lpi_irq) { + /* Clear LPI interrupt by reading MAC_LPI_Control_Status */ + u32 status = readl(ioaddr + GMAC4_LPI_CTRL_STATUS); + + if (status & GMAC4_LPI_CTRL_STATUS_TLPIEN) { + ret |= CORE_IRQ_TX_PATH_IN_LPI_MODE; + x->irq_tx_path_in_lpi_mode_n++; + } + if (status & GMAC4_LPI_CTRL_STATUS_TLPIEX) { + ret |= CORE_IRQ_TX_PATH_EXIT_LPI_MODE; + x->irq_tx_path_exit_lpi_mode_n++; + } + if (status & GMAC4_LPI_CTRL_STATUS_RLPIEN) + x->irq_rx_path_in_lpi_mode_n++; + if (status & GMAC4_LPI_CTRL_STATUS_RLPIEX) + x->irq_rx_path_exit_lpi_mode_n++; + } + dwmac_pcs_isr(ioaddr, GMAC_PCS_BASE, intr_status, x); if (intr_status & PCS_RGSMIIIS_IRQ) dwmac4_phystatus(ioaddr, x); -- 2.14.2 From 1586025162422646216@xxx Wed Dec 06 09:11:02 +0000 2017 X-GM-THRID: 1586022873452321662 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread