Skip to content

Commit 3a7ac49

Browse files
tanstafelgregkh
authored andcommitted
net: ks8851: Fix another TX stall caused by wrong ISR flag handling
commit 317a215 upstream. Under some circumstances it may happen that the ks8851 Ethernet driver stops sending data. Currently the interrupt handler resets the interrupt status flags in the hardware after handling TX. With this approach we may lose interrupts in the time window between handling the TX interrupt and resetting the TX interrupt status bit. When all of the three following conditions are true then transmitting data stops: - TX queue is stopped to wait for room in the hardware TX buffer - no queued SKBs in the driver (txq) that wait for being written to hw - hardware TX buffer is empty and the last TX interrupt was lost This is because reenabling the TX queue happens when handling the TX interrupt status but if the TX status bit has already been cleared then this interrupt will never come. With this commit the interrupt status flags will be cleared before they are handled. That way we stop losing interrupts. The wrong handling of the ISR flags was there from the beginning but with commit 3dc5d44 ("net: ks8851: Fix TX stall caused by TX buffer overrun") the issue becomes apparent. Fixes: 3dc5d44 ("net: ks8851: Fix TX stall caused by TX buffer overrun") Cc: "David S. Miller" <davem@davemloft.net> Cc: Eric Dumazet <edumazet@google.com> Cc: Jakub Kicinski <kuba@kernel.org> Cc: Paolo Abeni <pabeni@redhat.com> Cc: Simon Horman <horms@kernel.org> Cc: netdev@vger.kernel.org Cc: stable@vger.kernel.org # 5.10+ Signed-off-by: Ronald Wahl <ronald.wahl@raritan.com> Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 7e4f50d commit 3a7ac49

File tree

1 file changed

+1
-17
lines changed

1 file changed

+1
-17
lines changed

drivers/net/ethernet/micrel/ks8851_common.c

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -328,32 +328,24 @@ static irqreturn_t ks8851_irq(int irq, void *_ks)
328328
{
329329
struct ks8851_net *ks = _ks;
330330
struct sk_buff_head rxq;
331-
unsigned handled = 0;
332331
unsigned long flags;
333332
unsigned int status;
334333
struct sk_buff *skb;
335334

336335
ks8851_lock(ks, &flags);
337336

338337
status = ks8851_rdreg16(ks, KS_ISR);
338+
ks8851_wrreg16(ks, KS_ISR, status);
339339

340340
netif_dbg(ks, intr, ks->netdev,
341341
"%s: status 0x%04x\n", __func__, status);
342342

343-
if (status & IRQ_LCI)
344-
handled |= IRQ_LCI;
345-
346343
if (status & IRQ_LDI) {
347344
u16 pmecr = ks8851_rdreg16(ks, KS_PMECR);
348345
pmecr &= ~PMECR_WKEVT_MASK;
349346
ks8851_wrreg16(ks, KS_PMECR, pmecr | PMECR_WKEVT_LINK);
350-
351-
handled |= IRQ_LDI;
352347
}
353348

354-
if (status & IRQ_RXPSI)
355-
handled |= IRQ_RXPSI;
356-
357349
if (status & IRQ_TXI) {
358350
unsigned short tx_space = ks8851_rdreg16(ks, KS_TXMIR);
359351

@@ -365,20 +357,12 @@ static irqreturn_t ks8851_irq(int irq, void *_ks)
365357
if (netif_queue_stopped(ks->netdev))
366358
netif_wake_queue(ks->netdev);
367359
spin_unlock(&ks->statelock);
368-
369-
handled |= IRQ_TXI;
370360
}
371361

372-
if (status & IRQ_RXI)
373-
handled |= IRQ_RXI;
374-
375362
if (status & IRQ_SPIBEI) {
376363
netdev_err(ks->netdev, "%s: spi bus error\n", __func__);
377-
handled |= IRQ_SPIBEI;
378364
}
379365

380-
ks8851_wrreg16(ks, KS_ISR, handled);
381-
382366
if (status & IRQ_RXI) {
383367
/* the datasheet says to disable the rx interrupt during
384368
* packet read-out, however we're masking the interrupt

0 commit comments

Comments
 (0)