platform/upstream/libdrm.git
8 years agoamdgpu: fix overflow for timeout calculation
Jammy Zhou [Tue, 17 Nov 2015 09:14:35 +0000 (17:14 +0800)]
amdgpu: fix overflow for timeout calculation

Set the timeout to AMDGPU_TIMEOUT_INFINITE when overflow happens

Signed-off-by: Jammy Zhou <Jammy.Zhou@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
9 years agoconfigure.ac: test for the same atomic function as the one we use
Emil Velikov [Mon, 16 Nov 2015 13:51:01 +0000 (13:51 +0000)]
configure.ac: test for the same atomic function as the one we use

Unlikely that we'll hit a case where __sync_fetch_and_add is present
while __sync_add_and_fetch isn't. Regardless let's keep things sane and
consistent.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
9 years agoconfigure.ac: rework compiler builtin atomic tests
Jonathan Gray [Sat, 29 Aug 2015 07:32:50 +0000 (17:32 +1000)]
configure.ac: rework compiler builtin atomic tests

The libdrm autoconf test for atomics uses __sync_val_compare_and_swap with
the address of a function argument which triggers a gcc ICE on sparc64
with the OpenBSD system compiler.

Mark Kettenis pointed out that while other architectures probably spill the
argument onto the stack this is likely not the case on register window
architectures like SPARC and suggested passing a pointer as an argument
instead which avoids the ICE and allows the drm libraries requiring
atomics to build on sparc64 with the autoconf build.

Reported-by: Christian Weisgerber <naddy@openbsd.org>
Signed-off-by: Jonathan Gray <jsg@jsg.id.au>
Reviewed-by: Mark Kettenis <kettenis@openbsd.org>
Reviewed-by: Matthieu Herrb <matthieu@openbsd.org>
9 years agoradeon: Handle surface offsets exceeding 32 bits correctly
Michel Dänzer [Tue, 8 Sep 2015 06:03:55 +0000 (15:03 +0900)]
radeon: Handle surface offsets exceeding 32 bits correctly

The slice_size and bo_size fields were getting truncated to 32 bits.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
9 years agolibdrm: Use userspace compatible type in fourcc_mod_code macro
Tvrtko Ursulin [Wed, 23 Sep 2015 12:33:16 +0000 (13:33 +0100)]
libdrm: Use userspace compatible type in fourcc_mod_code macro

__u64 should be used instead of u64.

Kernel headers originally pulled in:

commit 8983fe5497e89a3ffaba3ad1ee06a30a1c7e6daf
Author: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Date:   Mon Aug 3 10:48:03 2015 +0100

    libdrm: Add framebuffer modifiers uapi

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: dri-devel@lists.freedesktop.org
Cc: Rob Clark <robdclark@gmail.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Rob Clark <robclark@freedesktop.org>
9 years agointel: Cleanup SKL PCI ID definitions.
Ben Widawsky [Thu, 22 Oct 2015 19:06:59 +0000 (12:06 -0700)]
intel: Cleanup SKL PCI ID definitions.

This removes ones which aren't used, and adds some new ones. I kept the original
names where possible.

Cc: Kristian Høgsberg <krh@bitplanet.net>
Cc: Damien Lespiau <damien.lespiau@intel.com>
Signed-off-by: Ben Widawsky <benjamin.widawsky@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
9 years agointel: Add SKL GT4 PCI IDs
Ben Widawsky [Thu, 22 Oct 2015 19:15:50 +0000 (12:15 -0700)]
intel: Add SKL GT4 PCI IDs

Cc: Kristian Høgsberg <krh@bitplanet.net>
Cc: Damien Lespiau <damien.lespiau@intel.com>
Signed-off-by: Ben Widawsky <benjamin.widawsky@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
9 years agoamdgpu: Cleanly handle ENOMEM on result in amdgpu_bo_list_create()
Tom St Denis [Fri, 9 Oct 2015 16:46:40 +0000 (12:46 -0400)]
amdgpu: Cleanly handle ENOMEM on result in amdgpu_bo_list_create()

Move the allocation of result prior to the IOCTL so we can cleanly
backtrack if the allocation fails.

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
9 years agoamdgpu: Fix use-after-free bug in vamgr_deinit
Tom St Denis [Fri, 9 Oct 2015 16:07:26 +0000 (12:07 -0400)]
amdgpu:  Fix use-after-free bug in vamgr_deinit

This patch fixes a use-after-free bug in the vamgr_deinit function.

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
9 years agoamdgpu: Unlock mutex if base_required is invalid
Tom St Denis [Fri, 9 Oct 2015 14:36:04 +0000 (10:36 -0400)]
amdgpu: Unlock mutex if base_required is invalid

In the function amdgpu_vamgr_find_va() the function would return
without unlocking the mutex if the base_required offset was below
the va managers base offset.

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
9 years agodrm: add virtgpu_drm.h
Dave Airlie [Tue, 20 Oct 2015 23:21:07 +0000 (09:21 +1000)]
drm: add virtgpu_drm.h

This is in drm-next now, so add to libdrm.

Signed-off-by: Dave Airlie <airlied@redhat.com>
9 years agoxf86drm: Handle unrecognized subsystems safely in drmGetDevice[s]()
Matt Roper [Fri, 16 Oct 2015 22:11:24 +0000 (15:11 -0700)]
xf86drm: Handle unrecognized subsystems safely in drmGetDevice[s]()

Both drmGetDevice() and drmGetDevices() currently print a warning when
they encounter an unknown (non-PCI) subsystem type for a device node,
but they still proceed to assume that the drmDevicePtr was initialized
and try to add it to the local device array.  Add a 'continue' to the
error case handling to bypass the rest of the processing for devices we
can't handle.

Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
9 years agoxf86drm: Fix error handling for drmGetDevice()
Matt Roper [Fri, 16 Oct 2015 22:11:23 +0000 (15:11 -0700)]
xf86drm: Fix error handling for drmGetDevice()

Some of the error conditions in drmGetDevice() can lead to us calling
closedir(NULL) or leaking memory.  Fix these conditions the same way we
did for drmGetDevices() in commit:

        commit 8c4a1cbd98bd8d185d489395f33302a17db643a9
        Author: Matt Roper <matthew.d.roper@intel.com>
        Date:   Wed Sep 30 09:30:51 2015 -0700

            xf86drm: Fix error handling for drmGetDevices()

Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
9 years agoFix void pointer arithmetic in drmProcessPciDevice
Michel Dänzer [Wed, 14 Oct 2015 03:48:52 +0000 (12:48 +0900)]
Fix void pointer arithmetic in drmProcessPciDevice

Arithmetic on void pointers is a GCC extension.

  CC       libdrm_la-xf86drm.lo
../xf86drm.c: In function 'drmProcessPciDevice':
../xf86drm.c:3017:10: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
     addr += sizeof(drmDevice);
          ^
../xf86drm.c:3020:10: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
     addr += DRM_NODE_MAX * sizeof(void *);
          ^
../xf86drm.c:3023:14: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
         addr += max_node_str;
              ^
../xf86drm.c:3035:14: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
         addr += sizeof(drmPciBusInfo);
              ^

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
9 years agoxf86drm: Fix error handling for drmGetDevices()
Matt Roper [Wed, 30 Sep 2015 16:30:51 +0000 (09:30 -0700)]
xf86drm: Fix error handling for drmGetDevices()

If the opendir() call in drmGetDevices() returns failure, we jump to an
error label that calls closedir() and then returns.  However this means
that we're calling closedir(NULL) which may not be safe on all
implementations.  We are also leaking the local_devices array that was
allocated before the opendir() call.

Fix both of these issues by jumping to an earlier error label (to free
local_devices) and guarding the closedir() call with a NULL test.

Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
[Emil Velikov: make the teardown symmetrical, remove the NULL check]
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
9 years agoxf86drm: include <limits.h> for PATH_MAX
Felix Janda [Sat, 26 Sep 2015 06:08:43 +0000 (08:08 +0200)]
xf86drm: include <limits.h> for PATH_MAX

fixes compilation error with musl libc and Solaris based platforms.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92082
Signed-off-by: Felix Janda <felix.janda@posteo.de>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
9 years agoxf86drm: remove makedev() hack/workaround
Emil Velikov [Fri, 7 Aug 2015 15:13:32 +0000 (16:13 +0100)]
xf86drm: remove makedev() hack/workaround

Back when this was introduced commit 569da5a42eb(Merged glxmisc-3-0-0)
sys/sysmacros.h was used instead of the respecive headers (as per the
manual).

We've been handling it correctly for a little while now - in Linux, BSD
and Solaris. Thus we can drop this workaround.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
9 years agoexynos/fimg2d: remove g2d_context from public header
Tobias Jakobi [Tue, 8 Sep 2015 15:22:34 +0000 (17:22 +0200)]
exynos/fimg2d: remove g2d_context from public header

All functions from the public API only operation on
struct g2d_context*, so this shouldn't break too much.

Make the context private since we don't want the
user to modify its content directly. Also remove
the defines that were only used for fields of
g2d_context.

Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
9 years agoexynos/fimg2d: add message prefix
Tobias Jakobi [Tue, 8 Sep 2015 15:22:33 +0000 (17:22 +0200)]
exynos/fimg2d: add message prefix

Add a prefix to the messages printed to the console via
printf() and fprintf() so that one can easily see where
the message comes from.

Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
9 years agoexynos/fimg2d: make g2d_add_cmd() less heavy
Tobias Jakobi [Tue, 8 Sep 2015 15:22:32 +0000 (17:22 +0200)]
exynos/fimg2d: make g2d_add_cmd() less heavy

The function currently checks for each added command
if an overflow of the corresponding command buffers
occurs, but none of the callers ever checks the
return value.

Since all callers are now converted to use
g2d_check_space() simplify the function.

(1) The overflow checks become asserts, so they're only
    active for debug builds. This is fine since
    g2d_add_cmd() is not part of the public API.

(2) Switch the return value to void.

(3) Explicitly state that the caller has to check
    buffer space before calling g2d_add_cmd().

Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
9 years agoexynos/fimg2d: remove superfluous initialization of g2d_point_val
Tobias Jakobi [Tue, 8 Sep 2015 15:22:31 +0000 (17:22 +0200)]
exynos/fimg2d: remove superfluous initialization of g2d_point_val

The g2d_point_val union consists of two coordinates of 16
bits. Whenever this union is used though, both coordinates
are explicitly set. Hence prior initialization is unnecessary.

Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
9 years agoexynos/fimg2d: remove default case from g2d_get_blend_op()
Tobias Jakobi [Tue, 8 Sep 2015 15:22:30 +0000 (17:22 +0200)]
exynos/fimg2d: remove default case from g2d_get_blend_op()

We now validate the blending mode via g2d_validate_mode()
prior to feeding it to g2d_get_blend_op().

Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
9 years agoexynos/fimg2d: add g2d_validate_xyz() functions
Tobias Jakobi [Tue, 8 Sep 2015 15:22:29 +0000 (17:22 +0200)]
exynos/fimg2d: add g2d_validate_xyz() functions

The G2D headers define a number of modes through enums
(like e.g. color, select, repeat, etc.).

This introduces g2d_validate_select_mode() and
g2d_validate_blending_op() which validate a
select mode or blending operation respectively.

Use this together with g2d_check_space() in
g2d_{blend,scale_and_blend}().

For this we move parameter validation to the top and
also validate the select mode of the source image and
the requested blending operation before starting
command submission.

Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
9 years agoexynos/fimg2d: add g2d_check_space()
Tobias Jakobi [Tue, 8 Sep 2015 15:22:28 +0000 (17:22 +0200)]
exynos/fimg2d: add g2d_check_space()

This is going to be used to check if the command buffers have
enough space left prior to actual submission of the commands.

Use this in g2d_{solid_fill,copy,copy_with_scale}().

For this the parameter validation before buffer space
checking so that we can exit early if it fails.
Also don't reset the G2D context in this situation since
the buffers are not partially submitted anymore.

The repeat mode in g2d_copy_with_scale() is checked first
to make computation of space easier.

Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
9 years agoexynos/fimg2d: simplify base address submission in g2d_scale_and_blend()
Tobias Jakobi [Tue, 8 Sep 2015 15:22:27 +0000 (17:22 +0200)]
exynos/fimg2d: simplify base address submission in g2d_scale_and_blend()

Use g2d_add_base_addr() for source and destination base
address just like all other calls.

Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
9 years agoexynos/fimg2d: fix empty buffer handling in g2d_flush()
Tobias Jakobi [Tue, 8 Sep 2015 15:22:26 +0000 (17:22 +0200)]
exynos/fimg2d: fix empty buffer handling in g2d_flush()

Empty command buffers are no error, we just don't have
anything to do for flushing then.

Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
9 years agoFix SunOS/NetBSD atomic macro
Emil Velikov [Mon, 21 Sep 2015 16:29:55 +0000 (17:29 +0100)]
Fix SunOS/NetBSD atomic macro

Reported-by: Evgeny Litvinenko <evgeny.v.litvinenko@gmail.com>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
9 years agotests/drmdevice: add drm{Get,Free}Device() example
Emil Velikov [Wed, 9 Sep 2015 17:13:01 +0000 (18:13 +0100)]
tests/drmdevice: add drm{Get,Free}Device() example

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
9 years agoxf86drm: add drm{Get,Free}Device
Emil Velikov [Wed, 9 Sep 2015 15:02:18 +0000 (16:02 +0100)]
xf86drm: add drm{Get,Free}Device

Similar interface to the *Devices() ones but they obtain/free the
information of the opened device (as given by its fd).

Note there is a fair bit of duplication between the two Get functions,
and anyone interested is more than welcome to consolidate it.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
9 years agoxf86drm: split out drmProcessPciDevice and drmFoldDuplicatedDevices
Emil Velikov [Wed, 9 Sep 2015 16:54:34 +0000 (17:54 +0100)]
xf86drm: split out drmProcessPciDevice and drmFoldDuplicatedDevices

Will be reused in the next commit.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
9 years agoxf86drm: warn on missing drmGetMinorNameForFD implementation
Emil Velikov [Mon, 7 Sep 2015 17:29:05 +0000 (18:29 +0100)]
xf86drm: warn on missing drmGetMinorNameForFD implementation

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
9 years agoxf86drm: move ifdef __linux__ guards where needed
Emil Velikov [Mon, 7 Sep 2015 17:26:34 +0000 (18:26 +0100)]
xf86drm: move ifdef __linux__ guards where needed

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
9 years agoxf86drm: rework drmGetDevices()
Emil Velikov [Mon, 7 Sep 2015 12:54:32 +0000 (13:54 +0100)]
xf86drm: rework drmGetDevices()

Do a once off memory allocation for each drmDevice.

This allows us to ease the error handling and simplify the
de-duplication loop. As part of this we need to rework drmFreeDevice()
such so that it frees the relevant hunks, rather than leaving that to
the caller.

Some memory stats from the drmdevice test

before: 22 allocs, 22 frees, 66,922 bytes allocated
after:   9 allocs, 9 frees, 66,436 bytes allocated

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
9 years agoutil_math: add MAX3 macro
Emil Velikov [Mon, 7 Sep 2015 13:13:32 +0000 (14:13 +0100)]
util_math: add MAX3 macro

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
9 years agoxf86drm: rename drmSameDevice to drmCompareBusInfo
Emil Velikov [Mon, 7 Sep 2015 12:51:54 +0000 (13:51 +0100)]
xf86drm: rename drmSameDevice to drmCompareBusInfo

Move away form the boolean name, change the return value
appropriately and check if either argument is NULL.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
9 years agoxf86drm: move the final linux specific bits out of drmGetDevices
Emil Velikov [Mon, 7 Sep 2015 11:54:27 +0000 (12:54 +0100)]
xf86drm: move the final linux specific bits out of drmGetDevices

Third and final piece of making drmGetDevices less crazy/ugly.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
9 years agoxf86drm: move platform details to drmParsePciDeviceInfo()
Emil Velikov [Mon, 7 Sep 2015 11:47:47 +0000 (12:47 +0100)]
xf86drm: move platform details to drmParsePciDeviceInfo()

As with previous commit let's try to keep drmGetDevices clean of linux
specifics.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
9 years agoxf86drm: flex platform specifics into drmParsePciBusInfo
Emil Velikov [Mon, 7 Sep 2015 11:37:57 +0000 (12:37 +0100)]
xf86drm: flex platform specifics into drmParsePciBusInfo

This will allow one to reuse the core drmGetDevices implementation on
other platforms. Keeping all the platform specifics in ParseFoo.

On the plus side this saves a bit of code :)

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
9 years agotests/drmdevice: add new 'test'
Emil Velikov [Wed, 9 Sep 2015 15:48:29 +0000 (16:48 +0100)]
tests/drmdevice: add new 'test'

A simple example of how to use/what is the new drm{Get,Free}Devices()
interface.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
9 years agoxf86drmMode: smoke-test the atomic API
Emil Velikov [Sat, 5 Sep 2015 16:20:53 +0000 (17:20 +0100)]
xf86drmMode: smoke-test the atomic API

As going through the modetest patches for atomic support I've noticed
that if we pass NULL for the drmModeAtomicReqPtr argument we'll crash.

So let's handle things appropriately if the user forgot to check the
return value of drmModeAtomicAlloc and drmModeAtomicDuplicate or made a
typo somewhere along the way.

Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Rob Clark <robclark@freedesktop.org>
Cc: Daniel Stone <daniels@collabora.com>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
9 years agoautomake: set --enable-valgrind during make distcheck
Emil Velikov [Fri, 4 Sep 2015 21:06:44 +0000 (22:06 +0100)]
automake: set --enable-valgrind during make distcheck

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
9 years agofreedreno: debug msg cleanup
Rob Clark [Fri, 4 Sep 2015 15:44:33 +0000 (11:44 -0400)]
freedreno: debug msg cleanup

Signed-off-by: Rob Clark <robclark@freedesktop.org>
9 years agofreedreno: drop exported dmabuf fd tracking
Rob Clark [Fri, 4 Sep 2015 15:41:47 +0000 (11:41 -0400)]
freedreno: drop exported dmabuf fd tracking

There is really no reason to keep around the fd, it just consumes an
extra file handle.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
9 years agofreedreno: don't reuse exported buffers
Rob Clark [Sat, 29 Aug 2015 16:49:28 +0000 (12:49 -0400)]
freedreno: don't reuse exported buffers

Signed-off-by: Rob Clark <robclark@freedesktop.org>
9 years agoBump version for release libdrm-2.4.65
Rob Clark [Wed, 16 Sep 2015 13:03:40 +0000 (09:03 -0400)]
Bump version for release

Signed-off-by: Rob Clark <robclark@freedesktop.org>
9 years agoInclude <alloca.h> when needed before calling alloca
Alan Coopersmith [Sun, 6 Sep 2015 16:34:31 +0000 (09:34 -0700)]
Include <alloca.h> when needed before calling alloca

Fixes "error: implicit declaration of function 'alloca'" failures
when building on Solaris

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
9 years agolibdrm: Add framebuffer modifiers uapi
Tvrtko Ursulin [Mon, 3 Aug 2015 09:48:03 +0000 (10:48 +0100)]
libdrm: Add framebuffer modifiers uapi

Sync up with new kernel features as per commits:

e3eb3250d84ef97b766312345774367b6a310db8
93b81f5102a7cd270a305c2741b17c8d44bb0629
b5ff6e1637b683d5996ae11ac29afe406c0bee90
8c4f83fb1e8bf317e894f62d17a63c32b7a6b75e
570655b09b065d2fff1b8ab9bdb8308f4c5a05a3

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: dri-devel@lists.freedesktop.org
Cc: Rob Clark <robdclark@gmail.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Rob Clark <robclark@freedesktop.org>
9 years agotests: Add -lm to LDADD for dristat
Michel Dänzer [Mon, 7 Sep 2015 10:02:14 +0000 (19:02 +0900)]
tests: Add -lm to LDADD for dristat

