Merge remote-tracking branch 'asoc/fix/wm8994' into asoc-linus
[deliverable/linux.git] / drivers / gpu / drm / nouveau / nouveau_bo.h
1 #ifndef __NOUVEAU_BO_H__
2 #define __NOUVEAU_BO_H__
3
4 struct nouveau_channel;
5 struct nouveau_fence;
6 struct nouveau_vma;
7
8 struct 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;
28 struct nouveau_drm_tile *tile;
29
30 struct drm_gem_object *gem;
31
32 /* protect by the ttm reservation lock */
33 int pin_refcnt;
34
35 struct ttm_bo_kmap_obj dma_buf_vmap;
36 };
37
38 static inline struct nouveau_bo *
39 nouveau_bo(struct ttm_buffer_object *bo)
40 {
41 return container_of(bo, struct nouveau_bo, bo);
42 }
43
44 static inline int
45 nouveau_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
63 extern struct ttm_bo_driver nouveau_bo_driver;
64
65 void nouveau_bo_move_init(struct nouveau_drm *);
66 int 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 **);
69 int nouveau_bo_pin(struct nouveau_bo *, u32 flags);
70 int nouveau_bo_unpin(struct nouveau_bo *);
71 int nouveau_bo_map(struct nouveau_bo *);
72 void nouveau_bo_unmap(struct nouveau_bo *);
73 void nouveau_bo_placement_set(struct nouveau_bo *, u32 type, u32 busy);
74 u16 nouveau_bo_rd16(struct nouveau_bo *, unsigned index);
75 void nouveau_bo_wr16(struct nouveau_bo *, unsigned index, u16 val);
76 u32 nouveau_bo_rd32(struct nouveau_bo *, unsigned index);
77 void nouveau_bo_wr32(struct nouveau_bo *, unsigned index, u32 val);
78 void nouveau_bo_fence(struct nouveau_bo *, struct nouveau_fence *);
79 int nouveau_bo_validate(struct nouveau_bo *, bool interruptible,
80 bool no_wait_gpu);
81
82 struct nouveau_vma *
83 nouveau_bo_vma_find(struct nouveau_bo *, struct nouveau_vm *);
84
85 int nouveau_bo_vma_add(struct nouveau_bo *, struct nouveau_vm *,
86 struct nouveau_vma *);
87 void nouveau_bo_vma_del(struct nouveau_bo *, struct nouveau_vma *);
88
89 /* TODO: submit equivalent to TTM generic API upstream? */
90 static inline void __iomem *
91 nvbo_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
100 #endif
This page took 0.032511 seconds and 5 git commands to generate.