Subject: pci_mapreg_map and LKM
To: None <tech-kern@NetBSD.org>
From: Ken Roberts <almostmtb@yahoo.com>
List: tech-kern
Date: 09/04/2007 04:58:04
I have a driver for a PCI device implemented in an LKM. I can load and
unload the module, and the driver seems to function properly until I
attempt to unload/load it for the fourth time. When I do this, the second
call to pci_mapreg_map() seems to fail in such a way that it never
returns,
and I have to reset the CPU to clear the problem. Here's the code snippet
that runs as part of the attach function:
if ( pci_mapreg_map(pa, PDX_PCI_BAR0, PCI_MAPREG_MEM_TYPE_32BIT,
0, &sc->pcit, &sc->pcih, &sc->pciaddress, &sc->pcisize) != 0 )
{
PDXLOG(LOG_CRIT,
"%s: unable to map internal pci space\n",
sc->device.dv_xname);
return;
}
if ( pci_mapreg_map(pa, PDX_PCI_BAR1, PCI_MAPREG_MEM_TYPE_32BIT,
0, &sc->memt, &sc->memh, &sc->memaddress, &sc->memsize) != 0 )
{
PDXLOG(LOG_INFO,
"%s: error mapping device register space\n",
sc->device.dv_xname);
return;
}
And here's the code that runs when I detach:
if ( sc->memsize )
{
bus_space_unmap(sc->memt, sc->memh, sc->memsize);
}
if ( sc->pcisize )
{
bus_space_unmap(sc->pcit, sc->pcih, sc->pcisize);
}
I'm hoping that someone can point me in the right direction here. Am I
missing something obvious?
Thanks,
Ken
____________________________________________________________________________________
Yahoo! oneSearch: Finally, mobile search
that gives answers, not web links.
http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC