XenevaOS
Loading...
Searching...
No Matches
dma-buf.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * Header file for dma buffer sharing framework.
4 *
5 * Copyright(C) 2011 Linaro Limited. All rights reserved.
6 * Author: Sumit Semwal <sumit.semwal@ti.com>
7 *
8 * Many thanks to linaro-mm-sig list, and specially
9 * Arnd Bergmann <arnd@arndb.de>, Rob Clark <rob@ti.com> and
10 * Daniel Vetter <daniel@ffwll.ch> for their support in creation and
11 * refining of this idea.
12 */
13#ifndef __DMA_BUF_H__
14#define __DMA_BUF_H__
15
16#include <linux/iosys-map.h>
17#include <linux/file.h>
18#include <linux/err.h>
19#include <linux/scatterlist.h>
20#include <linux/list.h>
21#include <linux/dma-mapping.h>
22#include <linux/fs.h>
23/*
24 * DCL delta: mainline's <linux/fs.h> includes <linux/uuid.h> (linux-7.2
25 * fs.h:37), and that is how DRM headers that name uuid_t -- virtgpu_drv.h:101
26 * is the reader here -- see the type. DCL's fs.h is a pinned ABI blob that
27 * includes nothing (see its opening note), so the include its mainline
28 * counterpart would have supplied is carried here, on the header that pulls
29 * fs.h in: drm_gem.h -> dma-buf.h.
30 */
31#include <linux/uuid.h>
32#include <linux/dma-fence.h>
33#include <linux/wait.h>
34#include <linux/pci-p2pdma.h>
35
36struct device;
37struct dma_buf;
39
73 int (*attach)(struct dma_buf *, struct dma_buf_attachment *);
74
84 void (*detach)(struct dma_buf *, struct dma_buf_attachment *);
85
111
124
180 struct sg_table * (*map_dma_buf)(struct dma_buf_attachment *,
181 enum dma_data_direction);
191 struct sg_table *,
192 enum dma_data_direction);
193
194 /* TODO: Add try_map_dma_buf version, to return immed with -EBUSY
195 * if the call would block.
196 */
197
204 void (*release)(struct dma_buf *);
205
232
249
285 int (*mmap)(struct dma_buf *, struct vm_area_struct *vma);
286
287 int (*vmap)(struct dma_buf *dmabuf, struct iosys_map *map);
288 void (*vunmap)(struct dma_buf *dmabuf, struct iosys_map *map);
289};
290
303struct dma_buf {
309 size_t size;
310
317 struct file *file;
318
326
328 const struct dma_buf_ops *ops;
329
337
343
349 const char *exp_name;
350
361 const char *name;
362
365
372 struct module *owner;
373
376
378 void *priv;
379
428 struct dma_resv *resv;
429
432
441};
442
473
503
518 const char *exp_name;
519 struct module *owner;
520 const struct dma_buf_ops *ops;
521 size_t size;
522 int flags;
523 struct dma_resv *resv;
524 void *priv;
525};
526
534#define DEFINE_DMA_BUF_EXPORT_INFO(name) \
535 struct dma_buf_export_info name = { .exp_name = KBUILD_MODNAME, \
536 .owner = THIS_MODULE }
537
547static inline void get_dma_buf(struct dma_buf *dmabuf)
548{
549 get_file(dmabuf->file);
550}
551
560static inline bool dma_buf_is_dynamic(struct dma_buf *dmabuf)
561{
562 return !!dmabuf->ops->pin;
563}
564
566 struct device *dev);
567struct dma_buf_attachment *
569 const struct dma_buf_attach_ops *importer_ops,
570 void *importer_priv);
572 struct dma_buf_attachment *attach);
573int dma_buf_pin(struct dma_buf_attachment *attach);
575
576struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info);
577
578int dma_buf_fd(struct dma_buf *dmabuf, int flags);
579struct dma_buf *dma_buf_get(int fd);
580void dma_buf_put(struct dma_buf *dmabuf);
581
583 enum dma_data_direction);
585 enum dma_data_direction);
589 enum dma_data_direction dir);
591 enum dma_data_direction dir);
592struct sg_table *
594 enum dma_data_direction direction);
596 struct sg_table *sg_table,
597 enum dma_data_direction direction);
598
599int dma_buf_mmap(struct dma_buf *, struct vm_area_struct *,
600 unsigned long);
601int dma_buf_vmap(struct dma_buf *dmabuf, struct iosys_map *map);
602void dma_buf_vunmap(struct dma_buf *dmabuf, struct iosys_map *map);
603int dma_buf_vmap_unlocked(struct dma_buf *dmabuf, struct iosys_map *map);
604void dma_buf_vunmap_unlocked(struct dma_buf *dmabuf, struct iosys_map *map);
606struct dma_buf *dma_buf_iter_next(struct dma_buf *dmbuf);
607#endif /* __DMA_BUF_H__ */
uint8_t flags
Definition virtio.h:0
int map
Definition d_mode.c:31
int dma_buf_vmap(struct dma_buf *dmabuf, struct iosys_map *map)
int dma_buf_mmap(struct dma_buf *, struct vm_area_struct *, unsigned long)
struct dma_buf * dma_buf_get(int fd)
void dma_buf_vunmap(struct dma_buf *dmabuf, struct iosys_map *map)
struct dma_buf * dma_buf_iter_next(struct dma_buf *dmbuf)
int dma_buf_vmap_unlocked(struct dma_buf *dmabuf, struct iosys_map *map)
int dma_buf_begin_cpu_access(struct dma_buf *dma_buf, enum dma_data_direction dir)
struct dma_buf * dma_buf_iter_begin(void)
void dma_buf_detach(struct dma_buf *dmabuf, struct dma_buf_attachment *attach)
int dma_buf_end_cpu_access(struct dma_buf *dma_buf, enum dma_data_direction dir)
struct sg_table * dma_buf_map_attachment(struct dma_buf_attachment *, enum dma_data_direction)
int dma_buf_pin(struct dma_buf_attachment *attach)
void dma_buf_unmap_attachment(struct dma_buf_attachment *, struct sg_table *, enum dma_data_direction)
struct dma_buf * dma_buf_export(const struct dma_buf_export_info *exp_info)
void dma_buf_invalidate_mappings(struct dma_buf *dma_buf)
void dma_buf_put(struct dma_buf *dmabuf)
void dma_buf_unmap_attachment_unlocked(struct dma_buf_attachment *attach, struct sg_table *sg_table, enum dma_data_direction direction)
int dma_buf_fd(struct dma_buf *dmabuf, int flags)
struct sg_table * dma_buf_map_attachment_unlocked(struct dma_buf_attachment *attach, enum dma_data_direction direction)
struct dma_buf_attachment * dma_buf_attach(struct dma_buf *dmabuf, struct device *dev)
void dma_buf_unpin(struct dma_buf_attachment *attach)
struct dma_buf_attachment * dma_buf_dynamic_attach(struct dma_buf *dmabuf, struct device *dev, const struct dma_buf_attach_ops *importer_ops, void *importer_priv)
bool dma_buf_attach_revocable(struct dma_buf_attachment *attach)
void dma_buf_vunmap_unlocked(struct dma_buf *dmabuf, struct iosys_map *map)
dma_data_direction
Definition dma-direction.h:21
const struct device * dev
Definition drm_print.h:519
unsigned int __poll_t
Definition fs.h:50
int spinlock_t
Definition kernel.h:44
Definition fs.h:255
Definition dma-buf.h:435
wait_queue_head_t * poll
Definition dma-buf.h:437
__poll_t active
Definition dma-buf.h:439
struct dma_fence_cb cb
Definition dma-buf.h:436
Definition dma-buf.h:448
void(* invalidate_mappings)(struct dma_buf_attachment *attach)
Definition dma-buf.h:471
bool allow_peer2peer
Definition dma-buf.h:455
Definition dma-buf.h:494
void * importer_priv
Definition dma-buf.h:500
const struct dma_buf_attach_ops * importer_ops
Definition dma-buf.h:499
bool peer2peer
Definition dma-buf.h:498
void * priv
Definition dma-buf.h:501
struct dma_buf * dmabuf
Definition dma-buf.h:495
struct device * dev
Definition dma-buf.h:496
struct list_head node
Definition dma-buf.h:497
Definition dma-buf.h:517
const struct dma_buf_ops * ops
Definition dma-buf.h:520
struct dma_resv * resv
Definition dma-buf.h:523
struct module * owner
Definition dma-buf.h:519
size_t size
Definition dma-buf.h:521
int flags
Definition dma-buf.h:522
const char * exp_name
Definition dma-buf.h:518
void * priv
Definition dma-buf.h:524
Definition dma-buf.h:46
void(* unmap_dma_buf)(struct dma_buf_attachment *, struct sg_table *, enum dma_data_direction)
Definition dma-buf.h:190
void(* release)(struct dma_buf *)
Definition dma-buf.h:204
int(* end_cpu_access)(struct dma_buf *, enum dma_data_direction)
Definition dma-buf.h:248
void(* detach)(struct dma_buf *, struct dma_buf_attachment *)
Definition dma-buf.h:84
int(* vmap)(struct dma_buf *dmabuf, struct iosys_map *map)
Definition dma-buf.h:287
int(* mmap)(struct dma_buf *, struct vm_area_struct *vma)
Definition dma-buf.h:285
void(* unpin)(struct dma_buf_attachment *attach)
Definition dma-buf.h:123
int(* attach)(struct dma_buf *, struct dma_buf_attachment *)
Definition dma-buf.h:73
void(* vunmap)(struct dma_buf *dmabuf, struct iosys_map *map)
Definition dma-buf.h:288
int(* begin_cpu_access)(struct dma_buf *, enum dma_data_direction)
Definition dma-buf.h:231
int(* pin)(struct dma_buf_attachment *attach)
Definition dma-buf.h:110
Definition dma-buf.h:303
struct dma_resv * resv
Definition dma-buf.h:428
struct dma_buf::dma_buf_poll_cb_t cb_in
struct module * owner
Definition dma-buf.h:372
spinlock_t name_lock
Definition dma-buf.h:364
struct iosys_map vmap_ptr
Definition dma-buf.h:342
wait_queue_head_t poll
Definition dma-buf.h:431
size_t size
Definition dma-buf.h:309
struct file * file
Definition dma-buf.h:317
struct list_head attachments
Definition dma-buf.h:325
const char * exp_name
Definition dma-buf.h:349
struct dma_buf::dma_buf_poll_cb_t cb_out
struct list_head list_node
Definition dma-buf.h:375
unsigned vmapping_counter
Definition dma-buf.h:336
const char * name
Definition dma-buf.h:361
void * priv
Definition dma-buf.h:378
const struct dma_buf_ops * ops
Definition dma-buf.h:328
Definition dma-fence.h:127
Definition dma-resv.h:155
Definition file.h:140
Definition fs.h:142
Definition iosys-map.h:109
Definition list.h:11
Definition scatterlist.h:135
Definition mm.h:182
Definition wait.h:75