From c6b3c8151e458e0f457f5ce77692c56085271670 Mon Sep 17 00:00:00 2001 From: jsg Date: Mon, 12 Aug 2024 23:42:15 +0000 Subject: [PATCH] drm/i915: Implement for_each_sgt_daddr_next From Nirmoy Das 0e514878486053363f8b2a806525fe67ae692827 in mainline linux --- sys/dev/pci/drm/i915/gt/intel_gtt.h | 3 +++ sys/dev/pci/drm/i915/i915_scatterlist.h | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/sys/dev/pci/drm/i915/gt/intel_gtt.h b/sys/dev/pci/drm/i915/gt/intel_gtt.h index 9ace406f7a4..b8e5a5fd5af 100644 --- a/sys/dev/pci/drm/i915/gt/intel_gtt.h +++ b/sys/dev/pci/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) \ + __for_each_daddr_next(__dp, __iter, I915_GTT_PAGE_SIZE) + struct i915_page_table { struct drm_i915_gem_object *base; union { diff --git a/sys/dev/pci/drm/i915/i915_scatterlist.h b/sys/dev/pci/drm/i915/i915_scatterlist.h index c552cc2a9ef..2331edb57b8 100644 --- a/sys/dev/pci/drm/i915/i915_scatterlist.h +++ b/sys/dev/pci/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.20.1