2020-01-07 13:40:09 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
/*
|
|
|
|
|
* Copyright © 2020 Intel Corporation
|
|
|
|
|
*/
|
|
|
|
|
|
2022-03-30 16:48:08 -07:00
|
|
|
#include <linux/types.h>
|
2020-01-07 13:40:09 +00:00
|
|
|
#include <asm/set_memory.h>
|
2020-01-09 09:23:03 +08:00
|
|
|
#include <asm/smp.h>
|
2020-01-07 13:40:09 +00:00
|
|
|
|
2020-02-25 15:31:31 +02:00
|
|
|
#include <drm/i915_drm.h>
|
|
|
|
|
|
2021-02-03 17:12:31 +00:00
|
|
|
#include "gem/i915_gem_lmem.h"
|
|
|
|
|
|
2020-01-07 13:40:09 +00:00
|
|
|
#include "intel_gt.h"
|
2022-03-30 16:48:08 -07:00
|
|
|
#include "intel_gt_gmch.h"
|
2022-01-27 15:43:33 -08:00
|
|
|
#include "intel_gt_regs.h"
|
2020-01-07 13:40:09 +00:00
|
|
|
#include "i915_drv.h"
|
|
|
|
|
#include "i915_scatterlist.h"
|
2022-03-29 10:02:04 +01:00
|
|
|
#include "i915_utils.h"
|
2020-01-07 13:40:09 +00:00
|
|
|
#include "i915_vgpu.h"
|
|
|
|
|
|
|
|
|
|
#include "intel_gtt.h"
|
2021-05-06 19:19:24 +03:00
|
|
|
#include "gen8_ppgtt.h"
|
2020-01-07 13:40:09 +00:00
|
|
|
|
|
|
|
|
static void i915_ggtt_color_adjust(const struct drm_mm_node *node,
|
|
|
|
|
unsigned long color,
|
|
|
|
|
u64 *start,
|
|
|
|
|
u64 *end)
|
|
|
|
|
{
|
|
|
|
|
if (i915_node_color_differs(node, color))
|
|
|
|
|
*start += I915_GTT_PAGE_SIZE;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Also leave a space between the unallocated reserved node after the
|
|
|
|
|
* GTT and any objects within the GTT, i.e. we use the color adjustment
|
|
|
|
|
* to insert a guard page to prevent prefetches crossing over the
|
|
|
|
|
* GTT boundary.
|
|
|
|
|
*/
|
|
|
|
|
node = list_next_entry(node, node_list);
|
|
|
|
|
if (node->color != color)
|
|
|
|
|
*end -= I915_GTT_PAGE_SIZE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int ggtt_init_hw(struct i915_ggtt *ggtt)
|
|
|
|
|
{
|
|
|
|
|
struct drm_i915_private *i915 = ggtt->vm.i915;
|
|
|
|
|
|
|
|
|
|
i915_address_space_init(&ggtt->vm, VM_CLASS_GGTT);
|
|
|
|
|
|
|
|
|
|
ggtt->vm.is_ggtt = true;
|
|
|
|
|
|
|
|
|
|
/* Only VLV supports read-only GGTT mappings */
|
|
|
|
|
ggtt->vm.has_read_only = IS_VALLEYVIEW(i915);
|
|
|
|
|
|
|
|
|
|
if (!HAS_LLC(i915) && !HAS_PPGTT(i915))
|
|
|
|
|
ggtt->vm.mm.color_adjust = i915_ggtt_color_adjust;
|
|
|
|
|
|
|
|
|
|
if (ggtt->mappable_end) {
|
|
|
|
|
if (!io_mapping_init_wc(&ggtt->iomap,
|
|
|
|
|
ggtt->gmadr.start,
|
|
|
|
|
ggtt->mappable_end)) {
|
|
|
|
|
ggtt->vm.cleanup(&ggtt->vm);
|
|
|
|
|
return -EIO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ggtt->mtrr = arch_phys_wc_add(ggtt->gmadr.start,
|
|
|
|
|
ggtt->mappable_end);
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-16 11:38:43 +00:00
|
|
|
intel_ggtt_init_fences(ggtt);
|
2020-01-07 13:40:09 +00:00
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* i915_ggtt_init_hw - Initialize GGTT hardware
|
|
|
|
|
* @i915: i915 device
|
|
|
|
|
*/
|
|
|
|
|
int i915_ggtt_init_hw(struct drm_i915_private *i915)
|
|
|
|
|
{
|
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Note that we use page colouring to enforce a guard page at the
|
|
|
|
|
* end of the address space. This is required as the CS may prefetch
|
|
|
|
|
* beyond the end of the batch buffer, across the page boundary,
|
|
|
|
|
* and beyond the end of the GTT if we do not provide a guard.
|
|
|
|
|
*/
|
2021-12-21 21:59:46 +02:00
|
|
|
ret = ggtt_init_hw(to_gt(i915)->ggtt);
|
2020-01-07 13:40:09 +00:00
|
|
|
if (ret)
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-01 20:35:50 +02:00
|
|
|
/**
|
|
|
|
|
* i915_ggtt_suspend_vm - Suspend the memory mappings for a GGTT or DPT VM
|
|
|
|
|
* @vm: The VM to suspend the mappings for
|
|
|
|
|
*
|
|
|
|
|
* Suspend the memory mappings for all objects mapped to HW via the GGTT or a
|
|
|
|
|
* DPT page table.
|
|
|
|
|
*/
|
|
|
|
|
void i915_ggtt_suspend_vm(struct i915_address_space *vm)
|
2020-01-07 13:40:09 +00:00
|
|
|
{
|
2020-05-28 09:24:27 +01:00
|
|
|
struct i915_vma *vma, *vn;
|
2022-03-04 09:26:39 +01:00
|
|
|
int save_skip_rewrite;
|
2020-01-30 18:17:10 +00:00
|
|
|
|
2021-11-01 20:35:50 +02:00
|
|
|
drm_WARN_ON(&vm->i915->drm, !vm->is_ggtt && !vm->is_dpt);
|
|
|
|
|
|
2022-01-14 14:23:18 +01:00
|
|
|
retry:
|
|
|
|
|
i915_gem_drain_freed_objects(vm->i915);
|
|
|
|
|
|
2021-11-01 20:35:50 +02:00
|
|
|
mutex_lock(&vm->mutex);
|
2020-05-28 09:24:27 +01:00
|
|
|
|
2022-03-04 09:26:39 +01:00
|
|
|
/*
|
|
|
|
|
* Skip rewriting PTE on VMA unbind.
|
|
|
|
|
* FIXME: Use an argument to i915_vma_unbind() instead?
|
|
|
|
|
*/
|
|
|
|
|
save_skip_rewrite = vm->skip_pte_rewrite;
|
|
|
|
|
vm->skip_pte_rewrite = true;
|
2020-05-28 09:24:27 +01:00
|
|
|
|
2021-11-01 20:35:50 +02:00
|
|
|
list_for_each_entry_safe(vma, vn, &vm->bound_list, vm_link) {
|
2022-01-14 14:23:18 +01:00
|
|
|
struct drm_i915_gem_object *obj = vma->obj;
|
|
|
|
|
|
2020-05-28 09:24:27 +01:00
|
|
|
GEM_BUG_ON(!drm_mm_node_allocated(&vma->node));
|
2020-01-30 18:17:10 +00:00
|
|
|
|
2022-01-14 14:23:18 +01:00
|
|
|
if (i915_vma_is_pinned(vma) || !i915_vma_is_bound(vma, I915_VMA_GLOBAL_BIND))
|
2020-05-28 09:24:27 +01:00
|
|
|
continue;
|
|
|
|
|
|
2022-01-14 14:23:18 +01:00
|
|
|
/* unlikely to race when GPU is idle, so no worry about slowpath.. */
|
|
|
|
|
if (WARN_ON(!i915_gem_object_trylock(obj, NULL))) {
|
|
|
|
|
/*
|
|
|
|
|
* No dead objects should appear here, GPU should be
|
|
|
|
|
* completely idle, and userspace suspended
|
|
|
|
|
*/
|
|
|
|
|
i915_gem_object_get(obj);
|
|
|
|
|
|
|
|
|
|
mutex_unlock(&vm->mutex);
|
|
|
|
|
|
|
|
|
|
i915_gem_object_lock(obj, NULL);
|
2022-03-04 09:26:39 +01:00
|
|
|
GEM_WARN_ON(i915_vma_unbind(vma));
|
2022-01-14 14:23:18 +01:00
|
|
|
i915_gem_object_unlock(obj);
|
|
|
|
|
i915_gem_object_put(obj);
|
2022-03-04 09:26:39 +01:00
|
|
|
|
|
|
|
|
vm->skip_pte_rewrite = save_skip_rewrite;
|
2022-01-14 14:23:18 +01:00
|
|
|
goto retry;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-28 09:24:27 +01:00
|
|
|
if (!i915_vma_is_bound(vma, I915_VMA_GLOBAL_BIND)) {
|
2022-01-14 14:23:18 +01:00
|
|
|
i915_vma_wait_for_bind(vma);
|
|
|
|
|
|
2022-01-10 18:22:17 +01:00
|
|
|
__i915_vma_evict(vma, false);
|
2020-05-28 09:24:27 +01:00
|
|
|
drm_mm_remove_node(&vma->node);
|
|
|
|
|
}
|
2022-01-14 14:23:18 +01:00
|
|
|
|
|
|
|
|
i915_gem_object_unlock(obj);
|
2020-05-28 09:24:27 +01:00
|
|
|
}
|
|
|
|
|
|
2021-11-01 20:35:50 +02:00
|
|
|
vm->clear_range(vm, 0, vm->total);
|
2020-05-28 09:24:27 +01:00
|
|
|
|
2022-03-04 09:26:39 +01:00
|
|
|
vm->skip_pte_rewrite = save_skip_rewrite;
|
2021-11-01 20:35:50 +02:00
|
|
|
|
|
|
|
|
mutex_unlock(&vm->mutex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void i915_ggtt_suspend(struct i915_ggtt *ggtt)
|
|
|
|
|
{
|
|
|
|
|
i915_ggtt_suspend_vm(&ggtt->vm);
|
|
|
|
|
ggtt->invalidate(ggtt);
|
2020-01-07 13:40:09 +00:00
|
|
|
|
2020-01-30 18:17:09 +00:00
|
|
|
intel_gt_check_and_clear_faults(ggtt->vm.gt);
|
2020-01-07 13:40:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void gen6_ggtt_invalidate(struct i915_ggtt *ggtt)
|
|
|
|
|
{
|
|
|
|
|
struct intel_uncore *uncore = ggtt->vm.gt->uncore;
|
|
|
|
|
|
|
|
|
|
spin_lock_irq(&uncore->lock);
|
|
|
|
|
intel_uncore_write_fw(uncore, GFX_FLSH_CNTL_GEN6, GFX_FLSH_CNTL_EN);
|
|
|
|
|
intel_uncore_read_fw(uncore, GFX_FLSH_CNTL_GEN6);
|
|
|
|
|
spin_unlock_irq(&uncore->lock);
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:48:08 -07:00
|
|
|
void gen8_ggtt_invalidate(struct i915_ggtt *ggtt)
|
2020-01-07 13:40:09 +00:00
|
|
|
{
|
|
|
|
|
struct intel_uncore *uncore = ggtt->vm.gt->uncore;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Note that as an uncached mmio write, this will flush the
|
|
|
|
|
* WCB of the writes into the GGTT before it triggers the invalidate.
|
|
|
|
|
*/
|
|
|
|
|
intel_uncore_write_fw(uncore, GFX_FLSH_CNTL_GEN6, GFX_FLSH_CNTL_EN);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void guc_ggtt_invalidate(struct i915_ggtt *ggtt)
|
|
|
|
|
{
|
|
|
|
|
struct intel_uncore *uncore = ggtt->vm.gt->uncore;
|
|
|
|
|
struct drm_i915_private *i915 = ggtt->vm.i915;
|
|
|
|
|
|
|
|
|
|
gen8_ggtt_invalidate(ggtt);
|
|
|
|
|
|
2021-06-05 08:53:52 -07:00
|
|
|
if (GRAPHICS_VER(i915) >= 12)
|
2020-01-07 13:40:09 +00:00
|
|
|
intel_uncore_write_fw(uncore, GEN12_GUC_TLB_INV_CR,
|
|
|
|
|
GEN12_GUC_TLB_INV_CR_INVALIDATE);
|
|
|
|
|
else
|
|
|
|
|
intel_uncore_write_fw(uncore, GEN8_GTCR, GEN8_GTCR_INVALIDATE);
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-06 19:19:24 +03:00
|
|
|
u64 gen8_ggtt_pte_encode(dma_addr_t addr,
|
|
|
|
|
enum i915_cache_level level,
|
|
|
|
|
u32 flags)
|
drm/i915/ggtt: do not set bits 1-11 in gen12 ptes
On TGL, bits 2-4 in the GGTT PTE are not ignored anymore and are
instead used for some extra VT-d capabilities. We don't (yet?) have
support for those capabilities, but, given that we shared the pte_encode
function betweed GGTT and PPGTT, we still set those bits to the PPGTT
PPAT values. The DMA engine gets very confused when those bits are
set while the iommu is enabled, leading to errors. E.g. when loading
the GuC we get:
[ 9.796218] DMAR: DRHD: handling fault status reg 2
[ 9.796235] DMAR: [DMA Write] Request device [00:02.0] PASID ffffffff fault addr 0 [fault reason 02] Present bit in context entry is clear
[ 9.899215] [drm:intel_guc_fw_upload [i915]] *ERROR* GuC firmware signature verification failed
To fix this, just have dedicated gen8_pte_encode function per type of
gtt. Also, explicitly set vm->pte_encode for gen8_ppgtt, even if we
don't use it, to make sure we don't accidentally assign it to the GGTT
one, like we do for gen6_ppgtt, in case we need it in the future.
Reported-by: "Sodhi, Vunny" <vunny.sodhi@intel.com>
Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Cc: Matthew Auld <matthew.auld@intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20200226185657.26445-1-daniele.ceraolospurio@intel.com
2020-02-26 10:56:57 -08:00
|
|
|
{
|
2021-12-06 13:52:45 -08:00
|
|
|
gen8_pte_t pte = addr | GEN8_PAGE_PRESENT;
|
2021-02-03 17:12:31 +00:00
|
|
|
|
|
|
|
|
if (flags & PTE_LM)
|
|
|
|
|
pte |= GEN12_GGTT_PTE_LM;
|
|
|
|
|
|
|
|
|
|
return pte;
|
drm/i915/ggtt: do not set bits 1-11 in gen12 ptes
On TGL, bits 2-4 in the GGTT PTE are not ignored anymore and are
instead used for some extra VT-d capabilities. We don't (yet?) have
support for those capabilities, but, given that we shared the pte_encode
function betweed GGTT and PPGTT, we still set those bits to the PPGTT
PPAT values. The DMA engine gets very confused when those bits are
set while the iommu is enabled, leading to errors. E.g. when loading
the GuC we get:
[ 9.796218] DMAR: DRHD: handling fault status reg 2
[ 9.796235] DMAR: [DMA Write] Request device [00:02.0] PASID ffffffff fault addr 0 [fault reason 02] Present bit in context entry is clear
[ 9.899215] [drm:intel_guc_fw_upload [i915]] *ERROR* GuC firmware signature verification failed
To fix this, just have dedicated gen8_pte_encode function per type of
gtt. Also, explicitly set vm->pte_encode for gen8_ppgtt, even if we
don't use it, to make sure we don't accidentally assign it to the GGTT
one, like we do for gen6_ppgtt, in case we need it in the future.
Reported-by: "Sodhi, Vunny" <vunny.sodhi@intel.com>
Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Cc: Matthew Auld <matthew.auld@intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20200226185657.26445-1-daniele.ceraolospurio@intel.com
2020-02-26 10:56:57 -08:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:48:08 -07:00
|
|
|
void intel_ggtt_bind_vma(struct i915_address_space *vm,
|
2020-07-29 17:42:17 +01:00
|
|
|
struct i915_vm_pt_stash *stash,
|
2022-01-10 18:22:15 +01:00
|
|
|
struct i915_vma_resource *vma_res,
|
2020-07-29 17:42:17 +01:00
|
|
|
enum i915_cache_level cache_level,
|
|
|
|
|
u32 flags)
|
2020-01-07 13:40:09 +00:00
|
|
|
{
|
|
|
|
|
u32 pte_flags;
|
|
|
|
|
|
2022-01-10 18:22:15 +01:00
|
|
|
if (vma_res->bound_flags & (~flags & I915_VMA_BIND_MASK))
|
2020-07-29 17:42:17 +01:00
|
|
|
return;
|
2020-05-25 08:53:36 +01:00
|
|
|
|
2022-01-10 18:22:15 +01:00
|
|
|
vma_res->bound_flags |= flags;
|
|
|
|
|
|
2020-01-07 13:40:09 +00:00
|
|
|
/* Applicable to VLV (gen8+ do not support RO in the GGTT) */
|
|
|
|
|
pte_flags = 0;
|
2022-01-10 18:22:15 +01:00
|
|
|
if (vma_res->bi.readonly)
|
2020-01-07 13:40:09 +00:00
|
|
|
pte_flags |= PTE_READ_ONLY;
|
2022-01-10 18:22:15 +01:00
|
|
|
if (vma_res->bi.lmem)
|
2021-02-03 17:12:31 +00:00
|
|
|
pte_flags |= PTE_LM;
|
2020-01-07 13:40:09 +00:00
|
|
|
|
2022-01-10 18:22:15 +01:00
|
|
|
vm->insert_entries(vm, vma_res, cache_level, pte_flags);
|
|
|
|
|
vma_res->page_sizes_gtt = I915_GTT_PAGE_SIZE;
|
2020-01-07 13:40:09 +00:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:48:08 -07:00
|
|
|
void intel_ggtt_unbind_vma(struct i915_address_space *vm,
|
2022-01-10 18:22:15 +01:00
|
|
|
struct i915_vma_resource *vma_res)
|
2020-01-07 13:40:09 +00:00
|
|
|
{
|
2022-01-10 18:22:15 +01:00
|
|
|
vm->clear_range(vm, vma_res->start, vma_res->vma_size);
|
2020-01-07 13:40:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int ggtt_reserve_guc_top(struct i915_ggtt *ggtt)
|
|
|
|
|
{
|
|
|
|
|
u64 size;
|
|
|
|
|
int ret;
|
|
|
|
|
|
2020-02-18 14:33:19 -08:00
|
|
|
if (!intel_uc_uses_guc(&ggtt->vm.gt->uc))
|
2020-01-07 13:40:09 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
GEM_BUG_ON(ggtt->vm.total <= GUC_GGTT_TOP);
|
|
|
|
|
size = ggtt->vm.total - GUC_GGTT_TOP;
|
|
|
|
|
|
2022-01-14 14:23:17 +01:00
|
|
|
ret = i915_gem_gtt_reserve(&ggtt->vm, NULL, &ggtt->uc_fw, size,
|
2020-01-07 13:40:09 +00:00
|
|
|
GUC_GGTT_TOP, I915_COLOR_UNEVICTABLE,
|
|
|
|
|
PIN_NOEVICT);
|
|
|
|
|
if (ret)
|
2020-01-28 10:14:31 +03:00
|
|
|
drm_dbg(&ggtt->vm.i915->drm,
|
|
|
|
|
"Failed to reserve top of GGTT for GuC\n");
|
2020-01-07 13:40:09 +00:00
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void ggtt_release_guc_top(struct i915_ggtt *ggtt)
|
|
|
|
|
{
|
|
|
|
|
if (drm_mm_node_allocated(&ggtt->uc_fw))
|
|
|
|
|
drm_mm_remove_node(&ggtt->uc_fw);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void cleanup_init_ggtt(struct i915_ggtt *ggtt)
|
|
|
|
|
{
|
|
|
|
|
ggtt_release_guc_top(ggtt);
|
|
|
|
|
if (drm_mm_node_allocated(&ggtt->error_capture))
|
|
|
|
|
drm_mm_remove_node(&ggtt->error_capture);
|
2020-01-10 12:30:56 +00:00
|
|
|
mutex_destroy(&ggtt->error_mutex);
|
2020-01-07 13:40:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int init_ggtt(struct i915_ggtt *ggtt)
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
* Let GEM Manage all of the aperture.
|
|
|
|
|
*
|
|
|
|
|
* However, leave one page at the end still bound to the scratch page.
|
|
|
|
|
* There are a number of places where the hardware apparently prefetches
|
|
|
|
|
* past the end of the object, and we've seen multiple hangs with the
|
|
|
|
|
* GPU head pointer stuck in a batchbuffer bound at the last page of the
|
|
|
|
|
* aperture. One page should be enough to keep any prefetching inside
|
|
|
|
|
* of the aperture.
|
|
|
|
|
*/
|
|
|
|
|
unsigned long hole_start, hole_end;
|
|
|
|
|
struct drm_mm_node *entry;
|
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* GuC requires all resources that we're sharing with it to be placed in
|
|
|
|
|
* non-WOPCM memory. If GuC is not present or not in use we still need a
|
|
|
|
|
* small bias as ring wraparound at offset 0 sometimes hangs. No idea
|
|
|
|
|
* why.
|
|
|
|
|
*/
|
|
|
|
|
ggtt->pin_bias = max_t(u32, I915_GTT_PAGE_SIZE,
|
|
|
|
|
intel_wopcm_guc_size(&ggtt->vm.i915->wopcm));
|
|
|
|
|
|
|
|
|
|
ret = intel_vgt_balloon(ggtt);
|
|
|
|
|
if (ret)
|
|
|
|
|
return ret;
|
|
|
|
|
|
2020-01-10 12:30:56 +00:00
|
|
|
mutex_init(&ggtt->error_mutex);
|
2020-01-07 13:40:09 +00:00
|
|
|
if (ggtt->mappable_end) {
|
2021-01-25 12:50:33 +00:00
|
|
|
/*
|
|
|
|
|
* Reserve a mappable slot for our lockless error capture.
|
|
|
|
|
*
|
|
|
|
|
* We strongly prefer taking address 0x0 in order to protect
|
|
|
|
|
* other critical buffers against accidental overwrites,
|
|
|
|
|
* as writing to address 0 is a very common mistake.
|
|
|
|
|
*
|
|
|
|
|
* Since 0 may already be in use by the system (e.g. the BIOS
|
|
|
|
|
* framebuffer), we let the reservation fail quietly and hope
|
|
|
|
|
* 0 remains reserved always.
|
|
|
|
|
*
|
|
|
|
|
* If we fail to reserve 0, and then fail to find any space
|
|
|
|
|
* for an error-capture, remain silent. We can afford not
|
|
|
|
|
* to reserve an error_capture node as we have fallback
|
|
|
|
|
* paths, and we trust that 0 will remain reserved. However,
|
|
|
|
|
* the only likely reason for failure to insert is a driver
|
|
|
|
|
* bug, which we expect to cause other failures...
|
|
|
|
|
*/
|
|
|
|
|
ggtt->error_capture.size = I915_GTT_PAGE_SIZE;
|
|
|
|
|
ggtt->error_capture.color = I915_COLOR_UNEVICTABLE;
|
|
|
|
|
if (drm_mm_reserve_node(&ggtt->vm.mm, &ggtt->error_capture))
|
|
|
|
|
drm_mm_insert_node_in_range(&ggtt->vm.mm,
|
|
|
|
|
&ggtt->error_capture,
|
|
|
|
|
ggtt->error_capture.size, 0,
|
|
|
|
|
ggtt->error_capture.color,
|
|
|
|
|
0, ggtt->mappable_end,
|
|
|
|
|
DRM_MM_INSERT_LOW);
|
2020-01-07 13:40:09 +00:00
|
|
|
}
|
2021-01-25 12:50:33 +00:00
|
|
|
if (drm_mm_node_allocated(&ggtt->error_capture))
|
|
|
|
|
drm_dbg(&ggtt->vm.i915->drm,
|
|
|
|
|
"Reserved GGTT:[%llx, %llx] for use by error capture\n",
|
|
|
|
|
ggtt->error_capture.start,
|
|
|
|
|
ggtt->error_capture.start + ggtt->error_capture.size);
|
2020-01-07 13:40:09 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* The upper portion of the GuC address space has a sizeable hole
|
|
|
|
|
* (several MB) that is inaccessible by GuC. Reserve this range within
|
|
|
|
|
* GGTT as it can comfortably hold GuC/HuC firmware images.
|
|
|
|
|
*/
|
|
|
|
|
ret = ggtt_reserve_guc_top(ggtt);
|
|
|
|
|
if (ret)
|
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
|
|
/* Clear any non-preallocated blocks */
|
|
|
|
|
drm_mm_for_each_hole(entry, &ggtt->vm.mm, hole_start, hole_end) {
|
2021-01-25 12:50:33 +00:00
|
|
|
drm_dbg(&ggtt->vm.i915->drm,
|
|
|
|
|
"clearing unused GTT space: [%lx, %lx]\n",
|
|
|
|
|
hole_start, hole_end);
|
2020-01-07 13:40:09 +00:00
|
|
|
ggtt->vm.clear_range(&ggtt->vm, hole_start,
|
|
|
|
|
hole_end - hole_start);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* And finally clear the reserved guard page */
|
|
|
|
|
ggtt->vm.clear_range(&ggtt->vm, ggtt->vm.total - PAGE_SIZE, PAGE_SIZE);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
err:
|
|
|
|
|
cleanup_init_ggtt(ggtt);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-29 17:42:17 +01:00
|
|
|
static void aliasing_gtt_bind_vma(struct i915_address_space *vm,
|
|
|
|
|
struct i915_vm_pt_stash *stash,
|
2022-01-10 18:22:15 +01:00
|
|
|
struct i915_vma_resource *vma_res,
|
2020-07-29 17:42:17 +01:00
|
|
|
enum i915_cache_level cache_level,
|
|
|
|
|
u32 flags)
|
2020-01-07 13:40:09 +00:00
|
|
|
{
|
|
|
|
|
u32 pte_flags;
|
|
|
|
|
|
|
|
|
|
/* Currently applicable only to VLV */
|
|
|
|
|
pte_flags = 0;
|
2022-01-10 18:22:15 +01:00
|
|
|
if (vma_res->bi.readonly)
|
2020-01-07 13:40:09 +00:00
|
|
|
pte_flags |= PTE_READ_ONLY;
|
|
|
|
|
|
2020-07-29 17:42:17 +01:00
|
|
|
if (flags & I915_VMA_LOCAL_BIND)
|
|
|
|
|
ppgtt_bind_vma(&i915_vm_to_ggtt(vm)->alias->vm,
|
2022-01-10 18:22:15 +01:00
|
|
|
stash, vma_res, cache_level, flags);
|
2020-01-07 13:40:09 +00:00
|
|
|
|
2020-01-10 14:44:18 +00:00
|
|
|
if (flags & I915_VMA_GLOBAL_BIND)
|
2022-01-10 18:22:15 +01:00
|
|
|
vm->insert_entries(vm, vma_res, cache_level, pte_flags);
|
|
|
|
|
|
|
|
|
|
vma_res->bound_flags |= flags;
|
2020-01-07 13:40:09 +00:00
|
|
|
}
|
|
|
|
|
|
2020-07-03 11:25:19 +01:00
|
|
|
static void aliasing_gtt_unbind_vma(struct i915_address_space *vm,
|
2022-01-10 18:22:15 +01:00
|
|
|
struct i915_vma_resource *vma_res)
|
2020-01-07 13:40:09 +00:00
|
|
|
{
|
2022-01-10 18:22:15 +01:00
|
|
|
if (vma_res->bound_flags & I915_VMA_GLOBAL_BIND)
|
|
|
|
|
vm->clear_range(vm, vma_res->start, vma_res->vma_size);
|
2020-01-07 13:40:09 +00:00
|
|
|
|
2022-01-10 18:22:15 +01:00
|
|
|
if (vma_res->bound_flags & I915_VMA_LOCAL_BIND)
|
|
|
|
|
ppgtt_unbind_vma(&i915_vm_to_ggtt(vm)->alias->vm, vma_res);
|
2020-01-07 13:40:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int init_aliasing_ppgtt(struct i915_ggtt *ggtt)
|
|
|
|
|
{
|
2020-07-29 17:42:17 +01:00
|
|
|
struct i915_vm_pt_stash stash = {};
|
2020-01-07 13:40:09 +00:00
|
|
|
struct i915_ppgtt *ppgtt;
|
|
|
|
|
int err;
|
|
|
|
|
|
2021-09-22 08:25:25 +02:00
|
|
|
ppgtt = i915_ppgtt_create(ggtt->vm.gt, 0);
|
2020-01-07 13:40:09 +00:00
|
|
|
if (IS_ERR(ppgtt))
|
|
|
|
|
return PTR_ERR(ppgtt);
|
|
|
|
|
|
|
|
|
|
if (GEM_WARN_ON(ppgtt->vm.total < ggtt->vm.total)) {
|
|
|
|
|
err = -ENODEV;
|
|
|
|
|
goto err_ppgtt;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-29 17:42:17 +01:00
|
|
|
err = i915_vm_alloc_pt_stash(&ppgtt->vm, &stash, ggtt->vm.total);
|
|
|
|
|
if (err)
|
|
|
|
|
goto err_ppgtt;
|
|
|
|
|
|
2021-03-23 16:50:29 +01:00
|
|
|
i915_gem_object_lock(ppgtt->vm.scratch[0], NULL);
|
2021-04-27 09:54:13 +01:00
|
|
|
err = i915_vm_map_pt_stash(&ppgtt->vm, &stash);
|
2021-03-23 16:50:29 +01:00
|
|
|
i915_gem_object_unlock(ppgtt->vm.scratch[0]);
|
2020-07-29 17:42:18 +01:00
|
|
|
if (err)
|
|
|
|
|
goto err_stash;
|
|
|
|
|
|
2020-01-07 13:40:09 +00:00
|
|
|
/*
|
|
|
|
|
* Note we only pre-allocate as far as the end of the global
|
|
|
|
|
* GTT. On 48b / 4-level page-tables, the difference is very,
|
|
|
|
|
* very significant! We have to preallocate as GVT/vgpu does
|
|
|
|
|
* not like the page directory disappearing.
|
|
|
|
|
*/
|
2020-07-29 17:42:17 +01:00
|
|
|
ppgtt->vm.allocate_va_range(&ppgtt->vm, &stash, 0, ggtt->vm.total);
|
2020-01-07 13:40:09 +00:00
|
|
|
|
|
|
|
|
ggtt->alias = ppgtt;
|
|
|
|
|
ggtt->vm.bind_async_flags |= ppgtt->vm.bind_async_flags;
|
|
|
|
|
|
2022-03-30 16:48:08 -07:00
|
|
|
GEM_BUG_ON(ggtt->vm.vma_ops.bind_vma != intel_ggtt_bind_vma);
|
2020-01-07 13:40:09 +00:00
|
|
|
ggtt->vm.vma_ops.bind_vma = aliasing_gtt_bind_vma;
|
|
|
|
|
|
2022-03-30 16:48:08 -07:00
|
|
|
GEM_BUG_ON(ggtt->vm.vma_ops.unbind_vma != intel_ggtt_unbind_vma);
|
2020-01-07 13:40:09 +00:00
|
|
|
ggtt->vm.vma_ops.unbind_vma = aliasing_gtt_unbind_vma;
|
|
|
|
|
|
2020-07-29 17:42:17 +01:00
|
|
|
i915_vm_free_pt_stash(&ppgtt->vm, &stash);
|
2020-01-07 13:40:09 +00:00
|
|
|
return 0;
|
|
|
|
|
|
2020-07-29 17:42:18 +01:00
|
|
|
err_stash:
|
|
|
|
|
i915_vm_free_pt_stash(&ppgtt->vm, &stash);
|
2020-01-07 13:40:09 +00:00
|
|
|
err_ppgtt:
|
|
|
|
|
i915_vm_put(&ppgtt->vm);
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void fini_aliasing_ppgtt(struct i915_ggtt *ggtt)
|
|
|
|
|
{
|
|
|
|
|
struct i915_ppgtt *ppgtt;
|
|
|
|
|
|
|
|
|
|
ppgtt = fetch_and_zero(&ggtt->alias);
|
|
|
|
|
if (!ppgtt)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
i915_vm_put(&ppgtt->vm);
|
|
|
|
|
|
2022-03-30 16:48:08 -07:00
|
|
|
ggtt->vm.vma_ops.bind_vma = intel_ggtt_bind_vma;
|
|
|
|
|
ggtt->vm.vma_ops.unbind_vma = intel_ggtt_unbind_vma;
|
2020-01-07 13:40:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int i915_init_ggtt(struct drm_i915_private *i915)
|
|
|
|
|
{
|
|
|
|
|
int ret;
|
|
|
|
|
|
2021-12-21 21:59:46 +02:00
|
|
|
ret = init_ggtt(to_gt(i915)->ggtt);
|
2020-01-07 13:40:09 +00:00
|
|
|
if (ret)
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
|
|
if (INTEL_PPGTT(i915) == INTEL_PPGTT_ALIASING) {
|
2021-12-21 21:59:46 +02:00
|
|
|
ret = init_aliasing_ppgtt(to_gt(i915)->ggtt);
|
2020-01-07 13:40:09 +00:00
|
|
|
if (ret)
|
2021-12-21 21:59:46 +02:00
|
|
|
cleanup_init_ggtt(to_gt(i915)->ggtt);
|
2020-01-07 13:40:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void ggtt_cleanup_hw(struct i915_ggtt *ggtt)
|
|
|
|
|
{
|
|
|
|
|
struct i915_vma *vma, *vn;
|
|
|
|
|
|
|
|
|
|
flush_workqueue(ggtt->vm.i915->wq);
|
2022-01-14 14:23:18 +01:00
|
|
|
i915_gem_drain_freed_objects(ggtt->vm.i915);
|
2020-01-07 13:40:09 +00:00
|
|
|
|
|
|
|
|
mutex_lock(&ggtt->vm.mutex);
|
|
|
|
|
|
2022-03-04 09:26:39 +01:00
|
|
|
ggtt->vm.skip_pte_rewrite = true;
|
|
|
|
|
|
2022-01-14 14:23:18 +01:00
|
|
|
list_for_each_entry_safe(vma, vn, &ggtt->vm.bound_list, vm_link) {
|
|
|
|
|
struct drm_i915_gem_object *obj = vma->obj;
|
|
|
|
|
bool trylock;
|
|
|
|
|
|
|
|
|
|
trylock = i915_gem_object_trylock(obj, NULL);
|
|
|
|
|
WARN_ON(!trylock);
|
|
|
|
|
|
2020-01-07 13:40:09 +00:00
|
|
|
WARN_ON(__i915_vma_unbind(vma));
|
2022-01-14 14:23:18 +01:00
|
|
|
if (trylock)
|
|
|
|
|
i915_gem_object_unlock(obj);
|
|
|
|
|
}
|
2020-01-07 13:40:09 +00:00
|
|
|
|
|
|
|
|
if (drm_mm_node_allocated(&ggtt->error_capture))
|
|
|
|
|
drm_mm_remove_node(&ggtt->error_capture);
|
2020-01-10 12:30:56 +00:00
|
|
|
mutex_destroy(&ggtt->error_mutex);
|
2020-01-07 13:40:09 +00:00
|
|
|
|
|
|
|
|
ggtt_release_guc_top(ggtt);
|
|
|
|
|
intel_vgt_deballoon(ggtt);
|
|
|
|
|
|
|
|
|
|
ggtt->vm.cleanup(&ggtt->vm);
|
|
|
|
|
|
|
|
|
|
mutex_unlock(&ggtt->vm.mutex);
|
|
|
|
|
i915_address_space_fini(&ggtt->vm);
|
|
|
|
|
|
|
|
|
|
arch_phys_wc_del(ggtt->mtrr);
|
|
|
|
|
|
|
|
|
|
if (ggtt->iomap.size)
|
|
|
|
|
io_mapping_fini(&ggtt->iomap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* i915_ggtt_driver_release - Clean up GGTT hardware initialization
|
|
|
|
|
* @i915: i915 device
|
|
|
|
|
*/
|
|
|
|
|
void i915_ggtt_driver_release(struct drm_i915_private *i915)
|
|
|
|
|
{
|
2021-12-21 21:59:46 +02:00
|
|
|
struct i915_ggtt *ggtt = to_gt(i915)->ggtt;
|
2020-01-07 13:40:09 +00:00
|
|
|
|
2020-03-16 11:38:46 +00:00
|
|
|
fini_aliasing_ppgtt(ggtt);
|
2020-01-07 13:40:09 +00:00
|
|
|
|
2020-03-16 11:38:46 +00:00
|
|
|
intel_ggtt_fini_fences(ggtt);
|
|
|
|
|
ggtt_cleanup_hw(ggtt);
|
2020-01-07 13:40:09 +00:00
|
|
|
}
|
|
|
|
|
|
2021-06-01 09:46:41 +02:00
|
|
|
/**
|
|
|
|
|
* i915_ggtt_driver_late_release - Cleanup of GGTT that needs to be done after
|
|
|
|
|
* all free objects have been drained.
|
|
|
|
|
* @i915: i915 device
|
|
|
|
|
*/
|
|
|
|
|
void i915_ggtt_driver_late_release(struct drm_i915_private *i915)
|
|
|
|
|
{
|
2021-12-21 21:59:46 +02:00
|
|
|
struct i915_ggtt *ggtt = to_gt(i915)->ggtt;
|
2021-06-01 09:46:41 +02:00
|
|
|
|
|
|
|
|
GEM_WARN_ON(kref_read(&ggtt->vm.resv_ref) != 1);
|
|
|
|
|
dma_resv_fini(&ggtt->vm._resv);
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:48:08 -07:00
|
|
|
struct resource intel_pci_resource(struct pci_dev *pdev, int bar)
|
2020-01-07 13:40:09 +00:00
|
|
|
{
|
|
|
|
|
return (struct resource)DEFINE_RES_MEM(pci_resource_start(pdev, bar),
|
|
|
|
|
pci_resource_len(pdev, bar));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int ggtt_probe_hw(struct i915_ggtt *ggtt, struct intel_gt *gt)
|
|
|
|
|
{
|
|
|
|
|
struct drm_i915_private *i915 = gt->i915;
|
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
|
|
ggtt->vm.gt = gt;
|
|
|
|
|
ggtt->vm.i915 = i915;
|
2021-01-28 14:31:24 +01:00
|
|
|
ggtt->vm.dma = i915->drm.dev;
|
2021-06-01 09:46:41 +02:00
|
|
|
dma_resv_init(&ggtt->vm._resv);
|
2020-01-07 13:40:09 +00:00
|
|
|
|
2021-06-05 08:53:52 -07:00
|
|
|
if (GRAPHICS_VER(i915) <= 5)
|
2022-03-30 16:48:08 -07:00
|
|
|
ret = intel_gt_gmch_gen5_probe(ggtt);
|
2021-06-05 08:53:52 -07:00
|
|
|
else if (GRAPHICS_VER(i915) < 8)
|
2022-03-30 16:48:08 -07:00
|
|
|
ret = intel_gt_gmch_gen6_probe(ggtt);
|
2020-01-07 13:40:09 +00:00
|
|
|
else
|
2022-03-30 16:48:08 -07:00
|
|
|
ret = intel_gt_gmch_gen8_probe(ggtt);
|
2021-03-23 16:50:29 +01:00
|
|
|
if (ret) {
|
2021-06-01 09:46:41 +02:00
|
|
|
dma_resv_fini(&ggtt->vm._resv);
|
2020-01-07 13:40:09 +00:00
|
|
|
return ret;
|
2021-03-23 16:50:29 +01:00
|
|
|
}
|
2020-01-07 13:40:09 +00:00
|
|
|
|
|
|
|
|
if ((ggtt->vm.total - 1) >> 32) {
|
drm/i915/ggtt: convert to drm_device based logging macros.
Converts various instances of the printk based drm logging macros to use
the struct drm_device based logging macros in i915/gt/intel_ggtt.c.
This change was done using the following coccinelle script that matches
based on the existence of a drm_i915_private device:
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
Note that this converts DRM_DEBUG_DRIVER to drm_dbg()
References: https://lists.freedesktop.org/archives/dri-devel/2020-January/253381.html
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200314183344.17603-2-wambui.karugax@gmail.com
2020-03-14 21:33:38 +03:00
|
|
|
drm_err(&i915->drm,
|
|
|
|
|
"We never expected a Global GTT with more than 32bits"
|
|
|
|
|
" of address space! Found %lldM!\n",
|
|
|
|
|
ggtt->vm.total >> 20);
|
2020-01-07 13:40:09 +00:00
|
|
|
ggtt->vm.total = 1ULL << 32;
|
|
|
|
|
ggtt->mappable_end =
|
|
|
|
|
min_t(u64, ggtt->mappable_end, ggtt->vm.total);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ggtt->mappable_end > ggtt->vm.total) {
|
drm/i915/ggtt: convert to drm_device based logging macros.
Converts various instances of the printk based drm logging macros to use
the struct drm_device based logging macros in i915/gt/intel_ggtt.c.
This change was done using the following coccinelle script that matches
based on the existence of a drm_i915_private device:
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
Note that this converts DRM_DEBUG_DRIVER to drm_dbg()
References: https://lists.freedesktop.org/archives/dri-devel/2020-January/253381.html
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200314183344.17603-2-wambui.karugax@gmail.com
2020-03-14 21:33:38 +03:00
|
|
|
drm_err(&i915->drm,
|
|
|
|
|
"mappable aperture extends past end of GGTT,"
|
|
|
|
|
" aperture=%pa, total=%llx\n",
|
|
|
|
|
&ggtt->mappable_end, ggtt->vm.total);
|
2020-01-07 13:40:09 +00:00
|
|
|
ggtt->mappable_end = ggtt->vm.total;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* GMADR is the PCI mmio aperture into the global GTT. */
|
drm/i915/ggtt: convert to drm_device based logging macros.
Converts various instances of the printk based drm logging macros to use
the struct drm_device based logging macros in i915/gt/intel_ggtt.c.
This change was done using the following coccinelle script that matches
based on the existence of a drm_i915_private device:
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
Note that this converts DRM_DEBUG_DRIVER to drm_dbg()
References: https://lists.freedesktop.org/archives/dri-devel/2020-January/253381.html
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200314183344.17603-2-wambui.karugax@gmail.com
2020-03-14 21:33:38 +03:00
|
|
|
drm_dbg(&i915->drm, "GGTT size = %lluM\n", ggtt->vm.total >> 20);
|
|
|
|
|
drm_dbg(&i915->drm, "GMADR size = %lluM\n",
|
|
|
|
|
(u64)ggtt->mappable_end >> 20);
|
|
|
|
|
drm_dbg(&i915->drm, "DSM size = %lluM\n",
|
|
|
|
|
(u64)resource_size(&intel_graphics_stolen_res) >> 20);
|
2020-01-07 13:40:09 +00:00
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* i915_ggtt_probe_hw - Probe GGTT hardware location
|
|
|
|
|
* @i915: i915 device
|
|
|
|
|
*/
|
|
|
|
|
int i915_ggtt_probe_hw(struct drm_i915_private *i915)
|
|
|
|
|
{
|
|
|
|
|
int ret;
|
|
|
|
|
|
2021-12-21 21:59:46 +02:00
|
|
|
ret = ggtt_probe_hw(to_gt(i915)->ggtt, to_gt(i915));
|
2020-01-07 13:40:09 +00:00
|
|
|
if (ret)
|
|
|
|
|
return ret;
|
|
|
|
|
|
2022-03-29 10:02:04 +01:00
|
|
|
if (i915_vtd_active(i915))
|
2020-04-02 14:48:18 +03:00
|
|
|
drm_info(&i915->drm, "VT-d active for gfx access\n");
|
2020-01-07 13:40:09 +00:00
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int i915_ggtt_enable_hw(struct drm_i915_private *i915)
|
|
|
|
|
{
|
2022-03-30 16:48:08 -07:00
|
|
|
return intel_gt_gmch_gen5_enable_hw(i915);
|
2020-01-07 13:40:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void i915_ggtt_enable_guc(struct i915_ggtt *ggtt)
|
|
|
|
|
{
|
|
|
|
|
GEM_BUG_ON(ggtt->invalidate != gen8_ggtt_invalidate);
|
|
|
|
|
|
|
|
|
|
ggtt->invalidate = guc_ggtt_invalidate;
|
|
|
|
|
|
|
|
|
|
ggtt->invalidate(ggtt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void i915_ggtt_disable_guc(struct i915_ggtt *ggtt)
|
|
|
|
|
{
|
|
|
|
|
/* XXX Temporary pardon for error unload */
|
|
|
|
|
if (ggtt->invalidate == gen8_ggtt_invalidate)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* We should only be called after i915_ggtt_enable_guc() */
|
|
|
|
|
GEM_BUG_ON(ggtt->invalidate != guc_ggtt_invalidate);
|
|
|
|
|
|
|
|
|
|
ggtt->invalidate = gen8_ggtt_invalidate;
|
|
|
|
|
|
|
|
|
|
ggtt->invalidate(ggtt);
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-01 20:35:50 +02:00
|
|
|
/**
|
|
|
|
|
* i915_ggtt_resume_vm - Restore the memory mappings for a GGTT or DPT VM
|
|
|
|
|
* @vm: The VM to restore the mappings for
|
|
|
|
|
*
|
|
|
|
|
* Restore the memory mappings for all objects mapped to HW via the GGTT or a
|
|
|
|
|
* DPT page table.
|
|
|
|
|
*
|
|
|
|
|
* Returns %true if restoring the mapping for any object that was in a write
|
|
|
|
|
* domain before suspend.
|
|
|
|
|
*/
|
|
|
|
|
bool i915_ggtt_resume_vm(struct i915_address_space *vm)
|
2020-01-07 13:40:09 +00:00
|
|
|
{
|
2020-01-10 11:04:00 +00:00
|
|
|
struct i915_vma *vma;
|
2021-11-01 20:35:50 +02:00
|
|
|
bool write_domain_objs = false;
|
2020-01-07 13:40:09 +00:00
|
|
|
|
2021-11-01 20:35:50 +02:00
|
|
|
drm_WARN_ON(&vm->i915->drm, !vm->is_ggtt && !vm->is_dpt);
|
2020-01-07 13:40:09 +00:00
|
|
|
|
|
|
|
|
/* First fill our portion of the GTT with scratch pages */
|
2021-11-01 20:35:50 +02:00
|
|
|
vm->clear_range(vm, 0, vm->total);
|
2020-01-07 13:40:09 +00:00
|
|
|
|
|
|
|
|
/* clflush objects bound into the GGTT and rebind them. */
|
2021-11-01 20:35:50 +02:00
|
|
|
list_for_each_entry(vma, &vm->bound_list, vm_link) {
|
2020-01-07 13:40:09 +00:00
|
|
|
struct drm_i915_gem_object *obj = vma->obj;
|
2020-07-29 17:42:17 +01:00
|
|
|
unsigned int was_bound =
|
|
|
|
|
atomic_read(&vma->flags) & I915_VMA_BIND_MASK;
|
2020-01-07 13:40:09 +00:00
|
|
|
|
2020-07-29 17:42:17 +01:00
|
|
|
GEM_BUG_ON(!was_bound);
|
2022-01-18 10:54:02 +00:00
|
|
|
vma->ops->bind_vma(vm, NULL, vma->resource,
|
2020-07-29 17:42:17 +01:00
|
|
|
obj ? obj->cache_level : 0,
|
|
|
|
|
was_bound);
|
2020-01-07 13:40:09 +00:00
|
|
|
if (obj) { /* only used during resume => exclusive access */
|
2021-11-01 20:35:50 +02:00
|
|
|
write_domain_objs |= fetch_and_zero(&obj->write_domain);
|
2020-01-07 13:40:09 +00:00
|
|
|
obj->read_domains |= I915_GEM_DOMAIN_GTT;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-01 20:35:50 +02:00
|
|
|
return write_domain_objs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void i915_ggtt_resume(struct i915_ggtt *ggtt)
|
|
|
|
|
{
|
|
|
|
|
bool flush;
|
|
|
|
|
|
|
|
|
|
intel_gt_check_and_clear_faults(ggtt->vm.gt);
|
|
|
|
|
|
|
|
|
|
flush = i915_ggtt_resume_vm(&ggtt->vm);
|
|
|
|
|
|
2020-01-07 13:40:09 +00:00
|
|
|
ggtt->invalidate(ggtt);
|
|
|
|
|
|
|
|
|
|
if (flush)
|
|
|
|
|
wbinvd_on_all_cpus();
|
|
|
|
|
|
2021-06-05 08:53:52 -07:00
|
|
|
if (GRAPHICS_VER(ggtt->vm.i915) >= 8)
|
2020-01-07 13:40:09 +00:00
|
|
|
setup_private_pat(ggtt->vm.gt->uncore);
|
2020-03-16 11:38:44 +00:00
|
|
|
|
|
|
|
|
intel_ggtt_restore_fences(ggtt);
|
2020-01-07 13:40:09 +00:00
|
|
|
}
|