* Question on Au1550 ...
@ 2004-10-18 12:01 Alexey Shinkin
2004-10-18 12:26 ` Ladislav Michl
2004-10-18 16:09 ` Dan Malek
0 siblings, 2 replies; 3+ messages in thread
From: Alexey Shinkin @ 2004-10-18 12:01 UTC (permalink / raw)
To: linux-mips
Hi , All !
I am porting a linux driver for PCI device and some applications form x86
platform to AMD Au1550 MIPS , running MontaVista Linux 2.4.20-mvl31.1550.
I got the following problem :
The driver allocates some memory (SharedMemory) for communication with PCI
card , using function pci_alloc_consistent(). PCI card can write to this
memory using DMA . On kernel level driver correctly reads values, written
by the board , and the board correctly reads values, written by driver.
The goal is to make this memoty visible from user level application. The
following approach is used on õ86 and works :
1. Application calls mmap( 0, Size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0
) ;
2. driver implements mmap() function that just prepares some vma
structure fields for nopage operetions :
vma->vm_flags |= VM_RESERVED; // no swapping
vma->vm_ops = &device_vmops; // contains nopage func
vma->vm_file = filp;
3. Application gets pointer and accesses all mapped pages (reads a byte
from each page) - this causes call of nopage function in driver .
The nopage function calculates VirtualAddress from SharedMemory address
(received after pci_alloc_consistent()),
then does KernelPage= virt_to_page(VirtualAddress) ,
get_page(KernelPage)
and returns KernelPage.
4. Now Application reads from SharedMemory , using a pointer , given by
mmap() .
This works fine on x86 platform , but on MIPS application cannot see
expected contents of the memory - it reads garbage .
What I have tried :
- to insert vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot)
in drivers implementation of mmap() ;
- to use remap_page_range() instead of vm_ops .
Result is the same application reads garbage . If application write some
values into the memory - it reads garbage . The values written by
application are not seen from kernel level .
I am new to MIPS so maybe I missed something obvious ? Is this right
approach on this platform at all ?
Thank you in advance!
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.com/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Question on Au1550 ...
2004-10-18 12:01 Question on Au1550 Alexey Shinkin
@ 2004-10-18 12:26 ` Ladislav Michl
2004-10-18 16:09 ` Dan Malek
1 sibling, 0 replies; 3+ messages in thread
From: Ladislav Michl @ 2004-10-18 12:26 UTC (permalink / raw)
To: Alexey Shinkin; +Cc: linux-mips
On Mon, Oct 18, 2004 at 07:01:30PM +0700, Alexey Shinkin wrote:
[snip]
> What I have tried :
> - to insert vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot)
> in driver?s implementation of mmap() ;
> - to use remap_page_range() instead of vm_ops .
Did you SetPageReserved bit?
ladis
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Question on Au1550 ...
2004-10-18 12:01 Question on Au1550 Alexey Shinkin
2004-10-18 12:26 ` Ladislav Michl
@ 2004-10-18 16:09 ` Dan Malek
1 sibling, 0 replies; 3+ messages in thread
From: Dan Malek @ 2004-10-18 16:09 UTC (permalink / raw)
To: Alexey Shinkin; +Cc: linux-mips
On Oct 18, 2004, at 8:01 AM, Alexey Shinkin wrote:
> The goal is to make this memoty visible from user level application.
> The following approach is used on õ86 and works :
I'm kinda surprised it works anywhere. You have taken a rather complex
approach to achieving your results.
> - to use remap_page_range() instead of vm_ops .
This is all you should have to do. Use the physical (dma_addr_t)
address
returned from pci_alloc_consistent() as the 'offset' parameter, use the
VMA
allocated and provided to you, call remap_page_range() and you are done.
An alternative is to have an ioctl() in your driver that returns the
physical
address of the buffer (as provided by pci_alloc_consistent()), then use
/dev/mem to do the mmap(). The only problem with this is coordination
with your driver, you have to ensure you release the /dev/mem mmap
in your application when the driver also does the same for the dma
buffer space.
-- Dan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-10-18 16:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-18 12:01 Question on Au1550 Alexey Shinkin
2004-10-18 12:26 ` Ladislav Michl
2004-10-18 16:09 ` Dan Malek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox