Home | History | Annotate | Download | only in dev

Lines Matching defs:iorq

107  * XDC_TWAIT: add iorq "N" to tail of SC's wait queue
117 * XDC_HWAIT: add iorq "N" to head of SC's wait queue
139 * XDC_FREE: add iorq "N" to SC's free list
151 * XDC_RQALLOC: allocate an iorq off the free list (assume nfree > 0).
187 * XDC_DONE: don't need IORQ, get error code and free (done after xdc_cmd)
202 * XDC_ADVANCE: advance iorq's pointers by a number of sectors
204 #define XDC_ADVANCE(IORQ, N) \
207 (IORQ)->sectcnt -= (N); \
208 (IORQ)->blockno += (N); \
209 (IORQ)->dbuf += ((N) * XDFM_BPS); \
216 * [2] & of xdc_softc's "nfree" (waiting for a free iorq/iopb)
217 * [3] & of xdc_softc's "ndone" (waiting for number of done iorq/iopb's
219 * [4] & an iorq (waiting for an XD_SUB_WAIT iorq to finish)
441 * iorq's up front. thus, we avoid linked lists and the costs
452 /* init free list, iorq to iopb pointers, and non-zero fields in the
1114 * if there are no free iorq's, then we just queue and return. the
1158 /* start any iorq's already waiting */
1161 /* fill up any remaining iorq's with queue'd buffers */
1197 * xdc_rqtopb: load up an IOPB based on an iorq
1200 xdc_rqtopb(struct xd_iorq *iorq, struct xd_iopb *iopb, int cmd, int subfun)
1210 if (iorq->xd)
1211 iopb->unit = iorq->xd->xd_drive;
1223 iopb->intl = (XD_STATE(iorq->mode) == XD_SUB_POLL)
1224 ? 0 : iorq->xdc->ipl;
1246 if (XD_STATE(iorq->mode) == XD_SUB_POLL)
1250 iorq->xdc->ipl;
1251 drv->maxsect = iorq->xd->nsect - 1;
1256 drv->maxcyl = iorq->xd->pcyl - 1;
1257 drv->maxhead = iorq->xd->nhead - 1;
1265 if (XD_STATE(iorq->mode) == XD_SUB_POLL)
1269 iorq->xdc->ipl;
1285 iopb->intl = (XD_STATE(iorq->mode) == XD_SUB_POLL)
1286 ? 0 : iorq->xdc->ipl;
1287 iopb->sectcnt = iorq->sectcnt;
1288 block = iorq->blockno;
1289 if (iorq->xd == NULL || block == 0) {
1292 iorq->xd->nsect;
1293 block = block / iorq->xd->nsect;
1294 iopb->headno = block % iorq->xd->nhead;
1295 block = block / iorq->xd->nhead;
1298 iopb->daddr = dp = (iorq->dbuf == NULL) ? 0 :
1299 dvma_kvtopa(iorq->dbuf, iorq->xdc->bustype);
1306 * If you've already got an IORQ, you can call submit directly (currently
1313 struct xd_iorq *iorq;
1318 /* get iorq/iopb */
1347 iorq = &xdcsc->reqs[rqno];
1348 iopb = iorq->iopb;
1351 /* init iorq/iopb */
1352 xdc_rqinit(iorq, xdcsc,
1356 /* load IOPB from iorq */
1357 xdc_rqtopb(iorq, iopb, cmd, subfn);
1360 xdc_submit_iorq(xdcsc, rqno, fullmode); /* error code will be in iorq */
1373 struct xd_iorq *iorq;
1381 iorq = &xdcsc->reqs[rqno];
1382 iopb = iorq->iopb;
1412 * in cases where we do a dvma_mapin, note that iorq points to the
1435 /* init iorq and load iopb from it */
1437 xdc_rqinit(iorq, xdcsc, xdsc, XD_SUB_NORM | XD_MODE_VERBO, block,
1440 xdc_rqtopb(iorq, iopb, (bp->b_flags & B_READ) ? XDCMD_RD : XDCMD_WR, 0);
1453 * xdc_submit_iorq: submit an iorq for processing. returns XD_ERR_AOK
1456 * note: caller frees iorq in all cases except NORM
1470 * software state is stored in the iorq structure. each iorq has an
1479 * on the iorq free list until some iopbs are available.
1486 struct xd_iorq *iorq = &xdcsc->reqs[iorqno];
1505 while (iorq->iopb->done == 0) {
1506 (void)tsleep(iorq, PRIBIO, "xdciorq", 0);
1508 return iorq->errno;
1517 u_char *rio = (u_char *)iorq->iopb;
1520 device_xname(xdcsc->sc_dev), iorq - xdcsc->reqs);
1528 iopbaddr = dvma_kvtopa(iorq->iopb, xdcsc->bustype);
1537 while (iorq->iopb->done == 0) {
1538 (void)tsleep(iorq, PRIBIO, "xdciorq", 0);
1540 return iorq->errno;
1555 * and drains off all i/o requests. it returns the status of the iorq
1557 * when there is a free iorq.
1672 struct xd_iorq *iorq;
1690 iorq = &xdcsc->reqs[lcv];
1692 if (XD_STATE(iorq->mode) != XD_SUB_POLL &&
1693 XD_STATE(iorq->mode) != XD_SUB_WAIT &&
1694 XD_STATE(iorq->mode) != XD_SUB_NORM)
1701 iorq->errno = error;
1703 switch (XD_STATE(iorq->mode)) {
1705 iorq->buf->b_error = EIO;
1706 iorq->buf->b_resid = iorq->sectcnt * XDFM_BPS;
1708 dvma_mapout(iorq->dbufbase,
1709 iorq->buf->b_bcount);
1710 disk_unbusy(&iorq->xd->sc_dk,
1711 (iorq->buf->b_bcount - iorq->buf->b_resid),
1712 (iorq->buf->b_flags & B_READ));
1713 biodone(iorq->buf);
1717 wakeup(iorq);
1720 iorq->mode =
1721 XD_NEWSTATE(iorq->mode, XD_SUB_DONE);
1782 struct xd_iorq *iorq;
1820 iorq = &xdcsc->reqs[rqno];
1821 if (iorq->mode == 0 || XD_STATE(iorq->mode) == XD_SUB_DONE)
1846 iorq->errno = iopb->errno;
1848 iorq->errno = 0;
1853 xdc_error(xdcsc, iorq, iopb, rqno, comm) == XD_ERR_AOK)
1857 /* this iorq is now done (hasn't been restarted or anything) */
1859 if ((iorq->mode & XD_MODE_VERBO) && iorq->lasterror)
1860 xdc_perror(iorq, iopb, 0);
1866 if ((iorq->mode & XD_MODE_B144) != 0 && errs == 0 &&
1876 XDC_ADVANCE(iorq, 1); /* advance 1 sector */
1879 iorq->mode = iorq->mode & (~XD_MODE_B144);
1881 if (iorq->sectcnt) { /* more to go! */
1882 iorq->lasterror = iorq->errno = iopb->errno = 0;
1884 iorq->tries = 0;
1885 iopb->sectcnt = iorq->sectcnt;
1887 iorq->blockno / iorq->xd->sectpercyl;
1889 (iorq->blockno / iorq->xd->nhead) %
1890 iorq->xd->nhead;
1891 iopb->sectno = iorq->blockno % XDFM_BPS;
1893 dvma_kvtopa(iorq->dbuf, xdcsc->bustype);
1901 switch (XD_STATE(iorq->mode)) {
1903 bp = iorq->buf;
1906 bp->b_resid = iorq->sectcnt * XDFM_BPS;
1911 dvma_mapout(iorq->dbufbase, iorq->buf->b_bcount);
1912 disk_unbusy(&iorq->xd->sc_dk,
1919 iorq->mode = XD_NEWSTATE(iorq->mode, XD_SUB_DONE);
1921 wakeup(iorq);
1924 iorq->mode = XD_NEWSTATE(iorq->mode, XD_SUB_DONE);
1939 * is in lasterror. also, if iorq->errno == 0, then we recovered
1940 * from that error (otherwise iorq->errno == iorq->lasterror).
1943 xdc_perror(struct xd_iorq *iorq, struct xd_iopb *iopb, int still_trying)
1945 int error = iorq->lasterror;
1947 printf("%s", (iorq->xd) ?
1948 device_xname(iorq->xd->sc_dev) :
1949 device_xname(iorq->xdc->sc_dev));
1950 if (iorq->buf)
1951 printf("%c: ", 'a' + (char)DISKPART(iorq->buf->b_dev));
1959 printf(" [still trying, new error=%s]", xdc_e2str(iorq->errno));
1961 if (iorq->errno == 0)
1962 printf(" [recovered in %d tries]", iorq->tries);
1972 xdc_error(struct xdc_softc *xdcsc, struct xd_iorq *iorq, struct xd_iopb *iopb,
1976 int errno = iorq->errno;
1981 oldmode = iorq->mode;
1982 iorq->mode = XD_SUB_DONE | (~XD_SUB_MASK & oldmode);
1985 xdc_reset(xdcsc, 1, XD_RSET_NONE, errno, iorq->xd);
1986 iorq->mode = oldmode;
1993 (iorq->mode & XD_MODE_B144) == 0) {
1994 advance = iorq->sectcnt - iopb->sectcnt;
1995 XDC_ADVANCE(iorq, advance);
1996 if ((i = isbad(&iorq->xd->dkb,
1997 iorq->blockno / iorq->xd->sectpercyl,
1998 (iorq->blockno / iorq->xd->nsect) % iorq->xd->nhead,
1999 iorq->blockno % iorq->xd->nsect)) != -1) {
2000 iorq->mode |= XD_MODE_B144; /* enter bad144 mode &
2004 iopb->cylno = (iorq->xd->ncyl + iorq->xd->acyl) - 2;
2006 i = iorq->xd->sectpercyl - 1 - i; /* follow bad144
2008 iopb->headno = i / iorq->xd->nhead;
2009 iopb->sectno = i % iorq->xd->nhead;
2020 if ((iorq->mode & XD_MODE_VERBO) && iorq->lasterror)
2021 xdc_perror(iorq, iopb, 1); /* inform of error state
2023 iorq->lasterror = errno;
2026 && iorq->tries < XDC_MAXTRIES) { /* retry? */
2027 iorq->tries++;
2028 iorq->errno = iopb->errno = iopb->done = iopb->errs = 0;