All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>,
	"Petri Latvala" <petri.latvala@intel.com>,
	"Ashutosh Dixit" <ashutosh.dixit@intel.com>
Subject: [igt-dev] [PATCH i-g-t 2/7] lib/intel_batchbuffer: Detect and use kernel alignment capability
Date: Fri,  8 Oct 2021 08:54:27 +0200	[thread overview]
Message-ID: <20211008065432.15482-3-zbigniew.kempczynski@intel.com> (raw)
In-Reply-To: <20211008065432.15482-1-zbigniew.kempczynski@intel.com>

For gens where relocations are supported kernel can set object offset
everywhere it wants but it honours the alignment setting.

For gens where we got no relocations and setting alignment is not
allowed in exec object we want to ensure allocator will still use it
to properly align the offset.

Detect kernel caps in alignment setting and use it for reloc/no-reloc
paths accordingly.

Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Petri Latvala <petri.latvala@intel.com>
Cc: Ashutosh Dixit <ashutosh.dixit@intel.com>
---
 lib/intel_batchbuffer.c | 9 +++++++--
 lib/intel_batchbuffer.h | 1 +
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
index 9c26fe207..ed7c25015 100644
--- a/lib/intel_batchbuffer.c
+++ b/lib/intel_batchbuffer.c
@@ -1335,6 +1335,7 @@ __intel_bb_create(int i915, uint32_t ctx, uint32_t size, bool do_relocs,
 
 	igt_assert(ibb);
 
+	ibb->allows_passing_alignment = gem_allows_passing_alignment(i915);
 	ibb->uses_full_ppgtt = gem_uses_full_ppgtt(i915);
 	ibb->devid = intel_get_drm_devid(i915);
 	ibb->gen = intel_gen(ibb->devid);
@@ -1783,6 +1784,7 @@ __add_to_cache(struct intel_bb *ibb, uint32_t handle)
 	igt_assert(object);
 
 	object->handle = handle;
+	object->alignment = 0;
 	found = tsearch((void *) object, &ibb->root, __compare_objects);
 
 	if (*found == object) {
@@ -1905,7 +1907,7 @@ intel_bb_add_object(struct intel_bb *ibb, uint32_t handle, uint64_t size,
 		   || ALIGN(offset, alignment) == offset);
 
 	object = __add_to_cache(ibb, handle);
-	object->alignment = alignment ?: 4096;
+	alignment = alignment ?: 4096;
 	__add_to_objects(ibb, object);
 
 	/*
@@ -1917,7 +1919,7 @@ intel_bb_add_object(struct intel_bb *ibb, uint32_t handle, uint64_t size,
 	if (INVALID_ADDR(object->offset)) {
 		if (INVALID_ADDR(offset)) {
 			offset = __intel_bb_get_offset(ibb, handle, size,
-						       object->alignment);
+						       alignment);
 		} else {
 			offset = offset & (ibb->gtt_size - 1);
 
@@ -1962,6 +1964,9 @@ intel_bb_add_object(struct intel_bb *ibb, uint32_t handle, uint64_t size,
 	if (ibb->uses_full_ppgtt && !ibb->enforce_relocs)
 		object->flags |= EXEC_OBJECT_PINNED;
 
+	if (ibb->allows_passing_alignment)
+		object->alignment = alignment;
+
 	return object;
 }
 
diff --git a/lib/intel_batchbuffer.h b/lib/intel_batchbuffer.h
index 58bddb1a1..728985274 100644
--- a/lib/intel_batchbuffer.h
+++ b/lib/intel_batchbuffer.h
@@ -476,6 +476,7 @@ struct intel_bb {
 	uint64_t gtt_size;
 	bool supports_48b_address;
 	bool uses_full_ppgtt;
+	bool allows_passing_alignment;
 
 	struct igt_pxp pxp;
 	uint32_t ctx;
-- 
2.26.0

  parent reply	other threads:[~2021-10-08  6:54 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-08  6:54 [igt-dev] [PATCH i-g-t 0/7] Prepare IGTs to allow only zero alignment Zbigniew Kempczyński
2021-10-08  6:54 ` [igt-dev] [PATCH i-g-t 1/7] lib/gem_submission: Add kernel exec object alignment capability Zbigniew Kempczyński
2021-10-13  4:47   ` Dixit, Ashutosh
2021-10-13  5:27     ` Zbigniew Kempczyński
2021-10-14  2:26       ` Dixit, Ashutosh
2021-10-14  7:14         ` Zbigniew Kempczyński
2021-10-14  7:22           ` Dixit, Ashutosh
2021-10-08  6:54 ` Zbigniew Kempczyński [this message]
2021-10-14  2:37   ` [igt-dev] [PATCH i-g-t 2/7] lib/intel_batchbuffer: Detect and use kernel " Dixit, Ashutosh
2021-10-14  7:25     ` Zbigniew Kempczyński
2021-10-14  7:22       ` Dixit, Ashutosh
2021-10-08  6:54 ` [igt-dev] [PATCH i-g-t 3/7] tests/gem_exec_alignment: Add prerequisite alignment condition Zbigniew Kempczyński
2021-10-14  4:12   ` Dixit, Ashutosh
2021-10-14  7:27     ` Zbigniew Kempczyński
2021-10-08  6:54 ` [igt-dev] [PATCH i-g-t 4/7] tests/gem_evict_alignment: Skip if kernel doesn't support passing alignment Zbigniew Kempczyński
2021-10-14  4:14   ` Dixit, Ashutosh
2021-10-08  6:54 ` [igt-dev] [PATCH i-g-t 5/7] tests/i915_pm_rpm: Fix invalid alignment Zbigniew Kempczyński
2021-10-14  4:18   ` Dixit, Ashutosh
2021-10-08  6:54 ` [igt-dev] [PATCH i-g-t 6/7] benchmarks/gem_exec_fault: Add timeout argument Zbigniew Kempczyński
2021-10-14  4:24   ` Dixit, Ashutosh
2021-10-14  7:47     ` Zbigniew Kempczyński
2021-10-14  7:30       ` Dixit, Ashutosh
2021-10-08  6:54 ` [igt-dev] [PATCH i-g-t 7/7] benchmarks/gem_exec_fault: Add softpin mode to support gens with ppgtt Zbigniew Kempczyński
2021-10-14  5:01   ` Dixit, Ashutosh
2021-10-14  5:06     ` Dixit, Ashutosh
2021-10-14  8:11     ` Zbigniew Kempczyński
2021-10-08  7:48 ` [igt-dev] ✓ Fi.CI.BAT: success for Prepare IGTs to allow only zero alignment Patchwork
2021-10-08  9:02 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2021-10-14  8:19 [igt-dev] [PATCH i-g-t 0/7] " Zbigniew Kempczyński
2021-10-14  8:19 ` [igt-dev] [PATCH i-g-t 2/7] lib/intel_batchbuffer: Detect and use kernel alignment capability 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=20211008065432.15482-3-zbigniew.kempczynski@intel.com \
    --to=zbigniew.kempczynski@intel.com \
    --cc=ashutosh.dixit@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=petri.latvala@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.