drm/i915: Pre-populate the cursor physical dma address
authorjsg <jsg@openbsd.org>
Thu, 11 Apr 2024 02:58:50 +0000 (02:58 +0000)
committerjsg <jsg@openbsd.org>
Thu, 11 Apr 2024 02:58:50 +0000 (02:58 +0000)
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
sys/dev/pci/drm/i915/display/intel_display_types.h
sys/dev/pci/drm/i915/display/intel_fb_pin.c

index 0d21c34..61df6cd 100644 (file)
@@ -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);
 
index 310d718..50fa553 100644 (file)
@@ -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;
index fffd568..a131656 100644 (file)
@@ -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);