From 9f3e77cf204ebb5755e092136c880a6c2d942568 Mon Sep 17 00:00:00 2001 From: Matt Roper Date: Thu, 5 Mar 2026 14:59:27 -0800 Subject: [PATCH] drm/xe: Add for_each_gt_with_type() iterator There are a couple places in the driver today that have GT loops that only need to operate on a specific type of GT. E.g., for_each_gt(...) { if (xe_gt_is_media_type(gt)) continue; ... } Some upcoming development is expected to utilize this pattern a bit more widely, so add a dedicated iterator that allows looping over specific GT type(s). Note that this iterator uses a mask for the "type" parameter rather than a direct value match. That's probably a bit overkill for now given that there are only two possible types of GTs, but if additional types of GTs ever show up in the future, this approach will fit more naturally and allow cases where we might want to loop over a subset of the possible types, or specifically mask off one single type. Reviewed-by: Rodrigo Vivi Link: https://patch.msgid.link/20260305-gt-type-loops-v1-1-aa42e9fc3f06@intel.com Signed-off-by: Matt Roper --- drivers/gpu/drm/xe/xe_device.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/xe/xe_device.h b/drivers/gpu/drm/xe/xe_device.h index 39464650533b..c4d267002661 100644 --- a/drivers/gpu/drm/xe/xe_device.h +++ b/drivers/gpu/drm/xe/xe_device.h @@ -131,6 +131,10 @@ static inline bool xe_device_uc_enabled(struct xe_device *xe) for ((id__) = 0; (id__) < (xe__)->info.tile_count * (xe__)->info.max_gt_per_tile; (id__)++) \ for_each_if((gt__) = xe_device_get_gt((xe__), (id__))) +#define for_each_gt_with_type(gt__, xe__, id__, typemask__) \ + for_each_gt((gt__), (xe__), (id__)) \ + for_each_if((typemask__) & BIT((gt__)->info.type)) + #define for_each_gt_on_tile(gt__, tile__, id__) \ for_each_gt((gt__), (tile__)->xe, (id__)) \ for_each_if((gt__)->tile == (tile__))