[PATCH] drm/xe: add system memory page iterator support to xe_res_cursor
Cavitt, Jonathan
jonathan.cavitt at intel.com
Wed Oct 9 15:07:08 UTC 2024
-----Original Message-----
From: Intel-xe <intel-xe-bounces at lists.freedesktop.org> On Behalf Of Hajda
Sent: Wednesday, October 9, 2024 6:32 AM
To: intel-xe at lists.freedesktop.org
Cc: Mika Kuoppala <mika.kuoppala at linux.intel.com>; Brost, Matthew <matthew.brost at intel.com>; Hajda, Andrzej <andrzej.hajda at intel.com>
Subject: [PATCH] drm/xe: add system memory page iterator support to xe_res_cursor
>
> Currently xe_res_cursor allows iteration only over DMA side of scatter
> gatter tables. Adding possibility to iterate over pages allows
> to use the cursor in more contexts.
>
> Signed-off-by: Andrzej Hajda <andrzej.hajda at intel.com>
s/gatter/gather
Though perhaps it would be better to call the scatter/gather tables by
their abbreviated form: the sg tables.
Or just call them scatterlists, as that's the struct name.
Also, one or both of:
- s/allows/allows us
- s/to use the/the use of
Reviewed-by: Jonathan Cavitt <jonathan.cavitt at intel.com>
-Jonathan Cavitt
> ---
> Hi all,
>
> This patch is required to proper implementation of userptr_vma access
> in configurations with iommu turned on[1]. Required by upcoming eudebug
> feature.
>
> [1]: https://lore.kernel.org/intel-xe/20241001144306.1991001-13-mika.kuoppala@linux.intel.com/
>
> Regards
> Andrzej
> ---
> drivers/gpu/drm/xe/xe_res_cursor.h | 51 +++++++++++++++++++++++++++++---------
> 1 file changed, 39 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_res_cursor.h b/drivers/gpu/drm/xe/xe_res_cursor.h
> index dca374b6521c..c1f39a680ae0 100644
> --- a/drivers/gpu/drm/xe/xe_res_cursor.h
> +++ b/drivers/gpu/drm/xe/xe_res_cursor.h
> @@ -129,18 +129,35 @@ static inline void __xe_res_sg_next(struct xe_res_cursor *cur)
> {
> struct scatterlist *sgl = cur->sgl;
> u64 start = cur->start;
> + unsigned int len;
>
> - while (start >= sg_dma_len(sgl)) {
> - start -= sg_dma_len(sgl);
> + while (true) {
> + len = (cur->mem_type == XE_PL_SYSTEM) ? sgl->length : sg_dma_len(sgl);
> + if (start < len)
> + break;
> + start -= len;
> sgl = sg_next(sgl);
> XE_WARN_ON(!sgl);
> }
> -
> cur->start = start;
> - cur->size = sg_dma_len(sgl) - start;
> + cur->size = len - start;
> cur->sgl = sgl;
> }
>
> +static inline void __xe_res_first_sg(const struct sg_table *sg,
> + u64 start, u64 size,
> + struct xe_res_cursor *cur, u32 mem_type)
> +{
> + XE_WARN_ON(!sg);
> + cur->node = NULL;
> + cur->start = start;
> + cur->remaining = size;
> + cur->size = 0;
> + cur->sgl = sg->sgl;
> + cur->mem_type = mem_type;
> + __xe_res_sg_next(cur);
> +}
> +
> /**
> * xe_res_first_sg - initialize a xe_res_cursor with a scatter gather table
> *
> @@ -155,14 +172,24 @@ static inline void xe_res_first_sg(const struct sg_table *sg,
> u64 start, u64 size,
> struct xe_res_cursor *cur)
> {
> - XE_WARN_ON(!sg);
> - cur->node = NULL;
> - cur->start = start;
> - cur->remaining = size;
> - cur->size = 0;
> - cur->sgl = sg->sgl;
> - cur->mem_type = XE_PL_TT;
> - __xe_res_sg_next(cur);
> + __xe_res_first_sg(sg, start, size, cur, XE_PL_TT);
> +}
> +
> +/**
> + * xe_res_first_sg_system - initialize a xe_res_cursor for iterate system memory pages
> + *
> + * @sg: scatter gather table to walk
> + * @start: Start of the range
> + * @size: Size of the range
> + * @cur: cursor object to initialize
> + *
> + * Start walking over the range of allocations between @start and @size
> + */
> +static inline void xe_res_first_sg_system(const struct sg_table *sg,
> + u64 start, u64 size,
> + struct xe_res_cursor *cur)
> +{
> + __xe_res_first_sg(sg, start, size, cur, XE_PL_SYSTEM);
> }
>
> /**
>
> ---
> base-commit: f1561e6c62b5b5c3fe0276f2fbe7325e0d7c262d
> change-id: 20241009-xe_res_cursor_add_page_iterator-d29d73c3eb99
>
> Best regards,
> --
> Andrzej Hajda <andrzej.hajda at intel.com>
>
>
More information about the Intel-xe
mailing list