Skip to contentSkip to conversation

Why not kmalloc() ??

DISCUSSION Rupesh S 7 participants 11 messages Jul 16, 2004

lore
Share & tools
lore

Rupesh S

author
#0 lore raw

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/

#1 lore raw

kernel 2.4.26 doesn't seem to work with a MPC859T

Hi,

I have a custom board with a MPC859T. When I do the 'gmake xconfig' in the
processor type option, the MPC859T does not appear. I have tried the 860L
and FADS but the kernel does not boot, it doesn't print any message.

Wich processor type could be compatible with the 859T? Are there other options that are affecting this behaviour?

I download a vanilla kernel 2.4.26 and I'm using ELDK 3.0.

Thanks in advance.

Pedro Aguilar

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

#2 lore raw
In reply to Rupesh S
Quoted 5 lines · Rupesh S

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.

Quoted 1 line

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/

#3 lore raw

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

Quoted 14 lines · Magnus Damm
Quoted 5 lines · Rupesh S

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.

Quoted 1 line

2) Why is the difference important in ppc linux ?

Quoted 10 lines

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/

#4 lore raw
Quoted 3 lines · sanjeev ramachandran

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/

#5 lore raw
Quoted 9 lines

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/

#6 lore raw
Quoted 2 lines · Mark Chambers

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/

#7 lore raw
Quoted 1 line · Rune Torgersen

Yous should even be able to use kmalloc(x, GFP_KERNEL | GFP_DMA)

No. This will not work properly on 8xx.

Quoted 4 lines

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/

#8 lore raw
In reply to Mark Chambers
Quoted 3 lines · Mark Chambers

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/

#9 lore raw
In reply to Magnus Damm
Quoted 3 lines · Magnus Damm

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/

#10 lore raw
In reply to Rupesh S
Quoted 2 lines · Rupesh S

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.

Quoted 1 line

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/