mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Armin Schindler <armin@melware.de>
To: Linux Kernel Mailinglist <linux-kernel@vger.kernel.org>
Subject: Re: Map PCI resource to user space problem.
Date: Mon, 20 Jun 2011 18:38:20 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.00.1106201830260.17005@justus.melware.de> (raw)
In-Reply-To: <alpine.DEB.2.00.1106201132170.14886@justus.melware.de>

On Mon, 20 Jun 2011, Armin Schindler wrote:
> Hello,
>
> when I try to map PCI resource of size < PAGE_SIZE to user space
> with e.g. remap_pfn_range() the mapping seems to be created,
> but the access to the PCI device just doesn't work (read returns 0xff).
>
> The same happens when using sysfs. The device has
> # ls -al /sys/bus/pci/devices/0000\:02\:09.0/resource*
> -rw------- 1 root root     512 Jun 20 11:33 
> /sys/bus/pci/devices/0000:02:09.0/resource0
> -rw------- 1 root root     256 Jun 20 11:33 
> /sys/bus/pci/devices/0000:02:09.0/resource1
> -rw------- 1 root root 8388608 Jun 20 11:33 
> /sys/bus/pci/devices/0000:02:09.0/resource2
> -rw------- 1 root root  262144 Jun 20 11:33 
> /sys/bus/pci/devices/0000:02:09.0/resource3
>
> and when I mmap() resource0, a valid address is returned, but reading the 
> area always returns 0xff.
>
> Since a kernel driver can access resource0 here without problems when using
> ioremap(), I'm not sure what is wrong with the sysfs entry for user space
> (or using remap_pfn_range() in own mmap function).
> The only hint I have so far is the size, which is smaller than PAGE_SIZE.

I found the reason. It is not the size of the resource.
The resource0 is assigned to a not page-aligned address.
Example, the pci resource0 has address 0xfe5ffc00. mmap()ing it will
actually seems to map address 0xfe5ff000 and the user needs to add 0xc00 to 
the address returned by mmap().

Armin


  reply	other threads:[~2011-06-20 16:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-20  9:45 Armin Schindler
2011-06-20 16:38 ` Armin Schindler [this message]
2011-06-20 16:41   ` Bjorn Helgaas
2011-06-21 12:23     ` Matthew Wilcox
2011-06-21 13:20       ` Armin Schindler

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=alpine.DEB.2.00.1106201830260.17005@justus.melware.de \
    --to=armin@melware.de \
    --cc=linux-kernel@vger.kernel.org \
    /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®