AMD-GFX Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 1/3] drm/amdgpu: make sure we unpin the UVD BO
@ 2021-04-15  8:47 Christian König
  2021-04-15  8:47 ` [PATCH 2/3] drm/amdgpu: freeing pinned objects is illegal now Christian König
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Christian König @ 2021-04-15  8:47 UTC (permalink / raw)
  To: dri-devel, amd-gfx; +Cc: daniel

Releasing pinned BOs is illegal now.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
index 7cd67cb2ac5f..1a2bf2ca1be5 100644
--- a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
@@ -363,6 +363,7 @@ static int uvd_v7_0_enc_ring_test_ib(struct amdgpu_ring *ring, long timeout)
 
 error:
 	dma_fence_put(fence);
+	amdgpu_bo_unpin(bo);
 	amdgpu_bo_unreserve(bo);
 	amdgpu_bo_unref(&bo);
 	return r;
-- 
2.25.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/3] drm/amdgpu: freeing pinned objects is illegal now
  2021-04-15  8:47 [PATCH 1/3] drm/amdgpu: make sure we unpin the UVD BO Christian König
@ 2021-04-15  8:47 ` Christian König
  2021-04-15  8:47 ` [PATCH 3/3] drm/ttm: warn stricter about freeing pinned BOs Christian König
  2021-04-16 12:54 ` [PATCH 1/3] drm/amdgpu: make sure we unpin the UVD BO Christian König
  2 siblings, 0 replies; 5+ messages in thread
From: Christian König @ 2021-04-15  8:47 UTC (permalink / raw)
  To: dri-devel, amd-gfx; +Cc: daniel

We want to drop support in TTM for this.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 36 ++++++----------------
 1 file changed, 10 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 984dcf5a475e..aee8b7b8c154 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -52,35 +52,11 @@
  *
  */
 
-/**
- * amdgpu_bo_subtract_pin_size - Remove BO from pin_size accounting
- *
- * @bo: &amdgpu_bo buffer object
- *
- * This function is called when a BO stops being pinned, and updates the
- * &amdgpu_device pin_size values accordingly.
- */
-static void amdgpu_bo_subtract_pin_size(struct amdgpu_bo *bo)
-{
-	struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
-
-	if (bo->tbo.mem.mem_type == TTM_PL_VRAM) {
-		atomic64_sub(amdgpu_bo_size(bo), &adev->vram_pin_size);
-		atomic64_sub(amdgpu_vram_mgr_bo_visible_size(bo),
-			     &adev->visible_pin_size);
-	} else if (bo->tbo.mem.mem_type == TTM_PL_TT) {
-		atomic64_sub(amdgpu_bo_size(bo), &adev->gart_pin_size);
-	}
-}
-
 static void amdgpu_bo_destroy(struct ttm_buffer_object *tbo)
 {
 	struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev);
 	struct amdgpu_bo *bo = ttm_to_amdgpu_bo(tbo);
 
-	if (bo->tbo.pin_count > 0)
-		amdgpu_bo_subtract_pin_size(bo);
-
 	amdgpu_bo_kunmap(bo);
 
 	if (bo->tbo.base.import_attach)
@@ -1000,14 +976,22 @@ int amdgpu_bo_pin(struct amdgpu_bo *bo, u32 domain)
  */
 void amdgpu_bo_unpin(struct amdgpu_bo *bo)
 {
+	struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
+
 	ttm_bo_unpin(&bo->tbo);
 	if (bo->tbo.pin_count)
 		return;
 
-	amdgpu_bo_subtract_pin_size(bo);
-
 	if (bo->tbo.base.import_attach)
 		dma_buf_unpin(bo->tbo.base.import_attach);
+
+	if (bo->tbo.mem.mem_type == TTM_PL_VRAM) {
+		atomic64_sub(amdgpu_bo_size(bo), &adev->vram_pin_size);
+		atomic64_sub(amdgpu_vram_mgr_bo_visible_size(bo),
+			     &adev->visible_pin_size);
+	} else if (bo->tbo.mem.mem_type == TTM_PL_TT) {
+		atomic64_sub(amdgpu_bo_size(bo), &adev->gart_pin_size);
+	}
 }
 
 /**
-- 
2.25.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 3/3] drm/ttm: warn stricter about freeing pinned BOs
  2021-04-15  8:47 [PATCH 1/3] drm/amdgpu: make sure we unpin the UVD BO Christian König
  2021-04-15  8:47 ` [PATCH 2/3] drm/amdgpu: freeing pinned objects is illegal now Christian König
@ 2021-04-15  8:47 ` Christian König
  2021-04-16 12:54 ` [PATCH 1/3] drm/amdgpu: make sure we unpin the UVD BO Christian König
  2 siblings, 0 replies; 5+ messages in thread
From: Christian König @ 2021-04-15  8:47 UTC (permalink / raw)
  To: dri-devel, amd-gfx; +Cc: daniel

So far we only warned when the BOs where pinned and not idle.

Also warn if we see a pinned BO in general.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/ttm/ttm_bo.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index cfd0b9292397..80831df0ef61 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -401,6 +401,8 @@ static void ttm_bo_release(struct kref *kref)
 	struct ttm_device *bdev = bo->bdev;
 	int ret;
 
+	WARN_ON_ONCE(bo->pin_count);
+
 	if (!bo->deleted) {
 		ret = ttm_bo_individualize_resv(bo);
 		if (ret) {
@@ -434,7 +436,7 @@ static void ttm_bo_release(struct kref *kref)
 		 * FIXME: QXL is triggering this. Can be removed when the
 		 * driver is fixed.
 		 */
