Subject: problem with DMA driver (vm race?)
To: None <tech-kern@NetBSD.ORG, port-i386@NetBSD.ORG>
From: Matthias Drochner <drochner@zelux6.zel.kfa-juelich.de>
List: tech-kern
Date: 06/24/1996 16:39:23
I encountered a strange problem in a driver for a
homegrown PCI card:

The card (CAMAC controller) does DMA. For sake of
latency, I do the transfer directly into the user buffer.
(not mapped into kernel space - vmapbuf() causes too much
overhead)
The driver function is laid out as follows:

while(todo>0){
	len=min(64k, todo)
	vslock(buf, len)
	s=splbio()
	[start DMA]
	res=tsleep()
	splx(s)
	[error handling for res]
	vsunlock(buf, len, 1)
	todo-=len
	buf+=len
}

If the machine is heavily loaded (esp. process creation) the
"vsunlock()" occasionaly causes a panic in "vm_fault_unwire()":
"unwire: page not in pmap". The reason is (I checked it explicitely
before calling "vsunlock()") that the page directory entry for
the user buffer became zero in the meantime.
(The check tests
vm_map_pmap(&curproc->p_vmspace->vm_map)->pm_pdir[((vm_offset_t)(buf) >>
PDSHIFT)&1023]
)
The system is NetBSD-1.1.

Can anybody explain this?

best regards
Matthias Drochner