This tests async processing of G2D jobs. A separate thread is spawned
to monitor the DRM fd for events and check whether a G2D job was
completed.
Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
Signed-off-by: Hyungwon Hwang <human.hwang@samsung.com>
This enables us to pass command buffers to the kernel which
trigger an event on the DRM fd upon completion.
The final goal is to enable asynchronous operation of the
G2D engine, similar to async page flips.
Passing the event userdata pointer through the G2D context
was chosen to not change the current API (e.g. by adding
a userdata argument to each public functions).
Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
Currently only fast solid color clear performance is measured.
A large buffer is allocated and solid color clear operations
are executed on it with randomly chosen properties (position
and size of the region, clear color). Execution time is
measured and output together with the amount of pixels
processed.
The 'simple' variant only executes one G2D command buffer at
a time, while the 'multi' variant executes multiple ones. This
can be used to measure setup/exec overhead.
The test also serves a stability check. If clocks/voltages are
too high or low respectively, the test quickly reveals this.
Tested-by: Hyungwon Hwang <human.hwang@samsung.com>
Reviewed-by: Hyungwon Hwang <human.hwang@samsung.com>
Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
Used to handle kernel events specific to the Exynos platform.
Currently only G2D events are handled.
Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
Signed-off-by: Hyungwon Hwang <human.hwang@samsung.com>
Softpin allows userspace to take greater control of GPU virtual address
space and eliminates the need of relocations. It can also be used to
mirror addresses between GPU and CPU (shared virtual memory).
Calls to drm_intel_bo_emit_reloc are still required to build the list of
drm_i915_gem_exec_objects at exec time, but no entries in relocs are
created. Self-relocs don't make any sense for softpinned objects and can
indicate a programming errors, thus are forbidden. Softpinned objects
are marked by asterisk in debug dumps.
Cc: Thomas Daniel <thomas.daniel@intel.com>
Cc: Kristian Høgsberg <krh@bitplanet.net>
Cc: Zou Nanhai <nanhai.zou@intel.com>
Cc: Michel Thierry <michel.thierry@intel.com>
Cc: Ben Widawsky <ben@bwidawsk.net>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
Signed-off-by: Michel Thierry <michel.thierry@intel.com>
Reviewed-by: Kristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>
Signed-off-by: Kristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>
Gen8+ supports 48-bit virtual addresses, but some objects must always be
allocated inside the 32-bit address range.
In specific, any resource used with flat/heapless (0x00000000-0xfffff000)
General State Heap (GSH) or Instruction State Heap (ISH) must be in a
32-bit range, because the General State Offset and Instruction State Offset
are limited to 32-bits.
The i915 driver has been modified to provide a flag to set when the 4GB
limit is not necessary in a given bo (EXEC_OBJECT_SUPPORTS_48B_ADDRESS).
48-bit range will only be used when explicitly requested.
Callers to the existing drm_intel_bo_emit_reloc function should set the
use_48b_address_range flag beforehand, in order to use full ppgtt range.
v2: Make set/clear functions nops on pre-gen8 platforms, and use them
internally in emit_reloc functions (Ben)
s/48BADDRESS/48B_ADDRESS/ (Dave)
v3: Keep set/clear functions internal, no-one needs to use them directly.
v4: Don't set 48bit-support flag in emit reloc, check for ppgtt type
before enabling set/clear function, print full offsets in debug
statements, using port of lower_32_bits and upper_32_bits from linux
kernel (Michał)
References: http://lists.freedesktop.org/archives/intel-gfx/2015-July/072612.html
Cc: Ben Widawsky <ben@bwidawsk.net>
Cc: Michał Winiarski <michal.winiarski@intel.com>
Signed-off-by: Michel Thierry <michel.thierry@intel.com>
Reviewed-by: Kristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>
Signed-off-by: Kristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>
It defines the prototype of ffs that fixes the building error
on Android 6.0 64-bit image.
Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
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>
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>
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>
__u64 should be used instead of u64.
Kernel headers originally pulled in:
commit 8983fe5497
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>