From owner-freebsd-scsi Mon Apr 20 06:37:22 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id GAA20285 for freebsd-scsi-outgoing; Mon, 20 Apr 1998 06:37:22 -0700 (PDT) (envelope-from owner-freebsd-scsi@FreeBSD.ORG) Received: from spinner.netplex.com.au (spinner.netplex.com.au [202.12.86.3]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id NAA20202; Mon, 20 Apr 1998 13:36:56 GMT (envelope-from peter@netplex.com.au) Received: from spinner.netplex.com.au (localhost [127.0.0.1]) by spinner.netplex.com.au (8.8.8/8.8.8/Spinner) with ESMTP id VAA04663; Mon, 20 Apr 1998 21:36:42 +0800 (WST) (envelope-from peter@spinner.netplex.com.au) Message-Id: <199804201336.VAA04663@spinner.netplex.com.au> X-Mailer: exmh version 2.0.2 2/24/98 To: gibbs@FreeBSD.ORG cc: scsi@FreeBSD.ORG Subject: New CAM w/ buslogic doesn't do bounce buffers correctly.. Date: Mon, 20 Apr 1998 21:36:41 +0800 From: Peter Wemm Sender: owner-freebsd-scsi@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org It seems that when bt_ccb's are allocated, the dmamap pointer isn't initialized, so it stays null. This causes a few things to hit a fatal trap at first call since map == NULL isn't checked in a few critical places (bus_dmamap_load for starters). add_bounce_page() doesn;'t work if the map = NULL -> map = &nobounce_dmamap conversion happens since the bpages SLIST isn't initialized there either. dev/buslogic/bt.c: segs = sg_map->sg_vaddr; physaddr = sg_map->sg_physaddr; newcount = (PAGE_SIZE / (BT_NSEG * sizeof(bt_sg_t))); for (i = 0; bt->num_ccbs < bt->max_ccbs && i < newcount; i++) { next_ccb->sg_list = segs; next_ccb->sg_list_phys = physaddr; next_ccb->flags = BCCB_FREE; >> what about next_ccb->dmamap?? SLIST_INSERT_HEAD(&bt->free_bt_ccbs, next_ccb, links); segs += BT_NSEG; physaddr += (BT_NSEG * sizeof(bt_sg_t)); next_ccb++; bt->num_ccbs++; } At a guess, it should be set pointing to the instance of the containing page's sg->sg_dmamap. so, perhaps + new_ccb->dmamap = sg->sg_dmamap? And then there's this: int bus_dmamap_load(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf, bus_size_t buflen, bus_dmamap_callback_t *callback, void *callback_arg, int flags) { [..] if (dmat->lowaddr < ptoa(Maxmem) && map->pagesneeded == 0) { [..] } if (map == NULL) map = &nobounce_dmamap; [later] do { [..] if (map->pagesneeded != 0 && run_filter(dmat, paddr)) { paddr = add_bounce_page(dmat, map, vaddr, size); } [..] And add_bounce_page() does: [..] bpage->datavaddr = vaddr; bpage->datacount = size; STAILQ_INSERT_TAIL(&(map->bpages), bpage, links); return (bpage->busaddr); } In the instance where map = &nobounce_dmamap, the STAILQ_INSERT_TAIL() faults since the bpages list is never intialised. If the map = NULL stuff isn't really needed (or I'm sure the bus_dmamap_load stuff would have been noticed by now :-), then perhaps it's just some bit-rot that needs to be trimmed. Cheers, -Peter -- Peter Wemm Netplex Consulting To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-scsi" in the body of the message