Subject: driver replacements for kmalloc and __pa()

From: Jeff Brower <[email-masked]>
Date: Tue, 09 Sep 2008 17:00:56 -0500

Hello,

We have inherited an older driver that uses kmalloc() and vtophys (which resolves to
the __pa() macro) to create memory accessible by an external PCI device doing bus
master read/writes.  The driver works Ok on several x86 machines, but is failing on a
PPC board (MPC7447/8) running Gentoo Linux 2.6.9.  After looking at PCI bus analyzer
captures, it seems the physical address the driver is giving to the PCI device is
invalid, so the device ends up reading/writing incorrect memory areas.

What are the up-to-date APIs we should be using for DMA memory allocation and
virtual-to-physical address translation?  We have another driver for another device
that's working fine on this board and it uses pci_alloc_consistent().  What about
bus_space_vaddr()?  I'm hoping to get a recommendation for what's currently
appropriate and most future-proof for drivers that depend on external PCI DMA.

Any suggestions welcome.  Thanks.

-Jeff