[igt-dev] [PATCH i-g-t 1/3] igt/kms_addfb_basic: Call dumb destroy in case have dumb buffer

Deepak Rawat drawat at vmware.com
Wed Jan 16 00:22:28 UTC 2019


Drivers not necessarily support GEM interface to destroy dumb buffer, so
call DRM_IOCTL_MODE_DESTROY_DUMB in case bo is a dumb buffer.

Signed-off-by: Deepak Rawat <drawat at vmware.com>
---
 tests/kms_addfb_basic.c | 70 ++++++++++++++++++++++++++++++-----------
 1 file changed, 52 insertions(+), 18 deletions(-)

diff --git a/tests/kms_addfb_basic.c b/tests/kms_addfb_basic.c
index 400241a9..47dce2d4 100644
--- a/tests/kms_addfb_basic.c
+++ b/tests/kms_addfb_basic.c
@@ -70,6 +70,7 @@ static int rmfb(int fd, uint32_t id)
 static void invalid_tests(int fd)
 {
 	struct local_drm_mode_fb_cmd2 f = {};
+	bool is_dumb = false;
 
 	f.width = 512;
 	f.height = 512;
@@ -78,7 +79,7 @@ static void invalid_tests(int fd)
 
 	igt_fixture {
 		gem_bo = igt_create_bo_with_dimensions(fd, 1024, 1024,
-			DRM_FORMAT_XRGB8888, 0, 0, NULL, NULL, NULL);
+			DRM_FORMAT_XRGB8888, 0, 0, NULL, NULL, &is_dumb);
 		igt_assert(gem_bo);
 		gem_bo_small = igt_create_bo_with_dimensions(fd, 1024, 1023,
 			DRM_FORMAT_XRGB8888, 0, 0, NULL, NULL, NULL);
@@ -242,8 +243,13 @@ static void invalid_tests(int fd)
 	}
 
 	igt_fixture {
-		gem_close(fd, gem_bo);
-		gem_close(fd, gem_bo_small);
+		if (is_dumb) {
+			kmstest_dumb_destroy(fd, gem_bo);
+			kmstest_dumb_destroy(fd, gem_bo_small);
+		} else {
+			gem_close(fd, gem_bo);
+			gem_close(fd, gem_bo_small);
+		}
 	}
 }
 
@@ -251,6 +257,7 @@ static void pitch_tests(int fd)
 {
 	struct drm_mode_fb_cmd2 f = {};
 	int bad_pitches[] = { 0, 32, 63, 128, 256, 256*4, 999, 64*1024 };
+	bool is_dumb = false;
 	int i;
 
 	f.width = 512;
@@ -260,7 +267,7 @@ static void pitch_tests(int fd)
 
 	igt_fixture {
 		gem_bo = igt_create_bo_with_dimensions(fd, 1024, 1024,
-			DRM_FORMAT_XRGB8888, 0, 0, NULL, NULL, NULL);
+			DRM_FORMAT_XRGB8888, 0, 0, NULL, NULL, &is_dumb);
 		igt_assert(gem_bo);
 	}
 
@@ -284,8 +291,12 @@ static void pitch_tests(int fd)
 		}
 	}
 
-	igt_fixture
-		gem_close(fd, gem_bo);
+	igt_fixture {
+		if (is_dumb)
+			kmstest_dumb_destroy(fd, gem_bo);
+		else
+			gem_close(fd, gem_bo);
+	}
 }
 
 static void tiling_tests(int fd)
@@ -293,6 +304,7 @@ static void tiling_tests(int fd)
 	struct drm_mode_fb_cmd2 f = {};
 	uint32_t tiled_x_bo = 0;
 	uint32_t tiled_y_bo = 0;
+	bool is_dumb = false;
 
 	f.width = 512;
 	f.height = 512;
@@ -303,7 +315,7 @@ static void tiling_tests(int fd)
 		igt_fixture {
 			tiled_x_bo = igt_create_bo_with_dimensions(fd, 1024, 1024,
 				DRM_FORMAT_XRGB8888, LOCAL_I915_FORMAT_MOD_X_TILED,
-				1024*4, NULL, NULL, NULL);
+				1024*4, NULL, NULL, &is_dumb);
 			igt_assert(tiled_x_bo);
 
 			tiled_y_bo = igt_create_bo_with_dimensions(fd, 1024, 1024,
@@ -353,8 +365,13 @@ static void tiling_tests(int fd)
 		}
 
 		igt_fixture {
-			gem_close(fd, tiled_x_bo);
-			gem_close(fd, tiled_y_bo);
+			if (is_dumb) {
+				kmstest_dumb_destroy(fd, tiled_x_bo);
+				kmstest_dumb_destroy(fd, tiled_y_bo);
+			} else {
+				gem_close(fd, tiled_x_bo);
+				gem_close(fd, tiled_y_bo);
+			}
 		}
 	}
 }
@@ -364,6 +381,7 @@ static void size_tests(int fd)
 	struct drm_mode_fb_cmd2 f = {};
 	struct drm_mode_fb_cmd2 f_16 = {};
 	struct drm_mode_fb_cmd2 f_8 = {};
+	bool is_dumb = false;
 
 	f.width = 1024;
 	f.height = 1024;
@@ -382,7 +400,7 @@ static void size_tests(int fd)
 
 	igt_fixture {
 		gem_bo = igt_create_bo_with_dimensions(fd, 1024, 1024,
-			DRM_FORMAT_XRGB8888, 0, 0, NULL, NULL, NULL);
+			DRM_FORMAT_XRGB8888, 0, 0, NULL, NULL, &is_dumb);
 		igt_assert(gem_bo);
 		gem_bo_small = igt_create_bo_with_dimensions(fd, 1024, 1023,
 			DRM_FORMAT_XRGB8888, 0, 0, NULL, NULL, NULL);
@@ -453,18 +471,24 @@ static void size_tests(int fd)
 
 
 	igt_fixture {
-		gem_close(fd, gem_bo);
-		gem_close(fd, gem_bo_small);
+		if (is_dumb) {
+			kmstest_dumb_destroy(fd, gem_bo);
+			kmstest_dumb_destroy(fd, gem_bo_small);
+		} else {
+			gem_close(fd, gem_bo);
+			gem_close(fd, gem_bo_small);
+		}
 	}
 }
 
 static void addfb25_tests(int fd)
 {
 	struct local_drm_mode_fb_cmd2 f = {};
+	bool is_dumb = false;
 
 	igt_fixture {
 		gem_bo = igt_create_bo_with_dimensions(fd, 1024, 1024,
-			DRM_FORMAT_XRGB8888, 0, 0, NULL, NULL, NULL);
+			DRM_FORMAT_XRGB8888, 0, 0, NULL, NULL, &is_dumb);
 		igt_assert(gem_bo);
 
 		memset(&f, 0, sizeof(f));
@@ -522,8 +546,12 @@ static void addfb25_tests(int fd)
 			f.fb_id = 0;
 		}
 	}
-	igt_fixture
-		gem_close(fd, gem_bo);
+	igt_fixture {
+		if (is_dumb)
+			kmstest_dumb_destroy(fd, gem_bo);
+		else
+			gem_close(fd, gem_bo);
+	}
 }
 
 static int addfb_expected_ret(int fd)
@@ -540,11 +568,12 @@ static int addfb_expected_ret(int fd)
 static void addfb25_ytile(int fd)
 {
 	struct local_drm_mode_fb_cmd2 f = {};
+	bool is_dumb = false;
 	int gen;
 
 	igt_fixture {
 		gem_bo = igt_create_bo_with_dimensions(fd, 1024, 1024,
-			DRM_FORMAT_XRGB8888, 0, 0, NULL, NULL, NULL);
+			DRM_FORMAT_XRGB8888, 0, 0, NULL, NULL, &is_dumb);
 		igt_assert(gem_bo);
 		gem_bo_small = igt_create_bo_with_dimensions(fd, 1024, 1023,
 			DRM_FORMAT_XRGB8888, 0, 0, NULL, NULL, NULL);
@@ -598,8 +627,13 @@ static void addfb25_ytile(int fd)
 	}
 
 	igt_fixture {
-		gem_close(fd, gem_bo);
-		gem_close(fd, gem_bo_small);
+		if (is_dumb) {
+			kmstest_dumb_destroy(fd, gem_bo);
+			kmstest_dumb_destroy(fd, gem_bo_small);
+		} else {
+			gem_close(fd, gem_bo);
+			gem_close(fd, gem_bo_small);
+		}
 	}
 }
 
-- 
2.17.1



More information about the igt-dev mailing list