summaryrefslogtreecommitdiff
path: root/lib/ioctl_wrappers.h
AgeCommit message (Collapse)Author
2019-04-05lib: ioctl_wrappers: reach engines by index as wellAndi Shyti
With the new engine query method engines are reachable through an index and context they are combined with. The 'gem_has_ring()' becomes 'gem_context_has_engine()' that requires the index that the engine is mapped within the driver. The function has been moved from lib/ioctl_wappers to lib/i915/gem_context where it is more appropriate. The previous 'gem_has_ring()' function becomes a wrapper to the new 'gem_context_has_engine()'. Signed-off-by: Andi Shyti <andi.shyti@intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
2019-03-29Revert "lib/igt_device: Move intel_get_pci_device under igt_device"Ville Syrjälä
One significant usecase for intel_reg/etc. is to be able to examine the hardware state *before* loading the driver. If the tool forces the driver to load we've totally lost that capability. This reverts commit 8ae86621d6fff60b6e20c6b0f9b336785c935b0f. Cc: Michał Winiarski <michal.winiarski@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Acked-by: Jani Nikula <jani.nikula@intel.com> Acked-by: Michał Winiarski <michal.winiarski@intel.com>
2019-03-20lib/igt_device: Move intel_get_pci_device under igt_deviceMichał Winiarski
It allows us to make things a little bit more generic. Also, we now require fd rather than doing guesswork when it comes to pci address. v2: Use readlinkat rather than string concat, move stuff around, provide a version that does not assert. (Chris) v3: Print addr on failure, avoid assignment in conditionals. (Chris) Signed-off-by: Michał Winiarski <michal.winiarski@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2019-02-26lib/i915: Move mmap IOCTLs wrappers into separate fileAntonio Argenziano
Move all mmap flavours and support function to separate file in i915 folder. This helps with moving i915 specific functions away from common libraries. v2: - Autotools still exists. (Petri) - Include gem_mman.h directly. (Chris) v3: - Keep includes explicit. (Chris) Signed-off-by: Antonio Argenziano <antonio.argenziano@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Cc: Petri Latvala <petri.latvala@intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2018-10-17lib: Don't call igt_require_fb_modifiers() when no modifierDeepak Rawat
vmwgfx and amdgpu doesn't support fb modifiers, yet kms_addfb() requires modifier support. Since many tests don't need this to run, the requirement can be made less broad. Therefore, tighten the requirement to cases where modifiers are actually needed. v2: * In create_fb() calls to kms_addfb(), remove the modifier flag iff the driver doesn't support modifiers and the modifer is 0 * Don't modify the flag in kms_addfb(). Signed-off-by: Deepak Rawat <drawat@vmware.com> Signed-off-by: Leo Li <sunpeng.li@amd.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2018-09-26lib: Unexport gem_gtt_type()Chris Wilson
Nobody uses the function directly, instead using the various helpers to determine if ppgtt is present. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
2018-09-25lib/kms: Pass the number of planes explicitly to __kms_addfb()Ville Syrjälä
Currently __kms_addfb() assumes that only the first plane can be at offset 0. I don't particularly like such assumptions so let's just pass in the number of planes explicitly. We'll also require offsets[] to be passed in always. Nothing really to gain by making it optional. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
2018-09-25lib/kms: Pass strides[] to __kms_addfbVille Syrjälä
Make __kms_addfb() usable with planar formats by passing in the stride for each plane. v2: Handle strides[1] for planar formats in kms_available_modes_crc Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
2018-07-13igt/gem_userptr: Check read-only mappingsChris Wilson
Setup a userptr object that only has a read-only mapping back to a file store (memfd). Then attempt to write into that mapping using the GPU and assert that those writes do not land (while also writing via a writable userptr mapping into the same memfd to verify that the GPU is working!) v2: Pull the random batch construction into a routine to avoid duplication. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
2018-03-26lib/dummyload: Add pollable spin batchTvrtko Ursulin
Pollable spin batch exports a spin->running pointer which can be checked by dereferencing it to see if the spinner is actually executing on the GPU. This is useful for tests which want to make sure they do not proceed with their next step whilst the spinner is potentially only being processed by the driver and not actually executing. Pollable spinner can be created with igt_spin_batch_new_poll or __igt_spin_batch_new_poll, after which igt_spin_busywait_until_running can be used to busy wait until it is executing. v2: * Move READ_ONCE to igt_core. * Add igt_spin_busywait_until_running. (Chris Wilson) Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2018-02-01lib/fb: Add support for creating planar framebuffers, v3.Maarten Lankhorst
Add support to create planar framebuffers, but don't add formats that support them yet. This first requires conversion to the RGB24 format. Changes since v1: - Don't crash in igt_create_bo_with_dimensions(). Changes since v2: - Zero offsets for dumb fb too. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Reviewed-by: Mika Kahola <mika.kahola@intel.com> [mlankhorst: Change memset(4 * ..) to memset(ARRAY_SIZE(format->plane_bpp) * ..)]
2017-10-17lib/i915: Move context related helpers to lib/i915/gem_contextMichał Winiarski
We'd like to make ioctl_wrappers a bit thinner, and we plan to add new helpers in the following patch. Let's move context related helpers before adding more content. Signed-off-by: Michał Winiarski <michal.winiarski@intel.com> Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Cc: Katarzyna Dec <katarzyna.dec@intel.com> Cc: Petri Latvala <petri.latvala@intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Katarzyna Dec <katarzyna.dec@intel.com> Acked-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
2017-10-17lib/i915: Extract helpers for determining scheduler capabilitiesMichał Winiarski
Couple of tests are using either determining scheduler capabilities or pretty printing. Let's move those to helpers in lib. We can also keep the value obtained from getparam static. v2: Break the trend of expanding ioctl_wrappers Signed-off-by: Michał Winiarski <michal.winiarski@intel.com> Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Cc: Katarzyna Dec <katarzyna.dec@intel.com> Cc: Petri Latvala <petri.latvala@intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Katarzyna Dec <katarzyna.dec@intel.com> Acked-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
2017-10-03lib: Fixup __gem_create() to be 64b safe.Chris Wilson
We want to create very large objects, larger than the 2G limit imposed by using ints. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Reviwed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
2017-10-03lib: Report the error from __gem_create()Chris Wilson
We have two style of ioctl wrappers. The principle interface does error checking on behalf of the caller (to avoid having lots of repetitious code in each test), and for the few cases where the error is important for the test, we also expose a double underscore version. Fix up __gem_create() to follow this pattern and report the negative error code returned by the kernel. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
2017-09-06lib: Disable MI_STORE_DATA_IMM for gen3 (i915g and i915gm)Chris Wilson
The early gen3 machines inherited the MI block and restrictions from gen2, and may only use physical addresses in conjunction with MI_STORE_DATA_IMM -- that makes it unusable for us from userspace, where we can only use virtual offsets. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2017-07-17lib: Add reset-type helper in ioctl_wrappersMichel Thierry
Soon we will have tests that are only for platforms with reset-engine (GEN8+), so add a helper to query the has_gpu_reset via the getparam ioctl. v2: Add more helper functions to avoid using magic numbers in tests (Arek). Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Signed-off-by: Michel Thierry <michel.thierry@intel.com> Acked-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
2017-05-31lib: Moving gem_execbuf_wr to ioctl_wrappersLukasz Fiedorowicz
gem_execbuf_wr was duplicated in multiple places. Moving everything to lib/ Signed-off-by: Lukasz Fiedorowicz <lukasz.fiedorowicz@intel.com> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
2017-04-13igt/gem_exec_reloc: Check interactions with WC domainChris Wilson
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-03-08tests/gem_userptr_blits: subtests for MAP_FIXED mappings of regular BOMichał Winiarski
When the memory backing the userptr object is released by the user, but the BO itself is not closed, it's possible to trigger recursive deadlock caused by operations done on different BO mapped in that region. Testcases are simulating such behaviour by using MAP_FIXED mmap flag. Signed-off-by: Michał Winiarski <michal.winiarski@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
2017-03-08igt/gem_madvise: Correct expected resultsChris Wilson
Trying to execbuf with a purged object is meant to fail. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-02-27lib: Add basic support for valgrind annotations.Maarten Lankhorst
SIGRTMAX appears to be used by valgrind now for its internal tracking, so avoid it in the helpers. Also add some valgrind annotations in gem_mmap, to make sure that its accesses are tracked correctly. I've also added gem_munmap, but there are a lot of places that don't use it yet in tests/. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
2017-02-22igt: Start marking up GEM tests that require an alive GPU to functionChris Wilson
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-02-04tests/gem_exec_params: add test for exec_fence paramsDaniele Ceraolo Spurio
Added a subtest for invalid FENCE_IN usage, updated invalid-flag subtest and made the rsvd2 test skip when exec fences are available. Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-01-04tests/kms_ccs: Add test for render compressionTomeu Vizoso
Add a few subtests that check that lossless compressed render targets are properly displayed. Also test a few error conditions. Cc: Ville Syrjälä <ville.syrjala@linux.intel.com> Cc: Ben Widawsky <ben@bwidawsk.net> Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Acked-by: Ben Widawsky <ben@bwidawsk.net>
2017-01-02lib: Wrap conversion from u64 to pointersChris Wilson
The opposite direction of to_user_pointer() is from_user_pointer(). Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-01-02lib/ioctl_wrappers.h: Fix to_user_pointer() helperRobert Foss
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-01-02lib/ioctl_wrappers.h: Add to_user_pointer() helperRobert Foss
Add to_user_pointer() helper function which helps cast pointers properly when being used with ioctls. Signed-off-by: Robert Foss <robert.foss@collabora.com> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-11-11lib: substitute cxt BAN_PERIOD with BANNABLEMika Kuoppala
Context BAN_PERIOD will get depracated so subsitute it with BANNABLE property. Make ctx param test to accept both variants for now until kernel changes have landed, to not break BAT. v2: check against - EINVAL on get/set ban as it can return -EPERM v3: better naming for get/set (Chris) Cc: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
2016-10-19igt: Check the physical swizzle statusChris Wilson
The kernel tries to hide L-shaped memory with asymmetric swizzling from userspace by reporting lies through the get-tiling interface. Check for these lies by comparing the reported swizzle with the actual swizzle, and only run swizzling tests where we know the underlying physical swizzling. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-10-13igt/gem_ctx_param: Update invalid parma numberChris Wilson
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97108 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-10-13igt/gem_ctx_param: Tidy error messagesChris Wilson
Avoid macro expansion inside the asserts so that the error messages are readable. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-06-07igt/gem_stolen: Check for available stolen memory sizeAnkitprasad Sharma
Check for available stolen memory size before attempting to run the stolen memory tests. This way we make sure that we do not create objects from stolen memory without knowing the available size. This checks if the kernel supports creation of stolen backed objects before doing any operation on stolen backed objects. Also correcting the CREATE_VERSION ioctl number in getparam ioctl, due to kernel changes added in between. v2: Removed size argument for checking stolen memory availability (Tvrtko) Signed-off-by: Ankitprasad Sharma <ankitprasad.r.sharma@intel.com> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
2016-05-12lib/igt_aux: Polish docs for igt_interruptibleDaniel Vetter
- Give __ prefix to internal funcstion and structs, only igt_interruptible is used by tests. - Move docs to igt_interruptible and adjust. - Explain more clearly how the timeout is getting doubled each iteration until no more interruptions happen. Also rename the argument to give it a more meaningful name in the docs. - Link from other functions to this one for cross-referencing. - Rename to igt_do_interruptible to make it clearer it's a loop, inspired by do {} while () loops. v2: Rename instead to igt_while_interruptible and fix typos (Chris). And add gtk-doc for igt_ioctl, too. Acked-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
2016-04-12test/gem_mocs_settings: Testing MOCS register settingsPeter Antoine
The MOCS registers were added in Gen9 and define the caching policy. The registers are split into two sets. The first set controls the EDRAM policy and have a set for each engine, the second set controls the L3 policy. The two sets use the same index. The RCS registers and the L3CC registers are stored in the RCS context. The test checks that the registers are correct by checking the values by directly reading them via MMIO, then again it tests them by reading them from within a batch buffer. RCS engine is tested last as it programs the registers via a batch buffer and this will invalidate the test for workloads that don't use the render ring or don't run a render batch first. v2: Reorganised the structure. Added more tests. (Chris Wilson) v3: Fixed a few bugs. (Chris Wilson) v4: More Tidy-ups. (Chris Wilson) SKL does does not have a snoop bit. (Peter Antoine) Signed-off-by: Peter Antoine <peter.antoine@intel.com>
2016-03-19lib: Replace drmIoctl() with a layer of indirectionChris Wilson
Insted of calling drmIoctl() directly, call igt_ioctl() instead. In the normal scenario this is function pointer that calls drmIoctl() (so no penalty), but allows us to divert ioctls into our own routines for nefarious purposes. One such purpose will be to control interrupt generation into the ioctl, to be able to detect when we successfully interrupt the ioctl and when we no longer need more interrupts. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-03-14lib: Remove dead gem_get_num_rings()Chris Wilson
No users so time to die. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-03-14lib: Remove unused gem_has_enable_ring()Chris Wilson
No one uses this nor should they as it just gem_get_param() in disguise and they are better feature queries for whether individual execution engines are functional. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-03-08igt/gem_exec_suspend: Do pre/post suspend double checksChris Wilson
Check that the system operates normally before and after the suspend (as well as across the suspend). The goal is to isolate the breakage to the subtest. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-03-01lib: Add read/write direction support for dmabuf synchronisationChris Wilson
Allow read-only synchronisation on dmabuf mmaps, useful to allow concurrent read-read testing between the CPU and GPU. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-02-23lib: Move gem_wait() to ioctl-wrappersChris Wilson
We intend to use gem_wait() in more tests than gem_wait.c, so move the simple ioctl wrapper into the core. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-02-18lib: Restore gem_available_aperture_size()Chris Wilson
Missed an error whilst rebasing and trying to modify the previous patch to keep this function intact... Instead, I now have to add this patch to restore gem_available_aperture_size() and its one usage. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-02-18igt: Report the global GTT sizeChris Wilson
For many tests, the relevant aperture is not the ppGTT but the internal global GTT managed by the kernel. Use this limit appropriately. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-02-11lib: Add prime_sync_start and prime_sync_end helpersTiago Vignatti
This patch adds dma-buf mmap synchronization ioctls that can be used by tests for cache coherency management e.g. when CPU and GPU domains are being accessed through dma-buf at the same time. v7: add sync invalid flags test. Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com> Reviewed-by: Stéphane Marchesin <marcheu@chromium.org> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
2016-02-11prime_mmap: Add basic tests to write in a bo using CPUTiago Vignatti
This patch adds test_correct_cpu_write, which maps the texture buffer through a prime fd and then writes directly to it using the CPU. It stresses the driver to guarantee cache synchronization among the different domains. This test also adds test_forked_cpu_write, which creates the GEM bo in one process and pass the prime handle of the it to another process, which in turn uses the handle only to map and write. Roughly speaking this test simulates Chrome OS architecture, where the Web content ("unpriviledged process") maps and CPU-draws a buffer, which was previously allocated in the GPU process ("priviledged process"). This requires kernel modifications (Daniel Thompson's "drm: prime: Honour O_RDWR during prime-handle-to-fd") and therefore prime_handle_to_fd_for_mmap is added to fail in case these lack. Also, upcoming tests (e.g. next patch) are going to use it as well, so make it public and available in the lib. v2: adds prime_handle_to_fd_with_mmap for skipping test in older kernels and test for invalid flags. Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com> Reviewed-by: Stéphane Marchesin <marcheu@chromium.org> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
2016-02-11lib: Add gem_userptr and __gem_userptr helpersTiago Vignatti
This patch moves userptr definitions and helpers implementation that were locally in gem_userptr_benchmark and gem_userptr_blits to the library, so other tests can make use of them as well. There's no functional changes. v2: added __ function to differentiate when errors want to be handled back in the caller; bring gem_userptr_sync back to gem_userptr_blits; added gtkdoc. v8: remove local_i915_gem_userptr from gem_concurrent_all.c to use the global helpers instead. Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com> Reviewed-by: Stéphane Marchesin <marcheu@chromium.org> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
2016-01-27lib: Share common __gem_execbuf()Chris Wilson
An oft-repeated function to check EXECBUFFER2 for a particular fail condition. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-01-25lib/ioctl_wrappers: Add gem_has_softpinMichał Winiarski
We can move it from softpin test into lib, and since softpin support is highly unlikely to go away in-between getparam ioctl calls, let's just do a single call and store the value. v2: rebase Signed-off-by: Michał Winiarski <michal.winiarski@intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2016-01-25lib/ioctl_wrappers: Add gem_gtt_type exposing raw HAS_ALIASING_PPGTT paramMichał Winiarski
No functional changes. While I'm here, let's also rename gem_uses_aliasing_ppgtt (since it's being used to indicate if we are using ANY kind of ppgtt) and introduce gem_uses_full_ppgtt to drop some unnecessary code from tests that were previously calling getparam directly instead of using ioctl wrapper. v2: drop gem_uses_full_48b_ppgtt since it's no longer used anywhere, s/48b/64b (Chris) v3: rebase Cc: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Michał Winiarski <michal.winiarski@intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2016-01-20lib: Expand igt_hang_ring() to select target context and various optionsChris Wilson
Some potential callers want to inject a hang into a particular context, some want to trigger an actual ban and others may or may not want to capture the associated error state. Expand the hang injection interface to suit all. v2: Disable the new kernel API, but push to provide a missing piece of infrastucture to unbreak compilation. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>