[PATCH] drm/amd/display: Interpret log_2(0) as 0

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Even though log(0) is technically undefined our code assumes that
log_2(0) is 0. This mirrors the current behavior of our log_2
implementation on non-Linux platforms.

Signed-off-by: Harry Wentland <harry.wentland@xxxxxxx>
---

What's num_pkrs value is upstream Mesa providing for CHIP_VANGOGH?

I saw that problem at bringup with an internal Mesa and had this fix
for it.

Harry

 drivers/gpu/drm/amd/display/dc/basics/conversion.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/basics/conversion.h b/drivers/gpu/drm/amd/display/dc/basics/conversion.h
index ade785c4fdc7..da9883ec7b1c 100644
--- a/drivers/gpu/drm/amd/display/dc/basics/conversion.h
+++ b/drivers/gpu/drm/amd/display/dc/basics/conversion.h
@@ -40,7 +40,11 @@ void convert_float_matrix(
 
 static inline unsigned int log_2(unsigned int num)
 {
-	return ilog2(num);
+	/*
+	 * Technically log(0) is undefined, but our code is structured
+	 * in a way that assumes log(0) = 0
+	 */
+	return num ? ilog2(num) : num;
 }
 
 #endif
-- 
2.28.0

_______________________________________________
amd-gfx mailing list
amd-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/amd-gfx



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux