Commit b0789992 authored by Andrzej Turko's avatar Andrzej Turko Committed by Matthew Auld
Browse files

lib/i915/gem_create: Add gem_create_ext



Add a wrapper for gem_create_ext ioctl (a version of gem_create that
accepts extensions). In preparation for the driver change implementing it,
a local definition of its id and necessary structs have been added,
which are to be erased as soon as those definitions
appear in the i915_drm.h file.

The new ioctl wrapper is added to a separate file.
For consistency the wrapper of the old ioctl, gem_create
is moved from ioctl_wrappers to gem_create.
Signed-off-by: default avatarAndrzej Turko <andrzej.turko@linux.intel.com>
Cc: Zbigniew Kempczynski <zbigniew.kempczynski@intel.com>
Cc: Dominik Grzegorzek <dominik.grzegorzek@intel.com>
Cc: Petri Latvala <petri.latvala@intel.com>
Cc: Chris P Wilson <chris.p.wilson@intel.com>
Signed-off-by: Matthew Auld's avatarMatthew Auld <matthew.auld@intel.com>
Acked-by: Petri Latvala's avatarPetri Latvala <petri.latvala@intel.com>
parent 072973f7
......@@ -41,7 +41,7 @@
#include <time.h>
#include "drm.h"
#include "i915/gem.h"
#include "i915/gem_create.h"
#define COPY_BLT_CMD (2<<29|0x53<<22|0x6)
#define BLT_WRITE_ALPHA (1<<21)
......
......@@ -45,7 +45,7 @@
#include "intel_chipset.h"
#include "intel_reg.h"
#include "igt_stats.h"
#include "i915/gem.h"
#include "i915/gem_create.h"
#include "i915/gem_mman.h"
#define ENGINE_FLAGS (I915_EXEC_RING_MASK | I915_EXEC_BSD_MASK)
......
......@@ -40,7 +40,7 @@
#include "drm.h"
#include "drmtest.h"
#include "i915/gem.h"
#include "i915/gem_create.h"
#include "igt_aux.h"
#include "igt_stats.h"
#include "intel_reg.h"
......
......@@ -40,7 +40,7 @@
#include "drm.h"
#include "drmtest.h"
#include "i915/gem.h"
#include "i915/gem_create.h"
#include "intel_io.h"
#include "intel_reg.h"
#include "igt_stats.h"
......
......@@ -42,7 +42,7 @@
#include "drm.h"
#include "drmtest.h"
#include "i915/gem.h"
#include "i915/gem_create.h"
#include "igt_stats.h"
#include "intel_io.h"
#include "intel_reg.h"
......
......@@ -40,7 +40,7 @@
#include "drm.h"
#include "drmtest.h"
#include "i915/gem.h"
#include "i915/gem_create.h"
#include "igt_stats.h"
#include "intel_io.h"
#include "intel_reg.h"
......
......@@ -38,7 +38,7 @@
#include "drm.h"
#include "drmtest.h"
#include "i915/gem.h"
#include "i915/gem_create.h"
#include "i915/gem_mman.h"
#include "igt_debugfs.h"
#include "intel_reg.h"
......
......@@ -41,7 +41,7 @@
#include "drm.h"
#include "drmtest.h"
#include "i915/gem.h"
#include "i915/gem_create.h"
#include "igt_stats.h"
#include "intel_io.h"
#include "ioctl_wrappers.h"
......
......@@ -43,7 +43,7 @@
#include <sys/resource.h>
#include "drm.h"
#include "i915/gem.h"
#include "i915/gem_create.h"
#include "igt.h"
#include "igt_device.h"
......
......@@ -40,7 +40,7 @@
#include "drm.h"
#include "drmtest.h"
#include "i915/gem.h"
#include "i915/gem_create.h"
#include "igt_aux.h"
#include "igt_stats.h"
#include "ioctl_wrappers.h"
......
......@@ -40,7 +40,7 @@
#include "drm.h"
#include "drmtest.h"
#include "i915/gem.h"
#include "i915/gem_create.h"
#include "igt_aux.h"
#include "ioctl_wrappers.h"
......
......@@ -44,7 +44,7 @@
#include <linux/unistd.h>
#include "i915/gem.h"
#include "i915/gem_create.h"
#include "i915/gem_ring.h"
#define sigev_notify_thread_id _sigev_un._tid
......
......@@ -56,7 +56,7 @@
#include "igt_perf.h"
#include "sw_sync.h"
#include "i915/gem.h"
#include "i915/gem_create.h"
#include "i915/gem_engine_topology.h"
#include "i915/gem_mman.h"
......
......@@ -38,7 +38,7 @@
#include "drm.h"
#include "drmtest.h"
#include "i915/gem.h"
#include "i915/gem_create.h"
#include "igt_rand.h"
#include "intel_io.h"
#include "ioctl_wrappers.h"
......
......@@ -32,7 +32,4 @@ void gem_quiescent_gpu(int i915);
int gem_reopen_driver(int i915);
int __gem_create(int fd, uint64_t *size, uint32_t *handle);
uint32_t gem_create(int fd, uint64_t size);
#endif /* I915_GEM_H */
......@@ -5,7 +5,7 @@
#include <errno.h>
#include "gem.h"
#include "gem_create.h"
#include "i915_drm.h"
#include "igt_core.h"
#include "ioctl_wrappers.h"
......@@ -47,3 +47,44 @@ uint32_t gem_create(int fd, uint64_t size)
return handle;
}
int __gem_create_ext(int fd, uint64_t *size, uint32_t *handle,
struct i915_user_extension *ext)
{
struct drm_i915_gem_create_ext create = {
.size = *size,
.extensions = to_user_pointer(ext),
};
int err = 0;
if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_CREATE_EXT, &create) == 0) {
*handle = create.handle;
*size = create.size;
} else {
err = -errno;
igt_assume(err != 0);
}
errno = 0;
return err;
}
/**
* gem_create_ext:
* @fd: open i915 drm file descriptor
* @size: desired size of the buffer
* @ext: optional extensions chain
*
* This wraps the GEM_CREATE_EXT ioctl, which allocates a new gem buffer object
* of @size.
*
* Returns: The file-private handle of the created buffer object
*/
uint32_t gem_create_ext(int fd, uint64_t size, struct i915_user_extension *ext)
{
uint32_t handle;
igt_assert_eq(__gem_create_ext(fd, &size, &handle, ext), 0);
return handle;
}
// SPDX-License-Identifier: MIT
/*
* Copyright © 2021 Intel Corporation
*/
#ifndef GEM_CREATE_H
#define GEM_CREATE_H
#include <stdint.h>
#include "i915_drm.h"
int __gem_create(int fd, uint64_t *size, uint32_t *handle);
uint32_t gem_create(int fd, uint64_t size);
int __gem_create_ext(int fd, uint64_t *size, uint32_t *handle,
struct i915_user_extension *ext);
uint32_t gem_create_ext(int fd, uint64_t size, struct i915_user_extension *ext);
#endif /* GEM_CREATE_H */
......@@ -31,7 +31,7 @@
#include "ioctl_wrappers.h"
#include "intel_chipset.h"
#include "gem.h"
#include "gem_create.h"
#include "gem_mman.h"
#ifdef HAVE_VALGRIND
......
......@@ -27,6 +27,7 @@
#include <sys/time.h>
#include "gem.h"
#include "gem_create.h"
#include "gem_ring.h"
#include "gem_submission.h"
......
......@@ -31,6 +31,7 @@
#include <i915_drm.h>
#include "i915/gem.h"
#include "i915/gem_create.h"
#include "i915/gem_engine_topology.h"
#include "i915/gem_submission.h"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment