All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Brost <matthew.brost@intel.com>
To: <intel-xe@lists.freedesktop.org>
Cc: dri-devel@lists.freedesktop.org,
	"Matthew Brost" <matthew.brost@intel.com>,
	"Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Subject: [PATCH v3 4/4] drm/xe: Use get_user / put_user with memory barriers for ufence
Date: Fri,  1 Mar 2024 14:49:19 -0800	[thread overview]
Message-ID: <20240301224919.271153-5-matthew.brost@intel.com> (raw)
In-Reply-To: <20240301224919.271153-1-matthew.brost@intel.com>

Better aligns with atomic semantics than copy to/from user.

Suggested-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
---
 drivers/gpu/drm/xe/xe_sync.c            | 6 +++---
 drivers/gpu/drm/xe/xe_wait_user_fence.c | 4 +++-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_sync.c b/drivers/gpu/drm/xe/xe_sync.c
index bf348d50a0b6..d6d2c8c19f71 100644
--- a/drivers/gpu/drm/xe/xe_sync.c
+++ b/drivers/gpu/drm/xe/xe_sync.c
@@ -116,9 +116,9 @@ static void user_fence_worker(struct work_struct *w)
 			}
 		}
 		if (!ufence->use_page) {
-			if (copy_to_user(ufence->addr, &ufence->value,
-					 sizeof(ufence->value)))
-				drm_warn(&ufence->xe->drm, "copy_to_user failed\n");
+			if (put_user(ufence->value, ufence->addr))
+				drm_warn(&ufence->xe->drm, "put_user failed\n");
+			smp_mb();
 		}
 		kthread_unuse_mm(mm);
 		mmput(mm);
diff --git a/drivers/gpu/drm/xe/xe_wait_user_fence.c b/drivers/gpu/drm/xe/xe_wait_user_fence.c
index f69721339201..af5b9a634c21 100644
--- a/drivers/gpu/drm/xe/xe_wait_user_fence.c
+++ b/drivers/gpu/drm/xe/xe_wait_user_fence.c
@@ -17,11 +17,13 @@
 
 static int do_compare(u64 addr, u64 value, u64 mask, u16 op)
 {
+	u64 __user *ptr = u64_to_user_ptr(addr);
 	u64 rvalue;
 	int err;
 	bool passed;
 
-	err = copy_from_user(&rvalue, u64_to_user_ptr(addr), sizeof(rvalue));
+	smp_mb();
+	err = get_user(rvalue, ptr);
 	if (err)
 		return -EFAULT;
 
-- 
2.34.1


  parent reply	other threads:[~2024-03-01 22:49 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-01 22:49 [PATCH v3 0/4] xe_sync and ufence rework Matthew Brost
2024-03-01 22:49 ` [PATCH v3 1/4] drm/xe: Remove used xe_sync_entry_wait Matthew Brost
2024-03-01 22:49 ` [PATCH v3 2/4] drm/xe: Validate user fence during creation Matthew Brost
2024-03-01 22:49 ` [PATCH v3 3/4] drm/xe: Get page on user fence creation Matthew Brost
2024-03-01 22:49 ` Matthew Brost [this message]
2024-03-01 22:53 ` ✓ CI.Patch_applied: success for xe_sync and ufence rework (rev3) Patchwork
2024-03-01 22:53 ` ✗ CI.checkpatch: warning " Patchwork
2024-03-01 22:54 ` ✓ CI.KUnit: success " Patchwork
2024-03-01 23:05 ` ✓ CI.Build: " Patchwork
2024-03-01 23:06 ` ✓ CI.Hooks: " Patchwork
2024-03-01 23:07 ` ✓ CI.checksparse: " Patchwork
2024-03-01 23:26 ` ✓ CI.BAT: " 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=20240301224919.271153-5-matthew.brost@intel.com \
    --to=matthew.brost@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=thomas.hellstrom@linux.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 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.