Skip to contentSkip to conversation

amdgpu: Use unsigned HW IP/instance/ring indices in amdgpu_queue_mgr_map

PATCH In review Michel Dänzer 4 participants 6 messages Nov 21, 2017 – Nov 22, 2017 4 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 amdgpu: Use unsigned HW IP/instance/ring indices in amdgpu_queue_mgr_map

From: Michel Dänzer <[email protected]>

This matches the corresponding UAPI fields. Treating the ring index as signed could result in accessing random unrelated memory if the MSB was set.

Fixes effd924d2f3b ("drm/amdgpu: untie user ring ids from kernel ring
                      ids v6")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h           | 2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_queue_mgr.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -1
index 86f91789de6d..f8657c37ba9d 100644
@@ -722,7 +722,7 @@ int amdgpu_queue_mgr_fini(struct amdgpu_device *adev,
 			  struct amdgpu_queue_mgr *mgr);
 int amdgpu_queue_mgr_map(struct amdgpu_device *adev,
 			 struct amdgpu_queue_mgr *mgr,
-			 int hw_ip, int instance, int ring,
+			 u32 hw_ip, u32 instance, u32 ring,
 			 struct amdgpu_ring **out_ring);
 
 /*
drivers/gpu/drm/amd/amdgpu/amdgpu_queue_mgr.c +3 -3
index 190e28cb827e..93d86619e802 100644
@@ -63,7 +63,7 @@ static int amdgpu_update_cached_map(struct amdgpu_queue_mapper *mapper,
 
 static int amdgpu_identity_map(struct amdgpu_device *adev,
 			       struct amdgpu_queue_mapper *mapper,
-			       int ring,
+			       u32 ring,
 			       struct amdgpu_ring **out_ring)
 {
 	switch (mapper->hw_ip) {
@@ -121,7 +121,7 @@ static enum amdgpu_ring_type amdgpu_hw_ip_to_ring_type(int hw_ip)
 
 static int amdgpu_lru_map(struct amdgpu_device *adev,
 			  struct amdgpu_queue_mapper *mapper,
-			  int user_ring, bool lru_pipe_order,
+			  u32 user_ring, bool lru_pipe_order,
 			  struct amdgpu_ring **out_ring)
 {
 	int r, i, j;
@@ -208,7 +208,7 @@ int amdgpu_queue_mgr_fini(struct amdgpu_device *adev,
  */
 int amdgpu_queue_mgr_map(struct amdgpu_device *adev,
 			 struct amdgpu_queue_mgr *mgr,
-			 int hw_ip, int instance, int ring,
+			 u32 hw_ip, u32 instance, u32 ring,
 			 struct amdgpu_ring **out_ring)
 {
 	int r, ip_num_rings;
Signature · 6 lines
2.15.0

_______________________________________________
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): 20171121172940.8037-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org

Reviewed-by Alex Deucher
#2 lore raw
Quoted 11 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Michel Dänzer
Sent: Tuesday, November 21, 2017 12:30 PM
To: [email protected]
Cc: Andres Rodriguez
Subject: [PATCH] amdgpu: Use unsigned HW IP/instance/ring indices in amdgpu_queue_mgr_map

From: Michel Dänzer <[email protected]>

Quoted 8 lines

This matches the corresponding UAPI fields. Treating the ring index as signed could result in accessing random unrelated memory if the MSB was set.

Fixes effd924d2f3b ("drm/amdgpu: untie user ring ids from kernel ring
                      ids v6")
Quoted 58 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h           | 2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_queue_mgr.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -1
index 86f91789de6d..f8657c37ba9d 100644
@@ -722,7 +722,7 @@ int amdgpu_queue_mgr_fini(struct amdgpu_device
 *adev,
 			  struct amdgpu_queue_mgr *mgr);
 int amdgpu_queue_mgr_map(struct amdgpu_device *adev,
 			 struct amdgpu_queue_mgr *mgr,
-			 int hw_ip, int instance, int ring,
+			 u32 hw_ip, u32 instance, u32 ring,
 			 struct amdgpu_ring **out_ring);
 

/*

drivers/gpu/drm/amd/amdgpu/amdgpu_queue_mgr.c +1 -1
index 190e28cb827e..93d86619e802 100644
@@ -63,7 +63,7 @@ static int amdgpu_update_cached_map(struct
 amdgpu_queue_mapper *mapper,
 
 static int amdgpu_identity_map(struct amdgpu_device *adev,
 			       struct amdgpu_queue_mapper *mapper,
-			       int ring,
+			       u32 ring,
 			       struct amdgpu_ring **out_ring)
 {
drivers/gpu/drm/amd/amdgpu/amdgpu_queue_mgr.c +1 -1
 	switch (mapper->hw_ip) {
@@ -121,7 +121,7 @@ static enum amdgpu_ring_type
 amdgpu_hw_ip_to_ring_type(int hw_ip)
 
 static int amdgpu_lru_map(struct amdgpu_device *adev,
 			  struct amdgpu_queue_mapper *mapper,
-			  int user_ring, bool lru_pipe_order,
+			  u32 user_ring, bool lru_pipe_order,
 			  struct amdgpu_ring **out_ring)
 {
drivers/gpu/drm/amd/amdgpu/amdgpu_queue_mgr.c +1 -1
 	int r, i, j;
@@ -208,7 +208,7 @@ int amdgpu_queue_mgr_fini(struct amdgpu_device
 *adev,
  */
 int amdgpu_queue_mgr_map(struct amdgpu_device *adev,
 			 struct amdgpu_queue_mgr *mgr,
-			 int hw_ip, int instance, int ring,
+			 u32 hw_ip, u32 instance, u32 ring,
 			 struct amdgpu_ring **out_ring)
 {

int r, ip_num_rings;
--
2.15.0

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

#3 lore raw
In reply to a message not in the archive

Am 21.11.2017 um 18:29 schrieb Michel Dänzer:

Quoted 10 lines

From: Michel Dänzer <[email protected]>

This matches the corresponding UAPI fields. Treating the ring index as signed could result in accessing random unrelated memory if the MSB was set.

Fixes effd924d2f3b ("drm/amdgpu: untie user ring ids from kernel ring
                       ids v6")

Subject line is off, with that fixed Reviewed-by: Christian König <[email protected]>.

Quoted 41 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu.h           | 2 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_queue_mgr.c | 6 +++---
  2 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -1
index 86f91789de6d..f8657c37ba9d 100644
@@ -722,7 +722,7 @@ int amdgpu_queue_mgr_fini(struct amdgpu_device *adev,
  			  struct amdgpu_queue_mgr *mgr);
  int amdgpu_queue_mgr_map(struct amdgpu_device *adev,
  			 struct amdgpu_queue_mgr *mgr,
-			 int hw_ip, int instance, int ring,
+			 u32 hw_ip, u32 instance, u32 ring,
  			 struct amdgpu_ring **out_ring);
 
  /*
drivers/gpu/drm/amd/amdgpu/amdgpu_queue_mgr.c +2 -2
index 190e28cb827e..93d86619e802 100644
@@ -63,7 +63,7 @@ static int amdgpu_update_cached_map(struct amdgpu_queue_mapper *mapper,
 
  static int amdgpu_identity_map(struct amdgpu_device *adev,
  			       struct amdgpu_queue_mapper *mapper,
-			       int ring,
+			       u32 ring,
  			       struct amdgpu_ring **out_ring)
  {
  	switch (mapper->hw_ip) {
@@ -121,7 +121,7 @@ static enum amdgpu_ring_type amdgpu_hw_ip_to_ring_type(int hw_ip)
 
  static int amdgpu_lru_map(struct amdgpu_device *adev,
  			  struct amdgpu_queue_mapper *mapper,
-			  int user_ring, bool lru_pipe_order,
+			  u32 user_ring, bool lru_pipe_order,
  			  struct amdgpu_ring **out_ring)
  {
  	int r, i, j;

drivers/gpu/drm/amd/amdgpu/amdgpu_queue_mgr.c int amdgpu_queue_mgr_fini(struct amdgpu_device *adev, · line 214

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_queue_mgr.c +1 -1
@@ -208,7 +208,7 @@ int amdgpu_queue_mgr_fini(struct amdgpu_device *adev,
   */
  int amdgpu_queue_mgr_map(struct amdgpu_device *adev,
  			 struct amdgpu_queue_mgr *mgr,
-			 int hw_ip, int instance, int ring,
+			 u32 hw_ip, u32 instance, u32 ring,
  			 struct amdgpu_ring **out_ring)
  {
  	int r, ip_num_rings;

_______________________________________________
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): fa7f26cb-7a4b-059c-d570-f2e7e15abeac-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#5 lore raw
Quoted 7 lines · Christian König

Am 21.11.2017 um 18:29 schrieb Michel Dänzer:

Quoted 6 lines

From: Michel Dänzer <[email protected]>

This matches the corresponding UAPI fields. Treating the ring index as signed could result in accessing random unrelated memory if the MSB was set.

Quoted 6 lines
Quoted 4 lines
Fixes effd924d2f3b ("drm/amdgpu: untie user ring ids from kernel ring

                       ids v6")

Subject line is off, [...]

I assume you're referring to the prefix. Well, I'm actually trying to set a trend there. :) Since there's no other amdgpu driver, the drm/ is redundant. In the specific case of this patch, adding it would make the shortlog too long, and IME it's quite often the case that those four character cells could be put to better use than for the redundant prefix.

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
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): e46d1d6b-213f-7095-6f8d-216413017cd7-otUistvHUpPR7s880joybQ@public.gmane.org

#7 lore raw

Am 22.11.2017 um 09:42 schrieb Michel Dänzer:

Quoted 12 lines · Christian König
Quoted 11 lines

Am 21.11.2017 um 18:29 schrieb Michel Dänzer:

Quoted 10 lines

From: Michel Dänzer <[email protected]>

This matches the corresponding UAPI fields. Treating the ring index as signed could result in accessing random unrelated memory if the MSB was set.

Fixes effd924d2f3b ("drm/amdgpu: untie user ring ids from kernel ring

                       ids v6")

Quoted 6 lines
Quoted 1 line

Subject line is off, [...]

I assume you're referring to the prefix. Well, I'm actually trying to set a trend there. :) Since there's no other amdgpu driver, the drm/ is redundant. In the specific case of this patch, adding it would make the shortlog too long, and IME it's quite often the case that those four character cells could be put to better use than for the redundant prefix.

Yeah, making the prefix shorter is one thing I have thought about as well.

But currently we use "drm/amdgpu:" for the kernel and "amdgpu:" for libdrm and I actually would like to keep that.

Christian.
_______________________________________________
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): 38c529df-e25e-1a85-03da-ed2a48728b90-5C7GfCeVMHo@public.gmane.org

#9 lore raw
Quoted 20 lines · Christian König

Am 22.11.2017 um 09:42 schrieb Michel Dänzer:

Quoted 12 lines · Christian König
Quoted 11 lines

Am 21.11.2017 um 18:29 schrieb Michel Dänzer:

Quoted 10 lines

From: Michel Dänzer <[email protected]>

This matches the corresponding UAPI fields. Treating the ring index as signed could result in accessing random unrelated memory if the MSB was set.

Fixes effd924d2f3b ("drm/amdgpu: untie user ring ids from kernel ring

                        ids v6")

Quoted 6 lines
Quoted 1 line

Subject line is off, [...]

I assume you're referring to the prefix. Well, I'm actually trying to set a trend there. :) Since there's no other amdgpu driver, the drm/ is redundant. In the specific case of this patch, adding it would make the shortlog too long, and IME it's quite often the case that those four character cells could be put to better use than for the redundant prefix.

Quoted 4 lines

Yeah, making the prefix shorter is one thing I have thought about as well.

But currently we use "drm/amdgpu:" for the kernel and "amdgpu:" for libdrm and I actually would like to keep that.

libdrm patches should have [PATCH libdrm] .

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx