Lines Matching defs:iorq
122 * XYC_DONE: don't need IORQ, get error code and free (done after xyc_cmd)
135 * XYC_ADVANCE: advance iorq's pointers by a number of sectors
138 #define XYC_ADVANCE(IORQ, N) \
141 (IORQ)->sectcnt -= (N); \
142 (IORQ)->blockno += (N); \
143 (IORQ)->dbuf += ((N) * XYFM_BPS); \
150 * [2] & an iorq (waiting for an XY_SUB_WAIT iorq to finish)
397 * init iorq to iopb pointers, and non-zero fields in the
1106 /* start any iorq's already waiting */
1140 * xyc_rqtopb: load up an IOPB based on an iorq
1144 xyc_rqtopb(struct xy_iorq *iorq, struct xy_iopb *iopb, int cmd, int subfun)
1151 iopb->ien = (XY_STATE(iorq->mode) == XY_SUB_POLL) ? 0 : 1;
1156 if (iorq->xy) {
1157 iopb->unit = iorq->xy->xy_drive;
1158 iopb->dt = iorq->xy->drive_type;
1163 block = iorq->blockno;
1164 if (iorq->xy == NULL || block == 0) {
1167 iopb->sect = block % iorq->xy->nsect;
1168 block = block / iorq->xy->nsect;
1169 iopb->head = block % iorq->xy->nhead;
1170 block = block / iorq->xy->nhead;
1173 iopb->scnt = iorq->sectcnt;
1174 if (iorq->dbuf == NULL) {
1178 dp = dvma_kvtopa(iorq->dbuf, iorq->xyc->bustype);
1210 struct xy_iorq *iorq = xycsc->ciorq;
1218 if (submode == XY_SUB_WAIT && XY_STATE(iorq->mode) != XY_SUB_FREE) {
1219 if (tsleep(iorq, PRIBIO, "xyc_cmd", 0))
1224 if (XY_STATE(iorq->mode) != XY_SUB_FREE) {
1225 DELAY(1000000); /* XY_SUB_POLL: steal the iorq */
1226 iorq->mode = XY_SUB_FREE;
1230 /* init iorq/iopb */
1232 xyc_rqinit(iorq, xycsc,
1236 /* load IOPB from iorq */
1238 xyc_rqtopb(iorq, iopb, cmd, subfn);
1242 xyc_submit_iorq(xycsc, iorq, fullmode); /* error code will be in iorq */
1255 struct xy_iorq *iorq;
1260 iorq = xysc->xyrq;
1261 iopb = iorq->iopb;
1288 * in cases where we do a dvma_mapin, note that iorq points to the
1308 /* init iorq
1310 xyc_rqinit(iorq, xycsc, xysc, XY_SUB_NORM | XY_MODE_VERBO, block,
1313 xyc_rqtopb(iorq, iopb, (bp->b_flags & B_READ) ? XYCMD_RD : XYCMD_WR, 0);
1323 * xyc_submit_iorq: submit an iorq for processing. returns XY_ERR_AOK
1326 * note: caller frees iorq in all cases except NORM
1340 * software state is stored in the iorq structure. each iorq has an
1352 * on the iorq free list until some iopbs are available.
1356 xyc_submit_iorq(struct xyc_softc *xycsc, struct xy_iorq *iorq, int type)
1363 device_xname(xycsc->sc_dev), iorq, type);
1377 while (iorq->iopb->done == 0) {
1378 (void)tsleep(iorq, PRIBIO, "xyciorq", 0);
1380 return (iorq->errno);
1394 iopb = xyc_chain(xycsc, iorq); /* build chain */
1410 while (iorq->iopb->done == 0) {
1411 (void)tsleep(iorq, PRIBIO, "xyciorq", 0);
1413 return iorq->errno;
1415 return xyc_piodriver(xycsc, iorq);
1426 * the chain. iorq != NULL: means we only want that item on the chain.
1430 xyc_chain(struct xyc_softc *xycsc, struct xy_iorq *iorq)
1440 if (iorq == NULL) {
1444 iorq = &xycsc->reqs[XYC_CTLIOPB];
1448 * special case: if iorq != NULL then we have a POLL or WAIT request.
1451 if (iorq) {
1452 xycsc->xy_chain[0] = iorq;
1453 iorq->iopb->chen = 0;
1454 return iorq->iopb;
1481 iorq = xycsc->xy_chain[chain];
1487 return iorq ? iorq->iopb : NULL;
1494 * and drains off the polled i/o request. it returns the status of the iorq
1498 xyc_piodriver(struct xyc_softc *xycsc, struct xy_iorq *iorq)
1505 printf("%s(%s, 0x%x)\n", __func__, device_xname(xycsc->sc_dev), iorq);
1508 while (iorq->iopb->done == 0) {
1522 (nreset++ == 0) ? XY_RSET_NONE : iorq,
1531 if (iorq->iopb->done == 0)
1532 xyc_start(xycsc, iorq);
1537 retval = iorq->errno;
1541 iorq->errno, xyc_e2str(iorq->errno));
1600 struct xy_iorq *iorq;
1618 iorq = &xycsc->reqs[lcv];
1620 if (XY_STATE(iorq->mode) != XY_SUB_POLL &&
1621 XY_STATE(iorq->mode) != XY_SUB_WAIT &&
1622 XY_STATE(iorq->mode) != XY_SUB_NORM)
1627 blastmode != iorq) {
1629 iorq->errno = error;
1631 switch (XY_STATE(iorq->mode)) {
1633 iorq->buf->b_error = EIO;
1634 iorq->buf->b_resid = iorq->sectcnt * XYFM_BPS;
1636 dvma_mapout(iorq->dbufbase,
1637 iorq->buf->b_bcount);
1638 (void)bufq_get(iorq->xy->xyq);
1639 disk_unbusy(&iorq->xy->sc_dk,
1640 (iorq->buf->b_bcount - iorq->buf->b_resid),
1641 (iorq->buf->b_flags & B_READ));
1642 biodone(iorq->buf);
1643 iorq->mode = XY_SUB_FREE;
1646 wakeup(iorq);
1648 iorq->mode =
1649 XY_NEWSTATE(iorq->mode, XY_SUB_DONE);
1673 xyc_start(struct xyc_softc *xycsc, struct xy_iorq *iorq)
1678 if (iorq == NULL) {
1689 xyc_submit_iorq(xycsc, iorq, XY_SUB_NOQ);
1703 struct xy_iorq *iorq;
1734 iorq = xycsc->xy_chain[rq];
1735 if (iorq == NULL) break; /* done ! */
1736 if (iorq->mode == 0 || XY_STATE(iorq->mode) == XY_SUB_DONE)
1738 iopb = iorq->iopb;
1746 iorq->errno = iopb->errno;
1748 iorq->errno = 0;
1753 xyc_error(xycsc, iorq, iopb, comm) == XY_ERR_AOK)
1757 /* this iorq is now done (hasn't been restarted or anything) */
1759 if ((iorq->mode & XY_MODE_VERBO) && iorq->lasterror)
1760 xyc_perror(iorq, iopb, 0);
1766 if ((iorq->mode & XY_MODE_B144) != 0 && errs == 0 &&
1776 XYC_ADVANCE(iorq, 1); /* advance 1 sector */
1779 iorq->mode = iorq->mode & (~XY_MODE_B144);
1781 if (iorq->sectcnt) { /* more to go! */
1782 iorq->lasterror = iorq->errno = iopb->errno = 0;
1784 iorq->tries = 0;
1785 iopb->scnt = iorq->sectcnt;
1787 iorq->blockno / iorq->xy->sectpercyl;
1789 (iorq->blockno / iorq->xy->nhead) %
1790 iorq->xy->nhead;
1791 iopb->sect = iorq->blockno % XYFM_BPS;
1792 addr = dvma_kvtopa(iorq->dbuf, xycsc->bustype);
1801 switch (XY_STATE(iorq->mode)) {
1803 bp = iorq->buf;
1806 bp->b_resid = iorq->sectcnt * XYFM_BPS;
1811 dvma_mapout(iorq->dbufbase, iorq->buf->b_bcount);
1812 (void)bufq_get(iorq->xy->xyq);
1813 disk_unbusy(&iorq->xy->sc_dk,
1816 iorq->mode = XY_SUB_FREE;
1820 iorq->mode = XY_NEWSTATE(iorq->mode, XY_SUB_DONE);
1821 wakeup(iorq);
1824 iorq->mode = XY_NEWSTATE(iorq->mode, XY_SUB_DONE);
1838 * is in lasterror. also, if iorq->errno == 0, then we recovered
1839 * from that error (otherwise iorq->errno == iorq->lasterror).
1842 xyc_perror(struct xy_iorq *iorq, struct xy_iopb *iopb, int still_trying)
1844 int error = iorq->lasterror;
1846 printf("%s", (iorq->xy) ? device_xname(iorq->xy->sc_dev)
1847 : device_xname(iorq->xyc->sc_dev));
1848 if (iorq->buf)
1849 printf("%c: ", 'a' + (char)DISKPART(iorq->buf->b_dev));
1857 printf(" [still trying, new error=%s]", xyc_e2str(iorq->errno));
1859 if (iorq->errno == 0)
1860 printf(" [recovered in %d tries]", iorq->tries);
1870 xyc_error(struct xyc_softc *xycsc, struct xy_iorq *iorq, struct xy_iopb *iopb,
1873 int errno = iorq->errno;
1878 oldmode = iorq->mode;
1879 iorq->mode = XY_SUB_DONE | (~XY_SUB_MASK & oldmode);
1881 xyc_reset(xycsc, 1, XY_RSET_NONE, errno, iorq->xy);
1882 iorq->mode = oldmode;
1888 (iorq->mode & XY_MODE_B144) == 0) {
1889 advance = iorq->sectcnt - iopb->scnt;
1890 XYC_ADVANCE(iorq, advance);
1891 if ((i = isbad(&iorq->xy->dkb,
1892 iorq->blockno / iorq->xy->sectpercyl,
1893 (iorq->blockno / iorq->xy->nsect) % iorq->xy->nhead,
1894 iorq->blockno % iorq->xy->nsect)) != -1) {
1895 iorq->mode |= XY_MODE_B144; /* enter bad144 mode &
1899 iopb->cyl = (iorq->xy->ncyl + iorq->xy->acyl) - 2;
1901 i = iorq->xy->sectpercyl - 1 - i; /* follow bad144
1903 iopb->head = i / iorq->xy->nhead;
1904 iopb->sect = i % iorq->xy->nhead;
1914 if ((iorq->mode & XY_MODE_VERBO) && iorq->lasterror)
1915 xyc_perror(iorq, iopb, 1); /* inform of error state
1917 iorq->lasterror = errno;
1920 && iorq->tries < XYC_MAXTRIES) { /* retry? */
1921 iorq->tries++;
1922 iorq->errno = iopb->errno = iopb->done = iopb->errs = 0;