Commit 62ad0621 authored by Matthew Brost's avatar Matthew Brost Committed by Rodrigo Vivi

drm/xe: Move TLB invalidation variable to own sub-structure in GT

TLB invalidations no longer just restricted to USM, move the variables
to own sub-structure.
Signed-off-by: default avatarMatthew Brost <matthew.brost@intel.com>
Reviewed-by: default avatarNiranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
parent a9351846
...@@ -11,13 +11,15 @@ ...@@ -11,13 +11,15 @@
#include "xe_gt.h" #include "xe_gt.h"
#include "xe_gt_debugfs.h" #include "xe_gt_debugfs.h"
#include "xe_gt_mcr.h" #include "xe_gt_mcr.h"
#include "xe_gt_pagefault.h"
#include "xe_gt_tlb_invalidation.h"
#include "xe_gt_topology.h" #include "xe_gt_topology.h"
#include "xe_hw_engine.h" #include "xe_hw_engine.h"
#include "xe_macros.h" #include "xe_macros.h"
#include "xe_uc_debugfs.h" #include "xe_uc_debugfs.h"
#ifdef CONFIG_DRM_XE_DEBUG
#include "xe_gt_tlb_invalidation.h"
#endif
static struct xe_gt *node_to_gt(struct drm_info_node *node) static struct xe_gt *node_to_gt(struct drm_info_node *node)
{ {
return node->info_ent->data; return node->info_ent->data;
......
...@@ -16,7 +16,7 @@ guc_to_gt(struct xe_guc *guc) ...@@ -16,7 +16,7 @@ guc_to_gt(struct xe_guc *guc)
int xe_gt_tlb_invalidation_init(struct xe_gt *gt) int xe_gt_tlb_invalidation_init(struct xe_gt *gt)
{ {
gt->usm.tlb_invalidation_seqno = 1; gt->tlb_invalidation.seqno = 1;
return 0; return 0;
} }
...@@ -40,12 +40,12 @@ static int send_tlb_invalidation(struct xe_guc *guc) ...@@ -40,12 +40,12 @@ static int send_tlb_invalidation(struct xe_guc *guc)
* need to be updated. * need to be updated.
*/ */
mutex_lock(&guc->ct.lock); mutex_lock(&guc->ct.lock);
seqno = gt->usm.tlb_invalidation_seqno; seqno = gt->tlb_invalidation.seqno;
action[1] = seqno; action[1] = seqno;
gt->usm.tlb_invalidation_seqno = (gt->usm.tlb_invalidation_seqno + 1) % gt->tlb_invalidation.seqno = (gt->tlb_invalidation.seqno + 1) %
TLB_INVALIDATION_SEQNO_MAX; TLB_INVALIDATION_SEQNO_MAX;
if (!gt->usm.tlb_invalidation_seqno) if (!gt->tlb_invalidation.seqno)
gt->usm.tlb_invalidation_seqno = 1; gt->tlb_invalidation.seqno = 1;
ret = xe_guc_ct_send_locked(&guc->ct, action, ARRAY_SIZE(action), ret = xe_guc_ct_send_locked(&guc->ct, action, ARRAY_SIZE(action),
G2H_LEN_DW_TLB_INVALIDATE, 1); G2H_LEN_DW_TLB_INVALIDATE, 1);
if (!ret) if (!ret)
...@@ -62,10 +62,10 @@ int xe_gt_tlb_invalidation(struct xe_gt *gt) ...@@ -62,10 +62,10 @@ int xe_gt_tlb_invalidation(struct xe_gt *gt)
static bool tlb_invalidation_seqno_past(struct xe_gt *gt, int seqno) static bool tlb_invalidation_seqno_past(struct xe_gt *gt, int seqno)
{ {
if (gt->usm.tlb_invalidation_seqno_recv >= seqno) if (gt->tlb_invalidation.seqno_recv >= seqno)
return true; return true;
if (seqno - gt->usm.tlb_invalidation_seqno_recv > if (seqno - gt->tlb_invalidation.seqno_recv >
(TLB_INVALIDATION_SEQNO_MAX / 2)) (TLB_INVALIDATION_SEQNO_MAX / 2))
return true; return true;
...@@ -87,7 +87,7 @@ int xe_gt_tlb_invalidation_wait(struct xe_gt *gt, int seqno) ...@@ -87,7 +87,7 @@ int xe_gt_tlb_invalidation_wait(struct xe_gt *gt, int seqno)
HZ / 5); HZ / 5);
if (!ret) { if (!ret) {
drm_err(&xe->drm, "TLB invalidation time'd out, seqno=%d, recv=%d\n", drm_err(&xe->drm, "TLB invalidation time'd out, seqno=%d, recv=%d\n",
seqno, gt->usm.tlb_invalidation_seqno_recv); seqno, gt->tlb_invalidation.seqno_recv);
return -ETIME; return -ETIME;
} }
...@@ -103,11 +103,11 @@ int xe_guc_tlb_invalidation_done_handler(struct xe_guc *guc, u32 *msg, u32 len) ...@@ -103,11 +103,11 @@ int xe_guc_tlb_invalidation_done_handler(struct xe_guc *guc, u32 *msg, u32 len)
return -EPROTO; return -EPROTO;
/* Sanity check on seqno */ /* Sanity check on seqno */
expected_seqno = (gt->usm.tlb_invalidation_seqno_recv + 1) % expected_seqno = (gt->tlb_invalidation.seqno_recv + 1) %
TLB_INVALIDATION_SEQNO_MAX; TLB_INVALIDATION_SEQNO_MAX;
XE_WARN_ON(expected_seqno != msg[0]); XE_WARN_ON(expected_seqno != msg[0]);
gt->usm.tlb_invalidation_seqno_recv = msg[0]; gt->tlb_invalidation.seqno_recv = msg[0];
smp_wmb(); smp_wmb();
wake_up_all(&guc->ct.wq); wake_up_all(&guc->ct.wq);
......
...@@ -160,6 +160,17 @@ struct xe_gt { ...@@ -160,6 +160,17 @@ struct xe_gt {
struct work_struct worker; struct work_struct worker;
} reset; } reset;
/** @tlb_invalidation: TLB invalidation state */
struct {
/** @seqno: TLB invalidation seqno, protected by CT lock */
#define TLB_INVALIDATION_SEQNO_MAX 0x100000
int seqno;
/**
* @seqno_recv: last received TLB invalidation seqno, protected by CT lock
*/
int seqno_recv;
} tlb_invalidation;
/** @usm: unified shared memory state */ /** @usm: unified shared memory state */
struct { struct {
/** /**
...@@ -175,17 +186,6 @@ struct xe_gt { ...@@ -175,17 +186,6 @@ struct xe_gt {
* operations (e.g. mmigrations, fixing page tables) * operations (e.g. mmigrations, fixing page tables)
*/ */
u16 reserved_bcs_instance; u16 reserved_bcs_instance;
/**
* @tlb_invalidation_seqno: TLB invalidation seqno, protected by
* CT lock
*/
#define TLB_INVALIDATION_SEQNO_MAX 0x100000
int tlb_invalidation_seqno;
/**
* @tlb_invalidation_seqno_recv: last received TLB invalidation
* seqno, protected by CT lock
*/
int tlb_invalidation_seqno_recv;
/** @pf_wq: page fault work queue, unbound, high priority */ /** @pf_wq: page fault work queue, unbound, high priority */
struct workqueue_struct *pf_wq; struct workqueue_struct *pf_wq;
/** @acc_wq: access counter work queue, unbound, high priority */ /** @acc_wq: access counter work queue, unbound, high priority */
......
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