Fixes build failure due to unresolved log2.

Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
9 years agoconfigure: remove -Wno-missing-field-initializers
Emil Velikov [Sat, 15 Aug 2015 16:00:37 +0000 (17:00 +0100)]
configure: remove -Wno-missing-field-initializers

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
9 years agointel: ignore missing-field-initializers warnings
Emil Velikov [Sun, 23 Aug 2015 13:20:17 +0000 (14:20 +0100)]
intel: ignore missing-field-initializers warnings

We're about to remove the -Wno flag from configure.ac which will lead
to a lot of unnecessary spam.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
9 years agonouveau: use designated initializers
Emil Velikov [Sat, 15 Aug 2015 17:01:53 +0000 (18:01 +0100)]
nouveau: use designated initializers

Cc: nouveau@lists.freedesktop.org
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
9 years agotests/amdgpu: ensure tests work by using c99 initializers
Emil Velikov [Sun, 23 Aug 2015 13:44:55 +0000 (14:44 +0100)]
tests/amdgpu: ensure tests work by using c99 initializers

In the latest version of CUnit the fourth parameter of the CU_SuiteInfo
struct is pSetUpFunc rather than *pTests.

Seems like the CUnit ABI broke at some point, so let's the the robust
thing and use c99 designated initializers to correctly populate the
struct(s).

Cc: Leo Liu <leo.liu@amd.com>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
9 years agotests/amdgpu: annotate (most of) the vce templates as const data
Emil Velikov [Sat, 15 Aug 2015 16:35:58 +0000 (17:35 +0100)]
tests/amdgpu: annotate (most of) the vce templates as const data

The remaining two templates are modified on the fly, depending on the
type of test to be performed.

Cc: Leo Liu <leo.liu@amd.com>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
9 years agotests/amdgpu: annotate the uvd message templates as const data
Emil Velikov [Sat, 15 Aug 2015 16:25:21 +0000 (17:25 +0100)]
tests/amdgpu: annotate the uvd message templates as const data

Cc: Leo Liu <leo.liu@amd.com>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
9 years agotests/amdgpu: reference the correct variable for memcpy
Emil Velikov [Sat, 15 Aug 2015 16:24:21 +0000 (17:24 +0100)]
tests/amdgpu: reference the correct variable for memcpy

Cc: Leo Liu <leo.liu@amd.com>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
9 years agofreedreno: annotate the device/bo/pipe/ringbuffer funcs as const data
Emil Velikov [Sat, 15 Aug 2015 16:17:52 +0000 (17:17 +0100)]
freedreno: annotate the device/bo/pipe/ringbuffer funcs as const data

Cc: freedreno@lists.freedesktop.org
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
9 years agoradeon: cleanup bo/cs func tables
Emil Velikov [Sat, 15 Aug 2015 16:12:13 +0000 (17:12 +0100)]
radeon: cleanup bo/cs func tables

Annotate the data as static const and use C99 designated initializers.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
9 years agolibkms: use static const for good measure
Emil Velikov [Sat, 15 Aug 2015 16:01:55 +0000 (17:01 +0100)]
libkms: use static const for good measure

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
9 years agomodetest: annotate const data as such for good measure
Emil Velikov [Sat, 15 Aug 2015 16:00:56 +0000 (17:00 +0100)]
modetest: annotate const data as such for good measure

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
9 years agoamdgpu: remove unneeded -Wno-switch-enum flag
Emil Velikov [Sat, 15 Aug 2015 14:53:26 +0000 (15:53 +0100)]
amdgpu: remove unneeded -Wno-switch-enum flag

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
9 years agoconfigure: enable -Wshadow when available
Emil Velikov [Sat, 15 Aug 2015 14:13:41 +0000 (15:13 +0100)]
configure: enable -Wshadow when available

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
9 years agointel: introduce to_bo_gem() helper
Emil Velikov [Mon, 31 Aug 2015 19:38:54 +0000 (20:38 +0100)]
intel: introduce to_bo_gem() helper

...to minimise misuse of bo_gem.
If the variable is declared at the top of the function and then used
for two (or more) different contexts this can cause confusion and errors.

Just introduce a wrapper, which can be used in a once off situations.

Suggested-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by Chris Wilson <chris@chris-wilson.co.uk>

9 years agointel: error out on has_error in exec2
Emil Velikov [Sat, 15 Aug 2015 14:43:46 +0000 (15:43 +0100)]
intel: error out on has_error in exec2

Just like we do for the original exec()

v2: move bo_gem declaration to the top of the function.

Cc: intel-gfx@lists.freedesktop.org
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by Chris Wilson <chris@chris-wilson.co.uk>

9 years agointel: resolve shadowing warnings
Emil Velikov [Sat, 15 Aug 2015 14:42:34 +0000 (15:42 +0100)]
intel: resolve shadowing warnings

v2: keep the bo_gem declaration in exec2() within the loop (Chris)

Cc: intel-gfx@lists.freedesktop.org
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by Chris Wilson <chris@chris-wilson.co.uk>

9 years agomodetest: fix shadowing warnings
Emil Velikov [Sat, 15 Aug 2015 14:20:37 +0000 (15:20 +0100)]
modetest: fix shadowing warnings

