Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 166200
b: refs/heads/master
c: 1cebd7a
h: refs/heads/master
v: v3
  • Loading branch information
Becky Bruce authored and Benjamin Herrenschmidt committed Sep 24, 2009
1 parent 351bb6b commit 090b066
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b9eceb2307f8dda124669a9dc213aad8c1569b5a
refs/heads/master: 1cebd7a0f62804ca24f7b7b35e8105000b9e879a
21 changes: 18 additions & 3 deletions trunk/arch/powerpc/include/asm/dma-mapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ extern void *dma_direct_alloc_coherent(struct device *dev, size_t size,
extern void dma_direct_free_coherent(struct device *dev, size_t size,
void *vaddr, dma_addr_t dma_handle);

extern unsigned long get_dma_direct_offset(struct device *dev);

#ifdef CONFIG_NOT_COHERENT_CACHE
/*
Expand Down Expand Up @@ -90,6 +89,22 @@ static inline void set_dma_ops(struct device *dev, struct dma_map_ops *ops)
dev->archdata.dma_ops = ops;
}

/*
* get_dma_offset()
*
* Get the dma offset on configurations where the dma address can be determined
* from the physical address by looking at a simple offset. Direct dma and
* swiotlb use this function, but it is typically not used by implementations
* with an iommu.
*/
static inline unsigned long get_dma_offset(struct device *dev)
{
if (dev)
return (unsigned long)dev->archdata.dma_data;

return PCI_DRAM_OFFSET;
}

/* this will be removed soon */
#define flush_write_buffers()

Expand Down Expand Up @@ -181,12 +196,12 @@ static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)

static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
{
return paddr + get_dma_direct_offset(dev);
return paddr + get_dma_offset(dev);
}

static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr)
{
return daddr - get_dma_direct_offset(dev);
return daddr - get_dma_offset(dev);
}

#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
Expand Down
15 changes: 4 additions & 11 deletions trunk/arch/powerpc/kernel/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@
* default the offset is PCI_DRAM_OFFSET.
*/

unsigned long get_dma_direct_offset(struct device *dev)
{
if (dev)
return (unsigned long)dev->archdata.dma_data;

return PCI_DRAM_OFFSET;
}

void *dma_direct_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t flag)
Expand All @@ -37,7 +30,7 @@ void *dma_direct_alloc_coherent(struct device *dev, size_t size,
ret = __dma_alloc_coherent(dev, size, dma_handle, flag);
if (ret == NULL)
return NULL;
*dma_handle += get_dma_direct_offset(dev);
*dma_handle += get_dma_offset(dev);
return ret;
#else
struct page *page;
Expand All @@ -51,7 +44,7 @@ void *dma_direct_alloc_coherent(struct device *dev, size_t size,
return NULL;
ret = page_address(page);
memset(ret, 0, size);
*dma_handle = virt_to_abs(ret) + get_dma_direct_offset(dev);
*dma_handle = virt_to_abs(ret) + get_dma_offset(dev);

return ret;
#endif
Expand All @@ -75,7 +68,7 @@ static int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl,
int i;

for_each_sg(sgl, sg, nents, i) {
sg->dma_address = sg_phys(sg) + get_dma_direct_offset(dev);
sg->dma_address = sg_phys(sg) + get_dma_offset(dev);
sg->dma_length = sg->length;
__dma_sync_page(sg_page(sg), sg->offset, sg->length, direction);
}
Expand Down Expand Up @@ -110,7 +103,7 @@ static inline dma_addr_t dma_direct_map_page(struct device *dev,
{
BUG_ON(dir == DMA_NONE);
__dma_sync_page(page, offset, size, dir);
return page_to_phys(page) + offset + get_dma_direct_offset(dev);
return page_to_phys(page) + offset + get_dma_offset(dev);
}

static inline void dma_direct_unmap_page(struct device *dev,
Expand Down

0 comments on commit 090b066

Please sign in to comment.