diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2019-12-19 13:25:45 +0100 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2019-12-19 13:25:45 +0100 |
commit | 17bca547816cdc2fabe15b38052cec07580cc8a6 (patch) | |
tree | 3f425f570a057f01bad5221e207b723ffbce2f47 | |
parent | 7650fa92f37dc58a70a3bae70c96aec479119a22 (diff) | |
download | drminfo-17bca547816cdc2fabe15b38052cec07580cc8a6.tar.gz |
add unbind test
-rw-r--r-- | drmtest.c | 43 |
1 files changed, 43 insertions, 0 deletions
@@ -7,6 +7,7 @@ #include <inttypes.h> #include <getopt.h> +#include <sys/fcntl.h> #include <sys/ioctl.h> #include <sys/mman.h> #include <sys/wait.h> @@ -334,6 +335,34 @@ static void drm_draw_dumb_fb(bool autotest, int updatetest) /* ------------------------------------------------------------------ */ +static int try_unbind(int card) +{ + char path[256]; + char *device, *name; + int fd; + + snprintf(path, sizeof(path), "/sys/class/drm/card%d/device", card); + device = realpath(path, NULL); + if (device == NULL) { + fprintf(stderr, "%s: can't resolve sysfs device path\n", __func__); + return -1; + } + + snprintf(path, sizeof(path), "%s/driver/unbind", device); + fd = open(path, O_WRONLY); + if (fd < 0) { + fprintf(stderr, "open %s: %s\n", path, strerror(errno)); + return -1; + } + + name = strrchr(device, '/') + 1; + write(fd, name, strlen(name)); + close(fd); + return 0; +} + +/* ------------------------------------------------------------------ */ + static void usage(FILE *fp) { fprintf(fp, @@ -346,6 +375,7 @@ static void usage(FILE *fp) " -a | --autotest autotest mode (don't print hardware info)\n" " --dmabuf run dma-buf tests\n" " --vgem vgem dma-buf import test\n" + " --unbind driver unbind test\n" " -c | --card <nr> pick card\n" " -o | --output <name> pick output\n" " -s | --sleep <secs> set sleep time (default: 60)\n" @@ -360,6 +390,7 @@ static void usage(FILE *fp) enum { OPT_LONG_DMABUF = 0x100, OPT_LONG_VGEM, + OPT_LONG_UNBIND, OPT_LONG_LEASE, }; @@ -386,6 +417,10 @@ struct option long_opts[] = { .has_arg = false, .val = OPT_LONG_VGEM, },{ + .name = "unbind", + .has_arg = false, + .val = OPT_LONG_UNBIND, + },{ /* --- with argument --- */ .name = "card", @@ -437,6 +472,7 @@ int main(int argc, char **argv) bool autotest = false; bool pixman = false; bool vgem = false; + bool unbind = false; int updatetest = 0; int c,i,pid,rc; @@ -458,6 +494,9 @@ int main(int argc, char **argv) case OPT_LONG_VGEM: vgem = true; break; + case OPT_LONG_UNBIND: + unbind = true; + break; case 'u': updatetest = atoi(optarg); break; @@ -614,6 +653,10 @@ int main(int argc, char **argv) } } + if (unbind) { + try_unbind(card); + } + if (autotest) fprintf(stdout, "---ok---\n"); tty_raw(); |