No real issue here, but let's fix these so that real issues don't get
lost in the spam.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
9 years agovbltest: fix variable shadowing warning
Emil Velikov [Sat, 15 Aug 2015 14:12:36 +0000 (15:12 +0100)]
vbltest: fix variable shadowing warning

Just remove the second (shadowing) declaration of ret.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
9 years agofreedreno: add API to get drm fd from fd_device
Rob Clark [Fri, 4 Sep 2015 15:08:04 +0000 (11:08 -0400)]
freedreno: add API to get drm fd from fd_device

Signed-off-by: Rob Clark <robclark@freedesktop.org>
9 years agodrm: make individual drm_server_info fxns optional
Rob Clark [Fri, 4 Sep 2015 12:08:02 +0000 (08:08 -0400)]
drm: make individual drm_server_info fxns optional

For android / drm_gralloc, we want to hook up our own debug_print()
without bothering with the reset of it.

Signed-off-by: Rob Clark <robdclark@gmail.com>
9 years agofreedreno: don't take ownership of the dmabuf fd on import
Rob Clark [Thu, 3 Sep 2015 18:56:02 +0000 (14:56 -0400)]
freedreno: don't take ownership of the dmabuf fd on import

EGL_EXT_image_dma_buf_import specifies that the importer retains
ownership of the fd, rather then the importee.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
9 years agoamdgpu: use EINVAL instead of EBADMSG in amdgpu_bo_cpu_unmap()
Jonathan Gray [Tue, 1 Sep 2015 11:37:19 +0000 (21:37 +1000)]
amdgpu: use EINVAL instead of EBADMSG in amdgpu_bo_cpu_unmap()

EBADMSG is a streams errno.  OpenBSD does not implement streams and does
include the streams errnos, this commit fixes the build on OpenBSD.

None of the callers of this function check the return value for -EBADMSG.

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Jonathan Gray <jsg@jsg.id.au>
9 years agoamdgpu: fix missing deinit on vamgr_32
monk.liu [Mon, 31 Aug 2015 07:06:58 +0000 (15:06 +0800)]
amdgpu: fix missing deinit on vamgr_32

Reviewed-by: Jammy Zhou <Jammy.Zhou@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: monk.liu <monk.liu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
9 years agofreedreno: serialize drmPrimeFDToHandle under table_lock
Varad Gautam [Sun, 30 Aug 2015 10:00:58 +0000 (15:30 +0530)]
freedreno: serialize drmPrimeFDToHandle under table_lock

fixes the prime sharing race condition described by
"intel: Serialize drmPrimeFDToHandle with struct_mutex".

we inline fd_bo_from_handle() into fd_bo_from_dmabuf() and allow locking.

Signed-off-by: Varad Gautam <varadgautam@gmail.com>
Signed-off-by: Rob Clark <robclark@freedesktop.org>
9 years agofreedreno: use drmPrime wrappers to import/export prime bo's
Varad Gautam [Sun, 30 Aug 2015 10:00:57 +0000 (15:30 +0530)]
freedreno: use drmPrime wrappers to import/export prime bo's

don't call drmIoctl() directly for prime bo's, use the wrappers instead.

v3: remove struct drm_prime_handle and split locking

Signed-off-by: Varad Gautam <varadgautam@gmail.com>
Signed-off-by: Rob Clark <robclark@freedesktop.org>
9 years agoomap: Initialize DMA BUF file descriptor to -1
Thierry Reding [Wed, 26 Aug 2015 08:05:48 +0000 (10:05 +0200)]
omap: Initialize DMA BUF file descriptor to -1

