Skip to contentSkip to conversation

drm/amdgpu/pm: Account for extra separator characters in sysfs interface

PATCH Applied Matt Coffin 3 participants 3 messages Sep 3, 2020 – Sep 15, 2020

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

PATCH 1/1 drm/amdgpu/pm: Account for extra separator characters in sysfs interface

Currently, the the input to the pp_od_clk_voltage sysfs interface has two adjacent separator characters, i.e. "\n\0", then we try to parse an argument out of the empty string, whereas we really should just ignore this case, and treat any number of adjacent separators as one separator for arguments.

We do this here by simply skipping the argument parsing for all empy-string arguments.

An example test case would be echo 's 1 900' > pp_od_clk_voltage (note the two spaces after the 's'.

This also solves the issue where the written string ends with both a newline, and a nul-terminator, '\n\0', as is the case for echo 's 1 900' > pp_od_clk_voltage since the recent rebase.

---
 drivers/gpu/drm/amd/pm/amdgpu_pm.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +2 -0
index 65f141c777c2..9ab29c21e458 100644
@@ -801,6 +801,8 @@ static ssize_t amdgpu_set_pp_od_clk_voltage(struct device *dev,
 	while (isspace(*++tmp_str));
 
 	while ((sub_str = strsep(&tmp_str, delimiter)) != NULL) {
+		if (strlen(sub_str) == 0)
+			continue;
 		ret = kstrtol(sub_str, 0, &parameter[parameter_size]);
 		if (ret)
 			return -EINVAL;
Signature · 6 lines
2.28.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]

Thanks. Reviewed-by: Evan Quan <[email protected]>

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Matt Coffin
Sent: Friday, September 4, 2020 5:06 AM
To: [email protected]
Cc: Matt Coffin <[email protected]>
Subject: [PATCH] drm/amdgpu/pm: Account for extra separator characters in sysfs interface

Currently, the the input to the pp_od_clk_voltage sysfs interface has two adjacent separator characters, i.e. "\n\0", then we try to parse an argument out of the empty string, whereas we really should just ignore this case, and treat any number of adjacent separators as one separator for arguments.

We do this here by simply skipping the argument parsing for all empy-string arguments.

An example test case would be echo 's 1 900' > pp_od_clk_voltage (note the two spaces after the 's'.

This also solves the issue where the written string ends with both a newline, and a nul-terminator, '\n\0', as is the case for echo 's 1 900' > pp_od_clk_voltage since the recent rebase.

---
 drivers/gpu/drm/amd/pm/amdgpu_pm.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +2 -0
index 65f141c777c2..9ab29c21e458 100644
@@ -801,6 +801,8 @@ static ssize_t amdgpu_set_pp_od_clk_voltage(struct device *dev,
 while (isspace(*++tmp_str));
 
 while ((sub_str = strsep(&tmp_str, delimiter)) != NULL) {
+if (strlen(sub_str) == 0)
+continue;
 ret = kstrtol(sub_str, 0, &parameter[parameter_size]);
 if (ret)
 return -EINVAL;

--
2.28.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%7Cevan.quan%40amd.com%7Cee0ba53db6a34135168908d8504d3f67%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637347640051630594&amp;sdata=MPjsHvjwbERjeLSsQHWymlnqav1O9XlF8DJoGvJpx%2BM%3D&amp;reserved=0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Applied
#2 lore raw

Applied. Thanks!

Alex

Quoted 49 lines · Evan

[AMD Official Use Only - Internal Distribution Only]

Thanks. Reviewed-by: Evan Quan <[email protected]>

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Matt Coffin
Sent: Friday, September 4, 2020 5:06 AM
To: [email protected]
Cc: Matt Coffin <[email protected]>
Subject: [PATCH] drm/amdgpu/pm: Account for extra separator characters in sysfs interface

Currently, the the input to the pp_od_clk_voltage sysfs interface has two adjacent separator characters, i.e. "\n\0", then we try to parse an argument out of the empty string, whereas we really should just ignore this case, and treat any number of adjacent separators as one separator for arguments.

We do this here by simply skipping the argument parsing for all empy-string arguments.

An example test case would be echo 's 1 900' > pp_od_clk_voltage (note the two spaces after the 's'.

This also solves the issue where the written string ends with both a newline, and a nul-terminator, '\n\0', as is the case for echo 's 1 900' > pp_od_clk_voltage since the recent rebase.

---
 drivers/gpu/drm/amd/pm/amdgpu_pm.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +2 -1
index 65f141c777c2..9ab29c21e458 100644
@@ -801,6 +801,8 @@ static ssize_t amdgpu_set_pp_od_clk_voltage(struct device *dev,
 while (isspace(*++tmp_str));
 
 while ((sub_str = strsep(&tmp_str, delimiter)) != NULL) {
+if (strlen(sub_str) == 0)
+continue;
 ret = kstrtol(sub_str, 0, &parameter[parameter_size]);
 if (ret)
 return -EINVAL;
--

2.28.0

Quoted 8 lines

_______________________________________________
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%7Cevan.quan%40amd.com%7Cee0ba53db6a34135168908d8504d3f67%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637347640051630594&amp;sdata=MPjsHvjwbERjeLSsQHWymlnqav1O9XlF8DJoGvJpx%2BM%3D&amp;reserved=0
_______________________________________________
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