[bug report] drm/amd/display: DML2.1 resynchronization

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

 



Hello Chaitanya Dhere,

This is a semi-automatic email about new static checker warnings.

Commit 2563391e57b5 ("drm/amd/display: DML2.1 resynchronization")
from Jul 2, 2024, leads to the following Smatch complaint:

    drivers/gpu/drm/amd/amdgpu/../display/dc/dml2/dml21/src/dml2_core/dml2_core_dcn4_calcs.c:3854 CalculateSwathAndDETConfiguration()
    warn: variable dereferenced before check 'p->UnboundedRequestEnabled' (see line 3698)

drivers/gpu/drm/amd/amdgpu/../display/dc/dml2/dml21/src/dml2_core/dml2_core_dcn4_calcs.c
  3697	
  3698		*p->UnboundedRequestEnabled = UnboundedRequest(p->display_cfg->overrides.hw.force_unbounded_requesting.enable, p->display_cfg->overrides.hw.force_unbounded_requesting.value, TotalActiveDPP, NoChromaOrLinear);
  3699	
  3700		CalculateDETBufferSize(
  3701			&scratch->CalculateDETBufferSize_locals,
  3702			p->display_cfg,
  3703			p->ForceSingleDPP,
  3704			p->NumberOfActiveSurfaces,
  3705			*p->UnboundedRequestEnabled,
  3706			p->nomDETInKByte,
  3707			p->MaxTotalDETInKByte,
  3708			p->ConfigReturnBufferSizeInKByte,
  3709			p->MinCompressedBufferSizeInKByte,
  3710			p->ConfigReturnBufferSegmentSizeInkByte,
  3711			p->CompressedBufferSegmentSizeInkByte,
  3712			p->ReadBandwidthLuma,
  3713			p->ReadBandwidthChroma,
  3714			p->full_swath_bytes_l,
  3715			p->full_swath_bytes_c,
  3716			p->DPPPerSurface,
  3717	
  3718			// Output
  3719			p->DETBufferSizeInKByte, // per hubp pipe
  3720			p->CompressedBufferSizeInkByte);
  3721	
  3722	#ifdef __DML_VBA_DEBUG__
  3723		dml2_printf("DML::%s: TotalActiveDPP = %u\n", __func__, TotalActiveDPP);
  3724		dml2_printf("DML::%s: nomDETInKByte = %u\n", __func__, p->nomDETInKByte);
  3725		dml2_printf("DML::%s: ConfigReturnBufferSizeInKByte = %u\n", __func__, p->ConfigReturnBufferSizeInKByte);
  3726		dml2_printf("DML::%s: UnboundedRequestEnabled = %u\n", __func__, *p->UnboundedRequestEnabled);
  3727		dml2_printf("DML::%s: CompressedBufferSizeInkByte = %u\n", __func__, *p->CompressedBufferSizeInkByte);
  3728	#endif
  3729	
  3730		*p->ViewportSizeSupport = true;
  3731		for (unsigned int k = 0; k < p->NumberOfActiveSurfaces; ++k) {
  3732	
  3733			DETBufferSizeInKByteForSwathCalculation = (dml_is_phantom_pipe(&p->display_cfg->plane_descriptors[k]) ? 1024 : p->DETBufferSizeInKByte[k]);
  3734	#ifdef __DML_VBA_DEBUG__
  3735			dml2_printf("DML::%s: k=%u DETBufferSizeInKByteForSwathCalculation = %u\n", __func__, k, DETBufferSizeInKByteForSwathCalculation);
  3736	#endif
  3737			if (p->display_cfg->plane_descriptors[k].surface.tiling == dml2_sw_linear) {
  3738				p->SwathHeightY[k] = MaximumSwathHeightY[k];
  3739				p->SwathHeightC[k] = MaximumSwathHeightC[k];
  3740				RoundedUpSwathSizeBytesY[k] = p->full_swath_bytes_l[k];
  3741				RoundedUpSwathSizeBytesC[k] = p->full_swath_bytes_c[k];
  3742	
  3743				if (p->surf_linear128_l[k])
  3744					p->request_size_bytes_luma[k] = 128;
  3745				else
  3746					p->request_size_bytes_luma[k] = 256;
  3747	
  3748				if (p->surf_linear128_c[k])
  3749					p->request_size_bytes_chroma[k] = 128;
  3750				else
  3751					p->request_size_bytes_chroma[k] = 256;
  3752	
  3753			} else if (p->full_swath_bytes_l[k] + p->full_swath_bytes_c[k] <= DETBufferSizeInKByteForSwathCalculation * 1024 / 2) {
  3754				p->SwathHeightY[k] = MaximumSwathHeightY[k];
  3755				p->SwathHeightC[k] = MaximumSwathHeightC[k];
  3756				RoundedUpSwathSizeBytesY[k] = p->full_swath_bytes_l[k];
  3757				RoundedUpSwathSizeBytesC[k] = p->full_swath_bytes_c[k];
  3758				p->request_size_bytes_luma[k] = 256;
  3759				p->request_size_bytes_chroma[k] = 256;
  3760	
  3761			} else if (p->full_swath_bytes_l[k] >= 1.5 * p->full_swath_bytes_c[k] && p->full_swath_bytes_l[k] / 2 + p->full_swath_bytes_c[k] <= DETBufferSizeInKByteForSwathCalculation * 1024 / 2) {
  3762				p->SwathHeightY[k] = MaximumSwathHeightY[k] / 2;
  3763				p->SwathHeightC[k] = MaximumSwathHeightC[k];
  3764				RoundedUpSwathSizeBytesY[k] = p->full_swath_bytes_l[k] / 2;
  3765				RoundedUpSwathSizeBytesC[k] = p->full_swath_bytes_c[k];
  3766				p->request_size_bytes_luma[k] = ((p->BytePerPixY[k] == 2) == dml_is_vertical_rotation(p->display_cfg->plane_descriptors[k].composition.rotation_angle)) ? 128 : 64;
  3767				p->request_size_bytes_chroma[k] = 256;
  3768	
  3769			} else if (p->full_swath_bytes_l[k] < 1.5 * p->full_swath_bytes_c[k] && p->full_swath_bytes_l[k] + p->full_swath_bytes_c[k] / 2 <= DETBufferSizeInKByteForSwathCalculation * 1024 / 2) {
  3770				p->SwathHeightY[k] = MaximumSwathHeightY[k];
  3771				p->SwathHeightC[k] = MaximumSwathHeightC[k] / 2;
  3772				RoundedUpSwathSizeBytesY[k] = p->full_swath_bytes_l[k];
  3773				RoundedUpSwathSizeBytesC[k] = p->full_swath_bytes_c[k] / 2;
  3774				p->request_size_bytes_luma[k] = 256;
  3775				p->request_size_bytes_chroma[k] = ((p->BytePerPixC[k] == 2) == dml_is_vertical_rotation(p->display_cfg->plane_descriptors[k].composition.rotation_angle)) ? 128 : 64;
  3776	
  3777			} else {
  3778				p->SwathHeightY[k] = MaximumSwathHeightY[k] / 2;
  3779				p->SwathHeightC[k] = MaximumSwathHeightC[k] / 2;
  3780				RoundedUpSwathSizeBytesY[k] = p->full_swath_bytes_l[k] / 2;
  3781				RoundedUpSwathSizeBytesC[k] = p->full_swath_bytes_c[k] / 2;
  3782				p->request_size_bytes_luma[k] = ((p->BytePerPixY[k] == 2) == dml_is_vertical_rotation(p->display_cfg->plane_descriptors[k].composition.rotation_angle)) ? 128 : 64;;
  3783				p->request_size_bytes_chroma[k] = ((p->BytePerPixC[k] == 2) == dml_is_vertical_rotation(p->display_cfg->plane_descriptors[k].composition.rotation_angle)) ? 128 : 64;;
  3784			}
  3785	
  3786			if (p->SwathHeightC[k] == 0)
  3787				p->request_size_bytes_chroma[k] = 0;
  3788	
  3789			if ((p->full_swath_bytes_l[k] / 2 + p->full_swath_bytes_c[k] / 2 > DETBufferSizeInKByteForSwathCalculation * 1024 / 2) ||
  3790				p->SwathWidth[k] > p->MaximumSwathWidthLuma[k] || (p->SwathHeightC[k] > 0 && p->SwathWidthChroma[k] > p->MaximumSwathWidthChroma[k])) {
  3791				*p->ViewportSizeSupport = false;
  3792				dml2_printf("DML::%s: k=%u full_swath_bytes_l=%u\n", __func__, k, p->full_swath_bytes_l[k]);
  3793				dml2_printf("DML::%s: k=%u full_swath_bytes_c=%u\n", __func__, k, p->full_swath_bytes_c[k]);
  3794				dml2_printf("DML::%s: k=%u DETBufferSizeInKByteForSwathCalculation=%u\n", __func__, k, DETBufferSizeInKByteForSwathCalculation);
  3795				dml2_printf("DML::%s: k=%u SwathWidth=%u\n", __func__, k, p->SwathWidth[k]);
  3796				dml2_printf("DML::%s: k=%u MaximumSwathWidthLuma=%f\n", __func__, k, p->MaximumSwathWidthLuma[k]);
  3797				dml2_printf("DML::%s: k=%u SwathWidthChroma=%d\n", __func__, k, p->SwathWidthChroma[k]);
  3798				dml2_printf("DML::%s: k=%u MaximumSwathWidthChroma=%f\n", __func__, k, p->MaximumSwathWidthChroma[k]);
  3799				p->ViewportSizeSupportPerSurface[k] = false;
  3800			} else {
  3801				p->ViewportSizeSupportPerSurface[k] = true;
  3802			}
  3803	
  3804			if (p->SwathHeightC[k] == 0) {
  3805	#ifdef __DML_VBA_DEBUG__
  3806				dml2_printf("DML::%s: k=%u, All DET will be used for plane0\n", __func__, k);
  3807	#endif
  3808				p->DETBufferSizeY[k] = p->DETBufferSizeInKByte[k] * 1024;
  3809				p->DETBufferSizeC[k] = 0;
  3810			} else if (RoundedUpSwathSizeBytesY[k] <= 1.5 * RoundedUpSwathSizeBytesC[k]) {
  3811	#ifdef __DML_VBA_DEBUG__
  3812				dml2_printf("DML::%s: k=%u, Half DET will be used for plane0, and half for plane1\n", __func__, k);
  3813	#endif
  3814				p->DETBufferSizeY[k] = p->DETBufferSizeInKByte[k] * 1024 / 2;
  3815				p->DETBufferSizeC[k] = p->DETBufferSizeInKByte[k] * 1024 / 2;
  3816			} else {
  3817	#ifdef __DML_VBA_DEBUG__
  3818				dml2_printf("DML::%s: k=%u, 2/3 DET will be used for plane0, and 1/3 for plane1\n", __func__, k);
  3819	#endif
  3820				p->DETBufferSizeY[k] = (unsigned int)(math_floor2(p->DETBufferSizeInKByte[k] * 1024 * 2 / 3, 1024));
  3821				p->DETBufferSizeC[k] = p->DETBufferSizeInKByte[k] * 1024 - p->DETBufferSizeY[k];
  3822			}
  3823	
  3824	#ifdef __DML_VBA_DEBUG__
  3825			dml2_printf("DML::%s: k=%u SwathHeightY = %u\n", __func__, k, p->SwathHeightY[k]);
  3826			dml2_printf("DML::%s: k=%u SwathHeightC = %u\n", __func__, k, p->SwathHeightC[k]);
  3827			dml2_printf("DML::%s: k=%u full_swath_bytes_l = %u\n", __func__, k, p->full_swath_bytes_l[k]);
  3828			dml2_printf("DML::%s: k=%u full_swath_bytes_c = %u\n", __func__, k, p->full_swath_bytes_c[k]);
  3829			dml2_printf("DML::%s: k=%u RoundedUpSwathSizeBytesY = %u\n", __func__, k, RoundedUpSwathSizeBytesY[k]);
  3830			dml2_printf("DML::%s: k=%u RoundedUpSwathSizeBytesC = %u\n", __func__, k, RoundedUpSwathSizeBytesC[k]);
  3831			dml2_printf("DML::%s: k=%u DETBufferSizeInKByte = %u\n", __func__, k, p->DETBufferSizeInKByte[k]);
  3832			dml2_printf("DML::%s: k=%u DETBufferSizeY = %u\n", __func__, k, p->DETBufferSizeY[k]);
  3833			dml2_printf("DML::%s: k=%u DETBufferSizeC = %u\n", __func__, k, p->DETBufferSizeC[k]);
  3834			dml2_printf("DML::%s: k=%u ViewportSizeSupportPerSurface = %u\n", __func__, k, p->ViewportSizeSupportPerSurface[k]);
  3835	#endif
  3836	
  3837		}
  3838	
  3839		*p->compbuf_reserved_space_64b = 2 * p->pixel_chunk_size_kbytes * 1024 / 64;
  3840		if (*p->UnboundedRequestEnabled) {
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Everything check if enabled is true

  3841			*p->compbuf_reserved_space_64b = (unsigned int)math_ceil2(math_max2(*p->compbuf_reserved_space_64b,
  3842				(double)(p->rob_buffer_size_kbytes * 1024 / 64) - (double)(RoundedUpSwathSizeBytesY[SurfaceDoingUnboundedRequest] * TTUFIFODEPTH / (p->mrq_present ? MAXIMUMCOMPRESSION : 1) / 64)), 1.0);
  3843	#ifdef __DML_VBA_DEBUG__
  3844			dml2_printf("DML::%s: RoundedUpSwathSizeBytesY[%d] = %u\n", __func__, SurfaceDoingUnboundedRequest, RoundedUpSwathSizeBytesY[SurfaceDoingUnboundedRequest]);
  3845			dml2_printf("DML::%s: rob_buffer_size_kbytes = %u\n", __func__, p->rob_buffer_size_kbytes);
  3846	#endif
  3847		}
  3848	#ifdef __DML_VBA_DEBUG__
  3849		dml2_printf("DML::%s: compbuf_reserved_space_64b = %u\n", __func__, *p->compbuf_reserved_space_64b);
  3850	#endif
  3851	
  3852		*p->hw_debug5 = false;
  3853		for (unsigned int k = 0; k < p->NumberOfActiveSurfaces; ++k) {
  3854			if (!(p->mrq_present) && (!p->UnboundedRequestEnabled) && (TotalActiveDPP == 1)
                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^
This checks if the pointer to enabled is NULL.  Probably *p was intended.


  3855				&& p->display_cfg->plane_descriptors[k].surface.dcc.enable
  3856				&& ((p->rob_buffer_size_kbytes * 1024 * (p->mrq_present ? MAXIMUMCOMPRESSION : 1)

regards,
dan carpenter



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

  Powered by Linux