[PATCH 5/8] drm/xe: Decouple TLB invalidations from GT

Summers, Stuart stuart.summers at intel.com
Thu Jul 31 17:05:20 UTC 2025


On Wed, 2025-07-30 at 20:45 +0000, stuartsummers wrote:
> From: Matthew Brost <matthew.brost at intel.com>
> 
> Decouple TLB invalidations from the GT by updating the TLB
> invalidation
> layer to accept a `struct xe_tlb_inval` instead of a `struct xe_gt`.
> Also, rename *gt_tlb* to *tlb*. The internals of the TLB invalidation
> code still operate on a GT, but this is now hidden from the rest of
> the
> driver.
> 
> Signed-off-by: Matthew Brost <matthew.brost at intel.com>
> Signed-off-by: Stuart Summers <stuart.summers at intel.com>
> ---
>  drivers/gpu/drm/xe/Makefile                   |   4 +-
>  drivers/gpu/drm/xe/xe_ggtt.c                  |   4 +-
>  drivers/gpu/drm/xe/xe_gt.c                    |   6 +-
>  drivers/gpu/drm/xe/xe_gt_tlb_inval.h          |  40 -----
>  drivers/gpu/drm/xe/xe_gt_tlb_inval_job.h      |  34 ----
>  drivers/gpu/drm/xe/xe_gt_types.h              |   2 +-
>  drivers/gpu/drm/xe/xe_guc_ct.c                |   2 +-
>  drivers/gpu/drm/xe/xe_lmtt.c                  |  12 +-
>  drivers/gpu/drm/xe/xe_migrate.h               |  10 +-
>  drivers/gpu/drm/xe/xe_pt.c                    |  63 ++++---
>  drivers/gpu/drm/xe/xe_svm.c                   |   1 -
>  .../xe/{xe_gt_tlb_inval.c => xe_tlb_inval.c}  | 143 ++++++++--------
>  drivers/gpu/drm/xe/xe_tlb_inval.h             |  41 +++++
>  ..._gt_tlb_inval_job.c => xe_tlb_inval_job.c} | 154 +++++++++-------
> --
>  drivers/gpu/drm/xe/xe_tlb_inval_job.h         |  34 ++++
>  ...tlb_inval_types.h => xe_tlb_inval_types.h} |  35 ++--
>  drivers/gpu/drm/xe/xe_trace.h                 |  24 +--
>  drivers/gpu/drm/xe/xe_vm.c                    |  26 +--
>  18 files changed, 331 insertions(+), 304 deletions(-)
>  delete mode 100644 drivers/gpu/drm/xe/xe_gt_tlb_inval.h
>  delete mode 100644 drivers/gpu/drm/xe/xe_gt_tlb_inval_job.h
>  rename drivers/gpu/drm/xe/{xe_gt_tlb_inval.c => xe_tlb_inval.c}
> (79%)
>  create mode 100644 drivers/gpu/drm/xe/xe_tlb_inval.h
>  rename drivers/gpu/drm/xe/{xe_gt_tlb_inval_job.c =>
> xe_tlb_inval_job.c} (51%)
>  create mode 100644 drivers/gpu/drm/xe/xe_tlb_inval_job.h
>  rename drivers/gpu/drm/xe/{xe_gt_tlb_inval_types.h =>
> xe_tlb_inval_types.h} (54%)
> 

<cut>

>  }
> diff --git a/drivers/gpu/drm/xe/xe_tlb_inval.h
> b/drivers/gpu/drm/xe/xe_tlb_inval.h
> new file mode 100644
> index 000000000000..7adee3f8c551
> --- /dev/null
> +++ b/drivers/gpu/drm/xe/xe_tlb_inval.h
> @@ -0,0 +1,41 @@
> +/* SPDX-License-Identifier: MIT */
> +/*
> + * Copyright © 2025 Intel Corporation
> + */
> +
> +#ifndef _XE_TLB_INVAL_H_
> +#define _XE_TLB_INVAL_H_
> +
> +#include <linux/types.h>
> +
> +#include "xe_tlb_inval_types.h"
> +
> +struct xe_gt;
> +struct xe_guc;
> +struct xe_vm;
> +struct xe_vma;

Looks like I missed a couple extra structs here... I'll remove xe_vma
here and drm_sched_job from xe_tlb_inval_job.h below in the next rev
(see below).

> +
> +int xe_gt_tlb_inval_init_early(struct xe_gt *gt);
> +
> +void xe_tlb_inval_reset(struct xe_tlb_inval *tlb_inval);
> +int xe_tlb_inval_ggtt(struct xe_tlb_inval *tlb_inval);
> +void xe_tlb_inval_vm(struct xe_tlb_inval *tlb_inval, struct xe_vm
> *vm);
> +int xe_tlb_inval_all(struct xe_tlb_inval *tlb_inval,
> +                    struct xe_tlb_inval_fence *fence);
> +int xe_tlb_inval_range(struct xe_tlb_inval *tlb_inval,
> +                      struct xe_tlb_inval_fence *fence,
> +                      u64 start, u64 end, u32 asid);
> +int xe_guc_tlb_inval_done_handler(struct xe_guc *guc, u32 *msg, u32
> len);
> +
> +void xe_tlb_inval_fence_init(struct xe_tlb_inval *tlb_inval,
> +                            struct xe_tlb_inval_fence *fence,
> +                            bool stack);
> +void xe_tlb_inval_fence_signal(struct xe_tlb_inval_fence *fence);
> +
> +static inline void
> +xe_tlb_inval_fence_wait(struct xe_tlb_inval_fence *fence)
> +{
> +       dma_fence_wait(&fence->base, false);
> +}
> +
> +#endif /* _XE_TLB_INVAL_ */
> diff --git a/drivers/gpu/drm/xe/xe_gt_tlb_inval_job.c
> b/drivers/gpu/drm/xe/xe_tlb_inval_job.c
> similarity index 51%
> rename from drivers/gpu/drm/xe/xe_gt_tlb_inval_job.c
> rename to drivers/gpu/drm/xe/xe_tlb_inval_job.c
> index 41e0ea92ea5a..492def04a559 100644
> --- a/drivers/gpu/drm/xe/xe_gt_tlb_inval_job.c
> +++ b/drivers/gpu/drm/xe/xe_tlb_inval_job.c
> @@ -3,21 +3,22 @@
>   * Copyright © 2025 Intel Corporation
>   */
>  

<cut>

>  {
>         if (!IS_ERR_OR_NULL(job))
> -               kref_put(&job->refcount,
> xe_gt_tlb_inval_job_destroy);
> +               kref_put(&job->refcount, xe_tlb_inval_job_destroy);
>  }
> diff --git a/drivers/gpu/drm/xe/xe_tlb_inval_job.h
> b/drivers/gpu/drm/xe/xe_tlb_inval_job.h
> new file mode 100644
> index 000000000000..32fb41599a19
> --- /dev/null
> +++ b/drivers/gpu/drm/xe/xe_tlb_inval_job.h
> @@ -0,0 +1,34 @@
> +/* SPDX-License-Identifier: MIT */
> +/*
> + * Copyright © 2025 Intel Corporation
> + */
> +
> +#ifndef _XE_TLB_INVAL_JOB_H_
> +#define _XE_TLB_INVAL_JOB_H_
> +
> +#include <linux/types.h>
> +
> +struct dma_fence;
> +struct drm_sched_job;

And here.

Otherwise the patch looks good to me. Would be nice to get another ack
since I'm making some minor changes here before merging..

Reviewed-by: Stuart Summers <stuart.summers at intel.com>

Thanks,
Stuart



More information about the Intel-xe mailing list