Fix an interrupt storm condition in vldcp(8) (sparc64).
authorstsp <stsp@openbsd.org>
Sat, 6 Jan 2018 21:35:45 +0000 (21:35 +0000)
committerstsp <stsp@openbsd.org>
Sat, 6 Jan 2018 21:35:45 +0000 (21:35 +0000)
If the Rx channel goes down with pending data on the ring, toss the pending
data to ensure that the firmware's rx ring head index matches the rx ring
tail index. Otherwise we trigger an interrupt storm since vldcpread() never
consumes pending data while the channel is down, and the firmware keeps
triggering the interrupt until all data on the ring is consumed.

Interrupt storm observed and fix tested on a T5220 (which can now run
ldom guests; without this fix starting ldomd would trigger the problem).

ok kettenis@

sys/arch/sparc64/dev/vldcp.c

index c51f222..f8ebc73 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: vldcp.c,v 1.12 2015/02/10 22:04:00 miod Exp $ */
+/*     $OpenBSD: vldcp.c,v 1.13 2018/01/06 21:35:45 stsp Exp $ */
 /*
  * Copyright (c) 2009, 2012 Mark Kettenis
  *
@@ -248,6 +248,14 @@ vldcp_rx_intr(void *arg)
                switch (rx_state) {
                case LDC_CHANNEL_DOWN:
                        DPRINTF(("Rx link down\n"));
+                       if (rx_head == rx_tail)
+                               break;
+                       /* Discard and ack pending I/O. */
+                       DPRINTF(("setting rx qhead to %lld\n", rx_tail));
+                       err = hv_ldc_rx_set_qhead(lc->lc_id, rx_tail);
+                       if (err == H_EOK)
+                               break;
+                       printf("%s: hv_ldc_rx_set_qhead %d\n", __func__, err);
                        break;
                case LDC_CHANNEL_UP:
                        DPRINTF(("Rx link up\n"));