[igt-dev] [PATCH i-g-t 1/2] lib/intel_allocator: Fixed start offset and alignment

Dominik Karol Piatkowski dominik.karol.piatkowski at intel.com
Tue Dec 20 07:07:16 UTC 2022


On some platforms it may be required to use non-zero start address
that is also aligned. Allocating memory before aligned safe start offset
may result in failures.

Signed-off-by: Dominik Karol Piatkowski <dominik.karol.piatkowski at intel.com>
Cc: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
---
 lib/intel_allocator.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/intel_allocator.c b/lib/intel_allocator.c
index 3004f15a..060a65ce 100644
--- a/lib/intel_allocator.c
+++ b/lib/intel_allocator.c
@@ -910,6 +910,9 @@ static uint64_t __intel_allocator_open_full(int fd, uint32_t ctx,
 	struct alloc_resp resp;
 	uint64_t gtt_size;
 
+	if (!start)
+		req.open.start = gem_detect_safe_start_offset(fd);
+
 	if (!end) {
 		igt_assert_f(can_report_gtt_size(fd), "Invalid fd\n");
 		gtt_size = gem_aperture_size(fd);
@@ -924,6 +927,8 @@ static uint64_t __intel_allocator_open_full(int fd, uint32_t ctx,
 	if (!default_alignment)
 		req.open.default_alignment = gem_detect_safe_alignment(fd);
 
+	req.open.start = ALIGN(req.open.start, req.open.default_alignment);
+
 	/* Get child_tid only once at open() */
 	if (child_tid == -1)
 		child_tid = gettid();
-- 
2.34.1



More information about the igt-dev mailing list