Skip to content

Commit 4497478

Browse files
Niklas Casseldavem330
authored andcommitted
net: stmmac: fix LPI transitioning for dwmac4
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 <niklas.cassel@axis.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent bde533f commit 4497478

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

drivers/net/ethernet/stmicro/stmmac/dwmac4.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,15 @@
9898
#define GMAC_PCS_IRQ_DEFAULT (GMAC_INT_RGSMIIS | GMAC_INT_PCS_LINK | \
9999
GMAC_INT_PCS_ANE)
100100

101-
#define GMAC_INT_DEFAULT_MASK GMAC_INT_PMT_EN
101+
#define GMAC_INT_DEFAULT_MASK (GMAC_INT_PMT_EN | GMAC_INT_LPI_EN)
102102

103103
enum dwmac4_irq_status {
104104
time_stamp_irq = 0x00001000,
105105
mmc_rx_csum_offload_irq = 0x00000800,
106106
mmc_tx_irq = 0x00000400,
107107
mmc_rx_irq = 0x00000200,
108108
mmc_irq = 0x00000100,
109+
lpi_irq = 0x00000020,
109110
pmt_irq = 0x00000010,
110111
};
111112

@@ -132,6 +133,10 @@ enum power_event {
132133
#define GMAC4_LPI_CTRL_STATUS_LPITXA BIT(19) /* Enable LPI TX Automate */
133134
#define GMAC4_LPI_CTRL_STATUS_PLS BIT(17) /* PHY Link Status */
134135
#define GMAC4_LPI_CTRL_STATUS_LPIEN BIT(16) /* LPI Enable */
136+
#define GMAC4_LPI_CTRL_STATUS_RLPIEX BIT(3) /* Receive LPI Exit */
137+
#define GMAC4_LPI_CTRL_STATUS_RLPIEN BIT(2) /* Receive LPI Entry */
138+
#define GMAC4_LPI_CTRL_STATUS_TLPIEX BIT(1) /* Transmit LPI Exit */
139+
#define GMAC4_LPI_CTRL_STATUS_TLPIEN BIT(0) /* Transmit LPI Entry */
135140

136141
/* MAC Debug bitmap */
137142
#define GMAC_DEBUG_TFCSTS_MASK GENMASK(18, 17)

drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,25 @@ static int dwmac4_irq_status(struct mac_device_info *hw,
580580
x->irq_receive_pmt_irq_n++;
581581
}
582582

583+
/* MAC tx/rx EEE LPI entry/exit interrupts */
584+
if (intr_status & lpi_irq) {
585+
/* Clear LPI interrupt by reading MAC_LPI_Control_Status */
586+
u32 status = readl(ioaddr + GMAC4_LPI_CTRL_STATUS);
587+
588+
if (status & GMAC4_LPI_CTRL_STATUS_TLPIEN) {
589+
ret |= CORE_IRQ_TX_PATH_IN_LPI_MODE;
590+
x->irq_tx_path_in_lpi_mode_n++;
591+
}
592+
if (status & GMAC4_LPI_CTRL_STATUS_TLPIEX) {
593+
ret |= CORE_IRQ_TX_PATH_EXIT_LPI_MODE;
594+
x->irq_tx_path_exit_lpi_mode_n++;
595+
}
596+
if (status & GMAC4_LPI_CTRL_STATUS_RLPIEN)
597+
x->irq_rx_path_in_lpi_mode_n++;
598+
if (status & GMAC4_LPI_CTRL_STATUS_RLPIEX)
599+
x->irq_rx_path_exit_lpi_mode_n++;
600+
}
601+
583602
dwmac_pcs_isr(ioaddr, GMAC_PCS_BASE, intr_status, x);
584603
if (intr_status & PCS_RGSMIIIS_IRQ)
585604
dwmac4_phystatus(ioaddr, x);

0 commit comments

Comments
 (0)