From 305ebcedc36e98f3118ac27a5bbde0ce7cd71a74 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 21 Feb 2018 14:13:16 +0000 Subject: Iterate over physical engines We current have a single for_each_engine() iterator which we use to generate both a set of uABI engines and a set of physical engines. Determining what uABI ring-id corresponds to an actual HW engine is tricky, so pull that out to a library function and introduce for_each_physical_engine() for cases where we want to issue requests once on each HW ring (avoiding aliasing issues). v2: Remember can_store_dword for gem_sync v3: Find more open-coded for_each_physical Signed-off-by: Chris Wilson Cc: Tvrtko Ursulin Reviewed-by: Tvrtko Ursulin --- lib/igt_gt.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'lib/igt_gt.c') diff --git a/lib/igt_gt.c b/lib/igt_gt.c index f70fcb92..e630550b 100644 --- a/lib/igt_gt.c +++ b/lib/igt_gt.c @@ -660,3 +660,26 @@ bool gem_has_engine(int gem_fd, gem_class_instance_to_eb_flags(gem_fd, class, instance)); } + +bool gem_ring_is_physical_engine(int fd, unsigned ring) +{ + if (ring == I915_EXEC_DEFAULT) + return false; + + /* BSD uses an extra flag to chose between aliasing modes */ + if ((ring & 63) == I915_EXEC_BSD) { + bool explicit_bsd = ring & (3 << 13); + bool has_bsd2 = gem_has_bsd2(fd); + return explicit_bsd ? has_bsd2 : !has_bsd2; + } + + return true; +} + +bool gem_ring_has_physical_engine(int fd, unsigned ring) +{ + if (!gem_ring_is_physical_engine(fd, ring)) + return false; + + return gem_has_ring(fd, ring); +} -- cgit v1.2.3