All of lore.kernel.org
 help / color / mirror / Atom feed
From: Deepak Rawat <drawat@vmware.com>
To: igt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org,
	linux-graphics-maintainer@vmware.com
Cc: Deepak Rawat <drawat@vmware.com>
Subject: [PATCH i-g-t 1/5] lib/igt_fb: Call dumb_destroy ioctl in case of dumb buffers
Date: Tue, 16 Oct 2018 15:23:37 -0700	[thread overview]
Message-ID: <20181016222341.1537-1-drawat@vmware.com> (raw)

vmwgfx does not support GEM interface so calling gem_close on vmwgfx
results in error.

v2: Use drmIoctl with error when ioctl() failed.

v3: Seperate ioctl wrapper.

Signed-off-by: Deepak Rawat <drawat@vmware.com>
---
 lib/igt_fb.c  |  5 ++++-
 lib/igt_kms.c | 22 ++++++++++++++++++++++
 lib/igt_kms.h |  1 +
 3 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 35be2e88..335ece69 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -2121,7 +2121,10 @@ void igt_remove_fb(int fd, struct igt_fb *fb)
 
 	cairo_surface_destroy(fb->cairo_surface);
 	do_or_die(drmModeRmFB(fd, fb->fb_id));
-	gem_close(fd, fb->gem_handle);
+	if (fb->is_dumb)
+		kmstest_dumb_destroy(fd, fb->gem_handle);
+	else
+		gem_close(fd, fb->gem_handle);
 	fb->fb_id = 0;
 }
 
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index b2cbaa11..6e499f48 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -641,6 +641,28 @@ void *kmstest_dumb_map_buffer(int fd, uint32_t handle, uint64_t size,
 	return ptr;
 }
 
+static int __kmstest_dumb_destroy(int fd, uint32_t handle)
+{
+	struct drm_mode_destroy_dumb arg = { handle };
+	int err = 0;
+
+	if (drmIoctl(fd, DRM_IOCTL_MODE_DESTROY_DUMB, &arg))
+		err = -errno;
+
+	errno = 0;
+	return err;
+}
+
+/**
+ * kmstest_dumb_destroy:
+ * @fd: Opened drm file descriptor
+ * @handle: Offset in the file referred to by fd
+ */
+void kmstest_dumb_destroy(int fd, uint32_t handle)
+{
+	igt_assert_eq(__kmstest_dumb_destroy(fd, handle), 0);
+}
+
 /*
  * Returns: the previous mode, or KD_GRAPHICS if no /dev/tty0 was
  * found and nothing was done.
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 38fa944e..cbfcced9 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -222,6 +222,7 @@ uint32_t kmstest_dumb_create(int fd, int width, int height, int bpp,
 
 void *kmstest_dumb_map_buffer(int fd, uint32_t handle, uint64_t size,
 			      unsigned prot);
+void kmstest_dumb_destroy(int fd, uint32_t handle);
 void kmstest_wait_for_pageflip(int fd);
 unsigned int kmstest_get_vblank(int fd, int pipe, unsigned int flags);
 void igt_assert_plane_visible(int fd, enum pipe pipe, bool visibility);
-- 
2.17.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

WARNING: multiple messages have this Message-ID (diff)
From: Deepak Rawat <drawat@vmware.com>
To: igt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org,
	linux-graphics-maintainer@vmware.com
Cc: Deepak Rawat <drawat@vmware.com>, petri.latvala@intel.com
Subject: [igt-dev] [PATCH i-g-t 1/5] lib/igt_fb: Call dumb_destroy ioctl in case of dumb buffers
Date: Tue, 16 Oct 2018 15:23:37 -0700	[thread overview]
Message-ID: <20181016222341.1537-1-drawat@vmware.com> (raw)

vmwgfx does not support GEM interface so calling gem_close on vmwgfx
results in error.

v2: Use drmIoctl with error when ioctl() failed.

v3: Seperate ioctl wrapper.

Signed-off-by: Deepak Rawat <drawat@vmware.com>
---
 lib/igt_fb.c  |  5 ++++-
 lib/igt_kms.c | 22 ++++++++++++++++++++++
 lib/igt_kms.h |  1 +
 3 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 35be2e88..335ece69 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -2121,7 +2121,10 @@ void igt_remove_fb(int fd, struct igt_fb *fb)
 
 	cairo_surface_destroy(fb->cairo_surface);
 	do_or_die(drmModeRmFB(fd, fb->fb_id));
-	gem_close(fd, fb->gem_handle);
+	if (fb->is_dumb)
+		kmstest_dumb_destroy(fd, fb->gem_handle);
+	else
+		gem_close(fd, fb->gem_handle);
 	fb->fb_id = 0;
 }
 
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index b2cbaa11..6e499f48 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -641,6 +641,28 @@ void *kmstest_dumb_map_buffer(int fd, uint32_t handle, uint64_t size,
 	return ptr;
 }
 
+static int __kmstest_dumb_destroy(int fd, uint32_t handle)
+{
+	struct drm_mode_destroy_dumb arg = { handle };
+	int err = 0;
+
+	if (drmIoctl(fd, DRM_IOCTL_MODE_DESTROY_DUMB, &arg))
+		err = -errno;
+
+	errno = 0;
+	return err;
+}
+
+/**
+ * kmstest_dumb_destroy:
+ * @fd: Opened drm file descriptor
+ * @handle: Offset in the file referred to by fd
+ */
+void kmstest_dumb_destroy(int fd, uint32_t handle)
+{
+	igt_assert_eq(__kmstest_dumb_destroy(fd, handle), 0);
+}
+
 /*
  * Returns: the previous mode, or KD_GRAPHICS if no /dev/tty0 was
  * found and nothing was done.
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 38fa944e..cbfcced9 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -222,6 +222,7 @@ uint32_t kmstest_dumb_create(int fd, int width, int height, int bpp,
 
 void *kmstest_dumb_map_buffer(int fd, uint32_t handle, uint64_t size,
 			      unsigned prot);
+void kmstest_dumb_destroy(int fd, uint32_t handle);
 void kmstest_wait_for_pageflip(int fd);
 unsigned int kmstest_get_vblank(int fd, int pipe, unsigned int flags);
 void igt_assert_plane_visible(int fd, enum pipe pipe, bool visibility);
-- 
2.17.1

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

             reply	other threads:[~2018-10-16 22:23 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-16 22:23 Deepak Rawat [this message]
2018-10-16 22:23 ` [igt-dev] [PATCH i-g-t 1/5] lib/igt_fb: Call dumb_destroy ioctl in case of dumb buffers Deepak Rawat
2018-10-16 22:23 ` [PATCH i-g-t 2/5] lib/igt_fb: Check for cairo surface success Deepak Rawat
2018-10-16 22:23   ` [Intel-gfx] " Deepak Rawat
2018-10-16 22:23 ` [PATCH i-g-t 3/5] lib: Don't call igt_require_fb_modifiers() when no modifier Deepak Rawat
2018-10-16 22:23   ` [igt-dev] " Deepak Rawat
2018-10-16 22:23 ` [PATCH i-g-t 4/5] tests/kms_atomic: Add a new test case for FB_DAMAGE_CLIPS plane property Deepak Rawat
2018-10-16 22:23   ` [igt-dev] " Deepak Rawat
2018-10-16 22:23 ` [PATCH i-g-t 5/5] tests/kms_selftest: Integrate kernel selftest test-drm_modeset Deepak Rawat
2018-10-16 22:23   ` [igt-dev] " Deepak Rawat
2019-06-20 13:20   ` Daniel Vetter
2019-06-20 13:20     ` [igt-dev] [Intel-gfx] " Daniel Vetter
2019-06-25  6:01     ` Arkadiusz Hiler
2019-06-25  6:01       ` [igt-dev] [Intel-gfx] " Arkadiusz Hiler
2019-06-25 15:37       ` Daniel Vetter
2019-06-25 15:37         ` [igt-dev] [Intel-gfx] " Daniel Vetter
2019-07-03 10:37         ` Daniel Vetter
2019-07-03 10:37           ` [igt-dev] [Intel-gfx] " Daniel Vetter
2019-07-03 10:53           ` Arkadiusz Hiler
2019-07-03 10:53             ` [igt-dev] [Intel-gfx] " Arkadiusz Hiler
2018-10-17  0:09 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/5] lib/igt_fb: Call dumb_destroy ioctl in case of dumb buffers Patchwork
2018-10-17  2:26 ` [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=20181016222341.1537-1-drawat@vmware.com \
    --to=drawat@vmware.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=linux-graphics-maintainer@vmware.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.