Skip to contentSkip to conversation

drm/amd/amdgpu: Remove static from variable in RLCG Reg RW.

PATCH In review Gavin Wan 3 participants 4 messages Apr 13, 2022 – Apr 14, 2022

Subsystems (2)
lore
Share & tools
lore

Gavin Wan

author
#0 lore raw

PATCH 1/1 drm/amd/amdgpu: Remove static from variable in RLCG Reg RW.

[why] These static variables saves the RLC Scratch registers address.
When we installed multiple GPUs (for example: XGMI setting) and multiple GPUs call the function at same time. The RLC Scratch registers address are changed each other. Then it caused reading/writing to wrong GPU.

[fix] Removed the static from the variables. The variables are
in stack.

Change-Id Iee78849291d4f7a9688ecc5165bec70ee85cdfbe
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +5 -5
index d5eea031c3e3..d18a05a20566 100644
@@ -868,11 +868,11 @@ static u32 amdgpu_virt_rlcg_reg_rw(struct amdgpu_device *adev, u32 offset, u32 v
 	uint32_t timeout = 50000;
 	uint32_t i, tmp;
 	uint32_t ret = 0;
-	static void *scratch_reg0;
-	static void *scratch_reg1;
-	static void *scratch_reg2;
-	static void *scratch_reg3;
-	static void *spare_int;
+	void *scratch_reg0;
+	void *scratch_reg1;
+	void *scratch_reg2;
+	void *scratch_reg3;
+	void *spare_int;
 
 	if (!adev->gfx.rlc.rlcg_reg_access_supported) {
 		dev_err(adev->dev,
Signature · 1 line
2.32.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Gavin Wan

[why] These static variables saves the RLC Scratch registers address.
When we installed multiple GPUs (for example: XGMI setting) and multiple GPUs call the function at same time. The RLC Scratch registers address are changed each other. Then it caused reading/writing to wrong GPU.

[fix] Removed the static from the variables. The variables are
in stack.

Please add:

Fixes 5d447e29670148 ("drm/amdgpu: add helper for rlcg indirect reg access")

With that added.

Quoted 31 lines
Change-Id Iee78849291d4f7a9688ecc5165bec70ee85cdfbe
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +5 -6
index d5eea031c3e3..d18a05a20566 100644
@@ -868,11 +868,11 @@ static u32 amdgpu_virt_rlcg_reg_rw(struct amdgpu_device *adev, u32 offset, u32 v
        uint32_t timeout = 50000;
        uint32_t i, tmp;
        uint32_t ret = 0;
-       static void *scratch_reg0;
-       static void *scratch_reg1;
-       static void *scratch_reg2;
-       static void *scratch_reg3;
-       static void *spare_int;
+       void *scratch_reg0;
+       void *scratch_reg1;
+       void *scratch_reg2;
+       void *scratch_reg3;
+       void *spare_int;
 
        if (!adev->gfx.rlc.rlcg_reg_access_supported) {
                dev_err(adev->dev,
--

2.32.0

#2 lore raw
In reply to Gavin Wan

Dear Gavin,

Thank you for your patch.

Am 13.04.22 um 17:26 schrieb Gavin Wan:

Should you re-roll your patch (v2), please remove the dot/period from the end of the git commit message summary (subject).

Quoted 1 line

[why] These static variables saves the RLC Scratch registers address.

s/saves/save/

Quoted 1 line

When we installed multiple GPUs (for example: XGMI setting) and

s/installed/install/

Quoted 1 line

multiple GPUs call the function at same time. The RLC Scratch

… same time, the RLC …

Quoted 1 line

registers address are changed each other. Then it caused

s/caused/causes/

Quoted 1 line

reading/writing to wrong GPU.

I see from other patches posted here, that [why] is put on a separate line, so you do not need to indent the text.

[why]

These static …

Quoted 3 lines

[fix] Removed the static from the variables. The variables are
in stack.

Same here, though *how* instead of *fix* seems more common.

s/Removed/Remove/
s/in stack/on the stack/

Quoted 3 lines
Change-Id Iee78849291d4f7a9688ecc5165bec70ee85cdfbe

Without the Gerrit URL that line is useless.

Kind regards.

Paul

Quoted 25 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 10 +++++-----
  1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +5 -5
index d5eea031c3e3..d18a05a20566 100644
@@ -868,11 +868,11 @@ static u32 amdgpu_virt_rlcg_reg_rw(struct amdgpu_device *adev, u32 offset, u32 v
  	uint32_t timeout = 50000;
  	uint32_t i, tmp;
  	uint32_t ret = 0;
-	static void *scratch_reg0;
-	static void *scratch_reg1;
-	static void *scratch_reg2;
-	static void *scratch_reg3;
-	static void *spare_int;
+	void *scratch_reg0;
+	void *scratch_reg1;
+	void *scratch_reg2;
+	void *scratch_reg3;
+	void *spare_int;
 
  	if (!adev->gfx.rlc.rlcg_reg_access_supported) {
  		dev_err(adev->dev,
author
#3 lore raw

[AMD Official Use Only]

Dear Paul,

Thanks for you comments. Let me do it.

Thanks,
Gavin

-----Original Message-----
From: Paul Menzel <[email protected]>
Sent: Thursday, April 14, 2022 1:59 PM
To: Wan, Gavin <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH] drm/amd/amdgpu: Remove static from variable in RLCG Reg RW.

Dear Gavin,

Thank you for your patch.

Am 13.04.22 um 17:26 schrieb Gavin Wan:

Should you re-roll your patch (v2), please remove the dot/period from the end of the git commit message summary (subject).

Quoted 1 line

[why] These static variables saves the RLC Scratch registers address.

s/saves/save/

Quoted 1 line

When we installed multiple GPUs (for example: XGMI setting) and

s/installed/install/

Quoted 1 line

multiple GPUs call the function at same time. The RLC Scratch

… same time, the RLC …

Quoted 1 line

registers address are changed each other. Then it caused

s/caused/causes/

Quoted 1 line

reading/writing to wrong GPU.

I see from other patches posted here, that [why] is put on a separate line, so you do not need to indent the text.

[why]

These static …

Quoted 3 lines

[fix] Removed the static from the variables. The variables are
in stack.

Same here, though *how* instead of *fix* seems more common.

s/Removed/Remove/
s/in stack/on the stack/

Quoted 3 lines
Change-Id Iee78849291d4f7a9688ecc5165bec70ee85cdfbe

Without the Gerrit URL that line is useless.

Kind regards.

Paul

Quoted 26 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 10 +++++-----
  1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +5 -5
index d5eea031c3e3..d18a05a20566 100644
@@ -868,11 +868,11 @@ static u32 amdgpu_virt_rlcg_reg_rw(struct amdgpu_device *adev, u32 offset, u32 v
      uint32_t timeout = 50000;
      uint32_t i, tmp;
      uint32_t ret = 0;
-     static void *scratch_reg0;
-     static void *scratch_reg1;
-     static void *scratch_reg2;
-     static void *scratch_reg3;
-     static void *spare_int;
+     void *scratch_reg0;
+     void *scratch_reg1;
+     void *scratch_reg2;
+     void *scratch_reg3;
+     void *spare_int;
 
      if (!adev->gfx.rlc.rlcg_reg_access_supported) {
              dev_err(adev->dev,