Commit 115cdcca authored by Jonathan Cavitt's avatar Jonathan Cavitt Committed by Andi Shyti

drm/i915: Make i915_coherent_map_type GT-centric

Refactor i915_coherent_map_type to be GT-centric rather than
device-centric.  Each GT may require different coherency
handling due to hardware workarounds.

Since the function now takes a GT instead of the i915, the function is
renamed and moved to the gt folder.
Suggested-by: default avatarMatt Roper <matthew.d.roper@intel.com>
Signed-off-by: default avatarJonathan Cavitt <jonathan.cavitt@intel.com>
Acked-by: default avatarFei Yang <fei.yang@intel.com>
Reviewed-by: default avatarAndi Shyti <andi.shyti@linux.intel.com>
Acked-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
Signed-off-by: default avatarAndi Shyti <andi.shyti@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230801153242.2445478-3-jonathan.cavitt@intel.com
Link: https://patchwork.freedesktop.org/patch/msgid/20230807121957.598420-3-andi.shyti@linux.intel.com
parent 8a612b2d
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <drm/i915_hdcp_interface.h> #include <drm/i915_hdcp_interface.h>
#include "gem/i915_gem_region.h" #include "gem/i915_gem_region.h"
#include "gt/intel_gt.h"
#include "gt/uc/intel_gsc_uc_heci_cmd_submit.h" #include "gt/uc/intel_gsc_uc_heci_cmd_submit.h"
#include "i915_drv.h" #include "i915_drv.h"
#include "i915_utils.h" #include "i915_utils.h"
...@@ -632,7 +633,7 @@ static int intel_hdcp_gsc_initialize_message(struct drm_i915_private *i915, ...@@ -632,7 +633,7 @@ static int intel_hdcp_gsc_initialize_message(struct drm_i915_private *i915,
return PTR_ERR(obj); return PTR_ERR(obj);
} }
cmd_in = i915_gem_object_pin_map_unlocked(obj, i915_coherent_map_type(i915, obj, true)); cmd_in = i915_gem_object_pin_map_unlocked(obj, intel_gt_coherent_map_type(gt, obj, true));
if (IS_ERR(cmd_in)) { if (IS_ERR(cmd_in)) {
drm_err(&i915->drm, "Failed to map gsc message page!\n"); drm_err(&i915->drm, "Failed to map gsc message page!\n");
err = PTR_ERR(cmd_in); err = PTR_ERR(cmd_in);
......
...@@ -716,10 +716,6 @@ void *__must_check i915_gem_object_pin_map(struct drm_i915_gem_object *obj, ...@@ -716,10 +716,6 @@ void *__must_check i915_gem_object_pin_map(struct drm_i915_gem_object *obj,
void *__must_check i915_gem_object_pin_map_unlocked(struct drm_i915_gem_object *obj, void *__must_check i915_gem_object_pin_map_unlocked(struct drm_i915_gem_object *obj,
enum i915_map_type type); enum i915_map_type type);
enum i915_map_type i915_coherent_map_type(struct drm_i915_private *i915,
struct drm_i915_gem_object *obj,
bool always_coherent);
void __i915_gem_object_flush_map(struct drm_i915_gem_object *obj, void __i915_gem_object_flush_map(struct drm_i915_gem_object *obj,
unsigned long offset, unsigned long offset,
unsigned long size); unsigned long size);
......
...@@ -468,21 +468,6 @@ void *i915_gem_object_pin_map_unlocked(struct drm_i915_gem_object *obj, ...@@ -468,21 +468,6 @@ void *i915_gem_object_pin_map_unlocked(struct drm_i915_gem_object *obj,
return ret; return ret;
} }
enum i915_map_type i915_coherent_map_type(struct drm_i915_private *i915,
struct drm_i915_gem_object *obj,
bool always_coherent)
{
/*
* Wa_22016122933: always return I915_MAP_WC for MTL
*/
if (i915_gem_object_is_lmem(obj) || IS_METEORLAKE(i915))
return I915_MAP_WC;
if (HAS_LLC(i915) || always_coherent)
return I915_MAP_WB;
else
return I915_MAP_WC;
}
void __i915_gem_object_flush_map(struct drm_i915_gem_object *obj, void __i915_gem_object_flush_map(struct drm_i915_gem_object *obj,
unsigned long offset, unsigned long offset,
unsigned long size) unsigned long size)
......
...@@ -13,12 +13,12 @@ ...@@ -13,12 +13,12 @@
#include "selftests/igt_spinner.h" #include "selftests/igt_spinner.h"
static int igt_fill_check_buffer(struct drm_i915_gem_object *obj, static int igt_fill_check_buffer(struct drm_i915_gem_object *obj,
struct intel_gt *gt,
bool fill) bool fill)
{ {
struct drm_i915_private *i915 = to_i915(obj->base.dev);
unsigned int i, count = obj->base.size / sizeof(u32); unsigned int i, count = obj->base.size / sizeof(u32);
enum i915_map_type map_type = enum i915_map_type map_type =
i915_coherent_map_type(i915, obj, false); intel_gt_coherent_map_type(gt, obj, false);
u32 *cur; u32 *cur;
int err = 0; int err = 0;
...@@ -66,7 +66,7 @@ static int igt_create_migrate(struct intel_gt *gt, enum intel_region_id src, ...@@ -66,7 +66,7 @@ static int igt_create_migrate(struct intel_gt *gt, enum intel_region_id src,
if (err) if (err)
continue; continue;
err = igt_fill_check_buffer(obj, true); err = igt_fill_check_buffer(obj, gt, true);
if (err) if (err)
continue; continue;
...@@ -86,7 +86,7 @@ static int igt_create_migrate(struct intel_gt *gt, enum intel_region_id src, ...@@ -86,7 +86,7 @@ static int igt_create_migrate(struct intel_gt *gt, enum intel_region_id src,
if (err) if (err)
continue; continue;
err = igt_fill_check_buffer(obj, false); err = igt_fill_check_buffer(obj, gt, false);
} }
i915_gem_object_put(obj); i915_gem_object_put(obj);
...@@ -233,7 +233,7 @@ static int __igt_lmem_pages_migrate(struct intel_gt *gt, ...@@ -233,7 +233,7 @@ static int __igt_lmem_pages_migrate(struct intel_gt *gt,
continue; continue;
if (!vma) { if (!vma) {
err = igt_fill_check_buffer(obj, true); err = igt_fill_check_buffer(obj, gt, true);
if (err) if (err)
continue; continue;
} }
...@@ -276,7 +276,7 @@ static int __igt_lmem_pages_migrate(struct intel_gt *gt, ...@@ -276,7 +276,7 @@ static int __igt_lmem_pages_migrate(struct intel_gt *gt,
if (err) if (err)
goto out_unlock; goto out_unlock;
} else { } else {
err = igt_fill_check_buffer(obj, false); err = igt_fill_check_buffer(obj, gt, false);
} }
out_unlock: out_unlock:
......
...@@ -39,7 +39,7 @@ static void dbg_poison_ce(struct intel_context *ce) ...@@ -39,7 +39,7 @@ static void dbg_poison_ce(struct intel_context *ce)
if (ce->state) { if (ce->state) {
struct drm_i915_gem_object *obj = ce->state->obj; struct drm_i915_gem_object *obj = ce->state->obj;
int type = i915_coherent_map_type(ce->engine->i915, obj, true); int type = intel_gt_coherent_map_type(ce->engine->gt, obj, true);
void *map; void *map;
if (!i915_gem_object_trylock(obj, NULL)) if (!i915_gem_object_trylock(obj, NULL))
......
...@@ -1003,3 +1003,18 @@ void intel_gt_info_print(const struct intel_gt_info *info, ...@@ -1003,3 +1003,18 @@ void intel_gt_info_print(const struct intel_gt_info *info,
intel_sseu_dump(&info->sseu, p); intel_sseu_dump(&info->sseu, p);
} }
enum i915_map_type intel_gt_coherent_map_type(struct intel_gt *gt,
struct drm_i915_gem_object *obj,
bool always_coherent)
{
/*
* Wa_22016122933: always return I915_MAP_WC for MTL
*/
if (i915_gem_object_is_lmem(obj) || IS_METEORLAKE(gt->i915))
return I915_MAP_WC;
if (HAS_LLC(gt->i915) || always_coherent)
return I915_MAP_WB;
else
return I915_MAP_WC;
}
...@@ -107,4 +107,8 @@ void intel_gt_info_print(const struct intel_gt_info *info, ...@@ -107,4 +107,8 @@ void intel_gt_info_print(const struct intel_gt_info *info,
void intel_gt_watchdog_work(struct work_struct *work); void intel_gt_watchdog_work(struct work_struct *work);
enum i915_map_type intel_gt_coherent_map_type(struct intel_gt *gt,
struct drm_i915_gem_object *obj,
bool always_coherent);
#endif /* __INTEL_GT_H__ */ #endif /* __INTEL_GT_H__ */
...@@ -89,7 +89,7 @@ int map_pt_dma(struct i915_address_space *vm, struct drm_i915_gem_object *obj) ...@@ -89,7 +89,7 @@ int map_pt_dma(struct i915_address_space *vm, struct drm_i915_gem_object *obj)
enum i915_map_type type; enum i915_map_type type;
void *vaddr; void *vaddr;
type = i915_coherent_map_type(vm->i915, obj, true); type = intel_gt_coherent_map_type(vm->gt, obj, true);
vaddr = i915_gem_object_pin_map_unlocked(obj, type); vaddr = i915_gem_object_pin_map_unlocked(obj, type);
if (IS_ERR(vaddr)) if (IS_ERR(vaddr))
return PTR_ERR(vaddr); return PTR_ERR(vaddr);
...@@ -103,7 +103,7 @@ int map_pt_dma_locked(struct i915_address_space *vm, struct drm_i915_gem_object ...@@ -103,7 +103,7 @@ int map_pt_dma_locked(struct i915_address_space *vm, struct drm_i915_gem_object
enum i915_map_type type; enum i915_map_type type;
void *vaddr; void *vaddr;
type = i915_coherent_map_type(vm->i915, obj, true); type = intel_gt_coherent_map_type(vm->gt, obj, true);
vaddr = i915_gem_object_pin_map(obj, type); vaddr = i915_gem_object_pin_map(obj, type);
if (IS_ERR(vaddr)) if (IS_ERR(vaddr))
return PTR_ERR(vaddr); return PTR_ERR(vaddr);
......
...@@ -1191,9 +1191,9 @@ lrc_pre_pin(struct intel_context *ce, ...@@ -1191,9 +1191,9 @@ lrc_pre_pin(struct intel_context *ce,
GEM_BUG_ON(!i915_vma_is_pinned(ce->state)); GEM_BUG_ON(!i915_vma_is_pinned(ce->state));
*vaddr = i915_gem_object_pin_map(ce->state->obj, *vaddr = i915_gem_object_pin_map(ce->state->obj,
i915_coherent_map_type(ce->engine->i915, intel_gt_coherent_map_type(ce->engine->gt,
ce->state->obj, ce->state->obj,
false) | false) |
I915_MAP_OVERRIDE); I915_MAP_OVERRIDE);
return PTR_ERR_OR_ZERO(*vaddr); return PTR_ERR_OR_ZERO(*vaddr);
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "intel_engine_regs.h" #include "intel_engine_regs.h"
#include "intel_gpu_commands.h" #include "intel_gpu_commands.h"
#include "intel_ring.h" #include "intel_ring.h"
#include "intel_gt.h"
#include "intel_timeline.h" #include "intel_timeline.h"
unsigned int intel_ring_update_space(struct intel_ring *ring) unsigned int intel_ring_update_space(struct intel_ring *ring)
...@@ -56,7 +57,7 @@ int intel_ring_pin(struct intel_ring *ring, struct i915_gem_ww_ctx *ww) ...@@ -56,7 +57,7 @@ int intel_ring_pin(struct intel_ring *ring, struct i915_gem_ww_ctx *ww)
if (i915_vma_is_map_and_fenceable(vma) && !HAS_LLC(vma->vm->i915)) { if (i915_vma_is_map_and_fenceable(vma) && !HAS_LLC(vma->vm->i915)) {
addr = (void __force *)i915_vma_pin_iomap(vma); addr = (void __force *)i915_vma_pin_iomap(vma);
} else { } else {
int type = i915_coherent_map_type(vma->vm->i915, vma->obj, false); int type = intel_gt_coherent_map_type(vma->vm->gt, vma->obj, false);
addr = i915_gem_object_pin_map(vma->obj, type); addr = i915_gem_object_pin_map(vma->obj, type);
} }
......
...@@ -88,8 +88,9 @@ static int __live_context_size(struct intel_engine_cs *engine) ...@@ -88,8 +88,9 @@ static int __live_context_size(struct intel_engine_cs *engine)
goto err; goto err;
vaddr = i915_gem_object_pin_map_unlocked(ce->state->obj, vaddr = i915_gem_object_pin_map_unlocked(ce->state->obj,
i915_coherent_map_type(engine->i915, intel_gt_coherent_map_type(engine->gt,
ce->state->obj, false)); ce->state->obj,
false));
if (IS_ERR(vaddr)) { if (IS_ERR(vaddr)) {
err = PTR_ERR(vaddr); err = PTR_ERR(vaddr);
intel_context_unpin(ce); intel_context_unpin(ce);
......
...@@ -73,7 +73,7 @@ static int hang_init(struct hang *h, struct intel_gt *gt) ...@@ -73,7 +73,7 @@ static int hang_init(struct hang *h, struct intel_gt *gt)
h->seqno = memset(vaddr, 0xff, PAGE_SIZE); h->seqno = memset(vaddr, 0xff, PAGE_SIZE);
vaddr = i915_gem_object_pin_map_unlocked(h->obj, vaddr = i915_gem_object_pin_map_unlocked(h->obj,
i915_coherent_map_type(gt->i915, h->obj, false)); intel_gt_coherent_map_type(gt, h->obj, false));
if (IS_ERR(vaddr)) { if (IS_ERR(vaddr)) {
err = PTR_ERR(vaddr); err = PTR_ERR(vaddr);
goto err_unpin_hws; goto err_unpin_hws;
...@@ -119,7 +119,7 @@ hang_create_request(struct hang *h, struct intel_engine_cs *engine) ...@@ -119,7 +119,7 @@ hang_create_request(struct hang *h, struct intel_engine_cs *engine)
return ERR_CAST(obj); return ERR_CAST(obj);
} }
vaddr = i915_gem_object_pin_map_unlocked(obj, i915_coherent_map_type(gt->i915, obj, false)); vaddr = i915_gem_object_pin_map_unlocked(obj, intel_gt_coherent_map_type(gt, obj, false));
if (IS_ERR(vaddr)) { if (IS_ERR(vaddr)) {
i915_gem_object_put(obj); i915_gem_object_put(obj);
i915_vm_put(vm); i915_vm_put(vm);
......
...@@ -1292,9 +1292,9 @@ static int compare_isolation(struct intel_engine_cs *engine, ...@@ -1292,9 +1292,9 @@ static int compare_isolation(struct intel_engine_cs *engine,
} }
lrc = i915_gem_object_pin_map_unlocked(ce->state->obj, lrc = i915_gem_object_pin_map_unlocked(ce->state->obj,
i915_coherent_map_type(engine->i915, intel_gt_coherent_map_type(engine->gt,
ce->state->obj, ce->state->obj,
false)); false));
if (IS_ERR(lrc)) { if (IS_ERR(lrc)) {
err = PTR_ERR(lrc); err = PTR_ERR(lrc);
goto err_B1; goto err_B1;
......
...@@ -282,7 +282,6 @@ static int gsc_fw_load(struct intel_gsc_uc *gsc) ...@@ -282,7 +282,6 @@ static int gsc_fw_load(struct intel_gsc_uc *gsc)
static int gsc_fw_load_prepare(struct intel_gsc_uc *gsc) static int gsc_fw_load_prepare(struct intel_gsc_uc *gsc)
{ {
struct intel_gt *gt = gsc_uc_to_gt(gsc); struct intel_gt *gt = gsc_uc_to_gt(gsc);
struct drm_i915_private *i915 = gt->i915;
void *src; void *src;
if (!gsc->local) if (!gsc->local)
...@@ -292,7 +291,7 @@ static int gsc_fw_load_prepare(struct intel_gsc_uc *gsc) ...@@ -292,7 +291,7 @@ static int gsc_fw_load_prepare(struct intel_gsc_uc *gsc)
return -ENOSPC; return -ENOSPC;
src = i915_gem_object_pin_map_unlocked(gsc->fw.obj, src = i915_gem_object_pin_map_unlocked(gsc->fw.obj,
i915_coherent_map_type(i915, gsc->fw.obj, true)); intel_gt_coherent_map_type(gt, gsc->fw.obj, true));
if (IS_ERR(src)) if (IS_ERR(src))
return PTR_ERR(src); return PTR_ERR(src);
......
...@@ -792,8 +792,8 @@ int intel_guc_allocate_and_map_vma(struct intel_guc *guc, u32 size, ...@@ -792,8 +792,8 @@ int intel_guc_allocate_and_map_vma(struct intel_guc *guc, u32 size,
return PTR_ERR(vma); return PTR_ERR(vma);
vaddr = i915_gem_object_pin_map_unlocked(vma->obj, vaddr = i915_gem_object_pin_map_unlocked(vma->obj,
i915_coherent_map_type(guc_to_gt(guc)->i915, intel_gt_coherent_map_type(guc_to_gt(guc),
vma->obj, true)); vma->obj, true));
if (IS_ERR(vaddr)) { if (IS_ERR(vaddr)) {
i915_vma_unpin_and_release(&vma, 0); i915_vma_unpin_and_release(&vma, 0);
return PTR_ERR(vaddr); return PTR_ERR(vaddr);
......
...@@ -27,7 +27,6 @@ struct mtl_huc_auth_msg_out { ...@@ -27,7 +27,6 @@ struct mtl_huc_auth_msg_out {
int intel_huc_fw_auth_via_gsccs(struct intel_huc *huc) int intel_huc_fw_auth_via_gsccs(struct intel_huc *huc)
{ {
struct intel_gt *gt = huc_to_gt(huc); struct intel_gt *gt = huc_to_gt(huc);
struct drm_i915_private *i915 = gt->i915;
struct drm_i915_gem_object *obj; struct drm_i915_gem_object *obj;
struct mtl_huc_auth_msg_in *msg_in; struct mtl_huc_auth_msg_in *msg_in;
struct mtl_huc_auth_msg_out *msg_out; struct mtl_huc_auth_msg_out *msg_out;
...@@ -43,7 +42,7 @@ int intel_huc_fw_auth_via_gsccs(struct intel_huc *huc) ...@@ -43,7 +42,7 @@ int intel_huc_fw_auth_via_gsccs(struct intel_huc *huc)
pkt_offset = i915_ggtt_offset(huc->heci_pkt); pkt_offset = i915_ggtt_offset(huc->heci_pkt);
pkt_vaddr = i915_gem_object_pin_map_unlocked(obj, pkt_vaddr = i915_gem_object_pin_map_unlocked(obj,
i915_coherent_map_type(i915, obj, true)); intel_gt_coherent_map_type(gt, obj, true));
if (IS_ERR(pkt_vaddr)) if (IS_ERR(pkt_vaddr))
return PTR_ERR(pkt_vaddr); return PTR_ERR(pkt_vaddr);
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <drm/drm_print.h> #include <drm/drm_print.h>
#include "gem/i915_gem_lmem.h" #include "gem/i915_gem_lmem.h"
#include "gt/intel_gt.h"
#include "gt/intel_gt_print.h" #include "gt/intel_gt_print.h"
#include "intel_gsc_binary_headers.h" #include "intel_gsc_binary_headers.h"
#include "intel_gsc_fw.h" #include "intel_gsc_fw.h"
...@@ -1197,7 +1198,7 @@ static int uc_fw_rsa_data_create(struct intel_uc_fw *uc_fw) ...@@ -1197,7 +1198,7 @@ static int uc_fw_rsa_data_create(struct intel_uc_fw *uc_fw)
return PTR_ERR(vma); return PTR_ERR(vma);
vaddr = i915_gem_object_pin_map_unlocked(vma->obj, vaddr = i915_gem_object_pin_map_unlocked(vma->obj,
i915_coherent_map_type(gt->i915, vma->obj, true)); intel_gt_coherent_map_type(gt, vma->obj, true));
if (IS_ERR(vaddr)) { if (IS_ERR(vaddr)) {
i915_vma_unpin_and_release(&vma, 0); i915_vma_unpin_and_release(&vma, 0);
err = PTR_ERR(vaddr); err = PTR_ERR(vaddr);
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "gem/i915_gem_internal.h" #include "gem/i915_gem_internal.h"
#include "gt/intel_context.h" #include "gt/intel_context.h"
#include "gt/intel_gt.h"
#include "gt/uc/intel_gsc_fw.h" #include "gt/uc/intel_gsc_fw.h"
#include "gt/uc/intel_gsc_uc_heci_cmd_submit.h" #include "gt/uc/intel_gsc_uc_heci_cmd_submit.h"
...@@ -336,7 +337,7 @@ gsccs_create_buffer(struct intel_gt *gt, ...@@ -336,7 +337,7 @@ gsccs_create_buffer(struct intel_gt *gt,
} }
/* return a virtual pointer */ /* return a virtual pointer */
*map = i915_gem_object_pin_map_unlocked(obj, i915_coherent_map_type(i915, obj, true)); *map = i915_gem_object_pin_map_unlocked(obj, intel_gt_coherent_map_type(gt, obj, true));
if (IS_ERR(*map)) { if (IS_ERR(*map)) {
drm_err(&i915->drm, "Failed to map gsccs backend %s.\n", bufname); drm_err(&i915->drm, "Failed to map gsccs backend %s.\n", bufname);
err = PTR_ERR(*map); err = PTR_ERR(*map);
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "gem/i915_gem_lmem.h" #include "gem/i915_gem_lmem.h"
#include "i915_drv.h" #include "i915_drv.h"
#include "gt/intel_gt.h"
#include "intel_pxp.h" #include "intel_pxp.h"
#include "intel_pxp_cmd_interface_42.h" #include "intel_pxp_cmd_interface_42.h"
...@@ -245,7 +246,9 @@ static int alloc_streaming_command(struct intel_pxp *pxp) ...@@ -245,7 +246,9 @@ static int alloc_streaming_command(struct intel_pxp *pxp)
} }
/* map the lmem into the virtual memory pointer */ /* map the lmem into the virtual memory pointer */
cmd = i915_gem_object_pin_map_unlocked(obj, i915_coherent_map_type(i915, obj, true)); cmd = i915_gem_object_pin_map_unlocked(obj,
intel_gt_coherent_map_type(pxp->ctrl_gt,
obj, true));
if (IS_ERR(cmd)) { if (IS_ERR(cmd)) {
drm_err(&i915->drm, "Failed to map gsc message page!\n"); drm_err(&i915->drm, "Failed to map gsc message page!\n");
err = PTR_ERR(cmd); err = PTR_ERR(cmd);
......
...@@ -97,7 +97,7 @@ int igt_spinner_pin(struct igt_spinner *spin, ...@@ -97,7 +97,7 @@ int igt_spinner_pin(struct igt_spinner *spin,
if (!spin->batch) { if (!spin->batch) {
unsigned int mode; unsigned int mode;
mode = i915_coherent_map_type(spin->gt->i915, spin->obj, false); mode = intel_gt_coherent_map_type(spin->gt, spin->obj, false);
vaddr = igt_spinner_pin_obj(ce, ww, spin->obj, mode, &spin->batch_vma); vaddr = igt_spinner_pin_obj(ce, ww, spin->obj, mode, &spin->batch_vma);
if (IS_ERR(vaddr)) if (IS_ERR(vaddr))
return PTR_ERR(vaddr); return PTR_ERR(vaddr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment