linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/i915: Mark check_shadow_context_ppgtt as maybe unused
@ 2020-05-16  2:35 Nathan Chancellor
  2020-05-18  6:09 ` Zhenyu Wang
  0 siblings, 1 reply; 2+ messages in thread
From: Nathan Chancellor @ 2020-05-16  2:35 UTC (permalink / raw)
  To: Zhenyu Wang, Zhi Wang, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi
  Cc: intel-gvt-dev, intel-gfx, dri-devel, linux-kernel,
	clang-built-linux, Nathan Chancellor

When CONFIG_DRM_I915_DEBUG_GEM is not set, clang warns:

drivers/gpu/drm/i915/gvt/scheduler.c:884:1: warning: function
'check_shadow_context_ppgtt' is not needed and will not be emitted
[-Wunneeded-internal-declaration]
check_shadow_context_ppgtt(struct execlist_ring_context *c, struct
intel_vgpu_mm *m)
^
1 warning generated.

This warning is similar to -Wunused-function but rather than warning
that the function is completely unused, it warns that it is used in some
expression within the file but that expression will be evaluated to a
constant or be optimized away in the final assembly, essentially making
it appeared used but really isn't. Usually, this happens when a function
or variable is only used in sizeof, where it will appear to be used but
will be evaluated at compile time and not be required to be emitted.

In this case, the function is only used in GEM_BUG_ON, which is defined
as BUILD_BUG_ON_INVALID, which intentionally follows this pattern. To
fix this warning, add __maybe_unused to make it clear that this is
intentional depending on the configuration.

Fixes: bec3df930fbd ("drm/i915/gvt: Support PPGTT table load command")
Link: https://github.com/ClangBuiltLinux/linux/issues/1027
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 drivers/gpu/drm/i915/gvt/scheduler.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/gvt/scheduler.c b/drivers/gpu/drm/i915/gvt/scheduler.c
index f776c92de8d7..0fb1df71c637 100644
--- a/drivers/gpu/drm/i915/gvt/scheduler.c
+++ b/drivers/gpu/drm/i915/gvt/scheduler.c
@@ -880,7 +880,7 @@ static void update_guest_pdps(struct intel_vgpu *vgpu,
 				gpa + i * 8, &pdp[7 - i], 4);
 }
 
-static bool
+static __maybe_unused bool
 check_shadow_context_ppgtt(struct execlist_ring_context *c, struct intel_vgpu_mm *m)
 {
 	if (m->ppgtt_mm.root_entry_type == GTT_TYPE_PPGTT_ROOT_L4_ENTRY) {

base-commit: bdecf38f228bcca73b31ada98b5b7ba1215eb9c9
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm/i915: Mark check_shadow_context_ppgtt as maybe unused
  2020-05-16  2:35 [PATCH] drm/i915: Mark check_shadow_context_ppgtt as maybe unused Nathan Chancellor
@ 2020-05-18  6:09 ` Zhenyu Wang
  0 siblings, 0 replies; 2+ messages in thread
From: Zhenyu Wang @ 2020-05-18  6:09 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Zhenyu Wang, Zhi Wang, Jani Nikula, Joonas Lahtinen,
	Rodrigo Vivi, intel-gfx, linux-kernel, dri-devel,
	clang-built-linux, intel-gvt-dev

[-- Attachment #1: Type: text/plain, Size: 2366 bytes --]

On 2020.05.15 19:35:45 -0700, Nathan Chancellor wrote:
> When CONFIG_DRM_I915_DEBUG_GEM is not set, clang warns:
> 
> drivers/gpu/drm/i915/gvt/scheduler.c:884:1: warning: function
> 'check_shadow_context_ppgtt' is not needed and will not be emitted
> [-Wunneeded-internal-declaration]
> check_shadow_context_ppgtt(struct execlist_ring_context *c, struct
> intel_vgpu_mm *m)
> ^
> 1 warning generated.
> 
> This warning is similar to -Wunused-function but rather than warning
> that the function is completely unused, it warns that it is used in some
> expression within the file but that expression will be evaluated to a
> constant or be optimized away in the final assembly, essentially making
> it appeared used but really isn't. Usually, this happens when a function
> or variable is only used in sizeof, where it will appear to be used but
> will be evaluated at compile time and not be required to be emitted.
> 
> In this case, the function is only used in GEM_BUG_ON, which is defined
> as BUILD_BUG_ON_INVALID, which intentionally follows this pattern. To
> fix this warning, add __maybe_unused to make it clear that this is
> intentional depending on the configuration.
> 
> Fixes: bec3df930fbd ("drm/i915/gvt: Support PPGTT table load command")
> Link: https://github.com/ClangBuiltLinux/linux/issues/1027
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
>  drivers/gpu/drm/i915/gvt/scheduler.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/gvt/scheduler.c b/drivers/gpu/drm/i915/gvt/scheduler.c
> index f776c92de8d7..0fb1df71c637 100644
> --- a/drivers/gpu/drm/i915/gvt/scheduler.c
> +++ b/drivers/gpu/drm/i915/gvt/scheduler.c
> @@ -880,7 +880,7 @@ static void update_guest_pdps(struct intel_vgpu *vgpu,
>  				gpa + i * 8, &pdp[7 - i], 4);
>  }
>  
> -static bool
> +static __maybe_unused bool
>  check_shadow_context_ppgtt(struct execlist_ring_context *c, struct intel_vgpu_mm *m)
>  {
>  	if (m->ppgtt_mm.root_entry_type == GTT_TYPE_PPGTT_ROOT_L4_ENTRY) {
> 
> base-commit: bdecf38f228bcca73b31ada98b5b7ba1215eb9c9

Thanks for the fix!

Acked-by: Zhenyu Wang <zhenyuw@linux.intel.com>

I'll pick up for gvt-next-fixes pull.

-- 
Open Source Technology Center, Intel ltd.

$gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-18  6:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-16  2:35 [PATCH] drm/i915: Mark check_shadow_context_ppgtt as maybe unused Nathan Chancellor
2020-05-18  6:09 ` Zhenyu Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).