drm/xe: Move TLB invalidation variable to own sub-structure in GT
authorMatthew Brost <matthew.brost@intel.com>
Wed, 18 Jan 2023 04:49:38 +0000 (20:49 -0800)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Tue, 19 Dec 2023 23:27:45 +0000 (18:27 -0500)
TLB invalidations no longer just restricted to USM, move the variables
to own sub-structure.

Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/xe/xe_gt_debugfs.c
drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c
drivers/gpu/drm/xe/xe_gt_types.h

index 01303bbe073c24c5cc2c5cbab7ea2dfd1d4df9ca..ea308b123474ee3cb487156191c3236479e2f8dd 100644 (file)
 #include "xe_gt.h"
 #include "xe_gt_debugfs.h"
 #include "xe_gt_mcr.h"
-#include "xe_gt_pagefault.h"
-#include "xe_gt_tlb_invalidation.h"
 #include "xe_gt_topology.h"
 #include "xe_hw_engine.h"
 #include "xe_macros.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)
 {
        return node->info_ent->data;
index fea7a557d213919b13e329bd975693484b88afe0..a39a2fb163aef0cd73b6e19700bb75b8dd00d97b 100644 (file)
@@ -16,7 +16,7 @@ guc_to_gt(struct xe_guc *guc)
 
 int xe_gt_tlb_invalidation_init(struct xe_gt *gt)
 {
-       gt->usm.tlb_invalidation_seqno = 1;
+       gt->tlb_invalidation.seqno = 1;
 
        return 0;
 }
@@ -40,12 +40,12 @@ static int send_tlb_invalidation(struct xe_guc *guc)
         * need to be updated.
         */
        mutex_lock(&guc->ct.lock);
-       seqno = gt->usm.tlb_invalidation_seqno;
+       seqno = gt->tlb_invalidation.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;
-       if (!gt->usm.tlb_invalidation_seqno)
-               gt->usm.tlb_invalidation_seqno = 1;
+       if (!gt->tlb_invalidation.seqno)
+               gt->tlb_invalidation.seqno = 1;
        ret = xe_guc_ct_send_locked(&guc->ct, action, ARRAY_SIZE(action),
                                    G2H_LEN_DW_TLB_INVALIDATE, 1);
        if (!ret)
@@ -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)
 {
-       if (gt->usm.tlb_invalidation_seqno_recv >= seqno)
+       if (gt->tlb_invalidation.seqno_recv >= seqno)
                return true;
 
-       if (seqno - gt->usm.tlb_invalidation_seqno_recv >
+       if (seqno - gt->tlb_invalidation.seqno_recv >
            (TLB_INVALIDATION_SEQNO_MAX / 2))
                return true;
 
@@ -87,7 +87,7 @@ int xe_gt_tlb_invalidation_wait(struct xe_gt *gt, int seqno)
                                 HZ / 5);
        if (!ret) {
                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;
        }
 
@@ -103,11 +103,11 @@ int xe_guc_tlb_invalidation_done_handler(struct xe_guc *guc, u32 *msg, u32 len)
                return -EPROTO;
 
        /* 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;
        XE_WARN_ON(expected_seqno != msg[0]);
 
-       gt->usm.tlb_invalidation_seqno_recv = msg[0];
+       gt->tlb_invalidation.seqno_recv = msg[0];
        smp_wmb();
        wake_up_all(&guc->ct.wq);
 
index 2dbc8cedd6305724e1750ec62816b3b6607baa5e..3bfce7abe857add20211538a16fe67dedcce5097 100644 (file)
@@ -160,6 +160,17 @@ struct xe_gt {
                struct work_struct worker;
        } 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 */
        struct {
                /**
@@ -175,17 +186,6 @@ struct xe_gt {
                 * operations (e.g. mmigrations, fixing page tables)
                 */
                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 */
                struct workqueue_struct *pf_wq;
                /** @acc_wq: access counter work queue, unbound, high priority */