Commit c86dabfc9f04 ("omap: zero is a valid fd number, treat it as
such") corrected checks for valid file descriptors, but the OMAP buffer
object code initializes the DMA-BUF file descriptor to 0 (as a result of
calloc()'ing the structure). Obviously this isn't going to work because
subsequent code will try to use file descriptor 0 (most likely stdin at
that point) as a DMA-BUF. It may also try and close stdin when a buffer
object is destroyed.

Fix this by initializing the DMA-BUF file descriptor to -1, properly
marking it as an invalid file descriptor.

Fixes: c86dabfc9f04 ("omap: zero is a valid fd number, treat it as such")
Reported-by: Robert Nelson <robertcnelson@gmail.com>
Tested-by: Robert Nelson <robertcnelson@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
9 years agoamdgpu: serialize drmPrimeFDToHandle
Christian König [Mon, 24 Aug 2015 09:43:30 +0000 (11:43 +0200)]
amdgpu: serialize drmPrimeFDToHandle

Fixes the same problem as "intel: Serialize drmPrimeFDToHandle with struct_mutex".

Reviewed-by: Jammy Zhou <Jammy.Zhou@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
9 years agoamdgpu: remove sequence mutex
Christian König [Mon, 24 Aug 2015 09:43:29 +0000 (11:43 +0200)]
amdgpu: remove sequence mutex

It's not used any more.

Reviewed-by: Jammy Zhou <Jammy.Zhou@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
9 years agoMove -lm link flag to LIBADD
Emil Velikov [Mon, 24 Aug 2015 17:21:51 +0000 (18:21 +0100)]
Move -lm link flag to LIBADD

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
9 years agodrm: Add -lm to libdrm ldflags to fix build failure.
Jérôme Glisse [Mon, 24 Aug 2015 17:16:56 +0000 (13:16 -0400)]
drm: Add -lm to libdrm ldflags to fix build failure.

Last commit (b556ea127e004b734b2a7bf8e67cdcf56312171d) introduced
use of log2 which require -lm flag for the linker on quite few
distribution. Just add that flag to fix build.

Signed-off-by: Jérôme Glisse <jglisse@redhat.com>
9 years agodrm: add interface to get drm devices on the system v3
Emil Velikov [Mon, 17 Aug 2015 03:09:06 +0000 (11:09 +0800)]
drm: add interface to get drm devices on the system v3

For mutiple GPU support, the devices on the system should be enumerated
to get necessary information about each device, and the drmGetDevices
interface is added for this. Currently only PCI devices are supported for
the enumeration.

Typical usage:
int count;
drmDevicePtr *foo;
count = drmGetDevices(NULL, 0);
foo = calloc(count, sizeof(drmDevicePtr));
count = drmGetDevices(foo, count);
/* find proper device, open correct device node, etc */
drmFreeDevices(foo, count);
free(foo);

v2: [Jammy Zhou]
 - return a list of devices, rather than nodes
v3: [Jammy Zhou]
 - fix the signed extension for PCI device info

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Jammy Zhou <Jammy.Zhou@amd.com>
9 years agodrm: fix the usage after free
Mathias Tillman [Mon, 24 Aug 2015 03:56:13 +0000 (11:56 +0800)]
drm: fix the usage after free

For readdir_r(), the next directory entry is returned in caller-allocted
buffer (pointered by pent here).

https://bugs.freedesktop.org/show_bug.cgi?id=91704

Signed-off-by: Mathias Tillman <master.homer@gmail.com>
Signed-off-by: Jammy Zhou <Jammy.Zhou@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
9 years agofreedreno: get bo size for imported dma-buf
Varad Gautam [Fri, 21 Aug 2015 16:44:35 +0000 (22:14 +0530)]
freedreno: get bo size for imported dma-buf

Signed-off-by: Varad Gautam <varadgautam@gmail.com>
Signed-off-by: Rob Clark <robclark@freedesktop.org>
9 years agofreedreno: fill bo->fd when importing
Varad Gautam [Fri, 21 Aug 2015 16:44:34 +0000 (22:14 +0530)]
freedreno: fill bo->fd when importing

Signed-off-by: Varad Gautam <varadgautam@gmail.com>
Signed-off-by: Rob Clark <robclark@freedesktop.org>
9 years agofreedreno: fix a bo cache segfault with imported bo's
Varad Gautam [Fri, 21 Aug 2015 16:44:33 +0000 (22:14 +0530)]
freedreno: fix a bo cache segfault with imported bo's

Importing a bo whose handle is still in the bo cache crashes during cleanup.
Remove bo from cache when importing.

Signed-off-by: Varad Gautam <varadgautam@gmail.com>
Signed-off-by: Rob Clark <robclark@freedesktop.org>
9 years agointel: Serialize drmPrimeFDToHandle with struct_mutex
Rafał Sapała [Fri, 24 Jul 2015 09:22:34 +0000 (11:22 +0200)]
intel: Serialize drmPrimeFDToHandle with struct_mutex

It is possible to hit a race condition in create_from_prime, when trying
to import a BO that's currently being freed. In case of prime sharing
we'll succesfully get a handle, but fail on get_tiling call, potentially
confusing the caller (and requiring different locking scheme than with
sharing using flink). Wrap fd_to_handle with struct_mutex to force
a more consistent behaviour between prime/flink, convert fprintf to DBG
when handling errors.

(From Chris:
  The race is that the kernel returns us the same file-private handle as
  the first thread, but that first thread is about to call gem_close
  (thereby removing the handle from the file completely) and does so
  between us acquiring the handle and taking the mutex. If we take
  the mutex, then we acquire the refcnt on the bo prior to the first
  thread completing its unref (and so preventing the early close). Or we
  acquire the handle after the earlier close, in which case we are the new
  owner.
)

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Testcase: igt/drm_import_export/import-close-race-prime
Signed-off-by: Rafał Sapała <rafal.a.sapala@intel.com>
Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
9 years agomodetest: remove the trailing white spaces
Hyungwon Hwang [Wed, 19 Aug 2015 00:58:42 +0000 (09:58 +0900)]
modetest: remove the trailing white spaces

This patch removes the trailing white spaces.

Signed-off-by: Hyungwon Hwang <human.hwang@samsung.com>
9 years agoxf86drmMode: remove the trailing white spaces
Hyungwon Hwang [Wed, 19 Aug 2015 00:58:39 +0000 (09:58 +0900)]
xf86drmMode: remove the trailing white spaces

This patch removes the trailing white spaces.

Signed-off-by: Hyungwon Hwang <human.hwang@samsung.com>
9 years agoamdgpu: add Android build support
Mauro Rossi [Tue, 18 Aug 2015 09:43:57 +0000 (11:43 +0200)]
amdgpu: add Android build support

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
9 years agoamdgpu: add Makefile.sources
Mauro Rossi [Thu, 20 Aug 2015 15:55:20 +0000 (16:55 +0100)]
amdgpu: add Makefile.sources

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
[Emil Velikov: remove duplicate amdgpu.h from LIBDRM_AMDGPU_FILES]
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
9 years agoBump version for release libdrm-2.4.64
Rob Clark [Tue, 18 Aug 2015 15:56:50 +0000 (11:56 -0400)]
Bump version for release

Signed-off-by: Rob Clark <robclark@freedesktop.org>
9 years agofreedreno: update freedreno-symbol-check
Rob Clark [Tue, 18 Aug 2015 14:53:36 +0000 (10:53 -0400)]
freedreno: update freedreno-symbol-check

Signed-off-by: Rob Clark <robclark@freedesktop.org>
9 years agolibdrm: Make indentation consistent
Thierry Reding [Wed, 9 Apr 2014 07:00:49 +0000 (09:00 +0200)]
libdrm: Make indentation consistent

Use tabs and spaces consistently to align function arguments on
subsequent lines with those of the first line.

Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
9 years agolibdrm: Remove gratuitous blank lines
Thierry Reding [Wed, 9 Apr 2014 06:59:04 +0000 (08:59 +0200)]
libdrm: Remove gratuitous blank lines

Usage of blank lines can be a matter of taste, of course, but for these
we can surely all agree that they're not needed and inconsistent.

Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
9 years agoamdgpu: make vamgr per device v2
Jammy Zhou [Mon, 17 Aug 2015 03:09:09 +0000 (11:09 +0800)]
amdgpu: make vamgr per device v2

Each device can have its own vamgr, so make it per device now.
This can fix the failure with multiple GPUs used in one single
process.

v2: rebase

Signed-off-by: Jammy Zhou <Jammy.Zhou@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
9 years agoamdgpu: add flag to support 32bit VA address v4
Jammy Zhou [Mon, 17 Aug 2015 03:09:08 +0000 (11:09 +0800)]
amdgpu: add flag to support 32bit VA address v4

The AMDGPU_VA_RANGE_32_BIT flag is added to request VA range in the
32bit address space for amdgpu_va_range_alloc.

The 32bit address space is reserved at initialization time, and managed
with a separate VAMGR as part of the global VAMGR. And if no enough VA
space available in range above 4GB, this reserved range can be used as
fallback.

v2: add comment for AMDGPU_VA_RANGE_32_BIT, and add vamgr to va_range
v3: rebase to Emil's drm_private series
v4: fix one warning

Signed-off-by: Jammy Zhou <Jammy.Zhou@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
9 years agoamdgpu: improve amdgpu_vamgr_init
Jammy Zhou [Mon, 17 Aug 2015 03:09:07 +0000 (11:09 +0800)]
amdgpu: improve amdgpu_vamgr_init

Make it a generic function independent of the device info.

Signed-off-by: Jammy Zhou <Jammy.Zhou@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
9 years agofreedreno: add fd_pipe_wait_timeout()
Rob Clark [Mon, 17 Aug 2015 14:33:59 +0000 (10:33 -0400)]
freedreno: add fd_pipe_wait_timeout()

We need to pass through a timeout parameter to implement
pipe->fence_finish() properly.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
9 years agofreedreno/msm: dump out submit info on error
Rob Clark [Tue, 21 Jul 2015 16:55:29 +0000 (12:55 -0400)]
freedreno/msm: dump out submit info on error

User should only see these with LIBGL_DEBUG=verbose.  But in case you
are hitting issues like "handle X at index Y already on submit list"
errors from the kernel, this gives some useful visibility for debug.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
9 years agofreedreno/msm: fix issue where same bo is on multiple rings
Rob Clark [Tue, 21 Jul 2015 15:57:00 +0000 (11:57 -0400)]
freedreno/msm: fix issue where same bo is on multiple rings

It should be a less common case, but it is possible for a single bo to
be on multiple rings, for example when sharing a buffer across multiple
pipe_context's created from same pipe_screen.

So rather than completely fall over in this case, fallback to slow-path
of looping over all bo's in the ring's bo-table (but retain the fast-
path of constant-lookup for the first ring the buffer is on).

Signed-off-by: Rob Clark <robclark@freedesktop.org>
9 years agofreedreno/msm: reorg ringbuffer struct
Rob Clark [Tue, 21 Jul 2015 16:11:36 +0000 (12:11 -0400)]
freedreno/msm: reorg ringbuffer struct

Group the parts related to building out submit ioctl into their own
sub-struct.  Split out from next commit since it is just boring churn.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
9 years agotests/amdgpu: Remove unused local variable 'i'
Michel Dänzer [Mon, 17 Aug 2015 09:43:39 +0000 (18:43 +0900)]
tests/amdgpu: Remove unused local variable 'i'

Reviewed-by: Christian König <christian.koenig@amd.com>