Skip to contentSkip to conversation

drm/amd/display: fix type mismatch in CalculateDynamicMetadataParameters()

PATCH Superseded Vitaliy Shevtsov 2 participants 2 messages Feb 23, 2025 – Feb 26, 2025

Subsystems (4)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd/display: fix type mismatch in CalculateDynamicMetadataParameters()

There is a type mismatch between what CalculateDynamicMetadataParameters() takes and what is passed to it. Currently this function accepts several args as signed long but it's called with unsigned integers. On some systems where long is 32 bits and one of these input params is greater than INT_MAX it may cause passing input params as negative values.

Fix this by changing these argument types from long to unsigned int. Also this will align the function's definition with similar functions in other dcn* drivers.

Found by Linux Verification Center (linuxtesting.org) with Svace.

---
 .../amd/display/dc/dml/dcn30/display_mode_vba_30.c   | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/display/dc/dml/dcn30/display_mode_vba_30.c +6 -6
index cee1b351e105..c6c7ce84e260 100644
@@ -281,10 +281,10 @@ static void CalculateDynamicMetadataParameters(
 		double DISPCLK,
 		double DCFClkDeepSleep,
 		double PixelClock,
-		long HTotal,
-		long VBlank,
-		long DynamicMetadataTransmittedBytes,
-		long DynamicMetadataLinesBeforeActiveRequired,
+		unsigned int HTotal,
+		unsigned int VBlank,
+		unsigned int DynamicMetadataTransmittedBytes,
+		unsigned int DynamicMetadataLinesBeforeActiveRequired,
 		int InterlaceEnable,
 		bool ProgressiveToInterlaceUnitInOPP,
 		double *Tsetup,
@@ -3265,8 +3265,8 @@ static double CalculateWriteBackDelay(
 
 
 static void CalculateDynamicMetadataParameters(int MaxInterDCNTileRepeaters, double DPPCLK, double DISPCLK,
-		double DCFClkDeepSleep, double PixelClock, long HTotal, long VBlank, long DynamicMetadataTransmittedBytes,
-		long DynamicMetadataLinesBeforeActiveRequired, int InterlaceEnable, bool ProgressiveToInterlaceUnitInOPP,
+		double DCFClkDeepSleep, double PixelClock, unsigned int HTotal, unsigned int VBlank, unsigned int DynamicMetadataTransmittedBytes,
+		unsigned int DynamicMetadataLinesBeforeActiveRequired, int InterlaceEnable, bool ProgressiveToInterlaceUnitInOPP,
 		double *Tsetup, double *Tdmbf, double *Tdmec, double *Tdmsks)
 {
 	double TotalRepeaterDelayTime = 0;
Signature · 1 line
2.48.1
#1 lore raw
Quoted 23 lines · Vitaliy Shevtsov

There is a type mismatch between what CalculateDynamicMetadataParameters() takes and what is passed to it. Currently this function accepts several args as signed long but it's called with unsigned integers. On some systems where long is 32 bits and one of these input params is greater than INT_MAX it may cause passing input params as negative values.

Fix this by changing these argument types from long to unsigned int. Also this will align the function's definition with similar functions in other dcn* drivers.

Found by Linux Verification Center (linuxtesting.org) with Svace.

---
  .../amd/display/dc/dml/dcn30/display_mode_vba_30.c   | 12 ++++++------
  1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/display/dc/dml/dcn30/display_mode_vba_30.c +0 -0
index cee1b351e105..c6c7ce84e260 100644
@@ -281,10 +281,10 @@ static void CalculateDynamicMetadataParameters(
  		double DISPCLK,

drivers/gpu/drm/amd/display/dc/dml/dcn30/display_mode_vba_30.c static void CalculateDynamicMetadataParameters( · line 287

Quoted 10 lines
drivers/gpu/drm/amd/display/dc/dml/dcn30/display_mode_vba_30.c +4 -4
  		double DCFClkDeepSleep,
  		double PixelClock,
-		long HTotal,
-		long VBlank,
-		long DynamicMetadataTransmittedBytes,
-		long DynamicMetadataLinesBeforeActiveRequired,
+		unsigned int HTotal,
+		unsigned int VBlank,
+		unsigned int DynamicMetadataTransmittedBytes,
+		unsigned int DynamicMetadataLinesBeforeActiveRequired,

DynamicMetadataLinesBeforeActiveRequired past to "CalculateDynamicMetadataParameters" are int instead of unsigned int. Can you confirm and try with Svace?

Thanks.

Quoted 14 lines
drivers/gpu/drm/amd/display/dc/dml/dcn30/display_mode_vba_30.c +2 -2
  		int InterlaceEnable,
  		bool ProgressiveToInterlaceUnitInOPP,
  		double *Tsetup,
@@ -3265,8 +3265,8 @@ static double CalculateWriteBackDelay(
 
 
  static void CalculateDynamicMetadataParameters(int MaxInterDCNTileRepeaters, double DPPCLK, double DISPCLK,
-		double DCFClkDeepSleep, double PixelClock, long HTotal, long VBlank, long DynamicMetadataTransmittedBytes,
-		long DynamicMetadataLinesBeforeActiveRequired, int InterlaceEnable, bool ProgressiveToInterlaceUnitInOPP,
+		double DCFClkDeepSleep, double PixelClock, unsigned int HTotal, unsigned int VBlank, unsigned int DynamicMetadataTransmittedBytes,
+		unsigned int DynamicMetadataLinesBeforeActiveRequired, int InterlaceEnable, bool ProgressiveToInterlaceUnitInOPP,
  		double *Tsetup, double *Tdmbf, double *Tdmec, double *Tdmsks)
  {
  	double TotalRepeaterDelayTime = 0;