Skip to contentSkip to conversation

drm/i915: Define and use GuC and CTB TLB invalidation routines

PATCH Superseded Jonathan Cavitt 5 participants 12 messages Sep 29, 2023 – Oct 2, 2023

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/4 drm/i915: Define and use GuC and CTB TLB invalidation routines

From: Prathap Kumar Valsan <[email protected]>

The GuC firmware had defined the interface for Translation Look-Aside Buffer (TLB) invalidation. We should use this interface when invalidating the engine and GuC TLBs.
Add additional functionality to intel_gt_invalidate_tlb, invalidating the GuC TLBs and falling back to GT invalidation when the GuC is disabled.
The invalidation is done by sending a request directly to the GuC tlb_lookup that invalidates the table. The invalidation is submitted as a wait request and is performed in the CT event handler. This means we cannot perform this TLB invalidation path if the CT is not enabled. If the request isn't fulfilled in two seconds, this would constitute an error in the invalidation as that would constitute either a lost request or a severe GuC overload.

With this new invalidation routine, we can perform GuC-based GGTT invalidations. We should only do this when GuC is enabled and fall back to the original path when GuC is disabled to prevent concurrent issuance between GuC and KMD.

---
 drivers/gpu/drm/i915/gt/intel_ggtt.c          |  42 ++--
 drivers/gpu/drm/i915/gt/intel_tlb.c           |  14 +-
 .../gpu/drm/i915/gt/uc/abi/guc_actions_abi.h  |  33 +++
 drivers/gpu/drm/i915/gt/uc/intel_guc.h        |  22 ++
 drivers/gpu/drm/i915/gt/uc/intel_guc_ct.c     |   8 +
 drivers/gpu/drm/i915/gt/uc/intel_guc_fwif.h   |   1 +
 .../gpu/drm/i915/gt/uc/intel_guc_submission.c | 212 +++++++++++++++++-
 7 files changed, 316 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/gt/intel_ggtt.c +29 -13
index da21f2786b5d7..c5b3725be3bf3 100644
@@ -201,22 +201,37 @@ static void gen8_ggtt_invalidate(struct i915_ggtt *ggtt)
 	intel_uncore_write_fw(uncore, GFX_FLSH_CNTL_GEN6, GFX_FLSH_CNTL_EN);
 }
 
-static void guc_ggtt_invalidate(struct i915_ggtt *ggtt)
+static void guc_ggtt_ct_invalidate(struct intel_gt *gt)
 {
-	struct drm_i915_private *i915 = ggtt->vm.i915;
+	struct intel_uncore *uncore = gt->uncore;
+	intel_wakeref_t wakeref;
+
+	with_intel_runtime_pm_if_active(uncore->rpm, wakeref) {
+		struct intel_guc *guc = &gt->uc.guc;
 
-	gen8_ggtt_invalidate(ggtt);
+		intel_guc_invalidate_tlb(guc);
+	}
+}
 
-	if (GRAPHICS_VER(i915) >= 12) {
-		struct intel_gt *gt;
+static void guc_ggtt_invalidate(struct i915_ggtt *ggtt)
+{
+	struct drm_i915_private *i915 = ggtt->vm.i915;
+	struct intel_gt *gt;
 
-		list_for_each_entry(gt, &ggtt->gt_list, ggtt_link)
-			intel_uncore_write_fw(gt->uncore,
-					      GEN12_GUC_TLB_INV_CR,
-					      GEN12_GUC_TLB_INV_CR_INVALIDATE);
-	} else {
-		intel_uncore_write_fw(ggtt->vm.gt->uncore,
-				      GEN8_GTCR, GEN8_GTCR_INVALIDATE);
+	if (!IS_GEN9_LP(i915) && GRAPHICS_VER(i915) < 11)
+		gen8_ggtt_invalidate(ggtt);
+
+	list_for_each_entry(gt, &ggtt->gt_list, ggtt_link) {
+		if (intel_guc_is_ready(&gt->uc.guc)) {
+			guc_ggtt_ct_invalidate(gt);
+		} else if (GRAPHICS_VER(i915) >= 12) {
+			intel_uncore_write(gt->uncore,
+					   GEN12_GUC_TLB_INV_CR,
+					   GEN12_GUC_TLB_INV_CR_INVALIDATE);
+		} else {
+			intel_uncore_write(gt->uncore,
+					   GEN8_GTCR, GEN8_GTCR_INVALIDATE);
+		}
 	}
 }
 
@@ -1008,7 +1023,8 @@ static int gen8_gmch_probe(struct i915_ggtt *ggtt)
 			I915_VMA_GLOBAL_BIND | I915_VMA_LOCAL_BIND;
 	}
 
-	if (intel_uc_wants_guc(&ggtt->vm.gt->uc))
+	if (intel_uc_wants_guc(&ggtt->vm.gt->uc) &&
+	    intel_uc_wants_guc_submission(&ggtt->vm.gt->uc))
 		ggtt->invalidate = guc_ggtt_invalidate;
 	else
 		ggtt->invalidate = gen8_ggtt_invalidate;
drivers/gpu/drm/i915/gt/intel_tlb.c +13 -1
index 139608c30d978..018aeb6bacc66 100644
@@ -12,6 +12,7 @@
 #include "intel_gt_print.h"
 #include "intel_gt_regs.h"
 #include "intel_tlb.h"
+#include "uc/intel_guc.h"
 
 /*
  * HW architecture suggest typical invalidation time at 40us,
@@ -131,11 +132,22 @@ void intel_gt_invalidate_tlb_full(struct intel_gt *gt, u32 seqno)
 		return;
 
 	with_intel_gt_pm_if_awake(gt, wakeref) {
+		struct intel_guc *guc = &gt->uc.guc;
+
 		mutex_lock(&gt->tlb.invalidate_lock);
 		if (tlb_seqno_passed(gt, seqno))
 			goto unlock;
 
-		mmio_invalidate_full(gt);
+		if (intel_guc_submission_is_used(guc)) {
+			if (intel_guc_is_ready(guc))
+				intel_guc_invalidate_tlb_full(guc);
+		} else {
+			/*
+			 * Fall back to old path if GuC is disabled.
+			 * This is safe because GuC is not enabled and not writing to MMIO.
+			 */
+			mmio_invalidate_full(gt);
+		}
 
 		write_seqcount_invalidate(&gt->tlb.seqno);
 unlock:
drivers/gpu/drm/i915/gt/uc/abi/guc_actions_abi.h +33 -0
index f359bef046e0b..9dff8012d5e76 100644
@@ -138,6 +138,8 @@ enum intel_guc_action {
 	INTEL_GUC_ACTION_REGISTER_CONTEXT_MULTI_LRC = 0x4601,
 	INTEL_GUC_ACTION_CLIENT_SOFT_RESET = 0x5507,
 	INTEL_GUC_ACTION_SET_ENG_UTIL_BUFF = 0x550A,
+	INTEL_GUC_ACTION_TLB_INVALIDATION = 0x7000,
+	INTEL_GUC_ACTION_TLB_INVALIDATION_DONE = 0x7001,
 	INTEL_GUC_ACTION_STATE_CAPTURE_NOTIFICATION = 0x8002,
 	INTEL_GUC_ACTION_NOTIFY_FLUSH_LOG_BUFFER_TO_FILE = 0x8003,
 	INTEL_GUC_ACTION_NOTIFY_CRASH_DUMP_POSTED = 0x8004,
@@ -181,4 +183,35 @@ enum intel_guc_state_capture_event_status {
 
 #define INTEL_GUC_STATE_CAPTURE_EVENT_STATUS_MASK      0x000000FF
 
+#define INTEL_GUC_TLB_INVAL_TYPE_MASK	REG_GENMASK(7, 0)
+#define INTEL_GUC_TLB_INVAL_MODE_MASK	REG_GENMASK(11, 8)
+#define INTEL_GUC_TLB_INVAL_FLUSH_CACHE REG_BIT(31)
+
+enum intel_guc_tlb_invalidation_type {
+	INTEL_GUC_TLB_INVAL_FULL = 0x0,
+	INTEL_GUC_TLB_INVAL_GUC = 0x3,
+};
+
+/*
+ * 0: Heavy mode of Invalidation:
+ * The pipeline of the engine(s) for which the invalidation is targeted to is
+ * blocked, and all the in-flight transactions are guaranteed to be Globally
+ * Observed before completing the TLB invalidation
+ * 1: Lite mode of Invalidation:
+ * TLBs of the targeted engine(s) are immediately invalidated.
+ * In-flight transactions are NOT guaranteed to be Globally Observed before
+ * completing TLB invalidation.
+ * Light Invalidation Mode is to be used only when
+ * it can be guaranteed (by SW) that the address translations remain invariant
+ * for the in-flight transactions across the TLB invalidation. In other words,
+ * this mode can be used when the TLB invalidation is intended to clear out the
+ * stale cached translations that are no longer in use. Light Invalidation Mode
+ * is much faster than the Heavy Invalidation Mode, as it does not wait for the
+ * in-flight transactions to be GOd.
+ */
+enum intel_guc_tlb_inval_mode {
+	INTEL_GUC_TLB_INVAL_MODE_HEAVY = 0x0,
+	INTEL_GUC_TLB_INVAL_MODE_LITE = 0x1,
+};
+
 #endif /* _ABI_GUC_ACTIONS_ABI_H */
drivers/gpu/drm/i915/gt/uc/intel_guc.h +22 -0
index 6c392bad29c19..0f74a460bfe56 100644
@@ -79,6 +79,18 @@ struct intel_guc {
 	 */
 	atomic_t outstanding_submission_g2h;
 
+	/** @tlb_lookup: xarray to store all pending TLB invalidation requests */
+	struct xarray tlb_lookup;
+
+	/**
+	 * @serial_slot: id to the initial waiter created in tlb_lookup,
+	 * which is used only when failed to allocate new waiter.
+	 */
+	u32 serial_slot;
+
+	/** @next_seqno: the next id (sequence no.) to allocate. */
+	u32 next_seqno;
+
 	/** @interrupts: pointers to GuC interrupt-managing functions. */
 	struct {
 		bool enabled;
@@ -296,6 +308,11 @@ struct intel_guc {
 #define MAKE_GUC_VER_STRUCT(ver)	MAKE_GUC_VER((ver).major, (ver).minor, (ver).patch)
 #define GUC_SUBMIT_VER(guc)		MAKE_GUC_VER_STRUCT((guc)->submission_version)
 
+struct intel_guc_tlb_wait {
+	struct wait_queue_head wq;
+	u8 status;
+} __aligned(4);
+
 static inline struct intel_guc *log_to_guc(struct intel_guc_log *log)
 {
 	return container_of(log, struct intel_guc, log);
@@ -413,6 +430,11 @@ int intel_guc_allocate_and_map_vma(struct intel_guc *guc, u32 size,
 int intel_guc_self_cfg32(struct intel_guc *guc, u16 key, u32 value);
 int intel_guc_self_cfg64(struct intel_guc *guc, u16 key, u64 value);
 
+int intel_guc_invalidate_tlb_full(struct intel_guc *guc);
+int intel_guc_invalidate_tlb(struct intel_guc *guc);
+int intel_guc_tlb_invalidation_done(struct intel_guc *guc, const u32 *hxg,
+				    u32 size);
+
 static inline bool intel_guc_is_supported(struct intel_guc *guc)
 {
 	return intel_uc_fw_is_supported(&guc->fw);
drivers/gpu/drm/i915/gt/uc/intel_guc_ct.c +8 -0
index 6e22af31513a5..21dd271b68d63 100644
@@ -1186,9 +1186,17 @@ static int ct_handle_event(struct intel_guc_ct *ct, struct ct_incoming_msg *requ
 	switch (action) {
 	case INTEL_GUC_ACTION_SCHED_CONTEXT_MODE_DONE:
 	case INTEL_GUC_ACTION_DEREGISTER_CONTEXT_DONE:
+	case INTEL_GUC_ACTION_TLB_INVALIDATION_DONE:
 		g2h_release_space(ct, request->size);
 	}
 
+	/* Handle tlb invalidation response in interrupt context */
+	if (action == INTEL_GUC_ACTION_TLB_INVALIDATION_DONE) {
+		int ret = intel_guc_tlb_invalidation_done(ct_to_guc(ct), hxg, request->size);
+		ct_free_msg(request);
+		return ret;
+	}
+
 	spin_lock_irqsave(&ct->requests.lock, flags);
 	list_add_tail(&request->link, &ct->requests.incoming);
 	spin_unlock_irqrestore(&ct->requests.lock, flags);
drivers/gpu/drm/i915/gt/uc/intel_guc_fwif.h +1 -0
index b4d56eccfb1f0..a7c9874e122a3 100644
@@ -22,6 +22,7 @@
 /* Payload length only i.e. don't include G2H header length */
 #define G2H_LEN_DW_SCHED_CONTEXT_MODE_SET	2
 #define G2H_LEN_DW_DEREGISTER_CONTEXT		1
+#define G2H_LEN_DW_INVALIDATE_TLB		1
 
 #define GUC_CONTEXT_DISABLE		0
 #define GUC_CONTEXT_ENABLE		1
drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c +210 -2

265 lines not on this page · raw message

Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 2/4 drm/i915: No TLB invalidation on wedged or suspended GT

From: Fei Yang <[email protected]>

In case of GT is suspended or wedged, don't allow submission of new TLB invalidation request and cancel all pending requests. The TLB entries will be invalidated either during GuC reload or on system resume.

---
 drivers/gpu/drm/i915/gt/intel_gt.h            |  9 +++++++
 drivers/gpu/drm/i915/gt/uc/intel_guc.h        |  1 +
 .../gpu/drm/i915/gt/uc/intel_guc_submission.c | 27 ++++++++++++++-----
 drivers/gpu/drm/i915/i915_driver.c            | 12 +++++++++
 4 files changed, 43 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/gt/intel_gt.h +9 -0
index 2cac499d5aa3e..3fcc0d2cd7bf3 100644
@@ -9,6 +9,7 @@
 #include "intel_engine_types.h"
 #include "intel_gt_types.h"
 #include "intel_reset.h"
+#include "i915_irq.h"
 
 struct drm_i915_private;
 struct drm_printer;
@@ -157,6 +158,14 @@ static inline bool intel_gt_is_wedged(const struct intel_gt *gt)
 	return unlikely(test_bit(I915_WEDGED, &gt->reset.flags));
 }
 
+static inline bool intel_gt_is_enabled(const struct intel_gt *gt)
+{
+	/* Check if GT is wedged or suspended */
+	if (intel_gt_is_wedged(gt) || !intel_irqs_enabled(gt->i915))
+		return false;
+	return true;
+}
+
 int intel_gt_probe_all(struct drm_i915_private *i915);
 int intel_gt_tiles_init(struct drm_i915_private *i915);
 void intel_gt_release_all(struct drm_i915_private *i915);
drivers/gpu/drm/i915/gt/uc/intel_guc.h +1 -0
index 0f74a460bfe56..5fe48f7ab7d65 100644
@@ -536,4 +536,5 @@ void intel_guc_dump_time_info(struct intel_guc *guc, struct drm_printer *p);
 
 int intel_guc_sched_disable_gucid_threshold_max(struct intel_guc *guc);
 
+void wake_up_all_tlb_invalidate(struct intel_guc *guc);
 #endif
drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c +21 -6
index 6a2dcab63074e..fd64443806e5c 100644
@@ -32,6 +32,7 @@
 
 #include "i915_drv.h"
 #include "i915_reg.h"
+#include "i915_irq.h"
 #include "i915_trace.h"
 
 /**
@@ -1803,13 +1804,20 @@ static void wake_up_tlb_invalidate(struct intel_guc_tlb_wait *wait)
 	wake_up(&wait->wq);
 }
 
-void intel_guc_submission_reset(struct intel_guc *guc, intel_engine_mask_t stalled)
+void wake_up_all_tlb_invalidate(struct intel_guc *guc)
 {
 	struct intel_guc_tlb_wait *wait;
+	unsigned long i;
+
+	xa_for_each(&guc->tlb_lookup, i, wait)
+		wake_up_tlb_invalidate(wait);
+}
+
+void intel_guc_submission_reset(struct intel_guc *guc, intel_engine_mask_t stalled)
+{
 	struct intel_context *ce;
 	unsigned long index;
 	unsigned long flags;
-	unsigned long i;
 
 	if (unlikely(!guc_submission_initialized(guc))) {
 		/* Reset called during driver load? GuC not yet initialised! */
@@ -1840,8 +1848,7 @@ void intel_guc_submission_reset(struct intel_guc *guc, intel_engine_mask_t stall
 	 * The full GT reset will have cleared the TLB caches and flushed the
 	 * G2H message queue; we can release all the blocked waiters.
 	 */
-	xa_for_each(&guc->tlb_lookup, i, wait)
-		wake_up_tlb_invalidate(wait);
+	wake_up_all_tlb_invalidate(guc);
 }
 
 static void guc_cancel_context_requests(struct intel_context *ce)
@@ -1937,6 +1944,12 @@ void intel_guc_submission_cancel_requests(struct intel_guc *guc)
 
 	/* GuC is blown away, drop all references to contexts */
 	xa_destroy(&guc->context_lookup);
+
+	/*
+	 * Wedged GT won't respond to any TLB invalidation request. Simply
+	 * release all the blocked waiters.
+	 */
+	wake_up_all_tlb_invalidate(guc);
 }
 
 void intel_guc_submission_reset_finish(struct intel_guc *guc)
@@ -4764,7 +4777,8 @@ static int guc_send_invalidate_tlb(struct intel_guc *guc, u32 type)
 	};
 	u32 size = ARRAY_SIZE(action);
 
-	if (!intel_guc_ct_enabled(&guc->ct))
+	if (!intel_guc_ct_enabled(&guc->ct) ||
+	    !intel_gt_is_enabled(gt))
 		return -EINVAL;
 
 	init_waitqueue_head(&_wq.wq);
@@ -4806,7 +4820,8 @@ static int guc_send_invalidate_tlb(struct intel_guc *guc, u32 type)
 	 * queued in CT buffer.
 	 */
 #define OUTSTANDING_GUC_TIMEOUT_PERIOD  (HZ * 2)
-	if (!must_wait_woken(&wait, OUTSTANDING_GUC_TIMEOUT_PERIOD)) {
+	if (!must_wait_woken(&wait, OUTSTANDING_GUC_TIMEOUT_PERIOD) &&
+	    intel_gt_is_enabled(gt)) {
 		gt_err(gt,
 		       "TLB invalidation response timed out for seqno %u\n", seqno);
 		err = -ETIME;
drivers/gpu/drm/i915/i915_driver.c +12 -0
index 78501a83ba109..30c2a7ced10f8 100644
@@ -72,6 +72,7 @@
 #include "gt/intel_gt.h"
 #include "gt/intel_gt_pm.h"
 #include "gt/intel_rc6.h"
+#include "gt/uc/intel_guc.h"
 
 #include "pxp/intel_pxp.h"
 #include "pxp/intel_pxp_debugfs.h"
@@ -1076,6 +1077,8 @@ static int i915_drm_suspend(struct drm_device *dev)
 	struct drm_i915_private *dev_priv = to_i915(dev);
 	struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev);
 	pci_power_t opregion_target_state;
+	struct intel_gt *gt;
+	int i;
 
 	disable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
@@ -1092,6 +1095,10 @@ static int i915_drm_suspend(struct drm_device *dev)
 	intel_dp_mst_suspend(dev_priv);
 
 	intel_runtime_pm_disable_interrupts(dev_priv);
+
+	for_each_gt(gt, dev_priv, i)
+		wake_up_all_tlb_invalidate(&gt->uc.guc);
+
 	intel_hpd_cancel_work(dev_priv);
 
 	intel_suspend_encoders(dev_priv);
@@ -1263,6 +1270,11 @@ static int i915_drm_resume(struct drm_device *dev)
 
 	intel_gvt_resume(dev_priv);
 
+	for_each_gt(gt, dev_priv, i) {
+		intel_guc_invalidate_tlb_full(&gt->uc.guc);
+		intel_guc_invalidate_tlb(&gt->uc.guc);
+	}
+
 	enable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
 	return 0;
Signature · 1 line
2.25.1
#5 lore raw

PATCH v2 3/4 drm/i915: add one header file for GT

In reply to Jonathan Cavitt

From: Fei Yang <[email protected]>

Add a new header file for GT related Macros.
Move I915_MAX_GT to this new header file because it doesn't belong to the i915 level.

---
 drivers/gpu/drm/i915/gt/intel_gt_types.h | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/i915/gt/intel_gt_types.h +1 -0
index def7dd0eb6f19..d697fcd7bad77 100644
@@ -23,6 +23,7 @@
 #include "i915_perf_types.h"
 #include "intel_engine_types.h"
 #include "intel_gt_buffer_pool_types.h"
+#include "intel_gt_defines.h"
 #include "intel_hwconfig.h"
 #include "intel_llc_types.h"
 #include "intel_reset_types.h"
Signature · 1 line
2.25.1
#7 lore raw

PATCH v2 4/4 drm/i915: Invalidate the TLBs on each GT

In reply to Jonathan Cavitt

From: Chris Wilson <[email protected]>

With multi-GT devices, the object may have been bound on each GT and so we need to invalidate the TLBs across all GT before releasing the pages back to the system.

---
 drivers/gpu/drm/i915/gem/i915_gem_pages.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/gem/i915_gem_pages.c +1 -1
index 6b6d22c194110..0ba955611dfb5 100644
@@ -198,7 +198,7 @@ static void flush_tlb_invalidate(struct drm_i915_gem_object *obj)
 
 	for_each_gt(gt, i915, id) {
 		if (!obj->mm.tlb[id])
-			return;
+			continue;
 
 		intel_gt_invalidate_tlb_full(gt, obj->mm.tlb[id]);
 		obj->mm.tlb[id] = 0;
Signature · 1 line
2.25.1
#9 lore raw

[Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for series starting with [v2,1/4] drm/i915: Define and use GuC and CTB TLB invalidation routines

In reply to Jonathan Cavitt
== Series Details ==

== Series Details ==

Series: series starting with [v2,1/4] drm/i915: Define and use GuC and CTB TLB invalidation routines
URL : https://patchwork.freedesktop.org/series/124472/
State : warning

== Summary ==

Error: dim checkpatch failed
11e3929526f1 drm/i915: Define and use GuC and CTB TLB invalidation routines -:246: WARNING:LINE_SPACING: Missing a blank line after declarations #246: FILE: drivers/gpu/drm/i915/gt/uc/intel_guc_ct.c:1196:
+ int ret = intel_guc_tlb_invalidation_done(ct_to_guc(ct), hxg, request->size);
+ ct_free_msg(request);

-:336: WARNING:AVOID_BUG: Do not crash the kernel unless it is absolutely unavoidable--use WARN_ON_ONCE() plus recovery code (if feasible) instead of BUG() or variants #336: FILE: drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:1995:
+ GEM_BUG_ON(wait->status);

-:465: WARNING:LONG_LINE: line length of 103 exceeds 100 columns #465: FILE: drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:4762:
+ REG_FIELD_PREP(INTEL_GUC_TLB_INVAL_MODE_MASK, INTEL_GUC_TLB_INVAL_MODE_HEAVY) |

-:501: WARNING:BRACES: braces {} are not necessary for single statement blocks #501: FILE: drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:4798:
+ if (err) {
+ goto out;
+ }

-:537: CHECK:LINE_SPACING: Please don't use multiple blank lines #537: FILE: drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:4834:
+
+

total: 0 errors, 4 warnings, 1 checks, 460 lines checked 2af442b6cac6 drm/i915: No TLB invalidation on wedged or suspended GT 9f3951ca96dc drm/i915: add one header file for GT 152c85bedcbb drm/i915: Invalidate the TLBs on each GT

#10 lore raw

[Intel-gfx] ✗ Fi.CI.SPARSE: warning for series starting with [v2,1/4] drm/i915: Define and use GuC and CTB TLB invalidation routines

In reply to Jonathan Cavitt
== Series Details ==

== Series Details ==

Series: series starting with [v2,1/4] drm/i915: Define and use GuC and CTB TLB invalidation routines
URL : https://patchwork.freedesktop.org/series/124472/
State : warning

== Summary ==

Error: dim sparse failed
Sparse version: v0.6.2
Fast mode used, each commit won't be checked separately.

#11 lore raw

[Intel-gfx] ✗ Fi.CI.BAT: failure for series starting with [v2,1/4] drm/i915: Define and use GuC and CTB TLB invalidation routines

In reply to Jonathan Cavitt
== Series Details ==

== Series Details ==

Series: series starting with [v2,1/4] drm/i915: Define and use GuC and CTB TLB invalidation routines
URL : https://patchwork.freedesktop.org/series/124472/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_13693 -> Patchwork_124472v1
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with Patchwork_124472v1 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes
introduced in Patchwork_124472v1, please notify your bug team ([email protected]) to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/index.html

Participating hosts (38 -> 36)
------------------------------

Additional (1): bat-dg2-9
Missing (3): fi-skl-guc bat-atsm-1 fi-snb-2520m

Possible new issues
-------------------

Here are the unknown changes that may have been introduced in Patchwork_124472v1:

### IGT changes ###

#### Possible regressions ####

* igt@gem_exec_suspend@basic-s0@smem:
- bat-adls-5: [PASS][1] -> [INCOMPLETE][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13693/bat-adls-5/igt@gem_exec_suspend@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/bat-adls-5/igt@gem_exec_suspend@[email protected]
- fi-apl-guc: [PASS][3] -> [INCOMPLETE][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13693/fi-apl-guc/igt@gem_exec_suspend@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/fi-apl-guc/igt@gem_exec_suspend@[email protected]
- fi-kbl-guc: [PASS][5] -> [INCOMPLETE][6]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13693/fi-kbl-guc/igt@gem_exec_suspend@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/fi-kbl-guc/igt@gem_exec_suspend@[email protected]
- fi-cfl-guc: [PASS][7] -> [INCOMPLETE][8]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13693/fi-cfl-guc/igt@gem_exec_suspend@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/fi-cfl-guc/igt@gem_exec_suspend@[email protected]

* igt@gem_ringfill@basic-all:
- bat-dg1-5: [PASS][9] -> [DMESG-WARN][10] +6 other tests dmesg-warn
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13693/bat-dg1-5/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/bat-dg1-5/igt@[email protected]

* igt@i915_selftest@live@gt_tlb:
- bat-mtlp-6: [PASS][11] -> [DMESG-FAIL][12]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13693/bat-mtlp-6/igt@i915_selftest@live@gt_tlb.html
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/bat-mtlp-6/igt@i915_selftest@live@gt_tlb.html
- bat-mtlp-8: [PASS][13] -> [DMESG-FAIL][14]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13693/bat-mtlp-8/igt@i915_selftest@live@gt_tlb.html
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/bat-mtlp-8/igt@i915_selftest@live@gt_tlb.html

* igt@i915_selftest@live@guc_hang:
- bat-rpls-1: [PASS][15] -> [ABORT][16]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13693/bat-rpls-1/igt@i915_selftest@live@guc_hang.html
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/bat-rpls-1/igt@i915_selftest@live@guc_hang.html
- bat-adlp-9: [PASS][17] -> [ABORT][18]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13693/bat-adlp-9/igt@i915_selftest@live@guc_hang.html
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/bat-adlp-9/igt@i915_selftest@live@guc_hang.html
- bat-dg2-11: [PASS][19] -> [ABORT][20]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13693/bat-dg2-11/igt@i915_selftest@live@guc_hang.html
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/bat-dg2-11/igt@i915_selftest@live@guc_hang.html
- bat-adlm-1: [PASS][21] -> [ABORT][22]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13693/bat-adlm-1/igt@i915_selftest@live@guc_hang.html
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/bat-adlm-1/igt@i915_selftest@live@guc_hang.html

Known issues
------------

Here are the changes found in Patchwork_124472v1 that come from known issues:

### CI changes ###

#### Possible fixes ####

* boot:
- fi-hsw-4770: [FAIL][23] ([i915#8293]) -> [PASS][24]
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13693/fi-hsw-4770/boot.html
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/fi-hsw-4770/boot.html

### IGT changes ###

#### Issues hit ####

* igt@gem_mmap@basic:
- bat-dg2-9: NOTRUN -> [SKIP][25] ([i915#4083])
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/bat-dg2-9/igt@[email protected]

* igt@gem_mmap_gtt@basic:
- bat-dg2-9: NOTRUN -> [SKIP][26] ([i915#4077]) +2 other tests skip
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/bat-dg2-9/igt@[email protected]

* igt@gem_render_tiled_blits@basic:
- bat-dg2-9: NOTRUN -> [SKIP][27] ([i915#4079]) +1 other test skip
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/bat-dg2-9/igt@[email protected]

* igt@i915_pm_rps@basic-api:
- bat-dg2-9: NOTRUN -> [SKIP][28] ([i915#6621])
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/bat-dg2-9/igt@[email protected]

* igt@i915_suspend@basic-s3-without-i915:
- bat-mtlp-8: NOTRUN -> [SKIP][29] ([i915#6645])
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/bat-mtlp-8/igt@[email protected]

* igt@kms_addfb_basic@addfb25-y-tiled-small-legacy:
- bat-dg2-9: NOTRUN -> [SKIP][30] ([i915#5190])
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/bat-dg2-9/igt@[email protected]
- fi-hsw-4770: NOTRUN -> [SKIP][31] ([fdo#109271]) +13 other tests skip
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/fi-hsw-4770/igt@[email protected]

* igt@kms_addfb_basic@basic-y-tiled-legacy:
- bat-dg2-9: NOTRUN -> [SKIP][32] ([i915#4215] / [i915#5190])
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/bat-dg2-9/igt@[email protected]

* igt@kms_addfb_basic@framebuffer-vs-set-tiling:
- bat-dg2-9: NOTRUN -> [SKIP][33] ([i915#4212]) +6 other tests skip
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/bat-dg2-9/igt@[email protected]

* igt@kms_addfb_basic@tile-pitch-mismatch:
- bat-dg2-9: NOTRUN -> [SKIP][34] ([i915#4212] / [i915#5608])
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/bat-dg2-9/igt@[email protected]

* igt@kms_cursor_legacy@basic-busy-flip-before-cursor-legacy:
- bat-dg2-9: NOTRUN -> [SKIP][35] ([i915#4103] / [i915#4213] / [i915#5608]) +1 other test skip
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/bat-dg2-9/igt@[email protected]

* igt@kms_force_connector_basic@force-load-detect:
- bat-dg2-9: NOTRUN -> [SKIP][36] ([fdo#109285])
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/bat-dg2-9/igt@[email protected]

* igt@kms_force_connector_basic@prune-stale-modes:
- bat-dg2-9: NOTRUN -> [SKIP][37] ([i915#5274])
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/bat-dg2-9/igt@[email protected]

* igt@kms_frontbuffer_tracking@basic:
- fi-bsw-nick: [PASS][38] -> [FAIL][39] ([i915#9276])
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13693/fi-bsw-nick/igt@[email protected]
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/fi-bsw-nick/igt@[email protected]

* igt@kms_pipe_crc_basic@read-crc-frame-sequence@pipe-c-dp-5:
- bat-adlp-11: NOTRUN -> [ABORT][40] ([i915#8668])
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/bat-adlp-11/igt@kms_pipe_crc_basic@[email protected]

* igt@kms_pipe_crc_basic@suspend-read-crc@pipe-c-vga-1:
- fi-hsw-4770: NOTRUN -> [DMESG-WARN][41] ([i915#8841]) +6 other tests dmesg-warn
[41]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/fi-hsw-4770/igt@kms_pipe_crc_basic@[email protected]

* igt@kms_psr@sprite_plane_onoff:
- bat-dg2-9: NOTRUN -> [SKIP][42] ([i915#1072]) +3 other tests skip
[42]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/bat-dg2-9/igt@kms_psr@sprite_plane_onoff.html
- fi-hsw-4770: NOTRUN -> [SKIP][43] ([fdo#109271] / [i915#1072]) +3 other tests skip
[43]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/fi-hsw-4770/igt@kms_psr@sprite_plane_onoff.html

* igt@kms_setmode@basic-clone-single-crtc:
- bat-dg2-9: NOTRUN -> [SKIP][44] ([i915#3555])
[44]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/bat-dg2-9/igt@[email protected]

* igt@prime_vgem@basic-fence-flip:
- bat-dg2-9: NOTRUN -> [SKIP][45] ([i915#3708])
[45]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/bat-dg2-9/igt@[email protected]

* igt@prime_vgem@basic-fence-mmap:
- bat-dg2-9: NOTRUN -> [SKIP][46] ([i915#3708] / [i915#4077]) +1 other test skip
[46]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/bat-dg2-9/igt@[email protected]

* igt@prime_vgem@basic-write:
- bat-dg2-9: NOTRUN -> [SKIP][47] ([i915#3291] / [i915#3708]) +2 other tests skip
[47]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/bat-dg2-9/igt@[email protected]

#### Possible fixes ####

* igt@i915_selftest@live@requests:
- bat-mtlp-8: [ABORT][48] ([i915#9414]) -> [PASS][49]
[48]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13693/bat-mtlp-8/igt@i915_selftest@[email protected]
[49]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/bat-mtlp-8/igt@i915_selftest@[email protected]

* igt@kms_pipe_crc_basic@nonblocking-crc-frame-sequence@pipe-a-dp-5:
- bat-adlp-11: [DMESG-FAIL][50] ([i915#6868]) -> [PASS][51]
[50]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13693/bat-adlp-11/igt@kms_pipe_crc_basic@[email protected]
[51]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/bat-adlp-11/igt@kms_pipe_crc_basic@[email protected]

* igt@kms_pipe_crc_basic@nonblocking-crc-frame-sequence@pipe-c-dp-5:
- bat-adlp-11: [FAIL][52] ([i915#9047]) -> [PASS][53] +2 other tests pass
[52]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13693/bat-adlp-11/igt@kms_pipe_crc_basic@[email protected]
[53]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/bat-adlp-11/igt@kms_pipe_crc_basic@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285
[i915#1072]: https://gitlab.freedesktop.org/drm/intel/issues/1072
[i915#3291]: https://gitlab.freedesktop.org/drm/intel/issues/3291
[i915#3555]: https://gitlab.freedesktop.org/drm/intel/issues/3555
[i915#3708]: https://gitlab.freedesktop.org/drm/intel/issues/3708
[i915#4077]: https://gitlab.freedesktop.org/drm/intel/issues/4077
[i915#4079]: https://gitlab.freedesktop.org/drm/intel/issues/4079
[i915#4083]: https://gitlab.freedesktop.org/drm/intel/issues/4083
[i915#4103]: https://gitlab.freedesktop.org/drm/intel/issues/4103
[i915#4212]: https://gitlab.freedesktop.org/drm/intel/issues/4212
[i915#4213]: https://gitlab.freedesktop.org/drm/intel/issues/4213
[i915#4215]: https://gitlab.freedesktop.org/drm/intel/issues/4215
[i915#5190]: https://gitlab.freedesktop.org/drm/intel/issues/5190
[i915#5274]: https://gitlab.freedesktop.org/drm/intel/issues/5274
[i915#5354]: https://gitlab.freedesktop.org/drm/intel/issues/5354
[i915#5608]: https://gitlab.freedesktop.org/drm/intel/issues/5608
[i915#6621]: https://gitlab.freedesktop.org/drm/intel/issues/6621
[i915#6645]: https://gitlab.freedesktop.org/drm/intel/issues/6645
[i915#6868]: https://gitlab.freedesktop.org/drm/intel/issues/6868
[i915#7952]: https://gitlab.freedesktop.org/drm/intel/issues/7952
[i915#8293]: https://gitlab.freedesktop.org/drm/intel/issues/8293
[i915#8668]: https://gitlab.freedesktop.org/drm/intel/issues/8668
[i915#8841]: https://gitlab.freedesktop.org/drm/intel/issues/8841
[i915#9047]: https://gitlab.freedesktop.org/drm/intel/issues/9047
[i915#9276]: https://gitlab.freedesktop.org/drm/intel/issues/9276
[i915#9414]: https://gitlab.freedesktop.org/drm/intel/issues/9414

Build changes
-------------

* Linux: CI_DRM_13693 -> Patchwork_124472v1

CI-20190529: 20190529
CI_DRM_13693: bb46e837b7e59c22a567ae6913ff4d6bf0e9211a @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_7506: 4fdf544bd0a38c5a100ef43c30171827e1c8c442 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_124472v1: bb46e837b7e59c22a567ae6913ff4d6bf0e9211a @ git://anongit.freedesktop.org/gfx-ci/linux

### Linux commits

ecfd690df307 drm/i915: Invalidate the TLBs on each GT 43524d5e2600 drm/i915: add one header file for GT
d1312eea6f62 drm/i915: No TLB invalidation on wedged or suspended GT 13007c14297a drm/i915: Define and use GuC and CTB TLB invalidation routines

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_124472v1/index.html

maintainer
#2 lore raw

Re: [Intel-gfx] [PATCH v2 2/4] drm/i915: No TLB invalidation on wedged or suspended GT

In reply to Jonathan Cavitt
Quoted 21 lines · Jonathan Cavitt

From: Fei Yang <[email protected]>

In case of GT is suspended or wedged, don't allow submission of new TLB invalidation request and cancel all pending requests. The TLB entries will be invalidated either during GuC reload or on system resume.

---
 drivers/gpu/drm/i915/gt/intel_gt.h            |  9 +++++++
 drivers/gpu/drm/i915/gt/uc/intel_guc.h        |  1 +
 .../gpu/drm/i915/gt/uc/intel_guc_submission.c | 27 ++++++++++++++-----
 drivers/gpu/drm/i915/i915_driver.c            | 12 +++++++++
 4 files changed, 43 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/gt/intel_gt.h +0 -0
index 2cac499d5aa3e..3fcc0d2cd7bf3 100644

drivers/gpu/drm/i915/gt/intel_gt.h line 12

Quoted 4 lines
drivers/gpu/drm/i915/gt/intel_gt.h +1 -0
@@ -9,6 +9,7 @@
 #include "intel_engine_types.h"
 #include "intel_gt_types.h"
 #include "intel_reset.h"
+#include "i915_irq.h"

No. Please do not include headers from headers.

Currently, *zero* headers include i915_irq.h.

drivers/gpu/drm/i915/gt/intel_gt.h static inline bool intel_gt_is_wedged(const struct intel_gt *gt) · line 167

Quoted 13 lines
drivers/gpu/drm/i915/gt/intel_gt.h +7 -0
 struct drm_i915_private;
 struct drm_printer;
@@ -157,6 +158,14 @@ static inline bool intel_gt_is_wedged(const struct intel_gt *gt)
 	return unlikely(test_bit(I915_WEDGED, &gt->reset.flags));
 }
 
+static inline bool intel_gt_is_enabled(const struct intel_gt *gt)
+{
+	/* Check if GT is wedged or suspended */
+	if (intel_gt_is_wedged(gt) || !intel_irqs_enabled(gt->i915))
+		return false;
+	return true;
+}

No. Please do not add static inlines in headers that require you to pull in more headers.

I've spent an awful lot of time cleaning this up, and I don't look kindly on that work being undermined.

Please look at [1] for my latest cleanup series. In particular, please take a moment to appreciate the stats in the cover letter. We have headers that, when modified, cause 300+ object files to be rebuilt.

Currently, 24 object files depend on i915_irq.h. This patch bumps that number to 129.

I don't approve.

BR,
Jani.

[1] https://patchwork.freedesktop.org/series/124418/

Quoted 136 lines
drivers/gpu/drm/i915/gt/intel_gt.h +1 -0
+
 int intel_gt_probe_all(struct drm_i915_private *i915);
 int intel_gt_tiles_init(struct drm_i915_private *i915);
 void intel_gt_release_all(struct drm_i915_private *i915);
drivers/gpu/drm/i915/gt/uc/intel_guc.h +1 -0
index 0f74a460bfe56..5fe48f7ab7d65 100644
@@ -536,4 +536,5 @@ void intel_guc_dump_time_info(struct intel_guc *guc, struct drm_printer *p);
 
 int intel_guc_sched_disable_gucid_threshold_max(struct intel_guc *guc);
 
+void wake_up_all_tlb_invalidate(struct intel_guc *guc);
 #endif
drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c +21 -6
index 6a2dcab63074e..fd64443806e5c 100644
@@ -32,6 +32,7 @@
 
 #include "i915_drv.h"
 #include "i915_reg.h"
+#include "i915_irq.h"
 #include "i915_trace.h"
 
 /**
@@ -1803,13 +1804,20 @@ static void wake_up_tlb_invalidate(struct intel_guc_tlb_wait *wait)
 	wake_up(&wait->wq);
 }
 
-void intel_guc_submission_reset(struct intel_guc *guc, intel_engine_mask_t stalled)
+void wake_up_all_tlb_invalidate(struct intel_guc *guc)
 {
 	struct intel_guc_tlb_wait *wait;
+	unsigned long i;
+
+	xa_for_each(&guc->tlb_lookup, i, wait)
+		wake_up_tlb_invalidate(wait);
+}
+
+void intel_guc_submission_reset(struct intel_guc *guc, intel_engine_mask_t stalled)
+{
 	struct intel_context *ce;
 	unsigned long index;
 	unsigned long flags;
-	unsigned long i;
 
 	if (unlikely(!guc_submission_initialized(guc))) {
 		/* Reset called during driver load? GuC not yet initialised! */
@@ -1840,8 +1848,7 @@ void intel_guc_submission_reset(struct intel_guc *guc, intel_engine_mask_t stall
 	 * The full GT reset will have cleared the TLB caches and flushed the
 	 * G2H message queue; we can release all the blocked waiters.
 	 */
-	xa_for_each(&guc->tlb_lookup, i, wait)
-		wake_up_tlb_invalidate(wait);
+	wake_up_all_tlb_invalidate(guc);
 }
 
 static void guc_cancel_context_requests(struct intel_context *ce)
@@ -1937,6 +1944,12 @@ void intel_guc_submission_cancel_requests(struct intel_guc *guc)
 
 	/* GuC is blown away, drop all references to contexts */
 	xa_destroy(&guc->context_lookup);
+
+	/*
+	 * Wedged GT won't respond to any TLB invalidation request. Simply
+	 * release all the blocked waiters.
+	 */
+	wake_up_all_tlb_invalidate(guc);
 }
 
 void intel_guc_submission_reset_finish(struct intel_guc *guc)
@@ -4764,7 +4777,8 @@ static int guc_send_invalidate_tlb(struct intel_guc *guc, u32 type)
 	};
 	u32 size = ARRAY_SIZE(action);
 
-	if (!intel_guc_ct_enabled(&guc->ct))
+	if (!intel_guc_ct_enabled(&guc->ct) ||
+	    !intel_gt_is_enabled(gt))
 		return -EINVAL;
 
 	init_waitqueue_head(&_wq.wq);
@@ -4806,7 +4820,8 @@ static int guc_send_invalidate_tlb(struct intel_guc *guc, u32 type)
 	 * queued in CT buffer.
 	 */
 #define OUTSTANDING_GUC_TIMEOUT_PERIOD  (HZ * 2)
-	if (!must_wait_woken(&wait, OUTSTANDING_GUC_TIMEOUT_PERIOD)) {
+	if (!must_wait_woken(&wait, OUTSTANDING_GUC_TIMEOUT_PERIOD) &&
+	    intel_gt_is_enabled(gt)) {
 		gt_err(gt,
 		       "TLB invalidation response timed out for seqno %u\n", seqno);
 		err = -ETIME;
drivers/gpu/drm/i915/i915_driver.c +12 -0
index 78501a83ba109..30c2a7ced10f8 100644
@@ -72,6 +72,7 @@
 #include "gt/intel_gt.h"
 #include "gt/intel_gt_pm.h"
 #include "gt/intel_rc6.h"
+#include "gt/uc/intel_guc.h"
 
 #include "pxp/intel_pxp.h"
 #include "pxp/intel_pxp_debugfs.h"
@@ -1076,6 +1077,8 @@ static int i915_drm_suspend(struct drm_device *dev)
 	struct drm_i915_private *dev_priv = to_i915(dev);
 	struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev);
 	pci_power_t opregion_target_state;
+	struct intel_gt *gt;
+	int i;
 
 	disable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
@@ -1092,6 +1095,10 @@ static int i915_drm_suspend(struct drm_device *dev)
 	intel_dp_mst_suspend(dev_priv);
 
 	intel_runtime_pm_disable_interrupts(dev_priv);
+
+	for_each_gt(gt, dev_priv, i)
+		wake_up_all_tlb_invalidate(&gt->uc.guc);
+
 	intel_hpd_cancel_work(dev_priv);
 
 	intel_suspend_encoders(dev_priv);
@@ -1263,6 +1270,11 @@ static int i915_drm_resume(struct drm_device *dev)
 
 	intel_gvt_resume(dev_priv);
 
+	for_each_gt(gt, dev_priv, i) {
+		intel_guc_invalidate_tlb_full(&gt->uc.guc);
+		intel_guc_invalidate_tlb(&gt->uc.guc);
+	}
+
 	enable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
 	return 0;
Signature · 1 line
Jani Nikula, Intel
maintainer
#6 lore raw

Re: [Intel-gfx] [PATCH v2 3/4] drm/i915: add one header file for GT

In reply to Jonathan Cavitt
Quoted 19 lines · Jonathan Cavitt

From: Fei Yang <[email protected]>

Add a new header file for GT related Macros.
Move I915_MAX_GT to this new header file because it doesn't belong to the i915 level.

---
 drivers/gpu/drm/i915/gt/intel_gt_types.h | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/i915/gt/intel_gt_types.h +0 -0
index def7dd0eb6f19..d697fcd7bad77 100644

drivers/gpu/drm/i915/gt/intel_gt_types.h line 26

Quoted 4 lines
drivers/gpu/drm/i915/gt/intel_gt_types.h +1 -0
@@ -23,6 +23,7 @@
 #include "i915_perf_types.h"
 #include "intel_engine_types.h"
 #include "intel_gt_buffer_pool_types.h"
+#include "intel_gt_defines.h"

Absolutely not.

Include it where needed.

We don't want catch-all headers.

BR,
Jani.

Quoted 3 lines
drivers/gpu/drm/i915/gt/intel_gt_types.h +0 -0
 #include "intel_hwconfig.h"
 #include "intel_llc_types.h"
 #include "intel_reset_types.h"
Signature · 1 line
Jani Nikula, Intel
#3 lore raw

Re: [Intel-gfx] [PATCH v2 2/4] drm/i915: No TLB invalidation on wedged or suspended GT

In reply to Jani Nikula
Quoted 37 lines · Jani Nikula
Quoted 21 lines · Jonathan Cavitt

From: Fei Yang <[email protected]>

In case of GT is suspended or wedged, don't allow submission of new TLB invalidation request and cancel all pending requests. The TLB entries will be invalidated either during GuC reload or on system resume.

---
  drivers/gpu/drm/i915/gt/intel_gt.h            |  9 +++++++
  drivers/gpu/drm/i915/gt/uc/intel_guc.h        |  1 +
  .../gpu/drm/i915/gt/uc/intel_guc_submission.c | 27 ++++++++++++++-----
  drivers/gpu/drm/i915/i915_driver.c            | 12 +++++++++
  4 files changed, 43 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/gt/intel_gt.h +0 -0
index 2cac499d5aa3e..3fcc0d2cd7bf3 100644

drivers/gpu/drm/i915/gt/intel_gt.h line 12

Quoted 4 lines
drivers/gpu/drm/i915/gt/intel_gt.h +1 -0
@@ -9,6 +9,7 @@
  #include "intel_engine_types.h"
  #include "intel_gt_types.h"
  #include "intel_reset.h"
+#include "i915_irq.h"

No. Please do not include headers from headers.

Currently, *zero* headers include i915_irq.h.

Quoted 6 lines
drivers/gpu/drm/i915/gt/intel_gt.h +0 -0
  struct drm_i915_private;
  struct drm_printer;
@@ -157,6 +158,14 @@ static inline bool intel_gt_is_wedged(const struct intel_gt *gt)
  	return unlikely(test_bit(I915_WEDGED, &gt->reset.flags));
  }
 
Quoted 10 lines

drivers/gpu/drm/i915/gt/intel_gt.h static inline bool intel_gt_is_wedged(const struct intel_gt *gt) · line 167

Quoted 7 lines
drivers/gpu/drm/i915/gt/intel_gt.h +7 -0
+static inline bool intel_gt_is_enabled(const struct intel_gt *gt)
+{
+	/* Check if GT is wedged or suspended */
+	if (intel_gt_is_wedged(gt) || !intel_irqs_enabled(gt->i915))
+		return false;
+	return true;
+}

No. Please do not add static inlines in headers that require you to pull in more headers.

Agreed. This one I think I commented on before how the name is not right and the helper itself can just be something more appropriately called and placed internally in intel_guc_submission.c, where the only two its callers are.

Btw has this version of the series fixed the null ptr deref on driver load when i915.enable_guc=2?

Regards,

Tvrtko

Quoted 158 lines

I've spent an awful lot of time cleaning this up, and I don't look kindly on that work being undermined.

Please look at [1] for my latest cleanup series. In particular, please take a moment to appreciate the stats in the cover letter. We have headers that, when modified, cause 300+ object files to be rebuilt.

Currently, 24 object files depend on i915_irq.h. This patch bumps that number to 129.

I don't approve.

BR,
Jani.

[1] https://patchwork.freedesktop.org/series/124418/

Quoted 136 lines
drivers/gpu/drm/i915/gt/intel_gt.h +1 -0
+
  int intel_gt_probe_all(struct drm_i915_private *i915);
  int intel_gt_tiles_init(struct drm_i915_private *i915);
  void intel_gt_release_all(struct drm_i915_private *i915);
drivers/gpu/drm/i915/gt/uc/intel_guc.h +1 -0
index 0f74a460bfe56..5fe48f7ab7d65 100644
@@ -536,4 +536,5 @@ void intel_guc_dump_time_info(struct intel_guc *guc, struct drm_printer *p);
 
  int intel_guc_sched_disable_gucid_threshold_max(struct intel_guc *guc);
 
+void wake_up_all_tlb_invalidate(struct intel_guc *guc);
  #endif
drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c +21 -6
index 6a2dcab63074e..fd64443806e5c 100644
@@ -32,6 +32,7 @@
 
  #include "i915_drv.h"
  #include "i915_reg.h"
+#include "i915_irq.h"
  #include "i915_trace.h"
 
  /**
@@ -1803,13 +1804,20 @@ static void wake_up_tlb_invalidate(struct intel_guc_tlb_wait *wait)
  	wake_up(&wait->wq);
  }
 
-void intel_guc_submission_reset(struct intel_guc *guc, intel_engine_mask_t stalled)
+void wake_up_all_tlb_invalidate(struct intel_guc *guc)
  {
  	struct intel_guc_tlb_wait *wait;
+	unsigned long i;
+
+	xa_for_each(&guc->tlb_lookup, i, wait)
+		wake_up_tlb_invalidate(wait);
+}
+
+void intel_guc_submission_reset(struct intel_guc *guc, intel_engine_mask_t stalled)
+{
  	struct intel_context *ce;
  	unsigned long index;
  	unsigned long flags;
-	unsigned long i;
 
  	if (unlikely(!guc_submission_initialized(guc))) {
  		/* Reset called during driver load? GuC not yet initialised! */
@@ -1840,8 +1848,7 @@ void intel_guc_submission_reset(struct intel_guc *guc, intel_engine_mask_t stall
  	 * The full GT reset will have cleared the TLB caches and flushed the
  	 * G2H message queue; we can release all the blocked waiters.
  	 */
-	xa_for_each(&guc->tlb_lookup, i, wait)
-		wake_up_tlb_invalidate(wait);
+	wake_up_all_tlb_invalidate(guc);
  }
 
  static void guc_cancel_context_requests(struct intel_context *ce)
@@ -1937,6 +1944,12 @@ void intel_guc_submission_cancel_requests(struct intel_guc *guc)
 
  	/* GuC is blown away, drop all references to contexts */
  	xa_destroy(&guc->context_lookup);
+
+	/*
+	 * Wedged GT won't respond to any TLB invalidation request. Simply
+	 * release all the blocked waiters.
+	 */
+	wake_up_all_tlb_invalidate(guc);
  }
 
  void intel_guc_submission_reset_finish(struct intel_guc *guc)
@@ -4764,7 +4777,8 @@ static int guc_send_invalidate_tlb(struct intel_guc *guc, u32 type)
  	};
  	u32 size = ARRAY_SIZE(action);
 
-	if (!intel_guc_ct_enabled(&guc->ct))
+	if (!intel_guc_ct_enabled(&guc->ct) ||
+	    !intel_gt_is_enabled(gt))
  		return -EINVAL;
 
  	init_waitqueue_head(&_wq.wq);
@@ -4806,7 +4820,8 @@ static int guc_send_invalidate_tlb(struct intel_guc *guc, u32 type)
  	 * queued in CT buffer.
  	 */
  #define OUTSTANDING_GUC_TIMEOUT_PERIOD  (HZ * 2)
-	if (!must_wait_woken(&wait, OUTSTANDING_GUC_TIMEOUT_PERIOD)) {
+	if (!must_wait_woken(&wait, OUTSTANDING_GUC_TIMEOUT_PERIOD) &&
+	    intel_gt_is_enabled(gt)) {
  		gt_err(gt,
  		       "TLB invalidation response timed out for seqno %u\n", seqno);
  		err = -ETIME;
drivers/gpu/drm/i915/i915_driver.c +12 -0
index 78501a83ba109..30c2a7ced10f8 100644
@@ -72,6 +72,7 @@
  #include "gt/intel_gt.h"
  #include "gt/intel_gt_pm.h"
  #include "gt/intel_rc6.h"
+#include "gt/uc/intel_guc.h"
 
  #include "pxp/intel_pxp.h"
  #include "pxp/intel_pxp_debugfs.h"
@@ -1076,6 +1077,8 @@ static int i915_drm_suspend(struct drm_device *dev)
  	struct drm_i915_private *dev_priv = to_i915(dev);
  	struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev);
  	pci_power_t opregion_target_state;
+	struct intel_gt *gt;
+	int i;
 
  	disable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
@@ -1092,6 +1095,10 @@ static int i915_drm_suspend(struct drm_device *dev)
  	intel_dp_mst_suspend(dev_priv);
 
  	intel_runtime_pm_disable_interrupts(dev_priv);
+
+	for_each_gt(gt, dev_priv, i)
+		wake_up_all_tlb_invalidate(&gt->uc.guc);
+
  	intel_hpd_cancel_work(dev_priv);
 
  	intel_suspend_encoders(dev_priv);
@@ -1263,6 +1270,11 @@ static int i915_drm_resume(struct drm_device *dev)
 
  	intel_gvt_resume(dev_priv);
 
+	for_each_gt(gt, dev_priv, i) {
+		intel_guc_invalidate_tlb_full(&gt->uc.guc);
+		intel_guc_invalidate_tlb(&gt->uc.guc);
+	}
+
  	enable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
  	return 0;
#4 lore raw

Re: [Intel-gfx] [PATCH v2 2/4] drm/i915: No TLB invalidation on wedged or suspended GT

In reply to Jonathan Cavitt
Quoted 153 lines · Jonathan Cavitt

From: Fei Yang <[email protected]>

In case of GT is suspended or wedged, don't allow submission of new TLB invalidation request and cancel all pending requests. The TLB entries will be invalidated either during GuC reload or on system resume.

---
  drivers/gpu/drm/i915/gt/intel_gt.h            |  9 +++++++
  drivers/gpu/drm/i915/gt/uc/intel_guc.h        |  1 +
  .../gpu/drm/i915/gt/uc/intel_guc_submission.c | 27 ++++++++++++++-----
  drivers/gpu/drm/i915/i915_driver.c            | 12 +++++++++
  4 files changed, 43 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/gt/intel_gt.h +9 -0
index 2cac499d5aa3e..3fcc0d2cd7bf3 100644
@@ -9,6 +9,7 @@
  #include "intel_engine_types.h"
  #include "intel_gt_types.h"
  #include "intel_reset.h"
+#include "i915_irq.h"
 
  struct drm_i915_private;
  struct drm_printer;
@@ -157,6 +158,14 @@ static inline bool intel_gt_is_wedged(const struct intel_gt *gt)
  	return unlikely(test_bit(I915_WEDGED, &gt->reset.flags));
  }
 
+static inline bool intel_gt_is_enabled(const struct intel_gt *gt)
+{
+	/* Check if GT is wedged or suspended */
+	if (intel_gt_is_wedged(gt) || !intel_irqs_enabled(gt->i915))
+		return false;
+	return true;
+}
+
  int intel_gt_probe_all(struct drm_i915_private *i915);
  int intel_gt_tiles_init(struct drm_i915_private *i915);
  void intel_gt_release_all(struct drm_i915_private *i915);
drivers/gpu/drm/i915/gt/uc/intel_guc.h +1 -0
index 0f74a460bfe56..5fe48f7ab7d65 100644
@@ -536,4 +536,5 @@ void intel_guc_dump_time_info(struct intel_guc *guc, struct drm_printer *p);
 
  int intel_guc_sched_disable_gucid_threshold_max(struct intel_guc *guc);
 
+void wake_up_all_tlb_invalidate(struct intel_guc *guc);
  #endif
drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c +21 -6
index 6a2dcab63074e..fd64443806e5c 100644
@@ -32,6 +32,7 @@
 
  #include "i915_drv.h"
  #include "i915_reg.h"
+#include "i915_irq.h"
  #include "i915_trace.h"
 
  /**
@@ -1803,13 +1804,20 @@ static void wake_up_tlb_invalidate(struct intel_guc_tlb_wait *wait)
  	wake_up(&wait->wq);
  }
 
-void intel_guc_submission_reset(struct intel_guc *guc, intel_engine_mask_t stalled)
+void wake_up_all_tlb_invalidate(struct intel_guc *guc)
  {
  	struct intel_guc_tlb_wait *wait;
+	unsigned long i;
+
+	xa_for_each(&guc->tlb_lookup, i, wait)
+		wake_up_tlb_invalidate(wait);
+}
+
+void intel_guc_submission_reset(struct intel_guc *guc, intel_engine_mask_t stalled)
+{
  	struct intel_context *ce;
  	unsigned long index;
  	unsigned long flags;
-	unsigned long i;
 
  	if (unlikely(!guc_submission_initialized(guc))) {
  		/* Reset called during driver load? GuC not yet initialised! */
@@ -1840,8 +1848,7 @@ void intel_guc_submission_reset(struct intel_guc *guc, intel_engine_mask_t stall
  	 * The full GT reset will have cleared the TLB caches and flushed the
  	 * G2H message queue; we can release all the blocked waiters.
  	 */
-	xa_for_each(&guc->tlb_lookup, i, wait)
-		wake_up_tlb_invalidate(wait);
+	wake_up_all_tlb_invalidate(guc);
  }
 
  static void guc_cancel_context_requests(struct intel_context *ce)
@@ -1937,6 +1944,12 @@ void intel_guc_submission_cancel_requests(struct intel_guc *guc)
 
  	/* GuC is blown away, drop all references to contexts */
  	xa_destroy(&guc->context_lookup);
+
+	/*
+	 * Wedged GT won't respond to any TLB invalidation request. Simply
+	 * release all the blocked waiters.
+	 */
+	wake_up_all_tlb_invalidate(guc);
  }
 
  void intel_guc_submission_reset_finish(struct intel_guc *guc)
@@ -4764,7 +4777,8 @@ static int guc_send_invalidate_tlb(struct intel_guc *guc, u32 type)
  	};
  	u32 size = ARRAY_SIZE(action);
 
-	if (!intel_guc_ct_enabled(&guc->ct))
+	if (!intel_guc_ct_enabled(&guc->ct) ||
+	    !intel_gt_is_enabled(gt))
  		return -EINVAL;
 
  	init_waitqueue_head(&_wq.wq);
@@ -4806,7 +4820,8 @@ static int guc_send_invalidate_tlb(struct intel_guc *guc, u32 type)
  	 * queued in CT buffer.
  	 */
  #define OUTSTANDING_GUC_TIMEOUT_PERIOD  (HZ * 2)
-	if (!must_wait_woken(&wait, OUTSTANDING_GUC_TIMEOUT_PERIOD)) {
+	if (!must_wait_woken(&wait, OUTSTANDING_GUC_TIMEOUT_PERIOD) &&
+	    intel_gt_is_enabled(gt)) {
  		gt_err(gt,
  		       "TLB invalidation response timed out for seqno %u\n", seqno);
  		err = -ETIME;
drivers/gpu/drm/i915/i915_driver.c +3 -0
index 78501a83ba109..30c2a7ced10f8 100644
@@ -72,6 +72,7 @@
  #include "gt/intel_gt.h"
  #include "gt/intel_gt_pm.h"
  #include "gt/intel_rc6.h"
+#include "gt/uc/intel_guc.h"
 
  #include "pxp/intel_pxp.h"
  #include "pxp/intel_pxp_debugfs.h"
@@ -1076,6 +1077,8 @@ static int i915_drm_suspend(struct drm_device *dev)
  	struct drm_i915_private *dev_priv = to_i915(dev);
  	struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev);
  	pci_power_t opregion_target_state;
+	struct intel_gt *gt;
+	int i;
 
  	disable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 

drivers/gpu/drm/i915/i915_driver.c static int i915_drm_suspend(struct drm_device *dev) · line 1100

Quoted 6 lines
drivers/gpu/drm/i915/i915_driver.c +3 -0
@@ -1092,6 +1095,10 @@ static int i915_drm_suspend(struct drm_device *dev)
  	intel_dp_mst_suspend(dev_priv);
 
  	intel_runtime_pm_disable_interrupts(dev_priv);
+
+	for_each_gt(gt, dev_priv, i)
+		wake_up_all_tlb_invalidate(&gt->uc.guc);

Addition of for_each_gt here and below feels should be a separate patch.

Regards,

Tvrtko

Quoted 16 lines
drivers/gpu/drm/i915/i915_driver.c +6 -0
+
  	intel_hpd_cancel_work(dev_priv);
 
  	intel_suspend_encoders(dev_priv);
@@ -1263,6 +1270,11 @@ static int i915_drm_resume(struct drm_device *dev)
 
  	intel_gvt_resume(dev_priv);
 
+	for_each_gt(gt, dev_priv, i) {
+		intel_guc_invalidate_tlb_full(&gt->uc.guc);
+		intel_guc_invalidate_tlb(&gt->uc.guc);
+	}
+
  	enable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
  	return 0;
Reviewed-by on v2 4/4
#8 lore raw

Re: [Intel-gfx] [PATCH v2 4/4] drm/i915: Invalidate the TLBs on each GT

In reply to Jonathan Cavitt

Hi Jonathan,

Quoted 10 lines · Jonathan Cavitt

From: Chris Wilson <[email protected]>

With multi-GT devices, the object may have been bound on each GT and so we need to invalidate the TLBs across all GT before releasing the pages back to the system.

As Nirmoy has been needing this on a different context, could you please send just this one as a separate e-mail?

This should also fix d6c531ab4820 ("drm/i915: Invalidate the TLBs on each GT")

Thanks,
Andi

Quoted 19 lines
---
 drivers/gpu/drm/i915/gem/i915_gem_pages.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/gem/i915_gem_pages.c +1 -1
index 6b6d22c194110..0ba955611dfb5 100644
@@ -198,7 +198,7 @@ static void flush_tlb_invalidate(struct drm_i915_gem_object *obj)
 
 	for_each_gt(gt, i915, id) {
 		if (!obj->mm.tlb[id])
-			return;
+			continue;
 
 		intel_gt_invalidate_tlb_full(gt, obj->mm.tlb[id]);
 		obj->mm.tlb[id] = 0;
Signature · 1 line
2.25.1