summaryrefslogtreecommitdiff
path: root/lib/libdrm
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2015-12-27 09:16:54 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2015-12-27 09:16:54 +0000
commit46bb4450c74e5481f39141bea53e02c2936456cb (patch)
tree5a06c8b5e50b5ebdfde3615296340a1cf55a370f /lib/libdrm
parent5db7cad38be896315e2b897f68d1751d340a2483 (diff)
Merge libdrm 2.4.65
Diffstat (limited to 'lib/libdrm')
-rw-r--r--lib/libdrm/Makefile.am2
-rw-r--r--lib/libdrm/Makefile.in2
-rw-r--r--lib/libdrm/amdgpu/Makefile.in45
-rw-r--r--lib/libdrm/amdgpu/amdgpu_bo.c9
-rw-r--r--lib/libdrm/configure24
-rw-r--r--lib/libdrm/configure.ac6
-rw-r--r--lib/libdrm/include/drm/drm.h1
-rw-r--r--lib/libdrm/intel/intel_bufmgr_fake.c2
-rw-r--r--lib/libdrm/intel/intel_bufmgr_gem.c31
-rw-r--r--lib/libdrm/intel/intel_decode.c10
-rw-r--r--lib/libdrm/libkms/linux.c2
-rw-r--r--lib/libdrm/radeon/radeon_bo_gem.c23
-rw-r--r--lib/libdrm/radeon/radeon_bo_int.h2
-rw-r--r--lib/libdrm/radeon/radeon_cs_gem.c20
-rw-r--r--lib/libdrm/radeon/radeon_cs_int.h2
-rw-r--r--lib/libdrm/tests/Makefile.in10
-rw-r--r--lib/libdrm/xf86drm.c368
-rw-r--r--lib/libdrm/xf86drm.h34
-rw-r--r--lib/libdrm/xf86drmMode.c4
19 files changed, 498 insertions, 99 deletions
diff --git a/lib/libdrm/Makefile.am b/lib/libdrm/Makefile.am
index 55e39a56e..a7a0ccae6 100644
--- a/lib/libdrm/Makefile.am
+++ b/lib/libdrm/Makefile.am
@@ -101,7 +101,7 @@ SUBDIRS = \
libdrm_la_LTLIBRARIES = libdrm.la
libdrm_ladir = $(libdir)
libdrm_la_LDFLAGS = -version-number 2:4:0 -no-undefined
-libdrm_la_LIBADD = @CLOCK_LIB@
+libdrm_la_LIBADD = @CLOCK_LIB@ -lm
libdrm_la_CPPFLAGS = -I$(top_srcdir)/include/drm
AM_CFLAGS = \
diff --git a/lib/libdrm/Makefile.in b/lib/libdrm/Makefile.in
index 870482bb6..3289a2d63 100644
--- a/lib/libdrm/Makefile.in
+++ b/lib/libdrm/Makefile.in
@@ -490,7 +490,7 @@ SUBDIRS = \
libdrm_la_LTLIBRARIES = libdrm.la
libdrm_ladir = $(libdir)
libdrm_la_LDFLAGS = -version-number 2:4:0 -no-undefined
-libdrm_la_LIBADD = @CLOCK_LIB@
+libdrm_la_LIBADD = @CLOCK_LIB@ -lm
libdrm_la_CPPFLAGS = -I$(top_srcdir)/include/drm
AM_CFLAGS = \
$(WARN_CFLAGS) \
diff --git a/lib/libdrm/amdgpu/Makefile.in b/lib/libdrm/amdgpu/Makefile.in
index 2ea2f405c..6ff1013bd 100644
--- a/lib/libdrm/amdgpu/Makefile.in
+++ b/lib/libdrm/amdgpu/Makefile.in
@@ -76,10 +76,10 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
-subdir = amdgpu
DIST_COMMON = $(libdrm_amdgpuinclude_HEADERS) $(srcdir)/Makefile.am \
- $(srcdir)/Makefile.in $(srcdir)/libdrm_amdgpu.pc.in \
- $(top_srcdir)/build-aux/depcomp
+ $(srcdir)/Makefile.in $(srcdir)/Makefile.sources \
+ $(srcdir)/libdrm_amdgpu.pc.in $(top_srcdir)/build-aux/depcomp
+subdir = amdgpu
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
@@ -123,9 +123,10 @@ am__installdirs = "$(DESTDIR)$(libdrm_amdgpu_ladir)" \
"$(DESTDIR)$(libdrm_amdgpuincludedir)"
LTLIBRARIES = $(libdrm_amdgpu_la_LTLIBRARIES)
libdrm_amdgpu_la_DEPENDENCIES = ../libdrm.la
-am_libdrm_amdgpu_la_OBJECTS = amdgpu_bo.lo amdgpu_cs.lo \
- amdgpu_device.lo amdgpu_gpu_info.lo amdgpu_vamgr.lo \
- util_hash.lo util_hash_table.lo
+am__objects_1 = amdgpu_bo.lo amdgpu_cs.lo amdgpu_device.lo \
+ amdgpu_gpu_info.lo amdgpu_vamgr.lo util_hash.lo \
+ util_hash_table.lo
+am_libdrm_amdgpu_la_OBJECTS = $(am__objects_1)
libdrm_amdgpu_la_OBJECTS = $(am_libdrm_amdgpu_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
@@ -335,18 +336,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-AM_CFLAGS = \
- $(WARN_CFLAGS) -Wno-switch-enum \
- -I$(top_srcdir) \
- $(PTHREADSTUBS_CFLAGS) \
- -I$(top_srcdir)/include/drm
-
-libdrm_amdgpu_la_LTLIBRARIES = libdrm_amdgpu.la
-libdrm_amdgpu_ladir = $(libdir)
-libdrm_amdgpu_la_LDFLAGS = -version-number 1:0:0 -no-undefined
-libdrm_amdgpu_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@
-libdrm_amdgpu_la_SOURCES = \
- amdgpu.h \
+LIBDRM_AMDGPU_FILES := \
amdgpu_bo.c \
amdgpu_cs.c \
amdgpu_device.c \
@@ -358,10 +348,22 @@ libdrm_amdgpu_la_SOURCES = \
util_hash_table.c \
util_hash_table.h
-libdrm_amdgpuincludedir = ${includedir}/libdrm
-libdrm_amdgpuinclude_HEADERS = \
+LIBDRM_AMDGPU_H_FILES := \
amdgpu.h
+AM_CFLAGS = \
+ $(WARN_CFLAGS) \
+ -I$(top_srcdir) \
+ $(PTHREADSTUBS_CFLAGS) \
+ -I$(top_srcdir)/include/drm
+
+libdrm_amdgpu_la_LTLIBRARIES = libdrm_amdgpu.la
+libdrm_amdgpu_ladir = $(libdir)
+libdrm_amdgpu_la_LDFLAGS = -version-number 1:0:0 -no-undefined
+libdrm_amdgpu_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@
+libdrm_amdgpu_la_SOURCES = $(LIBDRM_AMDGPU_FILES)
+libdrm_amdgpuincludedir = ${includedir}/libdrm
+libdrm_amdgpuinclude_HEADERS = $(LIBDRM_AMDGPU_H_FILES)
pkgconfig_DATA = libdrm_amdgpu.pc
TESTS = amdgpu-symbol-check
EXTRA_DIST = $(TESTS)
@@ -369,7 +371,7 @@ all: all-am
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(srcdir)/Makefile.sources $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
@@ -390,6 +392,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
+$(srcdir)/Makefile.sources:
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
diff --git a/lib/libdrm/amdgpu/amdgpu_bo.c b/lib/libdrm/amdgpu/amdgpu_bo.c
index a9fa7abae..348da0031 100644
--- a/lib/libdrm/amdgpu/amdgpu_bo.c
+++ b/lib/libdrm/amdgpu/amdgpu_bo.c
@@ -290,6 +290,10 @@ int amdgpu_bo_import(amdgpu_device_handle dev,
int dma_fd;
uint64_t dma_buf_size = 0;
+ /* We must maintain a list of pairs <handle, bo>, so that we always
+ * return the same amdgpu_bo instance for the same handle. */
+ pthread_mutex_lock(&dev->bo_table_mutex);
+
/* Convert a DMA buf handle to a KMS handle now. */
if (type == amdgpu_bo_handle_type_dma_buf_fd) {
uint32_t handle;
@@ -304,6 +308,7 @@ int amdgpu_bo_import(amdgpu_device_handle dev,
/* Query the buffer size. */
size = lseek(shared_handle, 0, SEEK_END);
if (size == (off_t)-1) {
+ pthread_mutex_unlock(&dev->bo_table_mutex);
amdgpu_close_kms_handle(dev, handle);
return -errno;
}
@@ -313,10 +318,6 @@ int amdgpu_bo_import(amdgpu_device_handle dev,
shared_handle = handle;
}
- /* We must maintain a list of pairs <handle, bo>, so that we always
- * return the same amdgpu_bo instance for the same handle. */
- pthread_mutex_lock(&dev->bo_table_mutex);
-
/* If we have already created a buffer with this handle, find it. */
switch (type) {
case amdgpu_bo_handle_type_gem_flink_name:
diff --git a/lib/libdrm/configure b/lib/libdrm/configure
index 3964f0887..a8cae76ce 100644
--- a/lib/libdrm/configure
+++ b/lib/libdrm/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for libdrm 2.4.64.
+# Generated by GNU Autoconf 2.69 for libdrm 2.4.65.
#
# Report bugs to <https://bugs.freedesktop.org/enter_bug.cgi?product=DRI>.
#
@@ -591,8 +591,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='libdrm'
PACKAGE_TARNAME='libdrm'
-PACKAGE_VERSION='2.4.64'
-PACKAGE_STRING='libdrm 2.4.64'
+PACKAGE_VERSION='2.4.65'
+PACKAGE_STRING='libdrm 2.4.65'
PACKAGE_BUGREPORT='https://bugs.freedesktop.org/enter_bug.cgi?product=DRI'
PACKAGE_URL=''
@@ -1418,7 +1418,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures libdrm 2.4.64 to adapt to many kinds of systems.
+\`configure' configures libdrm 2.4.65 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1488,7 +1488,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of libdrm 2.4.64:";;
+ short | recursive ) echo "Configuration of libdrm 2.4.65:";;
esac
cat <<\_ACEOF
@@ -1654,7 +1654,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-libdrm configure 2.4.64
+libdrm configure 2.4.65
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2077,7 +2077,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by libdrm $as_me 2.4.64, which was
+It was created by libdrm $as_me 2.4.65, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -3277,7 +3277,7 @@ fi
# Define the identity of the package.
PACKAGE='libdrm'
- VERSION='2.4.64'
+ VERSION='2.4.65'
cat >>confdefs.h <<_ACEOF
@@ -12915,8 +12915,8 @@ MAYBE_WARN="-Wall -Wextra \
-Wpacked -Wswitch-enum -Wmissing-format-attribute \
-Wstrict-aliasing=2 -Winit-self \
-Wdeclaration-after-statement -Wold-style-definition \
--Wno-missing-field-initializers -Wno-unused-parameter \
--Wno-attributes -Wno-long-long -Winline"
+-Wno-unused-parameter \
+-Wno-attributes -Wno-long-long -Winline -Wshadow"
# invalidate cached value if MAYBE_WARN has changed
if test "x$libdrm_cv_warn_maybe" != "x$MAYBE_WARN"; then
@@ -14557,7 +14557,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by libdrm $as_me 2.4.64, which was
+This file was extended by libdrm $as_me 2.4.65, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -14623,7 +14623,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-libdrm config.status 2.4.64
+libdrm config.status 2.4.65
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
diff --git a/lib/libdrm/configure.ac b/lib/libdrm/configure.ac
index 705ac3e70..89a3a468e 100644
--- a/lib/libdrm/configure.ac
+++ b/lib/libdrm/configure.ac
@@ -20,7 +20,7 @@
AC_PREREQ([2.63])
AC_INIT([libdrm],
- [2.4.64],
+ [2.4.65],
[https://bugs.freedesktop.org/enter_bug.cgi?product=DRI],
[libdrm])
@@ -173,8 +173,8 @@ MAYBE_WARN="-Wall -Wextra \
-Wpacked -Wswitch-enum -Wmissing-format-attribute \
-Wstrict-aliasing=2 -Winit-self \
-Wdeclaration-after-statement -Wold-style-definition \
--Wno-missing-field-initializers -Wno-unused-parameter \
--Wno-attributes -Wno-long-long -Winline"
+-Wno-unused-parameter \
+-Wno-attributes -Wno-long-long -Winline -Wshadow"
# invalidate cached value if MAYBE_WARN has changed
if test "x$libdrm_cv_warn_maybe" != "x$MAYBE_WARN"; then
diff --git a/lib/libdrm/include/drm/drm.h b/lib/libdrm/include/drm/drm.h
index 3f70d7748..2f7063741 100644
--- a/lib/libdrm/include/drm/drm.h
+++ b/lib/libdrm/include/drm/drm.h
@@ -818,6 +818,7 @@ struct drm_event_vblank {
#define DRM_CAP_PRIME 0x5
#define DRM_CAP_TIMESTAMP_MONOTONIC 0x6
#define DRM_CAP_ASYNC_PAGE_FLIP 0x7
+#define DRM_CAP_ADDFB2_MODIFIERS 0x10
#define DRM_PRIME_CAP_IMPORT 0x1
#define DRM_PRIME_CAP_EXPORT 0x2
diff --git a/lib/libdrm/intel/intel_bufmgr_fake.c b/lib/libdrm/intel/intel_bufmgr_fake.c
index 75387b7cf..551e05dee 100644
--- a/lib/libdrm/intel/intel_bufmgr_fake.c
+++ b/lib/libdrm/intel/intel_bufmgr_fake.c
@@ -1460,7 +1460,7 @@ restart:
assert(ret == 0);
if (bufmgr_fake->exec != NULL) {
- int ret = bufmgr_fake->exec(bo, used, bufmgr_fake->exec_priv);
+ ret = bufmgr_fake->exec(bo, used, bufmgr_fake->exec_priv);
if (ret != 0) {
pthread_mutex_unlock(&bufmgr_fake->lock);
return ret;
diff --git a/lib/libdrm/intel/intel_bufmgr_gem.c b/lib/libdrm/intel/intel_bufmgr_gem.c
index 03dfc88f7..ef437cbd2 100644
--- a/lib/libdrm/intel/intel_bufmgr_gem.c
+++ b/lib/libdrm/intel/intel_bufmgr_gem.c
@@ -278,6 +278,11 @@ static void drm_intel_gem_bo_unreference(drm_intel_bo *bo);
static void drm_intel_gem_bo_free(drm_intel_bo *bo);
+static inline drm_intel_bo_gem *to_bo_gem(drm_intel_bo *bo)
+{
+ return (drm_intel_bo_gem *)bo;
+}
+
static unsigned long
drm_intel_gem_bo_tile_size(drm_intel_bufmgr_gem *bufmgr_gem, unsigned long size,
uint32_t *tiling_mode)
@@ -2127,11 +2132,10 @@ drm_intel_gem_bo_exec(drm_intel_bo *bo, int used,
drm_clip_rect_t * cliprects, int num_cliprects, int DR4)
{
drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *) bo->bufmgr;
- drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo;
struct drm_i915_gem_execbuffer execbuf;
int ret, i;
- if (bo_gem->has_error)
+ if (to_bo_gem(bo)->has_error)
return -ENOMEM;
pthread_mutex_lock(&bufmgr_gem->lock);
@@ -2176,8 +2180,7 @@ drm_intel_gem_bo_exec(drm_intel_bo *bo, int used,
drm_intel_gem_dump_validation_list(bufmgr_gem);
for (i = 0; i < bufmgr_gem->exec_count; i++) {
- drm_intel_bo *bo = bufmgr_gem->exec_bos[i];
- drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo;
+ drm_intel_bo_gem *bo_gem = to_bo_gem(bufmgr_gem->exec_bos[i]);
bo_gem->idle = false;
@@ -2202,6 +2205,9 @@ do_exec2(drm_intel_bo *bo, int used, drm_intel_context *ctx,
int ret = 0;
int i;
+ if (to_bo_gem(bo)->has_error)
+ return -ENOMEM;
+
switch (flags & 0x7) {
default:
return -EINVAL;
@@ -2274,8 +2280,7 @@ skip_execution:
drm_intel_gem_dump_validation_list(bufmgr_gem);
for (i = 0; i < bufmgr_gem->exec_count; i++) {
- drm_intel_bo *bo = bufmgr_gem->exec_bos[i];
- drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *)bo;
+ drm_intel_bo_gem *bo_gem = to_bo_gem(bufmgr_gem->exec_bos[i]);
bo_gem->idle = false;
@@ -2442,14 +2447,19 @@ drm_intel_bo_gem_create_from_prime(drm_intel_bufmgr *bufmgr, int prime_fd, int s
struct drm_i915_gem_get_tiling get_tiling;
drmMMListHead *list;
+ pthread_mutex_lock(&bufmgr_gem->lock);
ret = drmPrimeFDToHandle(bufmgr_gem->fd, prime_fd, &handle);
+ if (ret) {
+ DBG("create_from_prime: failed to obtain handle from fd: %s\n", strerror(errno));
+ pthread_mutex_unlock(&bufmgr_gem->lock);
+ return NULL;
+ }
/*
* See if the kernel has already returned this buffer to us. Just as
* for named buffers, we must not create two bo's pointing at the same
* kernel object
*/
- pthread_mutex_lock(&bufmgr_gem->lock);
for (list = bufmgr_gem->named.next;
list != &bufmgr_gem->named;
list = list->next) {
@@ -2461,12 +2471,6 @@ drm_intel_bo_gem_create_from_prime(drm_intel_bufmgr *bufmgr, int prime_fd, int s
}
}
- if (ret) {
- fprintf(stderr,"ret is %d %d\n", ret, errno);
- pthread_mutex_unlock(&bufmgr_gem->lock);
- return NULL;
- }
-
bo_gem = calloc(1, sizeof(*bo_gem));
if (!bo_gem) {
pthread_mutex_unlock(&bufmgr_gem->lock);
@@ -2507,6 +2511,7 @@ drm_intel_bo_gem_create_from_prime(drm_intel_bufmgr *bufmgr, int prime_fd, int s
DRM_IOCTL_I915_GEM_GET_TILING,
&get_tiling);
if (ret != 0) {
+ DBG("create_from_prime: failed to get tiling: %s\n", strerror(errno));
drm_intel_gem_bo_unreference(&bo_gem->bo);
return NULL;
}
diff --git a/lib/libdrm/intel/intel_decode.c b/lib/libdrm/intel/intel_decode.c
index 2b902a39f..e7aef742a 100644
--- a/lib/libdrm/intel/intel_decode.c
+++ b/lib/libdrm/intel/intel_decode.c
@@ -38,6 +38,9 @@
#include "intel_chipset.h"
#include "intel_bufmgr.h"
+/* The compiler throws ~90 warnings. Do not spam the build, until we fix them. */
+#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
+
/* Struct for tracking drm_intel_decode state. */
struct drm_intel_decode {
/** stdio file where the output should land. Defaults to stdout. */
@@ -3630,7 +3633,6 @@ decode_3d_965(struct drm_intel_decode *ctx)
case 0x7a00:
if (IS_GEN6(devid) || IS_GEN7(devid)) {
- unsigned int i;
if (len != 4 && len != 5)
fprintf(out, "Bad count in PIPE_CONTROL\n");
@@ -3732,8 +3734,6 @@ decode_3d_965(struct drm_intel_decode *ctx)
if (opcode_3d->func) {
return opcode_3d->func(ctx);
} else {
- unsigned int i;
-
instr_out(ctx, 0, "%s\n", opcode_3d->name);
for (i = 1; i < len; i++) {
@@ -3883,9 +3883,9 @@ drm_intel_decode_set_head_tail(struct drm_intel_decode *ctx,
void
drm_intel_decode_set_output_file(struct drm_intel_decode *ctx,
- FILE *out)
+ FILE *output)
{
- ctx->out = out;
+ ctx->out = output;
}
/**
diff --git a/lib/libdrm/libkms/linux.c b/lib/libdrm/libkms/linux.c
index b735527c8..6e0da830f 100644
--- a/lib/libdrm/libkms/linux.c
+++ b/lib/libdrm/libkms/linux.c
@@ -149,7 +149,7 @@ struct create_record
int (*func)(int fd, struct kms_driver **out);
};
-static struct create_record table[] = {
+static const struct create_record table[] = {
{ 0x8086, 0x2a42, intel_create }, /* i965 */
#ifdef HAVE_VMWGFX
{ 0x15ad, 0x0405, vmwgfx_create }, /* VMware vGPU */
diff --git a/lib/libdrm/radeon/radeon_bo_gem.c b/lib/libdrm/radeon/radeon_bo_gem.c
index 7fdd437a1..c9fe19ff4 100644
--- a/lib/libdrm/radeon/radeon_bo_gem.c
+++ b/lib/libdrm/radeon/radeon_bo_gem.c
@@ -270,17 +270,18 @@ static int bo_get_tiling(struct radeon_bo_int *boi, uint32_t *tiling_flags,
return r;
}
-static struct radeon_bo_funcs bo_gem_funcs = {
- bo_open,
- bo_ref,
- bo_unref,
- bo_map,
- bo_unmap,
- bo_wait,
- NULL,
- bo_set_tiling,
- bo_get_tiling,
- bo_is_busy,
+static const struct radeon_bo_funcs bo_gem_funcs = {
+ .bo_open = bo_open,
+ .bo_ref = bo_ref,
+ .bo_unref = bo_unref,
+ .bo_map = bo_map,
+ .bo_unmap = bo_unmap,
+ .bo_wait = bo_wait,
+ .bo_is_static = NULL,
+ .bo_set_tiling = bo_set_tiling,
+ .bo_get_tiling = bo_get_tiling,
+ .bo_is_busy = bo_is_busy,
+ .bo_is_referenced_by_cs = NULL,
};
struct radeon_bo_manager *radeon_bo_manager_gem_ctor(int fd)
diff --git a/lib/libdrm/radeon/radeon_bo_int.h b/lib/libdrm/radeon/radeon_bo_int.h
index 9589ead10..de981b0af 100644
--- a/lib/libdrm/radeon/radeon_bo_int.h
+++ b/lib/libdrm/radeon/radeon_bo_int.h
@@ -2,7 +2,7 @@
#define RADEON_BO_INT
struct radeon_bo_manager {
- struct radeon_bo_funcs *funcs;
+ const struct radeon_bo_funcs *funcs;
int fd;
};
diff --git a/lib/libdrm/radeon/radeon_cs_gem.c b/lib/libdrm/radeon/radeon_cs_gem.c
index 1962e915b..cdec64e0b 100644
--- a/lib/libdrm/radeon/radeon_cs_gem.c
+++ b/lib/libdrm/radeon/radeon_cs_gem.c
@@ -514,16 +514,16 @@ static void cs_gem_print(struct radeon_cs_int *cs, FILE *file)
}
}
-static struct radeon_cs_funcs radeon_cs_gem_funcs = {
- cs_gem_create,
- cs_gem_write_reloc,
- cs_gem_begin,
- cs_gem_end,
- cs_gem_emit,
- cs_gem_destroy,
- cs_gem_erase,
- cs_gem_need_flush,
- cs_gem_print,
+static const struct radeon_cs_funcs radeon_cs_gem_funcs = {
+ .cs_create = cs_gem_create,
+ .cs_write_reloc = cs_gem_write_reloc,
+ .cs_begin = cs_gem_begin,
+ .cs_end = cs_gem_end,
+ .cs_emit = cs_gem_emit,
+ .cs_destroy = cs_gem_destroy,
+ .cs_erase = cs_gem_erase,
+ .cs_need_flush = cs_gem_need_flush,
+ .cs_print = cs_gem_print,
};
static int radeon_get_device_id(int fd, uint32_t *device_id)
diff --git a/lib/libdrm/radeon/radeon_cs_int.h b/lib/libdrm/radeon/radeon_cs_int.h
index 6cee57427..d906ad438 100644
--- a/lib/libdrm/radeon/radeon_cs_int.h
+++ b/lib/libdrm/radeon/radeon_cs_int.h
@@ -58,7 +58,7 @@ struct radeon_cs_funcs {
};
struct radeon_cs_manager {
- struct radeon_cs_funcs *funcs;
+ const struct radeon_cs_funcs *funcs;
int fd;
int32_t vram_limit, gart_limit;
int32_t vram_write_used, gart_write_used;
diff --git a/lib/libdrm/tests/Makefile.in b/lib/libdrm/tests/Makefile.in
index f324300cf..3f062db05 100644
--- a/lib/libdrm/tests/Makefile.in
+++ b/lib/libdrm/tests/Makefile.in
@@ -101,14 +101,13 @@ am__EXEEXT_2 = drmsl$(EXEEXT) hash$(EXEEXT) random$(EXEEXT) \
$(am__EXEEXT_1)
dristat_SOURCES = dristat.c
dristat_OBJECTS = dristat.$(OBJEXT)
-dristat_LDADD = $(LDADD)
-am__DEPENDENCIES_1 =
-@HAVE_LIBUDEV_TRUE@am__DEPENDENCIES_2 = libdrmtest.la \
-@HAVE_LIBUDEV_TRUE@ $(am__DEPENDENCIES_1)
-dristat_DEPENDENCIES = $(top_builddir)/libdrm.la $(am__DEPENDENCIES_2)
+dristat_DEPENDENCIES =
drmsl_SOURCES = drmsl.c
drmsl_OBJECTS = drmsl.$(OBJEXT)
drmsl_LDADD = $(LDADD)
+am__DEPENDENCIES_1 =
+@HAVE_LIBUDEV_TRUE@am__DEPENDENCIES_2 = libdrmtest.la \
+@HAVE_LIBUDEV_TRUE@ $(am__DEPENDENCIES_1)
drmsl_DEPENDENCIES = $(top_builddir)/libdrm.la $(am__DEPENDENCIES_2)
drmstat_SOURCES = drmstat.c
drmstat_OBJECTS = drmstat.$(OBJEXT)
@@ -407,6 +406,7 @@ AM_CFLAGS = \
-I $(top_srcdir)
LDADD = $(top_builddir)/libdrm.la $(am__append_7)
+dristat_LDADD = -lm
@HAVE_LIBUDEV_TRUE@check_LTLIBRARIES = libdrmtest.la
@HAVE_LIBUDEV_TRUE@libdrmtest_la_SOURCES = \
@HAVE_LIBUDEV_TRUE@ drmtest.c \
diff --git a/lib/libdrm/xf86drm.c b/lib/libdrm/xf86drm.c
index 47b2af3a6..c99df1f0a 100644
--- a/lib/libdrm/xf86drm.c
+++ b/lib/libdrm/xf86drm.c
@@ -55,6 +55,7 @@
#ifdef HAVE_SYS_MKDEV_H
# include <sys/mkdev.h> /* defines major(), minor(), and makedev() on Solaris */
#endif
+#include <math.h>
/* Not all systems have MAP_FAILED defined */
#ifndef MAP_FAILED
@@ -137,7 +138,8 @@ drmMsg(const char *format, ...)
{
va_list ap;
const char *env;
- if (((env = getenv("LIBGL_DEBUG")) && strstr(env, "verbose")) || drm_server_info)
+ if (((env = getenv("LIBGL_DEBUG")) && strstr(env, "verbose")) ||
+ (drm_server_info && drm_server_info->debug_print))
{
va_start(ap, format);
if (drm_server_info) {
@@ -354,7 +356,7 @@ static int drmOpenDevice(dev_t dev, int minor, int type)
sprintf(buf, dev_name, DRM_DIR_NAME, minor);
drmMsg("drmOpenDevice: node name is %s\n", buf);
- if (drm_server_info) {
+ if (drm_server_info && drm_server_info->get_perms) {
drm_server_info->get_perms(&serv_group, &serv_mode);
devmode = serv_mode ? serv_mode : DRM_DEV_MODE;
devmode &= ~(S_IXUSR|S_IXGRP|S_IXOTH);
@@ -378,7 +380,7 @@ static int drmOpenDevice(dev_t dev, int minor, int type)
mknod(buf, S_IFCHR | devmode, dev);
}
- if (drm_server_info) {
+ if (drm_server_info && drm_server_info->get_perms) {
group = ((int)serv_group >= 0) ? serv_group : DRM_DEV_GID;
chown_check_return(buf, user, group);
chmod(buf, devmode);
@@ -428,7 +430,7 @@ wait_for_udev:
return DRM_ERR_NOT_ROOT;
remove(buf);
mknod(buf, S_IFCHR | devmode, dev);
- if (drm_server_info) {
+ if (drm_server_info && drm_server_info->get_perms) {
chown_check_return(buf, user, group);
chmod(buf, devmode);
}
@@ -761,7 +763,8 @@ int drmOpen(const char *name, const char *busid)
*/
int drmOpenWithType(const char *name, const char *busid, int type)
{
- if (!drmAvailable() && name != NULL && drm_server_info) {
+ if (!drmAvailable() && name != NULL && drm_server_info &&
+ drm_server_info->load_module) {
/* try to load the kernel module */
if (!drm_server_info->load_module(name)) {
drmMsg("[drm] failed to load kernel module \"%s\"\n", name);
@@ -2836,11 +2839,12 @@ static char *drmGetMinorNameForFD(int fd, int type)
while (readdir_r(sysdir, pent, &ent) == 0 && ent != NULL) {
if (strncmp(ent->d_name, name, len) == 0) {
+ snprintf(dev_name, sizeof(dev_name), DRM_DIR_NAME "/%s",
+ ent->d_name);
+
free(pent);
closedir(sysdir);
- snprintf(dev_name, sizeof(dev_name), DRM_DIR_NAME "/%s",
- ent->d_name);
return strdup(dev_name);
}
}
@@ -2862,3 +2866,353 @@ char *drmGetRenderDeviceNameFromFd(int fd)
{
return drmGetMinorNameForFD(fd, DRM_NODE_RENDER);
}
+
+#ifdef __linux__
+static int drmParseSubsystemType(const char *str)
+{
+ char link[PATH_MAX + 1] = "";
+ char *name;
+
+ if (readlink(str, link, PATH_MAX) < 0)
+ return -EINVAL;
+
+ name = strrchr(link, '/');
+ if (!name)
+ return -EINVAL;
+
+ name++;
+
+ if (strncmp(name, "pci", 3) == 0)
+ return DRM_BUS_PCI;
+
+ return -EINVAL;
+}
+
+static int drmParsePciBusInfo(const char *str, drmPciBusInfoPtr info)
+{
+ int domain, bus, dev, func;
+ char *value;
+
+ if (str == NULL)
+ return -EINVAL;
+
+ value = strstr(str, "PCI_SLOT_NAME=");
+ if (value == NULL)
+ return -EINVAL;
+
+ value += strlen("PCI_SLOT_NAME=");
+
+ if (sscanf(value, "%04x:%02x:%02x.%1u",
+ &domain, &bus, &dev, &func) != 4)
+ return -EINVAL;
+
+ info->domain = domain;
+ info->bus = bus;
+ info->dev = dev;
+ info->func = func;
+
+ return 0;
+}
+
+static int drmSameDevice(drmDevicePtr a, drmDevicePtr b)
+{
+ if (a->bustype != b->bustype)
+ return 0;
+
+ switch (a->bustype) {
+ case DRM_BUS_PCI:
+ if (memcmp(a->businfo.pci, b->businfo.pci, sizeof(drmPciBusInfo)) == 0)
+ return 1;
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+static int drmGetNodeType(const char *name)
+{
+ if (strncmp(name, DRM_PRIMARY_MINOR_NAME,
+ sizeof(DRM_PRIMARY_MINOR_NAME) - 1) == 0)
+ return DRM_NODE_PRIMARY;
+
+ if (strncmp(name, DRM_CONTROL_MINOR_NAME,
+ sizeof(DRM_CONTROL_MINOR_NAME ) - 1) == 0)
+ return DRM_NODE_CONTROL;
+
+ if (strncmp(name, DRM_RENDER_MINOR_NAME,
+ sizeof(DRM_RENDER_MINOR_NAME) - 1) == 0)
+ return DRM_NODE_RENDER;
+
+ return -EINVAL;
+}
+
+static int drmParsePciDeviceInfo(const unsigned char *config,
+ drmPciDeviceInfoPtr device)
+{
+ if (config == NULL)
+ return -EINVAL;
+
+ device->vendor_id = config[0] | (config[1] << 8);
+ device->device_id = config[2] | (config[3] << 8);
+ device->revision_id = config[8];
+ device->subvendor_id = config[44] | (config[45] << 8);
+ device->subdevice_id = config[46] | (config[47] << 8);
+
+ return 0;
+}
+
+static void drmFreeDevice(drmDevicePtr device)
+{
+ int i;
+
+ if (device == NULL)
+ return;
+
+ if (device->nodes != NULL)
+ for (i = 0; i < DRM_NODE_MAX; i++)
+ free(device->nodes[i]);
+
+ free(device->nodes);
+ free(device->businfo.pci);
+ free(device->deviceinfo.pci);
+}
+
+void drmFreeDevices(drmDevicePtr devices[], int count)
+{
+ int i;
+
+ if (devices == NULL)
+ return;
+
+ for (i = 0; i < count; i++) {
+ drmFreeDevice(devices[i]);
+ free(devices[i]);
+ devices[i] = NULL;
+ }
+}
+
+/**
+ * Get drm devices on the system
+ *
+ * \param devices the array of devices with drmDevicePtr elements
+ * can be NULL to get the device number first
+ * \param max_devices the maximum number of devices for the array
+ *
+ * \return on error - negative error code,
+ * if devices is NULL - total number of devices available on the system,
+ * alternatively the number of devices stored in devices[], which is
+ * capped by the max_devices.
+ */
+int drmGetDevices(drmDevicePtr devices[], int max_devices)
+{
+ drmDevicePtr devs = NULL;
+ drmPciBusInfoPtr pcibus = NULL;
+ drmPciDeviceInfoPtr pcidevice = NULL;
+ DIR *sysdir = NULL;
+ struct dirent *dent = NULL;
+ struct stat sbuf = {0};
+ char node[PATH_MAX + 1] = "";
+ char path[PATH_MAX + 1] = "";
+ char data[128] = "";
+ unsigned char config[64] = "";
+ int node_type, subsystem_type;
+ int maj, min;
+ int fd;
+ int ret, i = 0, j, node_count, device_count = 0;
+ int max_count = 16;
+ int *duplicated = NULL;
+
+ devs = calloc(max_count, sizeof(*devs));
+ if (devs == NULL)
+ return -ENOMEM;
+
+ sysdir = opendir(DRM_DIR_NAME);
+ if (!sysdir) {
+ ret = -errno;
+ goto free_locals;
+ }
+
+ while ((dent = readdir(sysdir))) {
+ node_type = drmGetNodeType(dent->d_name);
+ if (node_type < 0)
+ continue;
+
+ snprintf(node, PATH_MAX, "%s/%s", DRM_DIR_NAME, dent->d_name);
+ if (stat(node, &sbuf))
+ continue;
+
+ maj = major(sbuf.st_rdev);
+ min = minor(sbuf.st_rdev);
+
+ if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode))
+ continue;
+
+ snprintf(path, PATH_MAX, "/sys/dev/char/%d:%d/device/subsystem",
+ maj, min);
+ subsystem_type = drmParseSubsystemType(path);
+
+ if (subsystem_type < 0)
+ continue;
+
+ switch (subsystem_type) {
+ case DRM_BUS_PCI:
+ pcibus = calloc(1, sizeof(*pcibus));
+ if (pcibus == NULL) {
+ ret = -ENOMEM;
+ goto free_locals;
+ }
+
+ snprintf(path, PATH_MAX, "/sys/dev/char/%d:%d/device/uevent",
+ maj, min);
+ fd = open(path, O_RDONLY);
+ if (fd < 0) {
+ ret = -errno;
+ goto free_locals;
+ }
+ ret = read(fd, data, sizeof(data));
+ if (ret < 0) {
+ ret = -errno;
+ close(fd);
+ goto free_locals;
+ }
+
+ ret = drmParsePciBusInfo(data, pcibus);
+ close(fd);
+ if (ret)
+ goto free_locals;
+
+ if (i >= max_count) {
+ max_count += 16;
+ devs = realloc(devs, max_count * sizeof(*devs));
+ }
+
+ devs[i].businfo.pci = pcibus;
+ devs[i].bustype = subsystem_type;
+ devs[i].nodes = calloc(DRM_NODE_MAX, sizeof(char *));
+ if (devs[i].nodes == NULL) {
+ ret = -ENOMEM;
+ goto free_locals;
+ }
+ devs[i].nodes[node_type] = strdup(node);
+ if (devs[i].nodes[node_type] == NULL) {
+ ret = -ENOMEM;
+ goto free_locals;
+ }
+ devs[i].available_nodes = 1 << node_type;
+
+ if (devices != NULL) {
+ snprintf(path, PATH_MAX, "/sys/class/drm/%s/device/config",
+ dent->d_name);
+ fd = open(path, O_RDONLY);
+ if (fd < 0) {
+ ret = -errno;
+ goto free_locals;
+ }
+ ret = read(fd, config, 64);
+ if (ret < 0) {
+ ret = -errno;
+ close(fd);
+ goto free_locals;
+ }
+
+ pcidevice = calloc(1, sizeof(*pcidevice));
+ if (pcidevice == NULL) {
+ ret = -ENOMEM;
+ goto free_locals;
+ }
+
+ ret = drmParsePciDeviceInfo(config, pcidevice);
+ if (ret)
+ goto free_locals;
+
+ devs[i].deviceinfo.pci = pcidevice;
+ close(fd);
+ }
+ break;
+ default:
+ fprintf(stderr, "The subsystem type is not supported yet\n");
+ break;
+ }
+ i++;
+ }
+
+ node_count = i;
+
+ /* merge duplicated devices with same domain/bus/device/func IDs */
+ duplicated = calloc(node_count, sizeof(*duplicated));
+ if (duplicated == NULL) {
+ ret = -ENOMEM;
+ goto free_locals;
+ }
+
+ for (i = 0; i < node_count; i++) {
+ for (j = i+1; j < node_count; j++) {
+ if (duplicated[i] || duplicated[j])
+ continue;
+ if (drmSameDevice(&devs[i], &devs[j])) {
+ duplicated[j] = 1;
+ devs[i].available_nodes |= devs[j].available_nodes;
+ node_type = log2(devs[j].available_nodes);
+ devs[i].nodes[node_type] = devs[j].nodes[node_type];
+ free(devs[j].nodes);
+ free(devs[j].businfo.pci);
+ free(devs[j].deviceinfo.pci);
+ }
+ }
+ }
+
+ for (i = 0; i < node_count; i++) {
+ if(duplicated[i] == 0) {
+ if ((devices != NULL) && (device_count < max_devices)) {
+ devices[device_count] = calloc(1, sizeof(drmDevice));
+ if (devices[device_count] == NULL) {
+ ret = -ENOMEM;
+ break;
+ }
+ memcpy(devices[device_count], &devs[i], sizeof(drmDevice));
+ } else
+ drmFreeDevice(&devs[i]);
+ device_count++;
+ }
+ }
+
+ if (i < node_count) {
+ drmFreeDevices(devices, device_count);
+ for ( ; i < node_count; i++)
+ if(duplicated[i] == 0)
+ drmFreeDevice(&devs[i]);
+ } else
+ ret = device_count;
+
+ free(duplicated);
+ free(devs);
+ closedir(sysdir);
+ return ret;
+
+free_locals:
+ for (j = 0; j < i; j++)
+ drmFreeDevice(&devs[j]);
+ free(pcidevice);
+ free(pcibus);
+ free(devs);
+ closedir(sysdir);
+ return ret;
+}
+#else
+void drmFreeDevices(drmDevicePtr devices[], int count)
+{
+ (void)devices;
+ (void)count;
+}
+
+int drmGetDevices(drmDevicePtr devices[], int max_devices)
+{
+ (void)devices;
+ (void)max_devices;
+ return -EINVAL;
+}
+
+#warning "Missing implementation of drmGetDevices/drmFreeDevices"
+
+#endif
diff --git a/lib/libdrm/xf86drm.h b/lib/libdrm/xf86drm.h
index 360e04af5..e82ca844c 100644
--- a/lib/libdrm/xf86drm.h
+++ b/lib/libdrm/xf86drm.h
@@ -563,6 +563,8 @@ extern int drmOpen(const char *name, const char *busid);
#define DRM_NODE_PRIMARY 0
#define DRM_NODE_CONTROL 1
#define DRM_NODE_RENDER 2
+#define DRM_NODE_MAX 3
+
extern int drmOpenWithType(const char *name, const char *busid,
int type);
@@ -759,6 +761,38 @@ extern int drmPrimeFDToHandle(int fd, int prime_fd, uint32_t *handle);
extern char *drmGetPrimaryDeviceNameFromFd(int fd);
extern char *drmGetRenderDeviceNameFromFd(int fd);
+#define DRM_BUS_PCI 0
+
+typedef struct _drmPciBusInfo {
+ uint16_t domain;
+ uint8_t bus;
+ uint8_t dev;
+ uint8_t func;
+} drmPciBusInfo, *drmPciBusInfoPtr;
+
+typedef struct _drmPciDeviceInfo {
+ uint16_t vendor_id;
+ uint16_t device_id;
+ uint16_t subvendor_id;
+ uint16_t subdevice_id;
+ uint8_t revision_id;
+} drmPciDeviceInfo, *drmPciDeviceInfoPtr;
+
+typedef struct _drmDevice {
+ char **nodes; /* DRM_NODE_MAX sized array */
+ int available_nodes; /* DRM_NODE_* bitmask */
+ int bustype;
+ union {
+ drmPciBusInfoPtr pci;
+ } businfo;
+ union {
+ drmPciDeviceInfoPtr pci;
+ } deviceinfo;
+} drmDevice, *drmDevicePtr;
+
+extern int drmGetDevices(drmDevicePtr devices[], int max_devices);
+extern void drmFreeDevices(drmDevicePtr devices[], int count);
+
#if defined(__cplusplus)
}
#endif
diff --git a/lib/libdrm/xf86drmMode.c b/lib/libdrm/xf86drmMode.c
index 9b70ce83f..23800dd18 100644
--- a/lib/libdrm/xf86drmMode.c
+++ b/lib/libdrm/xf86drmMode.c
@@ -873,7 +873,7 @@ int drmHandleEvent(int fd, drmEventContextPtr evctx)
int len, i;
struct drm_event *e;
struct drm_event_vblank *vblank;
-
+
/* The DRM read semantics guarantees that we always get only
* complete events. */
@@ -893,7 +893,7 @@ int drmHandleEvent(int fd, drmEventContextPtr evctx)
break;
vblank = (struct drm_event_vblank *) e;
evctx->vblank_handler(fd,
- vblank->sequence,
+ vblank->sequence,
vblank->tv_sec,
vblank->tv_usec,
U642VOID (vblank->user_data));