From: "Laurent Lagrange" <lagrange@fr.oleane.com>
To: <linuxppc-embedded@ozlabs.org>
Subject: Misunderstanding with function cpm_dpalloc in Linux 2.6.x
Date: Wed, 25 Jan 2006 14:48:05 +0100 [thread overview]
Message-ID: <000001c621b5$f8e45ab0$5201a8c0@GEG2400> (raw)
In-Reply-To:
Hello,
I work on MPC boards with Linux 2.6.9 and I have a problem with the
cpm_dpalloc function.
In the file cpm2_common.c the function "uint cpm_dpalloc(uint size, uint
align)" is intended
to allocate a piece of memory in the dpram. This piece of memory has at
least "size" bytes
and I beleived that the returned address should be aligned on "align" bytes.
This function calls "void *rh_alloc(rh_info_t * info, int size, const char
*owner)" from rheap.c file.
In this function the alignment is only used to calculate the right size with
the formula :
size = (size + (info->alignment - 1)) & ~(info->alignment - 1);
It seems to be right but the alignment is not used to retreive an aligned
start address.
So if I do the following sequential calls, I have the following results :
cpm_dpalloc(16, 8) -> 0XC0 -> right aligned
cpm_dpalloc(64, 64) -> 0XD0 -> wrong aligned -> must be 0x100
cpm_dpalloc(16, 8) -> 0X110 -> right aligned but wrong to use
cpm_dpalloc(24, 8) -> 0X1200 -> right aligned but wrong to use
I can have the wanted values if instead of size, I try to allocate (size +
align - 1) bytes
but I don't think it is the solution.
Perhaps, I don't understand the allocation theory.
Any idea ?
Thanks all
Laurent
next reply other threads:[~2006-01-25 13:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-25 13:48 Laurent Lagrange [this message]
2006-01-25 16:14 ` Misunderstanding with function cpm_dpalloc in Linux 2.6.x Pantelis Antoniou
2006-07-04 15:37 ` Linux 2.6.x : cpm_dpalloc alignment bug perhaps not fully resolved Laurent Lagrange
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='000001c621b5$f8e45ab0$5201a8c0@GEG2400' \
--to=lagrange@fr.oleane.com \
--cc=linuxppc-embedded@ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).