Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Brost <matthew.brost@intel.com>
To: Andrzej Hajda <andrzej.hajda@intel.com>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>,
	<intel-xe@lists.freedesktop.org>,
	Maciej Patelczyk <maciej.patelczyk@intel.com>
Subject: Re: [PATCH] fixup! drm/xe/eudebug: implement userptr_vma access
Date: Wed, 31 Jul 2024 17:51:29 +0000	[thread overview]
Message-ID: <Zqp5oYGygI97UglY@DUT025-TGLU> (raw)
In-Reply-To: <20240731111112.2702343-1-andrzej.hajda@intel.com>

On Wed, Jul 31, 2024 at 01:11:12PM +0200, Andrzej Hajda wrote:
> This fixup pulls call to xe_vma_userptr_pin_pages out of
> vm->userptr.notifier_lock.
> 
> Signed-off-by: Andrzej Hajda <andrzej.hajda@intel.com>
> ---
> Hi Matthew,
> 
> I hope this fixup should answer your concerns.
> It was tested on LNL with lockdep turned on and with your
> two patches mentioned earlier.
> 
> Posted in form of fixup to underline the difference,
> let me know if you insist on full patch.
> 

I think you change will work but I think this can be written cleaner and
also in a way in which the EU debug layer doesn't have to call into mmu
notifier functions (eventually we want to move all notifier interaction
to a DRM layer too).

How about:

retry:
	down_read(&vm->userptr.notifier_lock)

	/* re-pin if necessary */
	if (xe_vma_userptr_check_repin(uvma)) {
		up_read(&vm->userptr.notifier_lock)
		
		spin_lock(&vm->userptr.invalidated_lock);
		list_del_init(&uvma->userptr.invalidate_link);
		spin_unlock(&vm->userptr.invalidated_lock);

		ret = xe_vma_userptr_pin_pages(uvma);
		if (ret)
			return err;

		goto retry;
	}

	/* Do copy */

Also while you are here, maybe move the implementation for this function
in xe_vm.c as that seems to be a better place for this as this all
userptr specific code.

Matt

