All of lore.kernel.org
 help / color / mirror / Atom feed
From: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
To: Arkadiusz Hiler <arkadiusz.hiler@intel.com>,
	Petri Latvala <petri.latvala@intel.com>
Cc: Janusz Krzysztofik <janusz.krzysztofik@intel.com>,
	intel-gfx@lists.freedesktop.org, igt-dev@lists.freedesktop.org
Subject: [PATCH i-g-t v4] lib/i915/gem_mman: Add a helper for obtaining MMAP_GTT interface version
Date: Fri, 31 May 2019 11:29:16 +0200	[thread overview]
Message-ID: <20190531092916.23662-1-janusz.krzysztofik@linux.intel.com> (raw)

From: Janusz Krzysztofik <janusz.krzysztofik@intel.com>

If a test calls a function which depends on availability of a specific
version of MMAP_GTT interface, an error may occur on unsupported hardware.
That may negatively affect results reported by a test framework even if
that test ignores the failure and succeedes.

This helper wraps up an IOCTL call which returns a version number of
MMAP_GTT interface.  It may be used by tests which should adjust their
scope depending on availability of a specific version of MMAP_GTT
interface.

Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@intel.com>
Cc: Antonio Argenziano <antonio.argenziano@intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
---
Changelog:
v3 -> v4:
- return errno value on failure (Chris - thanks!),
- clear errno before return, as other helpers do,
- reword the helper documentation and commit message again (Chris -
  thanks!).

v2 (internal) -> v3:
- make the code less obsucre, more explicit (Antonio - thanks!),
- reword the helper documentation and commit message.

v1 (internal) -> v2 (internal):
- minimize future potential conflicts with 
  https://patchwork.freedesktop.org/patch/294053/?series=58551&rev=1
  (no progress with than one so not waiting for it any longer):
  - convert the helper to a drop-in replacement of the one from the
    above mentioned patch, returning mappable aperture version, not
    only information on its availability,
  - drop any other wrappers,
- document the helper,
- reword commit message.

 lib/i915/gem_mman.c | 25 +++++++++++++++++++++++++
 lib/i915/gem_mman.h |  1 +
 2 files changed, 26 insertions(+)

diff --git a/lib/i915/gem_mman.c b/lib/i915/gem_mman.c
index 3cf9a6bb..2c3d6971 100644
--- a/lib/i915/gem_mman.c
+++ b/lib/i915/gem_mman.c
@@ -40,6 +40,31 @@
 #define VG(x) do {} while (0)
 #endif
 
+/**
+ * gem_mmap__gtt_version:
+ * @fd: open i915 drm file descriptor
+ *
+ * This functions wraps up an IOCTL to obtain MMAP_GTT interface version
+ *
+ * Returns: MMAP_GTT interface version, kernel error code on failure.
+ */
+int gem_mmap__gtt_version(int fd)
+{
+	int gtt_version, ret;
+	struct drm_i915_getparam gp = {
+		.param = I915_PARAM_MMAP_GTT_VERSION,
+		.value = &gtt_version,
+	};
+
+	if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp))
+		ret = errno;
+	else
+		ret = gtt_version;
+
+	errno = 0;
+	return ret;
+}
+
 /**
  * __gem_mmap__gtt:
  * @fd: open i915 drm file descriptor
diff --git a/lib/i915/gem_mman.h b/lib/i915/gem_mman.h
index f7242ed7..ab12e566 100644
--- a/lib/i915/gem_mman.h
+++ b/lib/i915/gem_mman.h
@@ -25,6 +25,7 @@
 #ifndef GEM_MMAN_H
 #define GEM_MMAN_H
 
+int gem_mmap__gtt_version(int fd);
 void *gem_mmap__gtt(int fd, uint32_t handle, uint64_t size, unsigned prot);
 void *gem_mmap__cpu(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot);
 
-- 
2.21.0

_______________________________________________
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: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
To: Arkadiusz Hiler <arkadiusz.hiler@intel.com>,
	Petri Latvala <petri.latvala@intel.com>
Cc: Janusz Krzysztofik <janusz.krzysztofik@intel.com>,
	intel-gfx@lists.freedesktop.org, igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t v4] lib/i915/gem_mman: Add a helper for obtaining MMAP_GTT interface version
Date: Fri, 31 May 2019 11:29:16 +0200	[thread overview]
Message-ID: <20190531092916.23662-1-janusz.krzysztofik@linux.intel.com> (raw)

From: Janusz Krzysztofik <janusz.krzysztofik@intel.com>

If a test calls a function which depends on availability of a specific
version of MMAP_GTT interface, an error may occur on unsupported hardware.
That may negatively affect results reported by a test framework even if
that test ignores the failure and succeedes.

This helper wraps up an IOCTL call which returns a version number of
MMAP_GTT interface.  It may be used by tests which should adjust their
scope depending on availability of a specific version of MMAP_GTT
interface.

Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@intel.com>
Cc: Antonio Argenziano <antonio.argenziano@intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
---
Changelog:
v3 -> v4:
- return errno value on failure (Chris - thanks!),
- clear errno before return, as other helpers do,
- reword the helper documentation and commit message again (Chris -
  thanks!).

v2 (internal) -> v3:
- make the code less obsucre, more explicit (Antonio - thanks!),
- reword the helper documentation and commit message.

v1 (internal) -> v2 (internal):
- minimize future potential conflicts with 
  https://patchwork.freedesktop.org/patch/294053/?series=58551&rev=1
  (no progress with than one so not waiting for it any longer):
  - convert the helper to a drop-in replacement of the one from the
    above mentioned patch, returning mappable aperture version, not
    only information on its availability,
  - drop any other wrappers,
- document the helper,
- reword commit message.

 lib/i915/gem_mman.c | 25 +++++++++++++++++++++++++
 lib/i915/gem_mman.h |  1 +
 2 files changed, 26 insertions(+)

diff --git a/lib/i915/gem_mman.c b/lib/i915/gem_mman.c
index 3cf9a6bb..2c3d6971 100644
--- a/lib/i915/gem_mman.c
+++ b/lib/i915/gem_mman.c
@@ -40,6 +40,31 @@
 #define VG(x) do {} while (0)
 #endif
 
+/**
+ * gem_mmap__gtt_version:
+ * @fd: open i915 drm file descriptor
+ *
+ * This functions wraps up an IOCTL to obtain MMAP_GTT interface version
+ *
+ * Returns: MMAP_GTT interface version, kernel error code on failure.
+ */
+int gem_mmap__gtt_version(int fd)
+{
+	int gtt_version, ret;
+	struct drm_i915_getparam gp = {
+		.param = I915_PARAM_MMAP_GTT_VERSION,
+		.value = &gtt_version,
+	};
+
+	if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp))
+		ret = errno;
+	else
+		ret = gtt_version;
+
+	errno = 0;
+	return ret;
+}
+
 /**
  * __gem_mmap__gtt:
  * @fd: open i915 drm file descriptor
diff --git a/lib/i915/gem_mman.h b/lib/i915/gem_mman.h
index f7242ed7..ab12e566 100644
--- a/lib/i915/gem_mman.h
+++ b/lib/i915/gem_mman.h
@@ -25,6 +25,7 @@
 #ifndef GEM_MMAN_H
 #define GEM_MMAN_H
 
+int gem_mmap__gtt_version(int fd);
 void *gem_mmap__gtt(int fd, uint32_t handle, uint64_t size, unsigned prot);
 void *gem_mmap__cpu(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot);
 
-- 
2.21.0

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

             reply	other threads:[~2019-05-31  9:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-31  9:29 Janusz Krzysztofik [this message]
2019-05-31  9:29 ` [igt-dev] [PATCH i-g-t v4] lib/i915/gem_mman: Add a helper for obtaining MMAP_GTT interface version Janusz Krzysztofik
2019-05-31  9:35 ` Chris Wilson
2019-05-31  9:35   ` [igt-dev] " Chris Wilson
2019-05-31  9:42   ` Janusz Krzysztofik
2019-05-31  9:42     ` [igt-dev] " Janusz Krzysztofik
2019-05-31 14:49 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2019-06-01 12:41 ` [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=20190531092916.23662-1-janusz.krzysztofik@linux.intel.com \
    --to=janusz.krzysztofik@linux.intel.com \
    --cc=arkadiusz.hiler@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=janusz.krzysztofik@intel.com \
    --cc=petri.latvala@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 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.