Skip to content

Commit ea5e150

Browse files
committed
drm/i915: Tweak BIOS fb reuse check
Currently we assume that we bind the BIOS fb exactly into the same ggtt address where the BIOS left it. That is about to change, and in order to keep intel_reuse_initial_plane_obj() working as intended we need to compare the original ggtt offset (called 'base' here) as opposed to the actual vma ggtt offset we selected. Otherwise the first plane could change the ggtt offset, and then subsequent planes would no longer notice that they are in fact using the same ggtt offset that the first plane was already using. Thus the reuse check will fail and we proceed to turn off these subsequent planes. TODO: would probably make more sense to do the pure readout first for all the planes, then check for fb reuse, and only then proceed to pin the object into the final location in the ggtt... v2: "fix" xe Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com> Tested-by: Paz Zcharya <pazz@chromium.org> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240202224340.30647-15-ville.syrjala@linux.intel.com Acked-by: Lucas De Marchi <lucas.demarchi@intel.com>
1 parent f1ee98c commit ea5e150

2 files changed

Lines changed: 35 additions & 28 deletions

File tree

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

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,29 @@
1313
#include "intel_plane_initial.h"
1414

1515
static bool
16-
intel_reuse_initial_plane_obj(struct drm_i915_private *i915,
17-
const struct intel_initial_plane_config *plane_config,
16+
intel_reuse_initial_plane_obj(struct intel_crtc *this,
17+
const struct intel_initial_plane_config plane_configs[],
1818
struct drm_framebuffer **fb,
1919
struct i915_vma **vma)
2020
{
21+
struct drm_i915_private *i915 = to_i915(this->base.dev);
2122
struct intel_crtc *crtc;
2223

2324
for_each_intel_crtc(&i915->drm, crtc) {
24-
struct intel_crtc_state *crtc_state =
25-
to_intel_crtc_state(crtc->base.state);
2625
struct intel_plane *plane =
2726
to_intel_plane(crtc->base.primary);
28-
struct intel_plane_state *plane_state =
27+
const struct intel_plane_state *plane_state =
2928
to_intel_plane_state(plane->base.state);
29+
const struct intel_crtc_state *crtc_state =
30+
to_intel_crtc_state(crtc->base.state);
3031

3132
if (!crtc_state->uapi.active)
3233
continue;
3334

3435
if (!plane_state->ggtt_vma)
3536
continue;
3637

37-
if (intel_plane_ggtt_offset(plane_state) == plane_config->base) {
38+
if (plane_configs[this->pipe].base == plane_configs[crtc->pipe].base) {
3839
*fb = plane_state->hw.fb;
3940
*vma = plane_state->ggtt_vma;
4041
return true;
@@ -265,10 +266,11 @@ intel_alloc_initial_plane_obj(struct intel_crtc *crtc,
265266

266267
static void
267268
intel_find_initial_plane_obj(struct intel_crtc *crtc,
268-
struct intel_initial_plane_config *plane_config)
269+
struct intel_initial_plane_config plane_configs[])
269270
{
270-
struct drm_device *dev = crtc->base.dev;
271-
struct drm_i915_private *dev_priv = to_i915(dev);
271+
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
272+
struct intel_initial_plane_config *plane_config =
273+
&plane_configs[crtc->pipe];
272274
struct intel_plane *plane =
273275
to_intel_plane(crtc->base.primary);
274276
struct intel_plane_state *plane_state =
@@ -294,7 +296,7 @@ intel_find_initial_plane_obj(struct intel_crtc *crtc,
294296
* Failed to alloc the obj, check to see if we should share
295297
* an fb with another CRTC instead
296298
*/
297-
if (intel_reuse_initial_plane_obj(dev_priv, plane_config, &fb, &vma))
299+
if (intel_reuse_initial_plane_obj(crtc, plane_configs, &fb, &vma))
298300
goto valid_fb;
299301

300302
/*
@@ -359,10 +361,12 @@ static void plane_config_fini(struct intel_initial_plane_config *plane_config)
359361

360362
void intel_initial_plane_config(struct drm_i915_private *i915)
361363
{
364+
struct intel_initial_plane_config plane_configs[I915_MAX_PIPES] = {};
362365
struct intel_crtc *crtc;
363366

364367
for_each_intel_crtc(&i915->drm, crtc) {
365-
struct intel_initial_plane_config plane_config = {};
368+
struct intel_initial_plane_config *plane_config =
369+
&plane_configs[crtc->pipe];
366370

367371
if (!to_intel_crtc_state(crtc->base.state)->uapi.active)
368372
continue;
@@ -374,14 +378,14 @@ void intel_initial_plane_config(struct drm_i915_private *i915)
374378
* can even allow for smooth boot transitions if the BIOS
375379
* fb is large enough for the active pipe configuration.
376380
*/
377-
i915->display.funcs.display->get_initial_plane_config(crtc, &plane_config);
381+
i915->display.funcs.display->get_initial_plane_config(crtc, plane_config);
378382

379383
/*
380384
* If the fb is shared between multiple heads, we'll
381385
* just get the first one.
382386
*/
383-
intel_find_initial_plane_obj(crtc, &plane_config);
387+
intel_find_initial_plane_obj(crtc, plane_configs);
384388

385-
plane_config_fini(&plane_config);
389+
plane_config_fini(plane_config);
386390
}
387391
}

drivers/gpu/drm/xe/display/xe_plane_initial.c

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,28 @@
1818
#include "intel_plane_initial.h"
1919

2020
static bool
21-
intel_reuse_initial_plane_obj(struct drm_i915_private *i915,
22-
const struct intel_initial_plane_config *plane_config,
21+
intel_reuse_initial_plane_obj(struct intel_crtc *this,
22+
const struct intel_initial_plane_config plane_configs[],
2323
struct drm_framebuffer **fb)
2424
{
25+
struct drm_i915_private *i915 = to_i915(this->base.dev);
2526
struct intel_crtc *crtc;
2627

2728
for_each_intel_crtc(&i915->drm, crtc) {
28-
struct intel_crtc_state *crtc_state =
29-
to_intel_crtc_state(crtc->base.state);
3029
struct intel_plane *plane =
3130
to_intel_plane(crtc->base.primary);
32-
struct intel_plane_state *plane_state =
31+
const struct intel_plane_state *plane_state =
3332
to_intel_plane_state(plane->base.state);
33+
const struct intel_crtc_state *crtc_state =
34+
to_intel_crtc_state(crtc->base.state);
3435

3536
if (!crtc_state->uapi.active)
3637
continue;
3738

3839
if (!plane_state->ggtt_vma)
3940
continue;
4041

41-
if (intel_plane_ggtt_offset(plane_state) == plane_config->base) {
42+
if (plane_configs[this->pipe].base == plane_configs[crtc->pipe].base) {
4243
*fb = plane_state->hw.fb;
4344
return true;
4445
}
@@ -178,10 +179,10 @@ intel_alloc_initial_plane_obj(struct intel_crtc *crtc,
178179

179180
static void
180181
intel_find_initial_plane_obj(struct intel_crtc *crtc,
181-
struct intel_initial_plane_config *plane_config)
182+
struct intel_initial_plane_config plane_configs[])
182183
{
183-
struct drm_device *dev = crtc->base.dev;
184-
struct drm_i915_private *dev_priv = to_i915(dev);
184+
struct intel_initial_plane_config *plane_config =
185+
&plane_configs[crtc->pipe];
185186
struct intel_plane *plane =
186187
to_intel_plane(crtc->base.primary);
187188
struct intel_plane_state *plane_state =
@@ -201,7 +202,7 @@ intel_find_initial_plane_obj(struct intel_crtc *crtc,
201202

202203
if (intel_alloc_initial_plane_obj(crtc, plane_config))
203204
fb = &plane_config->fb->base;
204-
else if (!intel_reuse_initial_plane_obj(dev_priv, plane_config, &fb))
205+
else if (!intel_reuse_initial_plane_obj(crtc, plane_configs, &fb))
205206
goto nofb;
206207

207208
plane_state->uapi.rotation = plane_config->rotation;
@@ -269,10 +270,12 @@ static void plane_config_fini(struct intel_initial_plane_config *plane_config)
269270

270271
void intel_initial_plane_config(struct drm_i915_private *i915)
271272
{
273+
struct intel_initial_plane_config plane_configs[I915_MAX_PIPES] = {};
272274
struct intel_crtc *crtc;
273275

274276
for_each_intel_crtc(&i915->drm, crtc) {
275-
struct intel_initial_plane_config plane_config = {};
277+
struct intel_initial_plane_config *plane_config =
278+
&plane_configs[crtc->pipe];
276279

277280
if (!to_intel_crtc_state(crtc->base.state)->uapi.active)
278281
continue;
@@ -284,14 +287,14 @@ void intel_initial_plane_config(struct drm_i915_private *i915)
284287
* can even allow for smooth boot transitions if the BIOS
285288
* fb is large enough for the active pipe configuration.
286289
*/
287-
i915->display.funcs.display->get_initial_plane_config(crtc, &plane_config);
290+
i915->display.funcs.display->get_initial_plane_config(crtc, plane_config);
288291

289292
/*
290293
* If the fb is shared between multiple heads, we'll
291294
* just get the first one.
292295
*/
293-
intel_find_initial_plane_obj(crtc, &plane_config);
296+
intel_find_initial_plane_obj(crtc, plane_configs);
294297

295-
plane_config_fini(&plane_config);
298+
plane_config_fini(plane_config);
296299
}
297300
}

0 commit comments

Comments
 (0)