Re: Problem mapping small PCI memory space.

From: Richard B. Johnson (linux-os_at_analogic.com)
Date: 05/19/05

  • Next message: Chris Friesen: "Re: Thread and process dentifiers (CPU affinity, kill)"
    Date:	Thu, 19 May 2005 15:43:21 -0400 (EDT)
    To: Gianluca Varenni <gianluca.varenni@gmail.com>
    
    

    On Thu, 19 May 2005, Gianluca Varenni wrote:

    > Hi all.
    >
    > I'm writing a driver for a PCI board that exposes two memory spaces (out of
    > the 6 IO address regions).
    >
    > One of them is 1MB, and I can map it to user level without problems. The
    > other one is only 512 bytes.
    > If I try to open it with /dev/mem, it returns EINVAL (the 1MB memory space
    > is opened without any problem). If I try to expose it through mmap, mmap
    > succeeds, but I only see garbage at user level. At kernel level, I can
    > access that 512 bytes memory by using ioremap() on the physical address
    > returned by pci_resource_start().
    >
    > Are there any lower limits on the size of a PCI memory region?
    >
    > Have a nice day
    > GV
    >

    You impliment mmap() in your driver. It accesses the first megabyte
    as 256 pages. Then you tack on the additional page that your 512
    bytes resides at. mmap() only works with pages. The pages must
    be ioremap_nocache and they must be reserved. The reserved part
    is important to have them visible from user-space using mmap.

    That's IFF you really need to see the stuff in user-mode. Normally,
    you write a driver that accesses everything using the PCI primatives
    provided in the kernel, for the kernel.

    Cheers,
    *** Johnson
    Penguin : Linux version 2.6.11.9 on an i686 machine (5537.79 BogoMips).
      Notice : All mail here is now cached for review by Dictator Bush.
                      98.36% of all statistics are fiction.
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/


  • Next message: Chris Friesen: "Re: Thread and process dentifiers (CPU affinity, kill)"