From 3c8b1bf91ba325496d9abd87f902206aa275c831 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Thu, 29 Sep 1994 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1994-09-29 --- port/devns16552.c | 31 +++++++++++++++++-------------- port/qio.c | 8 ++++---- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/port/devns16552.c b/port/devns16552.c index a6f5975d09f555acef299541a44ccb12de62d27a..b80fbdde42a1844c58c5792d1e23310ca48650c1 100644 --- a/port/devns16552.c +++ b/port/devns16552.c @@ -513,7 +513,7 @@ ns16552intr(int dev) shakes = 0; for(loops = 0;; loops++){ p->istat = s = uartrdreg(p, Istat); - if(loops > 50000){ + if(loops > 100000){ if(shakes++ < 3){ /* try resetting the interface */ ns16552shake(p); @@ -592,7 +592,11 @@ ns16552intr(int dev) * * There's also a bit of code to get a stalled print going. * It shouldn't happen, but it does. Obviously I don't - * understand interrupts. -- presotto + * understand something. Since it was there, I bundled a + * restart after flow control with it to give some histeresis + * to the hardware flow control. This makes compressing + * modems happier but will probably bother something else. + * -- presotto */ void uartclock(void) @@ -607,8 +611,7 @@ uartclock(void) if(n > 0 && p->iq){ if(n > Stagesize) panic("uartclock"); - if(qproduce(p->iq, p->istage, n) != n) - ; + qproduce(p->iq, p->istage, n); p->ip = p->istage; } } @@ -737,19 +740,19 @@ ns16552close(Chan *c) return; if(NETTYPE(c->qid.path) == Nstatqid) return; + if((c->flag & COPEN) == 0) + return; p = uart[NETID(c->qid.path)]; - if(c->flag & COPEN){ - qlock(p); - p->opens--; - if(p->opens == 0){ - ns16552disable(p); - qclose(p->iq); - qclose(p->oq); - p->ip = p->istage; - } - qunlock(p); + qlock(p); + p->opens--; + if(p->opens == 0){ + ns16552disable(p); + qclose(p->iq); + qclose(p->oq); + p->ip = p->istage; } + qunlock(p); } static long diff --git a/port/qio.c b/port/qio.c index 09e8737777c93ec2cb77230bb8465dfd599f55f4..8765dc5bde6e6b327e587e08522266890522b24a 100644 --- a/port/qio.c +++ b/port/qio.c @@ -531,7 +531,7 @@ qwrite(Queue *q, void *vp, int len) } memmove(b->wp, p+sofar, n); b->wp += n; - + /* flow control */ while(!qnotfull(q)){ if(q->noblock){ @@ -544,9 +544,9 @@ qwrite(Queue *q, void *vp, int len) q->state |= Qflow; sleep(&q->wr, qnotfull, q); } - + ilock(q); - + if(q->state & Qclosed){ iunlock(q); error(Ehungup); @@ -571,7 +571,7 @@ qwrite(Queue *q, void *vp, int len) q->bfirst = b; q->blast = b; q->len += n; - + if(q->state & Qstarve){ q->state &= ~Qstarve; dowakeup = 1;