> Wait a minute. For me a 'kernel lock' is not acquired by the application
> directly at its initiative. It is used _inside_ the kernel between various
> parts of the kernel.
> So, in fact, I wonder if it's possible to put a kernel lock on the fb-area
> (the resource is the card memory) that can be used to enforce mutual
> exclusion between the hw accel _driver_ and the memory mapping mechanism.

No. 

> Understand that I have little understanding of how memory mapping works
> especially in linux. 

Well I joined the linux MM group to learn about the linux memory
management system. I have alot about how VM and that works. The only part
I don't understand all the way is how swap is delt with.  

> More precisely, is there any kernel code executed
> when an user-process writes in a memory mapped area or is it directly
> handled by the MMU hardware?

No. Think about it. How bad would preformace be if the kernel had to step
in when a application writes or reads from memory. Very bad. The kernel
only handles CPU <-> memory interacts. For example the kernel touches
memory when you access a page not in the TBLs of a CPU. Then the
page is loaded into the TBL which makes it ready for access. The kernel
handles other things like setting or changing the protection on pages. 

> If everything is handled directly by the MMU, then I guess you are
> right and we have no mean of control. Once we have accepted to
> memory map the fb into the userspace process adress space the only
> way to prevent it (even temporarily) to access this area is to
> unmap everything.

Yeap. The kernel has no control. But thats not the only way to control
access. It is possible to manipulate the schedular function to sync up
processes that access the video card.
 
> However, it seems to me that, for such memory mapping, some code
> may be executed sometimes in the kernel, no ? Modern hardware is
> so intelligent today that it can move pages between virtual
> memory and a PCI device alone without any kernel intervention?

Not on a PC. A Sparc works that way with the sbus. Thats why if you look
at fbcon their are special seperate mmap routines for sbus based cards. 

Reply via email to