From: "José Roberto de Souza" <jose.souza@intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: Steve Carbonari <steven.carbonari@intel.com>,
Lucas De Marchi <lucas.demarchi@intel.com>
Subject: [Intel-gfx] [PATCH v2] drm/i915: Check stolen memory size before calling drm_mm_init
Date: Wed, 23 Feb 2022 11:49:46 -0800 [thread overview]
Message-ID: <20220223194946.725328-1-jose.souza@intel.com> (raw)
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 cases that usable stolen is smaller than
page size(amount mapped and used to test memory).
v2:
- skiping test if available memory is smaller than page size (Lucas)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Signed-off-by: Steve Carbonari <steven.carbonari@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..16ab62d605b1a 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) < PAGE_SIZE)
+ return 0;
+
+ last = resource_size(&mem->region) - PAGE_SIZE;
+
/*
* Quick test to check read/write access to the iomap (backing store).
*
--
2.35.1
next reply other threads:[~2022-02-23 19:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-23 19:49 José Roberto de Souza [this message]
2022-02-23 21:43 ` [Intel-gfx] [PATCH v2] drm/i915: Check stolen memory size before calling drm_mm_init Lucas De Marchi
2022-02-24 13:14 ` [Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915: Check stolen memory size before calling drm_mm_init (rev4) Patchwork
2022-02-25 2:03 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2022-02-09 20:43 [Intel-gfx] [PATCH v2] drm/i915: Check stolen memory size before calling drm_mm_init José Roberto de Souza
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220223194946.725328-1-jose.souza@intel.com \
--to=jose.souza@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=lucas.demarchi@intel.com \
--cc=steven.carbonari@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox