Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 2/3] lib/xe_query: Add memory region getter from region mask
Date: Fri, 31 Mar 2023 11:16:59 +0200	[thread overview]
Message-ID: <20230331091700.69801-3-zbigniew.kempczynski@intel.com> (raw)
In-Reply-To: <20230331091700.69801-1-zbigniew.kempczynski@intel.com>

Due to xe is strict regarding bo create size we need to be aware
what's driver allocations restrictions. Add a getter for memory
region which describes requirements.

Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
---
 lib/xe/xe_query.c | 12 ++++++++++++
 lib/xe/xe_query.h |  1 +
 2 files changed, 13 insertions(+)

diff --git a/lib/xe/xe_query.c b/lib/xe/xe_query.c
index f281bc4a31..24a258a5e1 100644
--- a/lib/xe/xe_query.c
+++ b/lib/xe/xe_query.c
@@ -426,6 +426,18 @@ struct drm_xe_engine_class_instance *xe_hw_engine(int fd, int idx)
 	return &xe_dev->hw_engines[idx];
 }
 
+struct drm_xe_query_mem_region *xe_mem_region(int fd, uint64_t region)
+{
+	struct xe_device *xe_dev;
+	int region_idx = ffs(region) - 1;
+
+	xe_dev = find_in_cache(fd);
+	igt_assert(xe_dev);
+	igt_assert(xe_dev->mem_usage->num_regions > region_idx);
+
+	return &xe_dev->mem_usage->regions[region_idx];
+}
+
 /**
  * xe_number_hw_engine:
  * @fd: xe device fd
diff --git a/lib/xe/xe_query.h b/lib/xe/xe_query.h
index fddd05cf73..0d4b810a10 100644
--- a/lib/xe/xe_query.h
+++ b/lib/xe/xe_query.h
@@ -83,6 +83,7 @@ uint64_t vram_memory(int fd, int gt);
 uint64_t vram_if_possible(int fd, int gt);
 struct drm_xe_engine_class_instance *xe_hw_engines(int fd);
 struct drm_xe_engine_class_instance *xe_hw_engine(int fd, int idx);
+struct drm_xe_query_mem_region *xe_mem_region(int fd, uint64_t region);
 unsigned int xe_number_hw_engines(int fd);
 bool xe_has_vram(int fd);
 //uint64_t xe_vram_size(int fd);
-- 
2.34.1

  parent reply	other threads:[~2023-03-31  9:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-31  9:16 [igt-dev] [PATCH i-g-t 0/3] Add xe_create test Zbigniew Kempczyński
2023-03-31  9:16 ` [igt-dev] [PATCH i-g-t 1/3] lib/xe_query: Add xe_for_each_mem_region iterator Zbigniew Kempczyński
2023-03-31  9:16 ` Zbigniew Kempczyński [this message]
2023-03-31  9:17 ` [igt-dev] [PATCH i-g-t 3/3] xe/xe_create: Add xe_create test Zbigniew Kempczyński
2023-03-31 12:08   ` Maarten Lankhorst
2023-03-31 10:18 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2023-04-01  8:32 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork

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=20230331091700.69801-3-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