Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf
[deliverable/linux.git] / drivers / gpu / drm / nouveau / nouveau_bo.h
CommitLineData
8be21a64
BS
1#ifndef __NOUVEAU_BO_H__
2#define __NOUVEAU_BO_H__
3
4struct nouveau_channel;
ebb945a9 5struct nouveau_fence;
8be21a64
BS
6struct nouveau_vma;
7
8be21a64
BS
8struct nouveau_bo {
9 struct ttm_buffer_object bo;
10 struct ttm_placement placement;
11 u32 valid_domains;
12 u32 placements[3];
13 u32 busy_placements[3];
14 struct ttm_bo_kmap_obj kmap;
15 struct list_head head;
16
17 /* protected by ttm_bo_reserve() */
18 struct drm_file *reserved_by;
19 struct list_head entry;
20 int pbbo_index;
21 bool validate_mapped;
22
23 struct list_head vma_list;
24 unsigned page_shift;
25
26 u32 tile_mode;
27 u32 tile_flags;
ebb945a9 28 struct nouveau_drm_tile *tile;
8be21a64
BS
29
30 struct drm_gem_object *gem;
0ae6d7bc
DV
31
32 /* protect by the ttm reservation lock */
8be21a64
BS
33 int pin_refcnt;
34
35 struct ttm_bo_kmap_obj dma_buf_vmap;
8be21a64
BS
36};
37
38static inline struct nouveau_bo *
39nouveau_bo(struct ttm_buffer_object *bo)
40{
41 return container_of(bo, struct nouveau_bo, bo);
42}
43
44static inline int
45nouveau_bo_ref(struct nouveau_bo *ref, struct nouveau_bo **pnvbo)
46{
47 struct nouveau_bo *prev;
48
49 if (!pnvbo)
50 return -EINVAL;
51 prev = *pnvbo;
52
53 *pnvbo = ref ? nouveau_bo(ttm_bo_reference(&ref->bo)) : NULL;
54 if (prev) {
55 struct ttm_buffer_object *bo = &prev->bo;
56
57 ttm_bo_unref(&bo);
58 }
59
60 return 0;
61}
62
63extern struct ttm_bo_driver nouveau_bo_driver;
64
49981046 65void nouveau_bo_move_init(struct nouveau_drm *);
8be21a64
BS
66int nouveau_bo_new(struct drm_device *, int size, int align, u32 flags,
67 u32 tile_mode, u32 tile_flags, struct sg_table *sg,
68 struct nouveau_bo **);
69int nouveau_bo_pin(struct nouveau_bo *, u32 flags);
70int nouveau_bo_unpin(struct nouveau_bo *);
71int nouveau_bo_map(struct nouveau_bo *);
72void nouveau_bo_unmap(struct nouveau_bo *);
73void nouveau_bo_placement_set(struct nouveau_bo *, u32 type, u32 busy);
74u16 nouveau_bo_rd16(struct nouveau_bo *, unsigned index);
75void nouveau_bo_wr16(struct nouveau_bo *, unsigned index, u16 val);
76u32 nouveau_bo_rd32(struct nouveau_bo *, unsigned index);
77void nouveau_bo_wr32(struct nouveau_bo *, unsigned index, u32 val);
78void nouveau_bo_fence(struct nouveau_bo *, struct nouveau_fence *);
79int nouveau_bo_validate(struct nouveau_bo *, bool interruptible,
97a875cb 80 bool no_wait_gpu);
8be21a64
BS
81
82struct nouveau_vma *
83nouveau_bo_vma_find(struct nouveau_bo *, struct nouveau_vm *);
84
85int nouveau_bo_vma_add(struct nouveau_bo *, struct nouveau_vm *,
86 struct nouveau_vma *);
87void nouveau_bo_vma_del(struct nouveau_bo *, struct nouveau_vma *);
88
ebb945a9
BS
89/* TODO: submit equivalent to TTM generic API upstream? */
90static inline void __iomem *
91nvbo_kmap_obj_iovirtual(struct nouveau_bo *nvbo)
92{
93 bool is_iomem;
94 void __iomem *ioptr = (void __force __iomem *)ttm_kmap_obj_virtual(
95 &nvbo->kmap, &is_iomem);
96 WARN_ON_ONCE(ioptr && !is_iomem);
97 return ioptr;
98}
99
8be21a64 100#endif
This page took 0.074646 seconds and 5 git commands to generate.