Skip to content

Commit 3c6b29b

Browse files
committed
drm/i915: fully apply WaSkipStolenMemoryFirstPage
Don't even tell the mm allocator to handle the first page of stolen on the affected platforms. This means that we won't inherit the FB in case the BIOS decides to put it at the start of stolen. But the BIOS should not be putting it at the start of stolen since it's going to get corrupted. I suppose the bug here is that some pixels at the very top of the screen will be corrupted, so it's not exactly easy to notice. We have confirmation that the first page of stolen does actually get corrupted, so I really think we should do this in order to avoid any possible future headaches, even if that means losing BIOS framebuffer inheritance. Let's not use the HW in a way it's not supposed to be used. Notice that now ggtt->stolen_usable_size won't reflect the ending address of the stolen usable range anymore, so we have to fix the places that rely on this. To simplify, we'll just use U64_MAX. v2: don't even put the first page on the mm (Chris) v3: drm_mm_init() takes size instead of end as argument (Ville) v4: add a comment explaining the reserved ranges (Chris) use 0 for start and U64_MAX for end when possible (Chris) Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94605 Cc: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Link: http://patchwork.freedesktop.org/patch/msgid/1481808235-27607-1-git-send-email-paulo.r.zanoni@intel.com
1 parent d435376 commit 3c6b29b

File tree

3 files changed

+22
-26
lines changed

3 files changed

+22
-26
lines changed

drivers/gpu/drm/i915/i915_gem_gtt.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,16 @@ struct i915_ggtt {
315315
struct i915_address_space base;
316316
struct io_mapping mappable; /* Mapping to our CPU mappable region */
317317

318+
/* Stolen memory is segmented in hardware with different portions
319+
* offlimits to certain functions.
320+
*
321+
* The drm_mm is initialised to the total accessible range, as found
322+
* from the PCI config. On Broadwell+, this is further restricted to
323+
* avoid the first page! The upper end of stolen memory is reserved for
324+
* hardware functions and similarly removed from the accessible range.
325+
*/
318326
size_t stolen_size; /* Total size of stolen memory */
319-
size_t stolen_usable_size; /* Total size minus BIOS reserved */
327+
size_t stolen_usable_size; /* Total size minus reserved ranges */
320328
size_t stolen_reserved_base;
321329
size_t stolen_reserved_size;
322330
u64 mappable_end; /* End offset that we can CPU map */

drivers/gpu/drm/i915/i915_gem_stolen.c

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,6 @@ int i915_gem_stolen_insert_node_in_range(struct drm_i915_private *dev_priv,
5454
if (!drm_mm_initialized(&dev_priv->mm.stolen))
5555
return -ENODEV;
5656

57-
/* See the comment at the drm_mm_init() call for more about this check.
58-
* WaSkipStolenMemoryFirstPage:bdw+ (incomplete)
59-
*/
60-
if (start < 4096 && INTEL_GEN(dev_priv) >= 8)
61-
start = 4096;
62-
6357
mutex_lock(&dev_priv->mm.stolen_lock);
6458
ret = drm_mm_insert_node_in_range(&dev_priv->mm.stolen, node, size,
6559
alignment, start, end,
@@ -73,11 +67,8 @@ int i915_gem_stolen_insert_node(struct drm_i915_private *dev_priv,
7367
struct drm_mm_node *node, u64 size,
7468
unsigned alignment)
7569
{
76-
struct i915_ggtt *ggtt = &dev_priv->ggtt;
77-
7870
return i915_gem_stolen_insert_node_in_range(dev_priv, node, size,
79-
alignment, 0,
80-
ggtt->stolen_usable_size);
71+
alignment, 0, U64_MAX);
8172
}
8273

8374
void i915_gem_stolen_remove_node(struct drm_i915_private *dev_priv,
@@ -410,7 +401,7 @@ int i915_gem_init_stolen(struct drm_i915_private *dev_priv)
410401
{
411402
struct i915_ggtt *ggtt = &dev_priv->ggtt;
412403
unsigned long reserved_total, reserved_base = 0, reserved_size;
413-
unsigned long stolen_top;
404+
unsigned long stolen_usable_start, stolen_top;
414405

415406
mutex_init(&dev_priv->mm.stolen_lock);
416407

@@ -488,20 +479,17 @@ int i915_gem_init_stolen(struct drm_i915_private *dev_priv)
488479
ggtt->stolen_size >> 10,
489480
(ggtt->stolen_size - reserved_total) >> 10);
490481

491-
ggtt->stolen_usable_size = ggtt->stolen_size - reserved_total;
482+
stolen_usable_start = 0;
483+
/* WaSkipStolenMemoryFirstPage:bdw+ */
484+
if (INTEL_GEN(dev_priv) >= 8)
485+
stolen_usable_start = 4096;
492486

493-
/*
494-
* Basic memrange allocator for stolen space.
495-
*
496-
* TODO: Notice that some platforms require us to not use the first page
497-
* of the stolen memory but their BIOSes may still put the framebuffer
498-
* on the first page. So we don't reserve this page for now because of
499-
* that. Our current solution is to just prevent new nodes from being
500-
* inserted on the first page - see the check we have at
501-
* i915_gem_stolen_insert_node_in_range(). We may want to fix the fbcon
502-
* problem later.
503-
*/
504-
drm_mm_init(&dev_priv->mm.stolen, 0, ggtt->stolen_usable_size);
487+
ggtt->stolen_usable_size = ggtt->stolen_size - reserved_total -
488+
stolen_usable_start;
489+
490+
/* Basic memrange allocator for stolen space. */
491+
drm_mm_init(&dev_priv->mm.stolen, stolen_usable_start,
492+
ggtt->stolen_usable_size);
505493

506494
return 0;
507495
}

drivers/gpu/drm/i915/intel_fbc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ static int find_compression_threshold(struct drm_i915_private *dev_priv,
538538
IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv))
539539
end = ggtt->stolen_size - 8 * 1024 * 1024;
540540
else
541-
end = ggtt->stolen_usable_size;
541+
end = U64_MAX;
542542

543543
/* HACK: This code depends on what we will do in *_enable_fbc. If that
544544
* code changes, this code needs to change as well.

0 commit comments

Comments
 (0)