* Kmalloc returns which address
@ 2007-07-16 13:59 suresh suresh
2007-07-16 15:46 ` Scott Wood
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: suresh suresh @ 2007-07-16 13:59 UTC (permalink / raw)
To: linuxppc-embedded
[-- Attachment #1: Type: text/plain, Size: 451 bytes --]
Hi,
I am porting MPC8280 driver from vxWorks to Linux.
I want know the address return by kmalloc function? is it physical address
or kernel virtual address.
For Tx and Rx, hardware uses buffers, so I have to allocate buffers and pass
the pointer to hardware. Can I pass the pointer returned kmalloc? or I
should convert it into physical address?
If it returns kernel virtual address, then how to convert into physical?
Thanks & Regards-
Suresh
[-- Attachment #2: Type: text/html, Size: 514 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Kmalloc returns which address
2007-07-16 13:59 Kmalloc returns which address suresh suresh
@ 2007-07-16 15:46 ` Scott Wood
2007-07-23 3:47 ` Misbah khan
2007-07-24 7:03 ` Misbah khan
2007-07-20 10:52 ` Misbah khan
2007-07-20 12:13 ` Alessandro Rubini
2 siblings, 2 replies; 8+ messages in thread
From: Scott Wood @ 2007-07-16 15:46 UTC (permalink / raw)
To: suresh suresh; +Cc: linuxppc-embedded
suresh suresh wrote:
> I want know the address return by kmalloc function? is it physical address
> or kernel virtual address.
Kernel virtual.
> For Tx and Rx, hardware uses buffers, so I have to allocate buffers and
> pass
> the pointer to hardware. Can I pass the pointer returned kmalloc? or I
> should convert it into physical address?
You need to convert it; read Documentation/DMA-mapping.txt.
-Scott
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Kmalloc returns which address
2007-07-16 13:59 Kmalloc returns which address suresh suresh
2007-07-16 15:46 ` Scott Wood
@ 2007-07-20 10:52 ` Misbah khan
2007-07-20 16:58 ` Scott Wood
2007-07-20 12:13 ` Alessandro Rubini
2 siblings, 1 reply; 8+ messages in thread
From: Misbah khan @ 2007-07-20 10:52 UTC (permalink / raw)
To: linuxppc-embedded
hi Suresh
In linux kmelloc returns the pointer to virtual address not the physical
address, to return to the physical address there is different function
called ioremap
for eg :-
char *buf_tx =kmalloc(100,GFP_KERNEL); // Tx buffer
char *buf_rx=kmalloc(100,GFP_KERNEL); // Rx buffer
ptr_tx=ioremap( buf_tx,100);
ptr_rx=ioremap(buf_rx,100);
To learn more about this go through Linux device driver by rubini
I hope this will work for you
regard
Misbah
suresh suresh wrote:
>
> Hi,
>
> I am porting MPC8280 driver from vxWorks to Linux.
>
> I want know the address return by kmalloc function? is it physical address
> or kernel virtual address.
>
> For Tx and Rx, hardware uses buffers, so I have to allocate buffers and
> pass
> the pointer to hardware. Can I pass the pointer returned kmalloc? or I
> should convert it into physical address?
>
> If it returns kernel virtual address, then how to convert into physical?
>
> Thanks & Regards-
> Suresh
>
> _______________________________________________
> Linuxppc-embedded mailing list
> Linuxppc-embedded@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-embedded
>
--
View this message in context: http://www.nabble.com/Kmalloc-returns-which-address-tf4086826.html#a11705981
Sent from the linuxppc-embedded mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Kmalloc returns which address
2007-07-16 13:59 Kmalloc returns which address suresh suresh
2007-07-16 15:46 ` Scott Wood
2007-07-20 10:52 ` Misbah khan
@ 2007-07-20 12:13 ` Alessandro Rubini
2 siblings, 0 replies; 8+ messages in thread
From: Alessandro Rubini @ 2007-07-20 12:13 UTC (permalink / raw)
To: linuxppc-embedded
Hello.
> In linux kmelloc returns the pointer to virtual address not the physical
> address, to return to the physical address there is different function
> called ioremap
Not exactly. Both return virtual addresses. The kmalloc one is allocated
RAM memory, the ioremap is the virtual address built for you to
access a physical address you specified (i.e., a device memory area).
>> For Tx and Rx, hardware uses buffers, so I have to allocate buffers and
>> pass
>> the pointer to hardware. Can I pass the pointer returned kmalloc? or I
>> should convert it into physical address?
If you allocate with kmalloc, use __pa(addr) to turn the virtual
address addr into the physical address you need to pass to the device,
ad DMA access is outside of the virtual view of the address space.
However, please note that according to how your device is connected
and what bus it is using, the design can get more hairy, you may need
to study the consistent memory allocations.
Hope this helps
/alessandro
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Kmalloc returns which address
2007-07-20 10:52 ` Misbah khan
@ 2007-07-20 16:58 ` Scott Wood
0 siblings, 0 replies; 8+ messages in thread
From: Scott Wood @ 2007-07-20 16:58 UTC (permalink / raw)
To: Misbah khan; +Cc: linuxppc-embedded
Misbah khan wrote:
> hi Suresh
>
> In linux kmelloc returns the pointer to virtual address not the physical
> address, to return to the physical address there is different function
> called ioremap
>
> for eg :-
> char *buf_tx =kmalloc(100,GFP_KERNEL); // Tx buffer
> char *buf_rx=kmalloc(100,GFP_KERNEL); // Rx buffer
>
> ptr_tx=ioremap( buf_tx,100);
> ptr_rx=ioremap(buf_rx,100);
That's a really easy way to cause a machine check.
-Scott
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Kmalloc returns which address
2007-07-16 15:46 ` Scott Wood
@ 2007-07-23 3:47 ` Misbah khan
2007-07-23 18:35 ` Scott Wood
2007-07-24 7:03 ` Misbah khan
1 sibling, 1 reply; 8+ messages in thread
From: Misbah khan @ 2007-07-23 3:47 UTC (permalink / raw)
To: linuxppc-embedded
hi Scott
yes really it would really generate a machine check... but i guess if you
convert this virt address to physical address using __pa() then pass it to
the ioremap() i guess things will work .
Please correct me if i am wrong
regard
misbah
Scott Wood-2 wrote:
>
> suresh suresh wrote:
>> I want know the address return by kmalloc function? is it physical
>> address
>> or kernel virtual address.
>
> Kernel virtual.
>
>> For Tx and Rx, hardware uses buffers, so I have to allocate buffers and
>> pass
>> the pointer to hardware. Can I pass the pointer returned kmalloc? or I
>> should convert it into physical address?
>
> You need to convert it; read Documentation/DMA-mapping.txt.
>
> -Scott
> _______________________________________________
> Linuxppc-embedded mailing list
> Linuxppc-embedded@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-embedded
>
>
--
View this message in context: http://www.nabble.com/Kmalloc-returns-which-address-tf4086826.html#a11737504
Sent from the linuxppc-embedded mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Kmalloc returns which address
2007-07-23 3:47 ` Misbah khan
@ 2007-07-23 18:35 ` Scott Wood
0 siblings, 0 replies; 8+ messages in thread
From: Scott Wood @ 2007-07-23 18:35 UTC (permalink / raw)
To: Misbah khan; +Cc: linuxppc-embedded
On Sun, Jul 22, 2007 at 08:47:47PM -0700, Misbah khan wrote:
> yes really it would really generate a machine check... but i guess if you
> convert this virt address to physical address using __pa() then pass it to
> the ioremap() i guess things will work .
What would be the point? All you'd get is another virtual mapping.
Is the DMA mapping API that difficult?
-Scott
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Kmalloc returns which address
2007-07-16 15:46 ` Scott Wood
2007-07-23 3:47 ` Misbah khan
@ 2007-07-24 7:03 ` Misbah khan
1 sibling, 0 replies; 8+ messages in thread
From: Misbah khan @ 2007-07-24 7:03 UTC (permalink / raw)
To: linuxppc-embedded
Hi Scott
The while idea behind my logic was something this :-
Conver the physical address into virtual address and every time you read or
write to that virtual you are reading or writing to the physical address.
For that i suggested for ioremap(), some may suggest for __pa() to translate
the physical address to logical address. The whole idea behind this is to
make the task much easy and less complicated as if you are working on memory
mapped address.
DMA operation will make the application process to access the device
directly this i guess is little more complicated in implimentation and
passing a pointer to the application is a serious security concern untill
and unless only one thread is accessing .
well i will try this with a test driver as soon as i get the free time and
let you know with the findings
Thanks
Misbah
Scott Wood-2 wrote:
>
> suresh suresh wrote:
>> I want know the address return by kmalloc function? is it physical
>> address
>> or kernel virtual address.
>
> Kernel virtual.
>
>> For Tx and Rx, hardware uses buffers, so I have to allocate buffers and
>> pass
>> the pointer to hardware. Can I pass the pointer returned kmalloc? or I
>> should convert it into physical address?
>
> You need to convert it; read Documentation/DMA-mapping.txt.
>
> -Scott
> _______________________________________________
> Linuxppc-embedded mailing list
> Linuxppc-embedded@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-embedded
>
>
--
View this message in context: http://www.nabble.com/Kmalloc-returns-which-address-tf4086826.html#a11757911
Sent from the linuxppc-embedded mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2007-07-24 7:03 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-16 13:59 Kmalloc returns which address suresh suresh
2007-07-16 15:46 ` Scott Wood
2007-07-23 3:47 ` Misbah khan
2007-07-23 18:35 ` Scott Wood
2007-07-24 7:03 ` Misbah khan
2007-07-20 10:52 ` Misbah khan
2007-07-20 16:58 ` Scott Wood
2007-07-20 12:13 ` Alessandro Rubini
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).