diff mbox series

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

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

Commit Message

Chris Wilson Nov. 1, 2019, 7:21 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.

v2: More the long lines into their own function so there is no confusion
on operator precedence.

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 | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

Comments

Umesh Nerlige Ramappa Nov. 1, 2019, 7:31 p.m. UTC | #1
On Fri, Nov 01, 2019 at 07:21:16PM +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.
>
>v2: More the long lines into their own function so there is no confusion
>on operator precedence.
>
>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: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>

Thanks,
Umesh

>---
> drivers/gpu/drm/i915/i915_perf.c | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
>
>diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
>index a8c2318d3d5e..1fd6bac8a4fe 100644
>--- a/drivers/gpu/drm/i915/i915_perf.c
>+++ b/drivers/gpu/drm/i915/i915_perf.c
>@@ -2428,6 +2428,13 @@ static int gen8_enable_metric_set(struct i915_perf_stream *stream)
> 	return emit_oa_config(stream, oa_config, oa_context(stream));
> }
>
>+static u32 report_ctx_switches(const struct i915_perf_stream *stream)
>+{
>+	return _MASKED_FIELD(GEN12_OAG_OA_DEBUG_DISABLE_CTX_SWITCH_REPORTS,
>+			     (stream->sample_flags & SAMPLE_OA_REPORT) ?
>+			     0 : GEN12_OAG_OA_DEBUG_DISABLE_CTX_SWITCH_REPORTS);
>+}
>+
> static int gen12_enable_metric_set(struct i915_perf_stream *stream)
> {
> 	struct intel_uncore *uncore = stream->uncore;
>@@ -2441,12 +2448,10 @@ 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));
>+			   report_ctx_switches(stream));
>
> 	intel_uncore_write(uncore, GEN12_OAG_OAGLBCTXCTRL, periodic ?
> 			   (GEN12_OAG_OAGLBCTXCTRL_COUNTER_RESUME |
>-- 
>2.24.0.rc2
>
Nathan Chancellor Dec. 3, 2019, 5:05 a.m. UTC | #2
On Fri, Nov 01, 2019 at 07:21:16PM +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.
> 
> v2: More the long lines into their own function so there is no confusion
> on operator precedence.
> 
> 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>

I don't see this applied to drm-intel yet (unless I am blind) and clang
warns about this as well.

Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Chris Wilson Dec. 3, 2019, 9:11 a.m. UTC | #3
Quoting Nathan Chancellor (2019-12-03 05:05:22)
> On Fri, Nov 01, 2019 at 07:21:16PM +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.
> > 
> > v2: More the long lines into their own function so there is no confusion
> > on operator precedence.
> > 
> > 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>
> 
> I don't see this applied to drm-intel yet (unless I am blind) and clang
> warns about this as well.

It's in tip. I guess you are looking at the linux-next branch that gets
frozen for the merge window.
-Chris
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
index a8c2318d3d5e..1fd6bac8a4fe 100644
--- a/drivers/gpu/drm/i915/i915_perf.c
+++ b/drivers/gpu/drm/i915/i915_perf.c
@@ -2428,6 +2428,13 @@  static int gen8_enable_metric_set(struct i915_perf_stream *stream)
 	return emit_oa_config(stream, oa_config, oa_context(stream));
 }
 
+static u32 report_ctx_switches(const struct i915_perf_stream *stream)
+{
+	return _MASKED_FIELD(GEN12_OAG_OA_DEBUG_DISABLE_CTX_SWITCH_REPORTS,
+			     (stream->sample_flags & SAMPLE_OA_REPORT) ?
+			     0 : GEN12_OAG_OA_DEBUG_DISABLE_CTX_SWITCH_REPORTS);
+}
+
 static int gen12_enable_metric_set(struct i915_perf_stream *stream)
 {
 	struct intel_uncore *uncore = stream->uncore;
@@ -2441,12 +2448,10 @@  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));
+			   report_ctx_switches(stream));
 
 	intel_uncore_write(uncore, GEN12_OAG_OAGLBCTXCTRL, periodic ?
 			   (GEN12_OAG_OAGLBCTXCTRL_COUNTER_RESUME |