Skip to contentSkip to conversation

drm/i915: Fix runtime pm handling in i915_gem_shrink

PATCH In review Maarten Lankhorst 2 participants 2 messages Sep 28, 2021 – Sep 29, 2021 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 8/21 drm/i915: Fix runtime pm handling in i915_gem_shrink

We forgot to call intel_runtime_pm_put on error, fix it!

Fixes cf41a8f1dc1e ("drm/i915: Finally remove obj->mm.lock.")
Cc Thomas Hellström <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc <[email protected]> # v5.13+
---
 drivers/gpu/drm/i915/gem/i915_gem_shrinker.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_shrinker.c +5 -2
index e382b7f2353b..5ab136ffdeb2 100644
@@ -118,7 +118,7 @@ i915_gem_shrink(struct i915_gem_ww_ctx *ww,
 	intel_wakeref_t wakeref = 0;
 	unsigned long count = 0;
 	unsigned long scanned = 0;
-	int err;
+	int err = 0;
 
 	/* CHV + VTD workaround use stop_machine(); need to trylock vm->mutex */
 	bool trylock_vm = !ww && intel_vm_no_concurrent_access_wa(i915);
@@ -242,12 +242,15 @@ i915_gem_shrink(struct i915_gem_ww_ctx *ww,
 		list_splice_tail(&still_in_list, phase->list);
 		spin_unlock_irqrestore(&i915->mm.obj_lock, flags);
 		if (err)
-			return err;
+			break;
 	}
 
 	if (shrink & I915_SHRINK_BOUND)
 		intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 
+	if (err)
+		return err;
+
 	if (nr_scanned)
 		*nr_scanned += scanned;
 	return count;
Signature · 1 line
2.33.0
Reviewed-by on v1 8/21
#2 lore raw
Quoted 31 lines · Maarten Lankhorst

We forgot to call intel_runtime_pm_put on error, fix it!

Fixes cf41a8f1dc1e ("drm/i915: Finally remove obj->mm.lock.")
Cc Thomas Hellström <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc <[email protected]> # v5.13+
---
  drivers/gpu/drm/i915/gem/i915_gem_shrinker.c | 7 +++++--
  1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_shrinker.c +2 -2
index e382b7f2353b..5ab136ffdeb2 100644
@@ -118,7 +118,7 @@ i915_gem_shrink(struct i915_gem_ww_ctx *ww,
  	intel_wakeref_t wakeref = 0;
  	unsigned long count = 0;
  	unsigned long scanned = 0;
-	int err;
+	int err = 0;
 
  	/* CHV + VTD workaround use stop_machine(); need to trylock vm->mutex */
  	bool trylock_vm = !ww && intel_vm_no_concurrent_access_wa(i915);
@@ -242,12 +242,15 @@ i915_gem_shrink(struct i915_gem_ww_ctx *ww,
  		list_splice_tail(&still_in_list, phase->list);
  		spin_unlock_irqrestore(&i915->mm.obj_lock, flags);
  		if (err)
-			return err;
+			break;
  	}

drivers/gpu/drm/i915/gem/i915_gem_shrinker.c i915_gem_shrink(struct i915_gem_ww_ctx *ww, · line 256

Quoted 10 lines
drivers/gpu/drm/i915/gem/i915_gem_shrinker.c +3 -0
 
  	if (shrink & I915_SHRINK_BOUND)
  		intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 
+	if (err)
+		return err;
+
  	if (nr_scanned)
  		*nr_scanned += scanned;
  	return count;