Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t v2] lib/xe_query: fix vram_memory() and vram_if_possible()
@ 2023-04-06  8:21 Matthew Auld
  2023-04-06 10:06 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Matthew Auld @ 2023-04-06  8:21 UTC (permalink / raw)
  To: igt-dev

vram_memory() is meant to return VRAM if supported. If we call this on
igpu it should return zero. There is at least one user relying on this
in xe_mmap@vram, where we want to skip if the mask here is zero.

vram_if_possible() should account for the per GT VRAM when returning
the mask. Currently it just returns the mask for all VRAM instances.

v2 (Niranjana):
  - Squash into a single patch
  - Fold in the differences from the version by Matt Brost & Zbigniew

Reported-by: Gwan-gyeong Mun <gwan-gyeong.mun@intel.com>
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
Cc: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
---
 lib/xe/xe_query.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/lib/xe/xe_query.c b/lib/xe/xe_query.c
index 24a258a5e..2b627a78a 100644
--- a/lib/xe/xe_query.c
+++ b/lib/xe/xe_query.c
@@ -380,7 +380,7 @@ uint64_t vram_memory(int fd, int gt)
 	igt_assert(xe_dev);
 	igt_assert(gt >= 0 && gt < xe_dev->number_gt);
 
-	return native_region_for_gt(xe_dev->gts, gt);
+	return xe_has_vram(fd) ? native_region_for_gt(xe_dev->gts, gt) : 0;
 }
 
 /**
@@ -393,11 +393,7 @@ uint64_t vram_memory(int fd, int gt)
  */
 uint64_t vram_if_possible(int fd, int gt)
 {
-	uint64_t regions = all_memory_regions(fd);
-	uint64_t system_memory = regions & 0x1;
-	uint64_t vram = regions & (~0x1);
-
-	return vram ? vram : system_memory;
+	return vram_memory(fd, gt) ?: system_memory(fd);
 }
 
 /**
-- 
2.39.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-04-06 23:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-06  8:21 [igt-dev] [PATCH i-g-t v2] lib/xe_query: fix vram_memory() and vram_if_possible() Matthew Auld
2023-04-06 10:06 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2023-04-06 16:38 ` [igt-dev] [PATCH i-g-t v2] " Niranjana Vishwanathapura
2023-04-06 23:43 ` [igt-dev] ✓ Fi.CI.IGT: success for " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox