mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Gianluca Varenni" <gianluca.varenni@gmail.com>
To: <linux-os@analogic.com>
Cc: "Linux kernel" <linux-kernel@vger.kernel.org>
Subject: Re: Problem mapping small PCI memory space.
Date: Thu, 19 May 2005 13:28:51 -0700	[thread overview]
Message-ID: <039001c55cb1$5f7ad760$1a4da8c0@NELSON2> (raw)
In-Reply-To: <Pine.LNX.4.61.0505191533590.2987@chaos.analogic.com>


----- Original Message ----- 
From: "Richard B. Johnson" <linux-os@analogic.com>
To: "Gianluca Varenni" <gianluca.varenni@gmail.com>
Cc: "Linux kernel" <linux-kernel@vger.kernel.org>
Sent: Thursday, May 19, 2005 12:43 PM
Subject: Re: Problem mapping small PCI memory space.


> 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.

Do you have any link to a linux driver working exactly like this?

Have a nice day
GV

>
>
> Cheers,
> Dick 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. 


  reply	other threads:[~2005-05-19 20:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-19 19:03 Gianluca Varenni
2005-05-19 19:43 ` Richard B. Johnson
2005-05-19 20:28   ` Gianluca Varenni [this message]
2005-05-21  0:17   ` Benjamin Herrenschmidt
2005-05-21  1:09     ` Gianluca Varenni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='039001c55cb1$5f7ad760$1a4da8c0@NELSON2' \
    --to=gianluca.varenni@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-os@analogic.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®