linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: "Laurent Lagrange" <lagrange@fr.oleane.com>
To: "'Eugene Surovegin'" <ebs@ebshome.net>
Cc: linuxppc-embedded@ozlabs.org
Subject: RE: MPC8260 strange virtual addresses returned by kmalloc()
Date: Thu, 6 Jan 2005 18:42:50 +0100	[thread overview]
Message-ID: <000001c4f417$25e84260$5201a8c0@GEG2400> (raw)
In-Reply-To: <20050105174154.GB14485@gate.ebshome.net>

Hi Eugene

My PAGE_OFFSET is defined as follow :
#define PAGE_OFFSET  CONFIG_KERNEL_START     in
./linux/include/asm-ppc/page.h
#define CONFIG_KERNEL_START (0xc0000000)     in
./linux/include/linux/autoconf.h

After reading kmalloc manual pages, I am in doubt.
My call is like
if ((tmpbuffer = kmalloc(128 * 1024, GFP_KERNEL)) == NULL){
    return(1);
}

This is the first time, I kmallocate a 128KB buffer which seems to be the
max
contiguous memory space which can be allocated.
Is it true on PPC ? Some PPC drivers seems to only allocate multiple
PAGE_SIZE (4KB) buffers.

My allocated buffer is intended to be used for DMA accesses.
Must I add the GFP_DMA flag to force the kmalloc to use contiguous memory ?

The Linux code for vmalloc is based on successive kmalloc calls, but I don't
know
what the kmalloc do when the desired size is greater than the PAGE_SIZE.

What is the right way to allocate big (128KB ???) DMA buffers ?
The manual pages say "Only for DMA kmalloc or __get_dma_pages() has to be
used"

The global variable is well in the loaded module.
OK, I use a kmalloc for the buffer instead of using the global variable.

Thanks for your ideas.
Laurent

-----Message d'origine-----
De : Eugene Surovegin [mailto:ebs@ebshome.net]
Envoye : mer. 5 janvier 2005 18:42
A : Laurent Lagrange
Cc : linuxppc-embedded@ozlabs.org
Objet : Re: MPC8260 strange virtual addresses returned by kmalloc()


On Wed, Jan 05, 2005 at 02:38:12PM +0100, Laurent Lagrange wrote:
> Hi and Happy New Year to all,
>
> I use a Linux 2.4.25 kernel on a MPC8260 custom board with 128MB of RAM.
> PCI is activated and my drivers are loaded as modules.
> The RAM is mapped at 0xC0000000 as usual.
>
> On MPC8XX I used kmalloc and iopa to get the physical addresses of the
> allocated buffers.
> On MPC82XX I used kmalloc and __pa for the same thing and it worked fine
> with previous kernel.
>
> But now, when I want to use kmalloc, I get addresses like 0xC9xxxxxx.
> The __pa gives me physical addresses 0x09xxxxxx which are out of my
physical
> RAM.
> I tried old iopa function and got some real physical addresses and the
> module works.
> The virt_to_bus gives me too addresses like  0x09xxxxxx
> (ie substract kernel base address 0xC0000000 as usual).
>
> I don't understand why I get virtual addresses which seem to be out of my
> memory and why it runs.

Yeah, this looks strange, please, check that this address is really
from kmalloc and not from vmalloc.

Also, check that PAGE_OFFSET is really 0xc000'0000.

> More, I have a global variable which is a little buffer. It is also mapped
> at a 0xC9xxxxxx address.

Is this global variable in the loaded module? If yes, this is normal,
because modules are loaded into vmalloced space and you cannot use
__pa for such addresses.

--
Eugene

  reply	other threads:[~2005-01-06 17:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-05 13:38 MPC8260 strange virtual addresses returned by kmalloc() Laurent Lagrange
2005-01-05 17:41 ` Eugene Surovegin
2005-01-06 17:42   ` Laurent Lagrange [this message]
2005-01-06 18:59     ` Eugene Surovegin

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='000001c4f417$25e84260$5201a8c0@GEG2400' \
    --to=lagrange@fr.oleane.com \
    --cc=ebs@ebshome.net \
    --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).