diff mbox series

drm/i915/perf: Reverse a ternary to make sparse happy

Message ID 20191101181820.12932-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show
Series drm/i915/perf: Reverse a ternary to make sparse happy | expand

Commit Message

Chris Wilson Nov. 1, 2019, 6:18 p.m. UTC
Avoid

drivers/gpu/drm/i915/i915_perf.c:2442:85: warning: dubious: x | !y

simply by inverting the predicate and reversing the ternary.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Cc: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
---
 drivers/gpu/drm/i915/i915_perf.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Lionel Landwerlin Nov. 1, 2019, 6:23 p.m. UTC | #1
On 01/11/2019 20:18, Chris Wilson wrote:
> Avoid
>
> drivers/gpu/drm/i915/i915_perf.c:2442:85: warning: dubious: x | !y
>
> simply by inverting the predicate and reversing the ternary.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
> Cc: Lionel Landwerlin <lionel.g.landwerlin@intel.com>

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>


Thanks a lot,


-Lionel


> ---
>   drivers/gpu/drm/i915/i915_perf.c | 10 +++++-----
>   1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
> index 6e35b9255882..acd65da50651 100644
> --- a/drivers/gpu/drm/i915/i915_perf.c
> +++ b/drivers/gpu/drm/i915/i915_perf.c
> @@ -2441,12 +2441,12 @@ static int gen12_enable_metric_set(struct i915_perf_stream *stream)
>   			   _MASKED_BIT_ENABLE(GEN12_OAG_OA_DEBUG_DISABLE_CLK_RATIO_REPORTS |
>   					      GEN12_OAG_OA_DEBUG_INCLUDE_CLK_RATIO) |
>   			   /*
> -			    * If the user didn't require OA reports, instruct the
> -			    * hardware not to emit ctx switch reports.
> +			    * If the user didn't require OA reports, instruct
> +			    * the hardware not to emit ctx switch reports.
>   			    */
> -			   !(stream->sample_flags & SAMPLE_OA_REPORT) ?
> -			   _MASKED_BIT_ENABLE(GEN12_OAG_OA_DEBUG_DISABLE_CTX_SWITCH_REPORTS) :
> -			   _MASKED_BIT_DISABLE(GEN12_OAG_OA_DEBUG_DISABLE_CTX_SWITCH_REPORTS));
> +			   (stream->sample_flags & SAMPLE_OA_REPORT) ?
> +			   _MASKED_BIT_DISABLE(GEN12_OAG_OA_DEBUG_DISABLE_CTX_SWITCH_REPORTS) :
> +			   _MASKED_BIT_ENABLE(GEN12_OAG_OA_DEBUG_DISABLE_CTX_SWITCH_REPORTS));
>   
>   	intel_uncore_write(uncore, GEN12_OAG_OAGLBCTXCTRL, periodic ?
>   			   (GEN12_OAG_OAGLBCTXCTRL_COUNTER_RESUME |
Umesh Nerlige Ramappa Nov. 1, 2019, 7:12 p.m. UTC | #2
On Fri, Nov 01, 2019 at 06:18:20PM +0000, Chris Wilson wrote:
>Avoid
>
>drivers/gpu/drm/i915/i915_perf.c:2442:85: warning: dubious: x | !y
>
>simply by inverting the predicate and reversing the ternary.
>
>Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
>Cc: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
>Cc: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
>---
> drivers/gpu/drm/i915/i915_perf.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
>diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
>index 6e35b9255882..acd65da50651 100644
>--- a/drivers/gpu/drm/i915/i915_perf.c
>+++ b/drivers/gpu/drm/i915/i915_perf.c
>@@ -2441,12 +2441,12 @@ static int gen12_enable_metric_set(struct i915_perf_stream *stream)
> 			   _MASKED_BIT_ENABLE(GEN12_OAG_OA_DEBUG_DISABLE_CLK_RATIO_REPORTS |
> 					      GEN12_OAG_OA_DEBUG_INCLUDE_CLK_RATIO) |
> 			   /*
>-			    * If the user didn't require OA reports, instruct the
>-			    * hardware not to emit ctx switch reports.
>+			    * If the user didn't require OA reports, instruct
>+			    * the hardware not to emit ctx switch reports.
> 			    */
>-			   !(stream->sample_flags & SAMPLE_OA_REPORT) ?
>-			   _MASKED_BIT_ENABLE(GEN12_OAG_OA_DEBUG_DISABLE_CTX_SWITCH_REPORTS) :
>-			   _MASKED_BIT_DISABLE(GEN12_OAG_OA_DEBUG_DISABLE_CTX_SWITCH_REPORTS));
>+			   (stream->sample_flags & SAMPLE_OA_REPORT) ?
>+			   _MASKED_BIT_DISABLE(GEN12_OAG_OA_DEBUG_DISABLE_CTX_SWITCH_REPORTS) :
>+			   _MASKED_BIT_ENABLE(GEN12_OAG_OA_DEBUG_DISABLE_CTX_SWITCH_REPORTS));

oops, missed that one.

I thought sparse flagged it because of missing braces ("|" precedes "?:" 
).

Maybe expecting another brace around the ternary - more like this?

+			   ((stream->sample_flags & SAMPLE_OA_REPORT) ?
+			   _MASKED_BIT_DISABLE(GEN12_OAG_OA_DEBUG_DISABLE_CTX_SWITCH_REPORTS) :
+			   _MASKED_BIT_ENABLE(GEN12_OAG_OA_DEBUG_DISABLE_CTX_SWITCH_REPORTS)));

Thanks,
Umesh

>
> 	intel_uncore_write(uncore, GEN12_OAG_OAGLBCTXCTRL, periodic ?
> 			   (GEN12_OAG_OAGLBCTXCTRL_COUNTER_RESUME |
>-- 
>2.24.0.rc2
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
index 6e35b9255882..acd65da50651 100644
--- a/drivers/gpu/drm/i915/i915_perf.c
+++ b/drivers/gpu/drm/i915/i915_perf.c
@@ -2441,12 +2441,12 @@  static int gen12_enable_metric_set(struct i915_perf_stream *stream)
 			   _MASKED_BIT_ENABLE(GEN12_OAG_OA_DEBUG_DISABLE_CLK_RATIO_REPORTS |
 					      GEN12_OAG_OA_DEBUG_INCLUDE_CLK_RATIO) |
 			   /*
-			    * If the user didn't require OA reports, instruct the
-			    * hardware not to emit ctx switch reports.
+			    * If the user didn't require OA reports, instruct
+			    * the hardware not to emit ctx switch reports.
 			    */
-			   !(stream->sample_flags & SAMPLE_OA_REPORT) ?
-			   _MASKED_BIT_ENABLE(GEN12_OAG_OA_DEBUG_DISABLE_CTX_SWITCH_REPORTS) :
-			   _MASKED_BIT_DISABLE(GEN12_OAG_OA_DEBUG_DISABLE_CTX_SWITCH_REPORTS));
+			   (stream->sample_flags & SAMPLE_OA_REPORT) ?
+			   _MASKED_BIT_DISABLE(GEN12_OAG_OA_DEBUG_DISABLE_CTX_SWITCH_REPORTS) :
+			   _MASKED_BIT_ENABLE(GEN12_OAG_OA_DEBUG_DISABLE_CTX_SWITCH_REPORTS));
 
 	intel_uncore_write(uncore, GEN12_OAG_OAGLBCTXCTRL, periodic ?
 			   (GEN12_OAG_OAGLBCTXCTRL_COUNTER_RESUME |