Skip to contentSkip to conversation

drm/amd/pm: fix is_dpm_running() run error on 32bit system

PATCH Superseded Kevin 2 participants 3 messages Aug 24, 2020

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Kevin

author
#0 lore raw

PATCH 1/1 drm/amd/pm: fix is_dpm_running() run error on 32bit system

From: Kevin Wang <[email protected]>

the C type "unsigned long" size is 32bit on 32bit system, it will cause code logic error, so replace it with "uint64_t".

---
 drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c       | 9 +++++++--
 drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c         | 9 +++++++--
 drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c | 9 +++++++--
 3 files changed, 21 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c +7 -2
index 8347b1f2509f..e619315b0f5c 100644
@@ -1844,10 +1844,15 @@ static bool arcturus_is_dpm_running(struct smu_context *smu)
 {
 	int ret = 0;
 	uint32_t feature_mask[2];
-	unsigned long feature_enabled;
+	uint64_t feature_enabled;
+
 	ret = smu_cmn_get_enabled_mask(smu, feature_mask, 2);
-	feature_enabled = (unsigned long)((uint64_t)feature_mask[0] |
+	if (ret)
+		return false;
+
+	feature_enabled = (uint64_t)((uint64_t)feature_mask[0] |
 			   ((uint64_t)feature_mask[1] << 32));
+
 	return !!(feature_enabled & SMC_DPM_FEATURE);
 }
 
drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c +7 -2
index 72f3d68691d8..d95b370adaf4 100644
@@ -1345,10 +1345,15 @@ static bool navi10_is_dpm_running(struct smu_context *smu)
 {
 	int ret = 0;
 	uint32_t feature_mask[2];
-	unsigned long feature_enabled;
+	uint64_t feature_enabled;
+
 	ret = smu_cmn_get_enabled_mask(smu, feature_mask, 2);
-	feature_enabled = (unsigned long)((uint64_t)feature_mask[0] |
+	if (ret)
+		return false;
+
+	feature_enabled = (uint64_t)((uint64_t)feature_mask[0] |
 			   ((uint64_t)feature_mask[1] << 32));
+
 	return !!(feature_enabled & SMC_DPM_FEATURE);
 }
 
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +7 -2
index 66d655958a78..f8df6448ab4d 100644
@@ -1150,10 +1150,15 @@ static bool sienna_cichlid_is_dpm_running(struct smu_context *smu)
 {
 	int ret = 0;
 	uint32_t feature_mask[2];
-	unsigned long feature_enabled;
+	uint64_t feature_enabled;
+
 	ret = smu_cmn_get_enabled_mask(smu, feature_mask, 2);
-	feature_enabled = (unsigned long)((uint64_t)feature_mask[0] |
+	if (ret)
+		return false;
+
+	feature_enabled = (uint64_t)((uint64_t)feature_mask[0] |
 			   ((uint64_t)feature_mask[1] << 32));
+
 	return !!(feature_enabled & SMC_DPM_FEATURE);
 }
 
Signature · 6 lines
2.27.0

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

[AMD Official Use Only - Internal Distribution Only]

Good point, but I wonder whether the outmost uint64_t cast is necessary?

Regards,
Jiansong
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Kevin
Sent: Monday, August 24, 2020 4:59 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Huang, Ray <[email protected]>; Wang, Kevin(Yang) <[email protected]>
Subject: [PATCH] drm/amd/pm: fix is_dpm_running() run error on 32bit system

From: Kevin Wang <[email protected]>

the C type "unsigned long" size is 32bit on 32bit system, it will cause code logic error, so replace it with "uint64_t".

---
 drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c       | 9 +++++++--
 drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c         | 9 +++++++--
 drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c | 9 +++++++--
 3 files changed, 21 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c +7 -2
index 8347b1f2509f..e619315b0f5c 100644
@@ -1844,10 +1844,15 @@ static bool arcturus_is_dpm_running(struct smu_context *smu)  {
 int ret = 0;
 uint32_t feature_mask[2];
-unsigned long feature_enabled;
+uint64_t feature_enabled;
+
 ret = smu_cmn_get_enabled_mask(smu, feature_mask, 2);
-feature_enabled = (unsigned long)((uint64_t)feature_mask[0] |
+if (ret)
+return false;
+
+feature_enabled = (uint64_t)((uint64_t)feature_mask[0] |
    ((uint64_t)feature_mask[1] << 32));
+
 return !!(feature_enabled & SMC_DPM_FEATURE);  }
 
drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c +7 -2
index 72f3d68691d8..d95b370adaf4 100644
@@ -1345,10 +1345,15 @@ static bool navi10_is_dpm_running(struct smu_context *smu)  {
 int ret = 0;
 uint32_t feature_mask[2];
-unsigned long feature_enabled;
+uint64_t feature_enabled;
+
 ret = smu_cmn_get_enabled_mask(smu, feature_mask, 2);
-feature_enabled = (unsigned long)((uint64_t)feature_mask[0] |
+if (ret)
+return false;
+
+feature_enabled = (uint64_t)((uint64_t)feature_mask[0] |
    ((uint64_t)feature_mask[1] << 32));
+
 return !!(feature_enabled & SMC_DPM_FEATURE);  }
 
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +7 -3
index 66d655958a78..f8df6448ab4d 100644
@@ -1150,10 +1150,15 @@ static bool sienna_cichlid_is_dpm_running(struct smu_context *smu)  {
 int ret = 0;
 uint32_t feature_mask[2];
-unsigned long feature_enabled;
+uint64_t feature_enabled;
+
 ret = smu_cmn_get_enabled_mask(smu, feature_mask, 2);
-feature_enabled = (unsigned long)((uint64_t)feature_mask[0] |
+if (ret)
+return false;
+
+feature_enabled = (uint64_t)((uint64_t)feature_mask[0] |
    ((uint64_t)feature_mask[1] << 32));
+
 return !!(feature_enabled & SMC_DPM_FEATURE);  }
 
--

2.27.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=02%7C01%7CJiansong.Chen%40amd.com%7Cffe808387ca14e51bab408d8480bc717%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637338562729795065&amp;sdata=U2xw6nM06S0Am3TFYfyLhCHob2k3UH%2BYgMX1hYFKKHE%3D&amp;reserved=0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#2 lore raw

[AMD Official Use Only - Internal Distribution Only]

Indeed, that's not necessary.
thanks.

Best Regards,
Kevin

________________________________
From: Chen, Jiansong (Simon) <[email protected]>
Sent: Monday, August 24, 2020 7:59 PM
To: Wang, Kevin(Yang) <[email protected]>; [email protected] <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Huang, Ray <[email protected]>; Wang, Kevin(Yang) <[email protected]>
Subject: RE: [PATCH] drm/amd/pm: fix is_dpm_running() run error on 32bit system

[AMD Official Use Only - Internal Distribution Only]

Good point, but I wonder whether the outmost uint64_t cast is necessary?

Regards,
Jiansong
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Kevin
Sent: Monday, August 24, 2020 4:59 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Huang, Ray <[email protected]>; Wang, Kevin(Yang) <[email protected]>
Subject: [PATCH] drm/amd/pm: fix is_dpm_running() run error on 32bit system

From: Kevin Wang <[email protected]>

the C type "unsigned long" size is 32bit on 32bit system, it will cause code logic error, so replace it with "uint64_t".

---
 drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c       | 9 +++++++--
 drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c         | 9 +++++++--
 drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c | 9 +++++++--
 3 files changed, 21 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c +7 -2
index 8347b1f2509f..e619315b0f5c 100644
@@ -1844,10 +1844,15 @@ static bool arcturus_is_dpm_running(struct smu_context *smu)  {
 int ret = 0;
 uint32_t feature_mask[2];
-unsigned long feature_enabled;
+uint64_t feature_enabled;
+
 ret = smu_cmn_get_enabled_mask(smu, feature_mask, 2);
-feature_enabled = (unsigned long)((uint64_t)feature_mask[0] |
+if (ret)
+return false;
+
+feature_enabled = (uint64_t)((uint64_t)feature_mask[0] |
    ((uint64_t)feature_mask[1] << 32));
+
 return !!(feature_enabled & SMC_DPM_FEATURE);  }
 
drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c +7 -2
index 72f3d68691d8..d95b370adaf4 100644
@@ -1345,10 +1345,15 @@ static bool navi10_is_dpm_running(struct smu_context *smu)  {
 int ret = 0;
 uint32_t feature_mask[2];
-unsigned long feature_enabled;
+uint64_t feature_enabled;
+
 ret = smu_cmn_get_enabled_mask(smu, feature_mask, 2);
-feature_enabled = (unsigned long)((uint64_t)feature_mask[0] |
+if (ret)
+return false;
+
+feature_enabled = (uint64_t)((uint64_t)feature_mask[0] |
    ((uint64_t)feature_mask[1] << 32));
+
 return !!(feature_enabled & SMC_DPM_FEATURE);  }
 
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +7 -3
index 66d655958a78..f8df6448ab4d 100644
@@ -1150,10 +1150,15 @@ static bool sienna_cichlid_is_dpm_running(struct smu_context *smu)  {
 int ret = 0;
 uint32_t feature_mask[2];
-unsigned long feature_enabled;
+uint64_t feature_enabled;
+
 ret = smu_cmn_get_enabled_mask(smu, feature_mask, 2);
-feature_enabled = (unsigned long)((uint64_t)feature_mask[0] |
+if (ret)
+return false;
+
+feature_enabled = (uint64_t)((uint64_t)feature_mask[0] |
    ((uint64_t)feature_mask[1] << 32));
+
 return !!(feature_enabled & SMC_DPM_FEATURE);  }
 
--

2.27.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=02%7C01%7CJiansong.Chen%40amd.com%7Cffe808387ca14e51bab408d8480bc717%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637338562729795065&amp;sdata=U2xw6nM06S0Am3TFYfyLhCHob2k3UH%2BYgMX1hYFKKHE%3D&amp;reserved=0

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