diff mbox

drm/i915/perf: remove user triggerable warn

Message ID 20170327203236.18276-1-matthew.auld@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Matthew Auld March 27, 2017, 8:32 p.m. UTC
Don't throw a warning if we are given an invalid property id. While
here let's also bring back Robert' original idea of catching unhandled
enumeration values at compile time.

Fixes: eec688e1420d ("drm/i915: Add i915 perf infrastructure")
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Robert Bragg <robert@sixbynine.org>
---
 drivers/gpu/drm/i915/i915_perf.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Robert Bragg March 28, 2017, 11:20 a.m. UTC | #1
On Mon, Mar 27, 2017 at 9:32 PM, Matthew Auld <matthew.auld@intel.com>
wrote:

> Don't throw a warning if we are given an invalid property id. While
> here let's also bring back Robert' original idea of catching unhandled
> enumeration values at compile time.
>
> Fixes: eec688e1420d ("drm/i915: Add i915 perf infrastructure")
> Signed-off-by: Matthew Auld <matthew.auld@intel.com>
> Cc: Robert Bragg <robert@sixbynine.org>
> ---
>  drivers/gpu/drm/i915/i915_perf.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_
> perf.c
> index 8c121187ff39..e52bc6a581e6 100644
> --- a/drivers/gpu/drm/i915/i915_perf.c
> +++ b/drivers/gpu/drm/i915/i915_perf.c
> @@ -1793,6 +1793,11 @@ static int read_properties_unlocked(struct
> drm_i915_private *dev_priv,
>                 if (ret)
>                         return ret;
>
> +               if (id == 0 || id >= DRM_I915_PERF_PROP_MAX) {
> +                       DRM_DEBUG("Unknown i915 perf property ID\n");
> +                       return -EINVAL;
> +               }
> +
>                 switch ((enum drm_i915_perf_property_id)id) {
>                 case DRM_I915_PERF_PROP_CTX_HANDLE:
>                         props->single_context = 1;
> @@ -1862,9 +1867,8 @@ static int read_properties_unlocked(struct
> drm_i915_private *dev_priv,
>                         props->oa_periodic = true;
>                         props->oa_period_exponent = value;
>                         break;
> -               default:
> +               case DRM_I915_PERF_PROP_MAX:
>                         MISSING_CASE(id);
> -                       DRM_DEBUG("Unknown i915 perf property ID\n");
>                         return -EINVAL;
>                 }
>
> --
> 2.9.3
>
>
Looks good to me, thanks.

Reviewed-by: Robert Bragg <robert@sixbynine.org>
Mika Kuoppala March 28, 2017, 11:57 a.m. UTC | #2
Robert Bragg <robert@sixbynine.org> writes:

> On Mon, Mar 27, 2017 at 9:32 PM, Matthew Auld <matthew.auld@intel.com>
> wrote:
>
>> Don't throw a warning if we are given an invalid property id. While
>> here let's also bring back Robert' original idea of catching unhandled
>> enumeration values at compile time.
>>
>> Fixes: eec688e1420d ("drm/i915: Add i915 perf infrastructure")
>> Signed-off-by: Matthew Auld <matthew.auld@intel.com>
>> Cc: Robert Bragg <robert@sixbynine.org>
>> ---
>>  drivers/gpu/drm/i915/i915_perf.c | 8 ++++++--
>>  1 file changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_
>> perf.c
>> index 8c121187ff39..e52bc6a581e6 100644
>> --- a/drivers/gpu/drm/i915/i915_perf.c
>> +++ b/drivers/gpu/drm/i915/i915_perf.c
>> @@ -1793,6 +1793,11 @@ static int read_properties_unlocked(struct
>> drm_i915_private *dev_priv,
>>                 if (ret)
>>                         return ret;
>>
>> +               if (id == 0 || id >= DRM_I915_PERF_PROP_MAX) {
>> +                       DRM_DEBUG("Unknown i915 perf property ID\n");
>> +                       return -EINVAL;
>> +               }
>> +
>>                 switch ((enum drm_i915_perf_property_id)id) {
>>                 case DRM_I915_PERF_PROP_CTX_HANDLE:
>>                         props->single_context = 1;
>> @@ -1862,9 +1867,8 @@ static int read_properties_unlocked(struct
>> drm_i915_private *dev_priv,
>>                         props->oa_periodic = true;
>>                         props->oa_period_exponent = value;
>>                         break;
>> -               default:
>> +               case DRM_I915_PERF_PROP_MAX:
>>                         MISSING_CASE(id);
>> -                       DRM_DEBUG("Unknown i915 perf property ID\n");
>>                         return -EINVAL;
>>                 }
>>
>> --
>> 2.9.3
>>
>>
> Looks good to me, thanks.
>
> Reviewed-by: Robert Bragg <robert@sixbynine.org>

Pushed. Thanks for patch and review.
-Mika
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
index 8c121187ff39..e52bc6a581e6 100644
--- a/drivers/gpu/drm/i915/i915_perf.c
+++ b/drivers/gpu/drm/i915/i915_perf.c
@@ -1793,6 +1793,11 @@  static int read_properties_unlocked(struct drm_i915_private *dev_priv,
 		if (ret)
 			return ret;
 
+		if (id == 0 || id >= DRM_I915_PERF_PROP_MAX) {
+			DRM_DEBUG("Unknown i915 perf property ID\n");
+			return -EINVAL;
+		}
+
 		switch ((enum drm_i915_perf_property_id)id) {
 		case DRM_I915_PERF_PROP_CTX_HANDLE:
 			props->single_context = 1;
@@ -1862,9 +1867,8 @@  static int read_properties_unlocked(struct drm_i915_private *dev_priv,
 			props->oa_periodic = true;
 			props->oa_period_exponent = value;
 			break;
-		default:
+		case DRM_I915_PERF_PROP_MAX:
 			MISSING_CASE(id);
-			DRM_DEBUG("Unknown i915 perf property ID\n");
 			return -EINVAL;
 		}