Commit c81d293a authored by Micah Fedke's avatar Micah Fedke Committed by Thomas Wood

convert drm_open_any*() calls to drm_open_driver*(DRIVER_INTEL) calls with cocci

Apply the new API to all call sites within the test suite using the following
semantic patch:

// Semantic patch for replacing drm_open_any* with arch-specific drm_open_driver* calls
@@
identifier i =~ "\bdrm_open_any\b";
@@
- i()
+ drm_open_driver(DRIVER_INTEL)

@@
identifier i =~ "\bdrm_open_any_master\b";
@@
- i()
+ drm_open_driver_master(DRIVER_INTEL)

@@
identifier i =~ "\bdrm_open_any_render\b";
@@
- i()
+ drm_open_driver_render(DRIVER_INTEL)

@@
identifier i =~ "\b__drm_open_any\b";
@@
- i()
+ __drm_open_driver(DRIVER_INTEL)
Signed-off-by: 's avatarMicah Fedke <micah.fedke@collabora.co.uk>
Signed-off-by: 's avatarThomas Wood <thomas.wood@intel.com>
parent e2241805
......@@ -88,7 +88,7 @@ static void make_busy(int fd, uint32_t handle)
int main(int argc, char **argv)
{
int fd = drm_open_any();
int fd = drm_open_driver(DRIVER_INTEL);
int size = 0;
int busy = 0;
int reps = 13;
......
......@@ -89,7 +89,7 @@ static int loop(unsigned ring, int reps, enum mode mode)
int count, fd;
uint32_t ctx;
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
memset(&gem_exec, 0, sizeof(gem_exec));
gem_exec.handle = batch(fd);
......
......@@ -76,7 +76,7 @@ static int loop(unsigned ring, int reps)
struct drm_i915_gem_exec_object2 gem_exec;
int count, fd;
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
memset(&gem_exec, 0, sizeof(gem_exec));
gem_exec.handle = batch(fd);
......
......@@ -84,7 +84,7 @@ static int run(unsigned batch_size,
mem_reloc = calloc(sizeof(*mem_reloc), num_relocs);
target = calloc(sizeof(*target), num_relocs);
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
for (n = 0; n < num_objects; n++)
gem_exec[n].handle = gem_create(fd, 4096);
......
......@@ -118,7 +118,7 @@ static void replay(const char *filename)
madvise(ptr, st.st_size, MADV_SEQUENTIAL);
end = ptr + st.st_size;
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
clock_gettime(CLOCK_MONOTONIC, &t_start);
do {
......
......@@ -54,7 +54,7 @@ static uint64_t elapsed(const struct timespec *start,
int main(int argc, char **argv)
{
int fd = drm_open_any();
int fd = drm_open_driver(DRIVER_INTEL);
enum map {CPU, GTT, WC} map = CPU;
enum dir {READ, WRITE, CLEAR, FAULT} dir = READ;
int tiling = I915_TILING_NONE;
......
......@@ -54,7 +54,7 @@ static uint64_t elapsed(const struct timespec *start,
int main(int argc, char **argv)
{
int fd = drm_open_any();
int fd = drm_open_driver(DRIVER_INTEL);
int domain = I915_GEM_DOMAIN_GTT;
enum dir { READ, WRITE } dir = READ;
void *buf = malloc(OBJECT_SIZE);
......
......@@ -515,7 +515,7 @@ int main(int argc, char **argv)
igt_subtest_init(argc, argv);
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
igt_assert(fd >= 0);
ret = has_userptr(fd);
......
......@@ -124,7 +124,7 @@ int main(int argc, char **argv)
struct intel_batchbuffer *batch;
int i;
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
drm_intel_bufmgr_gem_enable_reuse(bufmgr);
......
......@@ -122,7 +122,7 @@ int main(int argc, char **argv)
struct intel_batchbuffer *batch;
int i;
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
drm_intel_bufmgr_gem_enable_reuse(bufmgr);
......
......@@ -125,7 +125,7 @@ int main(int argc, char **argv)
struct intel_batchbuffer *batch;
int i;
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
drm_intel_bufmgr_gem_enable_reuse(bufmgr);
......
......@@ -135,7 +135,7 @@ int main(int argc, char **argv)
struct intel_batchbuffer *batch;
int i;
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
drm_intel_bufmgr_gem_enable_reuse(bufmgr);
......
......@@ -161,7 +161,7 @@ int main(int argc, char **argv)
}
}
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
if (!crtc0_active(fd)) {
fprintf(stderr, "CRTC/pipe 0 not active\n");
return 77;
......
......@@ -551,7 +551,7 @@ int main(int argc, char* argv[]) {
*/
if (!clear_waits) {
int dh_handle;
drm_fd = drm_open_any();
drm_fd = drm_open_driver(DRIVER_INTEL);
bufmgr = drm_intel_bufmgr_gem_init(drm_fd, 4096);
setup_hw_bits();
......
......@@ -200,7 +200,7 @@ int igt_fork_hang_helper(void)
if (igt_only_list_subtests())
return 1;
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
if (fd == -1)
return 0;
......
......@@ -1957,7 +1957,7 @@ void igt_enable_connectors(void)
drmModeConnector *c;
int drm_fd;
drm_fd = drm_open_any();
drm_fd = drm_open_driver(DRIVER_INTEL);
res = drmModeGetResources(drm_fd);
......
......@@ -83,7 +83,7 @@ igt_main
{
/* root (which we run igt as) should always be authenticated */
igt_subtest("simple") {
int fd = drm_open_any();
int fd = drm_open_driver(DRIVER_INTEL);
igt_assert(check_auth(fd) == true);
......@@ -91,8 +91,8 @@ igt_main
}
igt_subtest("master-drop") {
int fd = drm_open_any();
int fd2 = drm_open_any();
int fd = drm_open_driver(DRIVER_INTEL);
int fd2 = drm_open_driver(DRIVER_INTEL);
igt_assert(check_auth(fd2) == true);
......
......@@ -39,7 +39,7 @@ igt_simple_main
int fd, ret;
drm_client_t client;
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
/* Look for client index 0. This should exist whether we're operating
* on an otherwise unused drm device, or the X Server is running on
......
......@@ -47,7 +47,7 @@ igt_simple_main
int fd, ret;
drm_stats_t stats;
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
ret = ioctl(fd, DRM_IOCTL_GET_STATS, &stats);
igt_assert(ret == 0);
......
......@@ -37,7 +37,7 @@ igt_simple_main
int fd;
drmVersionPtr v;
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
v = drmGetVersion(fd);
igt_assert(strlen(v->name) != 0);
igt_assert(strlen(v->date) != 0);
......
......@@ -120,7 +120,7 @@ static void test_basic_auth(int master)
int slave;
/* open slave and make sure it's NOT a master */
slave = drm_open_any();
slave = drm_open_driver(DRIVER_INTEL);
igt_require(slave >= 0);
igt_require(drmSetMaster(slave) < 0);
......@@ -151,7 +151,7 @@ igt_main
int master;
igt_fixture
master = drm_open_any_master();
master = drm_open_driver_master(DRIVER_INTEL);
igt_subtest("basic-auth")
test_basic_auth(master);
......
......@@ -239,14 +239,14 @@ pthread_t test_thread_id4;
igt_main {
igt_fixture {
fd1 = drm_open_any();
fd1 = drm_open_driver(DRIVER_INTEL);
igt_assert(fd1 >= 0);
bufmgr1 = drm_intel_bufmgr_gem_init(fd1, 8 *1024);
igt_assert(bufmgr1);
drm_intel_bufmgr_gem_enable_reuse(bufmgr1);
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
igt_assert(fd >= 0);
bufmgr = drm_intel_bufmgr_gem_init(fd, 8 *1024);
igt_assert(bufmgr);
......
......@@ -200,7 +200,7 @@ igt_main
siginterrupt(SIGALRM, 1);
igt_fixture {
fd = drm_open_any_master();
fd = drm_open_driver_master(DRIVER_INTEL);
igt_require(pipe0_enabled(fd));
}
......
......@@ -60,7 +60,7 @@ igt_simple_main
igt_skip_on_simulation();
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
drm_intel_bufmgr_gem_enable_reuse(bufmgr);
......
......@@ -59,7 +59,7 @@ igt_simple_main
igt_skip_on_simulation();
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
drm_intel_bufmgr_gem_enable_reuse(bufmgr);
......
......@@ -59,7 +59,7 @@ igt_simple_main
igt_skip_on_simulation();
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
drm_intel_bufmgr_gem_enable_reuse(bufmgr);
......
......@@ -60,7 +60,7 @@ igt_simple_main
igt_skip_on_simulation();
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
drm_intel_bufmgr_gem_enable_reuse(bufmgr);
......
......@@ -40,7 +40,7 @@ int devid;
static void
init(void)
{
drm_fd = drm_open_any();
drm_fd = drm_open_driver(DRIVER_INTEL);
devid = intel_get_drm_devid(drm_fd);
}
......
......@@ -220,7 +220,7 @@ static void test_error_state_basic(void)
clear_error_state();
assert_error_state_clear();
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
submit_batch(fd, I915_EXEC_RENDER, true);
close(fd);
......@@ -375,7 +375,7 @@ static void test_error_state_capture(unsigned ring_id,
clear_error_state();
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
gen = intel_gen(intel_get_drm_devid(fd));
cmd_parser = uses_cmd_parser(fd, gen);
......
......@@ -179,7 +179,7 @@ igt_main
igt_skip_on_simulation();
igt_fixture
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
igt_subtest("fence-restore-tiled2untiled")
test_fence_restore(fd, true, false);
......
......@@ -272,7 +272,7 @@ static int forking_evictions(int fd, struct igt_eviction_test_ops *ops,
igt_permute_array(bo, bo_count, exchange_uint32_t);
if (flags & FORKING_EVICTIONS_DUP_DRMFD) {
realfd = drm_open_any();
realfd = drm_open_driver(DRIVER_INTEL);
/* We can overwrite the bo array since we're forked. */
for (l = 0; l < bo_count; l++) {
......
......@@ -14,7 +14,7 @@ int main(void)
signal(SIGALRM, SIG_IGN);
fd = __drm_open_any();
fd = __drm_open_driver(DRIVER_INTEL);
if (fd < 0)
return IGT_EXIT_SKIP;
......
......@@ -60,7 +60,7 @@ igt_simple_main
{
int fd;
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
drm_intel_bufmgr_gem_enable_reuse(bufmgr);
......
......@@ -56,7 +56,7 @@ igt_simple_main
{
int fd;
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
drm_intel_bufmgr_gem_enable_reuse(bufmgr);
......
......@@ -96,7 +96,7 @@ igt_simple_main
drm_intel_bo *src;
int fd;
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
drm_intel_bufmgr_gem_enable_reuse(bufmgr);
......
......@@ -123,7 +123,7 @@ igt_simple_main
igt_skip_on_simulation();
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
create0(fd);
......
......@@ -231,7 +231,7 @@ int fd;
igt_main
{
igt_fixture {
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
}
igt_subtest("negative-reloc")
......
......@@ -79,7 +79,7 @@ int fd;
igt_main
{
igt_fixture
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
igt_subtest("bad-close")
test_bad_close(fd);
......
......@@ -114,7 +114,7 @@ igt_main
igt_fixture {
srandom(0xdeadbeef);
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
gem_require_caching(fd);
......
......@@ -823,7 +823,7 @@ static void run_forked(struct buffers *buffers,
igt_fork(child, 16) {
/* recreate process local variables */
buffers->count = 0;
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
batch = buffers_init(buffers, buffers->mode, fd);
......@@ -1072,7 +1072,7 @@ igt_main
all = true;
igt_fixture {
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
devid = intel_get_drm_devid(fd);
gen = intel_gen(devid);
rendercopy = igt_get_render_copyfunc(devid);
......
......@@ -246,7 +246,7 @@ igt_main
int fd, count;
igt_fixture {
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
}
igt_subtest("basic") {
......
......@@ -82,7 +82,7 @@ igt_simple_main
igt_skip_on_simulation();
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
igt_assert(bufmgr);
......
......@@ -154,7 +154,7 @@ igt_main
igt_skip_on_simulation();
igt_fixture {
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
/* This test is very sensitive to residual gtt_mm noise from previous
* tests. Try to quiet thing down first. */
......
......@@ -43,7 +43,7 @@ int fd;
igt_main
{
igt_fixture {
fd = drm_open_any_render();
fd = drm_open_driver_render(DRIVER_INTEL);
ctx_id = gem_context_create(fd);
/* Make sure a proper destroy works first */
......
......@@ -92,7 +92,7 @@ igt_main
igt_skip_on_simulation();
igt_fixture {
fd = drm_open_any_render();
fd = drm_open_driver_render(DRIVER_INTEL);
ctx_id = gem_context_create(fd);
......
......@@ -77,7 +77,7 @@ static void *work(void *arg)
int i;
if (multiple_fds)
td_fd = fd = drm_open_any_render();
td_fd = fd = drm_open_driver_render(DRIVER_INTEL);
else
td_fd = fd;
......@@ -143,7 +143,7 @@ int main(int argc, char *argv[])
igt_simple_init_parse_opts(&argc, argv, "i:c:n:mu", NULL, NULL,
opt_handler, NULL);
fd = drm_open_any_render();
fd = drm_open_driver_render(DRIVER_INTEL);
devid = intel_get_drm_devid(fd);
if (igt_run_in_simulation()) {
......
......@@ -37,7 +37,7 @@ struct drm_i915_gem_context_create create;
igt_main
{
igt_fixture
fd = drm_open_any_render();
fd = drm_open_driver_render(DRIVER_INTEL);
igt_subtest("basic") {
create.ctx_id = rand();
......
......@@ -160,7 +160,7 @@ igt_main
igt_skip_on_simulation();
igt_fixture {
fd = drm_open_any_render();
fd = drm_open_driver_render(DRIVER_INTEL);
handle = gem_create(fd, 4096);
......
......@@ -51,7 +51,7 @@ igt_main
memset(&ctx_param, 0, sizeof(ctx_param));
igt_fixture {
fd = drm_open_any_render();
fd = drm_open_driver_render(DRIVER_INTEL);
ctx = gem_context_create(fd);
}
......
......@@ -146,7 +146,7 @@ processes(void)
igt_skip_on_simulation();
fd = drm_open_any_render();
fd = drm_open_driver_render(DRIVER_INTEL);
devid = intel_get_drm_devid(fd);
aperture = gem_aperture_size(fd);
......@@ -248,7 +248,7 @@ threads(void)
igt_skip_on_simulation();
fd = drm_open_any_render();
fd = drm_open_driver_render(DRIVER_INTEL);
devid = intel_get_drm_devid(fd);
aperture = gem_aperture_size(fd);
......
......@@ -95,7 +95,7 @@ igt_simple_main
igt_skip_on_simulation();
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
devid = intel_get_drm_devid(fd);
igt_require_f(HAS_BLT_RING(devid),
"not (yet) implemented for pre-snb\n");
......
......@@ -178,7 +178,7 @@ igt_main
igt_fixture {
int i;
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
devid = intel_get_drm_devid(fd);
num_rings = gem_get_num_rings(fd);
/* Not yet implemented on pre-snb. */
......@@ -202,7 +202,7 @@ igt_main
for (i = 0; i < NUM_FD; i++) {
sprintf(buffer_name, "Target buffer %d\n", i);
mfd[i] = drm_open_any();
mfd[i] = drm_open_driver(DRIVER_INTEL);
mbufmgr[i] = drm_intel_bufmgr_gem_init(mfd[i], 4096);
igt_assert_f(mbufmgr[i],
"fail to initialize buf manager "
......
......@@ -175,7 +175,7 @@ igt_main
igt_skip_on_simulation();
igt_fixture {
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
igt_require_hang_ring(fd, -1);
}
......
......@@ -192,7 +192,7 @@ igt_main
int size, count;
igt_fixture {
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
}
igt_subtest("minor-normal") {
......
......@@ -189,7 +189,7 @@ igt_main
fd = -1;
igt_fixture {
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
size = 1024 * 1024;
count = 3*gem_aperture_size(fd) / size / 4;
......
......@@ -55,7 +55,7 @@ igt_simple_main
igt_skip_on_simulation();
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
memset(&execobj, 0, sizeof(execobj));
memset(&execbuf, 0, sizeof(execbuf));
......
......@@ -152,7 +152,7 @@ drm_intel_bo *tmp;
igt_main
{
igt_fixture {
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
drm_intel_bufmgr_gem_enable_reuse(bufmgr);
......
......@@ -189,7 +189,7 @@ igt_simple_main
uint64_t batch_size, max, reloc_ofs;
int fd;
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
use_64bit_relocs = intel_gen(intel_get_drm_devid(fd)) >= 8;
max = 3 * gem_aperture_size(fd) / 4;
......
......@@ -207,7 +207,7 @@ static void run(int object_size, bool dumb)
int fd, len, count;
int ring;
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
if (dumb)
handle = dumb_create(fd);
else
......
......@@ -171,7 +171,7 @@ static void run(int object_size)
int fd, len;
int ring;
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
devid = intel_get_drm_devid(fd);
handle = gem_create(fd, 4096);
src = gem_create(fd, object_size);
......
......@@ -103,7 +103,7 @@ igt_simple_main
igt_skip_on_simulation();
fd = drm_open_any();
fd = drm_open_driver(DRIVER_INTEL);
memset(gem_exec, 0, sizeof(gem_exec));
for (n = 0; n < MAX_NUM_EXEC; n++)
......
......@@ -208,7 +208,7 @@ igt_main