* troubles mmaping PCI device on Au1550
@ 2005-04-10 22:16 Clem Taylor
2005-04-10 22:16 ` Clem Taylor
2005-04-12 15:22 ` Dan Malek
0 siblings, 2 replies; 5+ messages in thread
From: Clem Taylor @ 2005-04-10 22:16 UTC (permalink / raw)
To: linux-mips
I'm working on a Au1550 driver for a PCI based co-processor. The
processor exports a 4Mbyte BAR that I want to mmap() into user space.
From inside the driver I can read and write to the BAR using an
address from ioremap_nocache(). I can read location with known values
and get back the expected data and with JTAG on the co-processor I saw
that data written from the 1550 really makes it into the PCI device.
From userspace with the llseek/read interface I can read the data well
known data and the data written by the driver.
However, I'm not having any luck getting mmap() to work. I must just
be mapping the wrong address... I tried a bunch of different
combinations of addresses, but so far I haven't had any luck getting
the mmap() to work.
The mmap() handler calls remap_pfn_range with a physical address
returned from pci_resource_start().
My driver code has something like:
remap_pfn_range ( vma, vma->vm_start,
( pci_resource_start ( pdev, BAR ) >> PAGE_SHIFT ) + vma->pgoff,
vma->vm_end - vma->vm_start, vma->vm_page_prot );
vma->pgoff is zero, so this should map starting at the beginning of
the BAR. From user space, the data at the mmap()ed address isn't what
I was expecting.
For a sanity check, I tried using /dev/mem to mmap the PCI address as
returned by lspci. This seems to return similar, but not identical
data as my device driver. But it isn't what I was expecting.
I tried a similar test using /dev/mem and the address the linear
framebuffer on my desktop machine (as returned by lspci). The mapped
data matches the pixels on the first line (as reported by xmag).
Has anyone tried something like this on the Alchemy processors with a
recent kernel?
Many thanks,
Clem Taylor
^ permalink raw reply [flat|nested] 5+ messages in thread
* troubles mmaping PCI device on Au1550
2005-04-10 22:16 troubles mmaping PCI device on Au1550 Clem Taylor
@ 2005-04-10 22:16 ` Clem Taylor
2005-04-12 15:22 ` Dan Malek
1 sibling, 0 replies; 5+ messages in thread
From: Clem Taylor @ 2005-04-10 22:16 UTC (permalink / raw)
To: linux-mips
I'm working on a Au1550 driver for a PCI based co-processor. The
processor exports a 4Mbyte BAR that I want to mmap() into user space.
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: troubles mmaping PCI device on Au1550
[not found] <20050410230001Z8226002-1340+5508@linux-mips.org>
@ 2005-04-11 4:08 ` Alexey Shinkin
0 siblings, 0 replies; 5+ messages in thread
From: Alexey Shinkin @ 2005-04-11 4:08 UTC (permalink / raw)
To: linux-mips
>Has anyone tried something like this on the Alchemy processors with a
>recent kernel?
>
> Many thanks,
> Clem Taylor
Hi !
Something like this works on Au1550 with montavista kernel 2.4.20 . Dont
know about more recent...
I use the followinng in drivers' mmap() :
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
remap_page_range(... , vma->vm_page_prot)
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: troubles mmaping PCI device on Au1550
2005-04-10 22:16 troubles mmaping PCI device on Au1550 Clem Taylor
2005-04-10 22:16 ` Clem Taylor
@ 2005-04-12 15:22 ` Dan Malek
2005-04-12 20:56 ` Clem Taylor
1 sibling, 1 reply; 5+ messages in thread
From: Dan Malek @ 2005-04-12 15:22 UTC (permalink / raw)
To: Clem Taylor; +Cc: linux-mips
On Apr 10, 2005, at 6:16 PM, Clem Taylor wrote:
> My driver code has something like:
> remap_pfn_range ( vma, vma->vm_start,
> ( pci_resource_start ( pdev, BAR ) >> PAGE_SHIFT ) + vma->pgoff,
> vma->vm_end - vma->vm_start, vma->vm_page_prot );
The Au15xx uses 36-bit addressing for the PCI (among other) physical
addresses. The mmap() in your driver is the right thing, but you need
to use io_remap_page_range() where the 2nd parameter is a phys_t.
Your offset should be a phys_t type, and pci_resource_start() also
returns a phys_t.
> I tried a similar test using /dev/mem and the address the linear
> framebuffer on my desktop machine (as returned by lspci).
You can't use /dev/mem for this on Au15xx because it doesn't have
provisions for more than 32-bit addresses. Be careful with lspci,
as it only returns the 32-bit BAR, not the 36-bit Au15xx address nor
the 32-bit ioremapped address.
Thanks.
-- Dan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: troubles mmaping PCI device on Au1550
2005-04-12 15:22 ` Dan Malek
@ 2005-04-12 20:56 ` Clem Taylor
0 siblings, 0 replies; 5+ messages in thread
From: Clem Taylor @ 2005-04-12 20:56 UTC (permalink / raw)
To: linux-mips
On Apr 12, 2005 11:22 AM, Dan Malek <dan@embeddedalley.com> wrote:
> The Au15xx uses 36-bit addressing for the PCI (among other) physical
> addresses. The mmap() in your driver is the right thing, but you need
> to use io_remap_page_range() where the 2nd parameter is a phys_t.
> Your offset should be a phys_t type, and pci_resource_start() also
> returns a phys_t.
Yeah, this was exactly my problem. Last night I managed to find the
comment about this in au1000.h. Now I can happily mmap() the PCI
devices memory. Thanks!
--Clem
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-04-12 20:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-10 22:16 troubles mmaping PCI device on Au1550 Clem Taylor
2005-04-10 22:16 ` Clem Taylor
2005-04-12 15:22 ` Dan Malek
2005-04-12 20:56 ` Clem Taylor
[not found] <20050410230001Z8226002-1340+5508@linux-mips.org>
2005-04-11 4:08 ` Alexey Shinkin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox