drm/ttm: cleanup ttm_resource_compat
Subsystems (8)
PATCH 1/5 drm/ttm: cleanup ttm_resource_compat
Move that function into the resource handling and remove an unused parameter.
--- drivers/gpu/drm/ttm/ttm_bo.c | 48 +---------------------------- drivers/gpu/drm/ttm/ttm_resource.c | 49 ++++++++++++++++++++++++++++++ drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 15 ++++----- include/drm/ttm/ttm_bo_api.h | 12 -------- include/drm/ttm/ttm_resource.h | 3 ++ 5 files changed, 59 insertions(+), 68 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +1 -47
@@ -924,57 +924,11 @@ static int ttm_bo_move_buffer(struct ttm_buffer_object *bo,return ret; } -static bool ttm_bo_places_compat (const struct ttm_place *places, -unsigned num_placement, -struct ttm_resource *mem, -uint32_t *new_flags) -{ -unsigned i; - -if (mem->placement &TTM_PL_FLAG_TEMPORARY ) -return false; - -for (i =0 ; i < num_placement; i++) { -const struct ttm_place *heap = &places[i]; - -if ((mem->start < heap->fpfn || - (heap->lpfn !=0 && (mem->start + mem->num_pages) > heap->lpfn))) -continue ; - - *new_flags = heap->flags; -if ((mem->mem_type == heap->mem_type) && - (!(*new_flags &TTM_PL_FLAG_CONTIGUOUS ) || - (mem->placement &TTM_PL_FLAG_CONTIGUOUS ))) -return true; - } -return false; -} - -bool ttm_bo_mem_compat (struct ttm_placement *placement, -struct ttm_resource *mem, -uint32_t *new_flags) -{ -if (ttm_bo_places_compat (placement->placement, placement->num_placement, - mem, new_flags)) -return true; - -if ((placement->busy_placement != placement->placement || - placement->num_busy_placement > placement->num_placement) && -ttm_bo_places_compat (placement->busy_placement, - placement->num_busy_placement, - mem, new_flags)) -return true; - -return false; -} -EXPORT_SYMBOL (ttm_bo_mem_compat); -int ttm_bo_validate (struct ttm_buffer_object *bo,struct ttm_placement *placement,struct ttm_operation_ctx *ctx) {int ret; -uint32_t new_flags;dma_resv_assert_held (bo->base.resv);
@@ -987,7 +941,7 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,/* * Check whether we need to move buffer. */ -if (!ttm_bo_mem_compat (placement, bo->resource, &new_flags)) { +if (!ttm_resource_compat (bo->resource, placement)) { ret =ttm_bo_move_buffer (bo, placement, ctx);if (ret)return ret;
drivers/gpu/drm/ttm/ttm_resource.c +49 -0
55 lines not on this page · raw message
drivers/gpu/drm/vmwgfx/vmwgfx_bo.c +6 -9
@@ -94,7 +94,6 @@ int vmw_bo_pin_in_placement(struct vmw_private *dev_priv,struct ttm_operation_ctx ctx = {interruptible, false };struct ttm_buffer_object *bo = &buf->base;int ret; -uint32_t new_flags;vmw_execbuf_release_pinned_bo (dev_priv);
@@ -103,8 +102,8 @@ int vmw_bo_pin_in_placement(struct vmw_private *dev_priv, goto err;if (buf->base.pin_count >0 ) - ret =ttm_bo_mem_compat (placement, bo->resource, - &new_flags) == true ?0 : -EINVAL ; + ret =ttm_resource_compat (bo->resource, placement) + ?0 : -EINVAL ;else ret =ttm_bo_validate (bo, placement, &ctx);
@@ -136,7 +135,6 @@ int vmw_bo_pin_in_vram_or_gmr(struct vmw_private *dev_priv,struct ttm_operation_ctx ctx = {interruptible, false };struct ttm_buffer_object *bo = &buf->base;int ret; -uint32_t new_flags;vmw_execbuf_release_pinned_bo (dev_priv);
@@ -145,8 +143,8 @@ int vmw_bo_pin_in_vram_or_gmr(struct vmw_private *dev_priv, goto err;if (buf->base.pin_count >0 ) { - ret =ttm_bo_mem_compat (&vmw_vram_gmr_placement, bo->resource, - &new_flags) == true ?0 : -EINVAL ; + ret =ttm_resource_compat (bo->resource, &vmw_vram_gmr_placement) + ?0 : -EINVAL ; goto out_unreserve; }
@@ -208,7 +206,6 @@ int vmw_bo_pin_in_start_of_vram(struct vmw_private *dev_priv,struct ttm_placement placement;struct ttm_place place;int ret =0 ; -uint32_t new_flags; place = vmw_vram_placement.placement[0 ]; place.lpfn = bo->resource->num_pages;
@@ -236,8 +233,8 @@ int vmw_bo_pin_in_start_of_vram(struct vmw_private *dev_priv, }if (buf->base.pin_count >0 ) - ret =ttm_bo_mem_compat (&placement, bo->resource, - &new_flags) == true ?0 : -EINVAL ; + ret =ttm_resource_compat (bo->resource, &placement) + ?0 : -EINVAL ;else ret =ttm_bo_validate (bo, &placement, &ctx);
include/drm/ttm/ttm_bo_api.h +0 -12
@@ -264,18 +264,6 @@ static inline int ttm_bo_wait_ctx(struct ttm_buffer_object *bo, struct ttm_operareturn ttm_bo_wait (bo, ctx->interruptible, ctx->no_wait_gpu); } -/** -* ttm_bo_mem_compat - Check if proposed placement is compatible with a bo -* -* @placement: Return immediately if buffer is busy. -* @mem: The struct ttm_resource indicating the region where the bo resides -* @new_flags: Describes compatible placement found -* -* Returns true if the placement is compatible -*/ -bool ttm_bo_mem_compat (struct ttm_placement *placement,struct ttm_resource *mem, -uint32_t *new_flags); -/** * ttm_bo_validate *
include/drm/ttm/ttm_resource.h +3 -0
@@ -40,6 +40,7 @@ struct ttm_resource_manager;struct ttm_resource ;struct ttm_place ;struct ttm_buffer_object ; +struct ttm_placement ;struct dma_buf_map ;struct io_mapping ;struct sg_table ;
@@ -266,6 +267,8 @@ int ttm_resource_alloc(struct ttm_buffer_object *bo,const struct ttm_place *place, struct ttm_resource **res);void ttm_resource_free (struct ttm_buffer_object *bo,struct ttm_resource **res); +bool ttm_resource_compat (struct ttm_resource *res, +struct ttm_placement *placement);void ttm_resource_manager_init (struct ttm_resource_manager *man,unsigned long p_size);
Signature · 1 line
2.25.1
PATCH 2/5 drm/ttm: add busy and idle placement flags
More flexible than the busy placements.
--- drivers/gpu/drm/ttm/ttm_bo.c | 8 +++++++- include/drm/ttm/ttm_placement.h | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_bo.c +7 -1
@@ -834,6 +834,9 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,const struct ttm_place *place = &placement->placement[i];struct ttm_resource_manager *man; +if (place->flags &TTM_PL_FLAG_BUSY ) +continue ; + man =ttm_manager_type (bdev, place->mem_type);if (!man || !ttm_resource_manager_used (man))continue ;
@@ -860,6 +863,9 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,const struct ttm_place *place = &placement->busy_placement[i];struct ttm_resource_manager *man; +if (place->flags &TTM_PL_FLAG_IDLE ) +continue ; + man =ttm_manager_type (bdev, place->mem_type);if (!man || !ttm_resource_manager_used (man))continue ;
@@ -869,7 +875,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,if (likely (!ret))return 0 ; -if (ret && ret != -EBUSY ) +if (ret != -EBUSY ) goto error; }
include/drm/ttm/ttm_placement.h +6 -0
@@ -53,6 +53,12 @@/* For multihop handling */ #define TTM_PL_FLAG_TEMPORARY (1 << 2) +/* Placement is only used when we are evicting */ +#define TTM_PL_FLAG_BUSY (1 << 3) + +/* Placement is only used when we are not evicting */ +#define TTM_PL_FLAG_IDLE (1 << 4) +/** * struct ttm_place *
Signature · 1 line
2.25.1
Re: [PATCH 2/5] drm/ttm: add busy and idle placement flags
Quoted 46 lines · Christian König
More flexible than the busy placements.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 8 +++++++- include/drm/ttm/ttm_placement.h | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-)drivers/gpu/drm/ttm/ttm_bo.c +7
-1@@ -834,6 +834,9 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,const struct ttm_place *place = &placement->placement[i];struct ttm_resource_manager *man; +if (place->flags &TTM_PL_FLAG_BUSY ) +continue ; + man =ttm_manager_type (bdev, place->mem_type);if (!man || !ttm_resource_manager_used (man))continue ;@@ -860,6 +863,9 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,const struct ttm_place *place = &placement->busy_placement[i];struct ttm_resource_manager *man; +if (place->flags &TTM_PL_FLAG_IDLE ) +continue ; + man =ttm_manager_type (bdev, place->mem_type);if (!man || !ttm_resource_manager_used (man))continue ;@@ -869,7 +875,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,if (likely (!ret))return 0 ; -if (ret && ret != -EBUSY ) +if (ret != -EBUSY ) goto error; }include/drm/ttm/ttm_placement.h +0
-0
include/drm/ttm/ttm_placement.h line 60
Quoted 8 lines
include/drm/ttm/ttm_placement.h +5
-0@@ -53,6 +53,12 @@/* For multihop handling */ #define TTM_PL_FLAG_TEMPORARY (1 << 2) +/* Placement is only used when we are evicting */ +#define TTM_PL_FLAG_BUSY (1 << 3) + +/* Placement is only used when we are not evicting */ +#define TTM_PL_FLAG_IDLE (1 << 4)
Using an enum for this (with BIT() macro or so) and then slapping kerneldoc on top would be nice. That way you can also use the same enum in parameters and structures and it's all a bit easier to find and connect.
Otherwise I think this series makes sense, but probably better for nouveau folks to do review/testing.
-Daniel
Quoted 7 lines
include/drm/ttm/ttm_placement.h +1
-0+/** * struct ttm_place * Signature · 1 line
2.25.1
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Re: [PATCH 2/5] drm/ttm: add busy and idle placement flags
Am 31.08.21 um 15:18 schrieb Daniel Vetter:
Quoted 50 lines · Christian König
Quoted 49 lines
More flexible than the busy placements.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 8 +++++++- include/drm/ttm/ttm_placement.h | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-)drivers/gpu/drm/ttm/ttm_bo.c +7
-1@@ -834,6 +834,9 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,const struct ttm_place *place = &placement->placement[i];struct ttm_resource_manager *man; +if (place->flags &TTM_PL_FLAG_BUSY ) +continue ; + man =ttm_manager_type (bdev, place->mem_type);if (!man || !ttm_resource_manager_used (man))continue ;@@ -860,6 +863,9 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,const struct ttm_place *place = &placement->busy_placement[i];struct ttm_resource_manager *man; +if (place->flags &TTM_PL_FLAG_IDLE ) +continue ; + man =ttm_manager_type (bdev, place->mem_type);if (!man || !ttm_resource_manager_used (man))continue ;@@ -869,7 +875,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,if (likely (!ret))return 0 ; -if (ret && ret != -EBUSY ) +if (ret != -EBUSY ) goto error; }include/drm/ttm/ttm_placement.h +0
-0@@ -53,6 +53,12 @@/* For multihop handling */ #define TTM_PL_FLAG_TEMPORARY (1 << 2)
Quoted 8 lines
include/drm/ttm/ttm_placement.h line 60
Quoted 5 lines
include/drm/ttm/ttm_placement.h +5
-0+/* Placement is only used when we are evicting */ +#define TTM_PL_FLAG_BUSY (1 << 3) + +/* Placement is only used when we are not evicting */ +#define TTM_PL_FLAG_IDLE (1 << 4)Using an enum for this (with
BIT()macro or so) and then slapping kerneldoc on top would be nice. That way you can also use the same enum in parameters and structures and it's all a bit easier to find and connect.
I don't really like to define flags as enums since they are not really an enumeration.
But some more kerneldoc sounds like a good idea to me.
Quoted 2 lines
Otherwise I think this series makes sense, but probably better for nouveau folks to do review/testing.
Yeah, agree completely. I can do some smoke testing with nouveau, but that's about it.
Christian.
Quoted 9 lines
-Daniel
Quoted 7 lines
include/drm/ttm/ttm_placement.h +1
-0+/** * struct ttm_place * Signature · 1 line
2.25.1
Re: [PATCH 2/5] drm/ttm: add busy and idle placement flags
In reply to Christian KönigQuoted 3 lines · Christian König
More flexible than the busy placements.
Signed-off-by Christian König <[email protected]>
Patch 2 -> 5 are Acked-by: Huang Rui <[email protected]>
Quoted 58 lines
--- drivers/gpu/drm/ttm/ttm_bo.c | 8 +++++++- include/drm/ttm/ttm_placement.h | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-)drivers/gpu/drm/ttm/ttm_bo.c +7
-1@@ -834,6 +834,9 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,const struct ttm_place *place = &placement->placement[i];struct ttm_resource_manager *man; +if (place->flags &TTM_PL_FLAG_BUSY ) +continue ; + man =ttm_manager_type (bdev, place->mem_type);if (!man || !ttm_resource_manager_used (man))continue ;@@ -860,6 +863,9 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,const struct ttm_place *place = &placement->busy_placement[i];struct ttm_resource_manager *man; +if (place->flags &TTM_PL_FLAG_IDLE ) +continue ; + man =ttm_manager_type (bdev, place->mem_type);if (!man || !ttm_resource_manager_used (man))continue ;@@ -869,7 +875,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,if (likely (!ret))return 0 ; -if (ret && ret != -EBUSY ) +if (ret != -EBUSY ) goto error; }include/drm/ttm/ttm_placement.h +6
-0@@ -53,6 +53,12 @@/* For multihop handling */ #define TTM_PL_FLAG_TEMPORARY (1 << 2) +/* Placement is only used when we are evicting */ +#define TTM_PL_FLAG_BUSY (1 << 3) + +/* Placement is only used when we are not evicting */ +#define TTM_PL_FLAG_IDLE (1 << 4) +/** * struct ttm_place * Signature · 1 line
2.25.1
PATCH 3/5 drm/amdgpu: use new placement flags
In reply to Christian KönigInstead of the busy placement.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 3 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1 -2
@@ -1393,8 +1393,7 @@ vm_fault_t amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo) AMDGPU_GEM_DOMAIN_GTT);/* Avoid costly evictions; only set GTT as a busy placement */ - abo->placement.num_busy_placement =1 ; - abo->placement.busy_placement = &abo->placements[1 ]; + abo->placements[0 ].flags |=TTM_PL_FLAG_IDLE ; r =ttm_bo_validate (bo, &abo->placement, &ctx);if (unlikely (r == -EBUSY || r == -ERESTARTSYS ))
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -2
@@ -153,8 +153,7 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo, AMDGPU_GEM_DOMAIN_CPU); abo->placements[0 ].fpfn = adev->gmc.visible_vram_size >>PAGE_SHIFT ; abo->placements[0 ].lpfn =0 ; - abo->placement.busy_placement = &abo->placements[1 ]; - abo->placement.num_busy_placement =1 ; + abo->placements[0 ].flags =TTM_PL_FLAG_IDLE ; }else {/* Move to GTT memory */ amdgpu_bo_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_GTT |
Signature · 1 line
2.25.1
PATCH 4/5 drm/nouveau: switch to using new placement flags
In reply to Christian KönigThis simplifies the handling quite a bit, but needs extensive testing.
--- drivers/gpu/drm/nouveau/nouveau_bo.c | 61 ++++++++++------------------ drivers/gpu/drm/nouveau/nouveau_bo.h | 1 - 2 files changed, 22 insertions(+), 40 deletions(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +22 -39
@@ -344,33 +344,41 @@ nouveau_bo_new(struct nouveau_cli *cli, u64 size, int align,return 0 ; } -static void -set_placement_list (struct ttm_place *pl,unsigned *n,uint32_t domain) +void +nouveau_bo_placement_set (struct nouveau_bo *nvbo,uint32_t domain, +uint32_t busy) { - *n =0 ; +struct nouveau_drm *drm =nouveau_bdev (nvbo->bo.bdev); +u64 vram_size = drm->client.device.info.ram_size; +unsigned *n = &nvbo->placement.num_placement; +struct ttm_place *pl = nvbo->placements; +unsigned i, fpfn, lpfn; + nvbo->placement.placement = pl; + nvbo->placement.busy_placement = pl; + busy &= ~domain; + domain |= busy; + + *n =0 ;if (domain &NOUVEAU_GEM_DOMAIN_VRAM ) { pl[*n].mem_type =TTM_PL_VRAM ; - pl[*n].flags =0 ; + pl[*n].flags = busy &NOUVEAU_GEM_DOMAIN_VRAM ? +TTM_PL_FLAG_BUSY :0 ; (*n)++; }if (domain &NOUVEAU_GEM_DOMAIN_GART ) { pl[*n].mem_type =TTM_PL_TT ; - pl[*n].flags =0 ; + pl[*n].flags = busy &NOUVEAU_GEM_DOMAIN_GART ? +TTM_PL_FLAG_BUSY :0 ; (*n)++; }if (domain &NOUVEAU_GEM_DOMAIN_CPU ) { pl[*n].mem_type =TTM_PL_SYSTEM ; - pl[(*n)++].flags =0 ; + pl[*n].flags = busy &NOUVEAU_GEM_DOMAIN_CPU ? +TTM_PL_FLAG_BUSY :0 ; + (*n)++; } -} - -static void -set_placement_range (struct nouveau_bo *nvbo,uint32_t domain) -{ -struct nouveau_drm *drm =nouveau_bdev (nvbo->bo.bdev); -u64 vram_size = drm->client.device.info.ram_size; -unsigned i, fpfn, lpfn; + nvbo->placement.num_busy_placement = *n; if (drm->client.device.info.family == NV_DEVICE_INFO_V0_CELSIUS && nvbo->mode && (domain & NOUVEAU_GEM_DOMAIN_VRAM) &&
@@ -392,29 +400,9 @@ set_placement_range(struct nouveau_bo *nvbo, uint32_t domain) nvbo->placements[i].fpfn = fpfn; nvbo->placements[i].lpfn = lpfn; } -for (i =0 ; i < nvbo->placement.num_busy_placement; ++i) { - nvbo->busy_placements[i].fpfn = fpfn; - nvbo->busy_placements[i].lpfn = lpfn; - } } } -void -nouveau_bo_placement_set (struct nouveau_bo *nvbo,uint32_t domain, -uint32_t busy) -{ -struct ttm_placement *pl = &nvbo->placement; - - pl->placement = nvbo->placements; -set_placement_list (nvbo->placements, &pl->num_placement, domain); - - pl->busy_placement = nvbo->busy_placements; -set_placement_list (nvbo->busy_placements, &pl->num_busy_placement, - domain | busy); - -set_placement_range (nvbo, domain); -} -int nouveau_bo_pin (struct nouveau_bo *nvbo,uint32_t domain,bool contig) {
@@ -1224,11 +1212,6 @@ vm_fault_t nouveau_ttm_fault_reserve_notify(struct ttm_buffer_object *bo) nvbo->placements[i].lpfn = mappable; } -for (i =0 ; i < nvbo->placement.num_busy_placement; ++i) { - nvbo->busy_placements[i].fpfn =0 ; - nvbo->busy_placements[i].lpfn = mappable; - } -nouveau_bo_placement_set (nvbo,NOUVEAU_GEM_DOMAIN_VRAM ,0 ); }
drivers/gpu/drm/nouveau/nouveau_bo.h +0 -1
@@ -14,7 +14,6 @@ struct nouveau_bo {struct ttm_placement placement;u32 valid_domains;struct ttm_place placements[3 ]; -struct ttm_place busy_placements[3 ];bool force_coherent;struct ttm_bo_kmap_obj kmap;struct list_head head;
Signature · 1 line
2.25.1
PATCH 5/5 drm/ttm: remove busy placement handling
In reply to Christian KönigDrivers can now use the flags for this.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 3 - drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 7 -- drivers/gpu/drm/drm_gem_vram_helper.c | 2 - drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 4 -- drivers/gpu/drm/nouveau/nouveau_bo.c | 2 - drivers/gpu/drm/qxl/qxl_object.c | 2 - drivers/gpu/drm/qxl/qxl_ttm.c | 2 - drivers/gpu/drm/radeon/radeon_object.c | 3 - drivers/gpu/drm/radeon/radeon_ttm.c | 11 +-- drivers/gpu/drm/radeon/radeon_uvd.c | 1 - drivers/gpu/drm/ttm/ttm_bo.c | 13 ++-- drivers/gpu/drm/ttm/ttm_resource.c | 41 ++++-------- drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 2 - drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 78 +++++++++++++--------- include/drm/ttm/ttm_placement.h | 4 -- 15 files changed, 66 insertions(+), 109 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0 -3
@@ -200,9 +200,6 @@ void amdgpu_bo_placement_from_domain(struct amdgpu_bo *abo, u32 domain) placement->num_placement = c; placement->placement = places; - - placement->num_busy_placement = c; - placement->busy_placement = places; }/**
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -7
@@ -98,16 +98,13 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo,/* Don't handle scatter gather BOs */ if (bo->type == ttm_bo_type_sg) { placement->num_placement =0 ; - placement->num_busy_placement =0 ;return ; }/* Object isn't an AMDGPU object so ignore */ if (!amdgpu_bo_is_amdgpu_bo (bo)) { placement->placement = &placements; - placement->busy_placement = &placements; placement->num_placement =1 ; - placement->num_busy_placement =1 ;return ; }
@@ -122,7 +119,6 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo,dma_fence_enable_sw_signaling (fence); placement->num_placement =0 ; - placement->num_busy_placement =0 ;rcu_read_unlock ();return ; }
@@ -132,7 +128,6 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo,case AMDGPU_PL_GWS :case AMDGPU_PL_OA : placement->num_placement =0 ; - placement->num_busy_placement =0 ;return ;case TTM_PL_VRAM :
@@ -972,8 +967,6 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo)/* allocate GART space */ placement.num_placement =1 ; placement.placement = &placements; - placement.num_busy_placement =1 ; - placement.busy_placement = &placements; placements.fpfn =0 ; placements.lpfn = adev->gmc.gart_size >>PAGE_SHIFT ; placements.mem_type =TTM_PL_TT ;
drivers/gpu/drm/drm_gem_vram_helper.c +0 -2
@@ -145,7 +145,6 @@ static void drm_gem_vram_placement(struct drm_gem_vram_object *gbo, invariant_flags =TTM_PL_FLAG_TOPDOWN ; gbo->placement.placement = gbo->placements; - gbo->placement.busy_placement = gbo->placements;if (pl_flag &DRM_GEM_VRAM_PL_FLAG_VRAM ) { gbo->placements[c].mem_type =TTM_PL_VRAM ;
@@ -158,7 +157,6 @@ static void drm_gem_vram_placement(struct drm_gem_vram_object *gbo, } gbo->placement.num_placement = c; - gbo->placement.num_busy_placement = c;for (i =0 ; i < c; ++i) { gbo->placements[i].fpfn =0 ;
drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0 -4
@@ -59,15 +59,11 @@ static const struct ttm_place lmem0_sys_placement_flags[] = {static struct ttm_placement i915_lmem0_placement = { .num_placement =1 , .placement = &lmem0_sys_placement_flags[0 ], - .num_busy_placement =1 , - .busy_placement = &lmem0_sys_placement_flags[0 ], };static struct ttm_placement i915_sys_placement = { .num_placement =1 , .placement = &lmem0_sys_placement_flags[1 ], - .num_busy_placement =1 , - .busy_placement = &lmem0_sys_placement_flags[1 ], };static void i915_ttm_adjust_lru (struct drm_i915_gem_object *obj);
drivers/gpu/drm/nouveau/nouveau_bo.c +0 -2
@@ -355,7 +355,6 @@ nouveau_bo_placement_set(struct nouveau_bo *nvbo, uint32_t domain,unsigned i, fpfn, lpfn; nvbo->placement.placement = pl; - nvbo->placement.busy_placement = pl; busy &= ~domain; domain |= busy;
@@ -378,7 +377,6 @@ nouveau_bo_placement_set(struct nouveau_bo *nvbo, uint32_t domain, TTM_PL_FLAG_BUSY :0 ; (*n)++; } - nvbo->placement.num_busy_placement = *n; if (drm->client.device.info.family == NV_DEVICE_INFO_V0_CELSIUS && nvbo->mode && (domain & NOUVEAU_GEM_DOMAIN_VRAM) &&
drivers/gpu/drm/qxl/qxl_object.c +0 -2
@@ -66,7 +66,6 @@ void qxl_ttm_placement_from_domain(struct qxl_bo *qbo, u32 domain) pflag |=TTM_PL_FLAG_TOPDOWN ; qbo->placement.placement = qbo->placements; - qbo->placement.busy_placement = qbo->placements;if (domain ==QXL_GEM_DOMAIN_VRAM ) { qbo->placements[c].mem_type =TTM_PL_VRAM ; qbo->placements[c++].flags = pflag;
@@ -86,7 +85,6 @@ void qxl_ttm_placement_from_domain(struct qxl_bo *qbo, u32 domain) qbo->placements[c++].flags =0 ; } qbo->placement.num_placement = c; - qbo->placement.num_busy_placement = c;for (i =0 ; i < c; ++i) { qbo->placements[i].fpfn =0 ; qbo->placements[i].lpfn =0 ;
drivers/gpu/drm/qxl/qxl_ttm.c +0 -2
@@ -60,9 +60,7 @@ static void qxl_evict_flags(struct ttm_buffer_object *bo,if (!qxl_ttm_bo_is_qxl_bo (bo)) { placement->placement = &placements; - placement->busy_placement = &placements; placement->num_placement =1 ; - placement->num_busy_placement =1 ;return ; } qbo =to_qxl_bo (bo);
drivers/gpu/drm/radeon/radeon_object.c +0 -3
@@ -99,7 +99,6 @@ void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain)u32 c =0 , i; rbo->placement.placement = rbo->placements; - rbo->placement.busy_placement = rbo->placements;if (domain &RADEON_GEM_DOMAIN_VRAM ) {/* Try placing BOs which don't need CPU access outside of the * CPU accessible part of VRAM
@@ -135,8 +134,6 @@ void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain) } rbo->placement.num_placement = c; - rbo->placement.num_busy_placement = c; -for (i =0 ; i < c; ++i) { if ((rbo->flags & RADEON_GEM_CPU_ACCESS) && (rbo->placements[i].mem_type == TTM_PL_VRAM) &&
drivers/gpu/drm/radeon/radeon_ttm.c +3 -8
@@ -93,9 +93,7 @@ static void radeon_evict_flags(struct ttm_buffer_object *bo,if (!radeon_ttm_bo_is_radeon_bo (bo)) { placement->placement = &placements; - placement->busy_placement = &placements; placement->num_placement =1 ; - placement->num_busy_placement =1 ;return ; } rbo = container_of(bo, struct radeon_bo, tbo);
@@ -113,17 +111,14 @@ static void radeon_evict_flags(struct ttm_buffer_object *bo,* BO will be evicted to GTT rather than causing other * BOs to be evicted from VRAM */ -radeon_ttm_placement_from_domain (rbo,RADEON_GEM_DOMAIN_VRAM | +radeon_ttm_placement_from_domain (rbo, +RADEON_GEM_DOMAIN_VRAM |RADEON_GEM_DOMAIN_GTT ); - rbo->placement.num_busy_placement =0 ;for (i =0 ; i < rbo->placement.num_placement; i++) {if (rbo->placements[i].mem_type ==TTM_PL_VRAM ) {if (rbo->placements[i].fpfn < fpfn) rbo->placements[i].fpfn = fpfn; - }else { - rbo->placement.busy_placement = - &rbo->placements[i]; - rbo->placement.num_busy_placement =1 ; + rbo->placements[i].flags |=TTM_PL_FLAG_IDLE ; } } }else
drivers/gpu/drm/radeon/radeon_uvd.c +0 -1
@@ -324,7 +324,6 @@ void radeon_uvd_force_into_uvd_segment(struct radeon_bo *rbo, rbo->placements[1 ].fpfn += (256 *1024 *1024 ) >>PAGE_SHIFT ; rbo->placements[1 ].lpfn += (256 *1024 *1024 ) >>PAGE_SHIFT ; rbo->placement.num_placement++; - rbo->placement.num_busy_placement++; }void radeon_uvd_free_handles (struct radeon_device *rdev,struct drm_file *filp)
drivers/gpu/drm/ttm/ttm_bo.c +6 -7
@@ -507,8 +507,8 @@ static int ttm_bo_bounce_temp_buffer(struct ttm_buffer_object *bo,struct ttm_resource *hop_mem;int ret; - hop_placement.num_placement = hop_placement.num_busy_placement =1 ; - hop_placement.placement = hop_placement.busy_placement = hop; + hop_placement.num_placement =1 ; + hop_placement.placement = hop;/* find space in the bounce domain */ ret =ttm_bo_mem_space (bo, &hop_placement, &hop_mem, ctx);
@@ -537,10 +537,9 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo,dma_resv_assert_held (bo->base.resv); placement.num_placement =0 ; - placement.num_busy_placement =0 ; bdev->funcs->evict_flags (bo, &placement); -if (!placement.num_placement && !placement.num_busy_placement) { +if (!placement.num_placement) { ret =ttm_bo_wait (bo, true, false);if (ret)return ret;
@@ -859,8 +858,8 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,return 0 ; } -for (i =0 ; i < placement->num_busy_placement; ++i) { -const struct ttm_place *place = &placement->busy_placement[i]; +for (i =0 ; i < placement->num_placement; ++i) { +const struct ttm_place *place = &placement->placement[i];struct ttm_resource_manager *man;if (place->flags &TTM_PL_FLAG_IDLE )
@@ -941,7 +940,7 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,/* * Remove the backing store if no placement is given. */ -if (!placement->num_placement && !placement->num_busy_placement) +if (!placement->num_placement)return ttm_bo_pipeline_gutting (bo);/*
drivers/gpu/drm/ttm/ttm_resource.c +12 -29
59 lines not on this page · raw message
drivers/gpu/drm/vmwgfx/vmwgfx_bo.c +0 -2
@@ -211,8 +211,6 @@ int vmw_bo_pin_in_start_of_vram(struct vmw_private *dev_priv, place.lpfn = bo->resource->num_pages; placement.num_placement =1 ; placement.placement = &place; - placement.num_busy_placement =1 ; - placement.busy_placement = &place;vmw_execbuf_release_pinned_bo (dev_priv); ret =ttm_bo_reserve (bo, interruptible, false,NULL );
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c +45 -33
139 lines not on this page · raw message
include/drm/ttm/ttm_placement.h +0 -4
@@ -80,16 +80,12 @@ struct ttm_place {* * @num_placement: number of preferred placements * @placement: preferred placements -* @num_busy_placement: number of preferred placements when need to evict buffer -* @busy_placement: preferred placements when need to evict buffer * * Structure indicating the placement you request for an object. */ struct ttm_placement {unsigned num_placement;const struct ttm_place *placement; -unsigned num_busy_placement; -const struct ttm_place *busy_placement; };#endif
Signature · 1 line
2.25.1
Quoted 3 lines · Christian König
Move that function into the resource handling and remove an unused parameter.
Signed-off-by Christian König <[email protected]>
Looks this patch is separate from others in this series.
new_flags won't be used anymore.
Quoted 247 lines
--- drivers/gpu/drm/ttm/ttm_bo.c | 48 +---------------------------- drivers/gpu/drm/ttm/ttm_resource.c | 49 ++++++++++++++++++++++++++++++ drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 15 ++++----- include/drm/ttm/ttm_bo_api.h | 12 -------- include/drm/ttm/ttm_resource.h | 3 ++ 5 files changed, 59 insertions(+), 68 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +1
-47@@ -924,57 +924,11 @@ static int ttm_bo_move_buffer(struct ttm_buffer_object *bo,return ret; } -static bool ttm_bo_places_compat (const struct ttm_place *places, -unsigned num_placement, -struct ttm_resource *mem, -uint32_t *new_flags) -{ -unsigned i; - -if (mem->placement &TTM_PL_FLAG_TEMPORARY ) -return false; - -for (i =0 ; i < num_placement; i++) { -const struct ttm_place *heap = &places[i]; - -if ((mem->start < heap->fpfn || - (heap->lpfn !=0 && (mem->start + mem->num_pages) > heap->lpfn))) -continue ; - - *new_flags = heap->flags; -if ((mem->mem_type == heap->mem_type) && - (!(*new_flags &TTM_PL_FLAG_CONTIGUOUS ) || - (mem->placement &TTM_PL_FLAG_CONTIGUOUS ))) -return true; - } -return false; -} - -bool ttm_bo_mem_compat (struct ttm_placement *placement, -struct ttm_resource *mem, -uint32_t *new_flags) -{ -if (ttm_bo_places_compat (placement->placement, placement->num_placement, - mem, new_flags)) -return true; - -if ((placement->busy_placement != placement->placement || - placement->num_busy_placement > placement->num_placement) && -ttm_bo_places_compat (placement->busy_placement, - placement->num_busy_placement, - mem, new_flags)) -return true; - -return false; -} -EXPORT_SYMBOL (ttm_bo_mem_compat); -int ttm_bo_validate (struct ttm_buffer_object *bo,struct ttm_placement *placement,struct ttm_operation_ctx *ctx) {int ret; -uint32_t new_flags;dma_resv_assert_held (bo->base.resv);@@ -987,7 +941,7 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,/* * Check whether we need to move buffer. */ -if (!ttm_bo_mem_compat (placement, bo->resource, &new_flags)) { +if (!ttm_resource_compat (bo->resource, placement)) { ret =ttm_bo_move_buffer (bo, placement, ctx);if (ret)return ret;drivers/gpu/drm/ttm/ttm_resource.c +49
-0@@ -67,6 +67,55 @@ void ttm_resource_free(struct ttm_buffer_object *bo, struct ttm_resource **res) }EXPORT_SYMBOL (ttm_resource_free); +static bool ttm_resource_places_compat (struct ttm_resource *res, +const struct ttm_place *places, +unsigned num_placement) +{ +unsigned i; + +if (res->placement &TTM_PL_FLAG_TEMPORARY ) +return false; + +for (i =0 ; i < num_placement; i++) { +const struct ttm_place *heap = &places[i]; + +if (res->start < heap->fpfn || (heap->lpfn && + (res->start + res->num_pages) > heap->lpfn)) +continue ; + +if ((res->mem_type == heap->mem_type) && + (!(heap->flags &TTM_PL_FLAG_CONTIGUOUS ) || + (res->placement &TTM_PL_FLAG_CONTIGUOUS ))) +return true; + } +return false; +} + +/** +* ttm_resource_compat - check if resource is compatible with placement +* +* @res: the resource to check +* @placement: the placement to check against +* +* Returns true if the placement is compatible. +*/ +bool ttm_resource_compat (struct ttm_resource *res, +struct ttm_placement *placement) +{ +if (ttm_resource_places_compat (res, placement->placement, + placement->num_placement)) +return true; + +if ((placement->busy_placement != placement->placement || + placement->num_busy_placement > placement->num_placement) && +ttm_resource_places_compat (res, placement->busy_placement, + placement->num_busy_placement)) +return true; + +return false; +} +EXPORT_SYMBOL (ttm_resource_compat); +/** * ttm_resource_manager_init * drivers/gpu/drm/vmwgfx/vmwgfx_bo.c +6
-9@@ -94,7 +94,6 @@ int vmw_bo_pin_in_placement(struct vmw_private *dev_priv,struct ttm_operation_ctx ctx = {interruptible, false };struct ttm_buffer_object *bo = &buf->base;int ret; -uint32_t new_flags;vmw_execbuf_release_pinned_bo (dev_priv);@@ -103,8 +102,8 @@ int vmw_bo_pin_in_placement(struct vmw_private *dev_priv, goto err;if (buf->base.pin_count >0 ) - ret =ttm_bo_mem_compat (placement, bo->resource, - &new_flags) == true ?0 : -EINVAL ; + ret =ttm_resource_compat (bo->resource, placement) + ?0 : -EINVAL ;else ret =ttm_bo_validate (bo, placement, &ctx);@@ -136,7 +135,6 @@ int vmw_bo_pin_in_vram_or_gmr(struct vmw_private *dev_priv,struct ttm_operation_ctx ctx = {interruptible, false };struct ttm_buffer_object *bo = &buf->base;int ret; -uint32_t new_flags;vmw_execbuf_release_pinned_bo (dev_priv);@@ -145,8 +143,8 @@ int vmw_bo_pin_in_vram_or_gmr(struct vmw_private *dev_priv, goto err;if (buf->base.pin_count >0 ) { - ret =ttm_bo_mem_compat (&vmw_vram_gmr_placement, bo->resource, - &new_flags) == true ?0 : -EINVAL ; + ret =ttm_resource_compat (bo->resource, &vmw_vram_gmr_placement) + ?0 : -EINVAL ; goto out_unreserve; }@@ -208,7 +206,6 @@ int vmw_bo_pin_in_start_of_vram(struct vmw_private *dev_priv,struct ttm_placement placement;struct ttm_place place;int ret =0 ; -uint32_t new_flags; place = vmw_vram_placement.placement[0 ]; place.lpfn = bo->resource->num_pages;@@ -236,8 +233,8 @@ int vmw_bo_pin_in_start_of_vram(struct vmw_private *dev_priv, }if (buf->base.pin_count >0 ) - ret =ttm_bo_mem_compat (&placement, bo->resource, - &new_flags) == true ?0 : -EINVAL ; + ret =ttm_resource_compat (bo->resource, &placement) + ?0 : -EINVAL ;else ret =ttm_bo_validate (bo, &placement, &ctx);include/drm/ttm/ttm_bo_api.h +0
-12@@ -264,18 +264,6 @@ static inline int ttm_bo_wait_ctx(struct ttm_buffer_object *bo, struct ttm_operareturn ttm_bo_wait (bo, ctx->interruptible, ctx->no_wait_gpu); } -/** -* ttm_bo_mem_compat - Check if proposed placement is compatible with a bo -* -* @placement: Return immediately if buffer is busy. -* @mem: The struct ttm_resource indicating the region where the bo resides -* @new_flags: Describes compatible placement found -* -* Returns true if the placement is compatible -*/ -bool ttm_bo_mem_compat (struct ttm_placement *placement,struct ttm_resource *mem, -uint32_t *new_flags); -/** * ttm_bo_validate * include/drm/ttm/ttm_resource.h +3
-0@@ -40,6 +40,7 @@ struct ttm_resource_manager;struct ttm_resource ;struct ttm_place ;struct ttm_buffer_object ; +struct ttm_placement ;struct dma_buf_map ;struct io_mapping ;struct sg_table ;@@ -266,6 +267,8 @@ int ttm_resource_alloc(struct ttm_buffer_object *bo,const struct ttm_place *place, struct ttm_resource **res);void ttm_resource_free (struct ttm_buffer_object *bo,struct ttm_resource **res); +bool ttm_resource_compat (struct ttm_resource *res, +struct ttm_placement *placement);void ttm_resource_manager_init (struct ttm_resource_manager *man,unsigned long p_size);Signature · 1 line
2.25.1