All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: intel-xe@lists.freedesktop.org
Subject: [Intel-xe] [PATCH 1/5] drm/xe: Kill small race with userptr invalidation
Date: Fri, 26 May 2023 14:10:57 +0200	[thread overview]
Message-ID: <20230526121101.1619278-2-maarten.lankhorst@linux.intel.com> (raw)
In-Reply-To: <20230526121101.1619278-1-maarten.lankhorst@linux.intel.com>

Theoretically, we can hit a small race where we hit an invalidation
after taking the lock in read-mode. In this case, take it in write
mode instead.

I don't think this is really an issue, but more of a robustness thing.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/xe/xe_exec.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/xe/xe_exec.c b/drivers/gpu/drm/xe/xe_exec.c
index e44076ee2e11..187108c4be6d 100644
--- a/drivers/gpu/drm/xe/xe_exec.c
+++ b/drivers/gpu/drm/xe/xe_exec.c
@@ -256,6 +256,13 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
 		/* We don't allow execs while the VM is in error state */
 		err = down_read_interruptible(&vm->lock);
 		write_locked = false;
+
+		/* Userptr invalidation while we were still acquiring lock? */
+		if (!err && !xe_vm_no_dma_fences(vm) && xe_vm_userptr_check_repin(vm)) {
+			up_read(&vm->lock);
+			err = down_write_killable(&vm->lock);
+			write_locked = true;
+		}
 	}
 	if (err)
 		goto err_syncs;
-- 
2.34.1


  reply	other threads:[~2023-05-26 12:11 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-26 12:10 [Intel-xe] [PATCH 0/5] Robustness fixes with eviction and invalidation Maarten Lankhorst
2023-05-26 12:10 ` Maarten Lankhorst [this message]
2023-05-26 12:26   ` [Intel-xe] [PATCH 1/5] drm/xe: Kill small race with userptr invalidation Thomas Hellström
2023-05-26 12:10 ` [Intel-xe] [PATCH 2/5] drm/xe: Add debugfs files to evict everything Maarten Lankhorst
2023-05-26 13:02   ` Thomas Hellström
2023-05-29 13:35     ` Maarten Lankhorst
2023-05-30 14:41       ` Thomas Hellström
2023-05-30 14:54         ` Maarten Lankhorst
2023-05-26 12:10 ` [Intel-xe] [PATCH 3/5] drm/xe: Fix extobj dropping issue Maarten Lankhorst
2023-05-26 12:31   ` Thomas Hellström
2023-05-26 12:11 ` [Intel-xe] [PATCH 4/5] drm/xe: Prevent evicting for page tables Maarten Lankhorst
2023-05-26 12:35   ` Thomas Hellström
2023-05-29 13:44     ` Maarten Lankhorst
2023-05-29 15:02       ` Thomas Hellström
2023-05-29 15:11         ` Maarten Lankhorst
2023-05-29 15:13           ` Thomas Hellström
2023-05-29 15:23             ` Maarten Lankhorst
2023-05-30  8:45               ` Thomas Hellström
2023-05-30  8:50                 ` Maarten Lankhorst
2023-05-26 12:11 ` [Intel-xe] [PATCH 5/5] drm/xe: Return the correct error when dma_resv_wait_timeout fails Maarten Lankhorst
2023-05-26 12:40   ` Thomas Hellström
2023-05-26 19:15   ` Souza, Jose
2023-05-27  5:17     ` Christopher Snowhill
2023-05-29 15:21       ` Maarten Lankhorst
2023-05-26 12:13 ` [Intel-xe] ✓ CI.Patch_applied: success for Robustness fixes with eviction and invalidation Patchwork
2023-05-26 12:15 ` [Intel-xe] ✓ CI.KUnit: " Patchwork
2023-05-26 12:19 ` [Intel-xe] ✓ CI.Build: " Patchwork
2023-05-26 12:48 ` [Intel-xe] ○ CI.BAT: info " 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=20230526121101.1619278-2-maarten.lankhorst@linux.intel.com \
    --to=maarten.lankhorst@linux.intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.