Skip to content

Commit f37b5c2

Browse files
danvetjnikula
authored andcommitted
drm/i915: Align initial plane backing objects correctly
Some bios really like to joke and start the planes at an offset ... hooray! Align start and end to fix this. v2: Fixup calculation of size, spotted by Chris Wilson. v3: Fix serious fumble I've just spotted. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=86883 Cc: stable@vger.kernel.org Cc: Johannes W <jargon@molb.org> Cc: Chris Wilson <chris@chris-wilson.co.uk> Cc: Jani Nikula <jani.nikula@linux.intel.com> Reported-and-tested-by: Johannes W <jargon@molb.org> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> [Jani: split WARN_ONs, rebase on v4.0-rc1] Signed-off-by: Jani Nikula <jani.nikula@intel.com>
1 parent 2dd2a88 commit f37b5c2

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

‎drivers/gpu/drm/i915/i915_gem_stolen.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -485,10 +485,8 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,
485485
stolen_offset, gtt_offset, size);
486486

487487
/* KISS and expect everything to be page-aligned */
488-
BUG_ON(stolen_offset & 4095);
489-
BUG_ON(size & 4095);
490-
491-
if (WARN_ON(size == 0))
488+
if (WARN_ON(size == 0) || WARN_ON(size & 4095) ||
489+
WARN_ON(stolen_offset & 4095))
492490
return NULL;
493491

494492
stolen = kzalloc(sizeof(*stolen), GFP_KERNEL);

‎drivers/gpu/drm/i915/intel_display.c‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2371,13 +2371,19 @@ intel_alloc_plane_obj(struct intel_crtc *crtc,
23712371
struct drm_device *dev = crtc->base.dev;
23722372
struct drm_i915_gem_object *obj = NULL;
23732373
struct drm_mode_fb_cmd2 mode_cmd = { 0 };
2374-
u32 base = plane_config->base;
2374+
u32 base_aligned = round_down(plane_config->base, PAGE_SIZE);
2375+
u32 size_aligned = round_up(plane_config->base + plane_config->size,
2376+
PAGE_SIZE);
2377+
2378+
size_aligned -= base_aligned;
23752379

23762380
if (plane_config->size == 0)
23772381
return false;
23782382

2379-
obj = i915_gem_object_create_stolen_for_preallocated(dev, base, base,
2380-
plane_config->size);
2383+
obj = i915_gem_object_create_stolen_for_preallocated(dev,
2384+
base_aligned,
2385+
base_aligned,
2386+
size_aligned);
23812387
if (!obj)
23822388
return false;
23832389

@@ -6636,7 +6642,7 @@ i9xx_get_initial_plane_config(struct intel_crtc *crtc,
66366642
aligned_height = intel_fb_align_height(dev, fb->height,
66376643
plane_config->tiling);
66386644

6639-
plane_config->size = PAGE_ALIGN(fb->pitches[0] * aligned_height);
6645+
plane_config->size = fb->pitches[0] * aligned_height;
66406646

66416647
DRM_DEBUG_KMS("pipe/plane %c/%d with fb: size=%dx%d@%d, offset=%x, pitch %d, size 0x%x\n",
66426648
pipe_name(pipe), plane, fb->width, fb->height,
@@ -7673,7 +7679,7 @@ skylake_get_initial_plane_config(struct intel_crtc *crtc,
76737679
aligned_height = intel_fb_align_height(dev, fb->height,
76747680
plane_config->tiling);
76757681

7676-
plane_config->size = ALIGN(fb->pitches[0] * aligned_height, PAGE_SIZE);
7682+
plane_config->size = fb->pitches[0] * aligned_height;
76777683

76787684
DRM_DEBUG_KMS("pipe %c with fb: size=%dx%d@%d, offset=%x, pitch %d, size 0x%x\n",
76797685
pipe_name(pipe), fb->width, fb->height,
@@ -7764,7 +7770,7 @@ ironlake_get_initial_plane_config(struct intel_crtc *crtc,
77647770
aligned_height = intel_fb_align_height(dev, fb->height,
77657771
plane_config->tiling);
77667772

7767-
plane_config->size = PAGE_ALIGN(fb->pitches[0] * aligned_height);
7773+
plane_config->size = fb->pitches[0] * aligned_height;
77687774

77697775
DRM_DEBUG_KMS("pipe %c with fb: size=%dx%d@%d, offset=%x, pitch %d, size 0x%x\n",
77707776
pipe_name(pipe), fb->width, fb->height,

0 commit comments

Comments
 (0)