Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Brost <matthew.brost@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: farah.kassabri@intel.com, michal.wajdeczko@intel.com
Subject: [PATCH 11/11] drm/xe: Add GT TLB invalidation watermark debugfs
Date: Fri,  5 Jul 2024 17:02:52 -0700	[thread overview]
Message-ID: <20240706000252.702044-12-matthew.brost@intel.com> (raw)
In-Reply-To: <20240706000252.702044-1-matthew.brost@intel.com>

Add GT TLB invalidation watermark to debugfs for feature tuning and
disabling (less than equal to a value of 1).

Signed-off-by: Matthew Brost <matthew.brost@intel.com>
---
 drivers/gpu/drm/xe/xe_debugfs.c             | 38 +++++++++++++++++++++
 drivers/gpu/drm/xe/xe_device.c              |  3 ++
 drivers/gpu/drm/xe/xe_device_types.h        |  5 +++
 drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c |  8 ++---
 4 files changed, 50 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_debugfs.c b/drivers/gpu/drm/xe/xe_debugfs.c
index 1011e5d281fa..dd27172197be 100644
--- a/drivers/gpu/drm/xe/xe_debugfs.c
+++ b/drivers/gpu/drm/xe/xe_debugfs.c
@@ -173,6 +173,41 @@ static const struct file_operations wedged_mode_fops = {
 	.write = wedged_mode_set,
 };
 
+static ssize_t tlb_invalidation_watermark_show(struct file *f, char __user *ubuf,
+					       size_t size, loff_t *pos)
+{
+	struct xe_device *xe = file_inode(f)->i_private;
+	char buf[32];
+	int len = 0;
+
+	len = scnprintf(buf, sizeof(buf), "%d\n", xe->tlb_invalidation_watermark);
+
+	return simple_read_from_buffer(ubuf, size, pos, buf, len);
+}
+
+static ssize_t tlb_invalidation_watermark_set(struct file *f,
+					      const char __user *ubuf,
+					      size_t size, loff_t *pos)
+{
+	struct xe_device *xe = file_inode(f)->i_private;
+	int tlb_invalidation_watermark;
+	ssize_t ret;
+
+	ret = kstrtoint_from_user(ubuf, size, 0, &tlb_invalidation_watermark);
+	if (ret)
+		return ret;
+
+	xe->tlb_invalidation_watermark = tlb_invalidation_watermark;
+
+	return size;
+}
+
+static const struct file_operations tlb_invalidation_watermark_fops = {
+	.owner = THIS_MODULE,
+	.read = tlb_invalidation_watermark_show,
+	.write = tlb_invalidation_watermark_set,
+};
+
 void xe_debugfs_register(struct xe_device *xe)
 {
 	struct ttm_device *bdev = &xe->ttm;
@@ -193,6 +228,9 @@ void xe_debugfs_register(struct xe_device *xe)
 	debugfs_create_file("wedged_mode", 0400, root, xe,
 			    &wedged_mode_fops);
 
+	debugfs_create_file("tlb_invalidation_watermark", 0400, root, xe,
+			    &tlb_invalidation_watermark_fops);
+
 	for (mem_type = XE_PL_VRAM0; mem_type <= XE_PL_VRAM1; ++mem_type) {
 		man = ttm_manager_type(bdev, mem_type);
 
diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
index db513175b29e..6d5ef3563082 100644
--- a/drivers/gpu/drm/xe/xe_device.c
+++ b/drivers/gpu/drm/xe/xe_device.c
@@ -274,6 +274,9 @@ struct xe_device *xe_device_create(struct pci_dev *pdev,
 	xe->info.revid = pdev->revision;
 	xe->info.force_execlist = xe_modparam.force_execlist;
 
+#define TLB_INVALIDATION_WATERMARK_DEFAULT	16
+	xe->tlb_invalidation_watermark = TLB_INVALIDATION_WATERMARK_DEFAULT;
+
 	spin_lock_init(&xe->irq.lock);
 	spin_lock_init(&xe->clients.lock);
 
diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_device_types.h
index f0cf9020e463..7e029493110a 100644
--- a/drivers/gpu/drm/xe/xe_device_types.h
+++ b/drivers/gpu/drm/xe/xe_device_types.h
@@ -481,6 +481,11 @@ struct xe_device {
 		int mode;
 	} wedged;
 
+	/**
+	 * @tlb_invalidation_watermark: TLB invalidation watermark to coalesce
+	 */
+	int tlb_invalidation_watermark;
+
 #ifdef TEST_VM_OPS_ERROR
 	/**
 	 * @vm_inject_error_position: inject errors at different places in VM
diff --git a/drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c b/drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c
index c7634acea938..74c2c33e043d 100644
--- a/drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c
+++ b/drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c
@@ -391,9 +391,6 @@ xe_gt_tlb_invalidation_coalesce_issue(struct xe_gt *gt,
 	xe_gt_assert(gt, list_empty(&coalesce->link));
 }
 
-/* Any more pending TLB invalidations start to hold in KMD */
-#define SEQNO_WATERMARK		16
-
 static int
 xe_gt_tlb_invalidation_coalesce_prep(struct xe_gt *gt,
 				     struct xe_gt_tlb_invalidation_fence *fence,
@@ -404,10 +401,13 @@ xe_gt_tlb_invalidation_coalesce_prep(struct xe_gt *gt,
 
 	lockdep_assert_held(&gt->tlb_invalidation.seqno_lock);
 
+	if (gt_to_xe(gt)->tlb_invalidation_watermark <= 1)	/* Disabled */
+		return 0;
+
 	spin_lock_irq(&gt->tlb_invalidation.pending_lock);
 
 	if (list_empty(&gt->tlb_invalidation.pending_coalesce) &&
-	    tlb_invalidation_seqno_diff(gt) < SEQNO_WATERMARK) {
+	    tlb_invalidation_seqno_diff(gt) < gt_to_xe(gt)->tlb_invalidation_watermark) {
 		ret = 0;
 		goto unlock;
 	}
-- 
2.34.1


  parent reply	other threads:[~2024-07-06  0:02 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-06  0:02 [PATCH 00/11] Proper GT TLB invalidation layering and new coalescing feature Matthew Brost
2024-07-06  0:02 ` [PATCH 01/11] drm/xe: Add xe_gt_tlb_invalidation_fence_init helper Matthew Brost
2024-07-06  0:02 ` [PATCH 02/11] drm/xe: Drop xe_gt_tlb_invalidation_wait Matthew Brost
2024-07-06  0:02 ` [PATCH 03/11] drm/xe: s/tlb_invalidation.lock/tlb_invalidation.fence_lock Matthew Brost
2024-07-06  0:02 ` [PATCH 04/11] drm/xe: Add tlb_invalidation.seqno_lock Matthew Brost
2024-07-06  0:02 ` [PATCH 05/11] drm/xe: Add xe_gt_tlb_invalidation_done_handler Matthew Brost
2024-07-06  0:02 ` [PATCH 06/11] drm/xe: Add send tlb invalidation helpers Matthew Brost
2024-07-06  0:02 ` [PATCH 07/11] drm/xe: Add xe_guc_tlb_invalidation layer Matthew Brost
2024-07-06  0:02 ` [PATCH 08/11] drm/xe: Add multi-client support for GT TLB invalidations Matthew Brost
2024-07-06  0:02 ` [PATCH 09/11] drm/xe: Add GT TLB invalidation coalescing Matthew Brost
2024-07-06  0:02 ` [PATCH 10/11] drm/xe: Add GT TLB coalesce tracepoints Matthew Brost
2024-07-06  0:02 ` Matthew Brost [this message]
2024-07-06  0:07 ` ✓ CI.Patch_applied: success for Proper GT TLB invalidation layering and new coalescing feature Patchwork
2024-07-06  0:07 ` ✗ CI.checkpatch: warning " Patchwork
2024-07-06  0:08 ` ✓ CI.KUnit: success " Patchwork
2024-07-06  0:20 ` ✓ CI.Build: " Patchwork
2024-07-06  0:22 ` ✗ CI.Hooks: failure " Patchwork
2024-07-06  0:24 ` ✓ CI.checksparse: success " Patchwork
2024-07-06  0:53 ` ✗ CI.BAT: failure " Patchwork
2024-07-06  1:41 ` ✗ CI.FULL: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240706000252.702044-12-matthew.brost@intel.com \
    --to=matthew.brost@intel.com \
    --cc=farah.kassabri@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=michal.wajdeczko@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox