1 #ifndef __NOUVEAU_BO_H__
2 #define __NOUVEAU_BO_H__
4 #include <drm/drm_gem.h>
6 struct nouveau_channel;
11 struct ttm_buffer_object bo;
12 struct ttm_placement placement;
14 struct ttm_place placements[3];
15 struct ttm_place busy_placements[3];
16 struct ttm_bo_kmap_obj kmap;
17 struct list_head head;
19 /* protected by ttm_bo_reserve() */
20 struct drm_file *reserved_by;
21 struct list_head entry;
25 struct list_head vma_list;
30 struct nouveau_drm_tile *tile;
32 /* Only valid if allocated via nouveau_gem_new() and iff you hold a
33 * gem reference to it! For debugging, use gem.filp != NULL to test
34 * whether it is valid. */
35 struct drm_gem_object gem;
37 /* protect by the ttm reservation lock */
40 struct ttm_bo_kmap_obj dma_buf_vmap;
43 static inline struct nouveau_bo *
44 nouveau_bo(struct ttm_buffer_object *bo)
46 return container_of(bo, struct nouveau_bo, bo);
50 nouveau_bo_ref(struct nouveau_bo *ref, struct nouveau_bo **pnvbo)
52 struct nouveau_bo *prev;
58 *pnvbo = ref ? nouveau_bo(ttm_bo_reference(&ref->bo)) : NULL;
60 struct ttm_buffer_object *bo = &prev->bo;
68 extern struct ttm_bo_driver nouveau_bo_driver;
70 void nouveau_bo_move_init(struct nouveau_drm *);
71 int nouveau_bo_new(struct drm_device *, int size, int align, u32 flags,
72 u32 tile_mode, u32 tile_flags, struct sg_table *sg,
73 struct reservation_object *robj,
74 struct nouveau_bo **);
75 int nouveau_bo_pin(struct nouveau_bo *, u32 flags);
76 int nouveau_bo_unpin(struct nouveau_bo *);
77 int nouveau_bo_map(struct nouveau_bo *);
78 void nouveau_bo_unmap(struct nouveau_bo *);
79 void nouveau_bo_placement_set(struct nouveau_bo *, u32 type, u32 busy);
80 u16 nouveau_bo_rd16(struct nouveau_bo *, unsigned index);
81 void nouveau_bo_wr16(struct nouveau_bo *, unsigned index, u16 val);
82 u32 nouveau_bo_rd32(struct nouveau_bo *, unsigned index);
83 void nouveau_bo_wr32(struct nouveau_bo *, unsigned index, u32 val);
84 void nouveau_bo_fence(struct nouveau_bo *, struct nouveau_fence *, bool exclusive);
85 int nouveau_bo_validate(struct nouveau_bo *, bool interruptible,
89 nouveau_bo_vma_find(struct nouveau_bo *, struct nouveau_vm *);
91 int nouveau_bo_vma_add(struct nouveau_bo *, struct nouveau_vm *,
92 struct nouveau_vma *);
93 void nouveau_bo_vma_del(struct nouveau_bo *, struct nouveau_vma *);
95 /* TODO: submit equivalent to TTM generic API upstream? */
96 static inline void __iomem *
97 nvbo_kmap_obj_iovirtual(struct nouveau_bo *nvbo)
100 void __iomem *ioptr = (void __force __iomem *)ttm_kmap_obj_virtual(
101 &nvbo->kmap, &is_iomem);
102 WARN_ON_ONCE(ioptr && !is_iomem);