Index: [thread] [date] [subject] [author]
  From: Jon M. Taylor <taylorj@gaia.ecs.csus.edu>
  To  : ggi-develop@eskimo.com
  Date: Tue, 8 Jun 1999 17:30:39 -0700 (PDT)

Re: Linux memory-mapping problem

On Tue, 8 Jun 1999, Marcus Sundberg wrote:

> Jon M. Taylor wrote:
> > 
> >         I'm having a very strange linux kernel related problem and I'm hoping
> > that someone here (Marcus in particular) might have some insight.  If not
> > I'll ask elsewhere.  The problem is that I cannot use remap_page_range() to
> > implement the mmap() function on a file so that I can map auxiliary hardware
> > buffers (z-buffer, textures, etc) into userspace.  I have tried implementing
> > this alternate mmap() system as an extension of fbcon-kgi.c's kgifb_mmap() as
> > well as implementing it as a separate function, but no matter what
> > contortions I put the code through I always see the same behavior.
> 
> Unfortunately I have no idea about this. I still haven't figured out why
> the GC mapping doesn't work when don't using USE_VMOPS...

	OK, I have (mostly) fixed my problem, which was caused by using the
MAP_PRIVATE flag in the mmap() call, which causes the kernel to implement a
shared copy-on-write mapping over the region in question.  Obviously this
cannot work for a region which is mapped to a physical I/O address 
space.  Using the MAP_SHARED flag instead fixed the problem.

	Marcus, I think that your GC mapping also falls victim to this
because you use _get_free_page() to allocate the GC, which also maps directly
to a physical I/O region.  I notice that your nopage() handler manually
increments the page useage count - a similar manual page-by-page PTE
constructor is necessary for multiple-page mappings, which can be seen by
examining drivers/video/sbusfb.c and drivers/char/bttv.c.

	Now, it is obviously not acceptable to allow userspace to trigger
that 'bogus page' error in the kernel, so I will have to think about how to
gracefully fail when userspace code uses the MAP_PRIVATE flag.  I may just
lock the aux-buffers on a per-process basis, since it is unlikely that
separate processes will ever be hitting the LFB and the aux-buffers at the
same time....

Jon

---
'Cloning and the reprogramming of DNA is the first serious step in 
becoming one with God.'
	- Scientist G. Richard Seed

Index: [thread] [date] [subject] [author]