* [PATCH v2] drm/amd/display: fix type mismatch in CalculateDynamicMetadataParameters()
@ 2025-02-26 11:10 Vitaliy Shevtsov
2025-02-26 19:09 ` Alex Hung
0 siblings, 1 reply; 2+ messages in thread
From: Vitaliy Shevtsov @ 2025-02-26 11:10 UTC (permalink / raw)
To: Chaitanya Dhere
Cc: Vitaliy Shevtsov, Jun Lei, Harry Wentland, Leo Li,
Rodrigo Siqueira, Alex Deucher, Christian König, Xinhui Pan,
David Airlie, Simona Vetter, Alex Hung, Fangzhi Zuo, Aric Cyr,
amd-gfx, dri-devel, linux-kernel, lvc-project
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.
Fixes: 6725a88f88a7 ("drm/amd/display: Add DCN3 DML")
Signed-off-by: Vitaliy Shevtsov <v.shevtsov@mt-integration.ru>
---
v2: Change DynamicMetadataLinesBeforeActiveRequired type from unsigned int
to int as per Alex Hung's observation.
Add Fixes tag missed by chance.
.../amd/display/dc/dml/dcn30/display_mode_vba_30.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn30/display_mode_vba_30.c b/drivers/gpu/drm/amd/display/dc/dml/dcn30/display_mode_vba_30.c
index cee1b351e105..f1fe49401bc0 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/dcn30/display_mode_vba_30.c
+++ b/drivers/gpu/drm/amd/display/dc/dml/dcn30/display_mode_vba_30.c
@@ -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,
+ 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,
+ int DynamicMetadataLinesBeforeActiveRequired, int InterlaceEnable, bool ProgressiveToInterlaceUnitInOPP,
double *Tsetup, double *Tdmbf, double *Tdmec, double *Tdmsks)
{
double TotalRepeaterDelayTime = 0;
--
2.48.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2] drm/amd/display: fix type mismatch in CalculateDynamicMetadataParameters()
2025-02-26 11:10 [PATCH v2] drm/amd/display: fix type mismatch in CalculateDynamicMetadataParameters() Vitaliy Shevtsov
@ 2025-02-26 19:09 ` Alex Hung
0 siblings, 0 replies; 2+ messages in thread
From: Alex Hung @ 2025-02-26 19:09 UTC (permalink / raw)
To: Vitaliy Shevtsov, Chaitanya Dhere
Cc: Jun Lei, Harry Wentland, Leo Li, Rodrigo Siqueira, Alex Deucher,
Christian König, Xinhui Pan, David Airlie, Simona Vetter,
Fangzhi Zuo, Aric Cyr, amd-gfx, dri-devel, linux-kernel,
lvc-project
On 2/26/25 04:10, Vitaliy Shevtsov wrote:
> 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.
The commit description needs to be updated to include int in addition to
unsigned int too.
>
> Found by Linux Verification Center (linuxtesting.org) with Svace.
>
> Fixes: 6725a88f88a7 ("drm/amd/display: Add DCN3 DML")
> Signed-off-by: Vitaliy Shevtsov <v.shevtsov@mt-integration.ru>
> ---
> v2: Change DynamicMetadataLinesBeforeActiveRequired type from unsigned int
> to int as per Alex Hung's observation.
> Add Fixes tag missed by chance.
>
> .../amd/display/dc/dml/dcn30/display_mode_vba_30.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn30/display_mode_vba_30.c b/drivers/gpu/drm/amd/display/dc/dml/dcn30/display_mode_vba_30.c
> index cee1b351e105..f1fe49401bc0 100644
> --- a/drivers/gpu/drm/amd/display/dc/dml/dcn30/display_mode_vba_30.c
> +++ b/drivers/gpu/drm/amd/display/dc/dml/dcn30/display_mode_vba_30.c
> @@ -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,
> + 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,
> + int DynamicMetadataLinesBeforeActiveRequired, int InterlaceEnable, bool ProgressiveToInterlaceUnitInOPP,
> double *Tsetup, double *Tdmbf, double *Tdmec, double *Tdmsks)
> {
> double TotalRepeaterDelayTime = 0;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-02-26 19:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-26 11:10 [PATCH v2] drm/amd/display: fix type mismatch in CalculateDynamicMetadataParameters() Vitaliy Shevtsov
2025-02-26 19:09 ` Alex Hung
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®