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 4/5] tests/dumb_duffer: extending for lmem coverage.
Date: Mon, 27 Jan 2020 22:32:04 +0530	[thread overview]
Message-ID: <20200127170205.7195-4-ramalingam.c@intel.com> (raw)
In-Reply-To: <20200127170205.7195-1-ramalingam.c@intel.com>

If lmem is available on intel platforms, dumb buffers are created out of
lmem. Hence tests detect the lmem and adopt the corresponding page
size to cover the dumb buffers from lmem.

Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
---
 tests/dumb_buffer.c | 54 ++++++++++++++++++++++++++++-----------------
 1 file changed, 34 insertions(+), 20 deletions(-)

diff --git a/tests/dumb_buffer.c b/tests/dumb_buffer.c
index ad854c0696e7..79a4fade5367 100644
--- a/tests/dumb_buffer.c
+++ b/tests/dumb_buffer.c
@@ -43,6 +43,9 @@
 #include <sys/ioctl.h>
 #include <sys/stat.h>
 #include <sys/time.h>
+#include <igt_debugfs.h>
+
+#include <i915/intel_memory_region.h>
 
 #include <drm.h>
 
@@ -52,7 +55,11 @@
 
 IGT_TEST_DESCRIPTION("This is a test for the generic dumb buffer interface.");
 
-#define PAGE_SIZE 4096
+static struct dumb_buffer_data {
+	int drm_fd;
+	bool lmem;
+	int page_size;
+} data;
 
 static int __dumb_create(int fd, struct drm_mode_create_dumb *create)
 {
@@ -227,13 +234,15 @@ struct thread_clear {
 	int fd;
 };
 
-#define MAX_PAGE_TO_REQUEST	102400
+#define MAX_SMEM_PAGE	102400
+#define MAX_LMEM_PAGE	1024
 
-static void *thread_clear(void *data)
+static void *thread_clear(void *thread_data)
 {
-	struct thread_clear *arg = data;
+	struct thread_clear *arg = thread_data;
 	unsigned long checked = 0;
 	int fd = arg->fd;
+	int max_page = data.lmem ? MAX_LMEM_PAGE : MAX_SMEM_PAGE;
 	void *ptr;
 
 	igt_until_timeout(arg->timeout) {
@@ -247,16 +256,14 @@ 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);
-			_npages = npages <= MAX_PAGE_TO_REQUEST ? npages :
-				  MAX_PAGE_TO_REQUEST;
+			create.width = data.page_size / (create.bpp / 8);
+			_npages = npages <= max_page ? npages : max_page;
 			create.height = _npages;
 
 			dumb_create(fd, &create);
-			igt_assert_eq(PAGE_SIZE * create.height, create.size);
+			igt_assert_eq(data.page_size * create.height, create.size);
 
-			ptr = dumb_map(fd,
-				       create.handle, create.size,
+			ptr = dumb_map(fd, create.handle, create.size,
 				       PROT_WRITE);
 
 			for (uint64_t page = 0; page < create.height; page++) {
@@ -307,7 +314,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 / data.page_size;
 	}
 
 	for (create.height = 1; create.height; create.height *= 2) {
@@ -354,27 +361,34 @@ static void always_clear(int fd, int timeout)
 
 igt_main
 {
-	int fd = -1;
-
 	igt_fixture {
-		fd = drm_open_driver(DRIVER_ANY);
+		data.drm_fd = drm_open_driver(DRIVER_ANY);
+		data.lmem = false;
+		data.page_size = 4096;
+		if (is_i915_device(data.drm_fd)) {
+			if (gem_has_lmem(data.drm_fd)) {
+				data.lmem = true;
+				data.page_size = 65536;
+			}
+		}
+
 	}
 
 	igt_subtest("invalid-bpp")
-		invalid_dimensions_test(fd);
+		invalid_dimensions_test(data.drm_fd);
 
 	igt_subtest("create-valid-dumb")
-		valid_dumb_creation_test(fd);
+		valid_dumb_creation_test(data.drm_fd);
 
 	igt_subtest("map-valid")
-		valid_map(fd);
+		valid_map(data.drm_fd);
 
 	igt_subtest("map-uaf")
-		uaf_map(fd);
+		uaf_map(data.drm_fd);
 
 	igt_subtest("map-invalid-size")
-		invalid_size_map(fd);
+		invalid_size_map(data.drm_fd);
 
 	igt_subtest("create-clear")
-		always_clear(fd, 30);
+		always_clear(data.drm_fd, 30);
 }
-- 
2.20.1

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

  parent reply	other threads:[~2020-01-27 17:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-27 17:02 [igt-dev] [PATCH i-g-t 1/5] tests/dumb_buffer: Remove page nonaligned buffer tests Ramalingam C
2020-01-27 17:02 ` [igt-dev] [PATCH i-g-t 2/5] tests/i915/gem_create: Modify the page nonaligned tests Ramalingam C
2020-01-27 17:02 ` [igt-dev] [PATCH i-g-t 3/5] tests/dumb_buffer: Try to compute the largest possible dumb buffer Ramalingam C
2020-01-27 17:02 ` Ramalingam C [this message]
2020-01-27 17:13   ` [igt-dev] [PATCH i-g-t 4/5] tests/dumb_duffer: extending for lmem coverage Chris Wilson
2020-01-27 17:02 ` [igt-dev] [PATCH i-g-t 5/5] lib/i915/intel_memory_region: wrappers for memory regions ops Ramalingam C
2020-01-27 19:41 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/5] tests/dumb_buffer: Remove page nonaligned buffer tests Patchwork
2020-01-28 13:57 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork

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=20200127170205.7195-4-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