Lines Matching defs:iorq
111 * XYC_DONE: don't need IORQ, get error code and free (done after xyc_cmd)
123 * XYC_ADVANCE: advance iorq's pointers by a number of sectors
126 #define XYC_ADVANCE(IORQ, N) { \
128 (IORQ)->sectcnt -= (N); \
129 (IORQ)->blockno += (N); \
130 (IORQ)->dbuf += ((N)*XYFM_BPS); \
137 * [2] & an iorq (waiting for an XY_SUB_WAIT iorq to finish)
462 /* Get DMA handle for mapping iorq descriptors */
480 /* Get DMA buffer for iorq descriptors */
497 * init iorq to iopb pointers, and non-zero fields in the
1255 /* start any iorq's already waiting */
1288 * xyc_rqtopb: load up an IOPB based on an iorq
1292 xyc_rqtopb(struct xy_iorq *iorq, struct xy_iopb *iopb, int cmd, int subfun)
1299 iopb->ien = (XY_STATE(iorq->mode) == XY_SUB_POLL) ? 0 : 1;
1304 if (iorq->xy) {
1305 iopb->unit = iorq->xy->xy_drive;
1306 iopb->dt = iorq->xy->drive_type;
1311 block = iorq->blockno;
1312 if (iorq->xy == NULL || block == 0) {
1315 iopb->sect = block % iorq->xy->nsect;
1316 block = block / iorq->xy->nsect;
1317 iopb->head = block % iorq
1318 block = block / iorq->xy->nhead;
1321 iopb->scnt = iorq->sectcnt;
1322 dp = (u_long) iorq->dbuf;
1323 if (iorq->dbuf == NULL) {
1358 struct xy_iorq *iorq = xycsc->ciorq;
1365 if (submode == XY_SUB_WAIT && XY_STATE(iorq->mode) != XY_SUB_FREE) {
1366 if (tsleep(iorq, PRIBIO, "xyc_cmd", 0))
1371 if (XY_STATE(iorq->mode) != XY_SUB_FREE) {
1372 DELAY(1000000); /* XY_SUB_POLL: steal the iorq */
1373 iorq->mode = XY_SUB_FREE;
1377 /* init iorq/iopb */
1379 xyc_rqinit(iorq, xycsc,
1383 /* load IOPB from iorq */
1385 xyc_rqtopb(iorq, iopb, cmd, subfn);
1389 xyc_submit_iorq(xycsc, iorq, fullmode); /* error code will be in iorq */
1406 struct xy_iorq *iorq;
1410 iorq = xysc->xyrq;
1411 iopb = iorq->iopb;
1429 * note that iorq points to the buffer as mapped into DVMA space,
1435 error = bus_dmamap_load(xycsc->dmatag, iorq->dmamap,
1443 bus_dmamap_sync(xycsc->dmatag, iorq->dmamap, 0,
1444 iorq->dmamap->dm_mapsize, (bp->b_flags & B_READ)
1448 /* init iorq and load iopb from it */
1449 xyc_rqinit(iorq, xycsc, xysc, XY_SUB_NORM | XY_MODE_VERBO, block,
1451 (void *)(u_long)iorq->dmamap->dm_segs[0].ds_addr,
1454 xyc_rqtopb(iorq, iopb, (bp->b_flags & B_READ) ? XYCMD_RD : XYCMD_WR, 0);
1464 * xyc_submit_iorq: submit an iorq for processing. returns XY_ERR_AOK
1467 * note: caller frees iorq in all cases except NORM
1481 * software state is stored in the iorq structure. each iorq has an
1493 * on the iorq free list until some iopbs are available.
1498 xyc_submit_iorq(struct xyc_softc *xycsc, struct xy_iorq *iorq, int type)
1504 device_xname(xycsc->sc_dev), iorq, type);
1518 while (iorq->iopb->done == 0) {
1519 (void) tsleep(iorq, PRIBIO, "xyciorq", 0);
1521 return (iorq->errnum);
1534 dmaiopb = xyc_chain(xycsc, iorq); /* build chain */
1549 while (iorq->iopb->done == 0) {
1550 (void) tsleep(iorq, PRIBIO, "xyciorq", 0);
1552 return (iorq->errnum);
1554 return (xyc_piodriver(xycsc, iorq));
1565 * the chain. iorq != NULL: means we only want that item on the chain.
1569 xyc_chain(struct xyc_softc *xycsc, struct xy_iorq *iorq)
1578 if (iorq == NULL) {
1582 iorq = &xycsc->reqs[XYC_CTLIOPB];
1586 * special case: if iorq != NULL then we have a POLL or WAIT request.
1589 if (iorq) {
1590 xycsc->xy_chain[0] = iorq;
1591 iorq->iopb->chen = 0;
1592 return(iorq->dmaiopb);
1621 iorq = xycsc->xy_chain[chain];
1630 return(iorq ? iorq->dmaiopb : NULL);
1637 * and drains off the polled i/o request. it returns the status of the iorq
1641 xyc_piodriver(struct xyc_softc *xycsc, struct xy_iorq *iorq)
1647 printf("xyc_piodriver(%s, 0x%x)\n", device_xname(xycsc->sc_dev), iorq);
1650 while (iorq->iopb->done == 0) {
1664 (nreset++ == 0) ? XY_RSET_NONE : iorq,
1674 if (iorq->iopb->done == 0)
1675 xyc_start(xycsc, iorq);
1680 retval = iorq->errnum;
1684 iorq->errnum, xyc_e2str(iorq->errnum));
1766 register struct xy_iorq *iorq = &xycsc->reqs[lcv];
1768 if (XY_STATE(iorq->mode) != XY_SUB_POLL &&
1769 XY_STATE(iorq->mode) != XY_SUB_WAIT &&
1770 XY_STATE(iorq->mode) != XY_SUB_NORM)
1775 blastmode != iorq) {
1777 iorq->errnum = error;
1779 switch (XY_STATE(iorq->mode)) {
1781 iorq->buf->b_error = EIO;
1782 iorq->buf->b_resid = iorq->sectcnt * XYFM_BPS;
1784 bus_dmamap_sync(xycsc->dmatag, iorq->dmamap, 0,
1785 iorq->dmamap->dm_mapsize,
1786 (iorq->buf->b_flags & B_READ)
1790 bus_dmamap_unload(xycsc->dmatag, iorq->dmamap);
1792 (void)bufq_get(iorq->xy->xyq);
1797 biodone(iorq->buf);
1798 iorq->mode = XY_SUB_FREE;
1801 wakeup(iorq);
1803 iorq->mode =
1804 XY_NEWSTATE(iorq->mode, XY_SUB_DONE);
1828 xyc_start(struct xyc_softc *xycsc, struct xy_iorq *iorq)
1833 if (iorq == NULL) {
1841 xyc_submit_iorq(xycsc, iorq, XY_SUB_NOQ);
1855 struct xy_iorq *iorq;
1885 iorq = xycsc->xy_chain[rq];
1886 if (iorq == NULL) break; /* done ! */
1887 if (iorq->mode == 0 || XY_STATE(iorq->mode) == XY_SUB_DONE)
1889 iopb = iorq->iopb;
1897 iorq->errnum = iopb->errnum;
1899 iorq->errnum = 0;
1904 xyc_error(xycsc, iorq, iopb, comm) == XY_ERR_AOK)
1908 /* this iorq is now done (hasn't been restarted or anything) */
1910 if ((iorq->mode & XY_MODE_VERBO) && iorq->lasterror)
1911 xyc_perror(iorq, iopb, 0);
1917 if ((iorq->mode & XY_MODE_B144) != 0 && errs == 0 &&
1927 XYC_ADVANCE(iorq, 1); /* advance 1 sector */
1930 iorq->mode = iorq->mode & (~XY_MODE_B144);
1932 if (iorq->sectcnt) { /* more to go! */
1933 iorq->lasterror = iorq->errnum = iopb->errnum = 0;
1935 iorq->tries = 0;
1936 iopb->scnt = iorq->sectcnt;
1937 iopb->cyl = iorq->blockno /
1938 iorq->xy->sectpercyl;
1940 (iorq->blockno / iorq->xy->nhead) %
1941 iorq->xy->nhead;
1942 iopb->sect = iorq->blockno % XYFM_BPS;
1943 addr = (u_long) iorq->dbuf;
1952 switch (XY_STATE(iorq->mode)) {
1954 iorq->buf;
1957 bp->b_resid = iorq->sectcnt * XYFM_BPS;
1961 bus_dmamap_sync(xycsc->dmatag, iorq->dmamap, 0,
1962 iorq->dmamap->dm_mapsize,
1963 (iorq->buf->b_flags & B_READ)
1967 bus_dmamap_unload(xycsc->dmatag, iorq->dmamap);
1969 (void)bufq_get(iorq->xy->xyq);
1970 disk_unbusy(&iorq->xy->sc_dk,
1973 iorq->mode = XY_SUB_FREE;
1977 iorq->mode = XY_NEWSTATE(iorq->mode, XY_SUB_DONE);
1978 wakeup(iorq);
1981 iorq->mode = XY_NEWSTATE(iorq->mode, XY_SUB_DONE);
1995 * is in lasterror. also, if iorq->errnum == 0, then we recovered
1996 * from that error (otherwise iorq->errnum == iorq->lasterror).
1999 xyc_perror(struct xy_iorq *iorq, struct xy_iopb *iopb, int still_trying)
2002 int error = iorq->lasterror;
2004 printf("%s", (iorq->xy) ? device_xname(iorq->xy->sc_dev)
2005 : device_xname(iorq->xyc->sc_dev));
2006 if (iorq->buf)
2007 printf("%c: ", 'a' + (char)DISKPART(iorq->buf->b_dev));
2015 printf(" [still trying, new error=%s]", xyc_e2str(iorq->errnum));
2017 if (iorq->errnum == 0)
2018 printf(" [recovered in %d tries]", iorq->tries);
2028 xyc_error(struct xyc_softc *xycsc, struct xy_iorq *iorq, struct xy_iopb *iopb,
2031 int errnum = iorq->errnum;
2039 oldmode = iorq->mode;
2040 iorq->mode = XY_SUB_DONE | (~XY_SUB_MASK & oldmode);
2042 xyc_reset(xycsc, 1, XY_RSET_NONE, errnum, iorq->xy);
2043 iorq->mode = oldmode;
2049 (iorq->mode & XY_MODE_B144) == 0) {
2050 advance = iorq->sectcnt - iopb->scnt;
2051 XYC_ADVANCE(iorq, advance);
2053 if ((i = isbad(&iorq->xy->dkb, iorq->blockno / iorq->xy->sectpercyl,
2054 (iorq->blockno / iorq->xy->nsect) % iorq->xy->nhead,
2055 iorq->blockno % iorq->xy->nsect)) != -1) {
2056 iorq->mode |= XY_MODE_B144; /* enter bad144 mode &
2060 iopb->cyl = (iorq->xy->ncyl + iorq->xy->acyl) - 2;
2062 i = iorq->xy->sectpercyl - 1 - i; /* follow bad144
2064 iopb->head = i / iorq->xy->nhead;
2065 iopb->sect = i % iorq->xy->nhead;
2076 if ((iorq->mode & XY_MODE_VERBO) && iorq->lasterror)
2077 xyc_perror(iorq, iopb, 1); /* inform of error state
2079 iorq->lasterror = errnum;
2082 && iorq->tries < XYC_MAXTRIES) { /* retry? */
2083 iorq->tries++;
2084 iorq->errnum = iopb->errnum = iopb->done = iopb->errs = 0;