Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 112559
b: refs/heads/master
c: 6c505ce
h: refs/heads/master
i:
  112557: 7933bd2
  112555: aa5fa66
  112551: 18c7638
  112543: 5b93f16
v: v3
  • Loading branch information
Joerg Roedel authored and Ingo Molnar committed Aug 22, 2008
1 parent 259db38 commit 007f44c
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 59 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: c647c3bb2d16246a87f49035985ddb7c1eb030df
refs/heads/master: 6c505ce3930c6a6b455cda53fab3e88ae44f8221
49 changes: 3 additions & 46 deletions trunk/arch/x86/kernel/pci-dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ EXPORT_SYMBOL(bad_dma_address);
/* Dummy device used for NULL arguments (normally ISA). Better would
be probably a smaller DMA mask, but this is bug-to-bug compatible
to older i386. */
struct device fallback_dev = {
struct device x86_dma_fallback_dev = {
.bus_id = "fallback device",
.coherent_dma_mask = DMA_32BIT_MASK,
.dma_mask = &fallback_dev.coherent_dma_mask,
.dma_mask = &x86_dma_fallback_dev.coherent_dma_mask,
};
EXPORT_SYMBOL(x86_dma_fallback_dev);

int dma_set_mask(struct device *dev, u64 mask)
{
Expand Down Expand Up @@ -241,50 +242,6 @@ int dma_supported(struct device *dev, u64 mask)
}
EXPORT_SYMBOL(dma_supported);

/*
* Allocate memory for a coherent mapping.
*/
void *
dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
gfp_t gfp)
{
struct dma_mapping_ops *ops = get_dma_ops(dev);
void *memory;

if (dma_alloc_from_coherent(dev, size, dma_handle, &memory))
return memory;

if (!dev) {
dev = &fallback_dev;
gfp |= GFP_DMA;
}

if (ops->alloc_coherent)
return ops->alloc_coherent(dev, size,
dma_handle, gfp);
return NULL;
}
EXPORT_SYMBOL(dma_alloc_coherent);

/*
* Unmap coherent memory.
* The caller must ensure that the device has finished accessing the mapping.
*/
void dma_free_coherent(struct device *dev, size_t size,
void *vaddr, dma_addr_t bus)
{
struct dma_mapping_ops *ops = get_dma_ops(dev);

WARN_ON(irqs_disabled()); /* for portability */

if (dma_release_from_coherent(dev, get_order(size), vaddr))
return;

if (ops->free_coherent)
ops->free_coherent(dev, size, vaddr, bus);
}
EXPORT_SYMBOL(dma_free_coherent);

static int __init pci_iommu_init(void)
{
calgary_iommu_init();
Expand Down
4 changes: 2 additions & 2 deletions trunk/arch/x86/kernel/pci-gart_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ gart_map_single(struct device *dev, phys_addr_t paddr, size_t size, int dir)
unsigned long bus;

if (!dev)
dev = &fallback_dev;
dev = &x86_dma_fallback_dev;

if (!need_iommu(dev, paddr, size))
return paddr;
Expand Down Expand Up @@ -427,7 +427,7 @@ gart_map_sg(struct device *dev, struct scatterlist *sg, int nents, int dir)
return 0;

if (!dev)
dev = &fallback_dev;
dev = &x86_dma_fallback_dev;

out = 0;
start = 0;
Expand Down
47 changes: 37 additions & 10 deletions trunk/include/asm-x86/dma-mapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
#include <linux/scatterlist.h>
#include <asm/io.h>
#include <asm/swiotlb.h>
#include <asm-generic/dma-coherent.h>

extern dma_addr_t bad_dma_address;
extern int iommu_merge;
extern struct device fallback_dev;
extern struct device x86_dma_fallback_dev;
extern int panic_on_overflow;
extern int force_iommu;

Expand Down Expand Up @@ -87,13 +88,7 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)

#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)

void *dma_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t flag);

void dma_free_coherent(struct device *dev, size_t size,
void *vaddr, dma_addr_t dma_handle);

#define dma_is_consistent(d, h) (1)

extern int dma_supported(struct device *hwdev, u64 mask);
extern int dma_set_mask(struct device *dev, u64 mask);
Expand Down Expand Up @@ -247,7 +242,39 @@ static inline int dma_get_cache_alignment(void)
return boot_cpu_data.x86_clflush_size;
}

#define dma_is_consistent(d, h) (1)
static inline void *
dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
gfp_t gfp)
{
struct dma_mapping_ops *ops = get_dma_ops(dev);
void *memory;

if (dma_alloc_from_coherent(dev, size, dma_handle, &memory))
return memory;

if (!dev) {
dev = &x86_dma_fallback_dev;
gfp |= GFP_DMA;
}

if (ops->alloc_coherent)
return ops->alloc_coherent(dev, size,
dma_handle, gfp);
return NULL;
}

static inline void dma_free_coherent(struct device *dev, size_t size,
void *vaddr, dma_addr_t bus)
{
struct dma_mapping_ops *ops = get_dma_ops(dev);

WARN_ON(irqs_disabled()); /* for portability */

if (dma_release_from_coherent(dev, get_order(size), vaddr))
return;

if (ops->free_coherent)
ops->free_coherent(dev, size, vaddr, bus);
}

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

0 comments on commit 007f44c

Please sign in to comment.