-		if (WARN_ON_ONCE(bo->pin_count)) {
+		if (bo->pin_count) {
 			bo->pin_count = 0;
 			ttm_bo_move_to_lru_tail(bo, &bo->mem, NULL);
 		}
-- 
2.25.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/3] drm/amdgpu: make sure we unpin the UVD BO
  2021-04-15  8:47 [PATCH 1/3] drm/amdgpu: make sure we unpin the UVD BO Christian König
  2021-04-15  8:47 ` [PATCH 2/3] drm/amdgpu: freeing pinned objects is illegal now Christian König
  2021-04-15  8:47 ` [PATCH 3/3] drm/ttm: warn stricter about freeing pinned BOs Christian König
@ 2021-04-16 12:54 ` Christian König
  2021-04-16 14:35   ` Leo Liu
  2 siblings, 1 reply; 5+ messages in thread
From: Christian König @ 2021-04-16 12:54 UTC (permalink / raw)
  To: dri-devel, amd-gfx; +Cc: daniel

Ping?

Am 15.04.21 um 10:47 schrieb Christian König:
> Releasing pinned BOs is illegal now.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
> index 7cd67cb2ac5f..1a2bf2ca1be5 100644
> --- a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
> @@ -363,6 +363,7 @@ static int uvd_v7_0_enc_ring_test_ib(struct amdgpu_ring *ring, long timeout)
>   
>   error:
>   	dma_fence_put(fence);
> +	amdgpu_bo_unpin(bo);
>   	amdgpu_bo_unreserve(bo);
>   	amdgpu_bo_unref(&bo);
>   	return r;

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/3] drm/amdgpu: make sure we unpin the UVD BO
  2021-04-16 12:54 ` [PATCH 1/3] drm/amdgpu: make sure we unpin the UVD BO Christian König
@ 2021-04-16 14:35   ` Leo Liu
  0 siblings, 0 replies; 5+ messages in thread
From: Leo Liu @ 2021-04-16 14:35 UTC (permalink / raw)
  To: Christian König, dri-devel, amd-gfx; +Cc: daniel

Acked-by: Leo Liu <leo.liu@amd.com>

On 2021-04-16 8:54 a.m., Christian König wrote:
> Ping?
>
> Am 15.04.21 um 10:47 schrieb Christian König:
>> Releasing pinned BOs is illegal now.
>>
>> Signed-off-by: Christian König <christian.koenig@amd.com>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c 
>> b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
>> index 7cd67cb2ac5f..1a2bf2ca1be5 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
>> @@ -363,6 +363,7 @@ static int uvd_v7_0_enc_ring_test_ib(struct 
>> amdgpu_ring *ring, long timeout)
>>     error:
>>       dma_fence_put(fence);
>> +    amdgpu_bo_unpin(bo);
>>       amdgpu_bo_unreserve(bo);
>>       amdgpu_bo_unref(&bo);
>>       return r;
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=04%7C01%7Cleo.liu%40amd.com%7C5823d278fae848e2292008d900d6bd76%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637541744618109453%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=TIn5u5%2FPS50wcKCd6%2FwTnpPm%2BgCPa8KOT1cz6r7Xgl0%3D&amp;reserved=0 
>
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-15  8:47 [PATCH 1/3] drm/amdgpu: make sure we unpin the UVD BO Christian König
2021-04-15  8:47 ` [PATCH 2/3] drm/amdgpu: freeing pinned objects is illegal now Christian König
2021-04-15  8:47 ` [PATCH 3/3] drm/ttm: warn stricter about freeing pinned BOs Christian König
2021-04-16 12:54 ` [PATCH 1/3] drm/amdgpu: make sure we unpin the UVD BO Christian König
2021-04-16 14:35   ` Leo Liu

AMD-GFX Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/amd-gfx/0 amd-gfx/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 amd-gfx amd-gfx/ https://lore.kernel.org/amd-gfx \
		amd-gfx@lists.freedesktop.org
	public-inbox-index amd-gfx

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.freedesktop.lists.amd-gfx


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git