From: Marcin Bernatowicz <marcin.bernatowicz@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: adam.miszczak@intel.com, matthew.auld@intel.com,
jakub1.kolakowski@intel.com
Subject: [igt-dev] [PATCH v4 i-g-t 1/2] lib/xe/xe_query: xe_visible_available_vram_size helper
Date: Thu, 23 Nov 2023 16:08:22 +0100 [thread overview]
Message-ID: <20231123150823.25862-2-marcin.bernatowicz@intel.com> (raw)
In-Reply-To: <20231123150823.25862-1-marcin.bernatowicz@intel.com>
Added 'xe_visible_available_vram_size' helper function
to query the available CPU-visible VRAM size.
Also, renamed 'xe_vram_available' to 'xe_available_vram_size'
for consistency with other function names.
Cc: Francois Dugast <francois.dugast@intel.com>
Cc: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Laguna, Lukasz <lukasz.laguna@intel.com>
Signed-off-by: Marcin Bernatowicz <marcin.bernatowicz@intel.com>
---
lib/xe/xe_query.c | 57 ++++++++++++++++++++++++++++----------
lib/xe/xe_query.h | 3 +-
tests/intel/xe_evict_ccs.c | 2 +-
3 files changed, 46 insertions(+), 16 deletions(-)
diff --git a/lib/xe/xe_query.c b/lib/xe/xe_query.c
index afd443be3..eb4759094 100644
--- a/lib/xe/xe_query.c
+++ b/lib/xe/xe_query.c
@@ -629,20 +629,20 @@ uint64_t xe_visible_vram_size(int fd, int gt)
return visible_size;
}
-/**
- * xe_vram_available:
- * @fd: xe device fd
- * @gt: gt
- *
- * Returns available vram of xe device @fd and @gt.
- */
-uint64_t xe_vram_available(int fd, int gt)
+
+struct __available_vram {
+ uint64_t total_available;
+ uint64_t cpu_visible_available;
+};
+
+static void __available_vram_size_snapshot(int fd, int gt, struct __available_vram *vram)
{
struct xe_device *xe_dev;
int region_idx;
struct drm_xe_query_mem_region *mem_region;
struct drm_xe_query_mem_regions *mem_regions;
+ igt_assert(vram);
xe_dev = find_in_cache(fd);
igt_assert(xe_dev);
@@ -650,19 +650,48 @@ uint64_t xe_vram_available(int fd, int gt)
mem_region = &xe_dev->mem_regions->regions[region_idx];
if (XE_IS_CLASS_VRAM(mem_region)) {
- uint64_t available_vram;
-
mem_regions = xe_query_mem_regions_new(fd);
pthread_mutex_lock(&cache.cache_mutex);
mem_region->used = mem_regions->regions[region_idx].used;
- available_vram = mem_region->total_size - mem_region->used;
+ mem_region->cpu_visible_used = mem_regions->regions[region_idx].cpu_visible_used;
+ vram->total_available = mem_region->total_size - mem_region->used;
+ vram->cpu_visible_available =
+ mem_region->cpu_visible_size - mem_region->cpu_visible_used;
pthread_mutex_unlock(&cache.cache_mutex);
free(mem_regions);
-
- return available_vram;
}
+}
- return 0;
+/**
+ * xe_available_vram_size:
+ * @fd: xe device fd
+ * @gt: gt
+ *
+ * Returns size of available vram of xe device @fd and @gt.
+ */
+uint64_t xe_available_vram_size(int fd, int gt)
+{
+ struct __available_vram vram = {};
+
+ __available_vram_size_snapshot(fd, gt, &vram);
+
+ return vram.total_available;
+}
+
+/**
+ * xe_visible_available_vram_size:
+ * @fd: xe device fd
+ * @gt: gt
+ *
+ * Returns size of visible available vram of xe device @fd and @gt.
+ */
+uint64_t xe_visible_available_vram_size(int fd, int gt)
+{
+ struct __available_vram vram = {};
+
+ __available_vram_size_snapshot(fd, gt, &vram);
+
+ return vram.cpu_visible_available;
}
/**
diff --git a/lib/xe/xe_query.h b/lib/xe/xe_query.h
index 38e9aa440..503d60b44 100644
--- a/lib/xe/xe_query.h
+++ b/lib/xe/xe_query.h
@@ -92,7 +92,8 @@ unsigned int xe_number_hw_engines(int fd);
bool xe_has_vram(int fd);
uint64_t xe_vram_size(int fd, int gt);
uint64_t xe_visible_vram_size(int fd, int gt);
-uint64_t xe_vram_available(int fd, int gt);
+uint64_t xe_available_vram_size(int fd, int gt);
+uint64_t xe_visible_available_vram_size(int fd, int gt);
uint32_t xe_get_default_alignment(int fd);
uint32_t xe_va_bits(int fd);
uint16_t xe_dev_id(int fd);
diff --git a/tests/intel/xe_evict_ccs.c b/tests/intel/xe_evict_ccs.c
index d7244f620..b04c20935 100644
--- a/tests/intel/xe_evict_ccs.c
+++ b/tests/intel/xe_evict_ccs.c
@@ -325,7 +325,7 @@ static void set_config(int fd, uint32_t flags, const struct param *param,
config->param = param;
config->flags = flags;
config->free_mb = xe_visible_vram_size(fd, 0) / SZ_1M;
- config->total_mb = xe_vram_available(fd, 0) / SZ_1M;
+ config->total_mb = xe_available_vram_size(fd, 0) / SZ_1M;
config->test_mb = min_t(int, config->free_mb * config->param->vram_percent / 100,
config->total_mb * config->param->vram_percent / 100);
--
2.31.1
next prev parent reply other threads:[~2023-11-23 15:08 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-23 15:08 [igt-dev] [PATCH v4 i-g-t 0/2] add create-big-vram subtest Marcin Bernatowicz
2023-11-23 15:08 ` Marcin Bernatowicz [this message]
2023-11-27 17:15 ` [igt-dev] [PATCH v4 i-g-t 1/2] lib/xe/xe_query: xe_visible_available_vram_size helper Kamil Konieczny
2023-11-23 15:08 ` [igt-dev] [PATCH v4 i-g-t 2/2] tests/intel/xe_create: create-big-vram subtest Marcin Bernatowicz
2023-11-23 17:24 ` Kamil Konieczny
2023-11-23 18:50 ` Bernatowicz, Marcin
2023-11-29 17:56 ` Kamil Konieczny
2023-11-30 10:11 ` Bernatowicz, Marcin
2023-11-30 12:49 ` Kamil Konieczny
2023-11-23 16:57 ` [igt-dev] ✓ Fi.CI.BAT: success for add " Patchwork
2023-11-23 18:13 ` [igt-dev] ✓ CI.xeBAT: " Patchwork
2023-11-25 9:40 ` [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=20231123150823.25862-2-marcin.bernatowicz@intel.com \
--to=marcin.bernatowicz@intel.com \
--cc=adam.miszczak@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=jakub1.kolakowski@intel.com \
--cc=matthew.auld@intel.com \
/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