Subject: RE: uvm_mmap.c 1.47
To: None <thorpej@zembu.com>
From: Andrew van der Stock <ajv@greebo.net>
List: tech-kern
Date: 01/12/2001 13:41:45
Just a data point:

I'm having problems with mmap'ing video memory on the Alpha using NetBSD-1.5
(GENERIC) and XFree86 4.0.2 with Simon's patches. Simon is similarly having
troubles and is probably using a more recent kernel than me, although I am
unclear on what Simon is trying to mmap().

My output errors:

(--) MGA(0): Linear framebuffer at 0x88000000
(--) MGA(0): MMIO registers at 0x80000000
(--) MGA(0): BIOS at 0x82010000
(WW) checkDevMem: failed to open /dev/mem (Operation not permitted)
	linear framebuffer access unavailable
(WW) MGA(0): Video BIOS info block not detected!
(II) MGA(0): MGABios.RamdacType = 0x0
(II) Machine needs sparse mapping

Fatal server error:
xf86MapVidMem: Could not mmap framebuffer (Bad file descriptor)

The first mmap code that fails is in checkDevMem(): (DEV_MEM is /dev/mem,
and I was running as root)

     if ((fd = open(DEV_MEM, O_RDWR)) >= 0)
        {
            /* Try to map a page at the VGA address */
            base = mmap((caddr_t)0, 4096, PROT_READ|PROT_WRITE,
                                 MAP_FLAGS, fd, (off_t)0xA0000 + BUS_BASE);

The second mmap failures are in mapVidMemSparse():

      memBase = mmap((caddr_t)0, 0x100000000,
                     PROT_READ | PROT_WRITE,
                     MAP_SHARED, devMemFd,
                     (off_t) BUS_BASE);
      memSBase = mmap((caddr_t)0, 0x100000000,
                      PROT_READ | PROT_WRITE,
                      MAP_SHARED, devMemFd,
                      (off_t) BUS_BASE_BWX);

      if (memSBase == MAP_FAILED || memBase == MAP_FAILED)      {
        FatalError("xf86MapVidMem: Could not mmap framebuffer (%s)\n",
                   strerror(errno));

The permissions for /dev/mem are stock 1.5 for me:

crw-r-----  1 root  kmem  2, 0 Jan 10 22:10 /dev/mem

Willing to contribute diffs (which are 25 kb) to 4.0.2 to you for testing.
Otherwise, it's 70 MB tarball.

Andrew

-----Original Message-----
From: tech-kern-owner@netbsd.org [mailto:tech-kern-owner@netbsd.org]On
Behalf Of Jason R Thorpe
Sent: Monday, 8 January 2001 07:34
To: Todd Vierling
Cc: Charles M. Hannum; tech-kern@netbsd.org
Subject: Re: uvm_mmap.c 1.47


On Sun, Jan 07, 2001 at 03:14:48PM -0500, Todd Vierling wrote:

 > Perhaps the syscall should be versioned?

Uh, no.

I'll look at it again as soon as I get some other things finished today.

--
        -- Jason R. Thorpe <thorpej@zembu.com>