From: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 4/6] i915/gem_engine_topology: Add helpers for checking driver capabilities
Date: Fri, 11 Mar 2022 13:13:16 +0100 [thread overview]
Message-ID: <20220311121318.112757-5-zbigniew.kempczynski@intel.com> (raw)
In-Reply-To: <20220311121318.112757-1-zbigniew.kempczynski@intel.com>
From: Chris Wilson <chris.p.wilson@intel.com>
If driver is able to report capabilities we want to use them in easy way.
For example it can support blitter "block_copy" (XY_BLOCK_COPY_BLT
command) and reports it in sysfs. We add then capabilities helpers to
read these properties. Helpers allows checking does driver knows
capability (by checking sysfs "known_capabilities" file) and supports it
(by checking sysfs "capabilities" file). Dedicated helper was added to
verify "block_copy" capability.
Signed-off-by: Chris Wilson <chris.p.wilson@intel.com>
Signed-off-by: Apoorva Singh <apoorva1.singh@intel.com>
Cc: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Arjun Melkaveri <arjun.melkaveri@intel.com>
Reviewed-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
---
lib/i915/gem_engine_topology.c | 39 ++++++++++++++++++++++++++++++++++
lib/i915/gem_engine_topology.h | 5 +++++
2 files changed, 44 insertions(+)
diff --git a/lib/i915/gem_engine_topology.c b/lib/i915/gem_engine_topology.c
index bd12d0bc98..ca3333c252 100644
--- a/lib/i915/gem_engine_topology.c
+++ b/lib/i915/gem_engine_topology.c
@@ -534,6 +534,45 @@ void gem_engine_properties_restore(int fd, const struct gem_engine_properties *s
}
}
+static bool
+__gem_engine_has_capability(int i915, const char *engine,
+ const char *attr, const char *cap)
+{
+ char buf[4096] = {};
+ FILE *file;
+
+ file = __open_attr(igt_sysfs_open(i915), "r",
+ "engine", engine, attr, NULL);
+ if (!file)
+ return NULL;
+
+ fread(buf, 1, sizeof(buf) - 1, file);
+ fclose(file);
+
+ return strstr(buf, cap);
+}
+
+bool gem_engine_has_capability(int i915, const char *engine, const char *cap)
+{
+ return __gem_engine_has_capability(i915, engine, "capabilities", cap);
+}
+
+bool gem_engine_has_known_capability(int i915, const char *engine, const char *cap)
+{
+ return __gem_engine_has_capability(i915, engine, "known_capabilities", cap);
+}
+
+bool gem_engine_can_block_copy(int i915, const struct intel_execution_engine2 *engine)
+{
+ if (engine->class != I915_ENGINE_CLASS_COPY)
+ return false;
+
+ if (!gem_engine_has_known_capability(i915, engine->name, "block_copy"))
+ return intel_gen(intel_get_drm_devid(i915)) >= 12;
+
+ return gem_engine_has_capability(i915, engine->name, "block_copy");
+}
+
uint32_t gem_engine_mmio_base(int i915, const char *engine)
{
unsigned int mmio = 0;
diff --git a/lib/i915/gem_engine_topology.h b/lib/i915/gem_engine_topology.h
index b413aa8aba..987f2bf944 100644
--- a/lib/i915/gem_engine_topology.h
+++ b/lib/i915/gem_engine_topology.h
@@ -133,6 +133,11 @@ int gem_engine_property_printf(int i915, const char *engine, const char *attr,
uint32_t gem_engine_mmio_base(int i915, const char *engine);
+bool gem_engine_has_capability(int i915, const char *engine, const char *cap);
+bool gem_engine_has_known_capability(int i915, const char *engine, const char *cap);
+
+bool gem_engine_can_block_copy(int i915, const struct intel_execution_engine2 *engine);
+
void dyn_sysfs_engines(int i915, int engines, const char *file,
void (*test)(int i915, int engine));
--
2.32.0
next prev parent reply other threads:[~2022-03-11 12:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-11 12:13 [igt-dev] [PATCH i-g-t 0/6] Add i915 blt library + gem_ccs test Zbigniew Kempczyński
2022-03-11 12:13 ` [igt-dev] [PATCH i-g-t 1/6] lib/i915/gem_create: Introduce gem-pool bo cache Zbigniew Kempczyński
2022-03-11 12:13 ` [igt-dev] [PATCH i-g-t 2/6] tests/api_intel_allocator: Verify gem-pool is working as expected Zbigniew Kempczyński
2022-03-11 12:13 ` [igt-dev] [PATCH i-g-t 3/6] lib/i915: Introduce library intel_mocs Zbigniew Kempczyński
2022-03-11 12:13 ` Zbigniew Kempczyński [this message]
2022-03-11 12:13 ` [igt-dev] [PATCH i-g-t 5/6] lib/i915_blt: Add library for blitter Zbigniew Kempczyński
2022-03-11 12:13 ` [igt-dev] [PATCH i-g-t 6/6] tests/gem_ccs: Verify uncompressed and compressed blits Zbigniew Kempczyński
2022-03-11 13:00 ` [igt-dev] ✓ Fi.CI.BAT: success for Add i915 blt library + gem_ccs test (rev8) Patchwork
2022-03-11 15:06 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2022-03-10 7:15 [igt-dev] [PATCH i-g-t 0/6] Add i915 blt library + gem_ccs test Zbigniew Kempczyński
2022-03-10 7:15 ` [igt-dev] [PATCH i-g-t 4/6] i915/gem_engine_topology: Add helpers for checking driver capabilities Zbigniew Kempczyński
2022-03-11 7:27 ` Zbigniew Kempczyński
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220311121318.112757-5-zbigniew.kempczynski@intel.com \
--to=zbigniew.kempczynski@intel.com \
--cc=igt-dev@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox