Skip to contentSkip to conversation

drm/amd/display: Don't check for NULL divisor in fixpt code

PATCH In review Harry Wentland 3 participants 3 messages Apr 28, 2025 – May 5, 2025

Subsystems (3)
lore
Share & tools
lore

Harry Wentland

author maintainer
#0 lore raw

PATCH 1/1 drm/amd/display: Don't check for NULL divisor in fixpt code

[Why]
We check for a NULL divisor but don't act on it. This check does nothing other than throw a warning. It does confuse static checkers though:
See https://lkml.org/lkml/2025/4/26/371

[How]
Drop the ASSERTs in both DC and SPL variants.

Cc Linus Torvalds <[email protected]>
Cc Leo Li <[email protected]>
Cc Alex Deucher <[email protected]>
---
 drivers/gpu/drm/amd/display/dc/basics/fixpt31_32.c   | 5 -----
 drivers/gpu/drm/amd/display/dc/sspl/spl_fixpt31_32.c | 4 ----
 2 files changed, 9 deletions(-)
drivers/gpu/drm/amd/display/dc/basics/fixpt31_32.c +0 -5
index 88d3f9d7dd55..452206b5095e 100644
@@ -51,8 +51,6 @@ static inline unsigned long long complete_integer_division_u64(
 {
 	unsigned long long result;
 
-	ASSERT(divisor);
-
 	result = div64_u64_rem(dividend, divisor, remainder);
 
 	return result;
@@ -213,9 +211,6 @@ struct fixed31_32 dc_fixpt_recip(struct fixed31_32 arg)
 	 * @note
 	 * Good idea to use Newton's method
 	 */
-
-	ASSERT(arg.value);
-
 	return dc_fixpt_from_fraction(
 		dc_fixpt_one.value,
 		arg.value);
drivers/gpu/drm/amd/display/dc/sspl/spl_fixpt31_32.c +0 -4
index 52d97918a3bd..ebf0287417e0 100644
@@ -29,8 +29,6 @@ static inline unsigned long long spl_complete_integer_division_u64(
 {
 	unsigned long long result;
 
-	SPL_ASSERT(divisor);
-
 	result = spl_div64_u64_rem(dividend, divisor, remainder);
 
 	return result;
@@ -196,8 +194,6 @@ struct spl_fixed31_32 spl_fixpt_recip(struct spl_fixed31_32 arg)
 	 * Good idea to use Newton's method
 	 */
 
-	SPL_ASSERT(arg.value);
-
 	return spl_fixpt_from_fraction(
 		spl_fixpt_one.value,
 		arg.value);
Signature · 1 line
2.49.0
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Harry Wentland

[Why]
We check for a NULL divisor but don't act on it. This check does nothing other than throw a warning. It does confuse static checkers though:
See https://lkml.org/lkml/2025/4/26/371

Quoted 7 lines

[How]
Drop the ASSERTs in both DC and SPL variants.

Cc Linus Torvalds <[email protected]>
Cc Leo Li <[email protected]>
Cc Alex Deucher <[email protected]>

Maybe add Fixes tags for the original patches which added these?

Quoted 53 lines
---
 drivers/gpu/drm/amd/display/dc/basics/fixpt31_32.c   | 5 -----
 drivers/gpu/drm/amd/display/dc/sspl/spl_fixpt31_32.c | 4 ----
 2 files changed, 9 deletions(-)
drivers/gpu/drm/amd/display/dc/basics/fixpt31_32.c +0 -5
index 88d3f9d7dd55..452206b5095e 100644
@@ -51,8 +51,6 @@ static inline unsigned long long complete_integer_division_u64(
 {
        unsigned long long result;
 
-       ASSERT(divisor);
-
        result = div64_u64_rem(dividend, divisor, remainder);
 
        return result;
@@ -213,9 +211,6 @@ struct fixed31_32 dc_fixpt_recip(struct fixed31_32 arg)
         * @note
         * Good idea to use Newton's method
         */
-
-       ASSERT(arg.value);
-
        return dc_fixpt_from_fraction(
                dc_fixpt_one.value,
                arg.value);
drivers/gpu/drm/amd/display/dc/sspl/spl_fixpt31_32.c +0 -5
index 52d97918a3bd..ebf0287417e0 100644
@@ -29,8 +29,6 @@ static inline unsigned long long spl_complete_integer_division_u64(
 {
        unsigned long long result;
 
-       SPL_ASSERT(divisor);
-
        result = spl_div64_u64_rem(dividend, divisor, remainder);
 
        return result;
@@ -196,8 +194,6 @@ struct spl_fixed31_32 spl_fixpt_recip(struct spl_fixed31_32 arg)
         * Good idea to use Newton's method
         */
 
-       SPL_ASSERT(arg.value);
-
        return spl_fixpt_from_fraction(
                spl_fixpt_one.value,
                arg.value);
--

2.49.0

Reviewed-by on v1 1/1
#2 lore raw
In reply to Harry Wentland
Quoted 63 lines · Harry Wentland

[Why]
We check for a NULL divisor but don't act on it. This check does nothing other than throw a warning. It does confuse static checkers though:
See https://lkml.org/lkml/2025/4/26/371

[How]
Drop the ASSERTs in both DC and SPL variants.

Cc Linus Torvalds <[email protected]>
Cc Leo Li <[email protected]>
Cc Alex Deucher <[email protected]>
---
  drivers/gpu/drm/amd/display/dc/basics/fixpt31_32.c   | 5 -----
  drivers/gpu/drm/amd/display/dc/sspl/spl_fixpt31_32.c | 4 ----
  2 files changed, 9 deletions(-)
drivers/gpu/drm/amd/display/dc/basics/fixpt31_32.c +0 -5
index 88d3f9d7dd55..452206b5095e 100644
@@ -51,8 +51,6 @@ static inline unsigned long long complete_integer_division_u64(
  {
  	unsigned long long result;
 
-	ASSERT(divisor);
-
  	result = div64_u64_rem(dividend, divisor, remainder);
 
  	return result;
@@ -213,9 +211,6 @@ struct fixed31_32 dc_fixpt_recip(struct fixed31_32 arg)
  	 * @note
  	 * Good idea to use Newton's method
  	 */
-
-	ASSERT(arg.value);
-
  	return dc_fixpt_from_fraction(
  		dc_fixpt_one.value,
  		arg.value);
drivers/gpu/drm/amd/display/dc/sspl/spl_fixpt31_32.c +0 -4
index 52d97918a3bd..ebf0287417e0 100644
@@ -29,8 +29,6 @@ static inline unsigned long long spl_complete_integer_division_u64(
  {
  	unsigned long long result;
 
-	SPL_ASSERT(divisor);
-
  	result = spl_div64_u64_rem(dividend, divisor, remainder);
 
  	return result;
@@ -196,8 +194,6 @@ struct spl_fixed31_32 spl_fixpt_recip(struct spl_fixed31_32 arg)
  	 * Good idea to use Newton's method
  	 */
 
-	SPL_ASSERT(arg.value);
-
  	return spl_fixpt_from_fraction(
  		spl_fixpt_one.value,
  		arg.value);