]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-6.6/drm-i915-pre-populate-the-cursor-physical-dma-addres.patch
a1dce250e0551e86682699de108ef726249a29bf
[thirdparty/kernel/stable-queue.git] / queue-6.6 / drm-i915-pre-populate-the-cursor-physical-dma-addres.patch
1 From ad3102f12645c2f80c50c325726c8a2d5cef1796 Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Mon, 25 Mar 2024 19:57:38 +0200
4 Subject: drm/i915: Pre-populate the cursor physical dma address
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 From: Ville Syrjälä <ville.syrjala@linux.intel.com>
10
11 [ Upstream commit 582dc04b0658ef3b90aeb49cbdd9747c2f1eccc3 ]
12
13 Calling i915_gem_object_get_dma_address() from the vblank
14 evade critical section triggers might_sleep().
15
16 While we know that we've already pinned the framebuffer
17 and thus i915_gem_object_get_dma_address() will in fact
18 not sleep in this case, it seems reasonable to keep the
19 unconditional might_sleep() for maximum coverage.
20
21 So let's instead pre-populate the dma address during
22 fb pinning, which all happens before we enter the
23 vblank evade critical section.
24
25 We can use u32 for the dma address as this class of
26 hardware doesn't support >32bit addresses.
27
28 Cc: stable@vger.kernel.org
29 Fixes: 0225a90981c8 ("drm/i915: Make cursor plane registers unlocked")
30 Reported-by: Borislav Petkov <bp@alien8.de>
31 Closes: https://lore.kernel.org/intel-gfx/20240227100342.GAZd2zfmYcPS_SndtO@fat_crate.local/
32 Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
33 Link: https://patchwork.freedesktop.org/patch/msgid/20240325175738.3440-1-ville.syrjala@linux.intel.com
34 Tested-by: Borislav Petkov (AMD) <bp@alien8.de>
35 Reviewed-by: Chaitanya Kumar Borah <chaitanya.kumar.borah@intel.com>
36 (cherry picked from commit c1289a5c3594cf04caa94ebf0edeb50c62009f1f)
37 Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
38 Signed-off-by: Sasha Levin <sashal@kernel.org>
39 ---
40 drivers/gpu/drm/i915/display/intel_cursor.c | 4 +---
41 drivers/gpu/drm/i915/display/intel_display_types.h | 1 +
42 drivers/gpu/drm/i915/display/intel_fb_pin.c | 10 ++++++++++
43 3 files changed, 12 insertions(+), 3 deletions(-)
44
45 diff --git a/drivers/gpu/drm/i915/display/intel_cursor.c b/drivers/gpu/drm/i915/display/intel_cursor.c
46 index 0d21c34f74990..61df6cd3f3778 100644
47 --- a/drivers/gpu/drm/i915/display/intel_cursor.c
48 +++ b/drivers/gpu/drm/i915/display/intel_cursor.c
49 @@ -34,12 +34,10 @@ static u32 intel_cursor_base(const struct intel_plane_state *plane_state)
50 {
51 struct drm_i915_private *dev_priv =
52 to_i915(plane_state->uapi.plane->dev);
53 - const struct drm_framebuffer *fb = plane_state->hw.fb;
54 - struct drm_i915_gem_object *obj = intel_fb_obj(fb);
55 u32 base;
56
57 if (DISPLAY_INFO(dev_priv)->cursor_needs_physical)
58 - base = i915_gem_object_get_dma_address(obj, 0);
59 + base = plane_state->phys_dma_addr;
60 else
61 base = intel_plane_ggtt_offset(plane_state);
62
63 diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
64 index 7fc92b1474cc4..8b0dc2b75da4a 100644
65 --- a/drivers/gpu/drm/i915/display/intel_display_types.h
66 +++ b/drivers/gpu/drm/i915/display/intel_display_types.h
67 @@ -701,6 +701,7 @@ struct intel_plane_state {
68 #define PLANE_HAS_FENCE BIT(0)
69
70 struct intel_fb_view view;
71 + u32 phys_dma_addr; /* for cursor_needs_physical */
72
73 /* Plane pxp decryption state */
74 bool decrypt;
75 diff --git a/drivers/gpu/drm/i915/display/intel_fb_pin.c b/drivers/gpu/drm/i915/display/intel_fb_pin.c
76 index fffd568070d41..a131656757f2b 100644
77 --- a/drivers/gpu/drm/i915/display/intel_fb_pin.c
78 +++ b/drivers/gpu/drm/i915/display/intel_fb_pin.c
79 @@ -254,6 +254,16 @@ int intel_plane_pin_fb(struct intel_plane_state *plane_state)
80 return PTR_ERR(vma);
81
82 plane_state->ggtt_vma = vma;
83 +
84 + /*
85 + * Pre-populate the dma address before we enter the vblank
86 + * evade critical section as i915_gem_object_get_dma_address()
87 + * will trigger might_sleep() even if it won't actually sleep,
88 + * which is the case when the fb has already been pinned.
89 + */
90 + if (phys_cursor)
91 + plane_state->phys_dma_addr =
92 + i915_gem_object_get_dma_address(intel_fb_obj(fb), 0);
93 } else {
94 struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb);
95
96 --
97 2.43.0
98