Skip to contentSkip to conversation

drm/amdgpu: fix object unreserved issue

PATCH In review Monk Liu 3 participants 6 messages Mar 5, 2018 4 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Monk Liu

author
#0 lore raw

PATCH 1/4 drm/amdgpu: fix object unreserved issue

bo_do_create will unreserve in in the end if @resv is NULL, which cause the following bo_create_shadow run without lock held on @resv

Change-Id Iaad24b8aea60522f25188874ab9d5c5f13f1a941
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +6 -3
index 216799cc..d8a818d 100644
@@ -507,9 +507,12 @@ int amdgpu_bo_create(struct amdgpu_device *adev,
 		return r;
 
 	if ((flags & AMDGPU_GEM_CREATE_SHADOW) && amdgpu_need_backup(adev)) {
-		if (!resv)
-			WARN_ON(reservation_object_lock((*bo_ptr)->tbo.resv,
-							NULL));
+		if (!resv) {
+			WARN_ON(reservation_object_lock((*bo_ptr)->tbo.resv, NULL));
+			r = amdgpu_bo_reserve(*bo_ptr, kernel?true:false);
+			if (unlikely(r))
+				return r;
+		}
 
 		r = amdgpu_bo_create_shadow(adev, size, byte_align, (*bo_ptr));
 
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1520222976-18814-1-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org

author
#2 lore raw

PATCH 2/4 drm/amdgpu: remove useless variable

Change-Id Iec96c7762d791164c719ec64ec410e00a8cf5d90
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +1 -1
index 43ce2e5..42c1401 100644
@@ -141,7 +141,7 @@ uint32_t amdgpu_virt_kiq_rreg(struct amdgpu_device *adev, uint32_t reg)
 {
 	signed long r, cnt = 0;
 	unsigned long flags;
-	uint32_t val, seq;
+	uint32_t seq;
 	struct amdgpu_kiq *kiq = &adev->gfx.kiq;
 	struct amdgpu_ring *ring = &kiq->ring;
 
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1520222976-18814-2-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org

#4 lore raw

Re: [PATCH 2/4] drm/amdgpu: remove useless variable

Quoted 2 lines · Monk Liu
Change-Id Iec96c7762d791164c719ec64ec410e00a8cf5d90

Already fixed in amd-staging-drm-next.

Alex

Quoted 20 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +1 -2
index 43ce2e5..42c1401 100644
@@ -141,7 +141,7 @@ uint32_t amdgpu_virt_kiq_rreg(struct amdgpu_device *adev, uint32_t reg)
 {
        signed long r, cnt = 0;
        unsigned long flags;
-       uint32_t val, seq;
+       uint32_t seq;
        struct amdgpu_kiq *kiq = &adev->gfx.kiq;
        struct amdgpu_ring *ring = &kiq->ring;
 
--

2.7.4

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#5 lore raw
In reply to a message not in the archive
Quoted 15 lines · Monk Liu

bo_do_create will unreserve in in the end if @resv is NULL, which cause the following bo_create_shadow run without lock held on @resv

Change-Id Iaad24b8aea60522f25188874ab9d5c5f13f1a941
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 9 ++++++---
  1 file changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0 -0
index 216799cc..d8a818d 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c int amdgpu_bo_create(struct amdgpu_device *adev, · line 511

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +2 -3
@@ -507,9 +507,12 @@ int amdgpu_bo_create(struct amdgpu_device *adev,
  		return r;
 
  	if ((flags & AMDGPU_GEM_CREATE_SHADOW) && amdgpu_need_backup(adev)) {
-		if (!resv)
-			WARN_ON(reservation_object_lock((*bo_ptr)->tbo.resv,
-							NULL));
+		if (!resv) {
+			WARN_ON(reservation_object_lock((*bo_ptr)->tbo.resv, NULL));

isn't this locking resv?

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c int amdgpu_bo_create(struct amdgpu_device *adev, · line 512

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1 -0
+			r = amdgpu_bo_reserve(*bo_ptr, kernel?true:false);

I don't think this is need.

Regards,
David Zhou

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c int amdgpu_bo_create(struct amdgpu_device *adev, · line 518

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +3 -0
+			if (unlikely(r))
+				return r;
+		}
 
  		r = amdgpu_bo_create_shadow(adev, size, byte_align, (*bo_ptr));
 

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 8b077a9e-da17-39b4-8368-c98ee805f8f2-5C7GfCeVMHo@public.gmane.org

author
#7 lore raw

Please check amdgpu_do_bo_create() logic,

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of zhoucm1
Sent: 2018年3月5日 12:52
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH 1/4] drm/amdgpu: fix object unreserved issue

Quoted 15 lines · Monk Liu

bo_do_create will unreserve in in the end if @resv is NULL, which cause the following bo_create_shadow run without lock held on @resv

Change-Id Iaad24b8aea60522f25188874ab9d5c5f13f1a941
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 9 ++++++---
  1 file changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0 -0
index 216799cc..d8a818d 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c int amdgpu_bo_create(struct amdgpu_device *adev, · line 511

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +2 -3
@@ -507,9 +507,12 @@ int amdgpu_bo_create(struct amdgpu_device *adev,
  		return r;
 
  	if ((flags & AMDGPU_GEM_CREATE_SHADOW) && amdgpu_need_backup(adev)) {
-		if (!resv)
-			WARN_ON(reservation_object_lock((*bo_ptr)->tbo.resv,
-							NULL));
+		if (!resv) {
+			WARN_ON(reservation_object_lock((*bo_ptr)->tbo.resv, NULL));

isn't this locking resv?

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c int amdgpu_bo_create(struct amdgpu_device *adev, · line 512

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1 -0
+			r = amdgpu_bo_reserve(*bo_ptr, kernel?true:false);

I don't think this is need.

Regards,
David Zhou

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c int amdgpu_bo_create(struct amdgpu_device *adev, · line 518

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +3 -0
+			if (unlikely(r))
+				return r;
+		}
 
  		r = amdgpu_bo_create_shadow(adev, size, byte_align, (*bo_ptr));
 

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): BLUPR12MB044981CF01DA7983A3308ECB84DA0-7LeqcoF/[email protected]

author
#9 lore raw

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c int amdgpu_bo_create(struct amdgpu_device *adev, · line 511

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +2 -0
+		if (!resv) {
+			WARN_ON(reservation_object_lock((*bo_ptr)->tbo.resv, NULL));

isn't this locking resv?

[ML] oh yeah, this patch is not needed in staging, my branch is a little different, missed that part, thanks

/Monk

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Liu, Monk
Sent: 2018年3月5日 13:53
To: Zhou, David(ChunMing) <[email protected]>; [email protected]
Subject: RE: [PATCH 1/4] drm/amdgpu: fix object unreserved issue

Please check amdgpu_do_bo_create() logic,

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of zhoucm1
Sent: 2018年3月5日 12:52
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH 1/4] drm/amdgpu: fix object unreserved issue

Quoted 15 lines · Monk Liu

bo_do_create will unreserve in in the end if @resv is NULL, which cause the following bo_create_shadow run without lock held on @resv

Change-Id Iaad24b8aea60522f25188874ab9d5c5f13f1a941
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 9 ++++++---
  1 file changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0 -0
index 216799cc..d8a818d 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c int amdgpu_bo_create(struct amdgpu_device *adev, · line 511

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +2 -3
@@ -507,9 +507,12 @@ int amdgpu_bo_create(struct amdgpu_device *adev,
  		return r;
 
  	if ((flags & AMDGPU_GEM_CREATE_SHADOW) && amdgpu_need_backup(adev)) {
-		if (!resv)
-			WARN_ON(reservation_object_lock((*bo_ptr)->tbo.resv,
-							NULL));
+		if (!resv) {
+			WARN_ON(reservation_object_lock((*bo_ptr)->tbo.resv, NULL));

isn't this locking resv?

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c int amdgpu_bo_create(struct amdgpu_device *adev, · line 512

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1 -0
+			r = amdgpu_bo_reserve(*bo_ptr, kernel?true:false);

I don't think this is need.

Regards,
David Zhou

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c int amdgpu_bo_create(struct amdgpu_device *adev, · line 518

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +3 -0
+			if (unlikely(r))
+				return r;
+		}
 
  		r = amdgpu_bo_create_shadow(adev, size, byte_align, (*bo_ptr));
 

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx