Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Auld <matthew.auld@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
Subject: [PATCH i-g-t v2 7/8] lib/intel_bufops: keep bo_size separate
Date: Tue, 13 Feb 2024 10:01:24 +0000	[thread overview]
Message-ID: <20240213100125.90085-7-matthew.auld@intel.com> (raw)
In-Reply-To: <20240213100125.90085-1-matthew.auld@intel.com>

If the caller provides some bo_size, like for an existing object handle,
then we currently trample the buf->size here, which seems quite
inconsistent. Rather treat bo_size and size separate, just ensuring that
bo_size is large enough.

v2:(Zbigniew)
  - Always assert bo_size >= size.

Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Reviewed-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
---
 lib/intel_bufops.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/lib/intel_bufops.c b/lib/intel_bufops.c
index 10e2d3dac..c8f91aef8 100644
--- a/lib/intel_bufops.c
+++ b/lib/intel_bufops.c
@@ -903,11 +903,6 @@ static void __intel_buf_init(struct buf_ops *bops,
 		size = buf->surface[0].stride * ALIGN(height, align_h);
 	}
 
-	if (bo_size > 0) {
-		igt_assert(bo_size >= size);
-		size = bo_size;
-	}
-
 	/* Store buffer size to avoid mistakes in calculating it again */
 	buf->size = size;
 	buf->handle = handle;
@@ -918,17 +913,22 @@ static void __intel_buf_init(struct buf_ops *bops,
 	buf->region = region;
 
 	if (!handle) {
+		if (!bo_size)
+			bo_size = size;
+
 		if (bops->driver == INTEL_DRIVER_I915) {
-			if (__gem_create_in_memory_regions(bops->fd, &buf->handle, &size, region))
-				igt_assert_eq(__gem_create(bops->fd, &size, &buf->handle), 0);
+			if (__gem_create_in_memory_regions(bops->fd, &buf->handle, &bo_size, region))
+				igt_assert_eq(__gem_create(bops->fd, &bo_size, &buf->handle), 0);
 		} else {
-			size = ALIGN(size, xe_get_default_alignment(bops->fd));
-			buf->handle = xe_bo_create(bops->fd, 0, size, region, 0);
+			bo_size = ALIGN(bo_size, xe_get_default_alignment(bops->fd));
+			buf->handle = xe_bo_create(bops->fd, 0, bo_size, region, 0);
 		}
 	}
 
+	igt_assert(bo_size >= size);
+
 	/* Store gem bo size */
-	buf->bo_size = size;
+	buf->bo_size = bo_size;
 
 	if (bops->driver == INTEL_DRIVER_I915)
 		set_hw_tiled(bops, buf);
-- 
2.43.0


  parent reply	other threads:[~2024-02-13 10:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-13 10:01 [PATCH i-g-t v2 1/8] tests/prime_nv_test: switch over to intel_buf_init() Matthew Auld
2024-02-13 10:01 ` [PATCH i-g-t v2 2/8] tests/intel: prefer intel_buf_init_in_region() Matthew Auld
2024-02-13 10:01 ` [PATCH i-g-t v2 3/8] lib/intel_bufops: repurpose intel_buf_create_using_handle_and_size() Matthew Auld
2024-02-13 10:01 ` [PATCH i-g-t v2 4/8] tests/intel: replace intel_buf_create_using_handle() Matthew Auld
2024-02-13 10:01 ` [PATCH i-g-t v2 5/8] tests/intel: replace intel_buf_init_using_handle() Matthew Auld
2024-02-13 10:01 ` [PATCH i-g-t v2 6/8] tests/intel/kms_dirtyfb: pass the bo_size Matthew Auld
2024-02-13 10:01 ` Matthew Auld [this message]
2024-02-13 10:01 ` [PATCH i-g-t v2 8/8] lib/igt_fb: assert fb->size blt_fb_init() Matthew Auld
2024-02-13 11:37 ` ✓ Fi.CI.BAT: success for series starting with [i-g-t,v2,1/8] tests/prime_nv_test: switch over to intel_buf_init() Patchwork
2024-02-13 12:26 ` ✓ CI.xeBAT: " Patchwork
2024-02-13 13:21 ` ✗ Fi.CI.IGT: failure " Patchwork
2024-02-16 11:12   ` Kamil Konieczny

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=20240213100125.90085-7-matthew.auld@intel.com \
    --to=matthew.auld@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=zbigniew.kempczynski@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