Subject: sparse vs. dense pci space
To: None <port-alpha@NetBSD.ORG>
From: Andrew Gallatin <>
List: port-alpha
Date: 12/13/1997 20:05:35
I'm attempting to get my 3rd-party Myrinet device driver going under

I last had it working in a -current source tree dated late spring or
early summer.  Since then, it looks like external access to
pci_mem_find() has been revoked.  So, I went about changing my pci
attach function to use pci_mapreg_map().  I ended up panic'ing when
attempting to read from the memory mapped area returned to me by

I eventually turned on extent debugging in
arch/alpha/pci/cia_swiz_bus_mem.c From the output of the debugging
printfs in pci_swiz_bus_mem_chipdep.c, it looks like I'm getting back
a handle for a sparse address.  The problem is that I need a
dense-space address.  I came up with a gross workaround to force
bus_space_map to give me back the sort of address I can use.  Doing
what I'm doing right now strikes me as wrong; can somebody offer a
suggestion as to how I should approach this?  Since there isn't a way
to specify dense/sparse, I think I must be doing something wrong.

To clarify, here's code snippets from my attach function, and some
of the printfs from arch/alpha/pci/cia_swiz_bus_mem.c 
(running on a AS600/266).

What I used to do:

    if (pci_mem_find(pa->pa_pc, pa->pa_tag, 0x10, &regbase, 
		     &regsize, &cacheable))
    if (bus_space_map(sc->myri_bustag, regbase, regsize, cacheable, 

What I think I should be able to do:

   if (pci_mapreg_map(pa, 0x10, PCI_MAPREG_TYPE_MEM, 0, 
		       &sc->myri_bustag, &sc->myri_bushandle,
		       &regbase, &regsize)) {
	    printf(": can't map registers\n");

What I'm doing right now:

    if (pci_mapreg_info(pa->pa_pc, pa->pa_tag, 0x10, PCI_MAPREG_TYPE_MEM, 
			&regbase, &regsize, &cacheable))

    if (bus_space_map(sc->myri_bustag, regbase, regsize, cacheable|BUS_SPACE_MAP_CACHEABLE, 

An example of the faulting read:

	mb = (struct MYRINET_BOARD *)sc->myri_bushandle;
	sc->myri_eeprom = (struct MYRINET_EEPROM *)&mb->lanai_eeprom[0];

The dense & sparce extents that were printed out from extent_print():

	extent `cia_swiz_bus_dmem' (0x0 - 0xffffffffffffffff), flags = 0x1
	     0x100000000 - 0xfffffffffffffffe

	extent `cia_swiz_bus_smem' (0x0 - 0xffffffffffffffff), flags = 0x1
	     0x4000000 - 0x7fffffff
	     0xa8000000 - 0xfffffffffffffffe

The value of the sparse handle I was getting back before my
	regbase = 0x82000000
	sc->myri_bushandle = 0x7ffffe402000000

And after:
	regbase = 0x82000000
	sc->myri_bushandle = 0x7ffffe402000000
	sc->myri_bushandle = 0xfffffc8682000000


Andrew Gallatin, Sr Systems Programmer
Duke University				Email:
Department of Computer Science		Phone: (919) 660-6590