mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-23 05:56:14 -04:00
drm/amd/display: Covert integers to double before divisions
Integer divisions result in loss of fractional and accuracy is lost when assigned or compared with double. It is necessary to perform double/integer instead or explicitly cast them to double. This fixes 54 UNINTENDED_INTEGER_DIVISION issues reported by Coverity. Reviewed-by: Harry Wentland <harry.wentland@amd.com> Acked-by: Hamza Mahfooz <hamza.mahfooz@amd.com> Signed-off-by: Alex Hung <alex.hung@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
@@ -690,7 +690,7 @@ static void hack_disable_optional_pipe_split(struct dcn_bw_internal_vars *v)
|
||||
static void hack_force_pipe_split(struct dcn_bw_internal_vars *v,
|
||||
unsigned int pixel_rate_100hz)
|
||||
{
|
||||
float pixel_rate_mhz = pixel_rate_100hz / 10000;
|
||||
float pixel_rate_mhz = pixel_rate_100hz / 10000.0;
|
||||
|
||||
/*
|
||||
* force enabling pipe split by lower dpp clock for DPM0 to just
|
||||
|
||||
@@ -1882,10 +1882,10 @@ void dcn20_update_bounding_box(struct dc *dc,
|
||||
bb->clock_limits[i].fabricclk_mhz = (min_fclk_required_by_uclk < min_dcfclk) ?
|
||||
min_dcfclk : min_fclk_required_by_uclk;
|
||||
|
||||
bb->clock_limits[i].socclk_mhz = (bb->clock_limits[i].fabricclk_mhz > max_clocks->socClockInKhz / 1000) ?
|
||||
bb->clock_limits[i].socclk_mhz = (bb->clock_limits[i].fabricclk_mhz > max_clocks->socClockInKhz / 1000.0) ?
|
||||
max_clocks->socClockInKhz / 1000 : bb->clock_limits[i].fabricclk_mhz;
|
||||
|
||||
bb->clock_limits[i].dcfclk_mhz = (bb->clock_limits[i].fabricclk_mhz > max_clocks->dcfClockInKhz / 1000) ?
|
||||
bb->clock_limits[i].dcfclk_mhz = (bb->clock_limits[i].fabricclk_mhz > max_clocks->dcfClockInKhz / 1000.0) ?
|
||||
max_clocks->dcfClockInKhz / 1000 : bb->clock_limits[i].fabricclk_mhz;
|
||||
|
||||
bb->clock_limits[i].dispclk_mhz = max_clocks->displayClockInKhz / 1000;
|
||||
@@ -1917,35 +1917,35 @@ void dcn20_cap_soc_clocks(struct _vcs_dpi_soc_bounding_box_st *bb,
|
||||
|
||||
// First pass - cap all clocks higher than the reported max
|
||||
for (i = 0; i < bb->num_states; i++) {
|
||||
if ((bb->clock_limits[i].dcfclk_mhz > (max_clocks.dcfClockInKhz / 1000))
|
||||
if ((bb->clock_limits[i].dcfclk_mhz > (max_clocks.dcfClockInKhz / 1000.0))
|
||||
&& max_clocks.dcfClockInKhz != 0)
|
||||
bb->clock_limits[i].dcfclk_mhz = (max_clocks.dcfClockInKhz / 1000);
|
||||
|
||||
if ((bb->clock_limits[i].dram_speed_mts > (max_clocks.uClockInKhz / 1000) * 16)
|
||||
if ((bb->clock_limits[i].dram_speed_mts > (max_clocks.uClockInKhz / 1000.0) * 16)
|
||||
&& max_clocks.uClockInKhz != 0)
|
||||
bb->clock_limits[i].dram_speed_mts = (max_clocks.uClockInKhz / 1000) * 16;
|
||||
|
||||
if ((bb->clock_limits[i].fabricclk_mhz > (max_clocks.fabricClockInKhz / 1000))
|
||||
if ((bb->clock_limits[i].fabricclk_mhz > (max_clocks.fabricClockInKhz / 1000.0))
|
||||
&& max_clocks.fabricClockInKhz != 0)
|
||||
bb->clock_limits[i].fabricclk_mhz = (max_clocks.fabricClockInKhz / 1000);
|
||||
|
||||
if ((bb->clock_limits[i].dispclk_mhz > (max_clocks.displayClockInKhz / 1000))
|
||||
if ((bb->clock_limits[i].dispclk_mhz > (max_clocks.displayClockInKhz / 1000.0))
|
||||
&& max_clocks.displayClockInKhz != 0)
|
||||
bb->clock_limits[i].dispclk_mhz = (max_clocks.displayClockInKhz / 1000);
|
||||
|
||||
if ((bb->clock_limits[i].dppclk_mhz > (max_clocks.dppClockInKhz / 1000))
|
||||
if ((bb->clock_limits[i].dppclk_mhz > (max_clocks.dppClockInKhz / 1000.0))
|
||||
&& max_clocks.dppClockInKhz != 0)
|
||||
bb->clock_limits[i].dppclk_mhz = (max_clocks.dppClockInKhz / 1000);
|
||||
|
||||
if ((bb->clock_limits[i].phyclk_mhz > (max_clocks.phyClockInKhz / 1000))
|
||||
if ((bb->clock_limits[i].phyclk_mhz > (max_clocks.phyClockInKhz / 1000.0))
|
||||
&& max_clocks.phyClockInKhz != 0)
|
||||
bb->clock_limits[i].phyclk_mhz = (max_clocks.phyClockInKhz / 1000);
|
||||
|
||||
if ((bb->clock_limits[i].socclk_mhz > (max_clocks.socClockInKhz / 1000))
|
||||
if ((bb->clock_limits[i].socclk_mhz > (max_clocks.socClockInKhz / 1000.0))
|
||||
&& max_clocks.socClockInKhz != 0)
|
||||
bb->clock_limits[i].socclk_mhz = (max_clocks.socClockInKhz / 1000);
|
||||
|
||||
if ((bb->clock_limits[i].dscclk_mhz > (max_clocks.dscClockInKhz / 1000))
|
||||
if ((bb->clock_limits[i].dscclk_mhz > (max_clocks.dscClockInKhz / 1000.0))
|
||||
&& max_clocks.dscClockInKhz != 0)
|
||||
bb->clock_limits[i].dscclk_mhz = (max_clocks.dscClockInKhz / 1000);
|
||||
}
|
||||
|
||||
@@ -1017,7 +1017,7 @@ static unsigned int CalculateVMAndRowBytes(
|
||||
if (ScanDirection == dm_horz)
|
||||
FractionOfPTEReturnDrop = 0;
|
||||
else
|
||||
FractionOfPTEReturnDrop = 7 / 8;
|
||||
FractionOfPTEReturnDrop = 7.0 / 8;
|
||||
} else if (VMMPageSize == 4096 && MacroTileSizeBytes > 4096) {
|
||||
PixelPTEReqHeight = 16 * BlockHeight256Bytes;
|
||||
PixelPTEReqWidth = 16 * BlockWidth256Bytes;
|
||||
@@ -3231,22 +3231,22 @@ static unsigned int TruncToValidBPP(
|
||||
if (Format == dm_420) {
|
||||
if (DecimalBPP < 6)
|
||||
return BPP_INVALID;
|
||||
else if (DecimalBPP >= 1.5 * DSCInputBitPerComponent - 1 / 16)
|
||||
return 1.5 * DSCInputBitPerComponent - 1 / 16;
|
||||
else if (DecimalBPP >= 1.5 * DSCInputBitPerComponent - 1.0 / 16)
|
||||
return 1.5 * DSCInputBitPerComponent - 1.0 / 16;
|
||||
else
|
||||
return dml_floor(16 * DecimalBPP, 1) / 16;
|
||||
} else if (Format == dm_n422) {
|
||||
if (DecimalBPP < 7)
|
||||
return BPP_INVALID;
|
||||
else if (DecimalBPP >= 2 * DSCInputBitPerComponent - 1 / 16)
|
||||
return 2 * DSCInputBitPerComponent - 1 / 16;
|
||||
else if (DecimalBPP >= 2 * DSCInputBitPerComponent - 1.0 / 16)
|
||||
return 2 * DSCInputBitPerComponent - 1.0 / 16;
|
||||
else
|
||||
return dml_floor(16 * DecimalBPP, 1) / 16;
|
||||
} else {
|
||||
if (DecimalBPP < 8)
|
||||
return BPP_INVALID;
|
||||
else if (DecimalBPP >= 3 * DSCInputBitPerComponent - 1 / 16)
|
||||
return 3 * DSCInputBitPerComponent - 1 / 16;
|
||||
else if (DecimalBPP >= 3 * DSCInputBitPerComponent - 1.0 / 16)
|
||||
return 3 * DSCInputBitPerComponent - 1.0 / 16;
|
||||
else
|
||||
return dml_floor(16 * DecimalBPP, 1) / 16;
|
||||
}
|
||||
@@ -4322,7 +4322,7 @@ void dml20_ModeSupportAndSystemConfigurationFull(struct display_mode_lib *mode_l
|
||||
locals->RoundedUpMaxSwathSizeBytesC = 0;
|
||||
}
|
||||
|
||||
if (locals->RoundedUpMaxSwathSizeBytesY + locals->RoundedUpMaxSwathSizeBytesC <= locals->DETBufferSizeInKByte[0] * 1024 / 2) {
|
||||
if (locals->RoundedUpMaxSwathSizeBytesY + locals->RoundedUpMaxSwathSizeBytesC <= locals->DETBufferSizeInKByte[0] * 1024.0 / 2) {
|
||||
locals->SwathHeightYPerState[i][j][k] = locals->MaxSwathHeightY[k];
|
||||
locals->SwathHeightCPerState[i][j][k] = locals->MaxSwathHeightC[k];
|
||||
} else {
|
||||
|
||||
@@ -1077,7 +1077,7 @@ static unsigned int CalculateVMAndRowBytes(
|
||||
if (ScanDirection == dm_horz)
|
||||
FractionOfPTEReturnDrop = 0;
|
||||
else
|
||||
FractionOfPTEReturnDrop = 7 / 8;
|
||||
FractionOfPTEReturnDrop = 7.0 / 8;
|
||||
} else if (VMMPageSize == 4096 && MacroTileSizeBytes > 4096) {
|
||||
PixelPTEReqHeight = 16 * BlockHeight256Bytes;
|
||||
PixelPTEReqWidth = 16 * BlockWidth256Bytes;
|
||||
@@ -4443,7 +4443,7 @@ void dml20v2_ModeSupportAndSystemConfigurationFull(struct display_mode_lib *mode
|
||||
locals->RoundedUpMaxSwathSizeBytesC = 0;
|
||||
}
|
||||
|
||||
if (locals->RoundedUpMaxSwathSizeBytesY + locals->RoundedUpMaxSwathSizeBytesC <= locals->DETBufferSizeInKByte[0] * 1024 / 2) {
|
||||
if (locals->RoundedUpMaxSwathSizeBytesY + locals->RoundedUpMaxSwathSizeBytesC <= locals->DETBufferSizeInKByte[0] * 1024.0 / 2) {
|
||||
locals->SwathHeightYPerState[i][j][k] = locals->MaxSwathHeightY[k];
|
||||
locals->SwathHeightCPerState[i][j][k] = locals->MaxSwathHeightC[k];
|
||||
} else {
|
||||
|
||||
@@ -1399,7 +1399,7 @@ static unsigned int CalculateVMAndRowBytes(
|
||||
if (ScanDirection == dm_horz)
|
||||
FractionOfPTEReturnDrop = 0;
|
||||
else
|
||||
FractionOfPTEReturnDrop = 7 / 8;
|
||||
FractionOfPTEReturnDrop = 7.0 / 8;
|
||||
} else if (VMMPageSize == 4096 && MacroTileSizeBytes > 4096) {
|
||||
PixelPTEReqHeightPTEs = 16;
|
||||
*PixelPTEReqHeight = 16 * BlockHeight256Bytes;
|
||||
|
||||
@@ -1783,7 +1783,7 @@ static unsigned int CalculateVMAndRowBytes(
|
||||
if (ScanDirection != dm_vert)
|
||||
FractionOfPTEReturnDrop = 0;
|
||||
else
|
||||
FractionOfPTEReturnDrop = 7 / 8;
|
||||
FractionOfPTEReturnDrop = 7.0 / 8;
|
||||
} else if (GPUVMMinPageSize == 4 && MacroTileSizeBytes > 4096) {
|
||||
PixelPTEReqHeightPTEs = 16;
|
||||
*PixelPTEReqHeight = 16 * BlockHeight256Bytes;
|
||||
|
||||
@@ -1932,7 +1932,7 @@ static unsigned int CalculateVMAndRowBytes(
|
||||
if (ScanDirection != dm_vert)
|
||||
FractionOfPTEReturnDrop = 0;
|
||||
else
|
||||
FractionOfPTEReturnDrop = 7 / 8;
|
||||
FractionOfPTEReturnDrop = 7.0 / 8;
|
||||
} else if (GPUVMMinPageSize == 4 && MacroTileSizeBytes > 4096) {
|
||||
PixelPTEReqHeightPTEs = 16;
|
||||
*PixelPTEReqHeight = 16 * BlockHeight256Bytes;
|
||||
@@ -3617,7 +3617,7 @@ static double TruncToValidBPP(
|
||||
NonDSCBPP1 = 15;
|
||||
NonDSCBPP2 = 18;
|
||||
MinDSCBPP = 6;
|
||||
MaxDSCBPP = 1.5 * DSCInputBitPerComponent - 1 / 16;
|
||||
MaxDSCBPP = 1.5 * DSCInputBitPerComponent - 1.0 / 16;
|
||||
} else if (Format == dm_444) {
|
||||
NonDSCBPP0 = 24;
|
||||
NonDSCBPP1 = 30;
|
||||
|
||||
@@ -3714,7 +3714,7 @@ static double TruncToValidBPP(
|
||||
NonDSCBPP1 = 15;
|
||||
NonDSCBPP2 = 18;
|
||||
MinDSCBPP = 6;
|
||||
MaxDSCBPP = 1.5 * DSCInputBitPerComponent - 1 / 16;
|
||||
MaxDSCBPP = 1.5 * DSCInputBitPerComponent - 1.0 / 16;
|
||||
} else if (Format == dm_444) {
|
||||
NonDSCBPP0 = 24;
|
||||
NonDSCBPP1 = 30;
|
||||
|
||||
@@ -1401,13 +1401,13 @@ void dml32_CalculateOutputLink(
|
||||
if (Output == dm_dp2p0) {
|
||||
*OutBpp = 0;
|
||||
if ((OutputLinkDPRate == dm_dp_rate_na || OutputLinkDPRate == dm_dp_rate_uhbr10) &&
|
||||
PHYCLKD32PerState >= 10000 / 32) {
|
||||
PHYCLKD32PerState >= 10000.0 / 32) {
|
||||
*OutBpp = dml32_TruncToValidBPP((1 - Downspreading / 100) * 10000,
|
||||
OutputLinkDPLanes, HTotal, HActive, PixelClockBackEnd,
|
||||
ForcedOutputLinkBPP, LinkDSCEnable, Output, OutputFormat,
|
||||
DSCInputBitPerComponent, NumberOfDSCSlices, AudioSampleRate,
|
||||
AudioSampleLayout, ODMModeNoDSC, ODMModeDSC, RequiredSlots);
|
||||
if (*OutBpp == 0 && PHYCLKD32PerState < 13500 / 32 && DSCEnable == true &&
|
||||
if (*OutBpp == 0 && PHYCLKD32PerState < 13500.0 / 32 && DSCEnable == true &&
|
||||
ForcedOutputLinkBPP == 0) {
|
||||
*RequiresDSC = true;
|
||||
LinkDSCEnable = true;
|
||||
@@ -1423,7 +1423,7 @@ void dml32_CalculateOutputLink(
|
||||
*OutputRate = dm_output_rate_dp_rate_uhbr10;
|
||||
}
|
||||
if ((OutputLinkDPRate == dm_dp_rate_na || OutputLinkDPRate == dm_dp_rate_uhbr13p5) &&
|
||||
*OutBpp == 0 && PHYCLKD32PerState >= 13500 / 32) {
|
||||
*OutBpp == 0 && PHYCLKD32PerState >= 13500.0 / 32) {
|
||||
*OutBpp = dml32_TruncToValidBPP((1 - Downspreading / 100) * 13500,
|
||||
OutputLinkDPLanes, HTotal, HActive, PixelClockBackEnd,
|
||||
ForcedOutputLinkBPP, LinkDSCEnable, Output, OutputFormat,
|
||||
@@ -1601,7 +1601,7 @@ double dml32_TruncToValidBPP(
|
||||
NonDSCBPP1 = 15;
|
||||
NonDSCBPP2 = 18;
|
||||
MinDSCBPP = 6;
|
||||
MaxDSCBPP = 1.5 * DSCInputBitPerComponent - 1 / 16;
|
||||
MaxDSCBPP = 1.5 * DSCInputBitPerComponent - 1.0 / 16;
|
||||
} else if (Format == dm_444) {
|
||||
NonDSCBPP0 = 24;
|
||||
NonDSCBPP1 = 30;
|
||||
|
||||
Reference in New Issue
Block a user