Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 108641
b: refs/heads/master
c: 98ed7d4
h: refs/heads/master
i:
  108639: 3371a81
v: v3
  • Loading branch information
Russell King authored and Russell King committed Aug 10, 2008
1 parent 07099f2 commit 0a3d478
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 38 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: 492c71dd545a54dc62df8780bd8d233d771748df
refs/heads/master: 98ed7d4b1a4eebc1ac25929b6968673bef4d54c3
18 changes: 9 additions & 9 deletions trunk/arch/arm/common/dmabounce.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,9 @@ map_single(struct device *dev, void *ptr, size_t size,
}

dev_dbg(dev,
"%s: unsafe buffer %p (phy=%p) mapped to %p (phy=%p)\n",
__func__, buf->ptr, (void *) virt_to_dma(dev, buf->ptr),
buf->safe, (void *) buf->safe_dma_addr);
"%s: unsafe buffer %p (dma=%#x) mapped to %p (dma=%#x)\n",
__func__, buf->ptr, virt_to_dma(dev, buf->ptr),
buf->safe, buf->safe_dma_addr);

if ((dir == DMA_TO_DEVICE) ||
(dir == DMA_BIDIRECTIONAL)) {
Expand Down Expand Up @@ -292,9 +292,9 @@ unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
BUG_ON(buf->size != size);

dev_dbg(dev,
"%s: unsafe buffer %p (phy=%p) mapped to %p (phy=%p)\n",
__func__, buf->ptr, (void *) virt_to_dma(dev, buf->ptr),
buf->safe, (void *) buf->safe_dma_addr);
"%s: unsafe buffer %p (dma=%#x) mapped to %p (dma=%#x)\n",
__func__, buf->ptr, virt_to_dma(dev, buf->ptr),
buf->safe, buf->safe_dma_addr);

DO_STATS ( device_info->bounce_count++ );

Expand Down Expand Up @@ -355,9 +355,9 @@ sync_single(struct device *dev, dma_addr_t dma_addr, size_t size,
*/

dev_dbg(dev,
"%s: unsafe buffer %p (phy=%p) mapped to %p (phy=%p)\n",
__func__, buf->ptr, (void *) virt_to_dma(dev, buf->ptr),
buf->safe, (void *) buf->safe_dma_addr);
"%s: unsafe buffer %p (dma=%#x) mapped to %p (dma=%#x)\n",
__func__, buf->ptr, virt_to_dma(dev, buf->ptr),
buf->safe, buf->safe_dma_addr);

DO_STATS ( device_info->bounce_count++ );

Expand Down
51 changes: 44 additions & 7 deletions trunk/arch/arm/include/asm/dma-mapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,48 @@

#ifdef __KERNEL__

#include <linux/mm.h> /* need struct page */

#include <linux/mm_types.h>
#include <linux/scatterlist.h>

#include <asm-generic/dma-coherent.h>
#include <asm/memory.h>

/*
* page_to_dma/dma_to_virt/virt_to_dma are architecture private functions
* used internally by the DMA-mapping API to provide DMA addresses. They
* must not be used by drivers.
*/
#ifndef __arch_page_to_dma
static inline dma_addr_t page_to_dma(struct device *dev, struct page *page)
{
return (dma_addr_t)__virt_to_bus((unsigned long)page_address(page));
}

static inline void *dma_to_virt(struct device *dev, dma_addr_t addr)
{
return (void *)__bus_to_virt(addr);
}

static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
{
return (dma_addr_t)__virt_to_bus((unsigned long)(addr));
}
#else
static inline dma_addr_t page_to_dma(struct device *dev, struct page *page)
{
return __arch_page_to_dma(dev, page);
}

static inline void *dma_to_virt(struct device *dev, dma_addr_t addr)
{
return __arch_dma_to_virt(dev, addr);
}

static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
{
return __arch_virt_to_dma(dev, addr);
}
#endif

