From: Matthew Brost <matthew.brost@intel.com>
To: Stuart Summers <stuart.summers@intel.com>
Cc: <lucas.demarchi@intel.com>, <nirmoy.das@linux.intel.com>,
<intel-xe@lists.freedesktop.org>,
Nirmoy Das <nirmoy.das@intel.com>
Subject: Re: [PATCH 2/2] drm/xe: Do not use CT lock in TLB code
Date: Wed, 16 Apr 2025 12:22:31 -0700 [thread overview]
Message-ID: <aAADdyOG0hXPWMgr@lstrano-desk.jf.intel.com> (raw)
In-Reply-To: <20250416183032.70948-2-stuart.summers@intel.com>
On Wed, Apr 16, 2025 at 06:30:32PM +0000, Stuart Summers wrote:
> From: Nirmoy Das <nirmoy.das@intel.com>
>
> Stop abusing CT lock for GT TLB invalidation fence seqno, add a
> dedicated lock.
>
> Signed-off-by: Nirmoy Das <nirmoy.das@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
> ---
> drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c | 17 ++++++++++-------
> drivers/gpu/drm/xe/xe_gt_types.h | 13 ++++++++++---
> 2 files changed, 20 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c b/drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c
> index 031c4d43f36b..c2bb53362d74 100644
> --- a/drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c
> +++ b/drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c
> @@ -3,6 +3,8 @@
> * Copyright © 2023 Intel Corporation
> */
>
> +#include <drm/drm_managed.h>
> +
> #include "xe_gt_tlb_invalidation.h"
>
> #include "abi/guc_actions_abi.h"
> @@ -123,7 +125,8 @@ int xe_gt_tlb_invalidation_init_early(struct xe_gt *gt)
> INIT_DELAYED_WORK(>->tlb_invalidation.fence_tdr,
> xe_gt_tlb_fence_timeout);
>
> - return 0;
> + return drmm_mutex_init(>_to_xe(gt)->drm,
> + >->tlb_invalidation.seqno_lock);
> }
>
> /**
> @@ -142,7 +145,7 @@ void xe_gt_tlb_invalidation_reset(struct xe_gt *gt)
> * appear.
> */
>
> - mutex_lock(>->uc.guc.ct.lock);
> + mutex_lock(>->tlb_invalidation.seqno_lock);
> spin_lock_irq(>->tlb_invalidation.pending_lock);
> cancel_delayed_work(>->tlb_invalidation.fence_tdr);
> /*
> @@ -162,7 +165,7 @@ void xe_gt_tlb_invalidation_reset(struct xe_gt *gt)
> >->tlb_invalidation.pending_fences, link)
> invalidation_fence_signal(gt_to_xe(gt), fence);
> spin_unlock_irq(>->tlb_invalidation.pending_lock);
> - mutex_unlock(>->uc.guc.ct.lock);
> + mutex_unlock(>->tlb_invalidation.seqno_lock);
> }
>
> static bool tlb_invalidation_seqno_past(struct xe_gt *gt, int seqno)
> @@ -195,13 +198,13 @@ static int send_tlb_invalidation(struct xe_guc *guc,
> * need to be updated.
> */
>
> - mutex_lock(&guc->ct.lock);
> + mutex_lock(>->tlb_invalidation.seqno_lock);
> seqno = gt->tlb_invalidation.seqno;
> fence->seqno = seqno;
> trace_xe_gt_tlb_invalidation_fence_send(xe, fence);
> action[1] = seqno;
> - ret = xe_guc_ct_send_locked(&guc->ct, action, len,
> - G2H_LEN_DW_TLB_INVALIDATE, 1);
> + ret = xe_guc_ct_send(&guc->ct, action, len,
> + G2H_LEN_DW_TLB_INVALIDATE, 1);
> if (!ret) {
> spin_lock_irq(>->tlb_invalidation.pending_lock);
> /*
> @@ -232,7 +235,7 @@ static int send_tlb_invalidation(struct xe_guc *guc,
> if (!gt->tlb_invalidation.seqno)
> gt->tlb_invalidation.seqno = 1;
> }
> - mutex_unlock(&guc->ct.lock);
> + mutex_unlock(>->tlb_invalidation.seqno_lock);
> xe_gt_stats_incr(gt, XE_GT_STATS_ID_TLB_INVAL, 1);
>
> return ret;
> diff --git a/drivers/gpu/drm/xe/xe_gt_types.h b/drivers/gpu/drm/xe/xe_gt_types.h
> index be81687cbe2b..4736a608a881 100644
> --- a/drivers/gpu/drm/xe/xe_gt_types.h
> +++ b/drivers/gpu/drm/xe/xe_gt_types.h
> @@ -187,17 +187,24 @@ struct xe_gt {
>
> /** @tlb_invalidation: TLB invalidation state */
> struct {
> - /** @tlb_invalidation.seqno: TLB invalidation seqno, protected by CT lock */
> + /** @tlb_invalidation.seqno_lock: TLB invalidation seqno lock */
> + struct mutex seqno_lock;
> + /**
> + * @tlb_invalidation.seqno: TLB invalidation seqno, protected
> + * by @tlb_invalidation.seqno_lock
> + */
> #define TLB_INVALIDATION_SEQNO_MAX 0x100000
> int seqno;
> /**
> * @tlb_invalidation.seqno_recv: last received TLB invalidation seqno,
> - * protected by CT lock
> + * protected by @tlb_invalidation.seqno_lock (send) and
> + * @tlb_invalidation.pending_lock (send, recv)
> */
> int seqno_recv;
> /**
> * @tlb_invalidation.pending_fences: list of pending fences waiting TLB
> - * invaliations, protected by CT lock
> + * invaliations, protected by @tlb_invalidation.seqno_lock
> + * (send) and @tlb_invalidation.pending_lock (send, recv)
> */
> struct list_head pending_fences;
> /**
> --
> 2.34.1
>
next prev parent reply other threads:[~2025-04-16 19:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-16 18:30 [PATCH 1/2] drm/xe: s/tlb_invalidation.lock/tlb_invalidation.fence_lock Stuart Summers
2025-04-16 18:30 ` [PATCH 2/2] drm/xe: Do not use CT lock in TLB code Stuart Summers
2025-04-16 19:22 ` Matthew Brost [this message]
2025-04-16 19:24 ` Summers, Stuart
2025-04-16 19:23 ` [PATCH 1/2] drm/xe: s/tlb_invalidation.lock/tlb_invalidation.fence_lock Summers, Stuart
2025-04-17 0:35 ` Matthew Brost
2025-04-16 20:54 ` ✓ Xe.CI.BAT: success for series starting with [1/2] " Patchwork
2025-04-17 7:31 ` ✗ Xe.CI.Full: failure " Patchwork
2025-04-17 22:39 ` Summers, Stuart
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=aAADdyOG0hXPWMgr@lstrano-desk.jf.intel.com \
--to=matthew.brost@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=lucas.demarchi@intel.com \
--cc=nirmoy.das@intel.com \
--cc=nirmoy.das@linux.intel.com \
--cc=stuart.summers@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.