Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Apr 1998 21:36:41 +0800
From:      Peter Wemm <peter@netplex.com.au>
To:        gibbs@FreeBSD.ORG
Cc:        scsi@FreeBSD.ORG
Subject:   New CAM w/ buslogic doesn't do bounce buffers correctly..
Message-ID:  <199804201336.VAA04663@spinner.netplex.com.au>

next in thread | raw e-mail | index | archive | help
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 <peter@netplex.com.au>   Netplex Consulting



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-scsi" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199804201336.VAA04663>