Files
linux-nvgpu/drivers/gpu
Jon Hunter d1b34e50e2 gpu: nvgpu: Fix build for Linux v5.14-rc2
Upstream Linux kernel commits b7eb335e26a9 ("Makefile: Enable
-Wimplicit-fallthrough for Clang") and d936eb238744 ('Revert "Makefile:
Enable -Wimplicit-fallthrough for Clang"') have the net effect of
updating the compiler flag -Wimplicit-fallthrough from
-Wimplicit-fallthrough= to -Wimplicit-fallthrough=5. This causes the
following build error to be seen ...

 nvgpu/drivers/gpu/nvgpu/common/pmu/clk/clk_prog.c:1042:15: error:
 	this statement may fall through [-Werror=implicit-fallthrough=]
 1042 |    step_count = (freq_step_size_mhz == 0U) ? 0U :
      |    ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1043 |      (u8)(p1xmaster->super.freq_max_mhz -
      |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1044 |       *pfreqmaxlastmhz - 1U) /
      |       ~~~~~~~~~~~~~~~~~~~~~~~~
 1045 |      freq_step_size_mhz;
      |      ~~~~~~~~~~~~~~~~~~
 nvgpu/drivers/gpu/nvgpu/common/pmu/clk/clk_prog.c:1048:3: note: here
 1048 |   case CTRL_CLK_PROG_1X_SOURCE_ONE_SOURCE:
      |   ^~~~
 cc1: all warnings being treated as errors
 scripts/Makefile.build:271: recipe for target
 	'nvgpu/drivers/gpu/nvgpu/common/pmu/clk/clk_prog.o' failed

Per commit d936eb238744 ('Revert "Makefile: Enable -Wimplicit-fallthrough
for Clang"'), by setting -Wimplicit-fallthrough=5 [0], the explicit
'fall-through' comments in the code are not recognised by the compiler
and cause the above error to be seen. This could be fixed by simply
replacing the 'fall-through' comment with the 'fallthrough;' statement.
However, this requires newer versions of GCC that support it. The
simplest way to fix this error is by ensuring that
-Wimplicit-fallthrough=3 for NVGPU so that fallthrough comments are
recognised by the compiler. Note that we still need to check that GCC
supports this option because older versions do not. It should be noted
that -Wimplicit-fallthrough=3 is the default set by -Wextra. See the
GCC warnings options document [0] for more details.

Bug 3340525

Link: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html [0]
Change-Id: Ia56e4343143185460a37f8a7b0dd229f005acbb9
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2567440
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2582509
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Rohit Khanna <rokhanna@nvidia.com>
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Tested-by: Rohit Khanna <rokhanna@nvidia.com>
GVS: Gerrit_Virtual_Submit
2021-09-01 18:49:59 -07:00
..