Commit Graph

5740 Commits (cf0f036e3d819fb7894562bfdfea95e5e5f57219)

Author SHA1 Message Date
Matt Roper cf0f036e3d 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 8c4a1cbd98
        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>
2015-10-20 18:44:58 +01:00
Michel Dänzer 3045523de2 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>
2015-10-14 12:48:52 +09:00
Matt Roper 8c4a1cbd98 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>
2015-10-02 13:17:03 +01:00
Felix Janda 4031dc17bb 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>
2015-09-28 17:59:55 +01:00
Emil Velikov f3c6740f0c 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>
2015-09-21 17:59:45 +01:00
Tobias Jakobi df21b293e9 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>
2015-09-21 17:43:14 +01:00
Tobias Jakobi ce4a4f6e21 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>
2015-09-21 17:43:14 +01:00
Tobias Jakobi bf666b5e99 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>
2015-09-21 17:43:14 +01:00
Tobias Jakobi 6a4479da71 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>
2015-09-21 17:43:14 +01:00
Tobias Jakobi 76d1c6b157 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>
2015-09-21 17:43:14 +01:00
Tobias Jakobi e3c97d1a24 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>
2015-09-21 17:43:14 +01:00
Tobias Jakobi 2362c88251 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>
2015-09-21 17:43:14 +01:00
Tobias Jakobi 9017619714 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>
2015-09-21 17:43:14 +01:00
Tobias Jakobi a8dc2e75cf 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>
2015-09-21 17:43:14 +01:00
Emil Velikov cec65e2fcc Fix SunOS/NetBSD atomic macro
Reported-by: Evgeny Litvinenko <evgeny.v.litvinenko@gmail.com>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2015-09-21 17:43:14 +01:00
Emil Velikov 8990ed3199 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>
2015-09-21 17:43:11 +01:00
Emil Velikov ccedf66b65 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>
2015-09-21 17:43:08 +01:00
Emil Velikov fae59d7234 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>
2015-09-21 17:43:06 +01:00
Emil Velikov 8415a00a3f xf86drm: warn on missing drmGetMinorNameForFD implementation
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2015-09-21 17:43:03 +01:00
Emil Velikov 291b2bb92c 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>
2015-09-21 17:42:57 +01:00
Emil Velikov 5f68d31820 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>
2015-09-21 17:42:53 +01:00
Emil Velikov 6c88173f7e util_math: add MAX3 macro
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2015-09-21 17:42:51 +01:00
Emil Velikov bc2aca9e22 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>
2015-09-21 17:42:48 +01:00
Emil Velikov a250fceaaa 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>
2015-09-21 17:42:46 +01:00
Emil Velikov ef5192e9c7 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>
2015-09-21 17:42:43 +01:00
Emil Velikov 536e0deba3 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>
2015-09-21 17:42:40 +01:00
Emil Velikov f098d1c130 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>
2015-09-21 17:42:37 +01:00
Emil Velikov ed3c665548 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>
2015-09-21 17:32:03 +01:00
Emil Velikov 00808a99d0 automake: set --enable-valgrind during make distcheck
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2015-09-21 17:32:03 +01:00
Rob Clark 14968e4cf6 freedreno: debug msg cleanup
Signed-off-by: Rob Clark <robclark@freedesktop.org>
2015-09-19 12:12:27 -04:00
Rob Clark 76a1e97eae 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>
2015-09-19 12:12:04 -04:00
Rob Clark 691d14c9a8 freedreno: don't reuse exported buffers
Signed-off-by: Rob Clark <robclark@freedesktop.org>
2015-09-19 12:11:38 -04:00
Rob Clark c349616763 Bump version for release
Signed-off-by: Rob Clark <robclark@freedesktop.org>
2015-09-16 09:03:40 -04:00
Alan Coopersmith 94ecdcb8b1 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>
2015-09-12 09:41:24 -07:00
Tvrtko Ursulin 8983fe5497 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>
2015-09-09 11:15:17 -04:00
Michel Dänzer a814152187 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>
2015-09-09 16:03:03 +01:00
Emil Velikov 7faedc9efc configure: remove -Wno-missing-field-initializers
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2015-09-04 21:39:06 +01:00
Emil Velikov 23667f566a 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>
2015-09-04 21:39:06 +01:00
Emil Velikov a9e5880b3e nouveau: use designated initializers
Cc: nouveau@lists.freedesktop.org
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2015-09-04 21:39:06 +01:00
Emil Velikov ae2cf4507c 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>
2015-09-04 21:39:06 +01:00
Emil Velikov f756877736 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>
2015-09-04 21:39:06 +01:00
Emil Velikov 05185fa054 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>
2015-09-04 21:39:06 +01:00
Emil Velikov 150ebe49ac 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>
2015-09-04 21:39:06 +01:00
Emil Velikov 6a6d668fad 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>
2015-09-04 21:39:06 +01:00
Emil Velikov ec2b105492 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>
2015-09-04 21:39:06 +01:00
Emil Velikov aecd5a1879 libkms: use static const for good measure
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2015-09-04 21:39:06 +01:00
Emil Velikov 04e243262d modetest: annotate const data as such for good measure
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2015-09-04 21:39:06 +01:00
Emil Velikov 6894f2340b 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>
2015-09-04 21:39:06 +01:00
Emil Velikov 598294dde8 configure: enable -Wshadow when available
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2015-09-04 21:39:06 +01:00
Emil Velikov 0ec7f4423d 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>
2015-09-04 21:39:01 +01:00