[RFC] Improve on using delays greater than a few milliseconds

From: Paul Menzel
Date: Sat Jul 28 2018 - 15:26:56 EST


Dear Linux folks,


Trying to decrease the boot time, mostly with ftrace by using [1], I noticed a lot of delays. Out of curiosity I searched for all calls of `mdelay()` in the driver *amdgpu*.

$ git grep mdelay drivers/gpu/drm/amd/amdgpu
drivers/gpu/drm/amd/amdgpu/atom.c: mdelay(count);
drivers/gpu/drm/amd/amdgpu/atombios_encoders.c: mdelay(1);
drivers/gpu/drm/amd/amdgpu/cik.c: mdelay(10);
drivers/gpu/drm/amd/amdgpu/cik.c: mdelay(10);
drivers/gpu/drm/amd/amdgpu/cik.c: mdelay(10);
drivers/gpu/drm/amd/amdgpu/cik.c: mdelay(100);
drivers/gpu/drm/amd/amdgpu/cik_ih.c: mdelay(1);
drivers/gpu/drm/amd/amdgpu/cz_ih.c: mdelay(1);
drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c: mdelay(1);
drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c: mdelay(1);
drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c: mdelay(1);
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c: mdelay(1);
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c: mdelay(1);
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c: mdelay(1);
drivers/gpu/drm/amd/amdgpu/iceland_ih.c: mdelay(1);
drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c: mdelay(5);
drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c: mdelay(1);
drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c: mdelay(5);
drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c: mdelay(5);
drivers/gpu/drm/amd/amdgpu/psp_v10_0.c: mdelay(20);
drivers/gpu/drm/amd/amdgpu/psp_v10_0.c: mdelay(20);
drivers/gpu/drm/amd/amdgpu/psp_v3_1.c: mdelay(20);
drivers/gpu/drm/amd/amdgpu/psp_v3_1.c: mdelay(20);
drivers/gpu/drm/amd/amdgpu/psp_v3_1.c: mdelay(20);
drivers/gpu/drm/amd/amdgpu/psp_v3_1.c: mdelay(20);
drivers/gpu/drm/amd/amdgpu/psp_v3_1.c: mdelay(1000);
drivers/gpu/drm/amd/amdgpu/si.c: mdelay(100);
drivers/gpu/drm/amd/amdgpu/si_ih.c: mdelay(1);
drivers/gpu/drm/amd/amdgpu/tonga_ih.c: mdelay(1);
drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c: mdelay(5);
drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c: mdelay(10);
drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c: mdelay(10);
drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c: mdelay(10);
drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c: mdelay(10);
drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c: mdelay(1);
drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c: mdelay(1);
drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c: mdelay(1);
drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c: mdelay(5);
drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c: mdelay(20);
drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c: mdelay(30);
drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c: mdelay(1);
drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c: mdelay(5);
drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c: mdelay(5);
drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c: mdelay(5);
drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c: mdelay(10);
drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c: mdelay(10);
drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c: mdelay(10);
drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c: mdelay(10);
drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c: mdelay(1);
drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c: mdelay(5);
drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c: mdelay(5);
drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c: mdelay(1);
drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c: mdelay(5);
drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c: mdelay(5);
drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c: mdelay(5);
drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c: mdelay(10);
drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c: mdelay(10);
drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c: mdelay(10);
drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c: mdelay(10);
drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c: mdelay(1);
drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c: mdelay(5);
drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c: mdelay(5);
drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c: mdelay(1);
drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c: mdelay(5);
drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c: mdelay(5);
drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c: mdelay(10);
drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c: mdelay(10);
drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c: mdelay(10);
drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c: mdelay(10);
drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c: mdelay(1);
drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c: mdelay(5);
drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c: mdelay(5);
drivers/gpu/drm/amd/amdgpu/vce_v2_0.c: mdelay(10);
drivers/gpu/drm/amd/amdgpu/vce_v2_0.c: mdelay(10);
drivers/gpu/drm/amd/amdgpu/vce_v2_0.c: mdelay(10);
drivers/gpu/drm/amd/amdgpu/vce_v2_0.c: mdelay(10);
drivers/gpu/drm/amd/amdgpu/vce_v2_0.c: mdelay(100);
drivers/gpu/drm/amd/amdgpu/vce_v2_0.c: mdelay(1);
drivers/gpu/drm/amd/amdgpu/vce_v2_0.c: mdelay(5);
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c: mdelay(10);
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c: mdelay(10);
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c: mdelay(10);
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c: mdelay(100);
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c: mdelay(5);
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c: mdelay(5);
drivers/gpu/drm/amd/amdgpu/vce_v4_0.c: mdelay(10);
drivers/gpu/drm/amd/amdgpu/vce_v4_0.c: mdelay(10);
drivers/gpu/drm/amd/amdgpu/vce_v4_0.c: mdelay(10);
drivers/gpu/drm/amd/amdgpu/vce_v4_0.c: mdelay(100);
drivers/gpu/drm/amd/amdgpu/vce_v4_0.c: mdelay(5);
drivers/gpu/drm/amd/amdgpu/vce_v4_0.c: mdelay(5);
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c: mdelay(1);
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c: mdelay(5);
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c: mdelay(5);
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c: mdelay(10);
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c: mdelay(10);
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c: mdelay(10);
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c: mdelay(10);
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c: mdelay(1);
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c: mdelay(5);
drivers/gpu/drm/amd/amdgpu/vega10_ih.c: mdelay(1);
drivers/gpu/drm/amd/amdgpu/vi.c: mdelay(10);
drivers/gpu/drm/amd/amdgpu/vi.c: mdelay(10);
drivers/gpu/drm/amd/amdgpu/vi.c: mdelay(10);

Looking through it, there are a lot of delays over ten milliseconds. Quite a few of 100 ms and once one second. I am wondring, why in these cases a while loop cannot check if the condition, that is waited for, became true. If the hardware engineers really designed the device that way, they should be contacted to improve that design in the future.

Do you you think the situation could be improved? I know, I am not a amdgfx developer â that datasheets are (often) missing â, but could the proposal below help? That could be checked during reviews.

For delays higher than five seconds, a comment must be added, why that delay is needed. Citing the datasheet name, revision and section is enough.

Additionally, for delays greater than 20 ms, a FIXME comment should be added and the situation explained in the commit message.


Kind regards,

Paul


[1]: https://01.org/suspendresume