* [PATCH] drm/amdgpu: Set TTM_PAGE_FLAG_SG earlier for userprt BOs
@ 2021-06-16 8:36 xinhui pan
2021-06-16 8:45 ` Christian König
0 siblings, 1 reply; 2+ messages in thread
From: xinhui pan @ 2021-06-16 8:36 UTC (permalink / raw)
To: amd-gfx; +Cc: alexander.deucher, Felix.Kuehling, xinhui pan, christian.koenig
Because TTM do page counting on userptr BOs which is actually not
needed. To avoid that, lets set TTM_PAGE_FLAG_SG after tt_create and
before tt_populate.
Signed-off-by: xinhui pan <xinhui.pan@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 0887942b4622..97c83164ce38 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -1147,8 +1147,6 @@ static int amdgpu_ttm_tt_populate(struct ttm_device *bdev,
ttm->sg = kzalloc(sizeof(struct sg_table), GFP_KERNEL);
if (!ttm->sg)
return -ENOMEM;
-
- ttm->page_flags |= TTM_PAGE_FLAG_SG;
return 0;
}
@@ -1174,7 +1172,6 @@ static void amdgpu_ttm_tt_unpopulate(struct ttm_device *bdev,
amdgpu_ttm_tt_set_user_pages(ttm, NULL);
kfree(ttm->sg);
ttm->sg = NULL;
- ttm->page_flags &= ~TTM_PAGE_FLAG_SG;
return;
}
@@ -1208,6 +1205,9 @@ int amdgpu_ttm_tt_set_userptr(struct ttm_buffer_object *bo,
return -ENOMEM;
}
+ /* Set TTM_PAGE_FLAG_SG before populate but after create. */
+ bo->ttm->page_flags |= TTM_PAGE_FLAG_SG;
+
gtt = (void *)bo->ttm;
gtt->userptr = addr;
gtt->userflags = flags;
--
2.25.1
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] drm/amdgpu: Set TTM_PAGE_FLAG_SG earlier for userprt BOs
2021-06-16 8:36 [PATCH] drm/amdgpu: Set TTM_PAGE_FLAG_SG earlier for userprt BOs xinhui pan
@ 2021-06-16 8:45 ` Christian König
0 siblings, 0 replies; 2+ messages in thread
From: Christian König @ 2021-06-16 8:45 UTC (permalink / raw)
To: xinhui pan, amd-gfx; +Cc: alexander.deucher, Felix.Kuehling, christian.koenig
Am 16.06.21 um 10:36 schrieb xinhui pan:
> Because TTM do page counting on userptr BOs which is actually not
> needed. To avoid that, lets set TTM_PAGE_FLAG_SG after tt_create and
> before tt_populate.
>
> Signed-off-by: xinhui pan <xinhui.pan@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index 0887942b4622..97c83164ce38 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -1147,8 +1147,6 @@ static int amdgpu_ttm_tt_populate(struct ttm_device *bdev,
> ttm->sg = kzalloc(sizeof(struct sg_table), GFP_KERNEL);
> if (!ttm->sg)
> return -ENOMEM;
> -
> - ttm->page_flags |= TTM_PAGE_FLAG_SG;
> return 0;
> }
>
> @@ -1174,7 +1172,6 @@ static void amdgpu_ttm_tt_unpopulate(struct ttm_device *bdev,
> amdgpu_ttm_tt_set_user_pages(ttm, NULL);
> kfree(ttm->sg);
> ttm->sg = NULL;
> - ttm->page_flags &= ~TTM_PAGE_FLAG_SG;
> return;
> }
>
> @@ -1208,6 +1205,9 @@ int amdgpu_ttm_tt_set_userptr(struct ttm_buffer_object *bo,
> return -ENOMEM;
> }
>
> + /* Set TTM_PAGE_FLAG_SG before populate but after create. */
> + bo->ttm->page_flags |= TTM_PAGE_FLAG_SG;
> +
> gtt = (void *)bo->ttm;
> gtt->userptr = addr;
> gtt->userflags = flags;
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-06-16 8:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-16 8:36 [PATCH] drm/amdgpu: Set TTM_PAGE_FLAG_SG earlier for userprt BOs xinhui pan
2021-06-16 8:45 ` Christian König
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.