[Intel-gfx] [PATCH 3/7] drm/i915: Implement for_each_sgt_daddr_next
Zeng, Oak
oak.zeng at intel.com
Wed Sep 13 16:45:16 UTC 2023
Thanks,
Oak
> -----Original Message-----
> From: Das, Nirmoy <nirmoy.das at intel.com>
> Sent: Wednesday, September 13, 2023 9:10 AM
> To: intel-gfx at lists.freedesktop.org
> Cc: Zeng, Oak <oak.zeng at intel.com>; chris.p.wilson at linux.intel.com; Piorkowski,
> Piotr <piotr.piorkowski at intel.com>; Shyti, Andi <andi.shyti at intel.com>; Mun,
> Gwan-gyeong <gwan-gyeong.mun at intel.com>; Roper, Matthew D
> <matthew.d.roper at intel.com>; Das, Nirmoy <nirmoy.das at intel.com>
> Subject: [PATCH 3/7] drm/i915: Implement for_each_sgt_daddr_next
>
> Implement a way to iterate over sgt with pre-initialized
> sgt_iter state.
>
> Signed-off-by: Nirmoy Das <nirmoy.das at intel.com>
> ---
> drivers/gpu/drm/i915/gt/intel_gtt.h | 3 +++
> drivers/gpu/drm/i915/i915_scatterlist.h | 10 ++++++++++
> 2 files changed, 13 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/gt/intel_gtt.h
> b/drivers/gpu/drm/i915/gt/intel_gtt.h
> index 346ec8ec2edd..41e530d0a4e9 100644
> --- a/drivers/gpu/drm/i915/gt/intel_gtt.h
> +++ b/drivers/gpu/drm/i915/gt/intel_gtt.h
> @@ -171,6 +171,9 @@ struct intel_gt;
> #define for_each_sgt_daddr(__dp, __iter, __sgt) \
> __for_each_sgt_daddr(__dp, __iter, __sgt, I915_GTT_PAGE_SIZE)
>
> +#define for_each_sgt_daddr_next(__dp, __iter) \
The naming of this macro... I feel _next is not a good name, but I couldn't find a better name either...
The codes look good to me, so it is Reviewed-by: Oak Zeng <oak.zeng at intel.com>
Oak
> + __for_each_daddr_next(__dp, __iter, I915_GTT_PAGE_SIZE)
> +
> struct i915_page_table {
> struct drm_i915_gem_object *base;
> union {
> diff --git a/drivers/gpu/drm/i915/i915_scatterlist.h
> b/drivers/gpu/drm/i915/i915_scatterlist.h
> index 5a10c1a31183..6cf8a298849f 100644
> --- a/drivers/gpu/drm/i915/i915_scatterlist.h
> +++ b/drivers/gpu/drm/i915/i915_scatterlist.h
> @@ -91,6 +91,16 @@ static inline struct scatterlist *__sg_next(struct scatterlist
> *sg)
> ((__dp) = (__iter).dma + (__iter).curr), (__iter).sgp; \
> (((__iter).curr += (__step)) >= (__iter).max) ? \
> (__iter) = __sgt_iter(__sg_next((__iter).sgp), true), 0 : 0)
> +/**
> + * __for_each_daddr_next - iterates over the device addresses with pre-
> initialized iterator.
> + * @__dp: Device address (output)
> + * @__iter: 'struct sgt_iter' (iterator state, external)
> + * @__step: step size
> + */
> +#define __for_each_daddr_next(__dp, __iter, __step) \
> + for (; ((__dp) = (__iter).dma + (__iter).curr), (__iter).sgp; \
> + (((__iter).curr += (__step)) >= (__iter).max) ? \
> + (__iter) = __sgt_iter(__sg_next((__iter).sgp), true), 0 : 0)
>
> /**
> * for_each_sgt_page - iterate over the pages of the given sg_table
> --
> 2.41.0
More information about the Intel-gfx
mailing list