From d156f4f9a120f0da8863a542434bc05a7f7f2b97 Mon Sep 17 00:00:00 2001 From: jsg Date: Thu, 11 Apr 2024 02:58:50 +0000 Subject: [PATCH] drm/i915: Pre-populate the cursor physical dma address From Ville Syrjala cc696ce93089e3e1bc28d749aee321a37cabe4bd in linux-6.6.y/6.6.26 582dc04b0658ef3b90aeb49cbdd9747c2f1eccc3 in mainline linux --- sys/dev/pci/drm/i915/display/intel_cursor.c | 4 +--- sys/dev/pci/drm/i915/display/intel_display_types.h | 1 + sys/dev/pci/drm/i915/display/intel_fb_pin.c | 10 ++++++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/sys/dev/pci/drm/i915/display/intel_cursor.c b/sys/dev/pci/drm/i915/display/intel_cursor.c index 0d21c34f749..61df6cd3f37 100644 --- a/sys/dev/pci/drm/i915/display/intel_cursor.c +++ b/sys/dev/pci/drm/i915/display/intel_cursor.c @@ -34,12 +34,10 @@ static u32 intel_cursor_base(const struct intel_plane_state *plane_state) { struct drm_i915_private *dev_priv = to_i915(plane_state->uapi.plane->dev); - const struct drm_framebuffer *fb = plane_state->hw.fb; - struct drm_i915_gem_object *obj = intel_fb_obj(fb); u32 base; if (DISPLAY_INFO(dev_priv)->cursor_needs_physical) - base = i915_gem_object_get_dma_address(obj, 0); + base = plane_state->phys_dma_addr; else base = intel_plane_ggtt_offset(plane_state); diff --git a/sys/dev/pci/drm/i915/display/intel_display_types.h b/sys/dev/pci/drm/i915/display/intel_display_types.h index 310d718f796..50fa55381bd 100644 --- a/sys/dev/pci/drm/i915/display/intel_display_types.h +++ b/sys/dev/pci/drm/i915/display/intel_display_types.h @@ -701,6 +701,7 @@ struct intel_plane_state { #define PLANE_HAS_FENCE BIT(0) struct intel_fb_view view; + u32 phys_dma_addr; /* for cursor_needs_physical */ /* Plane pxp decryption state */ bool decrypt; diff --git a/sys/dev/pci/drm/i915/display/intel_fb_pin.c b/sys/dev/pci/drm/i915/display/intel_fb_pin.c index fffd568070d..a131656757f 100644 --- a/sys/dev/pci/drm/i915/display/intel_fb_pin.c +++ b/sys/dev/pci/drm/i915/display/intel_fb_pin.c @@ -254,6 +254,16 @@ int intel_plane_pin_fb(struct intel_plane_state *plane_state) return PTR_ERR(vma); plane_state->ggtt_vma = vma; + + /* + * Pre-populate the dma address before we enter the vblank + * evade critical section as i915_gem_object_get_dma_address() + * will trigger might_sleep() even if it won't actually sleep, + * which is the case when the fb has already been pinned. + */ + if (phys_cursor) + plane_state->phys_dma_addr = + i915_gem_object_get_dma_address(intel_fb_obj(fb), 0); } else { struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb); -- 2.20.1