Lines Matching defs:iorq

96  * XDC_TWAIT: add iorq "N" to tail of SC's wait queue
105 * XDC_HWAIT: add iorq "N" to head of SC's wait queue
125 * XDC_FREE: add iorq "N" to SC's free list
135 * XDC_RQALLOC: allocate an iorq off the free list (assume nfree > 0).
182 * XDC_ADVANCE: advance iorq's pointers by a number of sectors
195 * [2] & of xdc_softc's "nfree" (waiting for a free iorq/iopb)
196 * [3] & of xdc_softc's "ndone" (waiting for number of done iorq/iopb's
198 * [4] & an iorq (waiting for an XD_SUB_WAIT iorq to finish)
513 * iorq's up front. thus, we avoid linked lists and the costs
536 /* Get DMA handle for mapping iorq descriptors */
554 /* Get DMA buffer for iorq descriptors */
573 /* init free list, iorq to iopb pointers, and non-zero fields in the
1289 /* if there are no free iorq's, then we just queue and return. the
1336 /* start any iorq's already waiting */
1340 /* fill up any remaining iorq's with queue'd buffers */
1374 * xdc_rqtopb: load up an IOPB based on an iorq
1378 xdc_rqtopb(struct xd_iorq *iorq, struct xd_iopb *iopb, int cmd, int subfun)
1388 if (iorq->xd)
1389 iopb->unit = iorq->xd->xd_drive;
1401 iopb->intl = (XD_STATE(iorq->mode) == XD_SUB_POLL)
1403 : iorq->xdc->ipl;
1417 if (XD_STATE(iorq->mode) == XD_SUB_POLL)
1421 iorq->xdc->ipl;
1422 drv->maxsect = iorq->xd->nsect - 1;
1427 drv->maxcyl = iorq->xd->pcyl - 1;
1428 drv->maxhead = iorq->xd->nhead - 1;
1434 if (XD_STATE(iorq->mode) == XD_SUB_POLL)
1438 iorq->xdc->ipl;
1454 iopb->intl = (XD_STATE(iorq->mode) == XD_SUB_POLL)
1456 : iorq->xdc->ipl;
1457 iopb->sectcnt = iorq->sectcnt;
1458 block = iorq->blockno;
1459 if (iorq->xd == NULL || block == 0) {
1462 iopb->sectno = block % iorq->xd->nsect;
1463 block = block / iorq->xd->nsect;
1464 iopb->headno = block % iorq->xd->nhead;
1465 block = block / iorq->xd->nhead;
1468 dp = (u_long) iorq->dbuf;
1469 dp = iopb->daddr = (iorq->dbuf == NULL) ? 0 : dp;
1470 iopb->addrmod = ((dp + (XDFM_BPS * iorq->sectcnt)) > 0x1000000)
1486 struct xd_iorq *iorq;
1489 /* get iorq/iopb */
1518 iorq = &xdcsc->reqs[rqno];
1519 iopb = iorq->iopb;
1522 /* init iorq/iopb */
1524 xdc_rqinit(iorq, xdcsc,
1528 /* load IOPB from iorq */
1530 xdc_rqtopb(iorq, iopb, cmd, subfn);
1534 xdc_submit_iorq(xdcsc, rqno, fullmode); /* error code will be in iorq */
1547 struct xd_iorq *iorq;
1556 iorq = &xdcsc->reqs[rqno];
1557 iopb = iorq->iopb;
1579 * note that iorq points to the buffer as mapped into DVMA space,
1586 error = bus_dmamap_load(xdcsc->dmatag, iorq->dmamap,
1595 bus_dmamap_sync(xdcsc->dmatag, iorq->dmamap, 0,
1596 iorq->dmamap->dm_mapsize, (bp->b_flags & B_READ)
1600 /* init iorq and load iopb from it */
1601 xdc_rqinit(iorq, xdcsc, xdsc, XD_SUB_NORM | XD_MODE_VERBO, block,
1603 (void *)(u_long)iorq->dmamap->dm_segs[0].ds_addr,
1606 xdc_rqtopb(iorq, iopb, (bp->b_flags & B_READ) ? XDCMD_RD : XDCMD_WR, 0);
1619 * xdc_submit_iorq: submit an iorq for processing. returns XD_ERR_AOK
1622 * note: caller frees iorq in all cases except NORM
1636 * software state is stored in the iorq structure. each iorq has an
1645 * on the iorq free list until some iopbs are available.
1653 struct xd_iorq *iorq = &xdcsc->reqs[iorqno];
1672 while (iorq->iopb->done == 0) {
1673 (void) tsleep(iorq, PRIBIO, "xdciorq", 0);
1675 return (iorq->errnum);
1684 u_char *rio = (u_char *) iorq->iopb;
1687 device_xname(&xdcsc->sc_dev), iorq - xdcsc->reqs);
1695 iopbaddr = (u_long) iorq->dmaiopb;
1704 while (iorq->iopb->done == 0) {
1705 (void) tsleep(iorq, PRIBIO, "xdciorq", 0);
1707 return (iorq->errnum);
1722 * and drains off all i/o requests. it returns the status of the iorq
1724 * when there is a free iorq.
1855 register struct xd_iorq *iorq = &xdcsc->reqs[lcv];
1857 if (XD_STATE(iorq->mode) != XD_SUB_POLL &&
1858 XD_STATE(iorq->mode) != XD_SUB_WAIT &&
1859 XD_STATE(iorq->mode) != XD_SUB_NORM)
1866 iorq->errnum = error;
1870 iorq->buf->b_error = EIO;
1871 iorq->buf->b_resid =
1872 iorq->sectcnt * XDFM_BPS;
1874 bus_dmamap_sync(xdcsc->dmatag, iorq->dmamap, 0,
1875 iorq->dmamap->dm_mapsize,
1876 (iorq->buf->b_flags & B_READ)
1880 bus_dmamap_unload(xdcsc->dmatag, iorq->dmamap);
1885 (iorq->buf->b_flags & B_READ));
1886 biodone(iorq->buf);
1890 wakeup(iorq);
1893 iorq->mode =
1894 XD_NEWSTATE(iorq->mode, XD_SUB_DONE);
1956 struct xd_iorq *iorq;
1993 iorq = &xdcsc->reqs[rqno];
1994 if (iorq->mode == 0 || XD_STATE(iorq->mode) == XD_SUB_DONE)
2017 iorq->errnum = iopb->errnum;
2019 iorq->errnum = 0;
2024 xdc_error(xdcsc, iorq, iopb, rqno, comm) == XD_ERR_AOK)
2028 /* this iorq is now done (hasn't been restarted or anything) */
2030 if ((iorq->mode & XD_MODE_VERBO) && iorq->lasterror)
2031 xdc_perror(iorq, iopb, 0);
2037 if ((iorq->mode & XD_MODE_B144) != 0 && errs == 0 &&
2047 XDC_ADVANCE(iorq, 1); /* advance 1 sector */
2050 iorq->mode = iorq->mode & (~XD_MODE_B144);
2052 if (iorq->sectcnt) { /* more to go! */
2053 iorq->lasterror = iorq->errnum = iopb->errnum = 0;
2055 iorq->tries = 0;
2056 iopb->sectcnt = iorq->sectcnt;
2057 iopb->cylno = iorq->blockno /
2058 iorq->xd->sectpercyl;
2060 (iorq->blockno / iorq->xd->nhead) %
2061 iorq->xd->nhead;
2062 iopb->sectno = iorq->blockno % XDFM_BPS;
2063 iopb->daddr = (u_long) iorq->dbuf;
2071 switch (XD_STATE(iorq->mode)) {
2073 bp = iorq->buf;
2076 bp->b_resid = iorq->sectcnt * XDFM_BPS;
2080 bus_dmamap_sync(xdcsc->dmatag, iorq->dmamap, 0,
2081 iorq->dmamap->dm_mapsize,
2085 bus_dmamap_unload(xdcsc->dmatag, iorq->dmamap);
2087 disk_unbusy(&iorq->xd->sc_dk,
2094 iorq->mode = XD_NEWSTATE(iorq->mode, XD_SUB_DONE);
2096 wakeup(iorq);
2099 iorq->mode = XD_NEWSTATE(iorq->mode, XD_SUB_DONE);
2114 * is in lasterror. also, if iorq->errnum == 0, then we recovered
2115 * from that error (otherwise iorq->errnum == iorq->lasterror).
2118 xdc_perror(struct xd_iorq *iorq, struct xd_iopb *iopb, int still_trying)
2122 int error = iorq->lasterror;
2124 printf("%s", (iorq->xd) ? device_xname(&iorq->xd->sc_dev)
2125 : device_xname(&iorq->xdc->sc_dev));
2126 if (iorq->buf)
2127 printf("%c: ", 'a' + (char)DISKPART(iorq->buf->b_dev));
2135 printf(" [still trying, new error=%s]", xdc_e2str(iorq->errnum));
2137 if (iorq->errnum == 0)
2138 printf(" [recovered in %d tries]", iorq->tries);
2148 xdc_error(struct xdc_softc *xdcsc, struct xd_iorq *iorq, struct xd_iopb *iopb,
2152 int errnum = iorq->errnum;
2160 oldmode = iorq->mode;
2161 iorq->mode = XD_SUB_DONE | (~XD_SUB_MASK & oldmode);
2164 xdc_reset(xdcsc, 1, XD_RSET_NONE, errnum, iorq->xd);
2165 iorq->mode = oldmode;
2172 (iorq->mode & XD_MODE_B144) == 0) {
2173 advance = iorq->sectcnt - iopb->sectcnt;
2174 XDC_ADVANCE(iorq, advance);
2176 if ((i = isbad(&iorq->xd->dkb, iorq->blockno / iorq->xd->sectpercyl,
2177 (iorq->blockno / iorq->xd->nsect) % iorq->xd->nhead,
2178 iorq->blockno % iorq->xd->nsect)) != -1) {
2179 iorq->mode |= XD_MODE_B144; /* enter bad144 mode &
2183 iopb->cylno = (iorq->xd->ncyl + iorq->xd->acyl) - 2;
2185 i = iorq->xd->sectpercyl - 1 - i; /* follow bad144
2187 iopb->headno = i / iorq->xd->nhead;
2188 iopb->sectno = i % iorq->xd->nhead;
2200 if ((iorq->mode & XD_MODE_VERBO) && iorq->lasterror)
2201 xdc_perror(iorq, iopb, 1); /* inform of error state
2203 iorq->lasterror = errnum;
2206 && iorq->tries < XDC_MAXTRIES) { /* retry? */
2207 iorq->tries++;
2208 iorq->errnum = iopb->errnum = iopb->done = iopb->errs = 0;