[Intel-gfx] [PATCH] drm/i915: Check stolen memory size before calling drm_mm_init
Lucas De Marchi
lucas.demarchi at intel.com
Wed Feb 23 19:24:52 UTC 2022
On Wed, Feb 23, 2022 at 11:12:56AM -0800, Jose Souza wrote:
>Add check for zero usable stolen memory before calling drm_mm_init
>to support configurations where stolen memory exists but is fully
>reserved.
>
>Also skip memory test in such case.
>
>Cc: Ville Syrjälä <ville.syrjala at linux.intel.com>
>Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio at intel.com>
>Cc: Lucas De Marchi <lucas.demarchi at intel.com>
>Signed-off-by: José Roberto de Souza <jose.souza at intel.com>
>Signed-off-by: Steve Carbonari <steven.carbonari at intel.com>
>---
> drivers/gpu/drm/i915/gem/i915_gem_stolen.c | 9 ++++++---
> drivers/gpu/drm/i915/intel_memory_region.c | 8 ++++++--
> 2 files changed, 12 insertions(+), 5 deletions(-)
>
>diff --git a/drivers/gpu/drm/i915/gem/i915_gem_stolen.c b/drivers/gpu/drm/i915/gem/i915_gem_stolen.c
>index b9c3196b91cab..636cdf8a73b0a 100644
>--- a/drivers/gpu/drm/i915/gem/i915_gem_stolen.c
>+++ b/drivers/gpu/drm/i915/gem/i915_gem_stolen.c
>@@ -497,13 +497,16 @@ static int i915_gem_init_stolen(struct intel_memory_region *mem)
> * memory, so just consider the start. */
> reserved_total = stolen_top - reserved_base;
>
>+ i915->stolen_usable_size =
>+ resource_size(&i915->dsm) - reserved_total;
>+
> drm_dbg(&i915->drm,
> "Memory reserved for graphics device: %lluK, usable: %lluK\n",
> (u64)resource_size(&i915->dsm) >> 10,
>- ((u64)resource_size(&i915->dsm) - reserved_total) >> 10);
>+ (u64)i915->stolen_usable_size >> 10);
>
>- i915->stolen_usable_size =
>- resource_size(&i915->dsm) - reserved_total;
>+ if (i915->stolen_usable_size == 0)
>+ return 0;
>
> /* Basic memrange allocator for stolen space. */
> drm_mm_init(&i915->mm.stolen, 0, i915->stolen_usable_size);
>diff --git a/drivers/gpu/drm/i915/intel_memory_region.c b/drivers/gpu/drm/i915/intel_memory_region.c
>index c70d7e286a512..1cbe194e01f6b 100644
>--- a/drivers/gpu/drm/i915/intel_memory_region.c
>+++ b/drivers/gpu/drm/i915/intel_memory_region.c
>@@ -97,10 +97,14 @@ static int iomemtest(struct intel_memory_region *mem,
> bool test_all,
> const void *caller)
> {
>- resource_size_t last = resource_size(&mem->region) - PAGE_SIZE;
>- resource_size_t page;
>+ resource_size_t last, page;
> int err;
>
>+ if (resource_size(&mem->region) == 0)
shouldn't this check be like below?
if (resource_size(&mem->region) < PAGE_SIZE)
Lucas De Marchi
>+ return 0;
>+
>+ last = resource_size(&mem->region) - PAGE_SIZE;
>+
> /*
> * Quick test to check read/write access to the iomap (backing store).
> *
>--
>2.35.1
>
More information about the Intel-gfx
mailing list