linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Matt Porter <mporter@kernel.crashing.org>
To: Jacky Lam <jackylam@astri.org>
Cc: linuxppc-embedded@lists.linuxppc.org
Subject: Re: General porting question
Date: Thu, 9 Oct 2003 06:38:12 -0700	[thread overview]
Message-ID: <20031009063812.A11979@home.com> (raw)
In-Reply-To: <008c01c38e2d$27feac20$2803050a@JackyLam>; from jackylam@astri.org on Thu, Oct 09, 2003 at 02:18:28PM +0800


On Thu, Oct 09, 2003 at 02:18:28PM +0800, Jacky Lam wrote:
>
> > A quick inspection shows that es1371 does some things that won't work on
> > a 405.  It takes a pci_alloc_consistent buffer and does a virt_to_page.
> > That will be bogus since the buffer's virtual address is in vmalloc
> > space on 4xx.  In addition, it performs a virt_to_phys and then uses
> > remap_page_range on that...that will be bogus as well.  A bus_to_virt
> > on the pci_alloc_consistent buffer's dma_addr will work and then
> > virt_to_page() can be used on that virtual address.  In the same
> > fashion one could do a virt_to_phys(bus_to_virt(dma_addr) to get
> > the correct physical address to be passed to remap_page_range.
> >
>
>     That means in short:
>
>     pci_alloc_consistent() ->virt_to_page() should be replaced by
> pci_alloc_consistent()->bus_to_virt()->virt_to_page().
>
>     Similarly, for any PCI related memory space. Before using
> virt_to_*/*_to_virt(), I should use bus_to_*/*_to_bus() on the argument
> first.

Almost.

You can not use virt_to_* on the address returned by
pci_alloc_consistent().

You need to hold on to the dma_addr_t returned, perform
a bus_to_virt(dma_addr_t) and then a virt_to_* will work
on that address.

However, I'm not sure of the "PCI related memory space" you
are referring to.  "PCI memory space" has a distinct meaning
and the virt_to_*/*_to_bus APIs don't work there.  Those APIs
are only valid for system memory that is accessible through
inbound transactions by a PCI bus master.

You can use virt_to_* on an address returned from kmalloc
or __get_free_pages.

-Matt

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

  reply	other threads:[~2003-10-09 13:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-09  4:11 General porting question Jacky Lam
2003-10-09  4:24 ` Bret Indrelee
2003-10-09  5:35 ` Matt Porter
2003-10-09  6:18   ` Jacky Lam
2003-10-09 13:38     ` Matt Porter [this message]
2003-10-09 15:36       ` Jacky Lam
2003-10-09 16:37         ` Matt Porter
2003-10-09 17:23           ` Jacky Lam

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=20031009063812.A11979@home.com \
    --to=mporter@kernel.crashing.org \
    --cc=jackylam@astri.org \
    --cc=linuxppc-embedded@lists.linuxppc.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).