mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Adam J. Richter" <adam@yggdrasil.com>
To: davem@redhat.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: Does kmalloc always return address below 4GB?
Date: Tue, 5 Mar 2002 06:43:35 -0800	[thread overview]
Message-ID: <200203051443.GAA05242@adam.yggdrasil.com> (raw)

>   | If you acquired your memory via the page allocator
>   | (i.e. __get_free_page*()) or the generic memory allocators
>   | (i.e. kmalloc() or kmem_cache_alloc()) then you may DMA to/from
>   | that memory using the addresses returned from those routines.
[...]
>Probably it should qualify what it means with "and you used
>GFP_KERNEL".  Because that was the intention.

	That change alone would result in a setence that
I still would not understand.  Does GFP_KERNEL guarantee address
below 4GB on all architectures?  The GFP_KERNEL mask that currently
includes __GFP_IO, but I'm not sure that that even means "below 4GB"
on all architectures.  If __GFP_IO really does guarantee "below 4GB
and physical = virtual" on all architectures, then it sounds like
I am back to not having to use pci_{,un}map_single in a number of
places in advansys.c, because the Scsi_Request structurs are allocated
with GFP_ATOMIC, which also includes __GFP_IO.

>I'll fix that.

>However, you can use GFP_HIGH memory with pci_map_page _iff_
>you set your DMA mask to allow 64-bits.

>The original impetus for that quoted bit of DMA-mapping.txt
>was to make sure nobody used vmalloc() or kmap() pointers.

	Just to be clear, I assume that you mean that you cannot
simply cast these virtual addresses to dma_addr_t and that the
underlying physical memory is not guaranteed to be below 4GB,
but that you can use that memory with pci_map_single if your
PCI device can handle 64 bit addresses.

	If I got it right, then here is some proposed replacement
text, to possibly save you a little effort:

| 	You cannot directly use an address in an area returned by
| vmalloc() or kmap(), because these routines are *not* guaranteed to
| return addresses where virtual == cpu memory bus == pci.  You
| cannot even use those addresses with PCI device that only have
| 32 bit addressing, because the underlying physical memory may be
| above 4GB.
|
| 	However, a PCI card that does 64-bit addressing can
| access memory returned by vmalloc or kmap via the dma_addr_t
| address returned by pci_map_single or pci_map_page.

Adam J. Richter     __     ______________   4880 Stevens Creek Blvd, Suite 104
adam@yggdrasil.com     \ /                  San Jose, California 95129-1034
+1 408 261-6630         | g g d r a s i l   United States of America
fax +1 408 261-6631      "Free Software For The Rest Of Us."

             reply	other threads:[~2002-03-05 14:44 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-03-05 14:43 Adam J. Richter [this message]
2002-03-05 15:15 ` David S. Miller
  -- strict thread matches above, loose matches on Subject: below --
2002-03-06  2:28 Adam J. Richter
2002-03-05 17:08 Adam J. Richter
2002-03-06  1:13 ` David S. Miller
2002-03-05 16:39 Adam J. Richter
2002-03-05 17:00 ` Gerd Knorr
2002-03-05 21:57 ` Steffen Persvold
2002-03-06  7:22 ` David S. Miller
2002-03-05 11:52 Adam J. Richter
2002-03-05 11:59 ` David S. Miller
2002-03-05 11:12 Adam J. Richter
2002-03-05 11:16 ` David S. Miller
2002-03-05 15:43   ` Steffen Persvold
2002-03-05 16:44     ` David Mosberger
2002-03-06  1:31       ` David Mosberger
2002-03-06  2:04         ` David Mosberger
2002-03-05 15:47   ` David S. Miller
2002-03-06  1:09     ` David S. Miller
2002-03-06  1:52       ` David S. Miller

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=200203051443.GAA05242@adam.yggdrasil.com \
    --to=adam@yggdrasil.com \
    --cc=davem@redhat.com \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®