public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Ramalingam C <ramalingam.c@intel.com>
To: igt-dev <igt-dev@lists.freedesktop.org>
Subject: [igt-dev] [PATCH i-g-t] tests/dumb_buffer: page_size for create_clear
Date: Wed,  5 Feb 2020 19:25:32 +0530	[thread overview]
Message-ID: <20200205135532.15757-1-ramalingam.c@intel.com> (raw)

For the dumb_buffer@clear_create test we need to detect the correct page
size for the buffer size calculation.

We create the least sized buffer and see the page aligned size returned
from kernel, which is minimum page size kernel will allocate.

Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
cc: Chris Wilson <chris@chris-wilson.co.uk>
---
 tests/dumb_buffer.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/tests/dumb_buffer.c b/tests/dumb_buffer.c
index ad854c0696e7..de0501873e59 100644
--- a/tests/dumb_buffer.c
+++ b/tests/dumb_buffer.c
@@ -52,8 +52,6 @@
 
 IGT_TEST_DESCRIPTION("This is a test for the generic dumb buffer interface.");
 
-#define PAGE_SIZE 4096
-
 static int __dumb_create(int fd, struct drm_mode_create_dumb *create)
 {
 	int err = 0;
@@ -225,6 +223,7 @@ struct thread_clear {
 	_Atomic(uint64_t) max;
 	int timeout;
 	int fd;
+	unsigned long page_size;
 };
 
 #define MAX_PAGE_TO_REQUEST	102400
@@ -247,14 +246,12 @@ static void *thread_clear(void *data)
 
 		for (uint64_t _npages = npages; npages > 0; npages -= _npages) {
 			create.bpp = 32;
-			create.width = PAGE_SIZE / (create.bpp / 8);
+			create.width = arg->page_size / (create.bpp / 8);
 			_npages = npages <= MAX_PAGE_TO_REQUEST ? npages :
 				  MAX_PAGE_TO_REQUEST;
 			create.height = _npages;
 
 			dumb_create(fd, &create);
-			igt_assert_eq(PAGE_SIZE * create.height, create.size);
-
 			ptr = dumb_map(fd,
 				       create.handle, create.size,
 				       PROT_WRITE);
@@ -286,7 +283,7 @@ static void sigprobe(int sig)
 	longjmp(sigjmp, sig);
 }
 
-static uint64_t estimate_largest_dumb_buffer(int fd)
+static uint64_t estimate_largest_dumb_buffer(int fd, unsigned long page_size)
 {
 	sighandler_t old_sigbus = signal(SIGBUS, sigprobe);
 	sighandler_t old_sigsegv = signal(SIGSEGV, sigprobe);
@@ -307,7 +304,7 @@ static uint64_t estimate_largest_dumb_buffer(int fd)
 
 		igt_info("Largest dumb buffer sucessfully created: %'"PRIu64" bytes\n",
 			 largest);
-		return largest / PAGE_SIZE;
+		return largest / page_size;
 	}
 
 	for (create.height = 1; create.height; create.height *= 2) {
@@ -334,13 +331,23 @@ static void always_clear(int fd, int timeout)
 	struct thread_clear arg = {
 		.fd = fd,
 		.timeout = timeout,
-		.max = estimate_largest_dumb_buffer(fd), /* in pages */
 	};
 	const int ncpus = sysconf(_SC_NPROCESSORS_ONLN);
+	struct drm_mode_create_dumb create = {
+		.bpp = 32,
+		.width = 1, /* in pixels */
+		.height = 1, /* in rows */
+	};
 	unsigned long checked;
 	pthread_t thread[ncpus];
 	void *result;
 
+	dumb_create(fd, &create);
+	arg.page_size = create.size;
+	dumb_destroy(fd, create.handle);
+
+	arg.max = estimate_largest_dumb_buffer(fd, arg.page_size);
+
 	for (int i = 0; i < ncpus; i++)
 		pthread_create(&thread[i], NULL, thread_clear, &arg);
 
-- 
2.20.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

             reply	other threads:[~2020-02-05 13:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-05 13:55 Ramalingam C [this message]
2020-02-05 14:01 ` [igt-dev] [PATCH i-g-t] tests/dumb_buffer: page_size for create_clear Chris Wilson
2020-02-05 15:02 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2020-02-08  1:18 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2020-02-05 17:00 [igt-dev] [PATCH i-g-t] " Ramalingam C

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=20200205135532.15757-1-ramalingam.c@intel.com \
    --to=ramalingam.c@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /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