Lines Matching defs:xdcsc

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