Page MenuHomeFreeBSD

D60897.1795328988.diff
No OneTemporary

Authored By
Unknown
Size
4 KB
Referenced Files
None
Subscribers
None

D60897.1795328988.diff

diff --git a/sys/dev/virtio/console/virtio_console.c b/sys/dev/virtio/console/virtio_console.c
--- a/sys/dev/virtio/console/virtio_console.c
+++ b/sys/dev/virtio/console/virtio_console.c
@@ -87,6 +87,10 @@
#define VTCON_PORT_FLAG_GONE 0x01
#define VTCON_PORT_FLAG_CONSOLE 0x02
#define VTCON_PORT_FLAG_ALIAS 0x04
+#define VTCON_PORT_FLAG_INPUT 0x08
+ char *vtcport_inbuf;
+ uint32_t vtcport_inpos;
+ uint32_t vtcport_inlen;
#if defined(KDB)
int vtcport_alt_break_state;
@@ -249,6 +253,8 @@
static void vtcon_port_update_console_size(struct vtcon_softc *);
static void vtcon_port_enable_intr(struct vtcon_port *);
static void vtcon_port_disable_intr(struct vtcon_port *);
+static uint32_t vtcon_port_rint(struct vtcon_port *, const char *,
+ uint32_t, uint32_t);
static void vtcon_port_in(struct vtcon_port *);
static void vtcon_port_intr(void *);
static void vtcon_port_out(struct vtcon_port *, void *, int);
@@ -257,6 +263,7 @@
static int vtcon_tty_open(struct tty *);
static void vtcon_tty_close(struct tty *);
+static void vtcon_tty_inwakeup(struct tty *);
static void vtcon_tty_outwakeup(struct tty *);
static void vtcon_tty_free(void *);
@@ -287,6 +294,7 @@
.tsw_flags = 0,
.tsw_open = vtcon_tty_open,
.tsw_close = vtcon_tty_close,
+ .tsw_inwakeup = vtcon_tty_inwakeup,
.tsw_outwakeup = vtcon_tty_outwakeup,
.tsw_free = vtcon_tty_free,
};
@@ -1637,6 +1645,7 @@
port->vtcport_invq = NULL;
port->vtcport_outvq = NULL;
port->vtcport_id = -1;
+ free(port->vtcport_inbuf, M_DEVBUF);
mtx_destroy(&port->vtcport_mtx);
free(port, M_DEVBUF);
}
@@ -1855,6 +1864,26 @@
virtqueue_disable_intr(port->vtcport_outvq);
}
+static uint32_t
+vtcon_port_rint(struct vtcon_port *port, const char *buf, uint32_t pos,
+ uint32_t len)
+{
+ struct tty *tp;
+
+ tp = port->vtcport_tty;
+
+ for (; pos < len; pos++) {
+ if (ttydisc_rint(tp, buf[pos], 0) == -1)
+ break;
+#if defined(KDB)
+ if (port->vtcport_flags & VTCON_PORT_FLAG_CONSOLE)
+ kdb_alt_break(buf[pos], &port->vtcport_alt_break_state);
+#endif
+ }
+
+ return (pos);
+}
+
static void
vtcon_port_in(struct vtcon_port *port)
{
@@ -1862,33 +1891,40 @@
struct virtqueue *vq;
struct tty *tp;
char *buf;
- uint32_t len;
- int i, deq, pending;
+ uint32_t len, pos;
+ int deq, pending;
scport = port->vtcport_scport;
tp = port->vtcport_tty;
vq = port->vtcport_invq;
+ port->vtcport_flags |= VTCON_PORT_FLAG_INPUT;
again:
deq = 0;
for (;;) {
- VTCON_SCPORT_LOCK(scport);
- buf = NULL;
- if (scport->vcsp_cn_grab == 0)
- buf = virtqueue_dequeue(vq, &len);
- VTCON_SCPORT_UNLOCK(scport);
- if (buf == NULL)
- break;
+ if ((buf = port->vtcport_inbuf) != NULL) {
+ pos = port->vtcport_inpos;
+ len = port->vtcport_inlen;
+ port->vtcport_inbuf = NULL;
+ } else {
+ VTCON_SCPORT_LOCK(scport);
+ buf = NULL;
+ if (scport->vcsp_cn_grab == 0)
+ buf = virtqueue_dequeue(vq, &len);
+ VTCON_SCPORT_UNLOCK(scport);
+ if (buf == NULL)
+ break;
+ pos = 0;
+ len = min(len, VTCON_BULK_BUFSZ);
+ }
- len = min(len, VTCON_BULK_BUFSZ);
- for (i = 0; i < len; i++) {
-#if defined(KDB)
- if (port->vtcport_flags & VTCON_PORT_FLAG_CONSOLE)
- kdb_alt_break(buf[i],
- &port->vtcport_alt_break_state);
-#endif
- ttydisc_rint(tp, buf[i], 0);
+ pos = vtcon_port_rint(port, buf, pos, len);
+ if (pos < len) {
+ port->vtcport_inbuf = buf;
+ port->vtcport_inpos = pos;
+ port->vtcport_inlen = len;
+ break;
}
VTCON_SCPORT_LOCK(scport);
@@ -1902,12 +1938,15 @@
if (deq > 0)
virtqueue_notify(vq);
pending = 0;
- if (scport->vcsp_cn_grab == 0)
+ if (port->vtcport_inbuf != NULL)
+ virtqueue_disable_intr(vq);
+ else if (scport->vcsp_cn_grab == 0)
pending = virtqueue_enable_intr(vq);
VTCON_SCPORT_UNLOCK(scport);
if (pending != 0)
goto again;
+ port->vtcport_flags &= ~VTCON_PORT_FLAG_INPUT;
}
static void
@@ -1995,6 +2034,20 @@
vtcon_port_submit_event(port, VIRTIO_CONSOLE_PORT_OPEN, 0);
}
+static void
+vtcon_tty_inwakeup(struct tty *tp)
+{
+ struct vtcon_port *port;
+
+ port = tty_softc(tp);
+
+ if (port->vtcport_flags &
+ (VTCON_PORT_FLAG_GONE | VTCON_PORT_FLAG_INPUT))
+ return;
+
+ vtcon_port_in(port);
+}
+
static void
vtcon_tty_outwakeup(struct tty *tp)
{

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 22, 6:29 AM (3 h, 52 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41169315
Default Alt Text
D60897.1795328988.diff (4 KB)

Event Timeline