aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/dma-buf.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/dma-buf.h')
-rw-r--r--include/linux/dma-buf.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h
index 24e0f4828711..ee7ef9990d9a 100644
--- a/include/linux/dma-buf.h
+++ b/include/linux/dma-buf.h
@@ -50,6 +50,17 @@ struct dma_buf_attachment;
50 * @unmap_dma_buf: decreases usecount of buffer, might deallocate scatter 50 * @unmap_dma_buf: decreases usecount of buffer, might deallocate scatter
51 * pages. 51 * pages.
52 * @release: release this buffer; to be called after the last dma_buf_put. 52 * @release: release this buffer; to be called after the last dma_buf_put.
53 * @begin_cpu_access: [optional] called before cpu access to invalidate cpu
54 * caches and allocate backing storage (if not yet done)
55 * respectively pin the objet into memory.
56 * @end_cpu_access: [optional] called after cpu access to flush cashes.
57 * @kmap_atomic: maps a page from the buffer into kernel address
58 * space, users may not block until the subsequent unmap call.
59 * This callback must not sleep.
60 * @kunmap_atomic: [optional] unmaps a atomically mapped page from the buffer.
61 * This Callback must not sleep.
62 * @kmap: maps a page from the buffer into kernel address space.
63 * @kunmap: [optional] unmaps a page from the buffer.
53 */ 64 */
54struct dma_buf_ops { 65struct dma_buf_ops {
55 int (*attach)(struct dma_buf *, struct device *, 66 int (*attach)(struct dma_buf *, struct device *,
@@ -73,6 +84,14 @@ struct dma_buf_ops {
73 /* after final dma_buf_put() */ 84 /* after final dma_buf_put() */
74 void (*release)(struct dma_buf *); 85 void (*release)(struct dma_buf *);
75 86
87 int (*begin_cpu_access)(struct dma_buf *, size_t, size_t,
88 enum dma_data_direction);
89 void (*end_cpu_access)(struct dma_buf *, size_t, size_t,
90 enum dma_data_direction);
91 void *(*kmap_atomic)(struct dma_buf *, unsigned long);
92 void (*kunmap_atomic)(struct dma_buf *, unsigned long, void *);
93 void *(*kmap)(struct dma_buf *, unsigned long);
94 void (*kunmap)(struct dma_buf *, unsigned long, void *);
76}; 95};
77 96
78/** 97/**
@@ -140,6 +159,14 @@ struct sg_table *dma_buf_map_attachment(struct dma_buf_attachment *,
140 enum dma_data_direction); 159 enum dma_data_direction);
141void dma_buf_unmap_attachment(struct dma_buf_attachment *, struct sg_table *, 160void dma_buf_unmap_attachment(struct dma_buf_attachment *, struct sg_table *,
142 enum dma_data_direction); 161 enum dma_data_direction);
162int dma_buf_begin_cpu_access(struct dma_buf *dma_buf, size_t start, size_t len,
163 enum dma_data_direction dir);
164void dma_buf_end_cpu_access(struct dma_buf *dma_buf, size_t start, size_t len,
165 enum dma_data_direction dir);
166void *dma_buf_kmap_atomic(struct dma_buf *, unsigned long);
167void dma_buf_kunmap_atomic(struct dma_buf *, unsigned long, void *);
168void *dma_buf_kmap(struct dma_buf *, unsigned long);
169void dma_buf_kunmap(struct dma_buf *, unsigned long, void *);
143#else 170#else
144 171
145static inline struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf, 172static inline struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf,
@@ -188,6 +215,38 @@ static inline void dma_buf_unmap_attachment(struct dma_buf_attachment *attach,
188 return; 215 return;
189} 216}
190 217
218static inline int dma_buf_begin_cpu_access(struct dma_buf *,
219 size_t, size_t,
220 enum dma_data_direction)
221{
222 return -ENODEV;
223}
224
225static inline void dma_buf_end_cpu_access(struct dma_buf *,
226 size_t, size_t,
227 enum dma_data_direction)
228{
229}
230
231static inline void *dma_buf_kmap_atomic(struct dma_buf *, unsigned long)
232{
233 return NULL;
234}
235
236static inline void dma_buf_kunmap_atomic(struct dma_buf *, unsigned long,
237 void *)
238{
239}
240
241static inline void *dma_buf_kmap(struct dma_buf *, unsigned long)
242{
243 return NULL;
244}
245
246static inline void dma_buf_kunmap(struct dma_buf *, unsigned long,
247 void *)
248{
249}
191#endif /* CONFIG_DMA_SHARED_BUFFER */ 250#endif /* CONFIG_DMA_SHARED_BUFFER */
192 251
193#endif /* __DMA_BUF_H__ */ 252#endif /* __DMA_BUF_H__ */