diff mbox series

[RFC,2/2] drm/ttm: skip swapout when ttm has no backend page.

Message ID 20210519022852.16766-2-xinhui.pan@amd.com (mailing list archive)
State New, archived
Headers show
Series [RFC,1/2] drm/amdgpu: Fix memory corruption due to swapout and swapin | expand

Commit Message

Pan, Xinhui May 19, 2021, 2:28 a.m. UTC
Signed-off-by: xinhui pan <xinhui.pan@amd.com>
---
 drivers/gpu/drm/ttm/ttm_device.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Christian König May 20, 2021, 11 a.m. UTC | #1
Am 19.05.21 um 04:28 schrieb xinhui pan:
> Signed-off-by: xinhui pan <xinhui.pan@amd.com>
> ---
>   drivers/gpu/drm/ttm/ttm_device.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_device.c b/drivers/gpu/drm/ttm/ttm_device.c
> index 510e3e001dab..a9772fcc8f9c 100644
> --- a/drivers/gpu/drm/ttm/ttm_device.c
> +++ b/drivers/gpu/drm/ttm/ttm_device.c
> @@ -146,6 +146,7 @@ int ttm_device_swapout(struct ttm_device *bdev, struct ttm_operation_ctx *ctx,
>   				uint32_t num_pages;
>   
>   				if (!bo->ttm ||
> +				    !bo->ttm->pages || !bo->ttm->pages[0] ||

This should call ttm_tt_is_populated() instead.

But apart from that it sounds like the right approach to fix this.

Thanks,
Christian.

>   				    bo->ttm->page_flags & TTM_PAGE_FLAG_SG ||
>   				    bo->ttm->page_flags & TTM_PAGE_FLAG_SWAPPED)
>   					continue;
diff mbox series

Patch

diff --git a/drivers/gpu/drm/ttm/ttm_device.c b/drivers/gpu/drm/ttm/ttm_device.c
index 510e3e001dab..a9772fcc8f9c 100644
--- a/drivers/gpu/drm/ttm/ttm_device.c
+++ b/drivers/gpu/drm/ttm/ttm_device.c
@@ -146,6 +146,7 @@  int ttm_device_swapout(struct ttm_device *bdev, struct ttm_operation_ctx *ctx,
 				uint32_t num_pages;
 
 				if (!bo->ttm ||
+				    !bo->ttm->pages || !bo->ttm->pages[0] ||
 				    bo->ttm->page_flags & TTM_PAGE_FLAG_SG ||
 				    bo->ttm->page_flags & TTM_PAGE_FLAG_SWAPPED)
 					continue;