Re: [PATCH] drm/ttm: specify bo priority when initializing ttm bo
On 05/11/2018 10:26 AM, zhoucm1 wrote: On 2018年05月11日 10:19, Zhang, Jerry (Junwei) wrote: On 05/11/2018 10:11 AM, zhoucm1 wrote: On 2018年05月11日 09:21, Zhang, Jerry (Junwei) wrote: On 05/10/2018 10:40 PM, Christian König wrote: Am 10.05.2018 um 07:01 schrieb Junwei Zhang: Expect to add an evitable bo who has reservation object to the correct lru[bo->priority] list Nice catch, but since this affects only a very small use case can we just remove and readd the BO to the LRU? A call to ttm_bo_move_to_lru_tail() after setting the priority should be sufficient. Yeah, at that moment, I thought setting a priority for tbo at initialization is a general way, which may help all associated modules to get out of potential pain if more priorities are adopted. Agree. The most simple way is to move the bo back to expected lru after priority setting. Going to prepare a patch. No, there is more simpler way. see inline... (in this case, include amd-gfx mail only) Regards, Jerry Thanks, Christian. Signed-off-by: Junwei Zhang --- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 11 ++- drivers/gpu/drm/ast/ast_ttm.c | 2 +- drivers/gpu/drm/bochs/bochs_mm.c| 2 +- drivers/gpu/drm/cirrus/cirrus_ttm.c | 2 +- drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c | 2 +- drivers/gpu/drm/mgag200/mgag200_ttm.c | 2 +- drivers/gpu/drm/nouveau/nouveau_bo.c| 2 +- drivers/gpu/drm/qxl/qxl_object.c| 2 +- drivers/gpu/drm/radeon/radeon_object.c | 2 +- drivers/gpu/drm/ttm/ttm_bo.c| 8 +--- drivers/gpu/drm/virtio/virtgpu_object.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_resource.c| 2 +- drivers/staging/vboxvideo/vbox_ttm.c| 2 +- include/drm/ttm/ttm_bo_api.h| 5 - 14 files changed, 26 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index e62153a..9a25ecb 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -360,6 +360,7 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, }; struct amdgpu_bo *bo; unsigned long page_align, size = bp->size; +uint32_t prio = 0; size_t acc_size; int r; @@ -419,10 +420,13 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, bo->tbo.bdev = &adev->mman.bdev; amdgpu_ttm_placement_from_domain(bo, bp->domain); +if (bp->type == ttm_bo_type_kernel) +prio = 1; Why not just bo->tbo.priority = 1? In that case, you don't need to add more parameter to ttm_bo_init_reserved. In fact, this change is already in my per-vm-lru patch set. Do you mean specify 1 before ttm_bo_init_reserved()? ttm_bo_init_reserved() will overwrite it to 0 again inside. If it can set outside of ttm, you can remove that overwriting. tbo allocation is from kzalloc. Yeah, that bases on different coding idea, I think. 1) always to clear the tbo memory before tbo init (mostly, we do so) 2) make sure the key(all) members are initialized as expected always inside init function. anyway, I will sent it out firstly and RFC. Jerry Regards, David Zhou Jerry Regards, David Zhou r = ttm_bo_init_reserved(&adev->mman.bdev, &bo->tbo, size, bp->type, - &bo->placement, page_align, &ctx, acc_size, - NULL, bp->resv, &amdgpu_ttm_bo_destroy); + prio, &bo->placement, page_align, &ctx, + acc_size, NULL, bp->resv, + &amdgpu_ttm_bo_destroy); if (unlikely(r != 0)) return r; @@ -434,9 +438,6 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, else amdgpu_cs_report_moved_bytes(adev, ctx.bytes_moved, 0); -if (bp->type == ttm_bo_type_kernel) -bo->tbo.priority = 1; - if (bp->flags & AMDGPU_GEM_CREATE_VRAM_CLEARED && bo->tbo.mem.placement & TTM_PL_FLAG_VRAM) { struct dma_fence *fence; diff --git a/drivers/gpu/drm/ast/ast_ttm.c b/drivers/gpu/drm/ast/ast_ttm.c index fe354eb..aabb96a 100644 --- a/drivers/gpu/drm/ast/ast_ttm.c +++ b/drivers/gpu/drm/ast/ast_ttm.c @@ -320,7 +320,7 @@ int ast_bo_create(struct drm_device *dev, int size, int align, sizeof(struct ast_bo)); ret = ttm_bo_init(&ast->ttm.bdev, &astbo->bo, size, - ttm_bo_type_device, &astbo->placement, + ttm_bo_type_device, 0, &astbo->placement, align >> PAGE_SHIFT, false, acc_size, NULL, NULL, ast_bo_ttm_destroy); if (ret) diff --git a/drivers/gpu/drm/bochs/bochs_mm.c b/drivers/gpu/drm/bochs/bochs_mm.c index 39cd084..9693109 100644 --- a/drivers/gpu/drm/bochs/bochs_mm.c +++ b/drivers/gpu/drm/bochs/bochs_mm.c @@ -366,7 +366,7 @@ static int bochs_bo_create(struct drm_device *dev, int size, int align, sizeof(struct bochs_bo)); ret = ttm_bo_init(&boc
Re: [PATCH] drm/ttm: specify bo priority when initializing ttm bo
On 2018年05月11日 10:19, Zhang, Jerry (Junwei) wrote: On 05/11/2018 10:11 AM, zhoucm1 wrote: On 2018年05月11日 09:21, Zhang, Jerry (Junwei) wrote: On 05/10/2018 10:40 PM, Christian König wrote: Am 10.05.2018 um 07:01 schrieb Junwei Zhang: Expect to add an evitable bo who has reservation object to the correct lru[bo->priority] list Nice catch, but since this affects only a very small use case can we just remove and readd the BO to the LRU? A call to ttm_bo_move_to_lru_tail() after setting the priority should be sufficient. Yeah, at that moment, I thought setting a priority for tbo at initialization is a general way, which may help all associated modules to get out of potential pain if more priorities are adopted. Agree. The most simple way is to move the bo back to expected lru after priority setting. Going to prepare a patch. No, there is more simpler way. see inline... (in this case, include amd-gfx mail only) Regards, Jerry Thanks, Christian. Signed-off-by: Junwei Zhang --- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 11 ++- drivers/gpu/drm/ast/ast_ttm.c | 2 +- drivers/gpu/drm/bochs/bochs_mm.c | 2 +- drivers/gpu/drm/cirrus/cirrus_ttm.c | 2 +- drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c | 2 +- drivers/gpu/drm/mgag200/mgag200_ttm.c | 2 +- drivers/gpu/drm/nouveau/nouveau_bo.c | 2 +- drivers/gpu/drm/qxl/qxl_object.c | 2 +- drivers/gpu/drm/radeon/radeon_object.c | 2 +- drivers/gpu/drm/ttm/ttm_bo.c | 8 +--- drivers/gpu/drm/virtio/virtgpu_object.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 2 +- drivers/staging/vboxvideo/vbox_ttm.c | 2 +- include/drm/ttm/ttm_bo_api.h | 5 - 14 files changed, 26 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index e62153a..9a25ecb 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -360,6 +360,7 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, }; struct amdgpu_bo *bo; unsigned long page_align, size = bp->size; + uint32_t prio = 0; size_t acc_size; int r; @@ -419,10 +420,13 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, bo->tbo.bdev = &adev->mman.bdev; amdgpu_ttm_placement_from_domain(bo, bp->domain); + if (bp->type == ttm_bo_type_kernel) + prio = 1; Why not just bo->tbo.priority = 1? In that case, you don't need to add more parameter to ttm_bo_init_reserved. In fact, this change is already in my per-vm-lru patch set. Do you mean specify 1 before ttm_bo_init_reserved()? ttm_bo_init_reserved() will overwrite it to 0 again inside. If it can set outside of ttm, you can remove that overwriting. tbo allocation is from kzalloc. Regards, David Zhou Jerry Regards, David Zhou r = ttm_bo_init_reserved(&adev->mman.bdev, &bo->tbo, size, bp->type, - &bo->placement, page_align, &ctx, acc_size, - NULL, bp->resv, &amdgpu_ttm_bo_destroy); + prio, &bo->placement, page_align, &ctx, + acc_size, NULL, bp->resv, + &amdgpu_ttm_bo_destroy); if (unlikely(r != 0)) return r; @@ -434,9 +438,6 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, else amdgpu_cs_report_moved_bytes(adev, ctx.bytes_moved, 0); - if (bp->type == ttm_bo_type_kernel) - bo->tbo.priority = 1; - if (bp->flags & AMDGPU_GEM_CREATE_VRAM_CLEARED && bo->tbo.mem.placement & TTM_PL_FLAG_VRAM) { struct dma_fence *fence; diff --git a/drivers/gpu/drm/ast/ast_ttm.c b/drivers/gpu/drm/ast/ast_ttm.c index fe354eb..aabb96a 100644 --- a/drivers/gpu/drm/ast/ast_ttm.c +++ b/drivers/gpu/drm/ast/ast_ttm.c @@ -320,7 +320,7 @@ int ast_bo_create(struct drm_device *dev, int size, int align, sizeof(struct ast_bo)); ret = ttm_bo_init(&ast->ttm.bdev, &astbo->bo, size, - ttm_bo_type_device, &astbo->placement, + ttm_bo_type_device, 0, &astbo->placement, align >> PAGE_SHIFT, false, acc_size, NULL, NULL, ast_bo_ttm_destroy); if (ret) diff --git a/drivers/gpu/drm/bochs/bochs_mm.c b/drivers/gpu/drm/bochs/bochs_mm.c index 39cd084..9693109 100644 --- a/drivers/gpu/drm/bochs/bochs_mm.c +++ b/drivers/gpu/drm/bochs/bochs_mm.c @@ -366,7 +366,7 @@ static int bochs_bo_create(struct drm_device *dev, int size, int align, sizeof(struct bochs_bo)); ret = ttm_bo_init(&bochs->ttm.bdev, &bochsbo->bo, size, - ttm_bo_type_device, &bochsbo->placement, + ttm_bo_type_device, 0, &bochsbo->placement, align >> PAGE_SHIFT, false, acc_size, NULL, NULL, bochs_bo_ttm_destroy); if (ret) diff --git a/drive
Re: [PATCH] drm/ttm: specify bo priority when initializing ttm bo
On 05/11/2018 10:11 AM, zhoucm1 wrote: On 2018年05月11日 09:21, Zhang, Jerry (Junwei) wrote: On 05/10/2018 10:40 PM, Christian König wrote: Am 10.05.2018 um 07:01 schrieb Junwei Zhang: Expect to add an evitable bo who has reservation object to the correct lru[bo->priority] list Nice catch, but since this affects only a very small use case can we just remove and readd the BO to the LRU? A call to ttm_bo_move_to_lru_tail() after setting the priority should be sufficient. Yeah, at that moment, I thought setting a priority for tbo at initialization is a general way, which may help all associated modules to get out of potential pain if more priorities are adopted. Agree. The most simple way is to move the bo back to expected lru after priority setting. Going to prepare a patch. No, there is more simpler way. see inline... (in this case, include amd-gfx mail only) Regards, Jerry Thanks, Christian. Signed-off-by: Junwei Zhang --- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 11 ++- drivers/gpu/drm/ast/ast_ttm.c | 2 +- drivers/gpu/drm/bochs/bochs_mm.c| 2 +- drivers/gpu/drm/cirrus/cirrus_ttm.c | 2 +- drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c | 2 +- drivers/gpu/drm/mgag200/mgag200_ttm.c | 2 +- drivers/gpu/drm/nouveau/nouveau_bo.c| 2 +- drivers/gpu/drm/qxl/qxl_object.c| 2 +- drivers/gpu/drm/radeon/radeon_object.c | 2 +- drivers/gpu/drm/ttm/ttm_bo.c| 8 +--- drivers/gpu/drm/virtio/virtgpu_object.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_resource.c| 2 +- drivers/staging/vboxvideo/vbox_ttm.c| 2 +- include/drm/ttm/ttm_bo_api.h| 5 - 14 files changed, 26 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index e62153a..9a25ecb 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -360,6 +360,7 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, }; struct amdgpu_bo *bo; unsigned long page_align, size = bp->size; +uint32_t prio = 0; size_t acc_size; int r; @@ -419,10 +420,13 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, bo->tbo.bdev = &adev->mman.bdev; amdgpu_ttm_placement_from_domain(bo, bp->domain); +if (bp->type == ttm_bo_type_kernel) +prio = 1; Why not just bo->tbo.priority = 1? In that case, you don't need to add more parameter to ttm_bo_init_reserved. In fact, this change is already in my per-vm-lru patch set. Do you mean specify 1 before ttm_bo_init_reserved()? ttm_bo_init_reserved() will overwrite it to 0 again inside. Jerry Regards, David Zhou r = ttm_bo_init_reserved(&adev->mman.bdev, &bo->tbo, size, bp->type, - &bo->placement, page_align, &ctx, acc_size, - NULL, bp->resv, &amdgpu_ttm_bo_destroy); + prio, &bo->placement, page_align, &ctx, + acc_size, NULL, bp->resv, + &amdgpu_ttm_bo_destroy); if (unlikely(r != 0)) return r; @@ -434,9 +438,6 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, else amdgpu_cs_report_moved_bytes(adev, ctx.bytes_moved, 0); -if (bp->type == ttm_bo_type_kernel) -bo->tbo.priority = 1; - if (bp->flags & AMDGPU_GEM_CREATE_VRAM_CLEARED && bo->tbo.mem.placement & TTM_PL_FLAG_VRAM) { struct dma_fence *fence; diff --git a/drivers/gpu/drm/ast/ast_ttm.c b/drivers/gpu/drm/ast/ast_ttm.c index fe354eb..aabb96a 100644 --- a/drivers/gpu/drm/ast/ast_ttm.c +++ b/drivers/gpu/drm/ast/ast_ttm.c @@ -320,7 +320,7 @@ int ast_bo_create(struct drm_device *dev, int size, int align, sizeof(struct ast_bo)); ret = ttm_bo_init(&ast->ttm.bdev, &astbo->bo, size, - ttm_bo_type_device, &astbo->placement, + ttm_bo_type_device, 0, &astbo->placement, align >> PAGE_SHIFT, false, acc_size, NULL, NULL, ast_bo_ttm_destroy); if (ret) diff --git a/drivers/gpu/drm/bochs/bochs_mm.c b/drivers/gpu/drm/bochs/bochs_mm.c index 39cd084..9693109 100644 --- a/drivers/gpu/drm/bochs/bochs_mm.c +++ b/drivers/gpu/drm/bochs/bochs_mm.c @@ -366,7 +366,7 @@ static int bochs_bo_create(struct drm_device *dev, int size, int align, sizeof(struct bochs_bo)); ret = ttm_bo_init(&bochs->ttm.bdev, &bochsbo->bo, size, - ttm_bo_type_device, &bochsbo->placement, + ttm_bo_type_device, 0, &bochsbo->placement, align >> PAGE_SHIFT, false, acc_size, NULL, NULL, bochs_bo_ttm_destroy); if (ret) diff --git a/drivers/gpu/drm/cirrus/cirrus_ttm.c b/drivers/gpu/drm/cirrus/cirrus_ttm.c index f219532..c1d85f8 100644 --- a/drivers/gpu/drm/cirrus/cirrus_ttm.c +++ b/drivers/gpu/drm/cirrus/cirrus_ttm.c @@ -327,7 +3
Re: [PATCH] drm/ttm: specify bo priority when initializing ttm bo
On 2018年05月11日 09:21, Zhang, Jerry (Junwei) wrote: On 05/10/2018 10:40 PM, Christian König wrote: Am 10.05.2018 um 07:01 schrieb Junwei Zhang: Expect to add an evitable bo who has reservation object to the correct lru[bo->priority] list Nice catch, but since this affects only a very small use case can we just remove and readd the BO to the LRU? A call to ttm_bo_move_to_lru_tail() after setting the priority should be sufficient. Yeah, at that moment, I thought setting a priority for tbo at initialization is a general way, which may help all associated modules to get out of potential pain if more priorities are adopted. Agree. The most simple way is to move the bo back to expected lru after priority setting. Going to prepare a patch. No, there is more simpler way. see inline... (in this case, include amd-gfx mail only) Regards, Jerry Thanks, Christian. Signed-off-by: Junwei Zhang --- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 11 ++- drivers/gpu/drm/ast/ast_ttm.c | 2 +- drivers/gpu/drm/bochs/bochs_mm.c | 2 +- drivers/gpu/drm/cirrus/cirrus_ttm.c | 2 +- drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c | 2 +- drivers/gpu/drm/mgag200/mgag200_ttm.c | 2 +- drivers/gpu/drm/nouveau/nouveau_bo.c | 2 +- drivers/gpu/drm/qxl/qxl_object.c | 2 +- drivers/gpu/drm/radeon/radeon_object.c | 2 +- drivers/gpu/drm/ttm/ttm_bo.c | 8 +--- drivers/gpu/drm/virtio/virtgpu_object.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 2 +- drivers/staging/vboxvideo/vbox_ttm.c | 2 +- include/drm/ttm/ttm_bo_api.h | 5 - 14 files changed, 26 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index e62153a..9a25ecb 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -360,6 +360,7 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, }; struct amdgpu_bo *bo; unsigned long page_align, size = bp->size; + uint32_t prio = 0; size_t acc_size; int r; @@ -419,10 +420,13 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, bo->tbo.bdev = &adev->mman.bdev; amdgpu_ttm_placement_from_domain(bo, bp->domain); + if (bp->type == ttm_bo_type_kernel) + prio = 1; Why not just bo->tbo.priority = 1? In that case, you don't need to add more parameter to ttm_bo_init_reserved. In fact, this change is already in my per-vm-lru patch set. Regards, David Zhou r = ttm_bo_init_reserved(&adev->mman.bdev, &bo->tbo, size, bp->type, - &bo->placement, page_align, &ctx, acc_size, - NULL, bp->resv, &amdgpu_ttm_bo_destroy); + prio, &bo->placement, page_align, &ctx, + acc_size, NULL, bp->resv, + &amdgpu_ttm_bo_destroy); if (unlikely(r != 0)) return r; @@ -434,9 +438,6 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, else amdgpu_cs_report_moved_bytes(adev, ctx.bytes_moved, 0); - if (bp->type == ttm_bo_type_kernel) - bo->tbo.priority = 1; - if (bp->flags & AMDGPU_GEM_CREATE_VRAM_CLEARED && bo->tbo.mem.placement & TTM_PL_FLAG_VRAM) { struct dma_fence *fence; diff --git a/drivers/gpu/drm/ast/ast_ttm.c b/drivers/gpu/drm/ast/ast_ttm.c index fe354eb..aabb96a 100644 --- a/drivers/gpu/drm/ast/ast_ttm.c +++ b/drivers/gpu/drm/ast/ast_ttm.c @@ -320,7 +320,7 @@ int ast_bo_create(struct drm_device *dev, int size, int align, sizeof(struct ast_bo)); ret = ttm_bo_init(&ast->ttm.bdev, &astbo->bo, size, - ttm_bo_type_device, &astbo->placement, + ttm_bo_type_device, 0, &astbo->placement, align >> PAGE_SHIFT, false, acc_size, NULL, NULL, ast_bo_ttm_destroy); if (ret) diff --git a/drivers/gpu/drm/bochs/bochs_mm.c b/drivers/gpu/drm/bochs/bochs_mm.c index 39cd084..9693109 100644 --- a/drivers/gpu/drm/bochs/bochs_mm.c +++ b/drivers/gpu/drm/bochs/bochs_mm.c @@ -366,7 +366,7 @@ static int bochs_bo_create(struct drm_device *dev, int size, int align, sizeof(struct bochs_bo)); ret = ttm_bo_init(&bochs->ttm.bdev, &bochsbo->bo, size, - ttm_bo_type_device, &bochsbo->placement, + ttm_bo_type_device, 0, &bochsbo->placement, align >> PAGE_SHIFT, false, acc_size, NULL, NULL, bochs_bo_ttm_destroy); if (ret) diff --git a/drivers/gpu/drm/cirrus/cirrus_ttm.c b/drivers/gpu/drm/cirrus/cirrus_ttm.c index f219532..c1d85f8 100644 --- a/drivers/gpu/drm/cirrus/cirrus_ttm.c +++ b/drivers/gpu/drm/cirrus/cirrus_ttm.c @@ -327,7 +327,7 @@ int cirrus_bo_create(struct drm_device *dev, int size, int align, sizeof(struct cirrus_bo)); ret = ttm
Re: [PATCH] drm/ttm: specify bo priority when initializing ttm bo
On 05/10/2018 10:40 PM, Christian König wrote: Am 10.05.2018 um 07:01 schrieb Junwei Zhang: Expect to add an evitable bo who has reservation object to the correct lru[bo->priority] list Nice catch, but since this affects only a very small use case can we just remove and readd the BO to the LRU? A call to ttm_bo_move_to_lru_tail() after setting the priority should be sufficient. Yeah, at that moment, I thought setting a priority for tbo at initialization is a general way, which may help all associated modules to get out of potential pain if more priorities are adopted. Agree. The most simple way is to move the bo back to expected lru after priority setting. Going to prepare a patch. (in this case, include amd-gfx mail only) Regards, Jerry Thanks, Christian. Signed-off-by: Junwei Zhang --- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 11 ++- drivers/gpu/drm/ast/ast_ttm.c | 2 +- drivers/gpu/drm/bochs/bochs_mm.c| 2 +- drivers/gpu/drm/cirrus/cirrus_ttm.c | 2 +- drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c | 2 +- drivers/gpu/drm/mgag200/mgag200_ttm.c | 2 +- drivers/gpu/drm/nouveau/nouveau_bo.c| 2 +- drivers/gpu/drm/qxl/qxl_object.c| 2 +- drivers/gpu/drm/radeon/radeon_object.c | 2 +- drivers/gpu/drm/ttm/ttm_bo.c| 8 +--- drivers/gpu/drm/virtio/virtgpu_object.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_resource.c| 2 +- drivers/staging/vboxvideo/vbox_ttm.c| 2 +- include/drm/ttm/ttm_bo_api.h| 5 - 14 files changed, 26 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index e62153a..9a25ecb 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -360,6 +360,7 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, }; struct amdgpu_bo *bo; unsigned long page_align, size = bp->size; +uint32_t prio = 0; size_t acc_size; int r; @@ -419,10 +420,13 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, bo->tbo.bdev = &adev->mman.bdev; amdgpu_ttm_placement_from_domain(bo, bp->domain); +if (bp->type == ttm_bo_type_kernel) +prio = 1; r = ttm_bo_init_reserved(&adev->mman.bdev, &bo->tbo, size, bp->type, - &bo->placement, page_align, &ctx, acc_size, - NULL, bp->resv, &amdgpu_ttm_bo_destroy); + prio, &bo->placement, page_align, &ctx, + acc_size, NULL, bp->resv, + &amdgpu_ttm_bo_destroy); if (unlikely(r != 0)) return r; @@ -434,9 +438,6 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, else amdgpu_cs_report_moved_bytes(adev, ctx.bytes_moved, 0); -if (bp->type == ttm_bo_type_kernel) -bo->tbo.priority = 1; - if (bp->flags & AMDGPU_GEM_CREATE_VRAM_CLEARED && bo->tbo.mem.placement & TTM_PL_FLAG_VRAM) { struct dma_fence *fence; diff --git a/drivers/gpu/drm/ast/ast_ttm.c b/drivers/gpu/drm/ast/ast_ttm.c index fe354eb..aabb96a 100644 --- a/drivers/gpu/drm/ast/ast_ttm.c +++ b/drivers/gpu/drm/ast/ast_ttm.c @@ -320,7 +320,7 @@ int ast_bo_create(struct drm_device *dev, int size, int align, sizeof(struct ast_bo)); ret = ttm_bo_init(&ast->ttm.bdev, &astbo->bo, size, - ttm_bo_type_device, &astbo->placement, + ttm_bo_type_device, 0, &astbo->placement, align >> PAGE_SHIFT, false, acc_size, NULL, NULL, ast_bo_ttm_destroy); if (ret) diff --git a/drivers/gpu/drm/bochs/bochs_mm.c b/drivers/gpu/drm/bochs/bochs_mm.c index 39cd084..9693109 100644 --- a/drivers/gpu/drm/bochs/bochs_mm.c +++ b/drivers/gpu/drm/bochs/bochs_mm.c @@ -366,7 +366,7 @@ static int bochs_bo_create(struct drm_device *dev, int size, int align, sizeof(struct bochs_bo)); ret = ttm_bo_init(&bochs->ttm.bdev, &bochsbo->bo, size, - ttm_bo_type_device, &bochsbo->placement, + ttm_bo_type_device, 0, &bochsbo->placement, align >> PAGE_SHIFT, false, acc_size, NULL, NULL, bochs_bo_ttm_destroy); if (ret) diff --git a/drivers/gpu/drm/cirrus/cirrus_ttm.c b/drivers/gpu/drm/cirrus/cirrus_ttm.c index f219532..c1d85f8 100644 --- a/drivers/gpu/drm/cirrus/cirrus_ttm.c +++ b/drivers/gpu/drm/cirrus/cirrus_ttm.c @@ -327,7 +327,7 @@ int cirrus_bo_create(struct drm_device *dev, int size, int align, sizeof(struct cirrus_bo)); ret = ttm_bo_init(&cirrus->ttm.bdev, &cirrusbo->bo, size, - ttm_bo_type_device, &cirrusbo->placement, + ttm_bo_type_device, 0, &cirrusbo->placement, align >> PAGE_SHIFT, false, acc_size, NULL, NULL, cirrus_bo_ttm_destroy); if (ret) diff --git a/drivers/gpu/drm/
Re: [PATCH] drm/ttm: specify bo priority when initializing ttm bo
Am 10.05.2018 um 07:01 schrieb Junwei Zhang: Expect to add an evitable bo who has reservation object to the correct lru[bo->priority] list Nice catch, but since this affects only a very small use case can we just remove and readd the BO to the LRU? A call to ttm_bo_move_to_lru_tail() after setting the priority should be sufficient. Thanks, Christian. Signed-off-by: Junwei Zhang --- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 11 ++- drivers/gpu/drm/ast/ast_ttm.c | 2 +- drivers/gpu/drm/bochs/bochs_mm.c| 2 +- drivers/gpu/drm/cirrus/cirrus_ttm.c | 2 +- drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c | 2 +- drivers/gpu/drm/mgag200/mgag200_ttm.c | 2 +- drivers/gpu/drm/nouveau/nouveau_bo.c| 2 +- drivers/gpu/drm/qxl/qxl_object.c| 2 +- drivers/gpu/drm/radeon/radeon_object.c | 2 +- drivers/gpu/drm/ttm/ttm_bo.c| 8 +--- drivers/gpu/drm/virtio/virtgpu_object.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_resource.c| 2 +- drivers/staging/vboxvideo/vbox_ttm.c| 2 +- include/drm/ttm/ttm_bo_api.h| 5 - 14 files changed, 26 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index e62153a..9a25ecb 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -360,6 +360,7 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, }; struct amdgpu_bo *bo; unsigned long page_align, size = bp->size; + uint32_t prio = 0; size_t acc_size; int r; @@ -419,10 +420,13 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, bo->tbo.bdev = &adev->mman.bdev; amdgpu_ttm_placement_from_domain(bo, bp->domain); + if (bp->type == ttm_bo_type_kernel) + prio = 1; r = ttm_bo_init_reserved(&adev->mman.bdev, &bo->tbo, size, bp->type, -&bo->placement, page_align, &ctx, acc_size, -NULL, bp->resv, &amdgpu_ttm_bo_destroy); +prio, &bo->placement, page_align, &ctx, +acc_size, NULL, bp->resv, +&amdgpu_ttm_bo_destroy); if (unlikely(r != 0)) return r; @@ -434,9 +438,6 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, else amdgpu_cs_report_moved_bytes(adev, ctx.bytes_moved, 0); - if (bp->type == ttm_bo_type_kernel) - bo->tbo.priority = 1; - if (bp->flags & AMDGPU_GEM_CREATE_VRAM_CLEARED && bo->tbo.mem.placement & TTM_PL_FLAG_VRAM) { struct dma_fence *fence; diff --git a/drivers/gpu/drm/ast/ast_ttm.c b/drivers/gpu/drm/ast/ast_ttm.c index fe354eb..aabb96a 100644 --- a/drivers/gpu/drm/ast/ast_ttm.c +++ b/drivers/gpu/drm/ast/ast_ttm.c @@ -320,7 +320,7 @@ int ast_bo_create(struct drm_device *dev, int size, int align, sizeof(struct ast_bo)); ret = ttm_bo_init(&ast->ttm.bdev, &astbo->bo, size, - ttm_bo_type_device, &astbo->placement, + ttm_bo_type_device, 0, &astbo->placement, align >> PAGE_SHIFT, false, acc_size, NULL, NULL, ast_bo_ttm_destroy); if (ret) diff --git a/drivers/gpu/drm/bochs/bochs_mm.c b/drivers/gpu/drm/bochs/bochs_mm.c index 39cd084..9693109 100644 --- a/drivers/gpu/drm/bochs/bochs_mm.c +++ b/drivers/gpu/drm/bochs/bochs_mm.c @@ -366,7 +366,7 @@ static int bochs_bo_create(struct drm_device *dev, int size, int align, sizeof(struct bochs_bo)); ret = ttm_bo_init(&bochs->ttm.bdev, &bochsbo->bo, size, - ttm_bo_type_device, &bochsbo->placement, + ttm_bo_type_device, 0, &bochsbo->placement, align >> PAGE_SHIFT, false, acc_size, NULL, NULL, bochs_bo_ttm_destroy); if (ret) diff --git a/drivers/gpu/drm/cirrus/cirrus_ttm.c b/drivers/gpu/drm/cirrus/cirrus_ttm.c index f219532..c1d85f8 100644 --- a/drivers/gpu/drm/cirrus/cirrus_ttm.c +++ b/drivers/gpu/drm/cirrus/cirrus_ttm.c @@ -327,7 +327,7 @@ int cirrus_bo_create(struct drm_device *dev, int size, int align, sizeof(struct cirrus_bo)); ret = ttm_bo_init(&cirrus->ttm.bdev, &cirrusbo->bo, size, - ttm_bo_type_device, &cirrusbo->placement, + ttm_bo_type_device, 0, &cirrusbo->placement, align >> PAGE_SHIFT, false, acc_size, NULL, NULL, cirrus_bo_ttm_destroy); if (ret) diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c index 4871025..8c24731
[PATCH] drm/ttm: specify bo priority when initializing ttm bo
Expect to add an evitable bo who has reservation object to the correct lru[bo->priority] list Signed-off-by: Junwei Zhang --- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 11 ++- drivers/gpu/drm/ast/ast_ttm.c | 2 +- drivers/gpu/drm/bochs/bochs_mm.c| 2 +- drivers/gpu/drm/cirrus/cirrus_ttm.c | 2 +- drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c | 2 +- drivers/gpu/drm/mgag200/mgag200_ttm.c | 2 +- drivers/gpu/drm/nouveau/nouveau_bo.c| 2 +- drivers/gpu/drm/qxl/qxl_object.c| 2 +- drivers/gpu/drm/radeon/radeon_object.c | 2 +- drivers/gpu/drm/ttm/ttm_bo.c| 8 +--- drivers/gpu/drm/virtio/virtgpu_object.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_resource.c| 2 +- drivers/staging/vboxvideo/vbox_ttm.c| 2 +- include/drm/ttm/ttm_bo_api.h| 5 - 14 files changed, 26 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index e62153a..9a25ecb 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -360,6 +360,7 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, }; struct amdgpu_bo *bo; unsigned long page_align, size = bp->size; + uint32_t prio = 0; size_t acc_size; int r; @@ -419,10 +420,13 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, bo->tbo.bdev = &adev->mman.bdev; amdgpu_ttm_placement_from_domain(bo, bp->domain); + if (bp->type == ttm_bo_type_kernel) + prio = 1; r = ttm_bo_init_reserved(&adev->mman.bdev, &bo->tbo, size, bp->type, -&bo->placement, page_align, &ctx, acc_size, -NULL, bp->resv, &amdgpu_ttm_bo_destroy); +prio, &bo->placement, page_align, &ctx, +acc_size, NULL, bp->resv, +&amdgpu_ttm_bo_destroy); if (unlikely(r != 0)) return r; @@ -434,9 +438,6 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, else amdgpu_cs_report_moved_bytes(adev, ctx.bytes_moved, 0); - if (bp->type == ttm_bo_type_kernel) - bo->tbo.priority = 1; - if (bp->flags & AMDGPU_GEM_CREATE_VRAM_CLEARED && bo->tbo.mem.placement & TTM_PL_FLAG_VRAM) { struct dma_fence *fence; diff --git a/drivers/gpu/drm/ast/ast_ttm.c b/drivers/gpu/drm/ast/ast_ttm.c index fe354eb..aabb96a 100644 --- a/drivers/gpu/drm/ast/ast_ttm.c +++ b/drivers/gpu/drm/ast/ast_ttm.c @@ -320,7 +320,7 @@ int ast_bo_create(struct drm_device *dev, int size, int align, sizeof(struct ast_bo)); ret = ttm_bo_init(&ast->ttm.bdev, &astbo->bo, size, - ttm_bo_type_device, &astbo->placement, + ttm_bo_type_device, 0, &astbo->placement, align >> PAGE_SHIFT, false, acc_size, NULL, NULL, ast_bo_ttm_destroy); if (ret) diff --git a/drivers/gpu/drm/bochs/bochs_mm.c b/drivers/gpu/drm/bochs/bochs_mm.c index 39cd084..9693109 100644 --- a/drivers/gpu/drm/bochs/bochs_mm.c +++ b/drivers/gpu/drm/bochs/bochs_mm.c @@ -366,7 +366,7 @@ static int bochs_bo_create(struct drm_device *dev, int size, int align, sizeof(struct bochs_bo)); ret = ttm_bo_init(&bochs->ttm.bdev, &bochsbo->bo, size, - ttm_bo_type_device, &bochsbo->placement, + ttm_bo_type_device, 0, &bochsbo->placement, align >> PAGE_SHIFT, false, acc_size, NULL, NULL, bochs_bo_ttm_destroy); if (ret) diff --git a/drivers/gpu/drm/cirrus/cirrus_ttm.c b/drivers/gpu/drm/cirrus/cirrus_ttm.c index f219532..c1d85f8 100644 --- a/drivers/gpu/drm/cirrus/cirrus_ttm.c +++ b/drivers/gpu/drm/cirrus/cirrus_ttm.c @@ -327,7 +327,7 @@ int cirrus_bo_create(struct drm_device *dev, int size, int align, sizeof(struct cirrus_bo)); ret = ttm_bo_init(&cirrus->ttm.bdev, &cirrusbo->bo, size, - ttm_bo_type_device, &cirrusbo->placement, + ttm_bo_type_device, 0, &cirrusbo->placement, align >> PAGE_SHIFT, false, acc_size, NULL, NULL, cirrus_bo_ttm_destroy); if (ret) diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c index 4871025..8c24731 100644 --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c @@ -315,7 +315,7 @@ int hibmc_bo_create(struct drm_device *dev, int size, int align, sizeof(struct hibmc_bo)); r