Date: Sun, 29 Jul 2007 06:26:27 GMT From: Peter Wemm <peter@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 124298 for review Message-ID: <200707290626.l6T6QRWB063327@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=124298 Change 124298 by peter@peter_overcee on 2007/07/29 06:26:18 Cleanup various bits. * Since we're giant locked, and will never do spl's again, toss the stupid in_intr detection. It'll be mutex locked at some point if ttys ever allow it. * likewise, we don't need to detect the timeout is running. Giant means it can't happen. * assert &Giant to make sure this is the case. * clean up some stuff that looks silly. * remove some unused relics. * turn off actual polling. Affected files ... .. //depot/projects/hammer/sys/dev/si/si.c#22 edit .. //depot/projects/hammer/sys/dev/si/si.h#6 edit Differences ... ==== //depot/projects/hammer/sys/dev/si/si.c#22 (text+ko) ==== @@ -83,7 +83,9 @@ */ #define POLL /* turn on poller to scan for lost interrupts */ +#if 0 #define REALPOLL /* on each poll, scan for work regardless */ +#endif #define POLLHZ (hz/10) /* 10 times per second */ #define SI_I_HIGH_WATER (TTYHOG - 2 * SI_BUFFERSIZE) #define INT_COUNT 25000 /* max of 125 ints per second */ @@ -166,7 +168,6 @@ { B115200, 11520, }, { -1, -1 }, }; -static volatile int in_intr = 0; /* Inside interrupt handler? */ #ifdef POLL static int si_pollrate; /* in addition to irq */ @@ -594,6 +595,7 @@ siopen(struct tty *tp, struct cdev *dev) { + mtx_assert(&Giant, MA_OWNED); #ifdef POLL /* * We've now got a device, so start the poller. @@ -611,6 +613,7 @@ { struct si_port *pp; + mtx_assert(&Giant, MA_OWNED); pp = tp->t_sc; (void) si_command(pp, FCLOSE, SI_NOWAIT); } @@ -620,6 +623,7 @@ { struct si_port *pp; + mtx_assert(&Giant, MA_OWNED); pp = tp->t_sc; if (sig) si_command(pp, SBREAK, SI_WAIT); @@ -645,6 +649,7 @@ DPRINT((0, DBG_ENTRY|DBG_IOCTL, "si_Sioctl(%s,%lx,%x,%x)\n", devtoname(dev), cmd, data, flag)); + mtx_assert(&Giant, MA_OWNED); #if 1 DPRINT((0, DBG_IOCTL, "TCSI_PORT=%x\n", TCSI_PORT)); @@ -786,6 +791,7 @@ BYTE val; DPRINT((pp, DBG_ENTRY|DBG_PARAM, "siparam(%x,%x)\n", tp, t)); + mtx_assert(&Giant, MA_OWNED); cflag = t->c_cflag; iflag = t->c_iflag; oflag = t->c_oflag; @@ -954,6 +960,7 @@ pp = tp->t_sc; DPRINT((pp, DBG_ENTRY|DBG_MODEM, "simodem(%x,%x)\n", sigon, sigoff)); + mtx_assert(&Giant, MA_OWNED); ccbp = pp->sp_ccb; /* Find channel address */ if (sigon == 0 && sigoff == 0) { x = ccbp->hi_ip; @@ -988,6 +995,7 @@ si_modem_state(struct si_port *pp, struct tty *tp, int hi_ip) { /* if a modem dev */ + mtx_assert(&Giant, MA_OWNED); if (hi_ip & IP_DCD) { if (!(pp->sp_last_hi_ip & IP_DCD)) { DPRINT((pp, DBG_INTR, "modem carr on t_line %d\n", @@ -1023,8 +1031,7 @@ DPRINT((0, DBG_POLL, "si_poll()\n")); oldspl = spltty(); - if (in_intr) - goto out; + mtx_assert(&Giant, MA_OWNED); lost = 0; for (i = 0; i < si_numunits; i++) { sc = devclass_get_softc(si_devclass, i); @@ -1061,7 +1068,6 @@ } if (lost || si_realpoll) si_intr(NULL); /* call intr with fake vector */ -out: splx(oldspl); timeout(si_poll, (caddr_t)0L, si_pollrate); @@ -1090,11 +1096,9 @@ BYTE c; sc = arg; + mtx_assert(&Giant, MA_OWNED); DPRINT((0, arg == NULL ? DBG_POLL:DBG_INTR, "si_intr\n")); - if (in_intr) - return; - in_intr = 1; /* * When we get an int we poll all the channels and do ALL pending @@ -1184,9 +1188,8 @@ /* * Continue on if it's closed */ - if (ccbp->hi_stat == IDLE_CLOSE) { + if (ccbp->hi_stat == IDLE_CLOSE) continue; - } /* * Do modem state change if not a local device @@ -1206,9 +1209,8 @@ * Do input break processing */ if (ccbp->hi_state & ST_BREAK) { - if (isopen) { + if (isopen) ttyld_rint(tp, TTY_BI); - } ccbp->hi_state &= ~ST_BREAK; /* A Bit iffy this */ DPRINT((pp, DBG_INTR, "si_intr break\n")); } @@ -1222,7 +1224,7 @@ * if the user cannot get an interrupt signal through. */ - more_rx: /* XXX Sorry. the nesting was driving me bats! :-( */ + more_rx: if (!isopen) { ccbp->hi_rxopos = ccbp->hi_rxipos; @@ -1234,9 +1236,8 @@ * the incoming buffers and let the auto flow control * assert.. */ - if (tp->t_state & TS_TBLOCK) { + if (tp->t_state & TS_TBLOCK) goto end_rx; - } /* * Process read characters if not skipped above @@ -1244,9 +1245,8 @@ op = ccbp->hi_rxopos; ip = ccbp->hi_rxipos; c = ip - op; - if (c == 0) { + if (c == 0) goto end_rx; - } n = c & 0xff; if (n > 250) @@ -1336,15 +1336,13 @@ */ for(x = 0; x < n; x++) { i = si_rxbuf[x]; - if (ttyld_rint(tp, i) - == -1) { + if (ttyld_rint(tp, i) == -1) pp->sp_delta_overflows++; - } } } goto more_rx; /* try for more until RXbuf is empty */ - end_rx: /* XXX: Again, sorry about the gotos.. :-) */ + end_rx: /* * Do TX stuff @@ -1354,7 +1352,6 @@ } /* end of for (all ports on this controller) */ } /* end of for (all controllers) */ - in_intr = 0; DPRINT((0, arg == NULL ? DBG_POLL:DBG_INTR, "end si_intr\n")); } @@ -1376,9 +1373,10 @@ struct clist *qp; BYTE ipos; int nchar; - int oldspl, count, n, amount, buffer_full; + int oldspl, count, n, amount; oldspl = spltty(); + mtx_assert(&Giant, MA_OWNED); qp = &tp->t_outq; pp = tp->t_sc; @@ -1390,17 +1388,14 @@ if (tp->t_state & (TS_TIMEOUT|TS_TTSTOP)) goto out; - buffer_full = 0; ccbp = pp->sp_ccb; count = (int)ccbp->hi_txipos - (int)ccbp->hi_txopos; DPRINT((pp, DBG_START, "count %d\n", (BYTE)count)); while ((nchar = qp->c_cc) > 0) { - if ((BYTE)count >= 255) { - buffer_full++; + if ((BYTE)count >= 255) break; - } amount = min(nchar, (255 - (BYTE)count)); ipos = (unsigned int)ccbp->hi_txipos; n = q_to_b(&tp->t_outq, si_txbuf, amount); @@ -1417,11 +1412,10 @@ count = (int)ccbp->hi_txipos - (int)ccbp->hi_txopos; } - if (count != 0 && nchar == 0) { + if (count != 0 && nchar == 0) tp->t_state |= TS_BUSY; - } else { + else tp->t_state &= ~TS_BUSY; - } /* wakeup time? */ ttwwakeup(tp); @@ -1429,8 +1423,7 @@ DPRINT((pp, DBG_START, "count %d, nchar %d, tp->t_state 0x%x\n", (BYTE)count, nchar, tp->t_state)); - if (tp->t_state & TS_BUSY) - { + if (tp->t_state & TS_BUSY) { int time; time = ttspeedtab(tp->t_ospeed, chartimes); @@ -1446,12 +1439,10 @@ time = hz/10; } - if ((pp->sp_state & (SS_LSTART|SS_INLSTART)) == SS_LSTART) { + if ((pp->sp_state & SS_LSTART) != 0) untimeout(si_lstart, (caddr_t)pp, pp->lstart_ch); - } else { - pp->sp_state |= SS_LSTART; - } DPRINT((pp, DBG_START, "arming lstart, time=%d\n", time)); + pp->sp_state |= SS_LSTART; pp->lstart_ch = timeout(si_lstart, (caddr_t)pp, time); } @@ -1477,16 +1468,14 @@ pp, pp->sp_state)); oldspl = spltty(); + mtx_assert(&Giant, MA_OWNED); + pp->sp_state &= ~SS_LSTART; tp = pp->sp_tty; - if ((tp->t_state & TS_ISOPEN) == 0 || - (pp->sp_state & SS_LSTART) == 0) { + if ((tp->t_state & TS_ISOPEN) == 0) { splx(oldspl); return; } - pp->sp_state &= ~SS_LSTART; - pp->sp_state |= SS_INLSTART; - /* deal with the process exit case */ ttwwakeup(tp); @@ -1494,7 +1483,6 @@ /* nudge protocols - eg: ppp */ ttyld_start(tp); - pp->sp_state &= ~SS_INLSTART; splx(oldspl); } @@ -1507,6 +1495,7 @@ volatile struct si_channel *ccbp; struct si_port *pp; + mtx_assert(&Giant, MA_OWNED); pp = tp->t_sc; ccbp = pp->sp_ccb; @@ -1548,6 +1537,7 @@ pp, cmd, waitflag, ccbp->hi_stat)); oldspl = spltty(); /* Keep others out */ + mtx_assert(&Giant, MA_OWNED); /* wait until it's finished what it was doing.. */ /* XXX: sits in IDLE_BREAK until something disturbs it or break @@ -1556,13 +1546,7 @@ x != IDLE_CLOSE && x != IDLE_BREAK && x != cmd) { - if (in_intr) { /* Prevent sleep in intr */ - DPRINT((pp, DBG_PARAM, - "cmd intr collision - completing %d\trequested %d\n", - x, cmd)); - splx(oldspl); - return; - } else if (ttysleep(pp->sp_tty, (caddr_t)&pp->sp_state, TTIPRI|PCATCH, + if (ttysleep(pp->sp_tty, (caddr_t)&pp->sp_state, TTIPRI|PCATCH, "sicmd1", 1)) { splx(oldspl); return; @@ -1588,13 +1572,7 @@ ccbp->hi_stat = cmd; /* Post it */ if (waitflag) { - if (in_intr) { /* If in interrupt handler */ - DPRINT((pp, DBG_PARAM, - "attempt to sleep in si_intr - cmd req %d\n", - cmd)); - splx(oldspl); - return; - } else while(ccbp->hi_stat != IDLE_OPEN && + while(ccbp->hi_stat != IDLE_OPEN && ccbp->hi_stat != IDLE_BREAK) { if (ttysleep(pp->sp_tty, (caddr_t)&pp->sp_state, TTIPRI|PCATCH, "sicmd2", 0)) ==== //depot/projects/hammer/sys/dev/si/si.h#6 (text+ko) ==== @@ -302,7 +302,7 @@ /* 0x0040 -- */ /* 0x0080 -- */ #define SS_LSTART 0x0100 /* lstart timeout pending */ -#define SS_INLSTART 0x0200 /* running an lstart induced t_oproc */ +/* 0x0200 -- */ /* 0x0400 -- */ /* 0x0800 -- */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200707290626.l6T6QRWB063327>