Sanity check that the memory region found through the Graphics Base of Stolen Memory is reserved and hidden from the rest of the system through the use of the resource API. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> Cc: Daniel Vetter <daniel.vetter at ffwll.ch> --- drivers/gpu/drm/i915/i915_gem_stolen.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c index 5a97b3c..f110d3e 100644 --- a/drivers/gpu/drm/i915/i915_gem_stolen.c +++ b/drivers/gpu/drm/i915/i915_gem_stolen.c @@ -44,6 +44,8 @@ static unsigned long i915_stolen_to_physical(struct drm_device *dev) { + struct drm_i915_private *dev_priv = dev->dev_private; + struct resource *r; u32 base; /* Almost universally we can find the Graphics Base of Stolen Memory @@ -69,6 +71,21 @@ static unsigned long i915_stolen_to_physical(struct drm_device *dev) #endif } + if (base == 0) + return 0; + + /* Verify that nothing else uses this physical address. Stolen + * memory should be reserved by the BIOS and hidden from the + * kernel. So if the region is already marked as busy, something + * is seriously wrong. + */ + r = request_mem_region(base, dev_priv->gtt.stolen_size, "i915 stolen"); + if (r == NULL) { + DRM_ERROR("conflict detected with stolen region: [%u - %u]\n", + base, base + (uint32_t)dev_priv->gtt.stolen_size); + base = 0; + } + return base; } @@ -162,6 +179,10 @@ void i915_gem_cleanup_stolen(struct drm_device *dev) i915_gem_stolen_cleanup_compression(dev); drm_mm_takedown(&dev_priv->mm.stolen); + + if (dev_priv->mm.stolen_base != 0) + release_mem_region(dev_priv->mm.stolen_base, + dev_priv->gtt.stolen_size); } int i915_gem_init_stolen(struct drm_device *dev) -- 1.8.3.2