/*
* DMA-consistent mapping functions. These allocate/free a region of
Expand Down Expand Up @@ -169,7 +206,7 @@ dma_map_single(struct device *dev, void *cpu_addr, size_t size,
if (!arch_is_coherent())
dma_cache_maint(cpu_addr, size, dir);

return virt_to_dma(dev, (unsigned long)cpu_addr);
return virt_to_dma(dev, cpu_addr);
}
#else
extern dma_addr_t dma_map_single(struct device *,void *, size_t, enum dma_data_direction);
Expand All @@ -195,7 +232,7 @@ dma_map_page(struct device *dev, struct page *page,
unsigned long offset, size_t size,
enum dma_data_direction dir)
{
return dma_map_single(dev, page_address(page) + offset, size, (int)dir);
return dma_map_single(dev, page_address(page) + offset, size, dir);
}

/**
Expand Down Expand Up @@ -241,7 +278,7 @@ static inline void
dma_unmap_page(struct device *dev, dma_addr_t handle, size_t size,
enum dma_data_direction dir)
{
dma_unmap_single(dev, handle, size, (int)dir);
dma_unmap_single(dev, handle, size, dir);
}

/**
Expand Down Expand Up @@ -336,15 +373,15 @@ dma_sync_single_for_cpu(struct device *dev, dma_addr_t handle, size_t size,
enum dma_data_direction dir)
{
if (!arch_is_coherent())
dma_cache_maint((void *)dma_to_virt(dev, handle), size, dir);
dma_cache_maint(dma_to_virt(dev, handle), size, dir);
}

static inline void
dma_sync_single_for_device(struct device *dev, dma_addr_t handle, size_t size,
enum dma_data_direction dir)
{
if (!arch_is_coherent())
dma_cache_maint((void *)dma_to_virt(dev, handle), size, dir);
dma_cache_maint(dma_to_virt(dev, handle), size, dir);
}
#else
extern void dma_sync_single_for_cpu(struct device*, dma_addr_t, size_t, enum dma_data_direction);
Expand Down
14 changes: 0 additions & 14 deletions trunk/arch/arm/include/asm/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,20 +313,6 @@ static inline __deprecated void *bus_to_virt(unsigned long x)
*/
#define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)

/*
* Optional device DMA address remapping. Do _not_ use directly!
* We should really eliminate virt_to_bus() here - it's deprecated.
*/
#ifndef __arch_page_to_dma
#define page_to_dma(dev, page) ((dma_addr_t)__virt_to_bus((unsigned long)page_address(page)))
#define dma_to_virt(dev, addr) ((void *)__bus_to_virt(addr))
#define virt_to_dma(dev, addr) ((dma_addr_t)__virt_to_bus((unsigned long)(addr)))
#else
#define page_to_dma(dev, page) (__arch_page_to_dma(dev, page))
#define dma_to_virt(dev, addr) (__arch_dma_to_virt(dev, addr))
#define virt_to_dma(dev, addr) (__arch_virt_to_dma(dev, addr))
#endif

/*
* Optional coherency support. Currently used only by selected
* Intel XSC3-based systems.
Expand Down
15 changes: 8 additions & 7 deletions trunk/arch/arm/plat-omap/include/mach/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,14 @@
(dma_addr_t)virt_to_lbus(page_address(page)) : \
(dma_addr_t)__virt_to_bus(page_address(page));})

#define __arch_dma_to_virt(dev, addr) ({is_lbus_device(dev) ? \
lbus_to_virt(addr) : \
__bus_to_virt(addr);})

#define __arch_virt_to_dma(dev, addr) ({is_lbus_device(dev) ? \
virt_to_lbus(addr) : \
__virt_to_bus(addr);})
#define __arch_dma_to_virt(dev, addr) ({ (void *) (is_lbus_device(dev) ? \
lbus_to_virt(addr) : \
__bus_to_virt(addr)); })

#define __arch_virt_to_dma(dev, addr) ({ unsigned long __addr = (unsigned long)(addr); \
(dma_addr_t) (is_lbus_device(dev) ? \
virt_to_lbus(__addr) : \
__virt_to_bus(__addr)); })

#endif /* CONFIG_ARCH_OMAP15XX */

Expand Down

0 comments on commit 0a3d478

Please sign in to comment.