General porting question

Matt Porter mporter at kernel.crashing.org
Thu Oct 9 23:38:12 EST 2003


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/





More information about the Linuxppc-embedded mailing list