drm/ttm: fix error handling if no BO can be swapped out
Subsystems (3)
PATCH 1/1 drm/ttm: fix error handling if no BO can be swapped out
In case that all pre-allocated BOs are busy, just continue to populate BOs since likely half of system memory in total is still free.
--- drivers/gpu/drm/ttm/ttm_device.c | 4 ++-- drivers/gpu/drm/ttm/ttm_tt.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/ttm/ttm_device.c +2 -2
@@ -133,7 +133,7 @@ int ttm_device_swapout(struct ttm_device *bdev, struct ttm_operation_ctx *ctx,struct ttm_resource_manager *man;struct ttm_buffer_object *bo;unsigned i, j; -int ret; +int ret=-EBUSY ;spin_lock (&bdev->lru_lock);for (i =TTM_PL_SYSTEM ; i <TTM_NUM_MEM_TYPES ; ++i) {
@@ -161,7 +161,7 @@ int ttm_device_swapout(struct ttm_device *bdev, struct ttm_operation_ctx *ctx, } }spin_unlock (&bdev->lru_lock); -return 0 ; +return ret; }EXPORT_SYMBOL (ttm_device_swapout);
drivers/gpu/drm/ttm/ttm_tt.c +2 -0
@@ -329,6 +329,8 @@ int ttm_tt_populate(struct ttm_device *bdev, ttm_dma32_pages_limit) { ret =ttm_global_swapout (ctx,GFP_KERNEL ); +if (ret == -EBUSY ) +break ;if (ret <0 ) goto error; }
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Am 20.04.21 um 16:32 schrieb Shiwu Zhang:
Quoted 23 lines
In case that all pre-allocated BOs are busy, just continue to populate BOs since likely half of system memory in total is still free.
Signed-off-by Shiwu Zhang <[email protected]>--- drivers/gpu/drm/ttm/ttm_device.c | 4 ++-- drivers/gpu/drm/ttm/ttm_tt.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-)drivers/gpu/drm/ttm/ttm_device.c +1
-1@@ -133,7 +133,7 @@ int ttm_device_swapout(struct ttm_device *bdev, struct ttm_operation_ctx *ctx,struct ttm_resource_manager *man;struct ttm_buffer_object *bo;unsigned i, j; -int ret; +int ret=-EBUSY ;spin_lock (&bdev->lru_lock);for (i =TTM_PL_SYSTEM ; i <TTM_NUM_MEM_TYPES ; ++i) {
drivers/gpu/drm/ttm/ttm_device.c int ttm_device_swapout(struct ttm_device *bdev, struct ttm_operation_ctx *ctx, · line 164
Quoted 5 lines
drivers/gpu/drm/ttm/ttm_device.c +1
-1@@ -161,7 +161,7 @@ int ttm_device_swapout(struct ttm_device *bdev, struct ttm_operation_ctx *ctx, } }spin_unlock (&bdev->lru_lock); -return 0 ; +return ret;
The function should return the number of pages swapped out. Returning 0 here is already perfectly ok.
Quoted 8 lines
drivers/gpu/drm/ttm/ttm_device.c +0
-0}EXPORT_SYMBOL (ttm_device_swapout);drivers/gpu/drm/ttm/ttm_tt.c +0
-0
drivers/gpu/drm/ttm/ttm_tt.c int ttm_tt_populate(struct ttm_device *bdev, · line 335
Quoted 7 lines
drivers/gpu/drm/ttm/ttm_tt.c +2
-0@@ -329,6 +329,8 @@ int ttm_tt_populate(struct ttm_device *bdev, ttm_dma32_pages_limit) { ret =ttm_global_swapout (ctx,GFP_KERNEL ); +if (ret == -EBUSY ) +break ;if (ret <0 ) goto error;
Here we should just have a check for ret == 0 instead of testing for -EBUSY.
Regards,
Christian.
drivers/gpu/drm/ttm/ttm_tt.c int ttm_tt_populate(struct ttm_device *bdev, · line 336
Quoted 1 line
drivers/gpu/drm/ttm/ttm_tt.c +0
-0}
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
[AMD Official Use Only - Internal Distribution Only]
Hi Chris,
Yes. I'll rework the patch. Thanks for your comments.
--Brs,
Morris Zhang
MLSE Linux ML SRDC
Ext. 25147
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, April 21, 2021 9:34 PM
To: Zhang, Morris <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/ttm: fix error handling if no BO can be swapped out
Am 20.04.21 um 16:32 schrieb Shiwu Zhang:
Quoted 19 lines
In case that all pre-allocated BOs are busy, just continue to populate BOs since likely half of system memory in total is still free.
Signed-off-by Shiwu Zhang <[email protected]>--- drivers/gpu/drm/ttm/ttm_device.c | 4 ++-- drivers/gpu/drm/ttm/ttm_tt.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-)drivers/gpu/drm/ttm/ttm_device.c +0
-1@@ -133,7 +133,7 @@ int ttm_device_swapout(struct ttm_device *bdev, struct ttm_operation_ctx *ctx,struct ttm_resource_manager *man;struct ttm_buffer_object *bo;unsigned i, j; -int ret;
drivers/gpu/drm/ttm/ttm_device.c int ttm_device_swapout(struct ttm_device *bdev, struct ttm_operation_ctx *ctx,
Quoted 10 lines
drivers/gpu/drm/ttm/ttm_device.c +3
-1+int ret=-EBUSY ;spin_lock (&bdev->lru_lock); for (i = TTM_PL_SYSTEM; i < TTM_NUM_MEM_TYPES; ++i) { @@ -161,7 +161,7 @@ int ttm_device_swapout(struct ttm_device *bdev, struct ttm_operation_ctx *ctx, } }spin_unlock (&bdev->lru_lock); -return 0 ; +return ret;
The function should return the number of pages swapped out. Returning 0 here is already perfectly ok.
Quoted 8 lines
} EXPORT_SYMBOL(ttm_device_swapout);(quoted diff) +0
-0
b/drivers/gpu/drm/ttm/ttm_tt.cindex48c407cff112..4e1e06a04428100644
drivers/gpu/drm/ttm/ttm_tt.c int ttm_tt_populate(struct ttm_device *bdev, · line 335
Quoted 7 lines
drivers/gpu/drm/ttm/ttm_tt.c +2
-0@@ -329,6 +329,8 @@ int ttm_tt_populate(struct ttm_device *bdev, ttm_dma32_pages_limit) { ret =ttm_global_swapout (ctx,GFP_KERNEL ); +if (ret == -EBUSY ) +break ;if (ret <0 ) goto error;
Here we should just have a check for ret == 0 instead of testing for -EBUSY.
Regards,
Christian.
drivers/gpu/drm/ttm/ttm_tt.c int ttm_tt_populate(struct ttm_device *bdev, · line 336
Quoted 1 line
drivers/gpu/drm/ttm/ttm_tt.c +0
-0}
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel