do not store GPU address in TTM
Subsystems (7)
cover do not store GPU address in TTM
With this patch series I am trying to remove GPU address dependency in TTM and moving GPU address calculation to individual drm drivers.
I tested this patch series on qxl, bochs and amdgpu. Christian tested it on radeon HW. It would be nice if someone test this for nouveau and vmgfx.
Nirmoy Das (8):
drm/amdgpu: move ttm bo->offset to amdgpu_bo drm/radeon: don't use ttm bo->offset drm/vmwgfx: don't use ttm bo->offset drm/nouveau: don't use ttm bo->offset drm/qxl: don't use ttm bo->offset drm/vram-helper: don't use ttm bo->offset drm/bochs: use drm_gem_vram_offset to get bo offset drm/ttm: do not keep GPU dependent addresses
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 22 ++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 29 ++++++++++++++++----- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 1 + drivers/gpu/drm/bochs/bochs_kms.c | 2 +- drivers/gpu/drm/drm_gem_vram_helper.c | 2 +- drivers/gpu/drm/nouveau/dispnv04/crtc.c | 6 ++--- drivers/gpu/drm/nouveau/dispnv04/disp.c | 2 +- drivers/gpu/drm/nouveau/dispnv04/overlay.c | 6 ++--- drivers/gpu/drm/nouveau/dispnv50/base507c.c | 2 +- drivers/gpu/drm/nouveau/dispnv50/core507d.c | 2 +- drivers/gpu/drm/nouveau/dispnv50/ovly507e.c | 2 +- drivers/gpu/drm/nouveau/dispnv50/wndw.c | 2 +- drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c | 2 +- drivers/gpu/drm/nouveau/nouveau_abi16.c | 8 +++--- drivers/gpu/drm/nouveau/nouveau_bo.c | 1 + drivers/gpu/drm/nouveau/nouveau_bo.h | 3 +++ drivers/gpu/drm/nouveau/nouveau_chan.c | 2 +- drivers/gpu/drm/nouveau/nouveau_dmem.c | 2 +- drivers/gpu/drm/nouveau/nouveau_fbcon.c | 2 +- drivers/gpu/drm/nouveau/nouveau_gem.c | 10 +++---- drivers/gpu/drm/qxl/qxl_drv.h | 6 ++--- drivers/gpu/drm/qxl/qxl_kms.c | 5 ++-- drivers/gpu/drm/qxl/qxl_object.h | 5 ---- drivers/gpu/drm/qxl/qxl_ttm.c | 9 ------- drivers/gpu/drm/radeon/radeon.h | 1 + drivers/gpu/drm/radeon/radeon_object.h | 16 +++++++++++- drivers/gpu/drm/radeon/radeon_ttm.c | 4 +-- drivers/gpu/drm/ttm/ttm_bo.c | 7 ----- drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 4 +-- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 2 -- include/drm/ttm/ttm_bo_api.h | 2 -- include/drm/ttm/ttm_bo_driver.h | 1 - 35 files changed, 99 insertions(+), 76 deletions(-)
--
2.25.0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 1/8 drm/amdgpu: move ttm bo->offset to amdgpu_bo
GPU address should belong to driver not in memory management. This patch moves ttm bo.offset and gpu_offset calculation to amdgpu driver.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 22 ++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 29 ++++++++++++++++------ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 1 + 4 files changed, 44 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +20 -2
@@ -917,7 +917,7 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain, bo->pin_count++;if (max_offset !=0 ) { -u64 domain_start = bo->tbo.bdev->man[mem_type].gpu_offset; +u64 domain_start =amdgpu_ttm_domain_start (adev, mem_type);WARN_ON_ONCE (max_offset < (amdgpu_bo_gpu_offset (bo) - domain_start)); }
@@ -1445,7 +1445,25 @@ u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo)WARN_ON_ONCE (bo->tbo.mem.mem_type ==TTM_PL_VRAM && !(bo->flags &AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS )); -return amdgpu_gmc_sign_extend (bo->tbo.offset); +return amdgpu_bo_gpu_offset_no_check (bo); +} + +/** +* amdgpu_bo_gpu_offset_no_check - return GPU offset of bo +* @bo: amdgpu object for which we query the offset +* +* Returns: +* current GPU offset of the object without raising warnings. +*/ +u64 amdgpu_bo_gpu_offset_no_check (struct amdgpu_bo *bo) +{ +struct amdgpu_device *adev =amdgpu_ttm_adev (bo->tbo.bdev); +uint64_t offset; + + offset = (bo->tbo.mem.start <<PAGE_SHIFT ) + +amdgpu_ttm_domain_start (adev, bo->tbo.mem.mem_type); + +return amdgpu_gmc_sign_extend (offset); }/**
drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +1 -0
@@ -279,6 +279,7 @@ void amdgpu_bo_fence(struct amdgpu_bo *bo, struct dma_fence *fence, bool shared);int amdgpu_bo_sync_wait (struct amdgpu_bo *bo,void *owner,bool intr);u64 amdgpu_bo_gpu_offset (struct amdgpu_bo *bo); +u64 amdgpu_bo_gpu_offset_no_check (struct amdgpu_bo *bo);int amdgpu_bo_validate (struct amdgpu_bo *bo);int amdgpu_bo_restore_shadow (struct amdgpu_bo *shadow,struct dma_fence **fence);
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +22 -7
@@ -97,7 +97,6 @@ static int amdgpu_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,case TTM_PL_TT :/* GTT memory */ man->func = &amdgpu_gtt_mgr_func; - man->gpu_offset = adev->gmc.gart_start; man->available_caching =TTM_PL_MASK_CACHING ; man->default_caching =TTM_PL_FLAG_CACHED ; man->flags =TTM_MEMTYPE_FLAG_MAPPABLE |TTM_MEMTYPE_FLAG_CMA ;
@@ -105,7 +104,6 @@ static int amdgpu_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,case TTM_PL_VRAM :/* "On-card" video ram */ man->func = &amdgpu_vram_mgr_func; - man->gpu_offset = adev->gmc.vram_start; man->flags =TTM_MEMTYPE_FLAG_FIXED |TTM_MEMTYPE_FLAG_MAPPABLE ; man->available_caching =TTM_PL_FLAG_UNCACHED |TTM_PL_FLAG_WC ;
@@ -116,7 +114,6 @@ static int amdgpu_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,case AMDGPU_PL_OA :/* On-chip GDS memory*/ man->func = &ttm_bo_manager_func; - man->gpu_offset =0 ; man->flags =TTM_MEMTYPE_FLAG_FIXED |TTM_MEMTYPE_FLAG_CMA ; man->available_caching =TTM_PL_FLAG_UNCACHED ; man->default_caching =TTM_PL_FLAG_UNCACHED ;
@@ -264,7 +261,7 @@ static uint64_t amdgpu_mm_node_addr(struct ttm_buffer_object *bo,if (mm_node->start !=AMDGPU_BO_INVALID_OFFSET ) { addr = mm_node->start <<PAGE_SHIFT ; - addr += bo->bdev->man[mem->mem_type].gpu_offset; + addr +=amdgpu_ttm_domain_start (amdgpu_ttm_adev (bo->bdev), mem->mem_type); }return addr; }
@@ -751,6 +748,27 @@ static unsigned long amdgpu_ttm_io_mem_pfn(struct ttm_buffer_object *bo, (offset >>PAGE_SHIFT ); } +/** +* amdgpu_ttm_domain_start - Returns GPU start address +* @adev: amdgpu device object +* @type: type of the memory +* +* Returns: +* GPU start address of a memory domain +*/ + +uint64_t amdgpu_ttm_domain_start (struct amdgpu_device *adev,uint32_t type) +{ +switch (type) { +case TTM_PL_TT : +return adev->gmc.gart_start; +case TTM_PL_VRAM : +return adev->gmc.vram_start; + } + +return 0 ; +} +/* * TTM backend functions. */
@@ -1162,9 +1180,6 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo) bo->mem = tmp; } - bo->offset = (bo->mem.start <<PAGE_SHIFT ) + - bo->bdev->man[bo->mem.mem_type].gpu_offset; -return 0 ; }
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +1 -0
@@ -102,6 +102,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo,int amdgpu_mmap (struct file *filp,struct vm_area_struct *vma);int amdgpu_ttm_alloc_gart (struct ttm_buffer_object *bo);int amdgpu_ttm_recover_gart (struct ttm_buffer_object *tbo); +uint64_t amdgpu_ttm_domain_start (struct amdgpu_device *adev,uint32_t type);#if IS_ENABLED (CONFIG_DRM_AMDGPU_USERPTR )int amdgpu_ttm_tt_get_user_pages (struct amdgpu_bo *bo,struct page **pages);
Signature · 6 lines
2.25.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/8 drm/radeon: don't use ttm bo->offset
In reply to Nirmoy DasCalculate GPU offset in radeon_bo_gpu_offset without depending on bo->offset
--- drivers/gpu/drm/radeon/radeon.h | 1 + drivers/gpu/drm/radeon/radeon_object.h | 16 +++++++++++++++- drivers/gpu/drm/radeon/radeon_ttm.c | 4 +--- 3 files changed, 17 insertions(+), 4 deletions(-)
drivers/gpu/drm/radeon/radeon.h +1 -0
@@ -2828,6 +2828,7 @@ extern void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 sizeextern void radeon_program_register_sequence (struct radeon_device *rdev,const u32 *registers,const u32 array_size); +struct radeon_device *radeon_get_rdev (struct ttm_bo_device *bdev);/* * vm
drivers/gpu/drm/radeon/radeon_object.h +15 -1
@@ -90,7 +90,21 @@ static inline void radeon_bo_unreserve(struct radeon_bo *bo)*/ static inline u64 radeon_bo_gpu_offset (struct radeon_bo *bo) { -return bo->tbo.offset; +struct radeon_device *rdev; +u64 start =0 ; + + rdev =radeon_get_rdev (bo->tbo.bdev); + +switch (bo->tbo.mem.mem_type) { +case TTM_PL_TT : + start = rdev->mc.gtt_start; +break ; +case TTM_PL_VRAM : + start = rdev->mc.vram_start; +break ; + } + +return (bo->tbo.mem.start <<PAGE_SHIFT ) + start; }static inline unsigned long radeon_bo_size (struct radeon_bo *bo)
drivers/gpu/drm/radeon/radeon_ttm.c +1 -3
@@ -56,7 +56,7 @@static int radeon_ttm_debugfs_init (struct radeon_device *rdev);static void radeon_ttm_debugfs_fini (struct radeon_device *rdev); -static struct radeon_device *radeon_get_rdev (struct ttm_bo_device *bdev) +struct radeon_device *radeon_get_rdev (struct ttm_bo_device *bdev) {struct radeon_mman *mman;struct radeon_device *rdev;
@@ -82,7 +82,6 @@ static int radeon_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,break ;case TTM_PL_TT : man->func = &ttm_bo_manager_func; - man->gpu_offset = rdev->mc.gtt_start; man->available_caching =TTM_PL_MASK_CACHING ; man->default_caching =TTM_PL_FLAG_CACHED ; man->flags =TTM_MEMTYPE_FLAG_MAPPABLE |TTM_MEMTYPE_FLAG_CMA ;
@@ -104,7 +103,6 @@ static int radeon_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,case TTM_PL_VRAM :/* "On-card" video ram */ man->func = &ttm_bo_manager_func; - man->gpu_offset = rdev->mc.vram_start; man->flags =TTM_MEMTYPE_FLAG_FIXED |TTM_MEMTYPE_FLAG_MAPPABLE ; man->available_caching =TTM_PL_FLAG_UNCACHED |TTM_PL_FLAG_WC ;
Signature · 6 lines
2.25.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/8 drm/vmwgfx: don't use ttm bo->offset
In reply to Nirmoy DasCalculate GPU offset within vmwgfx driver itself without depending on bo->offset
--- drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 4 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 2 -- 4 files changed, 4 insertions(+), 6 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_bo.c +2 -2
@@ -258,7 +258,7 @@ int vmw_bo_pin_in_start_of_vram(struct vmw_private *dev_priv, ret =ttm_bo_validate (bo, &placement, &ctx);/* For some reason we didn't end up at the start of vram */ -WARN_ON (ret ==0 && bo->offset !=0 ); +WARN_ON (ret ==0 && bo->mem.start !=0 );if (!ret)vmw_bo_pin_reserved (buf, true);
@@ -317,7 +317,7 @@ void vmw_bo_get_guest_ptr(const struct ttm_buffer_object *bo, {if (bo->mem.mem_type ==TTM_PL_VRAM ) { ptr->gmrId =SVGA_GMR_FRAMEBUFFER ; - ptr->offset = bo->offset; + ptr->offset = bo->mem.start <<PAGE_SHIFT ; }else { ptr->gmrId = bo->mem.start; ptr->offset =0 ;
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +1 -1
@@ -3313,7 +3313,7 @@ static void vmw_apply_relocations(struct vmw_sw_context *sw_context) bo = &reloc->vbo->base;switch (bo->mem.mem_type) {case TTM_PL_VRAM : - reloc->location->offset += bo->offset; + reloc->location->offset += bo->mem.start <<PAGE_SHIFT ; reloc->location->gmrId =SVGA_GMR_FRAMEBUFFER ;break ;case VMW_PL_GMR :
drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c +1 -1
@@ -612,7 +612,7 @@ static int vmw_fifo_emit_dummy_legacy_query(struct vmw_private *dev_priv,if (bo->mem.mem_type ==TTM_PL_VRAM ) { cmd->body.guestResult.gmrId =SVGA_GMR_FRAMEBUFFER ; - cmd->body.guestResult.offset = bo->offset; + cmd->body.guestResult.offset = bo->mem.start <<PAGE_SHIFT ; }else { cmd->body.guestResult.gmrId = bo->mem.start; cmd->body.guestResult.offset =0 ;
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c +0 -2
@@ -750,7 +750,6 @@ static int vmw_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,case TTM_PL_VRAM :/* "On-card" video ram */ man->func = &ttm_bo_manager_func; - man->gpu_offset =0 ; man->flags =TTM_MEMTYPE_FLAG_FIXED |TTM_MEMTYPE_FLAG_MAPPABLE ; man->available_caching =TTM_PL_FLAG_CACHED ; man->default_caching =TTM_PL_FLAG_CACHED ;
@@ -763,7 +762,6 @@ static int vmw_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,* slots as well as the bo size. */ man->func = &vmw_gmrid_manager_func; - man->gpu_offset =0 ; man->flags =TTM_MEMTYPE_FLAG_CMA |TTM_MEMTYPE_FLAG_MAPPABLE ; man->available_caching =TTM_PL_FLAG_CACHED ; man->default_caching =TTM_PL_FLAG_CACHED ;
Signature · 6 lines
2.25.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/8 drm/nouveau: don't use ttm bo->offset
In reply to Nirmoy DasStore ttm bo->offset in struct nouveau_bo instead.
Christian König <[email protected]>
--- drivers/gpu/drm/nouveau/dispnv04/crtc.c | 6 +++--- drivers/gpu/drm/nouveau/dispnv04/disp.c | 2 +- drivers/gpu/drm/nouveau/dispnv04/overlay.c | 6 +++--- drivers/gpu/drm/nouveau/dispnv50/base507c.c | 2 +- drivers/gpu/drm/nouveau/dispnv50/core507d.c | 2 +- drivers/gpu/drm/nouveau/dispnv50/ovly507e.c | 2 +- drivers/gpu/drm/nouveau/dispnv50/wndw.c | 2 +- drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c | 2 +- drivers/gpu/drm/nouveau/nouveau_abi16.c | 8 ++++---- drivers/gpu/drm/nouveau/nouveau_bo.c | 1 + drivers/gpu/drm/nouveau/nouveau_bo.h | 3 +++ drivers/gpu/drm/nouveau/nouveau_chan.c | 2 +- drivers/gpu/drm/nouveau/nouveau_dmem.c | 2 +- drivers/gpu/drm/nouveau/nouveau_fbcon.c | 2 +- drivers/gpu/drm/nouveau/nouveau_gem.c | 10 +++++----- 15 files changed, 28 insertions(+), 24 deletions(-)
drivers/gpu/drm/nouveau/dispnv04/crtc.c +3 -3
@@ -845,7 +845,7 @@ nv04_crtc_do_mode_set_base(struct drm_crtc *crtc, fb =nouveau_framebuffer (crtc->primary->fb); } - nv_crtc->fb.offset = fb->nvbo->bo.offset; + nv_crtc->fb.offset = fb->nvbo->offset;if (nv_crtc->lut.depth != drm_fb->format->depth) { nv_crtc->lut.depth = drm_fb->format->depth;
@@ -1013,7 +1013,7 @@ nv04_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,nv04_cursor_upload (dev, cursor, nv_crtc->cursor.nvbo);nouveau_bo_unmap (cursor); - nv_crtc->cursor.offset = nv_crtc->cursor.nvbo->bo.offset; + nv_crtc->cursor.offset = nv_crtc->cursor.nvbo->offset; nv_crtc->cursor.set_offset (nv_crtc, nv_crtc->cursor.offset); nv_crtc->cursor.show (nv_crtc, true); out:
@@ -1191,7 +1191,7 @@ nv04_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,/* Initialize a page flip struct */ *s = (struct nv04_page_flip_state ) { { }, event, crtc, fb->format->cpp[0 ] *8 , fb->pitches[0 ], - new_bo->bo.offset }; + new_bo->offset };/* Keep vblanks on during flip, for the target crtc of this flip */ drm_crtc_vblank_get (crtc);
drivers/gpu/drm/nouveau/dispnv04/disp.c +1 -1
@@ -151,7 +151,7 @@ nv04_display_init(struct drm_device *dev, bool resume, bool runtime)continue ;if (nv_crtc->cursor.set_offset) - nv_crtc->cursor.set_offset (nv_crtc, nv_crtc->cursor.nvbo->bo.offset); + nv_crtc->cursor.set_offset (nv_crtc, nv_crtc->cursor.nvbo->offset); nv_crtc->cursor.set_pos (nv_crtc, nv_crtc->cursor_saved_x, nv_crtc->cursor_saved_y); }
drivers/gpu/drm/nouveau/dispnv04/overlay.c +3 -3
@@ -150,7 +150,7 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,nvif_mask (dev,NV_PCRTC_ENGINE_CTRL + soff2,NV_CRTC_FSEL_OVERLAY ,0 );nvif_wr32 (dev,NV_PVIDEO_BASE (flip),0 ); -nvif_wr32 (dev,NV_PVIDEO_OFFSET_BUFF (flip), nv_fb->nvbo->bo.offset); +nvif_wr32 (dev,NV_PVIDEO_OFFSET_BUFF (flip), nv_fb->nvbo->offset);nvif_wr32 (dev,NV_PVIDEO_SIZE_IN (flip), src_h <<16 | src_w);nvif_wr32 (dev,NV_PVIDEO_POINT_IN (flip), src_y <<16 | src_x);nvif_wr32 (dev,NV_PVIDEO_DS_DX (flip), (src_w <<20 ) / crtc_w);
@@ -172,7 +172,7 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,if (format &NV_PVIDEO_FORMAT_PLANAR ) {nvif_wr32 (dev,NV_PVIDEO_UVPLANE_BASE (flip),0 );nvif_wr32 (dev,NV_PVIDEO_UVPLANE_OFFSET_BUFF (flip), - nv_fb->nvbo->bo.offset + fb->offsets[1 ]); + nv_fb->nvbo->offset + fb->offsets[1 ]); }nvif_wr32 (dev,NV_PVIDEO_FORMAT (flip), format | fb->pitches[0 ]);nvif_wr32 (dev,NV_PVIDEO_STOP ,0 );
@@ -396,7 +396,7 @@ nv04_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,for (i =0 ; i <2 ; i++) {nvif_wr32 (dev,NV_PVIDEO_BUFF0_START_ADDRESS +4 * i, - nv_fb->nvbo->bo.offset); + nv_fb->nvbo->offset);nvif_wr32 (dev,NV_PVIDEO_BUFF0_PITCH_LENGTH +4 * i, fb->pitches[0 ]);nvif_wr32 (dev,NV_PVIDEO_BUFF0_OFFSET +4 * i,0 );
drivers/gpu/drm/nouveau/dispnv50/base507c.c +1 -1
@@ -274,7 +274,7 @@ base507c_new_(const struct nv50_wndw_func *func, const u32 *format, ret =nv50_dmac_create (&drm->client.device, &disp->disp->object, &oclass, head, &args,sizeof (args), - disp->sync->bo.offset, &wndw->wndw); + disp->sync->offset, &wndw->wndw);if (ret) {NV_ERROR (drm,"base%04x allocation failed: %d\n" , oclass, ret);return ret;
drivers/gpu/drm/nouveau/dispnv50/core507d.c +1 -1
@@ -99,7 +99,7 @@ core507d_new_(const struct nv50_core_func *func, struct nouveau_drm *drm, ret =nv50_dmac_create (&drm->client.device, &disp->disp->object, &oclass,0 , &args,sizeof (args), - disp->sync->bo.offset, &core->chan); + disp->sync->offset, &core->chan);if (ret) {NV_ERROR (drm,"core%04x allocation failed: %d\n" , oclass, ret);return ret;
drivers/gpu/drm/nouveau/dispnv50/ovly507e.c +1 -1
@@ -186,7 +186,7 @@ ovly507e_new_(const struct nv50_wndw_func *func, const u32 *format, ret =nv50_dmac_create (&drm->client.device, &disp->disp->object, &oclass,0 , &args,sizeof (args), - disp->sync->bo.offset, &wndw->wndw); + disp->sync->offset, &wndw->wndw);if (ret) {NV_ERROR (drm,"ovly%04x allocation failed: %d\n" , oclass, ret);return ret;
drivers/gpu/drm/nouveau/dispnv50/wndw.c +1 -1
@@ -509,7 +509,7 @@ nv50_wndw_prepare_fb(struct drm_plane *plane, struct drm_plane_state *state) } asyw->state.fence =dma_resv_get_excl_rcu (fb->nvbo->bo.base.resv); - asyw->image.offset[0 ] = fb->nvbo->bo.offset; + asyw->image.offset[0 ] = fb->nvbo->offset;if (wndw->func->prepare) { asyh =nv50_head_atom_get (asyw->state.state, asyw->state.crtc);
drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c +1 -1
@@ -298,7 +298,7 @@ wndwc37e_new_(const struct nv50_wndw_func *func, struct nouveau_drm *drm, ret =nv50_dmac_create (&drm->client.device, &disp->disp->object, &oclass,0 , &args,sizeof (args), - disp->sync->bo.offset, &wndw->wndw); + disp->sync->offset, &wndw->wndw);if (ret) {NV_ERROR (drm,"qndw%04x allocation failed: %d\n" , oclass, ret);return ret;
drivers/gpu/drm/nouveau/nouveau_abi16.c +4 -4
@@ -558,13 +558,13 @@ nouveau_abi16_ioctl_notifierobj_alloc(ABI16_IOCTL_ARGS)if (drm->agp.bridge) { args.target =NV_DMA_V0_TARGET_AGP ; args.access =NV_DMA_V0_ACCESS_RDWR ; - args.start += drm->agp.base + chan->ntfy->bo.offset; - args.limit += drm->agp.base + chan->ntfy->bo.offset; + args.start += drm->agp.base + chan->ntfy->offset; + args.limit += drm->agp.base + chan->ntfy->offset; }else { args.target =NV_DMA_V0_TARGET_VM ; args.access =NV_DMA_V0_ACCESS_RDWR ; - args.start += chan->ntfy->bo.offset; - args.limit += chan->ntfy->bo.offset; + args.start += chan->ntfy->offset; + args.limit += chan->ntfy->offset; } client->route =NVDRM_OBJECT_ABI16 ;
drivers/gpu/drm/nouveau/nouveau_bo.c +1 -0
@@ -1311,6 +1311,7 @@ nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, bool evict,list_for_each_entry (vma, &nvbo->vma_list, head) {nouveau_vma_map (vma, mem); } + nvbo->offset = (new_reg->start <<PAGE_SHIFT ); }else {list_for_each_entry (vma, &nvbo->vma_list, head) {WARN_ON (ttm_bo_wait (bo, false, false));
drivers/gpu/drm/nouveau/nouveau_bo.h +3 -0
@@ -24,6 +24,9 @@ struct nouveau_bo {int pbbo_index;bool validate_mapped; +/* GPU address space is independent of CPU word size */ +uint64_t offset; +struct list_head vma_list; unsigned contig:1;
drivers/gpu/drm/nouveau/nouveau_chan.c +1 -1
@@ -162,7 +162,7 @@ nouveau_channel_prep(struct nouveau_drm *drm, struct nvif_device *device,* pushbuf lives in, this is because the GEM code requires that * we be able to call out to other (indirect) push buffers */ - chan->push.addr = chan->push.buffer->bo.offset; + chan->push.addr = chan->push.buffer->offset;if (device->info.family >=NV_DEVICE_INFO_V0_TESLA ) { ret = nouveau_vma_new(chan->push.buffer, chan->vmm,
drivers/gpu/drm/nouveau/nouveau_dmem.c +1 -1
@@ -89,7 +89,7 @@ static unsigned long nouveau_dmem_page_addr(struct page *page)struct nouveau_dmem_chunk *chunk = page->zone_device_data;unsigned long idx =page_to_pfn (page) - chunk->pfn_first; -return (idx <<PAGE_SHIFT ) + chunk->bo->bo.offset; +return (idx <<PAGE_SHIFT ) + chunk->bo->offset; }static void nouveau_dmem_page_free (struct page *page)
drivers/gpu/drm/nouveau/nouveau_fbcon.c +1 -1
@@ -393,7 +393,7 @@ nouveau_fbcon_create(struct drm_fb_helper *helper,/* To allow resizeing without swapping buffers */ NV_INFO (drm,"allocated %dx%d fb: 0x%llx, bo %p\n" , - fb->base.width, fb->base.height, fb->nvbo->bo.offset, nvbo); + fb->base.width, fb->base.height, fb->nvbo->offset, nvbo);vga_switcheroo_client_fb_set (dev->pdev, info);return 0 ;
drivers/gpu/drm/nouveau/nouveau_gem.c +5 -5
@@ -232,7 +232,7 @@ nouveau_gem_info(struct drm_file *file_priv, struct drm_gem_object *gem, rep->domain =NOUVEAU_GEM_DOMAIN_GART ; else rep->domain = NOUVEAU_GEM_DOMAIN_VRAM; - rep->offset = nvbo->bo.offset; + rep->offset = nvbo->offset;if (vmm->vmm.object.oclass >=NVIF_CLASS_VMM_NV50 ) { vma =nouveau_vma_find (nvbo, vmm);if (!vma)
@@ -516,7 +516,7 @@ validate_list(struct nouveau_channel *chan, struct nouveau_cli *cli, }if (drm->client.device.info.family <NV_DEVICE_INFO_V0_TESLA ) { - if (nvbo->bo.offset == b->presumed.offset && + if (nvbo->offset == b->presumed.offset && ((nvbo->bo.mem.mem_type == TTM_PL_VRAM && b->presumed.domain & NOUVEAU_GEM_DOMAIN_VRAM) || (nvbo->bo.mem.mem_type == TTM_PL_TT &&
@@ -527,7 +527,7 @@ validate_list(struct nouveau_channel *chan, struct nouveau_cli *cli, b->presumed.domain =NOUVEAU_GEM_DOMAIN_GART ; else b->presumed.domain = NOUVEAU_GEM_DOMAIN_VRAM; - b->presumed.offset = nvbo->bo.offset; + b->presumed.offset = nvbo->offset; b->presumed.valid =0 ; relocs++; }
@@ -805,7 +805,7 @@ nouveau_gem_ioctl_pushbuf(struct drm_device *dev, void *data,struct nouveau_bo *nvbo = (void *)(unsigned long ) bo[push[i].bo_index].user_priv; -OUT_RING (chan, (nvbo->bo.offset + push[i].offset) |2 ); +OUT_RING (chan, (nvbo->offset + push[i].offset) |2 );OUT_RING (chan,0 ); } }else {
@@ -840,7 +840,7 @@ nouveau_gem_ioctl_pushbuf(struct drm_device *dev, void *data, }OUT_RING (chan,0x20000000 | - (nvbo->bo.offset + push[i].offset)); + (nvbo->offset + push[i].offset));OUT_RING (chan,0 );for (j =0 ; j <NOUVEAU_DMA_SKIPS ; j++)OUT_RING (chan,0 );
Signature · 6 lines
2.25.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 4/8] drm/nouveau: don't use ttm bo->offset
Quoted 5 lines · Nirmoy Das
Store ttm
bo->offsetin structnouveau_boinstead.Signed-off-by Nirmoy Das <[email protected]>Christian König <[email protected]>
Missing Acked or Reviewed prefix for Christian.
Alex
Quoted 297 lines
--- drivers/gpu/drm/nouveau/dispnv04/crtc.c | 6 +++--- drivers/gpu/drm/nouveau/dispnv04/disp.c | 2 +- drivers/gpu/drm/nouveau/dispnv04/overlay.c | 6 +++--- drivers/gpu/drm/nouveau/dispnv50/base507c.c | 2 +- drivers/gpu/drm/nouveau/dispnv50/core507d.c | 2 +- drivers/gpu/drm/nouveau/dispnv50/ovly507e.c | 2 +- drivers/gpu/drm/nouveau/dispnv50/wndw.c | 2 +- drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c | 2 +- drivers/gpu/drm/nouveau/nouveau_abi16.c | 8 ++++---- drivers/gpu/drm/nouveau/nouveau_bo.c | 1 + drivers/gpu/drm/nouveau/nouveau_bo.h | 3 +++ drivers/gpu/drm/nouveau/nouveau_chan.c | 2 +- drivers/gpu/drm/nouveau/nouveau_dmem.c | 2 +- drivers/gpu/drm/nouveau/nouveau_fbcon.c | 2 +- drivers/gpu/drm/nouveau/nouveau_gem.c | 10 +++++----- 15 files changed, 28 insertions(+), 24 deletions(-)drivers/gpu/drm/nouveau/dispnv04/crtc.c +3
-3@@ -845,7 +845,7 @@ nv04_crtc_do_mode_set_base(struct drm_crtc *crtc, fb =nouveau_framebuffer (crtc->primary->fb); } - nv_crtc->fb.offset = fb->nvbo->bo.offset; + nv_crtc->fb.offset = fb->nvbo->offset;if (nv_crtc->lut.depth != drm_fb->format->depth) { nv_crtc->lut.depth = drm_fb->format->depth;@@ -1013,7 +1013,7 @@ nv04_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,nv04_cursor_upload (dev, cursor, nv_crtc->cursor.nvbo);nouveau_bo_unmap (cursor); - nv_crtc->cursor.offset = nv_crtc->cursor.nvbo->bo.offset; + nv_crtc->cursor.offset = nv_crtc->cursor.nvbo->offset; nv_crtc->cursor.set_offset (nv_crtc, nv_crtc->cursor.offset); nv_crtc->cursor.show (nv_crtc, true); out:@@ -1191,7 +1191,7 @@ nv04_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,/* Initialize a page flip struct */ *s = (struct nv04_page_flip_state ) { { }, event, crtc, fb->format->cpp[0 ] *8 , fb->pitches[0 ], - new_bo->bo.offset }; + new_bo->offset };/* Keep vblanks on during flip, for the target crtc of this flip */ drm_crtc_vblank_get (crtc);drivers/gpu/drm/nouveau/dispnv04/disp.c +1
-1@@ -151,7 +151,7 @@ nv04_display_init(struct drm_device *dev, bool resume, bool runtime)continue ;if (nv_crtc->cursor.set_offset) - nv_crtc->cursor.set_offset (nv_crtc, nv_crtc->cursor.nvbo->bo.offset); + nv_crtc->cursor.set_offset (nv_crtc, nv_crtc->cursor.nvbo->offset); nv_crtc->cursor.set_pos (nv_crtc, nv_crtc->cursor_saved_x, nv_crtc->cursor_saved_y); }drivers/gpu/drm/nouveau/dispnv04/overlay.c +3
-3@@ -150,7 +150,7 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,nvif_mask (dev,NV_PCRTC_ENGINE_CTRL + soff2,NV_CRTC_FSEL_OVERLAY ,0 );nvif_wr32 (dev,NV_PVIDEO_BASE (flip),0 ); -nvif_wr32 (dev,NV_PVIDEO_OFFSET_BUFF (flip), nv_fb->nvbo->bo.offset); +nvif_wr32 (dev,NV_PVIDEO_OFFSET_BUFF (flip), nv_fb->nvbo->offset);nvif_wr32 (dev,NV_PVIDEO_SIZE_IN (flip), src_h <<16 | src_w);nvif_wr32 (dev,NV_PVIDEO_POINT_IN (flip), src_y <<16 | src_x);nvif_wr32 (dev,NV_PVIDEO_DS_DX (flip), (src_w <<20 ) / crtc_w);@@ -172,7 +172,7 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,if (format &NV_PVIDEO_FORMAT_PLANAR ) {nvif_wr32 (dev,NV_PVIDEO_UVPLANE_BASE (flip),0 );nvif_wr32 (dev,NV_PVIDEO_UVPLANE_OFFSET_BUFF (flip), - nv_fb->nvbo->bo.offset + fb->offsets[1 ]); + nv_fb->nvbo->offset + fb->offsets[1 ]); }nvif_wr32 (dev,NV_PVIDEO_FORMAT (flip), format | fb->pitches[0 ]);nvif_wr32 (dev,NV_PVIDEO_STOP ,0 );@@ -396,7 +396,7 @@ nv04_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,for (i =0 ; i <2 ; i++) {nvif_wr32 (dev,NV_PVIDEO_BUFF0_START_ADDRESS +4 * i, - nv_fb->nvbo->bo.offset); + nv_fb->nvbo->offset);nvif_wr32 (dev,NV_PVIDEO_BUFF0_PITCH_LENGTH +4 * i, fb->pitches[0 ]);nvif_wr32 (dev,NV_PVIDEO_BUFF0_OFFSET +4 * i,0 );drivers/gpu/drm/nouveau/dispnv50/base507c.c +1
-1@@ -274,7 +274,7 @@ base507c_new_(const struct nv50_wndw_func *func, const u32 *format, ret =nv50_dmac_create (&drm->client.device, &disp->disp->object, &oclass, head, &args,sizeof (args), - disp->sync->bo.offset, &wndw->wndw); + disp->sync->offset, &wndw->wndw);if (ret) {NV_ERROR (drm,"base%04x allocation failed: %d\n" , oclass, ret);return ret;drivers/gpu/drm/nouveau/dispnv50/core507d.c +1
-1@@ -99,7 +99,7 @@ core507d_new_(const struct nv50_core_func *func, struct nouveau_drm *drm, ret =nv50_dmac_create (&drm->client.device, &disp->disp->object, &oclass,0 , &args,sizeof (args), - disp->sync->bo.offset, &core->chan); + disp->sync->offset, &core->chan);if (ret) {NV_ERROR (drm,"core%04x allocation failed: %d\n" , oclass, ret);return ret;drivers/gpu/drm/nouveau/dispnv50/ovly507e.c +1
-1@@ -186,7 +186,7 @@ ovly507e_new_(const struct nv50_wndw_func *func, const u32 *format, ret =nv50_dmac_create (&drm->client.device, &disp->disp->object, &oclass,0 , &args,sizeof (args), - disp->sync->bo.offset, &wndw->wndw); + disp->sync->offset, &wndw->wndw);if (ret) {NV_ERROR (drm,"ovly%04x allocation failed: %d\n" , oclass, ret);return ret;drivers/gpu/drm/nouveau/dispnv50/wndw.c +1
-1@@ -509,7 +509,7 @@ nv50_wndw_prepare_fb(struct drm_plane *plane, struct drm_plane_state *state) } asyw->state.fence =dma_resv_get_excl_rcu (fb->nvbo->bo.base.resv); - asyw->image.offset[0 ] = fb->nvbo->bo.offset; + asyw->image.offset[0 ] = fb->nvbo->offset;if (wndw->func->prepare) { asyh =nv50_head_atom_get (asyw->state.state, asyw->state.crtc);drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c +1
-1@@ -298,7 +298,7 @@ wndwc37e_new_(const struct nv50_wndw_func *func, struct nouveau_drm *drm, ret =nv50_dmac_create (&drm->client.device, &disp->disp->object, &oclass,0 , &args,sizeof (args), - disp->sync->bo.offset, &wndw->wndw); + disp->sync->offset, &wndw->wndw);if (ret) {NV_ERROR (drm,"qndw%04x allocation failed: %d\n" , oclass, ret);return ret;drivers/gpu/drm/nouveau/nouveau_abi16.c +4
-4@@ -558,13 +558,13 @@ nouveau_abi16_ioctl_notifierobj_alloc(ABI16_IOCTL_ARGS)if (drm->agp.bridge) { args.target =NV_DMA_V0_TARGET_AGP ; args.access =NV_DMA_V0_ACCESS_RDWR ; - args.start += drm->agp.base + chan->ntfy->bo.offset; - args.limit += drm->agp.base + chan->ntfy->bo.offset; + args.start += drm->agp.base + chan->ntfy->offset; + args.limit += drm->agp.base + chan->ntfy->offset; }else { args.target =NV_DMA_V0_TARGET_VM ; args.access =NV_DMA_V0_ACCESS_RDWR ; - args.start += chan->ntfy->bo.offset; - args.limit += chan->ntfy->bo.offset; + args.start += chan->ntfy->offset; + args.limit += chan->ntfy->offset; } client->route =NVDRM_OBJECT_ABI16 ;drivers/gpu/drm/nouveau/nouveau_bo.c +1
-0@@ -1311,6 +1311,7 @@ nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, bool evict,list_for_each_entry (vma, &nvbo->vma_list, head) {nouveau_vma_map (vma, mem); } + nvbo->offset = (new_reg->start <<PAGE_SHIFT ); }else {list_for_each_entry (vma, &nvbo->vma_list, head) {WARN_ON (ttm_bo_wait (bo, false, false));drivers/gpu/drm/nouveau/nouveau_bo.h +3
-0@@ -24,6 +24,9 @@ struct nouveau_bo {int pbbo_index;bool validate_mapped; +/* GPU address space is independent of CPU word size */ +uint64_t offset; +struct list_head vma_list; unsigned contig:1;drivers/gpu/drm/nouveau/nouveau_chan.c +1
-1@@ -162,7 +162,7 @@ nouveau_channel_prep(struct nouveau_drm *drm, struct nvif_device *device,* pushbuf lives in, this is because the GEM code requires that * we be able to call out to other (indirect) push buffers */ - chan->push.addr = chan->push.buffer->bo.offset; + chan->push.addr = chan->push.buffer->offset;if (device->info.family >=NV_DEVICE_INFO_V0_TESLA ) { ret = nouveau_vma_new(chan->push.buffer, chan->vmm,drivers/gpu/drm/nouveau/nouveau_dmem.c +1
-1@@ -89,7 +89,7 @@ static unsigned long nouveau_dmem_page_addr(struct page *page)struct nouveau_dmem_chunk *chunk = page->zone_device_data;unsigned long idx =page_to_pfn (page) - chunk->pfn_first; -return (idx <<PAGE_SHIFT ) + chunk->bo->bo.offset; +return (idx <<PAGE_SHIFT ) + chunk->bo->offset; }static void nouveau_dmem_page_free (struct page *page)drivers/gpu/drm/nouveau/nouveau_fbcon.c +1
-1@@ -393,7 +393,7 @@ nouveau_fbcon_create(struct drm_fb_helper *helper,/* To allow resizeing without swapping buffers */ NV_INFO (drm,"allocated %dx%d fb: 0x%llx, bo %p\n" , - fb->base.width, fb->base.height, fb->nvbo->bo.offset, nvbo); + fb->base.width, fb->base.height, fb->nvbo->offset, nvbo);vga_switcheroo_client_fb_set (dev->pdev, info);return 0 ;drivers/gpu/drm/nouveau/nouveau_gem.c +5
-6@@ -232,7 +232,7 @@ nouveau_gem_info(struct drm_file *file_priv, struct drm_gem_object *gem, rep->domain =NOUVEAU_GEM_DOMAIN_GART ; else rep->domain = NOUVEAU_GEM_DOMAIN_VRAM; - rep->offset = nvbo->bo.offset; + rep->offset = nvbo->offset;if (vmm->vmm.object.oclass >=NVIF_CLASS_VMM_NV50 ) { vma =nouveau_vma_find (nvbo, vmm);if (!vma)@@ -516,7 +516,7 @@ validate_list(struct nouveau_channel *chan, struct nouveau_cli *cli, }if (drm->client.device.info.family <NV_DEVICE_INFO_V0_TESLA ) { - if (nvbo->bo.offset == b->presumed.offset && + if (nvbo->offset == b->presumed.offset && ((nvbo->bo.mem.mem_type == TTM_PL_VRAM && b->presumed.domain & NOUVEAU_GEM_DOMAIN_VRAM) || (nvbo->bo.mem.mem_type == TTM_PL_TT &&@@ -527,7 +527,7 @@ validate_list(struct nouveau_channel *chan, struct nouveau_cli *cli, b->presumed.domain =NOUVEAU_GEM_DOMAIN_GART ; else b->presumed.domain = NOUVEAU_GEM_DOMAIN_VRAM; - b->presumed.offset = nvbo->bo.offset; + b->presumed.offset = nvbo->offset; b->presumed.valid =0 ; relocs++; }@@ -805,7 +805,7 @@ nouveau_gem_ioctl_pushbuf(struct drm_device *dev, void *data,struct nouveau_bo *nvbo = (void *)(unsigned long ) bo[push[i].bo_index].user_priv; -OUT_RING (chan, (nvbo->bo.offset + push[i].offset) |2 ); +OUT_RING (chan, (nvbo->offset + push[i].offset) |2 );OUT_RING (chan,0 ); } }else {@@ -840,7 +840,7 @@ nouveau_gem_ioctl_pushbuf(struct drm_device *dev, void *data, }OUT_RING (chan,0x20000000 | - (nvbo->bo.offset + push[i].offset)); + (nvbo->offset + push[i].offset));OUT_RING (chan,0 );for (j =0 ; j <NOUVEAU_DMA_SKIPS ; j++)OUT_RING (chan,0 ); --2.25.0
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 4/8] drm/nouveau: don't use ttm bo->offset
Quoted 6 lines · Alex Deucher
Quoted 4 lines · Nirmoy Das
Store ttm
bo->offsetin structnouveau_boinstead.Signed-off-by Nirmoy Das <[email protected]>Christian König <[email protected]>
Missing Acked or Reviewed prefix for Christian.
:facepalm: Thanks Alex.
Nirmoy
Quoted 300 lines
Alex
Quoted 297 lines
--- drivers/gpu/drm/nouveau/dispnv04/crtc.c | 6 +++--- drivers/gpu/drm/nouveau/dispnv04/disp.c | 2 +- drivers/gpu/drm/nouveau/dispnv04/overlay.c | 6 +++--- drivers/gpu/drm/nouveau/dispnv50/base507c.c | 2 +- drivers/gpu/drm/nouveau/dispnv50/core507d.c | 2 +- drivers/gpu/drm/nouveau/dispnv50/ovly507e.c | 2 +- drivers/gpu/drm/nouveau/dispnv50/wndw.c | 2 +- drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c | 2 +- drivers/gpu/drm/nouveau/nouveau_abi16.c | 8 ++++---- drivers/gpu/drm/nouveau/nouveau_bo.c | 1 + drivers/gpu/drm/nouveau/nouveau_bo.h | 3 +++ drivers/gpu/drm/nouveau/nouveau_chan.c | 2 +- drivers/gpu/drm/nouveau/nouveau_dmem.c | 2 +- drivers/gpu/drm/nouveau/nouveau_fbcon.c | 2 +- drivers/gpu/drm/nouveau/nouveau_gem.c | 10 +++++----- 15 files changed, 28 insertions(+), 24 deletions(-)drivers/gpu/drm/nouveau/dispnv04/crtc.c +3
-3@@ -845,7 +845,7 @@ nv04_crtc_do_mode_set_base(struct drm_crtc *crtc, fb =nouveau_framebuffer (crtc->primary->fb); } - nv_crtc->fb.offset = fb->nvbo->bo.offset; + nv_crtc->fb.offset = fb->nvbo->offset;if (nv_crtc->lut.depth != drm_fb->format->depth) { nv_crtc->lut.depth = drm_fb->format->depth;@@ -1013,7 +1013,7 @@ nv04_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,nv04_cursor_upload (dev, cursor, nv_crtc->cursor.nvbo);nouveau_bo_unmap (cursor); - nv_crtc->cursor.offset = nv_crtc->cursor.nvbo->bo.offset; + nv_crtc->cursor.offset = nv_crtc->cursor.nvbo->offset; nv_crtc->cursor.set_offset (nv_crtc, nv_crtc->cursor.offset); nv_crtc->cursor.show (nv_crtc, true); out:@@ -1191,7 +1191,7 @@ nv04_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,/* Initialize a page flip struct */ *s = (struct nv04_page_flip_state ) { { }, event, crtc, fb->format->cpp[0 ] *8 , fb->pitches[0 ], - new_bo->bo.offset }; + new_bo->offset };/* Keep vblanks on during flip, for the target crtc of this flip */ drm_crtc_vblank_get (crtc);drivers/gpu/drm/nouveau/dispnv04/disp.c +1
-1@@ -151,7 +151,7 @@ nv04_display_init(struct drm_device *dev, bool resume, bool runtime)continue ;if (nv_crtc->cursor.set_offset) - nv_crtc->cursor.set_offset (nv_crtc, nv_crtc->cursor.nvbo->bo.offset); + nv_crtc->cursor.set_offset (nv_crtc, nv_crtc->cursor.nvbo->offset); nv_crtc->cursor.set_pos (nv_crtc, nv_crtc->cursor_saved_x, nv_crtc->cursor_saved_y); }drivers/gpu/drm/nouveau/dispnv04/overlay.c +3
-3@@ -150,7 +150,7 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,nvif_mask (dev,NV_PCRTC_ENGINE_CTRL + soff2,NV_CRTC_FSEL_OVERLAY ,0 );nvif_wr32 (dev,NV_PVIDEO_BASE (flip),0 ); -nvif_wr32 (dev,NV_PVIDEO_OFFSET_BUFF (flip), nv_fb->nvbo->bo.offset); +nvif_wr32 (dev,NV_PVIDEO_OFFSET_BUFF (flip), nv_fb->nvbo->offset);nvif_wr32 (dev,NV_PVIDEO_SIZE_IN (flip), src_h <<16 | src_w);nvif_wr32 (dev,NV_PVIDEO_POINT_IN (flip), src_y <<16 | src_x);nvif_wr32 (dev,NV_PVIDEO_DS_DX (flip), (src_w <<20 ) / crtc_w);@@ -172,7 +172,7 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,if (format &NV_PVIDEO_FORMAT_PLANAR ) {nvif_wr32 (dev,NV_PVIDEO_UVPLANE_BASE (flip),0 );nvif_wr32 (dev,NV_PVIDEO_UVPLANE_OFFSET_BUFF (flip), - nv_fb->nvbo->bo.offset + fb->offsets[1 ]); + nv_fb->nvbo->offset + fb->offsets[1 ]); }nvif_wr32 (dev,NV_PVIDEO_FORMAT (flip), format | fb->pitches[0 ]);nvif_wr32 (dev,NV_PVIDEO_STOP ,0 );@@ -396,7 +396,7 @@ nv04_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,for (i =0 ; i <2 ; i++) {nvif_wr32 (dev,NV_PVIDEO_BUFF0_START_ADDRESS +4 * i, - nv_fb->nvbo->bo.offset); + nv_fb->nvbo->offset);nvif_wr32 (dev,NV_PVIDEO_BUFF0_PITCH_LENGTH +4 * i, fb->pitches[0 ]);nvif_wr32 (dev,NV_PVIDEO_BUFF0_OFFSET +4 * i,0 );drivers/gpu/drm/nouveau/dispnv50/base507c.c +1
-1@@ -274,7 +274,7 @@ base507c_new_(const struct nv50_wndw_func *func, const u32 *format, ret =nv50_dmac_create (&drm->client.device, &disp->disp->object, &oclass, head, &args,sizeof (args), - disp->sync->bo.offset, &wndw->wndw); + disp->sync->offset, &wndw->wndw);if (ret) {NV_ERROR (drm,"base%04x allocation failed: %d\n" , oclass, ret);return ret;drivers/gpu/drm/nouveau/dispnv50/core507d.c +1
-1@@ -99,7 +99,7 @@ core507d_new_(const struct nv50_core_func *func, struct nouveau_drm *drm, ret =nv50_dmac_create (&drm->client.device, &disp->disp->object, &oclass,0 , &args,sizeof (args), - disp->sync->bo.offset, &core->chan); + disp->sync->offset, &core->chan);if (ret) {NV_ERROR (drm,"core%04x allocation failed: %d\n" , oclass, ret);return ret;drivers/gpu/drm/nouveau/dispnv50/ovly507e.c +1
-1@@ -186,7 +186,7 @@ ovly507e_new_(const struct nv50_wndw_func *func, const u32 *format, ret =nv50_dmac_create (&drm->client.device, &disp->disp->object, &oclass,0 , &args,sizeof (args), - disp->sync->bo.offset, &wndw->wndw); + disp->sync->offset, &wndw->wndw);if (ret) {NV_ERROR (drm,"ovly%04x allocation failed: %d\n" , oclass, ret);return ret;drivers/gpu/drm/nouveau/dispnv50/wndw.c +1
-1@@ -509,7 +509,7 @@ nv50_wndw_prepare_fb(struct drm_plane *plane, struct drm_plane_state *state) } asyw->state.fence =dma_resv_get_excl_rcu (fb->nvbo->bo.base.resv); - asyw->image.offset[0 ] = fb->nvbo->bo.offset; + asyw->image.offset[0 ] = fb->nvbo->offset;if (wndw->func->prepare) { asyh =nv50_head_atom_get (asyw->state.state, asyw->state.crtc);drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c +1
-1@@ -298,7 +298,7 @@ wndwc37e_new_(const struct nv50_wndw_func *func, struct nouveau_drm *drm, ret =nv50_dmac_create (&drm->client.device, &disp->disp->object, &oclass,0 , &args,sizeof (args), - disp->sync->bo.offset, &wndw->wndw); + disp->sync->offset, &wndw->wndw);if (ret) {NV_ERROR (drm,"qndw%04x allocation failed: %d\n" , oclass, ret);return ret;drivers/gpu/drm/nouveau/nouveau_abi16.c +4
-4@@ -558,13 +558,13 @@ nouveau_abi16_ioctl_notifierobj_alloc(ABI16_IOCTL_ARGS)if (drm->agp.bridge) { args.target =NV_DMA_V0_TARGET_AGP ; args.access =NV_DMA_V0_ACCESS_RDWR ; - args.start += drm->agp.base + chan->ntfy->bo.offset; - args.limit += drm->agp.base + chan->ntfy->bo.offset; + args.start += drm->agp.base + chan->ntfy->offset; + args.limit += drm->agp.base + chan->ntfy->offset; }else { args.target =NV_DMA_V0_TARGET_VM ; args.access =NV_DMA_V0_ACCESS_RDWR ; - args.start += chan->ntfy->bo.offset; - args.limit += chan->ntfy->bo.offset; + args.start += chan->ntfy->offset; + args.limit += chan->ntfy->offset; } client->route =NVDRM_OBJECT_ABI16 ;drivers/gpu/drm/nouveau/nouveau_bo.c +1
-0@@ -1311,6 +1311,7 @@ nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, bool evict,list_for_each_entry (vma, &nvbo->vma_list, head) {nouveau_vma_map (vma, mem); } + nvbo->offset = (new_reg->start <<PAGE_SHIFT ); }else {list_for_each_entry (vma, &nvbo->vma_list, head) {WARN_ON (ttm_bo_wait (bo, false, false));drivers/gpu/drm/nouveau/nouveau_bo.h +3
-0@@ -24,6 +24,9 @@ struct nouveau_bo {int pbbo_index;bool validate_mapped; +/* GPU address space is independent of CPU word size */ +uint64_t offset; +struct list_head vma_list; unsigned contig:1;drivers/gpu/drm/nouveau/nouveau_chan.c +1
-1@@ -162,7 +162,7 @@ nouveau_channel_prep(struct nouveau_drm *drm, struct nvif_device *device,* pushbuf lives in, this is because the GEM code requires that * we be able to call out to other (indirect) push buffers */ - chan->push.addr = chan->push.buffer->bo.offset; + chan->push.addr = chan->push.buffer->offset;if (device->info.family >=NV_DEVICE_INFO_V0_TESLA ) { ret = nouveau_vma_new(chan->push.buffer, chan->vmm,drivers/gpu/drm/nouveau/nouveau_dmem.c +1
-1@@ -89,7 +89,7 @@ static unsigned long nouveau_dmem_page_addr(struct page *page)struct nouveau_dmem_chunk *chunk = page->zone_device_data;unsigned long idx =page_to_pfn (page) - chunk->pfn_first; -return (idx <<PAGE_SHIFT ) + chunk->bo->bo.offset; +return (idx <<PAGE_SHIFT ) + chunk->bo->offset; }static void nouveau_dmem_page_free (struct page *page)drivers/gpu/drm/nouveau/nouveau_fbcon.c +1
-1@@ -393,7 +393,7 @@ nouveau_fbcon_create(struct drm_fb_helper *helper,/* To allow resizeing without swapping buffers */ NV_INFO (drm,"allocated %dx%d fb: 0x%llx, bo %p\n" , - fb->base.width, fb->base.height, fb->nvbo->bo.offset, nvbo); + fb->base.width, fb->base.height, fb->nvbo->offset, nvbo);vga_switcheroo_client_fb_set (dev->pdev, info);return 0 ;drivers/gpu/drm/nouveau/nouveau_gem.c +5
-6@@ -232,7 +232,7 @@ nouveau_gem_info(struct drm_file *file_priv, struct drm_gem_object *gem, rep->domain =NOUVEAU_GEM_DOMAIN_GART ; else rep->domain = NOUVEAU_GEM_DOMAIN_VRAM; - rep->offset = nvbo->bo.offset; + rep->offset = nvbo->offset;if (vmm->vmm.object.oclass >=NVIF_CLASS_VMM_NV50 ) { vma =nouveau_vma_find (nvbo, vmm);if (!vma)@@ -516,7 +516,7 @@ validate_list(struct nouveau_channel *chan, struct nouveau_cli *cli, }if (drm->client.device.info.family <NV_DEVICE_INFO_V0_TESLA ) { - if (nvbo->bo.offset == b->presumed.offset && + if (nvbo->offset == b->presumed.offset && ((nvbo->bo.mem.mem_type == TTM_PL_VRAM && b->presumed.domain & NOUVEAU_GEM_DOMAIN_VRAM) || (nvbo->bo.mem.mem_type == TTM_PL_TT &&@@ -527,7 +527,7 @@ validate_list(struct nouveau_channel *chan, struct nouveau_cli *cli, b->presumed.domain =NOUVEAU_GEM_DOMAIN_GART ; else b->presumed.domain = NOUVEAU_GEM_DOMAIN_VRAM; - b->presumed.offset = nvbo->bo.offset; + b->presumed.offset = nvbo->offset; b->presumed.valid =0 ; relocs++; }@@ -805,7 +805,7 @@ nouveau_gem_ioctl_pushbuf(struct drm_device *dev, void *data,struct nouveau_bo *nvbo = (void *)(unsigned long ) bo[push[i].bo_index].user_priv; -OUT_RING (chan, (nvbo->bo.offset + push[i].offset) |2 ); +OUT_RING (chan, (nvbo->offset + push[i].offset) |2 );OUT_RING (chan,0 ); } }else {@@ -840,7 +840,7 @@ nouveau_gem_ioctl_pushbuf(struct drm_device *dev, void *data, }OUT_RING (chan,0x20000000 | - (nvbo->bo.offset + push[i].offset)); + (nvbo->offset + push[i].offset));OUT_RING (chan,0 );for (j =0 ; j <NOUVEAU_DMA_SKIPS ; j++)OUT_RING (chan,0 ); --2.25.0
Quoted 4 lines
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=02%7C01%7Cnirmoy.das%40amd.com%7C61fe524a09c64a10891d08d7b3c221a8%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637175518684441041&sdata=oHp63aoK9vbCtKA89jXhIO%2FRyzj9uNkLl2NTPk5waig%3D&reserved=0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 5/8 drm/qxl: don't use ttm bo->offset
In reply to Nirmoy DasThis patch also removes slot->gpu_offset which is not required as VRAM and PRIV slot are in separate PCI bar
--- drivers/gpu/drm/qxl/qxl_drv.h | 6 ++---- drivers/gpu/drm/qxl/qxl_kms.c | 5 ++--- drivers/gpu/drm/qxl/qxl_object.h | 5 ----- drivers/gpu/drm/qxl/qxl_ttm.c | 9 --------- 4 files changed, 4 insertions(+), 21 deletions(-)
drivers/gpu/drm/qxl/qxl_drv.h +2 -4
@@ -134,7 +134,6 @@ struct qxl_memslot {uint64_t start_phys_addr;uint64_t size;uint64_t high_bits; -uint64_t gpu_offset; };enum {
@@ -311,10 +310,9 @@ qxl_bo_physical_address(struct qxl_device *qdev, struct qxl_bo *bo, (bo->tbo.mem.mem_type ==TTM_PL_VRAM ) ? &qdev->main_slot : &qdev->surfaces_slot; -WARN_ON_ONCE ((bo->tbo.offset & slot->gpu_offset) != slot->gpu_offset); +/* TODO - need to hold one of the locks to read bo->tbo.mem.start */ -/* TODO - need to hold one of the locks to read tbo.offset */ -return slot->high_bits | (bo->tbo.offset - slot->gpu_offset + offset); +return slot->high_bits | ((bo->tbo.mem.start <<PAGE_SHIFT ) + offset); }/* qxl_display.c */
drivers/gpu/drm/qxl/qxl_kms.c +2 -3
@@ -86,11 +86,10 @@ static void setup_slot(struct qxl_device *qdev, high_bits <<= (64 - (qdev->rom->slot_gen_bits + qdev->rom->slot_id_bits)); slot->high_bits = high_bits; -DRM_INFO ("slot %d (%s): base 0x%08lx, size 0x%08lx, gpu_offset 0x%lx\n" , +DRM_INFO ("slot %d (%s): base 0x%08lx, size 0x%08lx\n" , slot->index, slot->name, (unsigned long )slot->start_phys_addr, - (unsigned long )slot->size, - (unsigned long )slot->gpu_offset); + (unsigned long )slot->size); }void qxl_reinit_memslots (struct qxl_device *qdev)
drivers/gpu/drm/qxl/qxl_object.h +0 -5
@@ -48,11 +48,6 @@ static inline void qxl_bo_unreserve(struct qxl_bo *bo)ttm_bo_unreserve (&bo->tbo); } -static inline u64 qxl_bo_gpu_offset (struct qxl_bo *bo) -{ -return bo->tbo.offset; -} -static inline unsigned long qxl_bo_size (struct qxl_bo *bo) {return bo->tbo.num_pages <<PAGE_SHIFT ;
drivers/gpu/drm/qxl/qxl_ttm.c +0 -9
@@ -51,11 +51,6 @@ static struct qxl_device *qxl_get_qdev(struct ttm_bo_device *bdev)static int qxl_init_mem_type (struct ttm_bo_device *bdev,uint32_t type,struct ttm_mem_type_manager *man) { -struct qxl_device *qdev =qxl_get_qdev (bdev); -unsigned int gpu_offset_shift = -64 - (qdev->rom->slot_gen_bits + qdev->rom->slot_id_bits +8 ); -struct qxl_memslot *slot; -switch (type) {case TTM_PL_SYSTEM :/* System memory */
@@ -66,11 +61,7 @@ static int qxl_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,case TTM_PL_VRAM :case TTM_PL_PRIV :/* "On-card" video ram */ - slot = (type ==TTM_PL_VRAM ) ? - &qdev->main_slot : &qdev->surfaces_slot; - slot->gpu_offset = (uint64_t )type << gpu_offset_shift; man->func = &ttm_bo_manager_func; - man->gpu_offset = slot->gpu_offset; man->flags =TTM_MEMTYPE_FLAG_FIXED |TTM_MEMTYPE_FLAG_MAPPABLE ; man->available_caching =TTM_PL_MASK_CACHING ;
Signature · 6 lines
2.25.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 6/8 drm/vram-helper: don't use ttm bo->offset
In reply to Nirmoy DasCalculate GPU offset within vram-helper without depending on bo->offset
--- drivers/gpu/drm/drm_gem_vram_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_gem_vram_helper.c +1 -1
@@ -214,7 +214,7 @@ s64 drm_gem_vram_offset(struct drm_gem_vram_object *gbo) {if (WARN_ON_ONCE (!gbo->pin_count))return (s64)-ENODEV ; -return gbo->bo.offset; +return gbo->bo.mem.start <<PAGE_SHIFT ; }EXPORT_SYMBOL (drm_gem_vram_offset);
Signature · 6 lines
2.25.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 6/8] drm/vram-helper: don't use ttm bo->offset
Quoted 4 lines · Nirmoy Das
Calculate GPU offset within vram-helper without depending on
bo->offsetSigned-off-by Nirmoy Das <[email protected]>
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 6/8] drm/vram-helper: don't use ttm bo->offset
Hi Gerd,
This is old one can you please review v3 https://lists.freedesktop.org/archives/dri-devel/2020-February/255760.html
Regards,
Nirmoy
Quoted 7 lines · Gerd Hoffmann
Quoted 4 lines · Nirmoy Das
Calculate GPU offset within vram-helper without depending on
bo->offsetSigned-off-by Nirmoy Das <[email protected]>Acked-by Gerd Hoffmann <[email protected]>
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 7/8 drm/bochs: use drm_gem_vram_offset to get bo offset
In reply to Nirmoy DasSwitch over to GEM VRAM's implementation to retrieve bo->offset
--- drivers/gpu/drm/bochs/bochs_kms.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bochs/bochs_kms.c +1 -1
@@ -38,7 +38,7 @@ static void bochs_plane_update(struct bochs_device *bochs, state->crtc_x, state->crtc_y, state->fb->pitches[0 ], - state->fb->offsets[0] + gbo->bo.offset); + state->fb->offsets[0] + drm_gem_vram_offset(gbo));bochs_hw_setformat (bochs, state->fb->format); }
Signature · 6 lines
2.25.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 7/8] drm/bochs: use drm_gem_vram_offset to get bo offset
Am 17.02.20 um 16:04 schrieb Nirmoy Das:
Quoted 3 lines
Switch over to GEM VRAM's implementation to retrieve
bo->offsetSigned-off-by Nirmoy Das <[email protected]>
Quoted 9 lines
--- drivers/gpu/drm/bochs/bochs_kms.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/bochs/bochs_kms.c +0
-0
drivers/gpu/drm/bochs/bochs_kms.c static void bochs_plane_update(struct bochs_device *bochs, · line 44
Quoted 8 lines
drivers/gpu/drm/bochs/bochs_kms.c +1
-1@@ -38,7 +38,7 @@ static void bochs_plane_update(struct bochs_device *bochs, state->crtc_x, state->crtc_y, state->fb->pitches[0 ], - state->fb->offsets[0] + gbo->bo.offset); + state->fb->offsets[0] + drm_gem_vram_offset(gbo));bochs_hw_setformat (bochs, state->fb->format); }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 7/8] drm/bochs: use drm_gem_vram_offset to get bo offset
In reply to Nirmoy DasQuoted 3 lines · Nirmoy Das
Switch over to GEM VRAM's implementation to retrieve
bo->offsetSigned-off-by Nirmoy Das <[email protected]>
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 8/8 drm/ttm: do not keep GPU dependent addresses
In reply to Nirmoy DasGPU address handling is device specific and should be handle by its device driver.
--- drivers/gpu/drm/ttm/ttm_bo.c | 7 ------- include/drm/ttm/ttm_bo_api.h | 2 -- include/drm/ttm/ttm_bo_driver.h | 1 - 3 files changed, 10 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +0 -7
@@ -85,7 +85,6 @@ static void ttm_mem_type_debug(struct ttm_bo_device *bdev, struct drm_printer *pdrm_printf (p," has_type: %d\n" , man->has_type);drm_printf (p," use_type: %d\n" , man->use_type);drm_printf (p," flags: 0x%08X\n" , man->flags); -drm_printf (p," gpu_offset: 0x%08llX\n" , man->gpu_offset);drm_printf (p," size: %llu\n" , man->size);drm_printf (p," available_caching: 0x%08X\n" , man->available_caching);drm_printf (p," default_caching: 0x%08X\n" , man->default_caching);
@@ -345,12 +344,6 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo, moved: bo->evicted = false; -if (bo->mem.mm_node) - bo->offset = (bo->mem.start <<PAGE_SHIFT ) + - bdev->man[bo->mem.mem_type].gpu_offset; -else - bo->offset =0 ; - ctx->bytes_moved += bo->num_pages <<PAGE_SHIFT ;return 0 ;
include/drm/ttm/ttm_bo_api.h +0 -2
@@ -213,8 +213,6 @@ struct ttm_buffer_object {* either of these locks held. */ -uint64_t offset;/* GPU address space is independent of CPU word size */ -struct sg_table *sg; };
include/drm/ttm/ttm_bo_driver.h +0 -1
@@ -177,7 +177,6 @@ struct ttm_mem_type_manager {bool has_type;bool use_type;uint32_t flags; -uint64_t gpu_offset;/* GPU address space is independent of CPU word size */ uint64_t size;uint32_t available_caching;uint32_t default_caching;
Signature · 6 lines
2.25.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Thomas Zimmermann
maintainerRe: [PATCH 8/8] drm/ttm: do not keep GPU dependent addresses
Hi
Am 17.02.20 um 16:04 schrieb Nirmoy Das:
Quoted 23 lines
GPU address handling is device specific and should be handle by its device driver.
Signed-off-by Nirmoy Das <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 7 ------- include/drm/ttm/ttm_bo_api.h | 2 -- include/drm/ttm/ttm_bo_driver.h | 1 - 3 files changed, 10 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +0
-1@@ -85,7 +85,6 @@ static void ttm_mem_type_debug(struct ttm_bo_device *bdev, struct drm_printer *pdrm_printf (p," has_type: %d\n" , man->has_type);drm_printf (p," use_type: %d\n" , man->use_type);drm_printf (p," flags: 0x%08X\n" , man->flags); -drm_printf (p," gpu_offset: 0x%08llX\n" , man->gpu_offset);drm_printf (p," size: %llu\n" , man->size);drm_printf (p," available_caching: 0x%08X\n" , man->available_caching);drm_printf (p," default_caching: 0x%08X\n" , man->default_caching);
drivers/gpu/drm/ttm/ttm_bo.c static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo, · line 353
Quoted 9 lines
drivers/gpu/drm/ttm/ttm_bo.c +0
-6@@ -345,12 +344,6 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo, moved: bo->evicted = false; -if (bo->mem.mm_node) - bo->offset = (bo->mem.start <<PAGE_SHIFT ) + - bdev->man[bo->mem.mem_type].gpu_offset; -else - bo->offset =0 ; -
After moving this into users, the else branch has been lost. Is 'bo->mem.mm_node' always true?
Best regards
Thomas
Quoted 29 lines
drivers/gpu/drm/ttm/ttm_bo.c +0
-0ctx->bytes_moved += bo->num_pages <<PAGE_SHIFT ;return 0 ;include/drm/ttm/ttm_bo_api.h +0
-2@@ -213,8 +213,6 @@ struct ttm_buffer_object {* either of these locks held. */ -uint64_t offset;/* GPU address space is independent of CPU word size */ -struct sg_table *sg; };include/drm/ttm/ttm_bo_driver.h +0
-1@@ -177,7 +177,6 @@ struct ttm_mem_type_manager {bool has_type;bool use_type;uint32_t flags; -uint64_t gpu_offset;/* GPU address space is independent of CPU word size */ uint64_t size;uint32_t available_caching;uint32_t default_caching;
Signature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Felix Imendörffer
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Christian König
maintainerRe: [PATCH 8/8] drm/ttm: do not keep GPU dependent addresses
Am 18.02.20 um 13:40 schrieb Thomas Zimmermann:
Quoted 29 lines
Hi
Am 17.02.20 um 16:04 schrieb Nirmoy Das:
Quoted 26 lines
GPU address handling is device specific and should be handle by its device driver.
Signed-off-by Nirmoy Das <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 7 ------- include/drm/ttm/ttm_bo_api.h | 2 -- include/drm/ttm/ttm_bo_driver.h | 1 - 3 files changed, 10 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +0
-1@@ -85,7 +85,6 @@ static void ttm_mem_type_debug(struct ttm_bo_device *bdev, struct drm_printer *pdrm_printf (p," has_type: %d\n" , man->has_type);drm_printf (p," use_type: %d\n" , man->use_type);drm_printf (p," flags: 0x%08X\n" , man->flags); -drm_printf (p," gpu_offset: 0x%08llX\n" , man->gpu_offset);drm_printf (p," size: %llu\n" , man->size);drm_printf (p," available_caching: 0x%08X\n" , man->available_caching);drm_printf (p," default_caching: 0x%08X\n" , man->default_caching);@@ -345,12 +344,6 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo, moved: bo->evicted = false;
Quoted 8 lines
drivers/gpu/drm/ttm/ttm_bo.c static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo, · line 353
Quoted 6 lines
drivers/gpu/drm/ttm/ttm_bo.c +0
-6-if (bo->mem.mm_node) - bo->offset = (bo->mem.start <<PAGE_SHIFT ) + - bdev->man[bo->mem.mem_type].gpu_offset; -else - bo->offset =0 ; -After moving this into users, the else branch has been lost. Is '
bo->mem.mm_node' always true?
At least for the amdgpu and radeon use cases, yes.
But that is a rather good question I mean for it is illegal to get the GPU BO address if it is inaccessible (e.g. in the system domain).
Could be that some driver relied on the behavior to get 0 for the system domain here.
Regards,
Christian.
Quoted 20 lines
Best regards
ThomasQuoted 16 lines
drivers/gpu/drm/ttm/ttm_bo.c +0
-0ctx->bytes_moved += bo->num_pages <<PAGE_SHIFT ;return 0 ;include/drm/ttm/ttm_bo_api.h +0
-2@@ -213,8 +213,6 @@ struct ttm_buffer_object {* either of these locks held. */ -uint64_t offset;/* GPU address space is independent of CPU word size */ -struct sg_table *sg; };
Quoted 13 lines
include/drm/ttm/ttm_bo_driver.h struct ttm_mem_type_manager { · line 182
Quoted 13 lines
include/drm/ttm/ttm_bo_driver.h +0
-1@@ -177,7 +177,6 @@ struct ttm_mem_type_manager {bool has_type;bool use_type;uint32_t flags; -uint64_t gpu_offset;/* GPU address space is independent of CPU word size */ uint64_t size;uint32_t available_caching;uint32_t default_caching;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 8/8] drm/ttm: do not keep GPU dependent addresses
Quoted 40 lines · Christian König
Am 18.02.20 um 13:40 schrieb Thomas Zimmermann:
Quoted 30 lines
Hi
Am 17.02.20 um 16:04 schrieb Nirmoy Das:
Quoted 27 lines
GPU address handling is device specific and should be handle by its device driver.
Signed-off-by Nirmoy Das <[email protected]>---
drivers/gpu/drm/ttm/ttm_bo.c | 7 -------
include/drm/ttm/ttm_bo_api.h | 2 --
include/drm/ttm/ttm_bo_driver.h| 1 -3 files changed, 10 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +0
-0@@ -85,7 +85,6 @@ static void ttm_mem_type_debug(struct
ttm_bo_device*bdev, structdrm_printer*p
drm_printf(p, " has_type: %d\n", man->has_type);drm_printf(p, " use_type: %d\n", man->use_type);drm_printf(p, " flags: 0x%08X\n", man->flags);
-drm_printf(p, " gpu_offset: 0x%08llX\n", man->gpu_offset);drm_printf(p, " size: %llu\n", man->size);
drm_printf(p, " available_caching: 0x%08X\n", man->available_caching);drm_printf(p, " default_caching: 0x%08X\n", man->default_caching);drivers/gpu/drm/ttm/ttm_bo.c +0
-0@@ -345,12 +344,6 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,moved:
bo->evicted= false;Quoted 8 lines
Quoted 6 lines
- if (
bo->mem.mm_node)
-bo->offset= (bo->mem.start<<PAGE_SHIFT) + - bdev->man[bo->mem.mem_type].gpu_offset; - else
-bo->offset= 0;
-After moving this into users, the else branch has been lost. Is '
bo->mem.mm_node' always true?
Quoted 5 lines
At least for the amdgpu and radeon use cases, yes.
But that is a rather good question I mean for it is illegal to get the GPU BO address if it is inaccessible (e.g. in the system domain).
Could be that some driver relied on the behavior to get 0 for the system domain here.
I wonder how to verify that ?
If I understand correctly:
1 qxl uses bo->offset only in qxl_bo_physical_address() which is not in system domain.
2 unfortunately I can't say the same for bochs but it works with this patch series so I think bochs is fine as well.
3 vmwgfx uses bo->offset only when bo->mem.mem_type == TTM_PL_VRAM so vmwgfx should be fine.
4 amdgpu and radeon runs with 'bo->mem.mm_node' always true
I am not sure about nouveau as bo->offset is being used in many places.
I could probably mirror the removed logic to nouveau as
drivers/gpu/drm/nouveau/nouveau_bo.c +0 -0
@@ -1317,6 +1317,10 @@ nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, bool evict,
list_for_each_entry(vma, &nvbo->vma_list, head) { nouveau_vma_map(vma, mem);
}
+ if (bo->mem.mm_node)
+ nvbo->offset = (new_reg->start << PAGE_SHIFT); + else
+ nvbo->offset = 0;
} else {
list_for_each_entry(vma, &nvbo->vma_list, head) { WARN_ON(ttm_bo_wait(bo, false, false));
Regards,
Nirmoy
Quoted 27 lines
Regards,
Christian.Quoted 23 lines
Best regards
ThomasQuoted 19 lines
ctx->bytes_moved+=bo->num_pages<<PAGE_SHIFT;
return 0;
diff --gita/include/drm/ttm/ttm_bo_api.hb/include/drm/ttm/ttm_bo_api.hindexb9bc1b00142e..d6f39ee5bf5d100644include/drm/ttm/ttm_bo_api.h +0
-0@@ -213,8 +213,6 @@ struct ttm_buffer_object {* either of these locks held. */ -
uint64_toffset; /* GPU address space is independent of CPU word size */ -
structsg_table*sg;
};
diff --gita/include/drm/ttm/ttm_bo_driver.hb/include/drm/ttm/ttm_bo_driver.hindexc9e0fd09f4b2..c8ce6c181abe100644include/drm/ttm/ttm_bo_driver.h +0
-0@@ -177,7 +177,6 @@ struct ttm_mem_type_manager { bool has_type;
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
include/drm/ttm/ttm_bo_driver.h +0
-1bool use_type; uint32_t flags; - uint64_t gpu_offset; /* GPU address space is independent of CPUword size */
uint64_tsize;
uint32_tavailable_caching;
uint32_tdefault_caching;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 8/8] drm/ttm: do not keep GPU dependent addresses
Am 18.02.20 um 18:13 schrieb Nirmoy:
Quoted 42 lines · Christian König
Quoted 40 lines
Am 18.02.20 um 13:40 schrieb Thomas Zimmermann:
Quoted 38 lines
Hi
Am 17.02.20 um 16:04 schrieb Nirmoy Das:
Quoted 25 lines
GPU address handling is device specific and should be handle by its device driver.
Signed-off-by Nirmoy Das <[email protected]>---
drivers/gpu/drm/ttm/ttm_bo.c | 7 -------
include/drm/ttm/ttm_bo_api.h | 2 --
include/drm/ttm/ttm_bo_driver.h| 1 -3 files changed, 10 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +0
-0@@ -85,7 +85,6 @@ static void ttm_mem_type_debug(struct
ttm_bo_device*bdev, structdrm_printer*p
drm_printf(p, " has_type: %d\n", man->has_type);drm_printf(p, " use_type: %d\n", man->use_type);drm_printf(p, " flags: 0x%08X\n", man->flags);
-drm_printf(p, " gpu_offset: 0x%08llX\n", man->gpu_offset);drm_printf(p, " size: %llu\n", man->size);
drm_printf(p, " available_caching: 0x%08X\n", man->available_caching);drm_printf(p, " default_caching: 0x%08X\n", man->default_caching);drivers/gpu/drm/ttm/ttm_bo.c +0
-0@@ -345,12 +344,6 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,Quoted 8 lines
moved:
bo->evicted= false;
- if (bo->mem.mm_node)
-bo->offset= (bo->mem.start<<PAGE_SHIFT) + - bdev->man[bo->mem.mem_type].gpu_offset; - else
-bo->offset= 0;
-After moving this into users, the else branch has been lost. Is '
bo->mem.mm_node' always true?
Quoted 7 lines
Quoted 5 lines
At least for the amdgpu and radeon use cases, yes.
But that is a rather good question I mean for it is illegal to get the GPU BO address if it is inaccessible (e.g. in the system domain).
Could be that some driver relied on the behavior to get 0 for the system domain here.
I wonder how to verify that ?
No idea, but I wouldn't worry to much about that.
Quoted 10 lines
If I understand correctly:
1 qxl uses
bo->offsetonly inqxl_bo_physical_address()which is not in system domain.2 unfortunately I can't say the same for bochs but it works with this patch series so I think bochs is fine as well.
3 vmwgfx uses
bo->offsetonly whenbo->mem.mem_type==TTM_PL_VRAMso vmwgfx should be fine.4 amdgpu and radeon runs with '
bo->mem.mm_node' always true
That sounds like those four are ok to me.
Quoted 20 lines
I am not sure about nouveau as
bo->offsetis being used in many places.I could probably mirror the removed logic to nouveau as
drivers/gpu/drm/nouveau/nouveau_bo.c +4
-0@@ -1317,6 +1317,10 @@ nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, bool evict, list_for_each_entry(vma, &nvbo->vma_list, head) { nouveau_vma_map(vma, mem); } + if (bo->mem.mm_node) + nvbo->offset = (new_reg->start << PAGE_SHIFT); + else + nvbo->offset = 0; } else { list_for_each_entry(vma, &nvbo->vma_list, head) {
Quoted 1 line
WARN_ON(ttm_bo_wait(bo, false, false));
Yeah, I would go down that route.
Christian.
Quoted 42 lines
Regards,
Nirmoy
Quoted 27 lines
Regards,
Christian.Quoted 23 lines
Best regards
ThomasQuoted 19 lines
ctx->bytes_moved+=bo->num_pages<<PAGE_SHIFT;
return 0;
diff --gita/include/drm/ttm/ttm_bo_api.hb/include/drm/ttm/ttm_bo_api.hindexb9bc1b00142e..d6f39ee5bf5d100644include/drm/ttm/ttm_bo_api.h +0
-0@@ -213,8 +213,6 @@ struct ttm_buffer_object {* either of these locks held. */ -
uint64_toffset; /* GPU address space is independent of CPU word size */ -
structsg_table*sg;
};
diff --gita/include/drm/ttm/ttm_bo_driver.hb/include/drm/ttm/ttm_bo_driver.hindexc9e0fd09f4b2..c8ce6c181abe100644include/drm/ttm/ttm_bo_driver.h +0
-0@@ -177,7 +177,6 @@ struct ttm_mem_type_manager { bool has_type;Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
include/drm/ttm/ttm_bo_driver.h +0
-1bool use_type; uint32_t flags; - uint64_t gpu_offset; /* GPU address space is independent ofCPU word size */
uint64_tsize;
uint32_tavailable_caching;
uint32_tdefault_caching;
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
Thomas Zimmermann
maintainerRe: [PATCH 8/8] drm/ttm: do not keep GPU dependent addresses
In reply to NirmoyHi
Am 18.02.20 um 18:13 schrieb Nirmoy:
Quoted 64 lines · Christian König
Quoted 44 lines
Am 18.02.20 um 13:40 schrieb Thomas Zimmermann:
Quoted 34 lines
Hi
Am 17.02.20 um 16:04 schrieb Nirmoy Das:
Quoted 31 lines
GPU address handling is device specific and should be handle by its device
driver.Signed-off-by Nirmoy Das <[email protected]>---
drivers/gpu/drm/ttm/ttm_bo.c | 7 -------
include/drm/ttm/ttm_bo_api.h | 2 --
include/drm/ttm/ttm_bo_driver.h| 1 -3 files changed, 10 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +0
-0@@ -85,7 +85,6 @@ static void ttm_mem_type_debug(struct
ttm_bo_device*bdev, structdrm_printer*pdrm_printf(p, " has_type: %d\n", man->has_type);drm_printf(p, " use_type: %d\n", man->use_type);drm_printf(p, " flags: 0x%08X\n", man->flags); -drm_printf(p, " gpu_offset: 0x%08llX\n", man->gpu_offset);drm_printf(p, " size: %llu\n", man->size);drm_printf(p, " available_caching: 0x%08X\n", man->available_caching);
drm_printf(p, " default_caching: 0x%08X\n", man->default_caching);drivers/gpu/drm/ttm/ttm_bo.c +0
-0@@ -345,12 +344,6 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,moved:
bo->evicted= false;Quoted 8 lines
Quoted 6 lines
- if (
bo->mem.mm_node)
-bo->offset= (bo->mem.start<<PAGE_SHIFT) + - bdev->man[bo->mem.mem_type].gpu_offset; - else
-bo->offset= 0;
-After moving this into users, the else branch has been lost. Is '
bo->mem.mm_node' always true?Quoted 7 lines
At least for the amdgpu and radeon use cases, yes.
But that is a rather good question I mean for it is illegal to get the GPU BO address if it is inaccessible (e.g. in the system domain).
Could be that some driver relied on the behavior to get 0 for the system domain here.
I wonder how to verify that ?
If I understand correctly:
1 qxl uses
bo->offsetonly inqxl_bo_physical_address()which is not in system domain.2 unfortunately I can't say the same for bochs but it works with this patch series so I think bochs is fine as well.
Quoted 8 lines
3 vmwgfx uses
bo->offsetonly whenbo->mem.mem_type==TTM_PL_VRAMso vmwgfx should be fine.4 amdgpu and radeon runs with '
bo->mem.mm_node' always trueI am not sure about nouveau as
bo->offsetis being used in many places.I could probably mirror the removed logic to nouveau as
I suggest to introduce a ttm helper that contains the original branching and use it everywhere. Something like
s64 ttm_bo_offset(struct ttm_buffer_object *bo)
{
if (WARN_ON_ONCE(!bo->mem.mm_node))
return 0;
return bo->mem.start << PAGE_SHIFT;
}Could be static inline. The warning should point to broken drivers. This also gets rid of the ugly shift in the drivers.
Best regards
Thomas
Quoted 67 lines
drivers/gpu/drm/nouveau/nouveau_bo.c +4
-0@@ -1317,6 +1317,10 @@ nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, bool evict, list_for_each_entry(vma, &nvbo->vma_list, head) { nouveau_vma_map(vma, mem); } + if (bo->mem.mm_node) + nvbo->offset = (new_reg->start << PAGE_SHIFT); + else + nvbo->offset = 0; } else { list_for_each_entry(vma, &nvbo->vma_list, head) {
WARN_ON(ttm_bo_wait(bo, false, false));Regards,
Nirmoy
Quoted 30 lines
Regards,
Christian.Quoted 26 lines
Best regards
ThomasQuoted 22 lines
ctx->bytes_moved+=bo->num_pages<<PAGE_SHIFT; return 0;
diff --gita/include/drm/ttm/ttm_bo_api.hb/include/drm/ttm/ttm_bo_api.h
indexb9bc1b00142e..d6f39ee5bf5d100644include/drm/ttm/ttm_bo_api.h +0
-0@@ -213,8 +213,6 @@ struct ttm_buffer_object {* either of these locks held. */ -
uint64_toffset; /* GPU address space is independent of CPU word size */
-
structsg_table*sg;
};
diff --gita/include/drm/ttm/ttm_bo_driver.hb/include/drm/ttm/ttm_bo_driver.h
indexc9e0fd09f4b2..c8ce6c181abe100644include/drm/ttm/ttm_bo_driver.h +0
-0@@ -177,7 +177,6 @@ struct ttm_mem_type_manager { bool has_type;Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
include/drm/ttm/ttm_bo_driver.h +0
-1bool use_type; uint32_t flags; - uint64_t gpu_offset; /* GPU address space is independent of CPUword size */
uint64_tsize;
uint32_tavailable_caching;
uint32_tdefault_caching;_______________________________________________
dri-devel mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Felix Imendörffer
_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Christian König
maintainerRe: [PATCH 8/8] drm/ttm: do not keep GPU dependent addresses
Am 18.02.20 um 19:16 schrieb Thomas Zimmermann:
Quoted 82 lines
Hi
Am 18.02.20 um 18:13 schrieb Nirmoy:
Quoted 61 lines · Christian König
Quoted 43 lines
Am 18.02.20 um 13:40 schrieb Thomas Zimmermann:
Quoted 34 lines
Hi
Am 17.02.20 um 16:04 schrieb Nirmoy Das:
Quoted 31 lines
GPU address handling is device specific and should be handle by its device
driver.Signed-off-by Nirmoy Das <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 7 ------- include/drm/ttm/ttm_bo_api.h | 2 -- include/drm/ttm/ttm_bo_driver.h | 1 - 3 files changed, 10 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +0
-0@@ -85,7 +85,6 @@ static void ttm_mem_type_debug(struct
ttm_bo_device*bdev, structdrm_printer*p
drm_printf(p, " has_type: %d\n", man->has_type);drm_printf(p, " use_type: %d\n", man->use_type);drm_printf(p, " flags: 0x%08X\n", man->flags);
-drm_printf(p, " gpu_offset: 0x%08llX\n", man->gpu_offset);
drm_printf(p, " size: %llu\n", man->size); drm_printf(p, "available_caching: 0x%08X\n",man->available_caching);
drm_printf(p, "default_caching: 0x%08X\n",man->default_caching);drivers/gpu/drm/ttm/ttm_bo.c +0
-0@@ -345,12 +344,6 @@ static int ttm_bo_handle_move_mem(structttm_buffer_object *bo, moved: bo->evicted = false;Quoted 8 lines
drivers/gpu/drm/ttm/ttm_bo.c static int ttm_bo_handle_move_mem(struct · line 353
Quoted 6 lines
drivers/gpu/drm/ttm/ttm_bo.c +0
-5- if (bo->mem.mm_node) - bo->offset = (bo->mem.start << PAGE_SHIFT) + - bdev->man[bo->mem.mem_type].gpu_offset; - else - bo->offset = 0; -After moving this into users, the else branch has been lost. Is '
bo->mem.mm_node' always true?Quoted 7 lines
At least for the amdgpu and radeon use cases, yes.
But that is a rather good question I mean for it is illegal to get the GPU BO address if it is inaccessible (e.g. in the system domain).
Could be that some driver relied on the behavior to get 0 for the system domain here.
I wonder how to verify that ?
If I understand correctly:
1 qxl uses
bo->offsetonly inqxl_bo_physical_address()which is not in system domain.2 unfortunately I can't say the same for bochs but it works with this patch series so I think bochs is fine as well.
Quoted 8 lines
3 vmwgfx uses
bo->offsetonly whenbo->mem.mem_type==TTM_PL_VRAMso vmwgfx should be fine.4 amdgpu and radeon runs with '
bo->mem.mm_node' always trueI am not sure about nouveau as
bo->offsetis being used in many places.I could probably mirror the removed logic to nouveau as
I suggest to introduce a ttm helper that contains the original branching and use it everywhere. Something like
s64 ttm_bo_offset(struct ttm_buffer_object *bo) { if (WARN_ON_ONCE(!bo->mem.mm_node)) return 0; return bo->mem.start << PAGE_SHIFT; }
Quoted 2 lines
Could be static inline. The warning should point to broken drivers. This also gets rid of the ugly shift in the drivers.
Big NAK on this. That is exactly what we should NOT do.
See the shift belongs into the driver, because it is driver dependent if we work with page or byte offsets.
For amdgpu we for example want to work with byte offsets and TTM should not make any assumption about what bo->mem.start actually contains.
Regards,
Christian.
Quoted 68 lines
Best regards
ThomasQuoted 63 lines
drivers/gpu/drm/nouveau/nouveau_bo.c +4
-0@@ -1317,6 +1317,10 @@ nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, bool evict, list_for_each_entry(vma, &nvbo->vma_list, head) { nouveau_vma_map(vma, mem); } + if (bo->mem.mm_node) + nvbo->offset = (new_reg->start << PAGE_SHIFT); + else + nvbo->offset = 0; } else { list_for_each_entry(vma, &nvbo->vma_list, head) {
WARN_ON(ttm_bo_wait(bo, false, false));Regards,
Nirmoy
Quoted 28 lines
Regards,
Christian.Quoted 25 lines
Best regards
ThomasQuoted 22 lines
drivers/gpu/drm/ttm/ttm_bo.c +0
-0ctx->bytes_moved += bo->num_pages << PAGE_SHIFT; return 0; diff --git a/include/drm/ttm/ttm_bo_api.h
b/include/drm/ttm/ttm_bo_api.h
indexb9bc1b00142e..d6f39ee5bf5d100644include/drm/ttm/ttm_bo_api.h +0
-0@@ -213,8 +213,6 @@ struct ttm_buffer_object {* either of these locks held. */ - uint64_t offset; /* GPU address space is independent of CPUword size */
-
structsg_table*sg;
};
diff --gita/include/drm/ttm/ttm_bo_driver.hb/include/drm/ttm/ttm_bo_driver.h
indexc9e0fd09f4b2..c8ce6c181abe100644include/drm/ttm/ttm_bo_driver.h +0
-0@@ -177,7 +177,6 @@ struct ttm_mem_type_manager { bool has_type;Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
include/drm/ttm/ttm_bo_driver.h +0
-1bool use_type; uint32_t flags; - uint64_t gpu_offset; /* GPU address space is independent of CPUword size */
uint64_tsize;
uint32_tavailable_caching;
uint32_tdefault_caching;_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
Thomas Zimmermann
maintainerRe: [PATCH 8/8] drm/ttm: do not keep GPU dependent addresses
Hi
Am 18.02.20 um 19:23 schrieb Christian König:
Quoted 86 lines
Am 18.02.20 um 19:16 schrieb Thomas Zimmermann:
Quoted 82 lines
Hi
Am 18.02.20 um 18:13 schrieb Nirmoy:
Quoted 61 lines · Christian König
Quoted 43 lines
Am 18.02.20 um 13:40 schrieb Thomas Zimmermann:
Quoted 34 lines
Hi
Am 17.02.20 um 16:04 schrieb Nirmoy Das:
Quoted 31 lines
GPU address handling is device specific and should be handle by its device
driver.Signed-off-by Nirmoy Das <[email protected]>---
drivers/gpu/drm/ttm/ttm_bo.c | 7 -------
include/drm/ttm/ttm_bo_api.h | 2 --
include/drm/ttm/ttm_bo_driver.h| 1 -3 files changed, 10 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +0
-0@@ -85,7 +85,6 @@ static void ttm_mem_type_debug(struct
ttm_bo_device*bdev, structdrm_printer*pdrm_printf(p, " has_type: %d\n", man->has_type);drm_printf(p, " use_type: %d\n", man->use_type);drm_printf(p, " flags: 0x%08X\n", man->flags); -drm_printf(p, " gpu_offset: 0x%08llX\n", man->gpu_offset);drm_printf(p, " size: %llu\n", man->size);drm_printf(p, " available_caching: 0x%08X\n", man->available_caching);
drm_printf(p, " default_caching: 0x%08X\n", man->default_caching);drivers/gpu/drm/ttm/ttm_bo.c +0
-0@@ -345,12 +344,6 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,moved:
bo->evicted= false;Quoted 8 lines
Quoted 6 lines
- if (
bo->mem.mm_node)
-bo->offset= (bo->mem.start<<PAGE_SHIFT) + - bdev->man[bo->mem.mem_type].gpu_offset; - else
-bo->offset= 0;
-After moving this into users, the else branch has been lost. Is '
bo->mem.mm_node' always true?Quoted 7 lines
At least for the amdgpu and radeon use cases, yes.
But that is a rather good question I mean for it is illegal to get the GPU BO address if it is inaccessible (e.g. in the system domain).
Could be that some driver relied on the behavior to get 0 for the system domain here.
I wonder how to verify that ?
If I understand correctly:
1 qxl uses
bo->offsetonly inqxl_bo_physical_address()which is not in system domain.2 unfortunately I can't say the same for bochs but it works with this patch series so I think bochs is fine as well.
Quoted 8 lines
3 vmwgfx uses
bo->offsetonly whenbo->mem.mem_type==TTM_PL_VRAMso vmwgfx should be fine.4 amdgpu and radeon runs with '
bo->mem.mm_node' always trueI am not sure about nouveau as
bo->offsetis being used in many places.I could probably mirror the removed logic to nouveau as
I suggest to introduce a ttm helper that contains the original branching and use it everywhere. Something like
s64
ttm_bo_offset(struct ttm_buffer_object *bo){
if (WARN_ON_ONCE(!bo->mem.mm_node)) return 0;
returnbo->mem.start<<PAGE_SHIFT; }Quoted 2 lines
Could be static inline. The warning should point to broken drivers. This also gets rid of the ugly shift in the drivers.
Quoted 7 lines
Big NAK on this. That is exactly what we should NOT do.
See the shift belongs into the driver, because it is driver dependent if we work with page or byte offsets.
For amdgpu we for example want to work with byte offsets and TTM should not make any assumption about what
bo->mem.startactually contains.
OK. What about something like ttm_bo_pg_offset()? Same code without the shift. Would also make it clear that it's a page offset.
Best regards
Thomas
Quoted 77 lines
Regards,
Christian.Quoted 68 lines
Best regards
ThomasQuoted 63 lines
drivers/gpu/drm/nouveau/nouveau_bo.c +4
-0@@ -1317,6 +1317,10 @@ nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, bool evict, list_for_each_entry(vma, &nvbo->vma_list, head) { nouveau_vma_map(vma, mem); } + if (bo->mem.mm_node) + nvbo->offset = (new_reg->start << PAGE_SHIFT); + else + nvbo->offset = 0; } else { list_for_each_entry(vma, &nvbo->vma_list, head) {
WARN_ON(ttm_bo_wait(bo, false, false));Regards,
Nirmoy
Quoted 28 lines
Regards,
Christian.Quoted 25 lines
Best regards
ThomasQuoted 22 lines
ctx->bytes_moved+=bo->num_pages<<PAGE_SHIFT; return 0;
diff --gita/include/drm/ttm/ttm_bo_api.hb/include/drm/ttm/ttm_bo_api.h
indexb9bc1b00142e..d6f39ee5bf5d100644include/drm/ttm/ttm_bo_api.h +0
-0@@ -213,8 +213,6 @@ struct ttm_buffer_object {* either of these locks held. */ -
uint64_toffset; /* GPU address space is independent of CPU word size */
-
structsg_table*sg;
};
diff --gita/include/drm/ttm/ttm_bo_driver.hb/include/drm/ttm/ttm_bo_driver.h
indexc9e0fd09f4b2..c8ce6c181abe100644include/drm/ttm/ttm_bo_driver.h +0
-0@@ -177,7 +177,6 @@ struct ttm_mem_type_manager { bool has_type;Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
include/drm/ttm/ttm_bo_driver.h +0
-1bool use_type; uint32_t flags; - uint64_t gpu_offset; /* GPU address space is independent of CPUword size */
uint64_tsize;
uint32_tavailable_caching;
uint32_tdefault_caching;_______________________________________________
dri-devel mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel_______________________________________________
dri-devel mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Felix Imendörffer
_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 8/8] drm/ttm: do not keep GPU dependent addresses
Am 18.02.20 um 19:28 schrieb Thomas Zimmermann:
Quoted 90 lines
Hi
Am 18.02.20 um 19:23 schrieb Christian König:
Quoted 87 lines
Am 18.02.20 um 19:16 schrieb Thomas Zimmermann:
Quoted 82 lines
Hi
Am 18.02.20 um 18:13 schrieb Nirmoy:
Quoted 61 lines · Christian König
Quoted 43 lines
Am 18.02.20 um 13:40 schrieb Thomas Zimmermann:
Quoted 34 lines
Hi
Am 17.02.20 um 16:04 schrieb Nirmoy Das:
Quoted 31 lines
GPU address handling is device specific and should be handle by its device
driver.Signed-off-by Nirmoy Das <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 7 ------- include/drm/ttm/ttm_bo_api.h | 2 -- include/drm/ttm/ttm_bo_driver.h | 1 - 3 files changed, 10 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +0
-0@@ -85,7 +85,6 @@ static void ttm_mem_type_debug(struct
ttm_bo_device*bdev, structdrm_printer*p
drm_printf(p, " has_type: %d\n", man->has_type);drm_printf(p, " use_type: %d\n", man->use_type);drm_printf(p, " flags: 0x%08X\n", man->flags);
-drm_printf(p, " gpu_offset: 0x%08llX\n", man->gpu_offset);
drm_printf(p, " size: %llu\n", man->size); drm_printf(p, "available_caching: 0x%08X\n",man->available_caching);
drm_printf(p, "default_caching: 0x%08X\n",man->default_caching);drivers/gpu/drm/ttm/ttm_bo.c +0
-0@@ -345,12 +344,6 @@ static int ttm_bo_handle_move_mem(structttm_buffer_object *bo, moved: bo->evicted = false;Quoted 8 lines
drivers/gpu/drm/ttm/ttm_bo.c static int ttm_bo_handle_move_mem(struct · line 353
Quoted 6 lines
drivers/gpu/drm/ttm/ttm_bo.c +0
-5- if (bo->mem.mm_node) - bo->offset = (bo->mem.start << PAGE_SHIFT) + - bdev->man[bo->mem.mem_type].gpu_offset; - else - bo->offset = 0; -After moving this into users, the else branch has been lost. Is '
bo->mem.mm_node' always true?Quoted 7 lines
At least for the amdgpu and radeon use cases, yes.
But that is a rather good question I mean for it is illegal to get the GPU BO address if it is inaccessible (e.g. in the system domain).
Could be that some driver relied on the behavior to get 0 for the system domain here.
I wonder how to verify that ?
If I understand correctly:
1 qxl uses
bo->offsetonly inqxl_bo_physical_address()which is not in system domain.2 unfortunately I can't say the same for bochs but it works with this patch series so I think bochs is fine as well.
Quoted 8 lines
3 vmwgfx uses
bo->offsetonly whenbo->mem.mem_type==TTM_PL_VRAMso vmwgfx should be fine.4 amdgpu and radeon runs with '
bo->mem.mm_node' always trueI am not sure about nouveau as
bo->offsetis being used in many places.I could probably mirror the removed logic to nouveau as
I suggest to introduce a ttm helper that contains the original branching and use it everywhere. Something like
s64
ttm_bo_offset(struct ttm_buffer_object *bo){
if (WARN_ON_ONCE(!bo->mem.mm_node)) return 0;
returnbo->mem.start<<PAGE_SHIFT; }Quoted 2 lines
Could be static inline. The warning should point to broken drivers. This also gets rid of the ugly shift in the drivers.
Big NAK on this. That is exactly what we should NOT do.
Quoted 7 lines
Quoted 5 lines
See the shift belongs into the driver, because it is driver dependent if we work with page or byte offsets.
For amdgpu we for example want to work with byte offsets and TTM should not make any assumption about what
bo->mem.startactually contains.OK. What about something like
ttm_bo_pg_offset()? Same code without the shift. Would also make it clear that it's a page offset.
That is a rather good idea. We could name that ttm_bo_man_offset() and put it into ttm_bo_manager.c next to the manager which allocates them.
It's just that this manager is not used by everybody, so amdgpu, radeon and nouveau would still need a separate function.
Christian.
Quoted 79 lines
Best regards
ThomasQuoted 70 lines
Regards,
Christian.Quoted 67 lines
Best regards
ThomasQuoted 63 lines
drivers/gpu/drm/nouveau/nouveau_bo.c +4
-0@@ -1317,6 +1317,10 @@ nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, bool evict, list_for_each_entry(vma, &nvbo->vma_list, head) { nouveau_vma_map(vma, mem); } + if (bo->mem.mm_node) + nvbo->offset = (new_reg->start << PAGE_SHIFT); + else + nvbo->offset = 0; } else { list_for_each_entry(vma, &nvbo->vma_list, head) {
WARN_ON(ttm_bo_wait(bo, false, false));Regards,
Nirmoy
Quoted 28 lines
Regards,
Christian.Quoted 25 lines
Best regards
ThomasQuoted 22 lines
drivers/gpu/drm/ttm/ttm_bo.c +0
-0ctx->bytes_moved += bo->num_pages << PAGE_SHIFT; return 0; diff --git a/include/drm/ttm/ttm_bo_api.h
b/include/drm/ttm/ttm_bo_api.h
indexb9bc1b00142e..d6f39ee5bf5d100644include/drm/ttm/ttm_bo_api.h +0
-0@@ -213,8 +213,6 @@ struct ttm_buffer_object {* either of these locks held. */ - uint64_t offset; /* GPU address space is independent of CPUword size */
-
structsg_table*sg;
};
diff --gita/include/drm/ttm/ttm_bo_driver.hb/include/drm/ttm/ttm_bo_driver.h
indexc9e0fd09f4b2..c8ce6c181abe100644include/drm/ttm/ttm_bo_driver.h +0
-0@@ -177,7 +177,6 @@ struct ttm_mem_type_manager { bool has_type;Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
include/drm/ttm/ttm_bo_driver.h +0
-1bool use_type; uint32_t flags; - uint64_t gpu_offset; /* GPU address space is independent of CPUword size */
uint64_tsize;
uint32_tavailable_caching;
uint32_tdefault_caching;_______________________________________________
dri-devel mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-develQuoted 4 lines
_______________________________________________
dri-devel mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 4 lines
_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [Nouveau] [PATCH 8/8] drm/ttm: do not keep GPU dependent addresses
Quoted 96 lines · Christian König
Am 18.02.20 um 19:28 schrieb Thomas Zimmermann:
Quoted 95 lines
Hi
Am 18.02.20 um 19:23 schrieb Christian König:
Quoted 92 lines
Am 18.02.20 um 19:16 schrieb Thomas Zimmermann:
Quoted 82 lines
Hi
Am 18.02.20 um 18:13 schrieb Nirmoy:
Quoted 61 lines · Christian König
Quoted 43 lines
Am 18.02.20 um 13:40 schrieb Thomas Zimmermann:
Quoted 34 lines
Hi
Am 17.02.20 um 16:04 schrieb Nirmoy Das:
Quoted 31 lines
GPU address handling is device specific and should be handle by its device
driver.Signed-off-by Nirmoy Das <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 7 ------- include/drm/ttm/ttm_bo_api.h | 2 -- include/drm/ttm/ttm_bo_driver.h | 1 - 3 files changed, 10 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +0
-0@@ -85,7 +85,6 @@ static void ttm_mem_type_debug(struct
ttm_bo_device*bdev, structdrm_printer*p
drm_printf(p, " has_type: %d\n", man->has_type);drm_printf(p, " use_type: %d\n", man->use_type);drm_printf(p, " flags: 0x%08X\n", man->flags);
-drm_printf(p, " gpu_offset: 0x%08llX\n", man->gpu_offset);
drm_printf(p, " size: %llu\n", man->size); drm_printf(p, "available_caching: 0x%08X\n",man->available_caching);
drm_printf(p, "default_caching: 0x%08X\n",man->default_caching);drivers/gpu/drm/ttm/ttm_bo.c +0
-0@@ -345,12 +344,6 @@ static int ttm_bo_handle_move_mem(structttm_buffer_object *bo, moved: bo->evicted = false;Quoted 8 lines
drivers/gpu/drm/ttm/ttm_bo.c static int ttm_bo_handle_move_mem(struct · line 353
Quoted 6 lines
drivers/gpu/drm/ttm/ttm_bo.c +0
-5- if (bo->mem.mm_node) - bo->offset = (bo->mem.start << PAGE_SHIFT) + - bdev->man[bo->mem.mem_type].gpu_offset; - else - bo->offset = 0; -After moving this into users, the else branch has been lost. Is '
bo->mem.mm_node' always true?Quoted 7 lines
At least for the amdgpu and radeon use cases, yes.
But that is a rather good question I mean for it is illegal to get the GPU BO address if it is inaccessible (e.g. in the system domain).
Could be that some driver relied on the behavior to get 0 for the system domain here.
I wonder how to verify that ?
If I understand correctly:
1 qxl uses
bo->offsetonly inqxl_bo_physical_address()which is not in system domain.2 unfortunately I can't say the same for bochs but it works with this patch series so I think bochs is fine as well.
Quoted 8 lines
3 vmwgfx uses
bo->offsetonly whenbo->mem.mem_type==TTM_PL_VRAMso vmwgfx should be fine.4 amdgpu and radeon runs with '
bo->mem.mm_node' always trueI am not sure about nouveau as
bo->offsetis being used in many places.I could probably mirror the removed logic to nouveau as
I suggest to introduce a ttm helper that contains the original branching and use it everywhere. Something like
s64
ttm_bo_offset(struct ttm_buffer_object *bo){
if (WARN_ON_ONCE(!bo->mem.mm_node)) return 0;
returnbo->mem.start<<PAGE_SHIFT; }Quoted 2 lines
Could be static inline. The warning should point to broken drivers. This also gets rid of the ugly shift in the drivers.
Big NAK on this. That is exactly what we should NOT do.
See the shift belongs into the driver, because it is driver dependent if we work with page or byte offsets.
For amdgpu we for example want to work with byte offsets and TTM should not make any assumption about what
bo->mem.startactually contains.
Quoted 8 lines
Quoted 2 lines
OK. What about something like
ttm_bo_pg_offset()? Same code without the shift. Would also make it clear that it's a page offset.That is a rather good idea. We could name that
ttm_bo_man_offset()and put it intottm_bo_manager.cnext to the manager which allocates them.It's just that this manager is not used by everybody, so amdgpu, radeon and nouveau would still need a separate function.
Let me pile on with my bikeshed color choice :-)
I'd do this a wrapper, but for drivers individually. And only for those we haven't audited yet, or where we think the WARN_ON actually provides value. So maybe in vram helpers, since that might be used by some drivers that get stuff wrong. Or maybe noveau isn't audited yet.
That also sidesteps the "what should we call this, drivers are different?" problem.
Anyway feel free to ignore me, really just a bikeshed at this point.
Cheers, Daniel
Quoted 92 lines
Christian.
Quoted 79 lines
Best regards
ThomasQuoted 70 lines
Regards,
Christian.Quoted 67 lines
Best regards
ThomasQuoted 63 lines
drivers/gpu/drm/nouveau/nouveau_bo.c +4
-0@@ -1317,6 +1317,10 @@ nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, bool evict, list_for_each_entry(vma, &nvbo->vma_list, head) { nouveau_vma_map(vma, mem); } + if (bo->mem.mm_node) + nvbo->offset = (new_reg->start << PAGE_SHIFT); + else + nvbo->offset = 0; } else { list_for_each_entry(vma, &nvbo->vma_list, head) {
WARN_ON(ttm_bo_wait(bo, false, false));Regards,
Nirmoy
Quoted 28 lines
Regards,
Christian.Quoted 25 lines
Best regards
ThomasQuoted 22 lines
drivers/gpu/drm/ttm/ttm_bo.c +0
-0ctx->bytes_moved += bo->num_pages << PAGE_SHIFT; return 0; diff --git a/include/drm/ttm/ttm_bo_api.h
b/include/drm/ttm/ttm_bo_api.h
indexb9bc1b00142e..d6f39ee5bf5d100644include/drm/ttm/ttm_bo_api.h +0
-0@@ -213,8 +213,6 @@ struct ttm_buffer_object {* either of these locks held. */ - uint64_t offset; /* GPU address space is independent of CPUword size */
-
structsg_table*sg;
};
diff --gita/include/drm/ttm/ttm_bo_driver.hb/include/drm/ttm/ttm_bo_driver.h
indexc9e0fd09f4b2..c8ce6c181abe100644include/drm/ttm/ttm_bo_driver.h +0
-0@@ -177,7 +177,6 @@ struct ttm_mem_type_manager { bool has_type;Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
include/drm/ttm/ttm_bo_driver.h +0
-1bool use_type; uint32_t flags; - uint64_t gpu_offset; /* GPU address space is independent of CPUword size */
uint64_tsize;
uint32_tavailable_caching;
uint32_tdefault_caching;_______________________________________________
dri-devel mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-develQuoted 4 lines
_______________________________________________
dri-devel mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-develQuoted 4 lines
_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx_______________________________________________
Nouveau mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Re: [Nouveau] [PATCH 8/8] drm/ttm: do not keep GPU dependent addresses
Quoted 102 lines · Daniel Vetter
Quoted 101 lines · Christian König
Am 18.02.20 um 19:28 schrieb Thomas Zimmermann:
Quoted 90 lines
Hi
Am 18.02.20 um 19:23 schrieb Christian König:
Quoted 87 lines
Am 18.02.20 um 19:16 schrieb Thomas Zimmermann:
Quoted 82 lines
Hi
Am 18.02.20 um 18:13 schrieb Nirmoy:
Quoted 61 lines · Christian König
Quoted 43 lines
Am 18.02.20 um 13:40 schrieb Thomas Zimmermann:
Quoted 34 lines
Hi
Am 17.02.20 um 16:04 schrieb Nirmoy Das:
Quoted 31 lines
GPU address handling is device specific and should be handle by its device
driver.Signed-off-by Nirmoy Das <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 7 ------- include/drm/ttm/ttm_bo_api.h | 2 -- include/drm/ttm/ttm_bo_driver.h | 1 - 3 files changed, 10 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +0
-0@@ -85,7 +85,6 @@ static void ttm_mem_type_debug(struct
ttm_bo_device*bdev, structdrm_printer*p
drm_printf(p, " has_type: %d\n", man->has_type);drm_printf(p, " use_type: %d\n", man->use_type);drm_printf(p, " flags: 0x%08X\n", man->flags);
-drm_printf(p, " gpu_offset: 0x%08llX\n", man->gpu_offset);
drm_printf(p, " size: %llu\n", man->size); drm_printf(p, "available_caching: 0x%08X\n",man->available_caching);
drm_printf(p, "default_caching: 0x%08X\n",man->default_caching);drivers/gpu/drm/ttm/ttm_bo.c +0
-0@@ -345,12 +344,6 @@ static int ttm_bo_handle_move_mem(structttm_buffer_object *bo, moved: bo->evicted = false;Quoted 8 lines
drivers/gpu/drm/ttm/ttm_bo.c static int ttm_bo_handle_move_mem(struct · line 353
Quoted 6 lines
drivers/gpu/drm/ttm/ttm_bo.c +0
-5- if (bo->mem.mm_node) - bo->offset = (bo->mem.start << PAGE_SHIFT) + - bdev->man[bo->mem.mem_type].gpu_offset; - else - bo->offset = 0; -After moving this into users, the else branch has been lost. Is '
bo->mem.mm_node' always true?Quoted 7 lines
At least for the amdgpu and radeon use cases, yes.
But that is a rather good question I mean for it is illegal to get the GPU BO address if it is inaccessible (e.g. in the system domain).
Could be that some driver relied on the behavior to get 0 for the system domain here.
I wonder how to verify that ?
If I understand correctly:
1 qxl uses
bo->offsetonly inqxl_bo_physical_address()which is not in system domain.2 unfortunately I can't say the same for bochs but it works with this patch series so I think bochs is fine as well.
Quoted 8 lines
3 vmwgfx uses
bo->offsetonly whenbo->mem.mem_type==TTM_PL_VRAMso vmwgfx should be fine.4 amdgpu and radeon runs with '
bo->mem.mm_node' always trueI am not sure about nouveau as
bo->offsetis being used in many places.I could probably mirror the removed logic to nouveau as
I suggest to introduce a ttm helper that contains the original branching and use it everywhere. Something like
s64 ttm_bo_offset(struct ttm_buffer_object *bo) { if (WARN_ON_ONCE(!bo->mem.mm_node)) return 0; return bo->mem.start << PAGE_SHIFT; }Quoted 2 lines
Could be static inline. The warning should point to broken drivers. This also gets rid of the ugly shift in the drivers.
Big NAK on this. That is exactly what we should NOT do.
Quoted 7 lines
Quoted 5 lines
See the shift belongs into the driver, because it is driver dependent if we work with page or byte offsets.
For amdgpu we for example want to work with byte offsets and TTM should not make any assumption about what
bo->mem.startactually contains.OK. What about something like
ttm_bo_pg_offset()? Same code without the shift. Would also make it clear that it's a page offset.That is a rather good idea. We could name that
ttm_bo_man_offset()and put it intottm_bo_manager.cnext to the manager which allocates them.
Quoted 8 lines
Quoted 2 lines
It's just that this manager is not used by everybody, so amdgpu, radeon and nouveau would still need a separate function.
Let me pile on with my bikeshed color choice :-)
I'd do this a wrapper, but for drivers individually. And only for those we haven't audited yet, or where we think the
WARN_ONactually provides value. So maybe in vram helpers, since that might be used by some drivers that get stuff wrong. Or maybe noveau isn't audited yet.
I like this idea more. I will modify and resend patches with above suggestions.
Quoted 95 lines
That also sidesteps the "what should we call this, drivers are different?" problem.
Anyway feel free to ignore me, really just a bikeshed at this point.
Cheers, Daniel
Quoted 87 lines
Christian.
Quoted 73 lines
Best regards
ThomasQuoted 70 lines
Regards,
Christian.Quoted 67 lines
Best regards
ThomasQuoted 63 lines
drivers/gpu/drm/nouveau/nouveau_bo.c +4
-0@@ -1317,6 +1317,10 @@ nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, bool evict, list_for_each_entry(vma, &nvbo->vma_list, head) { nouveau_vma_map(vma, mem); } + if (bo->mem.mm_node) + nvbo->offset = (new_reg->start << PAGE_SHIFT); + else + nvbo->offset = 0; } else { list_for_each_entry(vma, &nvbo->vma_list, head) {WARN_ON(ttm_bo_wait(bo, false, false));Regards,
Nirmoy
Quoted 28 lines
Regards,
Christian.Quoted 25 lines
Best regards
ThomasQuoted 22 lines
drivers/gpu/drm/ttm/ttm_bo.c +0
-0ctx->bytes_moved += bo->num_pages << PAGE_SHIFT; return 0; diff --git a/include/drm/ttm/ttm_bo_api.h
b/include/drm/ttm/ttm_bo_api.h
indexb9bc1b00142e..d6f39ee5bf5d100644include/drm/ttm/ttm_bo_api.h +0
-0@@ -213,8 +213,6 @@ struct ttm_buffer_object {* either of these locks held. */ - uint64_t offset; /* GPU address space is independent of CPUword size */
-
structsg_table*sg;
};
diff --gita/include/drm/ttm/ttm_bo_driver.hb/include/drm/ttm/ttm_bo_driver.h
indexc9e0fd09f4b2..c8ce6c181abe100644include/drm/ttm/ttm_bo_driver.h +0
-0@@ -177,7 +177,6 @@ struct ttm_mem_type_manager { bool has_type;Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
include/drm/ttm/ttm_bo_driver.h +0
-1bool use_type; uint32_t flags; - uint64_t gpu_offset; /* GPU address space is independent of CPUword size */
uint64_tsize;
uint32_tavailable_caching;
uint32_tdefault_caching;_______________________________________________
dri-devel mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Fdri-devel&data=02%7C01%7CNirmoy.Das%40amd.com%7Cb0279de1528f44e16aa508d7b4a5b192%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637176496067660861&sdata=oDEilLoCymlcMxXJ2mnVWwTxqloQlW0SP3HDPmQRSVc%3D&reserved=0Quoted 8 lines
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Fdri-devel&data=02%7C01%7CNirmoy.Das%40amd.com%7Cb0279de1528f44e16aa508d7b4a5b192%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637176496067660861&sdata=oDEilLoCymlcMxXJ2mnVWwTxqloQlW0SP3HDPmQRSVc%3D&reserved=0_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=02%7C01%7CNirmoy.Das%40amd.com%7Cb0279de1528f44e16aa508d7b4a5b192%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637176496067660861&sdata=XNDpZIj%2FwDbHOHBL25G%2FHpS9JETN%2F37H35E6t4q4joU%3D&reserved=0_______________________________________________
Nouveau mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Fnouveau&data=02%7C01%7CNirmoy.Das%40amd.com%7Cb0279de1528f44e16aa508d7b4a5b192%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637176496067660861&sdata=6ln5B81rbRdVEN6tRk8KMmIx04VPJw10dwZdqIYMkSo%3D&reserved=0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 8/8] drm/ttm: do not keep GPU dependent addresses
In reply to Thomas ZimmermannQuoted 82 lines · Thomas Zimmermann
Hi
Am 18.02.20 um 18:13 schrieb Nirmoy:
Quoted 61 lines · Christian König
Quoted 43 lines
Am 18.02.20 um 13:40 schrieb Thomas Zimmermann:
Quoted 34 lines
Hi
Am 17.02.20 um 16:04 schrieb Nirmoy Das:
Quoted 31 lines
GPU address handling is device specific and should be handle by its device
driver.Signed-off-by Nirmoy Das <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 7 ------- include/drm/ttm/ttm_bo_api.h | 2 -- include/drm/ttm/ttm_bo_driver.h | 1 - 3 files changed, 10 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +0
-0@@ -85,7 +85,6 @@ static void ttm_mem_type_debug(struct
ttm_bo_device*bdev, structdrm_printer*p
drm_printf(p, " has_type: %d\n", man->has_type);drm_printf(p, " use_type: %d\n", man->use_type);drm_printf(p, " flags: 0x%08X\n", man->flags);
-drm_printf(p, " gpu_offset: 0x%08llX\n", man->gpu_offset);
drm_printf(p, " size: %llu\n", man->size); drm_printf(p, "available_caching: 0x%08X\n",man->available_caching);
drm_printf(p, "default_caching: 0x%08X\n",man->default_caching);drivers/gpu/drm/ttm/ttm_bo.c +0
-0@@ -345,12 +344,6 @@ static int ttm_bo_handle_move_mem(structttm_buffer_object *bo, moved: bo->evicted = false;Quoted 8 lines
drivers/gpu/drm/ttm/ttm_bo.c static int ttm_bo_handle_move_mem(struct · line 353
Quoted 6 lines
drivers/gpu/drm/ttm/ttm_bo.c +0
-5- if (bo->mem.mm_node) - bo->offset = (bo->mem.start << PAGE_SHIFT) + - bdev->man[bo->mem.mem_type].gpu_offset; - else - bo->offset = 0; -After moving this into users, the else branch has been lost. Is '
bo->mem.mm_node' always true?Quoted 7 lines
At least for the amdgpu and radeon use cases, yes.
But that is a rather good question I mean for it is illegal to get the GPU BO address if it is inaccessible (e.g. in the system domain).
Could be that some driver relied on the behavior to get 0 for the system domain here.
I wonder how to verify that ?
If I understand correctly:
1 qxl uses
bo->offsetonly inqxl_bo_physical_address()which is not in system domain.2 unfortunately I can't say the same for bochs but it works with this patch series so I think bochs is fine as well.
Quoted 8 lines
3 vmwgfx uses
bo->offsetonly whenbo->mem.mem_type==TTM_PL_VRAMso vmwgfx should be fine.4 amdgpu and radeon runs with '
bo->mem.mm_node' always trueI am not sure about nouveau as
bo->offsetis being used in many places.I could probably mirror the removed logic to nouveau as
I suggest to introduce a ttm helper that contains the original branching and use it everywhere. Something like
s64 ttm_bo_offset(struct ttm_buffer_object *bo) { if (WARN_ON_ONCE(!bo->mem.mm_node)) return 0; return bo->mem.start << PAGE_SHIFT; }
Quoted 2 lines
Could be static inline. The warning should point to broken drivers. This also gets rid of the ugly shift in the drivers.
The idea here is to remove this GPU memory offset calculation and reference completely
from ttm and let drivers decide how to handle that. Drivers are full of ugly shift anyway imho :)
Regards,
Nirmoy
Quoted 68 lines
Best regards
ThomasQuoted 63 lines
drivers/gpu/drm/nouveau/nouveau_bo.c +4
-0@@ -1317,6 +1317,10 @@ nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, bool evict, list_for_each_entry(vma, &nvbo->vma_list, head) { nouveau_vma_map(vma, mem); } + if (bo->mem.mm_node) + nvbo->offset = (new_reg->start << PAGE_SHIFT); + else + nvbo->offset = 0; } else { list_for_each_entry(vma, &nvbo->vma_list, head) {
WARN_ON(ttm_bo_wait(bo, false, false));Regards,
Nirmoy
Quoted 28 lines
Regards,
Christian.Quoted 25 lines
Best regards
ThomasQuoted 22 lines
drivers/gpu/drm/ttm/ttm_bo.c +0
-0ctx->bytes_moved += bo->num_pages << PAGE_SHIFT; return 0; diff --git a/include/drm/ttm/ttm_bo_api.h
b/include/drm/ttm/ttm_bo_api.h
indexb9bc1b00142e..d6f39ee5bf5d100644include/drm/ttm/ttm_bo_api.h +0
-0@@ -213,8 +213,6 @@ struct ttm_buffer_object {* either of these locks held. */ - uint64_t offset; /* GPU address space is independent of CPUword size */
-
structsg_table*sg;
};
diff --gita/include/drm/ttm/ttm_bo_driver.hb/include/drm/ttm/ttm_bo_driver.h
indexc9e0fd09f4b2..c8ce6c181abe100644include/drm/ttm/ttm_bo_driver.h +0
-0@@ -177,7 +177,6 @@ struct ttm_mem_type_manager { bool has_type;Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
include/drm/ttm/ttm_bo_driver.h +0
-1bool use_type; uint32_t flags; - uint64_t gpu_offset; /* GPU address space is independent of CPUword size */
uint64_tsize;
uint32_tavailable_caching;
uint32_tdefault_caching;_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Gerd Hoffmann
maintainerRe: [PATCH 8/8] drm/ttm: do not keep GPU dependent addresses
In reply to NirmoyHi,
Quoted 2 lines
2 unfortunately I can't say the same for bochs but it works with this patch series so I think bochs is fine as well.
bochs needs the offset only to scanout framebuffers, which in turn requires framebuffers being pinned to vram. So all green here.
cheers,
Gerd
Re: [PATCH 8/8] drm/ttm: do not keep GPU dependent addresses
Quoted 6 lines · Gerd Hoffmann
Hi,Quoted 2 lines
2 unfortunately I can't say the same for bochs but it works with this patch series so I think bochs is fine as well.
bochs needs the offset only to scanout framebuffers, which in turn requires framebuffers being pinned to vram. So all green here.
Thanks for confirming!
Quoted 4 lines
cheers,
Gerd
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Thomas Zimmermann
maintainerHi,
the email's subject line should contain the version of the patchset (e.g, v2, v3, etc). git send-mail adds this with the -v switch
Best regards
Thomas
Am 17.02.20 um 16:04 schrieb Nirmoy Das:
Quoted 61 lines
With this patch series I am trying to remove GPU address dependency in TTM and moving GPU address calculation to individual drm drivers.
I tested this patch series on qxl, bochs and amdgpu. Christian tested it on radeon HW. It would be nice if someone test this for nouveau and vmgfx.
Nirmoy Das (8):
drm/amdgpu: move ttmbo->offsettoamdgpu_bodrm/radeon: don't use ttmbo->offsetdrm/vmwgfx: don't use ttmbo->offsetdrm/nouveau: don't use ttmbo->offsetdrm/qxl: don't use ttmbo->offsetdrm/vram-helper: don't use ttmbo->offsetdrm/bochs: usedrm_gem_vram_offsetto get bo offset drm/ttm: do not keep GPU dependent addressesdrivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 22 ++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 29 ++++++++++++++++----- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 1 + drivers/gpu/drm/bochs/bochs_kms.c | 2 +- drivers/gpu/drm/drm_gem_vram_helper.c | 2 +- drivers/gpu/drm/nouveau/dispnv04/crtc.c | 6 ++--- drivers/gpu/drm/nouveau/dispnv04/disp.c | 2 +- drivers/gpu/drm/nouveau/dispnv04/overlay.c | 6 ++--- drivers/gpu/drm/nouveau/dispnv50/base507c.c | 2 +- drivers/gpu/drm/nouveau/dispnv50/core507d.c | 2 +- drivers/gpu/drm/nouveau/dispnv50/ovly507e.c | 2 +- drivers/gpu/drm/nouveau/dispnv50/wndw.c | 2 +- drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c | 2 +- drivers/gpu/drm/nouveau/nouveau_abi16.c | 8 +++--- drivers/gpu/drm/nouveau/nouveau_bo.c | 1 + drivers/gpu/drm/nouveau/nouveau_bo.h | 3 +++ drivers/gpu/drm/nouveau/nouveau_chan.c | 2 +- drivers/gpu/drm/nouveau/nouveau_dmem.c | 2 +- drivers/gpu/drm/nouveau/nouveau_fbcon.c | 2 +- drivers/gpu/drm/nouveau/nouveau_gem.c | 10 +++---- drivers/gpu/drm/qxl/qxl_drv.h | 6 ++--- drivers/gpu/drm/qxl/qxl_kms.c | 5 ++-- drivers/gpu/drm/qxl/qxl_object.h | 5 ---- drivers/gpu/drm/qxl/qxl_ttm.c | 9 ------- drivers/gpu/drm/radeon/radeon.h | 1 + drivers/gpu/drm/radeon/radeon_object.h | 16 +++++++++++- drivers/gpu/drm/radeon/radeon_ttm.c | 4 +-- drivers/gpu/drm/ttm/ttm_bo.c | 7 ----- drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 4 +-- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 2 -- include/drm/ttm/ttm_bo_api.h | 2 -- include/drm/ttm/ttm_bo_driver.h | 1 - 35 files changed, 99 insertions(+), 76 deletions(-)--
2.25.0_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Felix Imendörffer
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 4 lines · Thomas Zimmermann
Hi,
the email's subject line should contain the version of the patchset (e.g, v2, v3, etc). git send-mail adds this with the -v switch
Thanks Thomas. I over looked that, will add version tag from my next emails.
Nirmoy
Quoted 66 lines
Best regards
ThomasAm 17.02.20 um 16:04 schrieb Nirmoy Das:
Quoted 61 lines
With this patch series I am trying to remove GPU address dependency in TTM and moving GPU address calculation to individual drm drivers.
I tested this patch series on qxl, bochs and amdgpu. Christian tested it on radeon HW. It would be nice if someone test this for nouveau and vmgfx.
Nirmoy Das (8):
drm/amdgpu: move ttm bo->offset to amdgpu_bo drm/radeon: don't use ttm bo->offset drm/vmwgfx: don't use ttm bo->offset drm/nouveau: don't use ttm bo->offset drm/qxl: don't use ttm bo->offset drm/vram-helper: don't use ttm bo->offset drm/bochs: use drm_gem_vram_offset to get bo offset drm/ttm: do not keep GPU dependent addressesdrivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 22 ++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 29 ++++++++++++++++----- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 1 + drivers/gpu/drm/bochs/bochs_kms.c | 2 +- drivers/gpu/drm/drm_gem_vram_helper.c | 2 +- drivers/gpu/drm/nouveau/dispnv04/crtc.c | 6 ++--- drivers/gpu/drm/nouveau/dispnv04/disp.c | 2 +- drivers/gpu/drm/nouveau/dispnv04/overlay.c | 6 ++--- drivers/gpu/drm/nouveau/dispnv50/base507c.c | 2 +- drivers/gpu/drm/nouveau/dispnv50/core507d.c | 2 +- drivers/gpu/drm/nouveau/dispnv50/ovly507e.c | 2 +- drivers/gpu/drm/nouveau/dispnv50/wndw.c | 2 +- drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c | 2 +- drivers/gpu/drm/nouveau/nouveau_abi16.c | 8 +++--- drivers/gpu/drm/nouveau/nouveau_bo.c | 1 + drivers/gpu/drm/nouveau/nouveau_bo.h | 3 +++ drivers/gpu/drm/nouveau/nouveau_chan.c | 2 +- drivers/gpu/drm/nouveau/nouveau_dmem.c | 2 +- drivers/gpu/drm/nouveau/nouveau_fbcon.c | 2 +- drivers/gpu/drm/nouveau/nouveau_gem.c | 10 +++---- drivers/gpu/drm/qxl/qxl_drv.h | 6 ++--- drivers/gpu/drm/qxl/qxl_kms.c | 5 ++-- drivers/gpu/drm/qxl/qxl_object.h | 5 ---- drivers/gpu/drm/qxl/qxl_ttm.c | 9 ------- drivers/gpu/drm/radeon/radeon.h | 1 + drivers/gpu/drm/radeon/radeon_object.h | 16 +++++++++++- drivers/gpu/drm/radeon/radeon_ttm.c | 4 +-- drivers/gpu/drm/ttm/ttm_bo.c | 7 ----- drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 4 +-- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 2 -- include/drm/ttm/ttm_bo_api.h | 2 -- include/drm/ttm/ttm_bo_driver.h | 1 - 35 files changed, 99 insertions(+), 76 deletions(-)--
2.25.0_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx