Commit 171c32b5 authored by Daniel Vetter's avatar Daniel Vetter Committed by Sasha Levin

drm/i915: Align initial plane backing objects correctly

[ Upstream commit f37b5c2b ]

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: default avatarJohannes W <jargon@molb.org>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
[Jani: split WARN_ONs, rebase on v4.0-rc1]
Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
Signed-off-by: default avatarSasha Levin <sasha.levin@oracle.com>
parent fea8f8a4
...@@ -485,10 +485,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev, ...@@ -485,10 +485,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,
stolen_offset, gtt_offset, size); stolen_offset, gtt_offset, size);
/* KISS and expect everything to be page-aligned */ /* KISS and expect everything to be page-aligned */
BUG_ON(stolen_offset & 4095); if (WARN_ON(size == 0 || stolen_offset & 4095 || size & 4095))
BUG_ON(size & 4095);
if (WARN_ON(size == 0))
return NULL; return NULL;
stolen = kzalloc(sizeof(*stolen), GFP_KERNEL); stolen = kzalloc(sizeof(*stolen), GFP_KERNEL);
......
...@@ -2358,13 +2358,19 @@ static bool intel_alloc_plane_obj(struct intel_crtc *crtc, ...@@ -2358,13 +2358,19 @@ static bool intel_alloc_plane_obj(struct intel_crtc *crtc,
struct drm_device *dev = crtc->base.dev; struct drm_device *dev = crtc->base.dev;
struct drm_i915_gem_object *obj = NULL; struct drm_i915_gem_object *obj = NULL;
struct drm_mode_fb_cmd2 mode_cmd = { 0 }; struct drm_mode_fb_cmd2 mode_cmd = { 0 };
u32 base = plane_config->base; u32 base_aligned = round_down(plane_config->base, PAGE_SIZE);
u32 size_aligned = round_up(plane_config->base + plane_config->size,
PAGE_SIZE);
size_aligned -= base_aligned;
if (plane_config->size == 0) if (plane_config->size == 0)
return false; return false;
obj = i915_gem_object_create_stolen_for_preallocated(dev, base, base, obj = i915_gem_object_create_stolen_for_preallocated(dev,
plane_config->size); base_aligned,
base_aligned,
size_aligned);
if (!obj) if (!obj)
return false; return false;
...@@ -6383,8 +6389,7 @@ static void i9xx_get_plane_config(struct intel_crtc *crtc, ...@@ -6383,8 +6389,7 @@ static void i9xx_get_plane_config(struct intel_crtc *crtc,
aligned_height = intel_align_height(dev, crtc->base.primary->fb->height, aligned_height = intel_align_height(dev, crtc->base.primary->fb->height,
plane_config->tiled); plane_config->tiled);
plane_config->size = PAGE_ALIGN(crtc->base.primary->fb->pitches[0] * plane_config->size = crtc->base.primary->fb->pitches[0] * aligned_height;
aligned_height);
DRM_DEBUG_KMS("pipe/plane %d/%d with fb: size=%dx%d@%d, offset=%x, pitch %d, size 0x%x\n", DRM_DEBUG_KMS("pipe/plane %d/%d with fb: size=%dx%d@%d, offset=%x, pitch %d, size 0x%x\n",
pipe, plane, crtc->base.primary->fb->width, pipe, plane, crtc->base.primary->fb->width,
...@@ -7424,8 +7429,7 @@ static void ironlake_get_plane_config(struct intel_crtc *crtc, ...@@ -7424,8 +7429,7 @@ static void ironlake_get_plane_config(struct intel_crtc *crtc,
aligned_height = intel_align_height(dev, crtc->base.primary->fb->height, aligned_height = intel_align_height(dev, crtc->base.primary->fb->height,
plane_config->tiled); plane_config->tiled);
plane_config->size = PAGE_ALIGN(crtc->base.primary->fb->pitches[0] * plane_config->size = crtc->base.primary->fb->pitches[0] * aligned_height;
aligned_height);
DRM_DEBUG_KMS("pipe/plane %d/%d with fb: size=%dx%d@%d, offset=%x, pitch %d, size 0x%x\n", DRM_DEBUG_KMS("pipe/plane %d/%d with fb: size=%dx%d@%d, offset=%x, pitch %d, size 0x%x\n",
pipe, plane, crtc->base.primary->fb->width, pipe, plane, crtc->base.primary->fb->width,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment