summaryrefslogtreecommitdiff
path: root/lib/ioctl_wrappers.c
diff options
context:
space:
mode:
authorAnkitprasad Sharma <ankitprasad.r.sharma@intel.com>2016-06-06 14:52:42 +0530
committerTvrtko Ursulin <tvrtko.ursulin@intel.com>2016-06-07 15:03:37 +0100
commitbeef31a02679a914e2c101e60308511d396201fc (patch)
tree53ea7a853465404bf92545a349027f938d72797a /lib/ioctl_wrappers.c
parent293aa16a12f9e553c0dd767addd27d34c4739b39 (diff)
igt/gem_stolen: Check for available stolen memory size
Check for available stolen memory size before attempting to run the stolen memory tests. This way we make sure that we do not create objects from stolen memory without knowing the available size. This checks if the kernel supports creation of stolen backed objects before doing any operation on stolen backed objects. Also correcting the CREATE_VERSION ioctl number in getparam ioctl, due to kernel changes added in between. v2: Removed size argument for checking stolen memory availability (Tvrtko) Signed-off-by: Ankitprasad Sharma <ankitprasad.r.sharma@intel.com> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Diffstat (limited to 'lib/ioctl_wrappers.c')
-rw-r--r--lib/ioctl_wrappers.c48
1 files changed, 47 insertions, 1 deletions
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index f224091e..818853ee 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -455,7 +455,7 @@ bool gem_create__has_stolen_support(int fd)
if (has_stolen_support < 0) {
memset(&gp, 0, sizeof(gp));
- gp.param = 36; /* CREATE_VERSION */
+ gp.param = 38; /* CREATE_VERSION */
gp.value = &val;
/* Do we have the extended gem_create_ioctl? */
@@ -1230,6 +1230,52 @@ bool gem_has_bsd2(int fd)
has_bsd2 = has_param(fd, LOCAL_I915_PARAM_HAS_BSD2);
return has_bsd2;
}
+
+struct local_i915_gem_get_aperture {
+ __u64 aper_size;
+ __u64 aper_available_size;
+ __u64 version;
+ __u64 map_total_size;
+ __u64 stolen_total_size;
+};
+#define DRM_I915_GEM_GET_APERTURE 0x23
+#define LOCAL_IOCTL_I915_GEM_GET_APERTURE DRM_IOR (DRM_COMMAND_BASE + DRM_I915_GEM_GET_APERTURE, struct local_i915_gem_get_aperture)
+/**
+ * gem_total_mappable_size:
+ * @fd: open i915 drm file descriptor
+ *
+ * Feature test macro to query the kernel for the total mappable size.
+ *
+ * Returns: Total mappable address space size.
+ */
+uint64_t gem_total_mappable_size(int fd)
+{
+ struct local_i915_gem_get_aperture aperture;
+
+ memset(&aperture, 0, sizeof(aperture));
+ do_ioctl(fd, LOCAL_IOCTL_I915_GEM_GET_APERTURE, &aperture);
+
+ return aperture.map_total_size;
+}
+
+/**
+ * gem_total_stolen_size:
+ * @fd: open i915 drm file descriptor
+ *
+ * Feature test macro to query the kernel for the total stolen size.
+ *
+ * Returns: Total stolen memory.
+ */
+uint64_t gem_total_stolen_size(int fd)
+{
+ struct local_i915_gem_get_aperture aperture;
+
+ memset(&aperture, 0, sizeof(aperture));
+ do_ioctl(fd, LOCAL_IOCTL_I915_GEM_GET_APERTURE, &aperture);
+
+ return aperture.stolen_total_size;
+}
+
/**
* gem_available_aperture_size:
* @fd: open i915 drm file descriptor