Skip to content

Commit 4d4de1c

Browse files
committed
drm/i915/gt: limit lmem allocation size to succeed on SmallBars
In case system is short on mappable memory (256MB on SmallBar) allocation of two 1GB buffers will fail. Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/8300 Signed-off-by: Andrzej Hajda <andrzej.hajda@intel.com> Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20230601144450.792228-1-andrzej.hajda@intel.com
1 parent 1baeef6 commit 4d4de1c

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

drivers/gpu/drm/i915/gt/selftest_tlb.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,18 @@ pte_tlbinv(struct intel_context *ce,
190190

191191
static struct drm_i915_gem_object *create_lmem(struct intel_gt *gt)
192192
{
193+
struct intel_memory_region *mr = gt->i915->mm.regions[INTEL_REGION_LMEM_0];
194+
resource_size_t size = SZ_1G;
195+
193196
/*
194197
* Allocation of largest possible page size allows to test all types
195-
* of pages.
198+
* of pages. To succeed with both allocations, especially in case of Small
199+
* BAR, try to allocate no more than quarter of mappable memory.
196200
*/
197-
return i915_gem_object_create_lmem(gt->i915, SZ_1G, I915_BO_ALLOC_CONTIGUOUS);
201+
if (mr && size > mr->io_size / 4)
202+
size = mr->io_size / 4;
203+
204+
return i915_gem_object_create_lmem(gt->i915, size, I915_BO_ALLOC_CONTIGUOUS);
198205
}
199206

200207
static struct drm_i915_gem_object *create_smem(struct intel_gt *gt)

0 commit comments

Comments
 (0)