Skip to content

Commit b7599d2

Browse files
Javier Pellorodrigovivi
authored andcommitted
drm/i915/gt: Fix reservation address in ggtt_reserve_guc_top
There is an assertion in ggtt_reserve_guc_top that the global GTT is of size at least GUC_GGTT_TOP, which is not the case on a 32-bit platform; see commit 562d55d ("drm/i915/bdw: Only use 2g GGTT for 32b platforms"). If GEM_BUG_ON is enabled, this triggers a BUG(); if GEM_BUG_ON is disabled, the subsequent reservation fails and the driver fails to initialise the device: i915 0000:00:02.0: [drm:i915_init_ggtt [i915]] Failed to reserve top of GGTT for GuC i915 0000:00:02.0: Device initialization failed (-28) i915 0000:00:02.0: Please file a bug on drm/i915; see https://gitlab.freedesktop.org/drm/intel/-/wikis/How-to-file-i915-bugs for details. i915: probe of 0000:00:02.0 failed with error -28 Make the reservation at the top of the available space, whatever that is, instead of assuming that the top will be GUC_GGTT_TOP. Fixes: 9118007 ("drm/i915/uc: Reserve upper range of GGTT") Link: https://gitlab.freedesktop.org/drm/intel/-/issues/9080 Signed-off-by: Javier Pello <devel@otheo.eu> Reviewed-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com> Cc: Fernando Pacheco <fernando.pacheco@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Cc: Jani Nikula <jani.nikula@linux.intel.com> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com> Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> Cc: intel-gfx@lists.freedesktop.org Cc: stable@vger.kernel.org # v5.3+ Signed-off-by: John Harrison <John.C.Harrison@Intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20230902171039.2229126186d697dbcf62d6d8@otheo.eu (cherry picked from commit 0f3fa94) Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
1 parent 863a8eb commit b7599d2

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

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

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -511,20 +511,31 @@ void intel_ggtt_unbind_vma(struct i915_address_space *vm,
511511
vm->clear_range(vm, vma_res->start, vma_res->vma_size);
512512
}
513513

514+
/*
515+
* Reserve the top of the GuC address space for firmware images. Addresses
516+
* beyond GUC_GGTT_TOP in the GuC address space are inaccessible by GuC,
517+
* which makes for a suitable range to hold GuC/HuC firmware images if the
518+
* size of the GGTT is 4G. However, on a 32-bit platform the size of the GGTT
519+
* is limited to 2G, which is less than GUC_GGTT_TOP, but we reserve a chunk
520+
* of the same size anyway, which is far more than needed, to keep the logic
521+
* in uc_fw_ggtt_offset() simple.
522+
*/
523+
#define GUC_TOP_RESERVE_SIZE (SZ_4G - GUC_GGTT_TOP)
524+
514525
static int ggtt_reserve_guc_top(struct i915_ggtt *ggtt)
515526
{
516-
u64 size;
527+
u64 offset;
517528
int ret;
518529

519530
if (!intel_uc_uses_guc(&ggtt->vm.gt->uc))
520531
return 0;
521532

522-
GEM_BUG_ON(ggtt->vm.total <= GUC_GGTT_TOP);
523-
size = ggtt->vm.total - GUC_GGTT_TOP;
533+
GEM_BUG_ON(ggtt->vm.total <= GUC_TOP_RESERVE_SIZE);
534+
offset = ggtt->vm.total - GUC_TOP_RESERVE_SIZE;
524535

525-
ret = i915_gem_gtt_reserve(&ggtt->vm, NULL, &ggtt->uc_fw, size,
526-
GUC_GGTT_TOP, I915_COLOR_UNEVICTABLE,
527-
PIN_NOEVICT);
536+
ret = i915_gem_gtt_reserve(&ggtt->vm, NULL, &ggtt->uc_fw,
537+
GUC_TOP_RESERVE_SIZE, offset,
538+
I915_COLOR_UNEVICTABLE, PIN_NOEVICT);
528539
if (ret)
529540
drm_dbg(&ggtt->vm.i915->drm,
530541
"Failed to reserve top of GGTT for GuC\n");

0 commit comments

Comments
 (0)