linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Dma addr should use Kuseg1 for MIPS32?
@ 2009-12-07 12:55 figo zhang
  2009-12-07 13:45 ` Ralf Baechle
  0 siblings, 1 reply; 7+ messages in thread
From: figo zhang @ 2009-12-07 12:55 UTC (permalink / raw)
  To: Ralf Baechle, David Daney, macro; +Cc: linux-mips

[-- Attachment #1: Type: text/plain, Size: 337 bytes --]

hi,

I am writing a driver for MIPS32. i wirte this code for DMA addr:

dma_vaddr =(char*) __get_free_pages(GFP_KERNEL|
GFP_DMA, order);
dma_phy = virt_to_phy(dma_vaddr);

i write dma_phy to DMA base register, but why it cannot work? it should
write Kseg1 space to DMA register?
I remember that it is ok for ARM/X86 .


Best,
Figo.zhang

[-- Attachment #2: Type: text/html, Size: 400 bytes --]

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

* Re: Dma addr should use Kuseg1 for MIPS32?
       [not found] <c6ed1ac50912062352u227c28e1me2107dbf7bd8a0ea@mail.gmail.com>
@ 2009-12-07 13:30 ` zhangfx
  0 siblings, 0 replies; 7+ messages in thread
From: zhangfx @ 2009-12-07 13:30 UTC (permalink / raw)
  To: figo zhang; +Cc: wuzhangjin, linux-mips, rostedt

[-- Attachment #1: Type: text/plain, Size: 524 bytes --]

physical address (address comes out of the CPU bus to memory) can be 
different with bus address(used by DMA) in MIPS boards.

figo zhang 写道:
> hi,
>
> I am writing a driver for MIPS32. i wirte this code for DMA addr:
>
> dma_vaddr =(char*) __get_free_pages(GFP_KERNEL|GFP_DMA, order);
> dma_phy = virt_to_phy(dma_vaddr);
>
> i write dma_phy to DMA base register, but why it cannot work? it 
> should write Kseg1 space to DMA register?
> I remember that it is ok for ARM/X86 .
>
>
> Best,
> Figo.zhang

[-- Attachment #2: zhangfx.vcf --]
[-- Type: text/x-vcard, Size: 511 bytes --]

begin:vcard
fn;quoted-printable:=E5=BC=A0=E7=A6=8F=E6=96=B0
n;quoted-printable;quoted-printable:=E5=BC=A0;=E7=A6=8F=E6=96=B0
org;quoted-printable:;=E7=AE=A1=E7=90=86=E9=83=A8
adr;quoted-printable;dom:;;=E6=B1=9F=E8=8B=8F=E7=9C=81=E5=B8=B8=E7=86=9F=E5=B8=82=E8=99=9E=E5=B1=B1=E9=
	=95=87=E6=A2=A6=E5=85=B0=E5=B7=A5=E4=B8=9A=E5=9B=AD;;;215500
email;internet:zhangfx@lemote.com
title;quoted-printable:=E6=80=BB=E7=BB=8F=E7=90=86
tel;work:0512-52308679
url:http://www.lemote.com
version:2.1
end:vcard


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

* Re: Dma addr should use Kuseg1 for MIPS32?
  2009-12-07 12:55 figo zhang
@ 2009-12-07 13:45 ` Ralf Baechle
  2009-12-08  1:49   ` figo zhang
  0 siblings, 1 reply; 7+ messages in thread
From: Ralf Baechle @ 2009-12-07 13:45 UTC (permalink / raw)
  To: figo zhang; +Cc: David Daney, macro, linux-mips

On Mon, Dec 07, 2009 at 08:55:12PM +0800, figo zhang wrote:

> I am writing a driver for MIPS32. i wirte this code for DMA addr:
> 
> dma_vaddr =(char*) __get_free_pages(GFP_KERNEL|
> GFP_DMA, order);

You probably don't want to use GFP_DMA - unless your hardware has DMA
restrictions such as the ISA's bus's 16MB limit.

> dma_phy = virt_to_phy(dma_vaddr);

Ouch.  Don't.  See Documentation/DMA-API.txt for how to do it.

> i write dma_phy to DMA base register, but why it cannot work? it should
> write Kseg1 space to DMA register?
> I remember that it is ok for ARM/X86 .

It's only happens to work on some systems.

  Ralf

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

* Re: Dma addr should use Kuseg1 for MIPS32?
  2009-12-07 13:45 ` Ralf Baechle
@ 2009-12-08  1:49   ` figo zhang
  2009-12-08 11:36     ` Sergei Shtylyov
  2009-12-09 11:47     ` figo zhang
  0 siblings, 2 replies; 7+ messages in thread
From: figo zhang @ 2009-12-08  1:49 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: David Daney, macro, linux-mips

[-- Attachment #1: Type: text/plain, Size: 1511 bytes --]

2009/12/7 Ralf Baechle <ralf@linux-mips.org>

> On Mon, Dec 07, 2009 at 08:55:12PM +0800, figo zhang wrote:
>
> > I am writing a driver for MIPS32. i wirte this code for DMA addr:
> >
> > dma_vaddr =(char*) __get_free_pages(GFP_KERNEL|
> > GFP_DMA, order);
>
> You probably don't want to use GFP_DMA - unless your hardware has DMA
> restrictions such as the ISA's bus's 16MB limit.
>
> > dma_phy = virt_to_phy(dma_vaddr);
>

> Ouch.  Don't.  See Documentation/DMA-API.txt for how to do it.
>

hi Ralf,
is it using dma_alloc_coherent()? i see the this funtion in
arch/mips/mm/dma_default.c, it also invork the
__get_free_pages() and return the dma_addr by
plat_map_dma_mem()->virt_to_phy() , see
include/asm-mips/mach-genric/dma-coherent.h. so i think, i see use
__get_free_pages() alloce buffer for DMA.

>
> > i write dma_phy to DMA base register, but why it cannot work? it should
> > write Kseg1 space to DMA register?
> > I remember that it is ok for ARM/X86 .
>
> It's only happens to work on some systems.
>

in my puzzle, if i run
dma_vaddr =(char*) __get_free_pages(GFP_KERNEL,  order);
dma_phy = virt_to_phy(dma_vaddr);

if the result is:
dma_vaddr = 0x801b00000;
dma_phy = 0x1b00000;

so i should write 0x1b00000 to my DMA Base register or wirte (0x1b000000 |
0xa0000000) to DMA?

2. If my system have HIGHMEM, so i alloc highmem pages by :
  page = alloc_pages(__GFP_HIGHMEM, order);
  phy = page_to_phys(page);

how i write this highmem phy addr to DMA base register?

Best,
Figo.zhang



>  Ralf
>

[-- Attachment #2: Type: text/html, Size: 2531 bytes --]

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

* Re: Dma addr should use Kuseg1 for MIPS32?
  2009-12-08  1:49   ` figo zhang
@ 2009-12-08 11:36     ` Sergei Shtylyov
  2009-12-09 11:46       ` figo zhang
  2009-12-09 11:47     ` figo zhang
  1 sibling, 1 reply; 7+ messages in thread
From: Sergei Shtylyov @ 2009-12-08 11:36 UTC (permalink / raw)
  To: figo zhang; +Cc: Ralf Baechle, David Daney, macro, linux-mips

Hello.

figo zhang wrote:

>
>     > i write dma_phy to DMA base register, but why it cannot work? it
>     should
>     > write Kseg1 space to DMA register?
>     > I remember that it is ok for ARM/X86 .
>
>     It's only happens to work on some systems.
>
>
> in my puzzle, if i run 
> dma_vaddr =(char*) __get_free_pages(GFP_KERNEL,  order);
> dma_phy = virt_to_phy(dma_vaddr);
>
> if the result is:
> dma_vaddr = 0x801b00000;
> dma_phy = 0x1b00000;
>
> so i should write 0x1b00000 to my DMA Base register or wirte 
> (0x1b000000 | 0xa0000000) to DMA?

   You must always use the physical addresses when programming DMA, i.e. 
0x1b00000 in this case.

WBR, Sergei

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

* Re: Dma addr should use Kuseg1 for MIPS32?
  2009-12-08 11:36     ` Sergei Shtylyov
@ 2009-12-09 11:46       ` figo zhang
  0 siblings, 0 replies; 7+ messages in thread
From: figo zhang @ 2009-12-09 11:46 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: Ralf Baechle, David Daney, macro, linux-mips

[-- Attachment #1: Type: text/plain, Size: 870 bytes --]

2009/12/8 Sergei Shtylyov <sshtylyov@ru.mvista.com>

> Hello.
>
>
> figo zhang wrote:
>
>
>>    > i write dma_phy to DMA base register, but why it cannot work? it
>>    should
>>    > write Kseg1 space to DMA register?
>>    > I remember that it is ok for ARM/X86 .
>>
>>    It's only happens to work on some systems.
>>
>>
>> in my puzzle, if i run dma_vaddr =(char*) __get_free_pages(GFP_KERNEL,
>>  order);
>> dma_phy = virt_to_phy(dma_vaddr);
>>
>> if the result is:
>> dma_vaddr = 0x801b00000;
>> dma_phy = 0x1b00000;
>>
>> so i should write 0x1b00000 to my DMA Base register or wirte (0x1b000000 |
>> 0xa0000000) to DMA?
>>
>
>  You must always use the physical addresses when programming DMA, i.e.
> 0x1b00000 in this case.
>

I  write  0x1b00000 to my DMA Base register, the driver donot work.  write
(0x1b00000 | 0xa000000) it work, why?

>
> WBR, Sergei
>
>
>

[-- Attachment #2: Type: text/html, Size: 1542 bytes --]

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

* Re: Dma addr should use Kuseg1 for MIPS32?
  2009-12-08  1:49   ` figo zhang
  2009-12-08 11:36     ` Sergei Shtylyov
@ 2009-12-09 11:47     ` figo zhang
  1 sibling, 0 replies; 7+ messages in thread
From: figo zhang @ 2009-12-09 11:47 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: David Daney, macro, linux-mips

[-- Attachment #1: Type: text/plain, Size: 1734 bytes --]

2009/12/8 figo zhang <figo1802@gmail.com>

>
>
> 2009/12/7 Ralf Baechle <ralf@linux-mips.org>
>
> On Mon, Dec 07, 2009 at 08:55:12PM +0800, figo zhang wrote:
>>
>> > I am writing a driver for MIPS32. i wirte this code for DMA addr:
>> >
>> > dma_vaddr =(char*) __get_free_pages(GFP_KERNEL|
>> > GFP_DMA, order);
>>
>> You probably don't want to use GFP_DMA - unless your hardware has DMA
>> restrictions such as the ISA's bus's 16MB limit.
>>
>> > dma_phy = virt_to_phy(dma_vaddr);
>>
>
>> Ouch.  Don't.  See Documentation/DMA-API.txt for how to do it.
>>
>
> hi Ralf,
> is it using dma_alloc_coherent()? i see the this funtion in
> arch/mips/mm/dma_default.c, it also invork the
> __get_free_pages() and return the dma_addr by
> plat_map_dma_mem()->virt_to_phy() , see
> include/asm-mips/mach-genric/dma-coherent.h. so i think, i see use
> __get_free_pages() alloce buffer for DMA.
>
>>
>> > i write dma_phy to DMA base register, but why it cannot work? it should
>> > write Kseg1 space to DMA register?
>> > I remember that it is ok for ARM/X86 .
>>
>> It's only happens to work on some systems.
>>
>
> in my puzzle, if i run
> dma_vaddr =(char*) __get_free_pages(GFP_KERNEL,  order);
>
> dma_phy = virt_to_phy(dma_vaddr);
>
> if the result is:
> dma_vaddr = 0x801b00000;
> dma_phy = 0x1b00000;
>
> so i should write 0x1b00000 to my DMA Base register or wirte (0x1b000000 |
> 0xa0000000) to DMA?
>
> 2. If my system have HIGHMEM, so i alloc highmem pages by :
>   page = alloc_pages(__GFP_HIGHMEM, order);
>   phy = page_to_phys(page);
>
> how i write this highmem phy addr to DMA base register?
>

hi all,
 is anbody who would like to give me some advise about it?

Thanks,
Figo.zhang

>
> Best,
> Figo.zhang
>
>
>
>>  Ralf
>>
>
>

[-- Attachment #2: Type: text/html, Size: 3199 bytes --]

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

end of thread, other threads:[~2009-12-09 11:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <c6ed1ac50912062352u227c28e1me2107dbf7bd8a0ea@mail.gmail.com>
2009-12-07 13:30 ` Dma addr should use Kuseg1 for MIPS32? zhangfx
2009-12-07 12:55 figo zhang
2009-12-07 13:45 ` Ralf Baechle
2009-12-08  1:49   ` figo zhang
2009-12-08 11:36     ` Sergei Shtylyov
2009-12-09 11:46       ` figo zhang
2009-12-09 11:47     ` figo zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).