summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2003-07-18 09:39:45 +1000
committerPaul Mackerras <paulus@samba.org>2003-07-18 09:39:45 +1000
commite2be4811e9c08aa7df296ffd8f8fb08d3c4e9aaf (patch)
tree8257b78a3ef8588b15809925ae214ba4304b32aa /include
parent19acc0eb2262fcd616ed0b5bcc52ecd9ff064683 (diff)
PPC32: PCI mapping fixes for non-cache-coherent PPC machines.
Diffstat (limited to 'include')
-rw-r--r--include/asm-ppc/pci.h49
1 files changed, 23 insertions, 26 deletions
diff --git a/include/asm-ppc/pci.h b/include/asm-ppc/pci.h
index 0f535e374c97..b3757965e3e8 100644
--- a/include/asm-ppc/pci.h
+++ b/include/asm-ppc/pci.h
@@ -53,18 +53,12 @@ extern unsigned long phys_to_bus(unsigned long pa);
extern unsigned long pci_phys_to_bus(unsigned long pa, int busnr);
extern unsigned long pci_bus_to_phys(unsigned int ba, int busnr);
-/* Dynamic DMA Mapping stuff, stolen from i386
- * ++ajoshi
+/*
+ * Dynamic DMA Mapping stuff
+ * Originally stolen from i386 by ajoshi and updated by paulus
+ * Non-consistent cache support by Dan Malek
*/
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/string.h>
-#include <asm/scatterlist.h>
-#include <asm/io.h>
-
-struct pci_dev;
-
/* The PCI address space does equal the physical memory
* address space. The networking and block device layers use
* this boolean for bounce buffer decisions.
@@ -101,8 +95,7 @@ extern void pci_free_consistent(struct pci_dev *hwdev, size_t size,
static inline dma_addr_t pci_map_single(struct pci_dev *hwdev, void *ptr,
size_t size, int direction)
{
- if (direction == PCI_DMA_NONE)
- BUG();
+ BUG_ON(direction == PCI_DMA_NONE);
consistent_sync(ptr, size, direction);
@@ -130,10 +123,11 @@ static inline void pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr,
* to pci_map_single, but takes a struct page instead of a virtual address
*/
static inline dma_addr_t pci_map_page(struct pci_dev *hwdev, struct page *page,
- unsigned long offset, size_t size, int direction)
+ unsigned long offset, size_t size,
+ int direction)
{
- if (direction == PCI_DMA_NONE)
- BUG();
+ BUG_ON(direction == PCI_DMA_NONE);
+ consistent_sync_page(page, offset, size, direction);
return (page - mem_map) * PAGE_SIZE + PCI_DRAM_OFFSET + offset;
}
@@ -171,10 +165,11 @@ static inline int pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg,
/*
* temporary 2.4 hack
*/
- for (i = 0; i < nents; i++) {
- if (!sg[i].page)
- BUG();
- sg[i].dma_address = page_to_bus(sg[i].page) + sg[i].offset;
+ for (i = 0; i < nents; i++, sg++) {
+ BUG_ON(!sg->page);
+ consistent_sync_page(sg->page, sg->offset,
+ sg->length, direction);
+ sg->dma_address = page_to_bus(sg->page) + sg->offset;
}
return nents;
@@ -187,8 +182,7 @@ static inline int pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg,
static inline void pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg,
int nents, int direction)
{
- if (direction == PCI_DMA_NONE)
- BUG();
+ BUG_ON(direction == PCI_DMA_NONE);
/* nothing to do */
}
@@ -205,8 +199,7 @@ static inline void pci_dma_sync_single(struct pci_dev *hwdev,
dma_addr_t dma_handle,
size_t size, int direction)
{
- if (direction == PCI_DMA_NONE)
- BUG();
+ BUG_ON(direction == PCI_DMA_NONE);
consistent_sync(bus_to_virt(dma_handle), size, direction);
}
@@ -221,9 +214,13 @@ static inline void pci_dma_sync_sg(struct pci_dev *hwdev,
struct scatterlist *sg,
int nelems, int direction)
{
- if (direction == PCI_DMA_NONE)
- BUG();
- /* nothing to do */
+ int i;
+
+ BUG_ON(direction == PCI_DMA_NONE);
+
+ for (i = 0; i < nelems; i++, sg++)
+ consistent_sync_page(sg->page, sg->offset,
+ sg->length, direction);
}
/* Return whether the given PCI device DMA address mask can