diff mbox series

[RFC,i-g-t,v4,3/4] tests/gem_exec_reloc: Calculate offsets from minimum GTT alignment

Message ID 20191031152857.17143-4-janusz.krzysztofik@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series Calculate softpin offsets from minimum GTT alignment | expand

Commit Message

Janusz Krzysztofik Oct. 31, 2019, 3:28 p.m. UTC
The basic-range subtest assumes 4kB GTT alignment while calculating
softpin offsets.  On future backends with possibly larger minimum page
sizes the test will fail as a half of calculated offsets to be tested
will be incorrectly aligned.

Replace hardcoded constants corresponding to the assumed 4kB GTT
alignment with variables initialized with actual minimum GTT alignment
size and order.

v2: Simplify the code by reversing the size->order conversion,
  - drop irrelevant modifications of requested object sizes.
v3: Reword commit message after removal of patch "Don't filter out
    addresses on full PPGTT" from the series,
  - initialize page size order with an actual minimum returned by a new
    helper (inspired by Chris).
v4: Update the helper name, use the term 'minimum GTT alignment' across
    the change, adjust variable names,
  - refresh the commit message on top of the reintroduced patch that
    fixes invalid offsets incorrectly assumed as occupied.

Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
Cc: Katarzyna Dec <katarzyna.dec@intel.com>
Cc: Stuart Summers <stuart.summers@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
---
 tests/i915/gem_exec_reloc.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Chris Wilson Nov. 1, 2019, 10:11 a.m. UTC | #1
Quoting Janusz Krzysztofik (2019-10-31 15:28:56)
> The basic-range subtest assumes 4kB GTT alignment while calculating
> softpin offsets.  On future backends with possibly larger minimum page
> sizes the test will fail as a half of calculated offsets to be tested
> will be incorrectly aligned.
> 
> Replace hardcoded constants corresponding to the assumed 4kB GTT
> alignment with variables initialized with actual minimum GTT alignment
> size and order.
> 
> v2: Simplify the code by reversing the size->order conversion,
>   - drop irrelevant modifications of requested object sizes.
> v3: Reword commit message after removal of patch "Don't filter out
>     addresses on full PPGTT" from the series,
>   - initialize page size order with an actual minimum returned by a new
>     helper (inspired by Chris).
> v4: Update the helper name, use the term 'minimum GTT alignment' across
>     the change, adjust variable names,
>   - refresh the commit message on top of the reintroduced patch that
>     fixes invalid offsets incorrectly assumed as occupied.
> 
> Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
> Cc: Katarzyna Dec <katarzyna.dec@intel.com>
> Cc: Stuart Summers <stuart.summers@intel.com>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
diff mbox series

Patch

diff --git a/tests/i915/gem_exec_reloc.c b/tests/i915/gem_exec_reloc.c
index 423fed8b..8050cd3e 100644
--- a/tests/i915/gem_exec_reloc.c
+++ b/tests/i915/gem_exec_reloc.c
@@ -520,14 +520,16 @@  static void basic_range(int fd, unsigned flags)
 	uint64_t gtt_size = gem_aperture_size(fd);
 	const uint32_t bbe = MI_BATCH_BUFFER_END;
 	igt_spin_t *spin = NULL;
+	int alignment_order = gem_gtt_min_alignment_order(fd);
+	uint64_t alignment = 1ull << alignment_order;
 	int count, n, err;
 
 	igt_require(gem_has_softpin(fd));
 
-	for (count = 12; gtt_size >> (count + 1); count++)
+	for (count = alignment_order; gtt_size >> (count + 1); count++)
 		;
 
-	count -= 12;
+	count -= alignment_order;
 
 	memset(obj, 0, sizeof(obj));
 	memset(reloc, 0, sizeof(reloc));
@@ -536,7 +538,7 @@  static void basic_range(int fd, unsigned flags)
 	n = 0;
 	for (int i = 0; i <= count; i++) {
 		obj[n].handle = gem_create(fd, 4096);
-		obj[n].offset = (1ull << (i + 12)) - 4096;
+		obj[n].offset = (1ull << (i + alignment_order)) - alignment;
 		obj[n].offset = gen8_canonical_address(obj[n].offset);
 		obj[n].flags = EXEC_OBJECT_PINNED | EXEC_OBJECT_SUPPORTS_48B_ADDRESS;
 		gem_write(fd, obj[n].handle, 0, &bbe, sizeof(bbe));
@@ -559,7 +561,7 @@  static void basic_range(int fd, unsigned flags)
 	}
 	for (int i = 1; i < count; i++) {
 		obj[n].handle = gem_create(fd, 4096);
-		obj[n].offset = 1ull << (i + 12);
+		obj[n].offset = 1ull << (i + alignment_order);
 		obj[n].offset = gen8_canonical_address(obj[n].offset);
 		obj[n].flags = EXEC_OBJECT_PINNED | EXEC_OBJECT_SUPPORTS_48B_ADDRESS;
 		gem_write(fd, obj[n].handle, 0, &bbe, sizeof(bbe));