* Why not kmalloc() ??
@ 2004-07-16 9:25 Rupesh S
2004-07-16 11:34 ` Magnus Damm
2004-07-16 11:46 ` Dan Malek
0 siblings, 2 replies; 11+ messages in thread
From: Rupesh S @ 2004-07-16 9:25 UTC (permalink / raw)
To: linuxppc-embedded
Hi,
I just figured out that I need to use m8xx_cpm_hostalloc() to allocate memory for "buffer" that needs to be attached to the "Buffer Descriptor" of an MPC8xx CPM peripheral (like IIC, SPI, SCC etc). Instead, if I try to use kmalloc() or a static memory allocation, my driver isn't working.
1) Can somebody throw some light on what exactly is the difference between m8xx_cpm_hostalloc() and kmalloc().
2) Why is the difference important in ppc linux ?
Thanks
--
Rupesh S
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Why not kmalloc() ??
2004-07-16 9:25 Rupesh S
@ 2004-07-16 11:34 ` Magnus Damm
2004-07-16 12:06 ` sanjeev ramachandran
2004-07-16 13:29 ` Dan Malek
2004-07-16 11:46 ` Dan Malek
1 sibling, 2 replies; 11+ messages in thread
From: Magnus Damm @ 2004-07-16 11:34 UTC (permalink / raw)
To: Rupesh S; +Cc: linuxppc-embedded
On Fri, 2004-07-16 at 11:25, Rupesh S wrote:
> Hi,
>
> I just figured out that I need to use m8xx_cpm_hostalloc() to allocate memory for "buffer" that needs to be attached to the "Buffer Descriptor" of an MPC8xx CPM peripheral (like IIC, SPI, SCC etc). Instead, if I try to use kmalloc() or a static memory allocation, my driver isn't working.
>
> 1) Can somebody throw some light on what exactly is the difference between m8xx_cpm_hostalloc() and kmalloc().
kmalloc allocates from the kernel memory pool, ie your sdram.
you usually have several megabytes of sdram.
hostalloc allocates memory from the internal dpram area in the mpc8xx
processor. a mpc8xx-processor usually has around 4-8 kilobyte dpram.
> 2) Why is the difference important in ppc linux ?
the dpram (dual port ram) is used to communicate with the cpm devices
such as scc:s and smc.s found inside processors from the mpc8xx family.
the powerpc core has access to one side, the cpm has access to the other
side of the dual port memory. sort of anyway.
consult your friendly mpc8xx manual for further info.
/magnus
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Why not kmalloc() ??
2004-07-16 9:25 Rupesh S
2004-07-16 11:34 ` Magnus Damm
@ 2004-07-16 11:46 ` Dan Malek
1 sibling, 0 replies; 11+ messages in thread
From: Dan Malek @ 2004-07-16 11:46 UTC (permalink / raw)
To: Rupesh S; +Cc: linuxppc-embedded
On Jul 16, 2004, at 5:25 AM, Rupesh S wrote:
> 1) Can somebody throw some light on what exactly is the difference
> between m8xx_cpm_hostalloc() and kmalloc().
1) Cache coherency, and 2) need to allocate memory to CPM before the
kernel memory allocator has been initialized.
> 2) Why is the difference important in ppc linux ?
It's unique to the 8xx/82xx/85xx CPM peripherals that are used early
in the kernel start up process, not to the PowerPC Linux in general.
-- Dan
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Why not kmalloc() ??
2004-07-16 11:34 ` Magnus Damm
@ 2004-07-16 12:06 ` sanjeev ramachandran
2004-07-16 13:32 ` Dan Malek
2004-07-16 13:29 ` Dan Malek
1 sibling, 1 reply; 11+ messages in thread
From: sanjeev ramachandran @ 2004-07-16 12:06 UTC (permalink / raw)
To: Magnus Damm; +Cc: Rupesh S, linuxppc-embedded
Hi,
Bingo , But there is another function called dpalloc which does the same
job of allocating from the dual port ram. The host alloc function
allocates from the host page address that is passed when the cpm is
resetted. How are the dpalloc and hostalloc different.
San
On Fri, 2004-07-16 at 17:04, Magnus Damm wrote:
> On Fri, 2004-07-16 at 11:25, Rupesh S wrote:
> > Hi,
> >
> > I just figured out that I need to use m8xx_cpm_hostalloc() to allocate memory for "buffer" that needs to be attached to the "Buffer Descriptor" of an MPC8xx CPM peripheral (like IIC, SPI, SCC etc). Instead, if I try to use kmalloc() or a static memory allocation, my driver isn't working.
> >
> > 1) Can somebody throw some light on what exactly is the difference between m8xx_cpm_hostalloc() and kmalloc().
>
> kmalloc allocates from the kernel memory pool, ie your sdram.
> you usually have several megabytes of sdram.
> hostalloc allocates memory from the internal dpram area in the mpc8xx
> processor. a mpc8xx-processor usually has around 4-8 kilobyte dpram.
>
> > 2) Why is the difference important in ppc linux ?
>
> the dpram (dual port ram) is used to communicate with the cpm devices
> such as scc:s and smc.s found inside processors from the mpc8xx family.
> the powerpc core has access to one side, the cpm has access to the other
> side of the dual port memory. sort of anyway.
>
> consult your friendly mpc8xx manual for further info.
>
> /magnus
>
>
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Why not kmalloc() ??
2004-07-16 11:34 ` Magnus Damm
2004-07-16 12:06 ` sanjeev ramachandran
@ 2004-07-16 13:29 ` Dan Malek
1 sibling, 0 replies; 11+ messages in thread
From: Dan Malek @ 2004-07-16 13:29 UTC (permalink / raw)
To: Magnus Damm; +Cc: linuxppc-embedded, Rupesh S
On Jul 16, 2004, at 7:34 AM, Magnus Damm wrote:
> kmalloc allocates from the kernel memory pool, ie your sdram.
> you usually have several megabytes of sdram.
> hostalloc allocates memory from the internal dpram area in the mpc8xx
No, it does not. hostalloc allocates from the processor sdram, it
is not cached.
-- Dan
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Why not kmalloc() ??
2004-07-16 12:06 ` sanjeev ramachandran
@ 2004-07-16 13:32 ` Dan Malek
2004-07-16 14:06 ` Mark Chambers
0 siblings, 1 reply; 11+ messages in thread
From: Dan Malek @ 2004-07-16 13:32 UTC (permalink / raw)
To: sanjeev ramachandran; +Cc: Magnus Damm, linuxppc-embedded, Rupesh S
On Jul 16, 2004, at 8:06 AM, sanjeev ramachandran wrote:
> Bingo , But there is another function called dpalloc which does the
> same
> job of allocating from the dual port ram.
It is the only function that allocates from dpram. hostalloc does not.
Use the dpram only for those functions as necessary. Use hostalloc
only for those functions necesary (small serial fifos and such).
Use dma_alloc_consistent() for large memory buffers that you need
to attach to BDs, for example Ethernet buffers. There is very little
memory available from either dpalloc or hostalloc, and they must
be used only when necessary.
-- Dan
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Why not kmalloc() ??
2004-07-16 13:32 ` Dan Malek
@ 2004-07-16 14:06 ` Mark Chambers
2004-07-16 15:42 ` Rune Torgersen
2004-07-16 19:02 ` Dan Malek
0 siblings, 2 replies; 11+ messages in thread
From: Mark Chambers @ 2004-07-16 14:06 UTC (permalink / raw)
To: Dan Malek; +Cc: linuxppc-embedded
> Use hostalloc
> only for those functions necesary (small serial fifos and such).
>
> Use dma_alloc_consistent() for large memory buffers that you need
> to attach to BDs, for example Ethernet buffers. There is very little
> memory available from either dpalloc or hostalloc, and they must
> be used only when necessary.
>
Is there any reason to use m8xx_cpm_hostalloc() over dma_alloc_consistent()
for a loadable driver (that is, one loaded after VM initialized)?
Mark Chambers
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Why not kmalloc() ??
2004-07-16 14:06 ` Mark Chambers
@ 2004-07-16 15:42 ` Rune Torgersen
2004-07-16 19:03 ` Dan Malek
2004-07-16 19:02 ` Dan Malek
1 sibling, 1 reply; 11+ messages in thread
From: Rune Torgersen @ 2004-07-16 15:42 UTC (permalink / raw)
To: Mark Chambers; +Cc: linuxppc-embedded
On Fri, 2004-07-16 at 09:06, Mark Chambers wrote:
> Is there any reason to use m8xx_cpm_hostalloc() over dma_alloc_consistent()
> for a loadable driver (that is, one loaded after VM initialized)?
Yous should even be able to use kmalloc(x, GFP_KERNEL | GFP_DMA)
This works on 82xx CPU's (and is actually used as a replacement for hostalloc
on the rewritten cpm memory allocation stuff that is yet to be released)
Might not work on 8xx though...
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Why not kmalloc() ??
2004-07-16 14:06 ` Mark Chambers
2004-07-16 15:42 ` Rune Torgersen
@ 2004-07-16 19:02 ` Dan Malek
1 sibling, 0 replies; 11+ messages in thread
From: Dan Malek @ 2004-07-16 19:02 UTC (permalink / raw)
To: Mark Chambers; +Cc: linuxppc-embedded
On Jul 16, 2004, at 10:06 AM, Mark Chambers wrote:
> Is there any reason to use m8xx_cpm_hostalloc() over
> dma_alloc_consistent()
> for a loadable driver (that is, one loaded after VM initialized)?
You should always use dma_alloc_conistent(). The hostalloc space
is basically a small pre-allocated non-caches space that early
initialization
functions need.
Thanks.
-- Dan
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Why not kmalloc() ??
2004-07-16 15:42 ` Rune Torgersen
@ 2004-07-16 19:03 ` Dan Malek
0 siblings, 0 replies; 11+ messages in thread
From: Dan Malek @ 2004-07-16 19:03 UTC (permalink / raw)
To: Rune Torgersen; +Cc: linuxppc-embedded, Mark Chambers
On Jul 16, 2004, at 11:42 AM, Rune Torgersen wrote:
> Yous should even be able to use kmalloc(x, GFP_KERNEL | GFP_DMA)
No. This will not work properly on 8xx.
> This works on 82xx CPU's (and is actually used as a replacement for
> hostalloc
> on the rewritten cpm memory allocation stuff that is yet to be
> released)
That's because 82xx is cache coherent. The 8xx is not.
-- Dan
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Why not kmalloc() ??
@ 2004-07-17 4:51 Rupesh S
0 siblings, 0 replies; 11+ messages in thread
From: Rupesh S @ 2004-07-17 4:51 UTC (permalink / raw)
To: linuxppc-embedded
Here I put my understanding.
The hostalloc() function allocates space from "hostalloc space" which is basically a small pre-allocated non-caches space that has been initialized before "kernel memory allocator" is initialized. This "hostalloc space" is "Cache coherent" and not available for the "kernel memory allocator". But, "hostalloc space" cannot provide large memory buffers.
dma_alloc_consistent() function can be used allocating large memory buffers which is non-cached.
How is dma_alloc_consistent() different from kmalloc() ? - Is it that dma_alloc_consistent() allocates memory which is non-cached and kmaloc() allocates cached memory?
Thanks
--
Rupesh S
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2004-07-17 4:51 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-17 4:51 Why not kmalloc() ?? Rupesh S
-- strict thread matches above, loose matches on Subject: below --
2004-07-16 9:25 Rupesh S
2004-07-16 11:34 ` Magnus Damm
2004-07-16 12:06 ` sanjeev ramachandran
2004-07-16 13:32 ` Dan Malek
2004-07-16 14:06 ` Mark Chambers
2004-07-16 15:42 ` Rune Torgersen
2004-07-16 19:03 ` Dan Malek
2004-07-16 19:02 ` Dan Malek
2004-07-16 13:29 ` Dan Malek
2004-07-16 11:46 ` Dan Malek
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).