* [PATCH] drm/amd/pm: Prevent divide by zero
@ 2022-07-12 2:01 Yefim Barashkin
2022-07-12 3:51 ` Quan, Evan
2022-07-12 14:28 ` André Almeida
0 siblings, 2 replies; 8+ messages in thread
From: Yefim Barashkin @ 2022-07-12 2:01 UTC (permalink / raw)
To: amd-gfx; +Cc: Yefim Barashkin
divide error: 0000 [#1] SMP PTI
CPU: 3 PID: 78925 Comm: tee Not tainted 5.15.50-1-lts #1
Hardware name: MSI MS-7A59/Z270 SLI PLUS (MS-7A59), BIOS 1.90 01/30/2018
RIP: 0010:smu_v11_0_set_fan_speed_rpm+0x11/0x110 [amdgpu]
Speed is user-configurable through a file.
I accidentally set it to zero, and the driver crashed.
Signed-off-by: Yefim Barashkin <mr.b34r@kolabnow.com>
---
drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c b/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
index 5f8809f6990d..69cebdb58c04 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
@@ -1236,6 +1236,10 @@ int smu_v11_0_set_fan_speed_rpm(struct smu_context *smu,
* - For some Sienna Cichlid SKU, the fan speed cannot be set
* lower than 500 RPM.
*/
+
+ if (speed == 0)
+ return -EINVAL;
+
tach_period = 60 * crystal_clock_freq * 10000 / (8 * speed);
WREG32_SOC15(THM, 0, mmCG_TACH_CTRL,
REG_SET_FIELD(RREG32_SOC15(THM, 0, mmCG_TACH_CTRL),
--
2.36.1
Sorry about the mess with my name and formatting. It should be fixed now, hopefully.
^ permalink raw reply related [flat|nested] 8+ messages in thread
* RE: [PATCH] drm/amd/pm: Prevent divide by zero
2022-07-12 2:01 [PATCH] drm/amd/pm: Prevent divide by zero Yefim Barashkin
@ 2022-07-12 3:51 ` Quan, Evan
2022-07-12 14:28 ` André Almeida
1 sibling, 0 replies; 8+ messages in thread
From: Quan, Evan @ 2022-07-12 3:51 UTC (permalink / raw)
To: Yefim Barashkin, amd-gfx
[AMD Official Use Only - General]
Thanks for the fix! Patch is reviewed-by: Evan Quan <evan.quan@amd.com>
BR
Evan
> -----Original Message-----
> From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of
> Yefim Barashkin
> Sent: Tuesday, July 12, 2022 10:01 AM
> To: amd-gfx@lists.freedesktop.org
> Cc: Yefim Barashkin <mr.b34r@kolabnow.com>
> Subject: [PATCH] drm/amd/pm: Prevent divide by zero
>
> divide error: 0000 [#1] SMP PTI
> CPU: 3 PID: 78925 Comm: tee Not tainted 5.15.50-1-lts #1 Hardware name:
> MSI MS-7A59/Z270 SLI PLUS (MS-7A59), BIOS 1.90 01/30/2018
> RIP: 0010:smu_v11_0_set_fan_speed_rpm+0x11/0x110 [amdgpu]
>
> Speed is user-configurable through a file.
> I accidentally set it to zero, and the driver crashed.
>
> Signed-off-by: Yefim Barashkin <mr.b34r@kolabnow.com>
> ---
> drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
> b/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
> index 5f8809f6990d..69cebdb58c04 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
> +++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
> @@ -1236,6 +1236,10 @@ int smu_v11_0_set_fan_speed_rpm(struct
> smu_context *smu,
> * - For some Sienna Cichlid SKU, the fan speed cannot be set
> * lower than 500 RPM.
> */
> +
> + if (speed == 0)
> + return -EINVAL;
> +
> tach_period = 60 * crystal_clock_freq * 10000 / (8 * speed);
> WREG32_SOC15(THM, 0, mmCG_TACH_CTRL,
> REG_SET_FIELD(RREG32_SOC15(THM, 0,
> mmCG_TACH_CTRL),
> --
> 2.36.1
>
> Sorry about the mess with my name and formatting. It should be fixed now,
> hopefully.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] drm/amd/pm: Prevent divide by zero
2022-07-12 2:01 [PATCH] drm/amd/pm: Prevent divide by zero Yefim Barashkin
2022-07-12 3:51 ` Quan, Evan
@ 2022-07-12 14:28 ` André Almeida
1 sibling, 0 replies; 8+ messages in thread
From: André Almeida @ 2022-07-12 14:28 UTC (permalink / raw)
To: Yefim Barashkin; +Cc: Quan, Evan, amd-gfx
Às 23:01 de 11/07/22, Yefim Barashkin escreveu:
> divide error: 0000 [#1] SMP PTI
> CPU: 3 PID: 78925 Comm: tee Not tainted 5.15.50-1-lts #1
> Hardware name: MSI MS-7A59/Z270 SLI PLUS (MS-7A59), BIOS 1.90 01/30/2018
> RIP: 0010:smu_v11_0_set_fan_speed_rpm+0x11/0x110 [amdgpu]
>
> Speed is user-configurable through a file.
> I accidentally set it to zero, and the driver crashed.
>
> Signed-off-by: Yefim Barashkin <mr.b34r@kolabnow.com>
> ---
Reviewed-by: André Almeida <andrealmeid@igalia.com>
Minor nit, I would write this commit message like this:
Speed is user-configurable through a file. I accidentally set it to
zero, and the driver crashed:
divide error: 0000 [#1] SMP PTI
CPU: 3 PID: 78925 Comm: tee Not tainted 5.15.50-1-lts #1
Hardware name: MSI MS-7A59/Z270 SLI PLUS (MS-7A59), BIOS 1.90 01/30/2018
RIP: 0010:smu_v11_0_set_fan_speed_rpm+0x11/0x110 [amdgpu]
Fix that by checking user input value.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] drm/amd/pm: Prevent divide by zero
2022-07-11 22:35 ` Mr. B34r
@ 2022-07-12 15:27 ` Alex Deucher
0 siblings, 0 replies; 8+ messages in thread
From: Alex Deucher @ 2022-07-12 15:27 UTC (permalink / raw)
To: Mr. B34r; +Cc: Christian König, amd-gfx list
Applied. Thanks!
On Mon, Jul 11, 2022 at 9:06 PM Mr. B34r <mr.b34r@kolabnow.com> wrote:
>
> From: Yefim Barashkin <mr.b34r@kolabnow.com>
>
> divide error: 0000 [#1] SMP PTI
> CPU: 3 PID: 78925 Comm: tee Not tainted 5.15.50-1-lts #1
> Hardware name: MSI MS-7A59/Z270 SLI PLUS (MS-7A59), BIOS 1.90 01/30/2018
> RIP: 0010:smu_v11_0_set_fan_speed_rpm+0x11/0x110 [amdgpu]
>
> Speed is user-configurable through a file.
> I accidentally set it to zero, and the driver crashed.
>
> Signed-off-by: Yefim Barashkin <mr.b34r@kolabnow.com>
> ---
> drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
> b/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
> index 5f8809f6990d..69cebdb58c04 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
> +++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
> @@ -1236,6 +1236,10 @@ int smu_v11_0_set_fan_speed_rpm(struct
> smu_context *smu,
> * - For some Sienna Cichlid SKU, the fan speed cannot be set
> * lower than 500 RPM.
> */
> +
> + if (speed == 0)
> + return -EINVAL;
> +
> tach_period = 60 * crystal_clock_freq * 10000 / (8 * speed);
> WREG32_SOC15(THM, 0, mmCG_TACH_CTRL,
> REG_SET_FIELD(RREG32_SOC15(THM, 0, mmCG_TACH_CTRL),
> --
> 2.36.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] drm/amd/pm: Prevent divide by zero
2022-07-11 10:32 ` Christian König
@ 2022-07-11 22:35 ` Mr. B34r
2022-07-12 15:27 ` Alex Deucher
0 siblings, 1 reply; 8+ messages in thread
From: Mr. B34r @ 2022-07-11 22:35 UTC (permalink / raw)
To: Christian König; +Cc: amd-gfx
From: Yefim Barashkin <mr.b34r@kolabnow.com>
divide error: 0000 [#1] SMP PTI
CPU: 3 PID: 78925 Comm: tee Not tainted 5.15.50-1-lts #1
Hardware name: MSI MS-7A59/Z270 SLI PLUS (MS-7A59), BIOS 1.90 01/30/2018
RIP: 0010:smu_v11_0_set_fan_speed_rpm+0x11/0x110 [amdgpu]
Speed is user-configurable through a file.
I accidentally set it to zero, and the driver crashed.
Signed-off-by: Yefim Barashkin <mr.b34r@kolabnow.com>
---
drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
b/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
index 5f8809f6990d..69cebdb58c04 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
@@ -1236,6 +1236,10 @@ int smu_v11_0_set_fan_speed_rpm(struct
smu_context *smu,
* - For some Sienna Cichlid SKU, the fan speed cannot be set
* lower than 500 RPM.
*/
+
+ if (speed == 0)
+ return -EINVAL;
+
tach_period = 60 * crystal_clock_freq * 10000 / (8 * speed);
WREG32_SOC15(THM, 0, mmCG_TACH_CTRL,
REG_SET_FIELD(RREG32_SOC15(THM, 0, mmCG_TACH_CTRL),
--
2.36.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] drm/amd/pm: Prevent divide by zero
2022-07-09 2:31 Mr. B34r
2022-07-11 3:30 ` Quan, Evan
@ 2022-07-11 10:32 ` Christian König
2022-07-11 22:35 ` Mr. B34r
1 sibling, 1 reply; 8+ messages in thread
From: Christian König @ 2022-07-11 10:32 UTC (permalink / raw)
To: Mr. B34r, amd-gfx
Am 09.07.22 um 04:31 schrieb Mr. B34r:
> From: Vannoonnoo <mr.b34r@kolabnow.com>
>
> divide error: 0000 [#1] SMP PTI
> CPU: 3 PID: 78925 Comm: tee Not tainted 5.15.50-1-lts #1 5c320a339f0e397222fdfc9449eff04c0b12ea83
> Hardware name: MSI MS-7A59/Z270 SLI PLUS (MS-7A59), BIOS 1.90 01/30/2018
> RIP: 0010:smu_v11_0_set_fan_speed_rpm+0x11/0x110 [amdgpu]
>
> Speed is user-configurable through a file. I accidentally set it to zero, and the driver crashed.
Good catch, just some minor style problems. Your Signed-of-by line is
missing for example.
There is a checkpath.pl script in the Linux kernel source which can
point out such trivial mistakes.
Please run it on your patch and resend, apart from that looks good to me.
Christian.
>
> ---
> drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c b/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
> index 5f8809f6990d..69cebdb58c04 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
> +++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
> @@ -1236,6 +1236,10 @@ int smu_v11_0_set_fan_speed_rpm(struct smu_context *smu,
> * - For some Sienna Cichlid SKU, the fan speed cannot be set
> * lower than 500 RPM.
> */
> +
> + if (speed == 0)
> + return -EINVAL;
> +
> tach_period = 60 * crystal_clock_freq * 10000 / (8 * speed);
> WREG32_SOC15(THM, 0, mmCG_TACH_CTRL,
> REG_SET_FIELD(RREG32_SOC15(THM, 0, mmCG_TACH_CTRL),
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [PATCH] drm/amd/pm: Prevent divide by zero
2022-07-09 2:31 Mr. B34r
@ 2022-07-11 3:30 ` Quan, Evan
2022-07-11 10:32 ` Christian König
1 sibling, 0 replies; 8+ messages in thread
From: Quan, Evan @ 2022-07-11 3:30 UTC (permalink / raw)
To: Mr. B34r, amd-gfx
[AMD Official Use Only - General]
Reviewed-by: Evan Quan <evan.quan@amd.com>
> -----Original Message-----
> From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of Mr.
> B34r
> Sent: Saturday, July 9, 2022 10:31 AM
> To: amd-gfx@lists.freedesktop.org
> Cc: Vannoonnoo <mr.b34r@kolabnow.com>
> Subject: [PATCH] drm/amd/pm: Prevent divide by zero
>
> From: Vannoonnoo <mr.b34r@kolabnow.com>
>
> divide error: 0000 [#1] SMP PTI
> CPU: 3 PID: 78925 Comm: tee Not tainted 5.15.50-1-lts #1
> 5c320a339f0e397222fdfc9449eff04c0b12ea83
> Hardware name: MSI MS-7A59/Z270 SLI PLUS (MS-7A59), BIOS 1.90
> 01/30/2018
> RIP: 0010:smu_v11_0_set_fan_speed_rpm+0x11/0x110 [amdgpu]
>
> Speed is user-configurable through a file. I accidentally set it to zero, and the
> driver crashed.
>
> ---
> drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
> b/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
> index 5f8809f6990d..69cebdb58c04 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
> +++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
> @@ -1236,6 +1236,10 @@ int smu_v11_0_set_fan_speed_rpm(struct
> smu_context *smu,
> * - For some Sienna Cichlid SKU, the fan speed cannot be set
> * lower than 500 RPM.
> */
> +
> + if (speed == 0)
> + return -EINVAL;
> +
> tach_period = 60 * crystal_clock_freq * 10000 / (8 * speed);
> WREG32_SOC15(THM, 0, mmCG_TACH_CTRL,
> REG_SET_FIELD(RREG32_SOC15(THM, 0,
> mmCG_TACH_CTRL),
> --
> 2.36.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] drm/amd/pm: Prevent divide by zero
@ 2022-07-09 2:31 Mr. B34r
2022-07-11 3:30 ` Quan, Evan
2022-07-11 10:32 ` Christian König
0 siblings, 2 replies; 8+ messages in thread
From: Mr. B34r @ 2022-07-09 2:31 UTC (permalink / raw)
To: amd-gfx; +Cc: Vannoonnoo
From: Vannoonnoo <mr.b34r@kolabnow.com>
divide error: 0000 [#1] SMP PTI
CPU: 3 PID: 78925 Comm: tee Not tainted 5.15.50-1-lts #1 5c320a339f0e397222fdfc9449eff04c0b12ea83
Hardware name: MSI MS-7A59/Z270 SLI PLUS (MS-7A59), BIOS 1.90 01/30/2018
RIP: 0010:smu_v11_0_set_fan_speed_rpm+0x11/0x110 [amdgpu]
Speed is user-configurable through a file. I accidentally set it to zero, and the driver crashed.
---
drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c b/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
index 5f8809f6990d..69cebdb58c04 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
@@ -1236,6 +1236,10 @@ int smu_v11_0_set_fan_speed_rpm(struct smu_context *smu,
* - For some Sienna Cichlid SKU, the fan speed cannot be set
* lower than 500 RPM.
*/
+
+ if (speed == 0)
+ return -EINVAL;
+
tach_period = 60 * crystal_clock_freq * 10000 / (8 * speed);
WREG32_SOC15(THM, 0, mmCG_TACH_CTRL,
REG_SET_FIELD(RREG32_SOC15(THM, 0, mmCG_TACH_CTRL),
--
2.36.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-07-12 15:28 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-12 2:01 [PATCH] drm/amd/pm: Prevent divide by zero Yefim Barashkin
2022-07-12 3:51 ` Quan, Evan
2022-07-12 14:28 ` André Almeida
-- strict thread matches above, loose matches on Subject: below --
2022-07-09 2:31 Mr. B34r
2022-07-11 3:30 ` Quan, Evan
2022-07-11 10:32 ` Christian König
2022-07-11 22:35 ` Mr. B34r
2022-07-12 15:27 ` Alex Deucher
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.