diff mbox series

drm/i915/slpc: Fix inconsistent locked return

Message ID 20220830193537.52201-1-rodrigo.vivi@intel.com (mailing list archive)
State New, archived
Headers show
Series drm/i915/slpc: Fix inconsistent locked return | expand

Commit Message

Rodrigo Vivi Aug. 30, 2022, 7:35 p.m. UTC
Fix for intel_guc_slpc_set_min_freq() warn:
inconsistent returns '&slpc->lock'.

v2: Avoid with_intel_runtime_pm with the
    internal goto/return. (Ashutosh)
    Also standardize the 'ret' if this came from
    the efficient setup. And avoid the 'unlikely'.

Fixes: 95ccf312a1e4 ("drm/i915/guc/slpc: Allow SLPC to use efficient frequency")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Ashutosh Dixit <ashutosh.dixit@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
---
 drivers/gpu/drm/i915/gt/uc/intel_guc_slpc.c | 40 ++++++++++-----------
 1 file changed, 20 insertions(+), 20 deletions(-)

Comments

Dixit, Ashutosh Aug. 30, 2022, 9:23 p.m. UTC | #1
On Tue, 30 Aug 2022 12:35:37 -0700, Rodrigo Vivi wrote:
>
> Fix for intel_guc_slpc_set_min_freq() warn:
> inconsistent returns '&slpc->lock'.
>
> v2: Avoid with_intel_runtime_pm with the
>     internal goto/return. (Ashutosh)
>     Also standardize the 'ret' if this came from
>     the efficient setup. And avoid the 'unlikely'.

Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com>

> Fixes: 95ccf312a1e4 ("drm/i915/guc/slpc: Allow SLPC to use efficient frequency")
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Cc: Ashutosh Dixit <ashutosh.dixit@intel.com>
> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> ---
>  drivers/gpu/drm/i915/gt/uc/intel_guc_slpc.c | 40 ++++++++++-----------
>  1 file changed, 20 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_slpc.c b/drivers/gpu/drm/i915/gt/uc/intel_guc_slpc.c
> index 9d49ccef03bb..fdd895f73f9f 100644
> --- a/drivers/gpu/drm/i915/gt/uc/intel_guc_slpc.c
> +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_slpc.c
> @@ -467,33 +467,33 @@ int intel_guc_slpc_set_min_freq(struct intel_guc_slpc *slpc, u32 val)
>
>	/* Need a lock now since waitboost can be modifying min as well */
>	mutex_lock(&slpc->lock);
> -
> -	with_intel_runtime_pm(&i915->runtime_pm, wakeref) {
> -
> -		/* Ignore efficient freq if lower min freq is requested */
> -		ret = slpc_set_param(slpc,
> -				     SLPC_PARAM_IGNORE_EFFICIENT_FREQUENCY,
> -				     val < slpc->rp1_freq);
> -		if (unlikely(ret)) {
> -			i915_probe_error(i915, "Failed to toggle efficient freq (%pe)\n",
> -					 ERR_PTR(ret));
> -			return ret;
> -		}
> -
> -		ret = slpc_set_param(slpc,
> -				     SLPC_PARAM_GLOBAL_MIN_GT_UNSLICE_FREQ_MHZ,
> -				     val);
> -
> -		/* Return standardized err code for sysfs calls */
> -		if (ret)
> -			ret = -EIO;
> +	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
> +
> +	/* Ignore efficient freq if lower min freq is requested */
> +	ret = slpc_set_param(slpc,
> +			     SLPC_PARAM_IGNORE_EFFICIENT_FREQUENCY,
> +			     val < slpc->rp1_freq);
> +	if (ret) {
> +		i915_probe_error(i915, "Failed to toggle efficient freq (%pe)\n",
> +				 ERR_PTR(ret));
> +		goto out;
>	}
>
> +	ret = slpc_set_param(slpc,
> +			     SLPC_PARAM_GLOBAL_MIN_GT_UNSLICE_FREQ_MHZ,
> +			     val);
> +
>	if (!ret)
>		slpc->min_freq_softlimit = val;
>
> +out:
> +	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
>	mutex_unlock(&slpc->lock);
>
> +	/* Return standardized err code for sysfs calls */
> +	if (ret)
> +		ret = -EIO;
> +
>	return ret;
>  }
>
> --
> 2.37.2
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_slpc.c b/drivers/gpu/drm/i915/gt/uc/intel_guc_slpc.c
index 9d49ccef03bb..fdd895f73f9f 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_guc_slpc.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_slpc.c
@@ -467,33 +467,33 @@  int intel_guc_slpc_set_min_freq(struct intel_guc_slpc *slpc, u32 val)
 
 	/* Need a lock now since waitboost can be modifying min as well */
 	mutex_lock(&slpc->lock);
-
-	with_intel_runtime_pm(&i915->runtime_pm, wakeref) {
-
-		/* Ignore efficient freq if lower min freq is requested */
-		ret = slpc_set_param(slpc,
-				     SLPC_PARAM_IGNORE_EFFICIENT_FREQUENCY,
-				     val < slpc->rp1_freq);
-		if (unlikely(ret)) {
-			i915_probe_error(i915, "Failed to toggle efficient freq (%pe)\n",
-					 ERR_PTR(ret));
-			return ret;
-		}
-
-		ret = slpc_set_param(slpc,
-				     SLPC_PARAM_GLOBAL_MIN_GT_UNSLICE_FREQ_MHZ,
-				     val);
-
-		/* Return standardized err code for sysfs calls */
-		if (ret)
-			ret = -EIO;
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
+
+	/* Ignore efficient freq if lower min freq is requested */
+	ret = slpc_set_param(slpc,
+			     SLPC_PARAM_IGNORE_EFFICIENT_FREQUENCY,
+			     val < slpc->rp1_freq);
+	if (ret) {
+		i915_probe_error(i915, "Failed to toggle efficient freq (%pe)\n",
+				 ERR_PTR(ret));
+		goto out;
 	}
 
+	ret = slpc_set_param(slpc,
+			     SLPC_PARAM_GLOBAL_MIN_GT_UNSLICE_FREQ_MHZ,
+			     val);
+
 	if (!ret)
 		slpc->min_freq_softlimit = val;
 
+out:
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 	mutex_unlock(&slpc->lock);
 
+	/* Return standardized err code for sysfs calls */
+	if (ret)
+		ret = -EIO;
+
 	return ret;
 }