Skip to content

Commit d6dd684

Browse files
pzanoni-inteljnikula
authored andcommitted
drm/i915: fix plane/cursor handling when runtime suspended
If we're runtime suspended and try to use the plane interfaces, we will get a lot of WARNs saying we did the wrong thing. We need to get runtime PM references to pin the objects, and to change the fences. The pin functions are the ideal places for this, but intel_crtc_cursor_set_obj() doesn't call them, so we also have to add get/put calls inside it. There is no problem if we runtime suspend right after these functions are finished, because the registers written are forwarded to system memory. Note: for a complete fix of the cursor-dpms test case, we also need the patch named "drm/i915: Don't try to enable cursor from setplane when crtc is disabled". v2: - Narrow the put/get calls on intel_crtc_cursor_set_obj() (Daniel) v3: - Make get/put also surround the fence and unpin calls (Daniel and Ville). - Merge all the plane changes into a single patch since they're the same fix. - Add the comment requested by Daniel. v4: - Remove spurious whitespace (Ville). v5: - Remove intel_crtc_update_cursor() chunk since Ville did an equivalent fix in another patch (Ville). v6: - Remove unpin chunk: it will be on a separate patch (Ville, Chris, Daniel). v7: - Same thing, new color. Testcase: igt/pm_rpm/cursor Testcase: igt/pm_rpm/cursor-dpms Testcase: igt/pm_rpm/legacy-planes Testcase: igt/pm_rpm/legacy-planes-dpms Testcase: igt/pm_rpm/universal-planes Testcase: igt/pm_rpm/universal-planes-dpms Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=81645 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=82603 Cc: stable@vger.kernel.org Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
1 parent dfb3d47 commit d6dd684

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

drivers/gpu/drm/i915/intel_display.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2233,6 +2233,15 @@ intel_pin_and_fence_fb_obj(struct drm_device *dev,
22332233
if (need_vtd_wa(dev) && alignment < 256 * 1024)
22342234
alignment = 256 * 1024;
22352235

2236+
/*
2237+
* Global gtt pte registers are special registers which actually forward
2238+
* writes to a chunk of system memory. Which means that there is no risk
2239+
* that the register values disappear as soon as we call
2240+
* intel_runtime_pm_put(), so it is correct to wrap only the
2241+
* pin/unpin/fence and not more.
2242+
*/
2243+
intel_runtime_pm_get(dev_priv);
2244+
22362245
dev_priv->mm.interruptible = false;
22372246
ret = i915_gem_object_pin_to_display_plane(obj, alignment, pipelined);
22382247
if (ret)
@@ -2250,12 +2259,14 @@ intel_pin_and_fence_fb_obj(struct drm_device *dev,
22502259
i915_gem_object_pin_fence(obj);
22512260

22522261
dev_priv->mm.interruptible = true;
2262+
intel_runtime_pm_put(dev_priv);
22532263
return 0;
22542264

22552265
err_unpin:
22562266
i915_gem_object_unpin_from_display_plane(obj);
22572267
err_interruptible:
22582268
dev_priv->mm.interruptible = true;
2269+
intel_runtime_pm_put(dev_priv);
22592270
return ret;
22602271
}
22612272

@@ -8240,6 +8251,15 @@ static int intel_crtc_cursor_set_obj(struct drm_crtc *crtc,
82408251
goto fail_locked;
82418252
}
82428253

8254+
/*
8255+
* Global gtt pte registers are special registers which actually
8256+
* forward writes to a chunk of system memory. Which means that
8257+
* there is no risk that the register values disappear as soon
8258+
* as we call intel_runtime_pm_put(), so it is correct to wrap
8259+
* only the pin/unpin/fence and not more.
8260+
*/
8261+
intel_runtime_pm_get(dev_priv);
8262+
82438263
/* Note that the w/a also requires 2 PTE of padding following
82448264
* the bo. We currently fill all unused PTE with the shadow
82458265
* page and so we should always have valid PTE following the
@@ -8252,16 +8272,20 @@ static int intel_crtc_cursor_set_obj(struct drm_crtc *crtc,
82528272
ret = i915_gem_object_pin_to_display_plane(obj, alignment, NULL);
82538273
if (ret) {
82548274
DRM_DEBUG_KMS("failed to move cursor bo into the GTT\n");
8275+
intel_runtime_pm_put(dev_priv);
82558276
goto fail_locked;
82568277
}
82578278

82588279
ret = i915_gem_object_put_fence(obj);
82598280
if (ret) {
82608281
DRM_DEBUG_KMS("failed to release fence for cursor");
8282+
intel_runtime_pm_put(dev_priv);
82618283
goto fail_unpin;
82628284
}
82638285

82648286
addr = i915_gem_obj_ggtt_offset(obj);
8287+
8288+
intel_runtime_pm_put(dev_priv);
82658289
} else {
82668290
int align = IS_I830(dev) ? 16 * 1024 : 256;
82678291
ret = i915_gem_object_attach_phys(obj, align);

0 commit comments

Comments
 (0)