~ubuntu-branches/debian/experimental/linux-tools/experimental

« back to all changes in this revision

Viewing changes to arch/arm/include/asm/dma-mapping.h

  • Committer: Package Import Robot
  • Author(s): Ben Hutchings
  • Date: 2014-02-02 16:57:49 UTC
  • mfrom: (1.1.10) (0.1.21 sid)
  • Revision ID: package-import@ubuntu.com-20140202165749-tw94o9t1t0a8txk6
Tags: 3.13-1~exp2
Merge changes from sid up to 3.12.6-3

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
#include <asm-generic/dma-coherent.h>
12
12
#include <asm/memory.h>
13
13
 
 
14
#include <xen/xen.h>
 
15
#include <asm/xen/hypervisor.h>
 
16
 
14
17
#define DMA_ERROR_CODE  (~0)
15
18
extern struct dma_map_ops arm_dma_ops;
16
19
extern struct dma_map_ops arm_coherent_dma_ops;
17
20
 
18
 
static inline struct dma_map_ops *get_dma_ops(struct device *dev)
 
21
static inline struct dma_map_ops *__generic_dma_ops(struct device *dev)
19
22
{
20
23
        if (dev && dev->archdata.dma_ops)
21
24
                return dev->archdata.dma_ops;
22
25
        return &arm_dma_ops;
23
26
}
24
27
 
 
28
static inline struct dma_map_ops *get_dma_ops(struct device *dev)
 
29
{
 
30
        if (xen_initial_domain())
 
31
                return xen_dma_ops;
 
32
        else
 
33
                return __generic_dma_ops(dev);
 
34
}
 
35
 
25
36
static inline void set_dma_ops(struct device *dev, struct dma_map_ops *ops)
26
37
{
27
38
        BUG_ON(!dev);
64
75
{
65
76
        return (dma_addr_t)__virt_to_bus((unsigned long)(addr));
66
77
}
 
78
 
67
79
#else
68
80
static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn)
69
81
{
86
98
}
87
99
#endif
88
100
 
 
101
/* The ARM override for dma_max_pfn() */
 
102
static inline unsigned long dma_max_pfn(struct device *dev)
 
103
{
 
104
        return PHYS_PFN_OFFSET + dma_to_pfn(dev, *dev->dma_mask);
 
105
}
 
106
#define dma_max_pfn(dev) dma_max_pfn(dev)
 
107
 
 
108
static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
 
109
{
 
110
        unsigned int offset = paddr & ~PAGE_MASK;
 
111
        return pfn_to_dma(dev, __phys_to_pfn(paddr)) + offset;
 
112
}
 
113
 
 
114
static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t dev_addr)
 
115
{
 
116
        unsigned int offset = dev_addr & ~PAGE_MASK;
 
117
        return __pfn_to_phys(dma_to_pfn(dev, dev_addr)) + offset;
 
118
}
 
119
 
 
120
static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
 
121
{
 
122
        u64 limit, mask;
 
123
 
 
124
        if (!dev->dma_mask)
 
125
                return 0;
 
126
 
 
127
        mask = *dev->dma_mask;
 
128
 
 
129
        limit = (mask + 1) & ~mask;
 
130
        if (limit && size > limit)
 
131
                return 0;
 
132
 
 
133
        if ((addr | (addr + size - 1)) & ~mask)
 
134
                return 0;
 
135
 
 
136
        return 1;
 
137
}
 
138
 
 
139
static inline void dma_mark_clean(void *addr, size_t size) { }
 
140
 
89
141
/*
90
142
 * DMA errors are defined by all-bits-set in the DMA address.
91
143
 */