public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: Problem with remap_page_range
  2003-09-10  1:13 Problem with remap_page_range Dmytro Bablinyuk
@ 2003-09-09  9:59 ` Jamie Lokier
  2003-09-09 17:03   ` Matt Porter
  2003-09-10  2:19   ` Dmytro Bablinyuk
  2003-09-09 17:02 ` Matt Porter
  1 sibling, 2 replies; 7+ messages in thread
From: Jamie Lokier @ 2003-09-09  9:59 UTC (permalink / raw)
  To: Dmytro Bablinyuk; +Cc: linux-kernel

Dmytro Bablinyuk wrote:
>  if (remap_page_range(vma->vm_start,

Try io_remap_page_range() instead?

-- Jamie

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Problem with remap_page_range
  2003-09-10  1:13 Problem with remap_page_range Dmytro Bablinyuk
  2003-09-09  9:59 ` Jamie Lokier
@ 2003-09-09 17:02 ` Matt Porter
  2003-09-09 21:54   ` Dmytro Bablinyuk
  1 sibling, 1 reply; 7+ messages in thread
From: Matt Porter @ 2003-09-09 17:02 UTC (permalink / raw)
  To: Dmytro Bablinyuk; +Cc: linux-kernel

On Tue, Sep 09, 2003 at 09:13:49PM -0400, Dmytro Bablinyuk wrote:
> 
> We have a DSP shared memory which we should access (from PowerPC).
> The problem is when I do ioremap I can see the memory correctly from the 
> driver (see below) but when I do remap_page_range to the user space 
> application then data appears to be wrong, I can recognize some values 
> there, but they are in the wrong places and other values around from 
> everywhere else (see below).

<snip>

>   if (remap_page_range(vma->vm_start,
>                        DSP_ADDR,
>                        size,
>                        vma->vm_page_prot
>                        ))

Your remap call isn't adding _PAGE_NO_CACHE and _PAGE_GUARDED flags
like ioremap_nocache()/ioremap() do on PPC.  You'll get bad results
because of the ordering and cache issues resulting from not using
these PTE flags.  In 2.6, these can be added using pgprot_noncached()
that is defined per-arch.

BTW, ioremap_nocache() and ioremap() are identical on PPC.

-Matt

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Problem with remap_page_range
  2003-09-09  9:59 ` Jamie Lokier
@ 2003-09-09 17:03   ` Matt Porter
  2003-09-10  2:19   ` Dmytro Bablinyuk
  1 sibling, 0 replies; 7+ messages in thread
From: Matt Porter @ 2003-09-09 17:03 UTC (permalink / raw)
  To: Jamie Lokier; +Cc: Dmytro Bablinyuk, linux-kernel

On Tue, Sep 09, 2003 at 10:59:26AM +0100, Jamie Lokier wrote:
> Dmytro Bablinyuk wrote:
> >  if (remap_page_range(vma->vm_start,
> 
> Try io_remap_page_range() instead?

These are identical on PPC.

-Matt

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Problem with remap_page_range
  2003-09-09 17:02 ` Matt Porter
@ 2003-09-09 21:54   ` Dmytro Bablinyuk
  2003-09-09 22:06     ` Matt Porter
  0 siblings, 1 reply; 7+ messages in thread
From: Dmytro Bablinyuk @ 2003-09-09 21:54 UTC (permalink / raw)
  To: Matt Porter; +Cc: linux-kernel

>
>
>>  if (remap_page_range(vma->vm_start,
>>                       DSP_ADDR,
>>                       size,
>>                       vma->vm_page_prot
>>                       ))
>>    
>>
>
>Your remap call isn't adding _PAGE_NO_CACHE and _PAGE_GUARDED flags
>like ioremap_nocache()/ioremap() do on PPC.  You'll get bad results
>because of the ordering and cache issues resulting from not using
>these PTE flags.  In 2.6, these can be added using pgprot_noncached()
>that is defined per-arch.
>
>  
>
Thank you Matt,

Coud you please give me en example on how to add these flags to remap in 
kernel 2.4.21 (powerpc).
It seems I could not find these flags available in my kernel.

Thank you very much




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Problem with remap_page_range
  2003-09-09 21:54   ` Dmytro Bablinyuk
@ 2003-09-09 22:06     ` Matt Porter
  0 siblings, 0 replies; 7+ messages in thread
From: Matt Porter @ 2003-09-09 22:06 UTC (permalink / raw)
  To: Dmytro Bablinyuk; +Cc: linux-kernel

On Wed, Sep 10, 2003 at 09:54:20AM +1200, Dmytro Bablinyuk wrote:
> >
> >
> >>  if (remap_page_range(vma->vm_start,
> >>                       DSP_ADDR,
> >>                       size,
> >>                       vma->vm_page_prot
> >>                       ))
> >>    
> >>
> >
> >Your remap call isn't adding _PAGE_NO_CACHE and _PAGE_GUARDED flags
> >like ioremap_nocache()/ioremap() do on PPC.  You'll get bad results
> >because of the ordering and cache issues resulting from not using
> >these PTE flags.  In 2.6, these can be added using pgprot_noncached()
> >that is defined per-arch.
> >
> >  
> >
> Thank you Matt,
> 
> Coud you please give me en example on how to add these flags to remap in 
> kernel 2.4.21 (powerpc).
> It seems I could not find these flags available in my kernel.

They're defined in include/asm-ppc/pgtable.h

-Matt

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Problem with remap_page_range
@ 2003-09-10  1:13 Dmytro Bablinyuk
  2003-09-09  9:59 ` Jamie Lokier
  2003-09-09 17:02 ` Matt Porter
  0 siblings, 2 replies; 7+ messages in thread
From: Dmytro Bablinyuk @ 2003-09-10  1:13 UTC (permalink / raw)
  To: linux-kernel


We have a DSP shared memory which we should access (from PowerPC).
The problem is when I do ioremap I can see the memory correctly from the 
driver (see below) but when I do remap_page_range to the user space 
application then data appears to be wrong, I can recognize some values 
there, but they are in the wrong places and other values around from 
everywhere else (see below).

I tried mem_map_reserve - but still without luck.

Could somebody please give me a clue on this.

Thank you very much in advance for any help.

Below: the dsp_area prints correct values from DSP RAM but remap_page_range does not work properly.

  dsp_ptr=ioremap_nocache( DSP_ADDR, WINDOW_SIZE);
  dsp_area=(ushort *)(((unsigned long)dsp_ptr + PAGE_SIZE -1) &
PAGE_MASK);
/*   for (virt_addr=(unsigned long)dsp_area; virt_addr<(unsigned
long)dsp_area+WINDOW_SIZE; */
/*        virt_addr+=PAGE_SIZE) { */
/*       /\* reserve all pages to make them remapable *\/ */
/*     mem_map_reserve(virt_to_page(virt_addr)); */
/*   } */

  printk("dsp_area[0]=%04x\n", dsp_area[0]); //prints correct values
  ...
  vma->vm_flags |= (VM_SHM | VM_LOCKED | VM_IO | VM_RESERVED);

  if (remap_page_range(vma->vm_start,
                       DSP_ADDR,
                       size,
                       vma->vm_page_prot
                       ))
    {
      printk("remap page range failed\n");
      return -ENXIO;
    }

Here is the ouput:
//correct from the driver
dsp_area[0]=0000
dsp_area[1]=bc00
dsp_area[2]=eb17
dsp_area[3]=2643
dsp_area[4]=54cd
dsp_area[5]=5405
dsp_area[6]=91ba
dsp_area[7]=49c2
dsp_area[8]=1f61
hpi_mmap: vma->vm_start=3006f000, vma->vm_end=30097000
vma->vm_flags=864fb

//wrong from the user space application
kadr=0x3006f000
kadr[0]=1c59
kadr[1]=49c2
kadr[2]=5405
kadr[3]=bc00
kadr[4]=49c2
kadr[5]=54cd
kadr[6]=bc00
kadr[7]=54cd




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Problem with remap_page_range
  2003-09-09  9:59 ` Jamie Lokier
  2003-09-09 17:03   ` Matt Porter
@ 2003-09-10  2:19   ` Dmytro Bablinyuk
  1 sibling, 0 replies; 7+ messages in thread
From: Dmytro Bablinyuk @ 2003-09-10  2:19 UTC (permalink / raw)
  To: Jamie Lokier; +Cc: linux-kernel

>
>
>Try io_remap_page_range() instead?
>  
>
I just tried - the problem remains, but what is interesting:

Correct values (driver):

dsp_area[0]=91ba
dsp_area[1]=bc00
dsp_area[2]=eb17
dsp_area[3]=2643
dsp_area[4]=54cd
dsp_area[5]=5405
dsp_area[6]=91ba
dsp_area[7]=49c2
dsp_area[8]=1f61

Wrong values (application):

kadr[0]=1c59
kadr[1]=5405
kadr[2]=1f61
kadr[3]=49c2
kadr[4]=49c2
kadr[5]=eb17
kadr[6]=1f61
kadr[7]=2643


It's looks like application has some correct values but it's kind of mess.
What else could be wrong?

Thank you very much


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2003-09-09 22:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-09-10  1:13 Problem with remap_page_range Dmytro Bablinyuk
2003-09-09  9:59 ` Jamie Lokier
2003-09-09 17:03   ` Matt Porter
2003-09-10  2:19   ` Dmytro Bablinyuk
2003-09-09 17:02 ` Matt Porter
2003-09-09 21:54   ` Dmytro Bablinyuk
2003-09-09 22:06     ` Matt Porter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox