Skip to content

Commit 171c32b

Browse files
danvetsashalevin
authored andcommitted
drm/i915: Align initial plane backing objects correctly
[ Upstream commit f37b5c2 ] 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> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
1 parent fea8f8a commit 171c32b

2 files changed

Lines changed: 12 additions & 11 deletions

File tree

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -485,10 +485,7 @@ 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 || stolen_offset & 4095 || size & 4095))
492489
return NULL;
493490

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

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2358,13 +2358,19 @@ static bool intel_alloc_plane_obj(struct intel_crtc *crtc,
23582358
struct drm_device *dev = crtc->base.dev;
23592359
struct drm_i915_gem_object *obj = NULL;
23602360
struct drm_mode_fb_cmd2 mode_cmd = { 0 };
2361-
u32 base = plane_config->base;
2361+
u32 base_aligned = round_down(plane_config->base, PAGE_SIZE);
2362+
u32 size_aligned = round_up(plane_config->base + plane_config->size,
2363+
PAGE_SIZE);
2364+
2365+
size_aligned -= base_aligned;
23622366

23632367
if (plane_config->size == 0)
23642368
return false;
23652369

2366-
obj = i915_gem_object_create_stolen_for_preallocated(dev, base, base,
2367-
plane_config->size);
2370+
obj = i915_gem_object_create_stolen_for_preallocated(dev,
2371+
base_aligned,
2372+
base_aligned,
2373+
size_aligned);
23682374
if (!obj)
23692375
return false;
23702376

@@ -6383,8 +6389,7 @@ static void i9xx_get_plane_config(struct intel_crtc *crtc,
63836389
aligned_height = intel_align_height(dev, crtc->base.primary->fb->height,
63846390
plane_config->tiled);
63856391

6386-
plane_config->size = PAGE_ALIGN(crtc->base.primary->fb->pitches[0] *
6387-
aligned_height);
6392+
plane_config->size = crtc->base.primary->fb->pitches[0] * aligned_height;
63886393

63896394
DRM_DEBUG_KMS("pipe/plane %d/%d with fb: size=%dx%d@%d, offset=%x, pitch %d, size 0x%x\n",
63906395
pipe, plane, crtc->base.primary->fb->width,
@@ -7424,8 +7429,7 @@ static void ironlake_get_plane_config(struct intel_crtc *crtc,
74247429
aligned_height = intel_align_height(dev, crtc->base.primary->fb->height,
74257430
plane_config->tiled);
74267431

7427-
plane_config->size = PAGE_ALIGN(crtc->base.primary->fb->pitches[0] *
7428-
aligned_height);
7432+
plane_config->size = crtc->base.primary->fb->pitches[0] * aligned_height;
74297433

74307434
DRM_DEBUG_KMS("pipe/plane %d/%d with fb: size=%dx%d@%d, offset=%x, pitch %d, size 0x%x\n",
74317435
pipe, plane, crtc->base.primary->fb->width,

0 commit comments

Comments
 (0)