Lines Matching refs:xdcsc
121 xdcsc->nwait--; \
1331 struct xdc_softc *xdcsc = v; in xdcintr() local
1335 xdcsc->sc_intrcnt.ev_count++; in xdcintr()
1339 xdc_remove_iorq(xdcsc); in xdcintr()
1343 xdc_start(xdcsc, XDC_MAXIOPB); in xdcintr()
1347 while (xdcsc->nfree > 0 && bufq_peek(xdcsc->sc_wq) != NULL) in xdcintr()
1348 if (xdc_startbuf(xdcsc, NULL, NULL) != XD_ERR_AOK) in xdcintr()
1487 xdc_cmd(struct xdc_softc *xdcsc, int cmd, int subfn, int unit, int block, in xdc_cmd() argument
1497 while (xdcsc->nfree == 0) { in xdc_cmd()
1498 if (xdc_piodriver(xdcsc, 0, 1) != XD_ERR_AOK) in xdc_cmd()
1505 while (xdcsc->nfree == 0) { in xdc_cmd()
1506 if (tsleep(&xdcsc->nfree, PRIBIO, "xdnfree", 0)) in xdc_cmd()
1509 while (xdcsc->ndone > XDC_SUBWAITLIM) { in xdc_cmd()
1510 if (tsleep(&xdcsc->ndone, PRIBIO, "xdsubwait", 0)) in xdc_cmd()
1513 if (xdcsc->nfree) in xdc_cmd()
1520 if (xdcsc->nfree == 0) in xdc_cmd()
1522 rqno = XDC_RQALLOC(xdcsc); in xdc_cmd()
1523 iorq = &xdcsc->reqs[rqno]; in xdc_cmd()
1529 xdc_rqinit(iorq, xdcsc, in xdc_cmd()
1530 (unit == XDC_NOUNIT) ? NULL : xdcsc->sc_drives[unit], in xdc_cmd()
1539 xdc_submit_iorq(xdcsc, rqno, fullmode); /* error code will be in iorq */ in xdc_cmd()
1549 xdc_startbuf(struct xdc_softc *xdcsc, struct xd_softc *xdsc, struct buf *bp) in xdc_startbuf() argument
1558 if (!xdcsc->nfree) in xdc_startbuf()
1560 rqno = XDC_RQALLOC(xdcsc); in xdc_startbuf()
1561 iorq = &xdcsc->reqs[rqno]; in xdc_startbuf()
1567 bp = bufq_get(xdcsc->sc_wq); in xdc_startbuf()
1570 xdsc = xdcsc->sc_drives[DISKUNIT(bp->b_dev)]; in xdc_startbuf()
1591 error = bus_dmamap_load(xdcsc->dmatag, iorq->dmamap, in xdc_startbuf()
1594 aprint_error_dev(xdcsc->sc_dev, "warning: cannot load DMA map\n"); in xdc_startbuf()
1595 XDC_FREE(xdcsc, rqno); in xdc_startbuf()
1596 bufq_put(xdcsc->sc_wq, bp); in xdc_startbuf()
1600 bus_dmamap_sync(xdcsc->dmatag, iorq->dmamap, 0, in xdc_startbuf()
1606 xdc_rqinit(iorq, xdcsc, xdsc, XD_SUB_NORM | XD_MODE_VERBO, block, in xdc_startbuf()
1618 xdc_submit_iorq(xdcsc, rqno, XD_SUB_NORM); in xdc_startbuf()
1655 xdc_submit_iorq(struct xdc_softc *xdcsc, int iorqno, int type) in xdc_submit_iorq() argument
1658 struct xd_iorq *iorq = &xdcsc->reqs[iorqno]; in xdc_submit_iorq()
1661 printf("xdc_submit_iorq(%s, no=%d, type=%d)\n", device_xname(xdcsc->sc_dev), in xdc_submit_iorq()
1666 if (xdcsc->xdc->xdc_csr & XDC_ADDING) { in xdc_submit_iorq()
1672 XDC_TWAIT(xdcsc, iorqno); /* put at end of waitq */ in xdc_submit_iorq()
1682 return (xdc_piodriver(xdcsc, iorqno, 0)); in xdc_submit_iorq()
1692 device_xname(xdcsc->sc_dev), iorq - xdcsc->reqs); in xdc_submit_iorq()
1701 XDC_GO(xdcsc->xdc, iopbaddr); /* go! */ in xdc_submit_iorq()
1702 xdcsc->nrun++; in xdc_submit_iorq()
1714 return (xdc_piodriver(xdcsc, iorqno, 0)); in xdc_submit_iorq()
1732 xdc_piodriver(struct xdc_softc *xdcsc, int iorqno, int freeone) in xdc_piodriver() argument
1737 struct xdc *xdc = xdcsc->xdc; in xdc_piodriver()
1739 printf("xdc_piodriver(%s, %d, freeone=%d)\n", device_xname(xdcsc->sc_dev), in xdc_piodriver()
1743 while (xdcsc->nwait || xdcsc->nrun) { in xdc_piodriver()
1746 xdcsc->nwait, xdcsc->nrun); in xdc_piodriver()
1754 xdc_reset(xdcsc, 0, XD_RSET_ALL, XD_ERR_FAIL, 0); in xdc_piodriver()
1761 if (xdc_reset(xdcsc, 0, in xdc_piodriver()
1769 xdc_remove_iorq(xdcsc); /* could resubmit request */ in xdc_piodriver()
1771 if (xdcsc->nrun < XDC_MAXIOPB) { in xdc_piodriver()
1779 xdc_start(xdcsc, XDC_MAXIOPB); in xdc_piodriver()
1784 retval = xdcsc->reqs[iorqno].errnum; in xdc_piodriver()
1788 xdcsc->reqs[iorqno].errnum, xdc_e2str(xdcsc->reqs[iorqno].errnum)); in xdc_piodriver()
1794 while (xdcsc->nfree > 0 && bufq_peek(xdcsc->sc_wq) != NULL) in xdc_piodriver()
1795 if (xdc_startbuf(xdcsc, NULL, NULL) != XD_ERR_AOK) in xdc_piodriver()
1806 xdc_xdreset(struct xdc_softc *xdcsc, struct xd_softc *xdsc) in xdc_xdreset() argument
1811 memcpy(&tmpiopb, xdcsc->iopbase, sizeof(tmpiopb)); in xdc_xdreset()
1812 memset(xdcsc->iopbase, 0, sizeof(tmpiopb)); in xdc_xdreset()
1813 xdcsc->iopbase->comm = XDCMD_RST; in xdc_xdreset()
1814 xdcsc->iopbase->unit = xdsc->xd_drive; in xdc_xdreset()
1815 addr = (u_long) xdcsc->dvmaiopb; in xdc_xdreset()
1816 XDC_GO(xdcsc->xdc, addr); /* go! */ in xdc_xdreset()
1817 XDC_WAIT(xdcsc->xdc, del, XDC_RESETUSEC, XDC_REMIOPB); in xdc_xdreset()
1818 if (del <= 0 || xdcsc->iopbase->errs) { in xdc_xdreset()
1819 printf("%s: off-line: %s\n", device_xname(xdcsc->sc_dev), in xdc_xdreset()
1820 xdc_e2str(xdcsc->iopbase->errnum)); in xdc_xdreset()
1821 xdcsc->xdc->xdc_csr = XDC_RESET; in xdc_xdreset()
1822 XDC_WAIT(xdcsc->xdc, del, XDC_RESETUSEC, XDC_RESET); in xdc_xdreset()
1826 xdcsc->xdc->xdc_csr = XDC_CLRRIO; /* clear RIO */ in xdc_xdreset()
1828 memcpy(xdcsc->iopbase, &tmpiopb, sizeof(tmpiopb)); in xdc_xdreset()
1837 xdc_reset(struct xdc_softc *xdcsc, int quiet, int blastmode, int error, in xdc_reset() argument
1842 int oldfree = xdcsc->nfree; in xdc_reset()
1847 printf("%s: soft reset\n", device_xname(xdcsc->sc_dev)); in xdc_reset()
1848 xdcsc->xdc->xdc_csr = XDC_RESET; in xdc_reset()
1849 XDC_WAIT(xdcsc->xdc, del, XDC_RESETUSEC, XDC_RESET); in xdc_reset()
1855 xdc_xdreset(xdcsc, xdsc); in xdc_reset()
1860 register struct xd_iorq *iorq = &xdcsc->reqs[lcv]; in xdc_reset()
1868 xdcsc->nrun--; /* it isn't running any more */ in xdc_reset()
1872 xdcsc->iopbase[lcv].done = xdcsc->iopbase[lcv].errs = 1; in xdc_reset()
1873 switch (XD_STATE(xdcsc->reqs[lcv].mode)) { in xdc_reset()
1879 bus_dmamap_sync(xdcsc->dmatag, iorq->dmamap, 0, in xdc_reset()
1885 bus_dmamap_unload(xdcsc->dmatag, iorq->dmamap); in xdc_reset()
1887 disk_unbusy(&xdcsc->reqs[lcv].xd->sc_dk, in xdc_reset()
1888 (xdcsc->reqs[lcv].buf->b_bcount - in xdc_reset()
1889 xdcsc->reqs[lcv].buf->b_resid), in xdc_reset()
1892 XDC_FREE(xdcsc, lcv); /* add to free list */ in xdc_reset()
1897 xdcsc->ndone++; in xdc_reset()
1906 XDC_HWAIT(xdcsc, lcv); in xdc_reset()
1914 xdc_start(xdcsc, XDC_MAXIOPB); in xdc_reset()
1917 if (oldfree == 0 && xdcsc->nfree) in xdc_reset()
1918 wakeup(&xdcsc->nfree); in xdc_reset()
1921 del = xdcsc->nwait + xdcsc->nrun + xdcsc->nfree + xdcsc->ndone; in xdc_reset()
1924 device_xname(xdcsc->sc_dev), del, XDC_MAXIOPB); in xdc_reset()
1926 if (xdcsc->ndone > XDC_MAXIOPB - XDC_SUBWAITLIM) in xdc_reset()
1928 device_xname(xdcsc->sc_dev), xdcsc->ndone); in xdc_reset()
1938 xdc_start(struct xdc_softc *xdcsc, int maxio) in xdc_start() argument
1942 while (maxio && xdcsc->nwait && in xdc_start()
1943 (xdcsc->xdc->xdc_csr & XDC_ADDING) == 0) { in xdc_start()
1944 XDC_GET_WAITER(xdcsc, rqno); /* note: rqno is an "out" in xdc_start()
1946 if (xdc_submit_iorq(xdcsc, rqno, XD_SUB_NOQ) != XD_ERR_AOK) in xdc_start()
1956 xdc_remove_iorq(struct xdc_softc *xdcsc) in xdc_remove_iorq() argument
1959 struct xdc *xdc = xdcsc->xdc; in xdc_remove_iorq()
1971 aprint_error_dev(xdcsc->sc_dev, "fatal error 0x%02x: %s\n", in xdc_remove_iorq()
1973 if (xdc_reset(xdcsc, 0, XD_RSET_ALL, errnum, 0) != XD_ERR_AOK) { in xdc_remove_iorq()
1974 aprint_error_dev(xdcsc->sc_dev, "soft reset failed!\n"); in xdc_remove_iorq()
1998 iorq = &xdcsc->reqs[rqno]; in xdc_remove_iorq()
2001 iopb = &xdcsc->iopbase[rqno]; in xdc_remove_iorq()
2009 printf("%s: rio #%d [", device_xname(xdcsc->sc_dev), rqno); in xdc_remove_iorq()
2016 xdcsc->nrun--; in xdc_remove_iorq()
2029 xdc_error(xdcsc, iorq, iopb, rqno, comm) == XD_ERR_AOK) in xdc_remove_iorq()
2069 XDC_HWAIT(xdcsc, rqno); in xdc_remove_iorq()
2070 xdc_start(xdcsc, 1); /* resubmit */ in xdc_remove_iorq()
2085 bus_dmamap_sync(xdcsc->dmatag, iorq->dmamap, 0, in xdc_remove_iorq()
2090 bus_dmamap_unload(xdcsc->dmatag, iorq->dmamap); in xdc_remove_iorq()
2095 XDC_FREE(xdcsc, rqno); in xdc_remove_iorq()
2100 xdcsc->ndone++; in xdc_remove_iorq()
2105 xdcsc->ndone++; in xdc_remove_iorq()
2153 xdc_error(struct xdc_softc *xdcsc, struct xd_iorq *iorq, struct xd_iopb *iopb, in xdc_error() argument
2167 xdcsc->ndone++; in xdc_error()
2169 xdc_reset(xdcsc, 1, XD_RSET_NONE, errnum, iorq->xd); in xdc_error()
2171 xdcsc->ndone--; in xdc_error()
2194 XDC_HWAIT(xdcsc, rqno); in xdc_error()
2195 xdc_start(xdcsc, 1); /* resubmit */ in xdc_error()
2214 XDC_HWAIT(xdcsc, rqno); in xdc_error()
2215 xdc_start(xdcsc, 1); /* restart */ in xdc_error()
2230 struct xdc_softc *xdcsc = arg; in xdc_tick() local
2236 nwait = xdcsc->nwait; in xdc_tick()
2237 nrun = xdcsc->nrun; in xdc_tick()
2238 nfree = xdcsc->nfree; in xdc_tick()
2239 ndone = xdcsc->ndone; in xdc_tick()
2240 memcpy(wqc, xdcsc->waitq, sizeof(wqc)); in xdc_tick()
2241 memcpy(fqc, xdcsc->freereq, sizeof(fqc)); in xdc_tick()
2245 device_xname(xdcsc->sc_dev), nwait, nfree, nrun, ndone, in xdc_tick()
2265 lcv, xdcsc->reqs[lcv].mode, in xdc_tick()
2266 xdcsc->iopbase[lcv].done, in xdc_tick()
2267 xdcsc->iopbase[lcv].errs, in xdc_tick()
2268 xdcsc->iopbase[lcv].errnum, in xdc_tick()
2269 xdcsc->reqs[lcv].ttl, xdcsc->reqs[lcv].buf); in xdc_tick()
2274 device_xname(xdcsc->sc_dev), ndone); in xdc_tick()
2279 device_xname(xdcsc->sc_dev), in xdc_tick()
2280 xdcsc->xdc->xdc_csr, xdcsc->nwait, xdcsc->nfree, xdcsc->nrun, in xdc_tick()
2281 xdcsc->ndone); in xdc_tick()
2283 if (xdcsc->reqs[lcv].mode) in xdc_tick()
2286 xdcsc->reqs[lcv].mode, xdcsc->iopbase[lcv].done, in xdc_tick()
2287 xdcsc->iopbase[lcv].errs, xdcsc->iopbase[lcv].errnum); in xdc_tick()
2294 if (xdcsc->reqs[lcv].mode == 0 || in xdc_tick()
2295 XD_STATE(xdcsc->reqs[lcv].mode) == XD_SUB_DONE) in xdc_tick()
2297 xdcsc->reqs[lcv].ttl--; in xdc_tick()
2298 if (xdcsc->reqs[lcv].ttl == 0) in xdc_tick()
2302 printf("%s: watchdog timeout\n", device_xname(xdcsc->sc_dev)); in xdc_tick()
2303 xdc_reset(xdcsc, 0, XD_RSET_NONE, XD_ERR_FAIL, NULL); in xdc_tick()
2309 callout_reset(&xdcsc->sc_tick_ch, XDC_TICKCNT, xdc_tick, xdcsc); in xdc_tick()
2324 struct xdc_softc *xdcsc; in xdc_ioctlcmd() local
2406 xdcsc = xd->parent; in xdc_ioctlcmd()
2412 if ((error = xd_dmamem_alloc(xdcsc->dmatag, xdcsc->auxmap, in xdc_ioctlcmd()
2422 bus_dmamem_unmap(xdcsc->dmatag, buf, xio->dlen); in xdc_ioctlcmd()
2423 bus_dmamem_free(xdcsc->dmatag, &seg, rseg); in xdc_ioctlcmd()
2433 rqno = xdc_cmd(xdcsc, xio->cmd, xio->subfn, xd->xd_drive, xio->block, in xdc_ioctlcmd()
2439 xio->errnum = xdcsc->reqs[rqno].errnum; in xdc_ioctlcmd()
2440 xio->tries = xdcsc->reqs[rqno].tries; in xdc_ioctlcmd()
2441 XDC_DONE(xdcsc, rqno, dummy); in xdc_ioctlcmd()
2450 xd_dmamem_free(xdcsc->dmatag, xdcsc->auxmap, &seg, rseg, in xdc_ioctlcmd()