> Regards
> Andrzej
> ---
>  drivers/gpu/drm/xe/xe_eudebug.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_eudebug.c b/drivers/gpu/drm/xe/xe_eudebug.c
> index 472d9314505a..80d6f886969a 100644
> --- a/drivers/gpu/drm/xe/xe_eudebug.c
> +++ b/drivers/gpu/drm/xe/xe_eudebug.c
> @@ -3343,6 +3343,7 @@ static int xe_eudebug_uvma_access(struct xe_userptr_vma *uvma, u64 offset,
>  	struct xe_res_cursor cur = {};
>  	int cur_len, ret = 0;
>  
> +lock_notifier:
>  	/* lock notifier in non-invalidation state */
>  	for (unsigned long nseq = uvma->userptr.notifier_seq; true;
>  	     nseq = mmu_interval_read_begin(&uvma->userptr.notifier)) {
> @@ -3358,9 +3359,11 @@ static int xe_eudebug_uvma_access(struct xe_userptr_vma *uvma, u64 offset,
>  		list_del_init(&uvma->userptr.invalidate_link);
>  		spin_unlock(&vm->userptr.invalidated_lock);
>  
> +		up_read(&vm->userptr.notifier_lock);
>  		ret = xe_vma_userptr_pin_pages(uvma);
>  		if (ret)
> -			goto out_unlock_notifier;
> +			return ret;
> +		goto lock_notifier;
>  	}
>  
>  	if (!up->sg) {
> -- 
> 2.34.1
> 

  reply	other threads:[~2024-07-31 17:52 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-26 14:07 [PATCH 00/21] GPU debug support (eudebug) Mika Kuoppala
2024-07-26 14:07 ` [PATCH 01/21] drm/xe: Export xe_hw_engine's mmio accessors Mika Kuoppala
2024-07-27  5:45   ` Matthew Brost
2024-08-08 11:04   ` Andi Shyti
2024-07-26 14:07 ` [PATCH 02/21] drm/xe: Move and export xe_hw_engine lookup Mika Kuoppala
2024-07-27  5:49   ` Matthew Brost
2024-08-08 11:08   ` Andi Shyti
2024-07-26 14:08 ` [PATCH 03/21] drm/xe/eudebug: Introduce eudebug support Mika Kuoppala
2024-07-26 19:20   ` Matthew Brost
2024-07-30 14:12     ` Mika Kuoppala
2024-07-31  1:18       ` Matthew Brost
2024-08-07  9:34   ` Zbigniew Kempczyński
2024-08-21 11:37     ` Mika Kuoppala
2024-08-12 12:02   ` Zbigniew Kempczyński
2024-08-21 11:38     ` Mika Kuoppala
2024-07-26 14:08 ` [PATCH 04/21] kernel: export ptrace_may_access Mika Kuoppala
2024-07-29 18:56   ` Lucas De Marchi
2024-08-08 11:18   ` Andi Shyti
2024-08-21 11:46     ` Mika Kuoppala
2024-07-26 14:08 ` [PATCH 05/21] drm/xe/eudebug: Use ptrace_may_access for xe_eudebug_attach Mika Kuoppala
2024-07-29 19:00   ` Lucas De Marchi
2024-07-26 14:08 ` [PATCH 06/21] drm/xe/eudebug: Introduce discovery for resources Mika Kuoppala
2024-07-26 14:08 ` [PATCH 07/21] drm/xe/eudebug: Introduce exec_queue events Mika Kuoppala
2024-07-26 14:08 ` [PATCH 08/21] drm/xe/eudebug: hw enablement for eudebug Mika Kuoppala
2024-07-29 19:05   ` Lucas De Marchi
2024-07-29 19:16     ` Lucas De Marchi
2024-07-30  9:01     ` Grzegorzek, Dominik
2024-07-30 13:56       ` Lucas De Marchi
2024-07-26 14:08 ` [PATCH 09/21] drm/xe: Add EUDEBUG_ENABLE exec queue property Mika Kuoppala
2024-07-26 18:35   ` Matthew Brost
2024-07-27  0:54   ` Matthew Brost
2024-07-26 14:08 ` [PATCH 10/21] drm/xe/eudebug: Introduce per device attention scan worker Mika Kuoppala
2024-07-27  5:08   ` Matthew Brost
2024-07-29 10:10     ` Grzegorzek, Dominik
2024-07-31  1:25       ` Matthew Brost
2024-07-27  5:39   ` Matthew Brost
2024-07-26 14:08 ` [PATCH 11/21] drm/xe/eudebug: Introduce EU control interface Mika Kuoppala
2024-07-26 14:08 ` [PATCH 12/21] drm/xe/eudebug: Add vm bind and vm bind ops Mika Kuoppala
2024-07-26 14:08 ` [PATCH 13/21] drm/xe/eudebug: Add UFENCE events with acks Mika Kuoppala
2024-07-27  0:40   ` Matthew Brost
2024-07-30 14:05     ` Mika Kuoppala
2024-07-31  1:33       ` Matthew Brost
2024-07-26 14:08 ` [PATCH 14/21] drm/xe/eudebug: vm open/pread/pwrite Mika Kuoppala
2024-07-26 18:59   ` Matthew Brost
2024-07-26 14:08 ` [PATCH 15/21] drm/xe/eudebug: implement userptr_vma access Mika Kuoppala
2024-07-26 18:46   ` Matthew Brost
2024-07-26 18:50     ` Matthew Brost
2024-07-27  1:45       ` Matthew Brost
2024-07-31 11:11         ` [PATCH] fixup! " Andrzej Hajda
2024-07-31 17:51           ` Matthew Brost [this message]
2024-08-05 16:54             ` [PATCH v2] " Andrzej Hajda
2024-08-05 19:20               ` Cavitt, Jonathan
2024-08-26 14:40             ` [PATCH v2.5] " Andrzej Hajda
2024-08-26 16:45               ` Andrzej Hajda
2024-08-26 17:02               ` Matthew Brost
2024-08-27  8:41                 ` [PATCH v3] " Andrzej Hajda
2024-07-26 14:08 ` [PATCH 16/21] drm/xe: Debug metadata create/destroy ioctls Mika Kuoppala
2024-07-26 14:08 ` [PATCH 17/21] drm/xe: Attach debug metadata to vma Mika Kuoppala
2024-07-26 21:25   ` Matthew Brost
2024-07-26 14:08 ` [PATCH 18/21] drm/xe/eudebug: Add debug metadata support for xe_eudebug Mika Kuoppala
2024-07-26 14:08 ` [PATCH 19/21] drm/xe/eudebug: Implement vm_bind_op discovery Mika Kuoppala
2024-07-27  4:39   ` Matthew Brost
2024-07-26 14:08 ` [PATCH 20/21] drm/xe/eudebug: Dynamically toggle debugger functionality Mika Kuoppala
2024-07-28  4:50   ` Matthew Brost
2024-07-30 15:01     ` Manszewski, Christoph
2024-07-31 18:03       ` Matthew Brost
2024-08-07 10:09     ` Manszewski, Christoph
2024-07-26 14:08 ` [PATCH 21/21] drm/xe/eudebug_test: Introduce xe_eudebug wa kunit test Mika Kuoppala
2024-07-26 14:32 ` ✓ CI.Patch_applied: success for GPU debug support (eudebug) Patchwork
2024-07-26 14:33 ` ✗ CI.checkpatch: warning " Patchwork
2024-07-26 14:34 ` ✓ CI.KUnit: success " Patchwork
2024-07-26 14:46 ` ✓ CI.Build: " Patchwork
2024-07-26 14:48 ` ✗ CI.Hooks: failure " Patchwork
2024-07-26 14:49 ` ✓ CI.checksparse: success " Patchwork
2024-07-26 15:10 ` ✓ CI.BAT: " Patchwork
2024-07-27  2:37 ` ✓ CI.FULL: " Patchwork
2024-07-27  5:23 ` [PATCH 00/21] " Matthew Brost
2024-07-29  8:27   ` Gwan-gyeong Mun

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=Zqp5oYGygI97UglY@DUT025-TGLU \
    --to=matthew.brost@intel.com \
    --cc=andrzej.hajda@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=maciej.patelczyk@intel.com \
    --cc=mika.kuoppala@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox