Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 582dc04

Browse files
vsyrjalarodrigovivi
authored andcommitted
drm/i915: Pre-populate the cursor physical dma address
Calling i915_gem_object_get_dma_address() from the vblank evade critical section triggers might_sleep(). While we know that we've already pinned the framebuffer and thus i915_gem_object_get_dma_address() will in fact not sleep in this case, it seems reasonable to keep the unconditional might_sleep() for maximum coverage. So let's instead pre-populate the dma address during fb pinning, which all happens before we enter the vblank evade critical section. We can use u32 for the dma address as this class of hardware doesn't support >32bit addresses. Cc: stable@vger.kernel.org Fixes: 0225a90 ("drm/i915: Make cursor plane registers unlocked") Reported-by: Borislav Petkov <bp@alien8.de> Closes: https://lore.kernel.org/intel-gfx/20240227100342.GAZd2zfmYcPS_SndtO@fat_crate.local/ Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240325175738.3440-1-ville.syrjala@linux.intel.com Tested-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Chaitanya Kumar Borah <chaitanya.kumar.borah@intel.com> (cherry picked from commit c1289a5) Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
1 parent 4a3859e commit 582dc04

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

drivers/gpu/drm/i915/display/intel_cursor.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,10 @@ static u32 intel_cursor_base(const struct intel_plane_state *plane_state)
3636
{
3737
struct drm_i915_private *dev_priv =
3838
to_i915(plane_state->uapi.plane->dev);
39-
const struct drm_framebuffer *fb = plane_state->hw.fb;
40-
struct drm_i915_gem_object *obj = intel_fb_obj(fb);
4139
u32 base;
4240

4341
if (DISPLAY_INFO(dev_priv)->cursor_needs_physical)
44-
base = i915_gem_object_get_dma_address(obj, 0);
42+
base = plane_state->phys_dma_addr;
4543
else
4644
base = intel_plane_ggtt_offset(plane_state);
4745

drivers/gpu/drm/i915/display/intel_display_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,7 @@ struct intel_plane_state {
727727
#define PLANE_HAS_FENCE BIT(0)
728728

729729
struct intel_fb_view view;
730+
u32 phys_dma_addr; /* for cursor_needs_physical */
730731

731732
/* Plane pxp decryption state */
732733
bool decrypt;

drivers/gpu/drm/i915/display/intel_fb_pin.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,16 @@ int intel_plane_pin_fb(struct intel_plane_state *plane_state)
255255
return PTR_ERR(vma);
256256

257257
plane_state->ggtt_vma = vma;
258+
259+
/*
260+
* Pre-populate the dma address before we enter the vblank
261+
* evade critical section as i915_gem_object_get_dma_address()
262+
* will trigger might_sleep() even if it won't actually sleep,
263+
* which is the case when the fb has already been pinned.
264+
*/
265+
if (phys_cursor)
266+
plane_state->phys_dma_addr =
267+
i915_gem_object_get_dma_address(intel_fb_obj(fb), 0);
258268
} else {
259269
struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb);
260270

0 commit comments

Comments
 (0)