FILE
nouveau_bo.h
File preview with syntax highlighting.
linux-6.19.14/drivers/gpu/drm/nouveau/nouveau_bo.h
1/* SPDX-License-Identifier: MIT */ 2#ifndef __NOUVEAU_BO_H__ 3#define __NOUVEAU_BO_H__ 4#include <drm/drm_gem.h> 5#include <drm/ttm/ttm_bo.h> 6#include <drm/ttm/ttm_placement.h> 7 8struct nouveau_channel; 9struct nouveau_cli; 10struct nouveau_drm; 11struct nouveau_fence; 12struct nouveau_vma; 13 14struct nouveau_bo { 15 struct ttm_buffer_object bo; 16 struct ttm_placement placement; 17 u32 valid_domains; 18 struct ttm_place placements[3]; 19 bool force_coherent; 20 struct ttm_bo_kmap_obj kmap; 21 struct list_head head; 22 struct list_head io_reserve_lru; 23 24 /* protected by ttm_bo_reserve() */ 25 struct drm_file *reserved_by; 26 struct list_head entry; 27 int pbbo_index; 28 bool validate_mapped; 29 30 /* Root GEM object we derive the dma_resv of in case this BO is not 31 * shared between VMs. 32 */ 33 struct drm_gem_object *r_obj; 34 bool no_share; 35 36 /* GPU address space is independent of CPU word size */ 37 uint64_t offset; 38 39 struct list_head vma_list; 40 41 unsigned contig:1; 42 unsigned page:5; 43 unsigned kind:8; 44 unsigned comp:3; 45 unsigned zeta:3; 46 unsigned mode; 47 48 struct nouveau_drm_tile *tile; 49}; 50 51static inline struct nouveau_bo * 52nouveau_bo(struct ttm_buffer_object *bo) 53{ 54 return container_of(bo, struct nouveau_bo, bo); 55} 56 57static inline void 58nouveau_bo_fini(struct nouveau_bo *bo) 59{ 60 ttm_bo_fini(&bo->bo); 61} 62 63extern struct ttm_device_funcs nouveau_bo_driver; 64 65void nouveau_bo_move_init(struct nouveau_drm *); 66struct nouveau_bo *nouveau_bo_alloc(struct nouveau_cli *, u64 *size, int *align, 67 u32 domain, u32 tile_mode, u32 tile_flags, bool internal); 68int nouveau_bo_init(struct nouveau_bo *, u64 size, int align, u32 domain, 69 struct sg_table *sg, struct dma_resv *robj); 70int nouveau_bo_new(struct nouveau_cli *, u64 size, int align, u32 domain, 71 u32 tile_mode, u32 tile_flags, struct sg_table *sg, 72 struct dma_resv *robj, 73 struct nouveau_bo **); 74int nouveau_bo_pin_locked(struct nouveau_bo *nvbo, uint32_t domain, bool contig); 75void nouveau_bo_unpin_locked(struct nouveau_bo *nvbo); 76int nouveau_bo_pin(struct nouveau_bo *, u32 flags, bool contig); 77int nouveau_bo_unpin(struct nouveau_bo *); 78int nouveau_bo_map(struct nouveau_bo *); 79void nouveau_bo_unmap(struct nouveau_bo *); 80void nouveau_bo_placement_set(struct nouveau_bo *, u32 type, u32 busy); 81void nouveau_bo_wr16(struct nouveau_bo *, unsigned index, u16 val); 82u32 nouveau_bo_rd32(struct nouveau_bo *, unsigned index); 83void nouveau_bo_wr32(struct nouveau_bo *, unsigned index, u32 val); 84vm_fault_t nouveau_ttm_fault_reserve_notify(struct ttm_buffer_object *bo); 85void nouveau_bo_fence(struct nouveau_bo *, struct nouveau_fence *, bool exclusive); 86int nouveau_bo_validate(struct nouveau_bo *, bool interruptible, 87 bool no_wait_gpu); 88void nouveau_bo_sync_for_device(struct nouveau_bo *nvbo); 89void nouveau_bo_sync_for_cpu(struct nouveau_bo *nvbo); 90void nouveau_bo_add_io_reserve_lru(struct ttm_buffer_object *bo); 91void nouveau_bo_del_io_reserve_lru(struct ttm_buffer_object *bo); 92 93int nouveau_bo_new_pin(struct nouveau_cli *, u32 domain, u32 size, struct nouveau_bo **); 94int nouveau_bo_new_map(struct nouveau_cli *, u32 domain, u32 size, struct nouveau_bo **); 95int nouveau_bo_new_map_gpu(struct nouveau_cli *, u32 domain, u32 size, 96 struct nouveau_bo **, struct nouveau_vma **); 97void nouveau_bo_unpin_del(struct nouveau_bo **); 98 99/* TODO: submit equivalent to TTM generic API upstream? */ 100static inline void __iomem * 101nvbo_kmap_obj_iovirtual(struct nouveau_bo *nvbo) 102{ 103 bool is_iomem; 104 void __iomem *ioptr = (void __force __iomem *)ttm_kmap_obj_virtual( 105 &nvbo->kmap, &is_iomem); 106 WARN_ON_ONCE(ioptr && !is_iomem); 107 return ioptr; 108} 109 110int nv04_bo_move_init(struct nouveau_channel *, u32); 111int nv04_bo_move_m2mf(struct nouveau_channel *, struct ttm_buffer_object *, 112 struct ttm_resource *, struct ttm_resource *); 113 114int nv50_bo_move_init(struct nouveau_channel *, u32); 115int nv50_bo_move_m2mf(struct nouveau_channel *, struct ttm_buffer_object *, 116 struct ttm_resource *, struct ttm_resource *); 117 118int nv84_bo_move_exec(struct nouveau_channel *, struct ttm_buffer_object *, 119 struct ttm_resource *, struct ttm_resource *); 120 121int nva3_bo_move_copy(struct nouveau_channel *, struct ttm_buffer_object *, 122 struct ttm_resource *, struct ttm_resource *); 123 124int nvc0_bo_move_init(struct nouveau_channel *, u32); 125int nvc0_bo_move_m2mf(struct nouveau_channel *, struct ttm_buffer_object *, 126 struct ttm_resource *, struct ttm_resource *); 127 128int nvc0_bo_move_copy(struct nouveau_channel *, struct ttm_buffer_object *, 129 struct ttm_resource *, struct ttm_resource *); 130 131int nve0_bo_move_init(struct nouveau_channel *, u32); 132int nve0_bo_move_copy(struct nouveau_channel *, struct ttm_buffer_object *, 133 struct ttm_resource *, struct ttm_resource *); 134 135#define NVBO_WR32_(b,o,dr,f) nouveau_bo_wr32((b), (o)/4 + (dr), (f)) 136#define NVBO_RD32_(b,o,dr) nouveau_bo_rd32((b), (o)/4 + (dr)) 137#define NVBO_RD32(A...) DRF_RD(NVBO_RD32_, ##A) 138#define NVBO_RV32(A...) DRF_RV(NVBO_RD32_, ##A) 139#define NVBO_TV32(A...) DRF_TV(NVBO_RD32_, ##A) 140#define NVBO_TD32(A...) DRF_TD(NVBO_RD32_, ##A) 141#define NVBO_WR32(A...) DRF_WR( NVBO_WR32_, ##A) 142#define NVBO_WV32(A...) DRF_WV( NVBO_WR32_, ##A) 143#define NVBO_WD32(A...) DRF_WD( NVBO_WR32_, ##A) 144#define NVBO_MR32(A...) DRF_MR(NVBO_RD32_, NVBO_WR32_, u32, ##A) 145#define NVBO_MV32(A...) DRF_MV(NVBO_RD32_, NVBO_WR32_, u32, ##A) 146#define NVBO_MD32(A...) DRF_MD(NVBO_RD32_, NVBO_WR32_, u32, ##A) 147#endif
~/
Read-only file preview.