* [PATCH] drm/i915: Mark expected switch fall-throughs
@ 2019-07-22 18:12 Gustavo A. R. Silva
2019-07-22 18:24 ` Kees Cook
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Gustavo A. R. Silva @ 2019-07-22 18:12 UTC (permalink / raw)
To: Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, David Airlie, Daniel Vetter
Cc: intel-gfx, dri-devel, linux-kernel, Gustavo A. R. Silva, Kees Cook
In preparation to enabling -Wimplicit-fallthrough, mark switch
cases where we are expecting to fall through.
This patch fixes the following warnings:
drivers/gpu/drm/i915/gem/i915_gem_mman.c: In function ‘i915_gem_fault’:
drivers/gpu/drm/i915/gem/i915_gem_mman.c:342:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
if (!i915_terminally_wedged(i915))
^
drivers/gpu/drm/i915/gem/i915_gem_mman.c:345:2: note: here
case -EAGAIN:
^~~~
drivers/gpu/drm/i915/gem/i915_gem_pages.c: In function ‘i915_gem_object_map’:
./include/linux/compiler.h:78:22: warning: this statement may fall through [-Wimplicit-fallthrough=]
# define unlikely(x) __builtin_expect(!!(x), 0)
^~~~~~~~~~~~~~~~~~~~~~~~~~
./include/asm-generic/bug.h:136:2: note: in expansion of macro ‘unlikely’
unlikely(__ret_warn_on); \
^~~~~~~~
drivers/gpu/drm/i915/i915_utils.h:49:25: note: in expansion of macro ‘WARN’
#define MISSING_CASE(x) WARN(1, "Missing case (%s == %ld)\n", \
^~~~
drivers/gpu/drm/i915/gem/i915_gem_pages.c:270:3: note: in expansion of macro ‘MISSING_CASE’
MISSING_CASE(type);
^~~~~~~~~~~~
drivers/gpu/drm/i915/gem/i915_gem_pages.c:272:2: note: here
case I915_MAP_WB:
^~~~
drivers/gpu/drm/i915/i915_gpu_error.c: In function ‘error_record_engine_registers’:
./include/linux/compiler.h:78:22: warning: this statement may fall through [-Wimplicit-fallthrough=]
# define unlikely(x) __builtin_expect(!!(x), 0)
^~~~~~~~~~~~~~~~~~~~~~~~~~
./include/asm-generic/bug.h:136:2: note: in expansion of macro ‘unlikely’
unlikely(__ret_warn_on); \
^~~~~~~~
drivers/gpu/drm/i915/i915_utils.h:49:25: note: in expansion of macro ‘WARN’
#define MISSING_CASE(x) WARN(1, "Missing case (%s == %ld)\n", \
^~~~
drivers/gpu/drm/i915/i915_gpu_error.c:1196:5: note: in expansion of macro ‘MISSING_CASE’
MISSING_CASE(engine->id);
^~~~~~~~~~~~
drivers/gpu/drm/i915/i915_gpu_error.c:1197:4: note: here
case RCS0:
^~~~
drivers/gpu/drm/i915/display/intel_dp.c: In function ‘intel_dp_get_fia_supported_lane_count’:
./include/linux/compiler.h:78:22: warning: this statement may fall through [-Wimplicit-fallthrough=]
# define unlikely(x) __builtin_expect(!!(x), 0)
^~~~~~~~~~~~~~~~~~~~~~~~~~
./include/asm-generic/bug.h:136:2: note: in expansion of macro ‘unlikely’
unlikely(__ret_warn_on); \
^~~~~~~~
drivers/gpu/drm/i915/i915_utils.h:49:25: note: in expansion of macro ‘WARN’
#define MISSING_CASE(x) WARN(1, "Missing case (%s == %ld)\n", \
^~~~
drivers/gpu/drm/i915/display/intel_dp.c:233:3: note: in expansion of macro ‘MISSING_CASE’
MISSING_CASE(lane_info);
^~~~~~~~~~~~
drivers/gpu/drm/i915/display/intel_dp.c:234:2: note: here
case 1:
^~~~
drivers/gpu/drm/i915/display/intel_display.c: In function ‘check_digital_port_conflicts’:
CC [M] drivers/gpu/drm/nouveau/nvkm/engine/disp/cursgv100.o
drivers/gpu/drm/i915/display/intel_display.c:12043:7: warning: this statement may fall through [-Wimplicit-fallthrough=]
if (WARN_ON(!HAS_DDI(to_i915(dev))))
^
drivers/gpu/drm/i915/display/intel_display.c:12046:3: note: here
case INTEL_OUTPUT_DP:
^~~~
Also, notice that the Makefile is modified in order to stop
ignoring fall-through warnings. The -Wimplicit-fallthrough
option will be enabled globally in v5.3.
Warning level 3 was used: -Wimplicit-fallthrough=3
This patch is part of the ongoing efforts to enable
-Wimplicit-fallthrough.
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
drivers/gpu/drm/i915/Makefile | 1 -
drivers/gpu/drm/i915/display/intel_display.c | 2 +-
drivers/gpu/drm/i915/display/intel_dp.c | 1 +
drivers/gpu/drm/i915/gem/i915_gem_mman.c | 2 +-
drivers/gpu/drm/i915/gem/i915_gem_pages.c | 2 +-
drivers/gpu/drm/i915/i915_gpu_error.c | 1 +
6 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index 91355c2ea8a5..8cace65f50ce 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -16,7 +16,6 @@ subdir-ccflags-y := -Wall -Wextra
subdir-ccflags-y += $(call cc-disable-warning, unused-parameter)
subdir-ccflags-y += $(call cc-disable-warning, type-limits)
subdir-ccflags-y += $(call cc-disable-warning, missing-field-initializers)
-subdir-ccflags-y += $(call cc-disable-warning, implicit-fallthrough)
subdir-ccflags-y += $(call cc-disable-warning, unused-but-set-variable)
# clang warnings
subdir-ccflags-y += $(call cc-disable-warning, sign-compare)
diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index 8592a7d422de..30b97ded6fdd 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -12042,7 +12042,7 @@ static bool check_digital_port_conflicts(struct intel_atomic_state *state)
case INTEL_OUTPUT_DDI:
if (WARN_ON(!HAS_DDI(to_i915(dev))))
break;
- /* else: fall through */
+ /* else, fall through */
case INTEL_OUTPUT_DP:
case INTEL_OUTPUT_HDMI:
case INTEL_OUTPUT_EDP:
diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
index 4336df46fe78..d0fc34826771 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -231,6 +231,7 @@ static int intel_dp_get_fia_supported_lane_count(struct intel_dp *intel_dp)
switch (lane_info) {
default:
MISSING_CASE(lane_info);
+ /* fall through */
case 1:
case 2:
case 4:
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
index 391621ee3cbb..39a661927d8e 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
@@ -341,7 +341,7 @@ vm_fault_t i915_gem_fault(struct vm_fault *vmf)
*/
if (!i915_terminally_wedged(i915))
return VM_FAULT_SIGBUS;
- /* else: fall through */
+ /* else, fall through */
case -EAGAIN:
/*
* EAGAIN means the gpu is hung and we'll wait for the error
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_pages.c b/drivers/gpu/drm/i915/gem/i915_gem_pages.c
index b36ad269f4ea..65eb430cedba 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_pages.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_pages.c
@@ -268,7 +268,7 @@ static void *i915_gem_object_map(const struct drm_i915_gem_object *obj,
switch (type) {
default:
MISSING_CASE(type);
- /* fallthrough to use PAGE_KERNEL anyway */
+ /* fallthrough - to use PAGE_KERNEL anyway */
case I915_MAP_WB:
pgprot = PAGE_KERNEL;
break;
diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c
index b7e9fddef270..41a511d5267f 100644
--- a/drivers/gpu/drm/i915/i915_gpu_error.c
+++ b/drivers/gpu/drm/i915/i915_gpu_error.c
@@ -1194,6 +1194,7 @@ static void error_record_engine_registers(struct i915_gpu_state *error,
switch (engine->id) {
default:
MISSING_CASE(engine->id);
+ /* fall through */
case RCS0:
mmio = RENDER_HWS_PGA_GEN7;
break;
--
2.22.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] drm/i915: Mark expected switch fall-throughs
2019-07-22 18:12 [PATCH] drm/i915: Mark expected switch fall-throughs Gustavo A. R. Silva
@ 2019-07-22 18:24 ` Kees Cook
2019-07-22 18:44 ` ✗ Fi.CI.BAT: failure for drm/i915: Mark expected switch fall-throughs (rev3) Patchwork
2019-07-23 0:00 ` Rodrigo Vivi
2 siblings, 0 replies; 6+ messages in thread
From: Kees Cook @ 2019-07-22 18:24 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, David Airlie,
Daniel Vetter, intel-gfx, dri-devel, linux-kernel
On Mon, Jul 22, 2019 at 01:12:44PM -0500, Gustavo A. R. Silva wrote:
> In preparation to enabling -Wimplicit-fallthrough, mark switch
> cases where we are expecting to fall through.
>
> This patch fixes the following warnings:
>
> drivers/gpu/drm/i915/gem/i915_gem_mman.c: In function ‘i915_gem_fault’:
> drivers/gpu/drm/i915/gem/i915_gem_mman.c:342:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
> if (!i915_terminally_wedged(i915))
> ^
> drivers/gpu/drm/i915/gem/i915_gem_mman.c:345:2: note: here
> case -EAGAIN:
> ^~~~
>
> drivers/gpu/drm/i915/gem/i915_gem_pages.c: In function ‘i915_gem_object_map’:
> ./include/linux/compiler.h:78:22: warning: this statement may fall through [-Wimplicit-fallthrough=]
> # define unlikely(x) __builtin_expect(!!(x), 0)
> ^~~~~~~~~~~~~~~~~~~~~~~~~~
> ./include/asm-generic/bug.h:136:2: note: in expansion of macro ‘unlikely’
> unlikely(__ret_warn_on); \
> ^~~~~~~~
> drivers/gpu/drm/i915/i915_utils.h:49:25: note: in expansion of macro ‘WARN’
> #define MISSING_CASE(x) WARN(1, "Missing case (%s == %ld)\n", \
> ^~~~
> drivers/gpu/drm/i915/gem/i915_gem_pages.c:270:3: note: in expansion of macro ‘MISSING_CASE’
> MISSING_CASE(type);
> ^~~~~~~~~~~~
> drivers/gpu/drm/i915/gem/i915_gem_pages.c:272:2: note: here
> case I915_MAP_WB:
> ^~~~
>
> drivers/gpu/drm/i915/i915_gpu_error.c: In function ‘error_record_engine_registers’:
> ./include/linux/compiler.h:78:22: warning: this statement may fall through [-Wimplicit-fallthrough=]
> # define unlikely(x) __builtin_expect(!!(x), 0)
> ^~~~~~~~~~~~~~~~~~~~~~~~~~
> ./include/asm-generic/bug.h:136:2: note: in expansion of macro ‘unlikely’
> unlikely(__ret_warn_on); \
> ^~~~~~~~
> drivers/gpu/drm/i915/i915_utils.h:49:25: note: in expansion of macro ‘WARN’
> #define MISSING_CASE(x) WARN(1, "Missing case (%s == %ld)\n", \
> ^~~~
> drivers/gpu/drm/i915/i915_gpu_error.c:1196:5: note: in expansion of macro ‘MISSING_CASE’
> MISSING_CASE(engine->id);
> ^~~~~~~~~~~~
> drivers/gpu/drm/i915/i915_gpu_error.c:1197:4: note: here
> case RCS0:
> ^~~~
>
> drivers/gpu/drm/i915/display/intel_dp.c: In function ‘intel_dp_get_fia_supported_lane_count’:
> ./include/linux/compiler.h:78:22: warning: this statement may fall through [-Wimplicit-fallthrough=]
> # define unlikely(x) __builtin_expect(!!(x), 0)
> ^~~~~~~~~~~~~~~~~~~~~~~~~~
> ./include/asm-generic/bug.h:136:2: note: in expansion of macro ‘unlikely’
> unlikely(__ret_warn_on); \
> ^~~~~~~~
> drivers/gpu/drm/i915/i915_utils.h:49:25: note: in expansion of macro ‘WARN’
> #define MISSING_CASE(x) WARN(1, "Missing case (%s == %ld)\n", \
> ^~~~
> drivers/gpu/drm/i915/display/intel_dp.c:233:3: note: in expansion of macro ‘MISSING_CASE’
> MISSING_CASE(lane_info);
> ^~~~~~~~~~~~
> drivers/gpu/drm/i915/display/intel_dp.c:234:2: note: here
> case 1:
> ^~~~
>
> drivers/gpu/drm/i915/display/intel_display.c: In function ‘check_digital_port_conflicts’:
> CC [M] drivers/gpu/drm/nouveau/nvkm/engine/disp/cursgv100.o
> drivers/gpu/drm/i915/display/intel_display.c:12043:7: warning: this statement may fall through [-Wimplicit-fallthrough=]
> if (WARN_ON(!HAS_DDI(to_i915(dev))))
> ^
> drivers/gpu/drm/i915/display/intel_display.c:12046:3: note: here
> case INTEL_OUTPUT_DP:
> ^~~~
>
> Also, notice that the Makefile is modified in order to stop
> ignoring fall-through warnings. The -Wimplicit-fallthrough
> option will be enabled globally in v5.3.
>
> Warning level 3 was used: -Wimplicit-fallthrough=3
>
> This patch is part of the ongoing efforts to enable
> -Wimplicit-fallthrough.
>
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Excellent; I think these are literally the last remaining cases in the
kernel. :)
Reviewed-by: Kees Cook <keescook@chromium.org>
-Kees
> ---
> drivers/gpu/drm/i915/Makefile | 1 -
> drivers/gpu/drm/i915/display/intel_display.c | 2 +-
> drivers/gpu/drm/i915/display/intel_dp.c | 1 +
> drivers/gpu/drm/i915/gem/i915_gem_mman.c | 2 +-
> drivers/gpu/drm/i915/gem/i915_gem_pages.c | 2 +-
> drivers/gpu/drm/i915/i915_gpu_error.c | 1 +
> 6 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
> index 91355c2ea8a5..8cace65f50ce 100644
> --- a/drivers/gpu/drm/i915/Makefile
> +++ b/drivers/gpu/drm/i915/Makefile
> @@ -16,7 +16,6 @@ subdir-ccflags-y := -Wall -Wextra
> subdir-ccflags-y += $(call cc-disable-warning, unused-parameter)
> subdir-ccflags-y += $(call cc-disable-warning, type-limits)
> subdir-ccflags-y += $(call cc-disable-warning, missing-field-initializers)
> -subdir-ccflags-y += $(call cc-disable-warning, implicit-fallthrough)
> subdir-ccflags-y += $(call cc-disable-warning, unused-but-set-variable)
> # clang warnings
> subdir-ccflags-y += $(call cc-disable-warning, sign-compare)
> diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
> index 8592a7d422de..30b97ded6fdd 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -12042,7 +12042,7 @@ static bool check_digital_port_conflicts(struct intel_atomic_state *state)
> case INTEL_OUTPUT_DDI:
> if (WARN_ON(!HAS_DDI(to_i915(dev))))
> break;
> - /* else: fall through */
> + /* else, fall through */
> case INTEL_OUTPUT_DP:
> case INTEL_OUTPUT_HDMI:
> case INTEL_OUTPUT_EDP:
> diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
> index 4336df46fe78..d0fc34826771 100644
> --- a/drivers/gpu/drm/i915/display/intel_dp.c
> +++ b/drivers/gpu/drm/i915/display/intel_dp.c
> @@ -231,6 +231,7 @@ static int intel_dp_get_fia_supported_lane_count(struct intel_dp *intel_dp)
> switch (lane_info) {
> default:
> MISSING_CASE(lane_info);
> + /* fall through */
> case 1:
> case 2:
> case 4:
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> index 391621ee3cbb..39a661927d8e 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> @@ -341,7 +341,7 @@ vm_fault_t i915_gem_fault(struct vm_fault *vmf)
> */
> if (!i915_terminally_wedged(i915))
> return VM_FAULT_SIGBUS;
> - /* else: fall through */
> + /* else, fall through */
> case -EAGAIN:
> /*
> * EAGAIN means the gpu is hung and we'll wait for the error
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_pages.c b/drivers/gpu/drm/i915/gem/i915_gem_pages.c
> index b36ad269f4ea..65eb430cedba 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_pages.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_pages.c
> @@ -268,7 +268,7 @@ static void *i915_gem_object_map(const struct drm_i915_gem_object *obj,
> switch (type) {
> default:
> MISSING_CASE(type);
> - /* fallthrough to use PAGE_KERNEL anyway */
> + /* fallthrough - to use PAGE_KERNEL anyway */
> case I915_MAP_WB:
> pgprot = PAGE_KERNEL;
> break;
> diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c
> index b7e9fddef270..41a511d5267f 100644
> --- a/drivers/gpu/drm/i915/i915_gpu_error.c
> +++ b/drivers/gpu/drm/i915/i915_gpu_error.c
> @@ -1194,6 +1194,7 @@ static void error_record_engine_registers(struct i915_gpu_state *error,
> switch (engine->id) {
> default:
> MISSING_CASE(engine->id);
> + /* fall through */
> case RCS0:
> mmio = RENDER_HWS_PGA_GEN7;
> break;
> --
> 2.22.0
>
--
Kees Cook
^ permalink raw reply [flat|nested] 6+ messages in thread
* ✗ Fi.CI.BAT: failure for drm/i915: Mark expected switch fall-throughs (rev3)
2019-07-22 18:12 [PATCH] drm/i915: Mark expected switch fall-throughs Gustavo A. R. Silva
2019-07-22 18:24 ` Kees Cook
@ 2019-07-22 18:44 ` Patchwork
2019-07-23 0:00 ` Rodrigo Vivi
2 siblings, 0 replies; 6+ messages in thread
From: Patchwork @ 2019-07-22 18:44 UTC (permalink / raw)
To: Gustavo A. R. Silva; +Cc: intel-gfx
== Series Details ==
Series: drm/i915: Mark expected switch fall-throughs (rev3)
URL : https://patchwork.freedesktop.org/series/34495/
State : failure
== Summary ==
Applying: drm/i915: Mark expected switch fall-throughs
Using index info to reconstruct a base tree...
M drivers/gpu/drm/i915/Makefile
M drivers/gpu/drm/i915/display/intel_display.c
M drivers/gpu/drm/i915/display/intel_dp.c
M drivers/gpu/drm/i915/gem/i915_gem_mman.c
M drivers/gpu/drm/i915/i915_gpu_error.c
Falling back to patching base and 3-way merge...
Auto-merging drivers/gpu/drm/i915/i915_gpu_error.c
Auto-merging drivers/gpu/drm/i915/gem/i915_gem_mman.c
Auto-merging drivers/gpu/drm/i915/display/intel_dp.c
CONFLICT (content): Merge conflict in drivers/gpu/drm/i915/display/intel_dp.c
Auto-merging drivers/gpu/drm/i915/display/intel_display.c
Auto-merging drivers/gpu/drm/i915/Makefile
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch' to see the failed patch
Patch failed at 0001 drm/i915: Mark expected switch fall-throughs
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Intel-gfx] [PATCH] drm/i915: Mark expected switch fall-throughs
2019-07-22 18:12 [PATCH] drm/i915: Mark expected switch fall-throughs Gustavo A. R. Silva
@ 2019-07-23 0:00 ` Rodrigo Vivi
2019-07-22 18:44 ` ✗ Fi.CI.BAT: failure for drm/i915: Mark expected switch fall-throughs (rev3) Patchwork
2019-07-23 0:00 ` Rodrigo Vivi
2 siblings, 0 replies; 6+ messages in thread
From: Rodrigo Vivi @ 2019-07-23 0:00 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Jani Nikula, Joonas Lahtinen, David Airlie, Daniel Vetter,
Kees Cook, intel-gfx, linux-kernel, dri-devel
Hi Gustavo,
could you please rebase on top of drm-tip and resend it please?
Thanks,
Rodrigo.
On Mon, Jul 22, 2019 at 01:12:44PM -0500, Gustavo A. R. Silva wrote:
> In preparation to enabling -Wimplicit-fallthrough, mark switch
> cases where we are expecting to fall through.
>
> This patch fixes the following warnings:
>
> drivers/gpu/drm/i915/gem/i915_gem_mman.c: In function ‘i915_gem_fault’:
> drivers/gpu/drm/i915/gem/i915_gem_mman.c:342:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
> if (!i915_terminally_wedged(i915))
> ^
> drivers/gpu/drm/i915/gem/i915_gem_mman.c:345:2: note: here
> case -EAGAIN:
> ^~~~
>
> drivers/gpu/drm/i915/gem/i915_gem_pages.c: In function ‘i915_gem_object_map’:
> ./include/linux/compiler.h:78:22: warning: this statement may fall through [-Wimplicit-fallthrough=]
> # define unlikely(x) __builtin_expect(!!(x), 0)
> ^~~~~~~~~~~~~~~~~~~~~~~~~~
> ./include/asm-generic/bug.h:136:2: note: in expansion of macro ‘unlikely’
> unlikely(__ret_warn_on); \
> ^~~~~~~~
> drivers/gpu/drm/i915/i915_utils.h:49:25: note: in expansion of macro ‘WARN’
> #define MISSING_CASE(x) WARN(1, "Missing case (%s == %ld)\n", \
> ^~~~
> drivers/gpu/drm/i915/gem/i915_gem_pages.c:270:3: note: in expansion of macro ‘MISSING_CASE’
> MISSING_CASE(type);
> ^~~~~~~~~~~~
> drivers/gpu/drm/i915/gem/i915_gem_pages.c:272:2: note: here
> case I915_MAP_WB:
> ^~~~
>
> drivers/gpu/drm/i915/i915_gpu_error.c: In function ‘error_record_engine_registers’:
> ./include/linux/compiler.h:78:22: warning: this statement may fall through [-Wimplicit-fallthrough=]
> # define unlikely(x) __builtin_expect(!!(x), 0)
> ^~~~~~~~~~~~~~~~~~~~~~~~~~
> ./include/asm-generic/bug.h:136:2: note: in expansion of macro ‘unlikely’
> unlikely(__ret_warn_on); \
> ^~~~~~~~
> drivers/gpu/drm/i915/i915_utils.h:49:25: note: in expansion of macro ‘WARN’
> #define MISSING_CASE(x) WARN(1, "Missing case (%s == %ld)\n", \
> ^~~~
> drivers/gpu/drm/i915/i915_gpu_error.c:1196:5: note: in expansion of macro ‘MISSING_CASE’
> MISSING_CASE(engine->id);
> ^~~~~~~~~~~~
> drivers/gpu/drm/i915/i915_gpu_error.c:1197:4: note: here
> case RCS0:
> ^~~~
>
> drivers/gpu/drm/i915/display/intel_dp.c: In function ‘intel_dp_get_fia_supported_lane_count’:
> ./include/linux/compiler.h:78:22: warning: this statement may fall through [-Wimplicit-fallthrough=]
> # define unlikely(x) __builtin_expect(!!(x), 0)
> ^~~~~~~~~~~~~~~~~~~~~~~~~~
> ./include/asm-generic/bug.h:136:2: note: in expansion of macro ‘unlikely’
> unlikely(__ret_warn_on); \
> ^~~~~~~~
> drivers/gpu/drm/i915/i915_utils.h:49:25: note: in expansion of macro ‘WARN’
> #define MISSING_CASE(x) WARN(1, "Missing case (%s == %ld)\n", \
> ^~~~
> drivers/gpu/drm/i915/display/intel_dp.c:233:3: note: in expansion of macro ‘MISSING_CASE’
> MISSING_CASE(lane_info);
> ^~~~~~~~~~~~
> drivers/gpu/drm/i915/display/intel_dp.c:234:2: note: here
> case 1:
> ^~~~
>
> drivers/gpu/drm/i915/display/intel_display.c: In function ‘check_digital_port_conflicts’:
> CC [M] drivers/gpu/drm/nouveau/nvkm/engine/disp/cursgv100.o
> drivers/gpu/drm/i915/display/intel_display.c:12043:7: warning: this statement may fall through [-Wimplicit-fallthrough=]
> if (WARN_ON(!HAS_DDI(to_i915(dev))))
> ^
> drivers/gpu/drm/i915/display/intel_display.c:12046:3: note: here
> case INTEL_OUTPUT_DP:
> ^~~~
>
> Also, notice that the Makefile is modified in order to stop
> ignoring fall-through warnings. The -Wimplicit-fallthrough
> option will be enabled globally in v5.3.
>
> Warning level 3 was used: -Wimplicit-fallthrough=3
>
> This patch is part of the ongoing efforts to enable
> -Wimplicit-fallthrough.
>
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
> drivers/gpu/drm/i915/Makefile | 1 -
> drivers/gpu/drm/i915/display/intel_display.c | 2 +-
> drivers/gpu/drm/i915/display/intel_dp.c | 1 +
> drivers/gpu/drm/i915/gem/i915_gem_mman.c | 2 +-
> drivers/gpu/drm/i915/gem/i915_gem_pages.c | 2 +-
> drivers/gpu/drm/i915/i915_gpu_error.c | 1 +
> 6 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
> index 91355c2ea8a5..8cace65f50ce 100644
> --- a/drivers/gpu/drm/i915/Makefile
> +++ b/drivers/gpu/drm/i915/Makefile
> @@ -16,7 +16,6 @@ subdir-ccflags-y := -Wall -Wextra
> subdir-ccflags-y += $(call cc-disable-warning, unused-parameter)
> subdir-ccflags-y += $(call cc-disable-warning, type-limits)
> subdir-ccflags-y += $(call cc-disable-warning, missing-field-initializers)
> -subdir-ccflags-y += $(call cc-disable-warning, implicit-fallthrough)
> subdir-ccflags-y += $(call cc-disable-warning, unused-but-set-variable)
> # clang warnings
> subdir-ccflags-y += $(call cc-disable-warning, sign-compare)
> diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
> index 8592a7d422de..30b97ded6fdd 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -12042,7 +12042,7 @@ static bool check_digital_port_conflicts(struct intel_atomic_state *state)
> case INTEL_OUTPUT_DDI:
> if (WARN_ON(!HAS_DDI(to_i915(dev))))
> break;
> - /* else: fall through */
> + /* else, fall through */
> case INTEL_OUTPUT_DP:
> case INTEL_OUTPUT_HDMI:
> case INTEL_OUTPUT_EDP:
> diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
> index 4336df46fe78..d0fc34826771 100644
> --- a/drivers/gpu/drm/i915/display/intel_dp.c
> +++ b/drivers/gpu/drm/i915/display/intel_dp.c
> @@ -231,6 +231,7 @@ static int intel_dp_get_fia_supported_lane_count(struct intel_dp *intel_dp)
> switch (lane_info) {
> default:
> MISSING_CASE(lane_info);
> + /* fall through */
> case 1:
> case 2:
> case 4:
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> index 391621ee3cbb..39a661927d8e 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> @@ -341,7 +341,7 @@ vm_fault_t i915_gem_fault(struct vm_fault *vmf)
> */
> if (!i915_terminally_wedged(i915))
> return VM_FAULT_SIGBUS;
> - /* else: fall through */
> + /* else, fall through */
> case -EAGAIN:
> /*
> * EAGAIN means the gpu is hung and we'll wait for the error
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_pages.c b/drivers/gpu/drm/i915/gem/i915_gem_pages.c
> index b36ad269f4ea..65eb430cedba 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_pages.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_pages.c
> @@ -268,7 +268,7 @@ static void *i915_gem_object_map(const struct drm_i915_gem_object *obj,
> switch (type) {
> default:
> MISSING_CASE(type);
> - /* fallthrough to use PAGE_KERNEL anyway */
> + /* fallthrough - to use PAGE_KERNEL anyway */
> case I915_MAP_WB:
> pgprot = PAGE_KERNEL;
> break;
> diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c
> index b7e9fddef270..41a511d5267f 100644
> --- a/drivers/gpu/drm/i915/i915_gpu_error.c
> +++ b/drivers/gpu/drm/i915/i915_gpu_error.c
> @@ -1194,6 +1194,7 @@ static void error_record_engine_registers(struct i915_gpu_state *error,
> switch (engine->id) {
> default:
> MISSING_CASE(engine->id);
> + /* fall through */
> case RCS0:
> mmio = RENDER_HWS_PGA_GEN7;
> break;
> --
> 2.22.0
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Intel-gfx] [PATCH] drm/i915: Mark expected switch fall-throughs
@ 2019-07-23 0:00 ` Rodrigo Vivi
0 siblings, 0 replies; 6+ messages in thread
From: Rodrigo Vivi @ 2019-07-23 0:00 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Kees Cook, David Airlie, intel-gfx, linux-kernel, dri-devel
Hi Gustavo,
could you please rebase on top of drm-tip and resend it please?
Thanks,
Rodrigo.
On Mon, Jul 22, 2019 at 01:12:44PM -0500, Gustavo A. R. Silva wrote:
> In preparation to enabling -Wimplicit-fallthrough, mark switch
> cases where we are expecting to fall through.
>
> This patch fixes the following warnings:
>
> drivers/gpu/drm/i915/gem/i915_gem_mman.c: In function ‘i915_gem_fault’:
> drivers/gpu/drm/i915/gem/i915_gem_mman.c:342:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
> if (!i915_terminally_wedged(i915))
> ^
> drivers/gpu/drm/i915/gem/i915_gem_mman.c:345:2: note: here
> case -EAGAIN:
> ^~~~
>
> drivers/gpu/drm/i915/gem/i915_gem_pages.c: In function ‘i915_gem_object_map’:
> ./include/linux/compiler.h:78:22: warning: this statement may fall through [-Wimplicit-fallthrough=]
> # define unlikely(x) __builtin_expect(!!(x), 0)
> ^~~~~~~~~~~~~~~~~~~~~~~~~~
> ./include/asm-generic/bug.h:136:2: note: in expansion of macro ‘unlikely’
> unlikely(__ret_warn_on); \
> ^~~~~~~~
> drivers/gpu/drm/i915/i915_utils.h:49:25: note: in expansion of macro ‘WARN’
> #define MISSING_CASE(x) WARN(1, "Missing case (%s == %ld)\n", \
> ^~~~
> drivers/gpu/drm/i915/gem/i915_gem_pages.c:270:3: note: in expansion of macro ‘MISSING_CASE’
> MISSING_CASE(type);
> ^~~~~~~~~~~~
> drivers/gpu/drm/i915/gem/i915_gem_pages.c:272:2: note: here
> case I915_MAP_WB:
> ^~~~
>
> drivers/gpu/drm/i915/i915_gpu_error.c: In function ‘error_record_engine_registers’:
> ./include/linux/compiler.h:78:22: warning: this statement may fall through [-Wimplicit-fallthrough=]
> # define unlikely(x) __builtin_expect(!!(x), 0)
> ^~~~~~~~~~~~~~~~~~~~~~~~~~
> ./include/asm-generic/bug.h:136:2: note: in expansion of macro ‘unlikely’
> unlikely(__ret_warn_on); \
> ^~~~~~~~
> drivers/gpu/drm/i915/i915_utils.h:49:25: note: in expansion of macro ‘WARN’
> #define MISSING_CASE(x) WARN(1, "Missing case (%s == %ld)\n", \
> ^~~~
> drivers/gpu/drm/i915/i915_gpu_error.c:1196:5: note: in expansion of macro ‘MISSING_CASE’
> MISSING_CASE(engine->id);
> ^~~~~~~~~~~~
> drivers/gpu/drm/i915/i915_gpu_error.c:1197:4: note: here
> case RCS0:
> ^~~~
>
> drivers/gpu/drm/i915/display/intel_dp.c: In function ‘intel_dp_get_fia_supported_lane_count’:
> ./include/linux/compiler.h:78:22: warning: this statement may fall through [-Wimplicit-fallthrough=]
> # define unlikely(x) __builtin_expect(!!(x), 0)
> ^~~~~~~~~~~~~~~~~~~~~~~~~~
> ./include/asm-generic/bug.h:136:2: note: in expansion of macro ‘unlikely’
> unlikely(__ret_warn_on); \
> ^~~~~~~~
> drivers/gpu/drm/i915/i915_utils.h:49:25: note: in expansion of macro ‘WARN’
> #define MISSING_CASE(x) WARN(1, "Missing case (%s == %ld)\n", \
> ^~~~
> drivers/gpu/drm/i915/display/intel_dp.c:233:3: note: in expansion of macro ‘MISSING_CASE’
> MISSING_CASE(lane_info);
> ^~~~~~~~~~~~
> drivers/gpu/drm/i915/display/intel_dp.c:234:2: note: here
> case 1:
> ^~~~
>
> drivers/gpu/drm/i915/display/intel_display.c: In function ‘check_digital_port_conflicts’:
> CC [M] drivers/gpu/drm/nouveau/nvkm/engine/disp/cursgv100.o
> drivers/gpu/drm/i915/display/intel_display.c:12043:7: warning: this statement may fall through [-Wimplicit-fallthrough=]
> if (WARN_ON(!HAS_DDI(to_i915(dev))))
> ^
> drivers/gpu/drm/i915/display/intel_display.c:12046:3: note: here
> case INTEL_OUTPUT_DP:
> ^~~~
>
> Also, notice that the Makefile is modified in order to stop
> ignoring fall-through warnings. The -Wimplicit-fallthrough
> option will be enabled globally in v5.3.
>
> Warning level 3 was used: -Wimplicit-fallthrough=3
>
> This patch is part of the ongoing efforts to enable
> -Wimplicit-fallthrough.
>
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
> drivers/gpu/drm/i915/Makefile | 1 -
> drivers/gpu/drm/i915/display/intel_display.c | 2 +-
> drivers/gpu/drm/i915/display/intel_dp.c | 1 +
> drivers/gpu/drm/i915/gem/i915_gem_mman.c | 2 +-
> drivers/gpu/drm/i915/gem/i915_gem_pages.c | 2 +-
> drivers/gpu/drm/i915/i915_gpu_error.c | 1 +
> 6 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
> index 91355c2ea8a5..8cace65f50ce 100644
> --- a/drivers/gpu/drm/i915/Makefile
> +++ b/drivers/gpu/drm/i915/Makefile
> @@ -16,7 +16,6 @@ subdir-ccflags-y := -Wall -Wextra
> subdir-ccflags-y += $(call cc-disable-warning, unused-parameter)
> subdir-ccflags-y += $(call cc-disable-warning, type-limits)
> subdir-ccflags-y += $(call cc-disable-warning, missing-field-initializers)
> -subdir-ccflags-y += $(call cc-disable-warning, implicit-fallthrough)
> subdir-ccflags-y += $(call cc-disable-warning, unused-but-set-variable)
> # clang warnings
> subdir-ccflags-y += $(call cc-disable-warning, sign-compare)
> diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
> index 8592a7d422de..30b97ded6fdd 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -12042,7 +12042,7 @@ static bool check_digital_port_conflicts(struct intel_atomic_state *state)
> case INTEL_OUTPUT_DDI:
> if (WARN_ON(!HAS_DDI(to_i915(dev))))
> break;
> - /* else: fall through */
> + /* else, fall through */
> case INTEL_OUTPUT_DP:
> case INTEL_OUTPUT_HDMI:
> case INTEL_OUTPUT_EDP:
> diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
> index 4336df46fe78..d0fc34826771 100644
> --- a/drivers/gpu/drm/i915/display/intel_dp.c
> +++ b/drivers/gpu/drm/i915/display/intel_dp.c
> @@ -231,6 +231,7 @@ static int intel_dp_get_fia_supported_lane_count(struct intel_dp *intel_dp)
> switch (lane_info) {
> default:
> MISSING_CASE(lane_info);
> + /* fall through */
> case 1:
> case 2:
> case 4:
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> index 391621ee3cbb..39a661927d8e 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> @@ -341,7 +341,7 @@ vm_fault_t i915_gem_fault(struct vm_fault *vmf)
> */
> if (!i915_terminally_wedged(i915))
> return VM_FAULT_SIGBUS;
> - /* else: fall through */
> + /* else, fall through */
> case -EAGAIN:
> /*
> * EAGAIN means the gpu is hung and we'll wait for the error
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_pages.c b/drivers/gpu/drm/i915/gem/i915_gem_pages.c
> index b36ad269f4ea..65eb430cedba 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_pages.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_pages.c
> @@ -268,7 +268,7 @@ static void *i915_gem_object_map(const struct drm_i915_gem_object *obj,
> switch (type) {
> default:
> MISSING_CASE(type);
> - /* fallthrough to use PAGE_KERNEL anyway */
> + /* fallthrough - to use PAGE_KERNEL anyway */
> case I915_MAP_WB:
> pgprot = PAGE_KERNEL;
> break;
> diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c
> index b7e9fddef270..41a511d5267f 100644
> --- a/drivers/gpu/drm/i915/i915_gpu_error.c
> +++ b/drivers/gpu/drm/i915/i915_gpu_error.c
> @@ -1194,6 +1194,7 @@ static void error_record_engine_registers(struct i915_gpu_state *error,
> switch (engine->id) {
> default:
> MISSING_CASE(engine->id);
> + /* fall through */
> case RCS0:
> mmio = RENDER_HWS_PGA_GEN7;
> break;
> --
> 2.22.0
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Intel-gfx] [PATCH] drm/i915: Mark expected switch fall-throughs
2017-12-04 15:20 ` Gustavo A. R. Silva
@ 2017-12-04 18:11 ` Daniel Vetter
0 siblings, 0 replies; 6+ messages in thread
From: Daniel Vetter @ 2017-12-04 18:11 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Joonas Lahtinen, Kees Cook, David Airlie, intel-gfx,
Linux Kernel Mailing List, dri-devel, Rodrigo Vivi
On Mon, Dec 4, 2017 at 4:20 PM, Gustavo A. R. Silva
<garsilva@embeddedor.com> wrote:
> Hi Joonas,
>
> Quoting Joonas Lahtinen <joonas.lahtinen@linux.intel.com>:
>
>> On Mon, 2017-11-27 at 16:17 -0600, Gustavo A. R. Silva wrote:
>>>
>>> In preparation to enabling -Wimplicit-fallthrough, mark switch cases
>>> where we are expecting to fall through.
>>
>>
>> I have to say I'm totally not sold on regexps matching comment
>> contents. Was something more explicit ever considered? Like:
>>
>> #define FALLTHROUGH __attribute__((fallthrough));
>>
>> With the appropriate version checks, of course.
>>
>
> One of the arguments is that comments lets us leverage the existing static
> analyzers.
>
> We've been discussing this during the last week, feel free to join the
> discussion:
>
> http://www.spinics.net/lists/kernel/msg2659908.html
> http://www.spinics.net/lists/kernel/msg2659906.html
If we go with existing rules, then either pls patch coding style, or
be a bit more liberal in what you accept. E.g. fallthrough vs fall
through seems a bit a bikeshed (and will be an endless source of work
for you).
I'd also claim that "this shouldn't happen, dump a backtrace and hope
for the best" style macros like i915's MISSING_CASE or WARN_ON (as the
only thing) should count as an auto-fallthrough annotation.
>From a quick look, that would cover everything in your patch.
-Daniel
>
> Thanks!
> --
> Gustavo A. R. Silva
>
>
>
>
>
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-07-23 0:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-22 18:12 [PATCH] drm/i915: Mark expected switch fall-throughs Gustavo A. R. Silva
2019-07-22 18:24 ` Kees Cook
2019-07-22 18:44 ` ✗ Fi.CI.BAT: failure for drm/i915: Mark expected switch fall-throughs (rev3) Patchwork
2019-07-23 0:00 ` [Intel-gfx] [PATCH] drm/i915: Mark expected switch fall-throughs Rodrigo Vivi
2019-07-23 0:00 ` Rodrigo Vivi
-- strict thread matches above, loose matches on Subject: below --
2017-11-27 22:17 Gustavo A. R. Silva
2017-12-04 10:35 ` Joonas Lahtinen
2017-12-04 15:20 ` Gustavo A. R. Silva
2017-12-04 18:11 ` [Intel-gfx] " Daniel Vetter
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.