* [igt-dev] [PATCH i-g-t v3 1/2] tests/dumb_buffer: Tests for creation and map
@ 2019-11-29 11:24 Ramalingam C
2019-11-29 11:24 ` [igt-dev] [PATCH i-g-t v3 2/2] lib/kmstest_dumb_map_buffer: docs update Ramalingam C
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Ramalingam C @ 2019-11-29 11:24 UTC (permalink / raw)
To: igt-dev, Chris Wilson
Dumb buffer creation and mapping are covered with test cases.
v2:
Made as a generic test for dumb buffer creation [Chris]
v3:
dumb_map is used [Chris]
Added two tests for map.
Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
cc: Chris Wilson <chris@chris-wilson.co.uk>
---
tests/Makefile.am | 2 +
tests/Makefile.sources | 1 +
tests/gem_dumb_buffer.c | 317 ++++++++++++++++++++++++++++++++++++++++
tests/meson.build | 9 ++
4 files changed, 329 insertions(+)
create mode 100644 tests/gem_dumb_buffer.c
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 7fe60b78e258..a9b05416177d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -97,6 +97,8 @@ gem_ctx_freq_LDADD = $(LDADD) $(top_builddir)/lib/libigt_perf.la
gem_ctx_thrash_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
gem_ctx_thrash_LDADD = $(LDADD) -lpthread
gem_ctx_sseu_LDADD = $(LDADD) $(top_builddir)/lib/libigt_perf.la
+gem_dumb_buffer_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
+gem_dumb_buffer_LDADD = $(LDADD) -lpthread -latomic
gem_exec_balancer_LDADD = $(LDADD) $(top_builddir)/lib/libigt_perf.la
gem_exec_capture_LDADD = $(LDADD) -lz
gem_exec_parallel_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index bdd912d2d5a8..df9756dd703e 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -99,6 +99,7 @@ TESTS_progs = \
tools_test \
vgem_basic \
vgem_slow \
+ gem_dumb_buffer \
$(NULL)
TESTS_progs += gem_bad_reloc
diff --git a/tests/gem_dumb_buffer.c b/tests/gem_dumb_buffer.c
new file mode 100644
index 000000000000..caf1adb1fadb
--- /dev/null
+++ b/tests/gem_dumb_buffer.c
@@ -0,0 +1,317 @@
+/*
+ * Copyright © 2019 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ * Ramalingam C <ramalingam.c@intel.com>
+ *
+ */
+
+/** @file gem_dumb_buffer.c
+ *
+ * This is a test for the extended and old gem_create_dumb and gem_map_dumb
+ * ioctl, that includes allocation of object from stolen memory, shmem and
+ * local memory.
+ *
+ * The goal is to simply ensure that basics work and invalid input
+ * combinations are rejected.
+ */
+
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <getopt.h>
+#include <pthread.h>
+#include <stdatomic.h>
+
+#include <drm.h>
+
+#include "ioctl_wrappers.h"
+#include "intel_bufmgr.h"
+#include "intel_batchbuffer.h"
+#include "intel_io.h"
+#include "intel_chipset.h"
+#include "igt_aux.h"
+#include "drmtest.h"
+#include "drm.h"
+#include "i915_drm.h"
+#include "igt_kms.h"
+
+IGT_TEST_DESCRIPTION("This is a test for the extended & old gem_create_dumb and"
+ " gem_map_dumb ioctl,"
+ " that includes allocation of object from stolen memory,"
+ " shmem and local memory.");
+
+#define CLEAR(s) memset(&s, 0, sizeof(s))
+#define PAGE_SIZE 4096
+
+static void invalid_dimensions_test(int fd)
+{
+ struct drm_mode_create_dumb create;
+
+ memset(&create, 0, sizeof(create));
+ create.width = 4032;
+ create.height = 2016;
+ create.bpp = 24;
+ do_ioctl_err(fd, DRM_IOCTL_MODE_CREATE_DUMB, &create, EINVAL);
+
+ create.bpp = 32;
+ create.width = 0;
+ do_ioctl_err(fd, DRM_IOCTL_MODE_CREATE_DUMB, &create, EINVAL);
+
+ create.width = 4032;
+ create.height = 0;
+ do_ioctl_err(fd, DRM_IOCTL_MODE_CREATE_DUMB, &create, EINVAL);
+}
+
+static void valid_dumb_creation_test(int fd)
+{
+ struct drm_mode_create_dumb create = {
+ .width = 4032,
+ .height = 2016,
+ .bpp = 32,
+ };
+
+ do_ioctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &create);
+ gem_close(fd, create.handle);
+}
+
+static void valid_map(int fd)
+{
+ struct drm_mode_create_dumb create = {
+ .width = 4032,
+ .height = 2016,
+ .bpp = 32,
+ };
+ void *ptr;
+
+ do_ioctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &create);
+ ptr = kmstest_dumb_map_buffer(fd, create.handle, create.size,
+ PROT_READ | PROT_WRITE);
+ munmap(ptr, create.size);
+ gem_close(fd, create.handle);
+}
+
+static void invalid_size_map(int fd)
+{
+ struct drm_mode_map_dumb arg = {};
+ struct drm_mode_create_dumb create = {
+ .width = 4032,
+ .height = 2016,
+ .bpp = 32,
+ };
+ void *ptr;
+
+ do_ioctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &create);
+
+ arg.handle = create.handle;
+ do_ioctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &arg);
+
+ ptr = mmap(NULL, create.size + 1, PROT_READ | PROT_WRITE,
+ MAP_SHARED, fd, arg.offset);
+ igt_assert(ptr == MAP_FAILED);
+
+ gem_close(fd, create.handle);
+}
+
+/*
+ * Creating an dumb buffer with non-aligned size and trying to access it with an
+ * offset, which is greater than the requested size but smaller than the
+ * object's last page boundary. pwrite here must be successful.
+ */
+static void valid_nonaligned_size(int fd)
+{
+ struct drm_mode_create_dumb create = {
+ .width = 24,
+ .height = 24,
+ .bpp = 32,
+ };
+ char buf[PAGE_SIZE];
+
+ do_ioctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &create);
+
+ gem_write(fd, create.handle, PAGE_SIZE / 2, buf, PAGE_SIZE / 2);
+
+ gem_close(fd, create.handle);
+}
+
+/*
+ * Creating an object with non-aligned size and trying to access it with an
+ * offset, which is greater than the requested size and larger than the
+ * object's last page boundary. pwrite here must fail.
+ */
+static void invalid_nonaligned_size(int fd)
+{
+ struct drm_mode_create_dumb create = {
+ .width = 24,
+ .height = 24,
+ .bpp = 32,
+ };
+ char buf[PAGE_SIZE];
+
+ do_ioctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &create);
+ /* This should fail. Hence cannot use gem_write. */
+ igt_assert(__gem_write(fd, create.handle,
+ create.size - (PAGE_SIZE / 2), buf, PAGE_SIZE));
+ gem_close(fd, create.handle);
+}
+
+static uint64_t atomic_compare_swap_u64(_Atomic(uint64_t) *ptr,
+ uint64_t oldval, uint64_t newval)
+{
+ atomic_compare_exchange_strong(ptr, &oldval, newval);
+ return oldval;
+}
+
+static uint64_t get_npages(_Atomic(uint64_t) *global, uint64_t npages)
+{
+ uint64_t try, old, max;
+
+ max = *global;
+ do {
+ old = max;
+ try = 1 + npages % ((max / 2) ? (max / 2) : 1);
+ max -= try;
+ } while ((max = atomic_compare_swap_u64(global, old, max)) != old);
+
+ return try;
+}
+
+struct thread_clear {
+ _Atomic(uint64_t) max;
+ int timeout;
+ int fd;
+};
+
+#define MAX_PAGE_TO_REQUEST 102400
+
+static void *thread_clear(void *data)
+{
+ struct thread_clear *arg = data;
+ unsigned long checked = 0;
+ int fd = arg->fd;
+ void *ptr;
+
+ igt_until_timeout(arg->timeout) {
+ struct drm_mode_create_dumb create = {};
+ uint64_t npages;
+
+ npages = random();
+ npages = npages << 32;
+ npages |= random();
+ npages = get_npages(&arg->max, npages);
+
+ for(uint64_t _npages = npages; npages > 0; npages -= _npages)
+ {
+ create.bpp = 32;
+ create.width = PAGE_SIZE / (create.bpp / 8);
+ _npages = npages <= MAX_PAGE_TO_REQUEST ? npages :
+ MAX_PAGE_TO_REQUEST;
+ create.height = _npages;
+
+ do_ioctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &create);
+
+ igt_assert(_npages == create.size / PAGE_SIZE);
+
+ ptr = kmstest_dumb_map_buffer(fd, create.handle,
+ create.size,
+ PROT_READ | PROT_WRITE);
+
+ for (uint64_t page = 0; page < _npages; page++) {
+ uint64_t x;
+ memcpy(&x, ptr + page * 4096 +
+ page % (4096 - sizeof(x)), sizeof(x));
+ igt_assert_eq_u64(x, 0);
+ }
+
+ if (ptr)
+ munmap(ptr, create.size);
+
+ kmstest_dumb_destroy(fd, create.handle);
+ atomic_fetch_add(&arg->max, _npages);
+ checked += _npages;
+ }
+
+ }
+
+ return (void *)(uintptr_t)checked;
+}
+
+static void always_clear(int fd, int timeout)
+{
+ struct thread_clear arg = {
+ .fd = fd,
+ .timeout = timeout,
+ .max = intel_get_avail_ram_mb() << (20 - 12), /* in pages */
+ };
+ const int ncpus = sysconf(_SC_NPROCESSORS_ONLN);
+ unsigned long checked;
+ pthread_t thread[ncpus];
+ void *result;
+
+ for (int i = 0; i < ncpus; i++)
+ pthread_create(&thread[i], NULL, thread_clear, &arg);
+
+ checked = 0;
+ for (int i = 0; i < ncpus; i++) {
+ pthread_join(thread[i], &result);
+ checked += (uintptr_t)result;
+ }
+ igt_info("Checked %'lu page allocations\n", checked);
+}
+
+igt_main
+{
+ int fd = -1;
+
+ igt_skip_on_simulation();
+
+ igt_fixture {
+ fd = drm_open_driver(DRIVER_ANY);
+ }
+
+ igt_subtest("invalid-bpp")
+ invalid_dimensions_test(fd);
+
+ igt_subtest("create-valid-dumb")
+ valid_dumb_creation_test(fd);
+
+ igt_subtest("create-valid-nonaligned")
+ valid_nonaligned_size(fd);
+
+ igt_subtest("create-invalid-nonaligned")
+ invalid_nonaligned_size(fd);
+
+ igt_subtest("map-valid")
+ valid_map(fd);
+
+ igt_subtest("map-invalid-size")
+ invalid_size_map(fd);
+
+ igt_subtest("create-clear")
+ always_clear(fd, 30);
+}
diff --git a/tests/meson.build b/tests/meson.build
index 59c6961f1026..f043f4aff95b 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -97,6 +97,7 @@ test_progs = [
'vc4_wait_seqno',
'vgem_basic',
'vgem_slow',
+ 'gem_dumb_buffer'
]
i915_progs = [
@@ -297,6 +298,14 @@ test_executables += executable('gem_ctx_freq',
install : true)
test_list += 'gem_ctx_freq'
+# test_executables += executable('gem_dumb_buffer',
+# join_paths('i915', 'gem_dumb_buffer.c'),
+# dependencies : test_deps + [ libatomic ],
+# install_dir : libexecdir,
+# install_rpath : libexecdir_rpathdir,
+# install : true)
+#test_list += 'gem_dumb_buffer'
+
test_executables += executable('gem_ctx_sseu',
join_paths('i915', 'gem_ctx_sseu.c'),
dependencies : test_deps + [ lib_igt_perf ],
--
2.20.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 5+ messages in thread* [igt-dev] [PATCH i-g-t v3 2/2] lib/kmstest_dumb_map_buffer: docs update
2019-11-29 11:24 [igt-dev] [PATCH i-g-t v3 1/2] tests/dumb_buffer: Tests for creation and map Ramalingam C
@ 2019-11-29 11:24 ` Ramalingam C
2019-11-29 11:37 ` [igt-dev] ✗ GitLab.Pipeline: warning for series starting with [i-g-t,v3,1/2] tests/dumb_buffer: Tests for creation and map Patchwork
2019-11-29 11:53 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2 siblings, 0 replies; 5+ messages in thread
From: Ramalingam C @ 2019-11-29 11:24 UTC (permalink / raw)
To: igt-dev, Chris Wilson
Added the need for munmapping the returned pointer, after its usage.
Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
---
lib/igt_kms.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index e9b80b9bcb81..9242065ed36a 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -837,6 +837,7 @@ uint32_t kmstest_dumb_create(int fd, int width, int height, int bpp,
* @size: Length of the mapping, must be greater than 0
* @prot: Describes the memory protection of the mapping
* Returns: A pointer representing the start of the virtual mapping
+ * Caller of this function should munmap the pointer returned, after its usage.
*/
void *kmstest_dumb_map_buffer(int fd, uint32_t handle, uint64_t size,
unsigned prot)
--
2.20.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [igt-dev] ✗ GitLab.Pipeline: warning for series starting with [i-g-t,v3,1/2] tests/dumb_buffer: Tests for creation and map
2019-11-29 11:24 [igt-dev] [PATCH i-g-t v3 1/2] tests/dumb_buffer: Tests for creation and map Ramalingam C
2019-11-29 11:24 ` [igt-dev] [PATCH i-g-t v3 2/2] lib/kmstest_dumb_map_buffer: docs update Ramalingam C
@ 2019-11-29 11:37 ` Patchwork
2019-11-29 11:53 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2 siblings, 0 replies; 5+ messages in thread
From: Patchwork @ 2019-11-29 11:37 UTC (permalink / raw)
To: Ramalingam C; +Cc: igt-dev
== Series Details ==
Series: series starting with [i-g-t,v3,1/2] tests/dumb_buffer: Tests for creation and map
URL : https://patchwork.freedesktop.org/series/70203/
State : warning
== Summary ==
Did not get list of undocumented tests for this run, something is wrong!
Other than that, pipeline status: FAILED.
see https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/pipelines/84009 for the overview.
build:tests-debian-meson-mips has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/1038966):
FAILED: tests/gem_dumb_buffer
/usr/bin/mips-linux-gnu-gcc -o tests/gem_dumb_buffer 'tests/59830eb@@gem_dumb_buffer@exe/gem_dumb_buffer.c.o' -Wl,--no-undefined -Wl,--as-needed -Wl,--start-group lib/libigt.so.0 /usr/lib/mips-linux-gnu/libcairo.so /usr/lib/mips-linux-gnu/libglib-2.0.so /usr/lib/mips-linux-gnu/libdrm.so /usr/lib/mips-linux-gnu/libdw.so /usr/lib/mips-linux-gnu/libelf.so /usr/lib/mips-linux-gnu/libkmod.so /usr/lib/mips-linux-gnu/libprocps.so /lib/mips-linux-gnu/libudev.so -lm /usr/lib/mips-linux-gnu/libpciaccess.so /usr/lib/mips-linux-gnu/libpixman-1.so -lrt -lz /usr/lib/mips-linux-gnu/libunwind.so /usr/lib/mips-linux-gnu/libgsl.so /usr/lib/mips-linux-gnu/libgslcblas.so -lm /usr/lib/mips-linux-gnu/libasound.so /usr/lib/mips-linux-gnu/libdrm_nouveau.so -Wl,--end-group -pthread '-Wl,-rpath,$ORIGIN/../lib' -Wl,-rpath-link,/builds/gfx-ci/igt-ci-tags/build/lib
tests/59830eb@@gem_dumb_buffer@exe/gem_dumb_buffer.c.o: In function `get_npages':
/builds/gfx-ci/igt-ci-tags/build/../tests/gem_dumb_buffer.c:194: undefined reference to `__atomic_load_8'
/builds/gfx-ci/igt-ci-tags/build/../tests/gem_dumb_buffer.c:194: undefined reference to `__atomic_load_8'
tests/59830eb@@gem_dumb_buffer@exe/gem_dumb_buffer.c.o: In function `atomic_compare_swap_u64':
/builds/gfx-ci/igt-ci-tags/build/../tests/gem_dumb_buffer.c:186: undefined reference to `__atomic_compare_exchange_8'
/builds/gfx-ci/igt-ci-tags/build/../tests/gem_dumb_buffer.c:186: undefined reference to `__atomic_compare_exchange_8'
tests/59830eb@@gem_dumb_buffer@exe/gem_dumb_buffer.c.o: In function `thread_clear':
/builds/gfx-ci/igt-ci-tags/build/../tests/gem_dumb_buffer.c:255: undefined reference to `__atomic_fetch_add_8'
/builds/gfx-ci/igt-ci-tags/build/../tests/gem_dumb_buffer.c:255: undefined reference to `__atomic_fetch_add_8'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
section_end:1575027178:build_script
^[[0Ksection_start:1575027178:after_script
^[[0Ksection_end:1575027179:after_script
^[[0Ksection_start:1575027179:upload_artifacts_on_failure
^[[0Ksection_end:1575027181:upload_artifacts_on_failure
^[[0K^[[31;1mERROR: Job failed: exit code 1
^[[0;m
== Logs ==
For more details see: https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/pipelines/84009
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 5+ messages in thread
* [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,v3,1/2] tests/dumb_buffer: Tests for creation and map
2019-11-29 11:24 [igt-dev] [PATCH i-g-t v3 1/2] tests/dumb_buffer: Tests for creation and map Ramalingam C
2019-11-29 11:24 ` [igt-dev] [PATCH i-g-t v3 2/2] lib/kmstest_dumb_map_buffer: docs update Ramalingam C
2019-11-29 11:37 ` [igt-dev] ✗ GitLab.Pipeline: warning for series starting with [i-g-t,v3,1/2] tests/dumb_buffer: Tests for creation and map Patchwork
@ 2019-11-29 11:53 ` Patchwork
2 siblings, 0 replies; 5+ messages in thread
From: Patchwork @ 2019-11-29 11:53 UTC (permalink / raw)
To: Ramalingam C; +Cc: igt-dev
== Series Details ==
Series: series starting with [i-g-t,v3,1/2] tests/dumb_buffer: Tests for creation and map
URL : https://patchwork.freedesktop.org/series/70203/
State : success
== Summary ==
CI Bug Log - changes from IGT_5316 -> IGTPW_3784
====================================================
Summary
-------
**SUCCESS**
No regressions found.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3784/index.html
Known issues
------------
Here are the changes found in IGTPW_3784 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@gem_exec_gttfill@basic:
- fi-tgl-y: [PASS][1] -> [INCOMPLETE][2] ([fdo#111593])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5316/fi-tgl-y/igt@gem_exec_gttfill@basic.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3784/fi-tgl-y/igt@gem_exec_gttfill@basic.html
* igt@i915_selftest@live_blt:
- fi-hsw-peppy: [PASS][3] -> [DMESG-FAIL][4] ([fdo#112147])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5316/fi-hsw-peppy/igt@i915_selftest@live_blt.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3784/fi-hsw-peppy/igt@i915_selftest@live_blt.html
* igt@kms_chamelium@dp-crc-fast:
- fi-kbl-7500u: [PASS][5] -> [FAIL][6] ([fdo#109483] / [fdo#109635 ]) +1 similar issue
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5316/fi-kbl-7500u/igt@kms_chamelium@dp-crc-fast.html
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3784/fi-kbl-7500u/igt@kms_chamelium@dp-crc-fast.html
#### Possible fixes ####
* igt@i915_pm_rpm@module-reload:
- fi-skl-6770hq: [FAIL][7] ([fdo#108511]) -> [PASS][8]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5316/fi-skl-6770hq/igt@i915_pm_rpm@module-reload.html
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3784/fi-skl-6770hq/igt@i915_pm_rpm@module-reload.html
* igt@i915_selftest@live_gt_heartbeat:
- fi-skl-6600u: [DMESG-FAIL][9] ([fdo#112405]) -> [PASS][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5316/fi-skl-6600u/igt@i915_selftest@live_gt_heartbeat.html
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3784/fi-skl-6600u/igt@i915_selftest@live_gt_heartbeat.html
* igt@kms_frontbuffer_tracking@basic:
- fi-hsw-peppy: [DMESG-WARN][11] ([fdo#102614]) -> [PASS][12]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5316/fi-hsw-peppy/igt@kms_frontbuffer_tracking@basic.html
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3784/fi-hsw-peppy/igt@kms_frontbuffer_tracking@basic.html
#### Warnings ####
* igt@gem_exec_suspend@basic-s4-devices:
- fi-kbl-x1275: [DMESG-WARN][13] ([fdo#103558] / [fdo#105602] / [fdo#105763] / [fdo#107139]) -> [DMESG-WARN][14] ([fdo#103558] / [fdo#105602] / [fdo#107139])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5316/fi-kbl-x1275/igt@gem_exec_suspend@basic-s4-devices.html
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3784/fi-kbl-x1275/igt@gem_exec_suspend@basic-s4-devices.html
* igt@i915_pm_rpm@basic-pci-d3-state:
- fi-kbl-x1275: [DMESG-WARN][15] ([fdo#103558] / [fdo#105602] / [fdo#105763]) -> [SKIP][16] ([fdo#109271])
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5316/fi-kbl-x1275/igt@i915_pm_rpm@basic-pci-d3-state.html
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3784/fi-kbl-x1275/igt@i915_pm_rpm@basic-pci-d3-state.html
* igt@kms_busy@basic-flip-pipe-a:
- fi-kbl-x1275: [DMESG-WARN][17] ([fdo#103558] / [fdo#105602] / [fdo#105763]) -> [DMESG-WARN][18] ([fdo#103558] / [fdo#105602]) +9 similar issues
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5316/fi-kbl-x1275/igt@kms_busy@basic-flip-pipe-a.html
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3784/fi-kbl-x1275/igt@kms_busy@basic-flip-pipe-a.html
* igt@kms_busy@basic-flip-pipe-b:
- fi-kbl-x1275: [DMESG-WARN][19] ([fdo#103558] / [fdo#105602]) -> [DMESG-WARN][20] ([fdo#103558] / [fdo#105602] / [fdo#105763]) +6 similar issues
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5316/fi-kbl-x1275/igt@kms_busy@basic-flip-pipe-b.html
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3784/fi-kbl-x1275/igt@kms_busy@basic-flip-pipe-b.html
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#102614]: https://bugs.freedesktop.org/show_bug.cgi?id=102614
[fdo#103558]: https://bugs.freedesktop.org/show_bug.cgi?id=103558
[fdo#105602]: https://bugs.freedesktop.org/show_bug.cgi?id=105602
[fdo#105763]: https://bugs.freedesktop.org/show_bug.cgi?id=105763
[fdo#107139]: https://bugs.freedesktop.org/show_bug.cgi?id=107139
[fdo#108511]: https://bugs.freedesktop.org/show_bug.cgi?id=108511
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109483]: https://bugs.freedesktop.org/show_bug.cgi?id=109483
[fdo#109635 ]: https://bugs.freedesktop.org/show_bug.cgi?id=109635
[fdo#109964]: https://bugs.freedesktop.org/show_bug.cgi?id=109964
[fdo#111593]: https://bugs.freedesktop.org/show_bug.cgi?id=111593
[fdo#111747]: https://bugs.freedesktop.org/show_bug.cgi?id=111747
[fdo#112147]: https://bugs.freedesktop.org/show_bug.cgi?id=112147
[fdo#112298]: https://bugs.freedesktop.org/show_bug.cgi?id=112298
[fdo#112405]: https://bugs.freedesktop.org/show_bug.cgi?id=112405
Participating hosts (51 -> 46)
------------------------------
Additional (1): fi-cfl-guc
Missing (6): fi-ilk-m540 fi-hsw-4200u fi-bsw-cyan fi-ctg-p8600 fi-byt-clapper fi-bdw-samus
Build changes
-------------
* CI: CI-20190529 -> None
* IGT: IGT_5316 -> IGTPW_3784
CI-20190529: 20190529
CI_DRM_7440: 7b08e6efdddfcde8ea60a96d5a818af032b52b4d @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_3784: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3784/index.html
IGT_5316: f38b398103fea0423b7bf133bbe5868fde99623c @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
== Testlist changes ==
+igt@gem_dumb_buffer@create-clear
+igt@gem_dumb_buffer@create-invalid-nonaligned
+igt@gem_dumb_buffer@create-valid-dumb
+igt@gem_dumb_buffer@create-valid-nonaligned
+igt@gem_dumb_buffer@invalid-bpp
+igt@gem_dumb_buffer@map-invalid-size
+igt@gem_dumb_buffer@map-valid
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3784/index.html
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 5+ messages in thread
* [igt-dev] [PATCH i-g-t v3 1/2] tests/dumb_buffer: Tests for creation and map
@ 2019-11-28 18:09 Ramalingam C
2019-11-28 18:09 ` [igt-dev] [PATCH i-g-t v3 2/2] lib/kmstest_dumb_map_buffer: docs update Ramalingam C
0 siblings, 1 reply; 5+ messages in thread
From: Ramalingam C @ 2019-11-28 18:09 UTC (permalink / raw)
To: igt-dev, Chris Wilson
Dumb buffer creation and mapping are covered with test cases.
v2:
Made as a generic test for dumb buffer creation [Chris]
v3:
dumb_map is used [Chris]
Added two tests for map.
Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
cc: Chris Wilson <chris@chris-wilson.co.uk>
---
tests/Makefile.am | 2 +
tests/Makefile.sources | 1 +
tests/gem_dumb_buffer.c | 317 ++++++++++++++++++++++++++++++++++++++++
tests/meson.build | 9 ++
4 files changed, 329 insertions(+)
create mode 100644 tests/gem_dumb_buffer.c
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 7d71df8c7a2e..66e69558663a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -96,6 +96,8 @@ gem_close_race_LDADD = $(LDADD) -lpthread
gem_ctx_thrash_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
gem_ctx_thrash_LDADD = $(LDADD) -lpthread
gem_ctx_sseu_LDADD = $(LDADD) $(top_builddir)/lib/libigt_perf.la
+gem_dumb_buffer_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
+gem_dumb_buffer_LDADD = $(LDADD) -lpthread -latomic
gem_exec_balancer_LDADD = $(LDADD) $(top_builddir)/lib/libigt_perf.la
gem_exec_capture_LDADD = $(LDADD) -lz
gem_exec_parallel_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index 27801c89c46d..d02bbd0d981c 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -99,6 +99,7 @@ TESTS_progs = \
tools_test \
vgem_basic \
vgem_slow \
+ gem_dumb_buffer \
$(NULL)
TESTS_progs += gem_bad_reloc
diff --git a/tests/gem_dumb_buffer.c b/tests/gem_dumb_buffer.c
new file mode 100644
index 000000000000..caf1adb1fadb
--- /dev/null
+++ b/tests/gem_dumb_buffer.c
@@ -0,0 +1,317 @@
+/*
+ * Copyright © 2019 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ * Ramalingam C <ramalingam.c@intel.com>
+ *
+ */
+
+/** @file gem_dumb_buffer.c
+ *
+ * This is a test for the extended and old gem_create_dumb and gem_map_dumb
+ * ioctl, that includes allocation of object from stolen memory, shmem and
+ * local memory.
+ *
+ * The goal is to simply ensure that basics work and invalid input
+ * combinations are rejected.
+ */
+
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <getopt.h>
+#include <pthread.h>
+#include <stdatomic.h>
+
+#include <drm.h>
+
+#include "ioctl_wrappers.h"
+#include "intel_bufmgr.h"
+#include "intel_batchbuffer.h"
+#include "intel_io.h"
+#include "intel_chipset.h"
+#include "igt_aux.h"
+#include "drmtest.h"
+#include "drm.h"
+#include "i915_drm.h"
+#include "igt_kms.h"
+
+IGT_TEST_DESCRIPTION("This is a test for the extended & old gem_create_dumb and"
+ " gem_map_dumb ioctl,"
+ " that includes allocation of object from stolen memory,"
+ " shmem and local memory.");
+
+#define CLEAR(s) memset(&s, 0, sizeof(s))
+#define PAGE_SIZE 4096
+
+static void invalid_dimensions_test(int fd)
+{
+ struct drm_mode_create_dumb create;
+
+ memset(&create, 0, sizeof(create));
+ create.width = 4032;
+ create.height = 2016;
+ create.bpp = 24;
+ do_ioctl_err(fd, DRM_IOCTL_MODE_CREATE_DUMB, &create, EINVAL);
+
+ create.bpp = 32;
+ create.width = 0;
+ do_ioctl_err(fd, DRM_IOCTL_MODE_CREATE_DUMB, &create, EINVAL);
+
+ create.width = 4032;
+ create.height = 0;
+ do_ioctl_err(fd, DRM_IOCTL_MODE_CREATE_DUMB, &create, EINVAL);
+}
+
+static void valid_dumb_creation_test(int fd)
+{
+ struct drm_mode_create_dumb create = {
+ .width = 4032,
+ .height = 2016,
+ .bpp = 32,
+ };
+
+ do_ioctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &create);
+ gem_close(fd, create.handle);
+}
+
+static void valid_map(int fd)
+{
+ struct drm_mode_create_dumb create = {
+ .width = 4032,
+ .height = 2016,
+ .bpp = 32,
+ };
+ void *ptr;
+
+ do_ioctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &create);
+ ptr = kmstest_dumb_map_buffer(fd, create.handle, create.size,
+ PROT_READ | PROT_WRITE);
+ munmap(ptr, create.size);
+ gem_close(fd, create.handle);
+}
+
+static void invalid_size_map(int fd)
+{
+ struct drm_mode_map_dumb arg = {};
+ struct drm_mode_create_dumb create = {
+ .width = 4032,
+ .height = 2016,
+ .bpp = 32,
+ };
+ void *ptr;
+
+ do_ioctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &create);
+
+ arg.handle = create.handle;
+ do_ioctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &arg);
+
+ ptr = mmap(NULL, create.size + 1, PROT_READ | PROT_WRITE,
+ MAP_SHARED, fd, arg.offset);
+ igt_assert(ptr == MAP_FAILED);
+
+ gem_close(fd, create.handle);
+}
+
+/*
+ * Creating an dumb buffer with non-aligned size and trying to access it with an
+ * offset, which is greater than the requested size but smaller than the
+ * object's last page boundary. pwrite here must be successful.
+ */
+static void valid_nonaligned_size(int fd)
+{
+ struct drm_mode_create_dumb create = {
+ .width = 24,
+ .height = 24,
+ .bpp = 32,
+ };
+ char buf[PAGE_SIZE];
+
+ do_ioctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &create);
+
+ gem_write(fd, create.handle, PAGE_SIZE / 2, buf, PAGE_SIZE / 2);
+
+ gem_close(fd, create.handle);
+}
+
+/*
+ * Creating an object with non-aligned size and trying to access it with an
+ * offset, which is greater than the requested size and larger than the
+ * object's last page boundary. pwrite here must fail.
+ */
+static void invalid_nonaligned_size(int fd)
+{
+ struct drm_mode_create_dumb create = {
+ .width = 24,
+ .height = 24,
+ .bpp = 32,
+ };
+ char buf[PAGE_SIZE];
+
+ do_ioctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &create);
+ /* This should fail. Hence cannot use gem_write. */
+ igt_assert(__gem_write(fd, create.handle,
+ create.size - (PAGE_SIZE / 2), buf, PAGE_SIZE));
+ gem_close(fd, create.handle);
+}
+
+static uint64_t atomic_compare_swap_u64(_Atomic(uint64_t) *ptr,
+ uint64_t oldval, uint64_t newval)
+{
+ atomic_compare_exchange_strong(ptr, &oldval, newval);
+ return oldval;
+}
+
+static uint64_t get_npages(_Atomic(uint64_t) *global, uint64_t npages)
+{
+ uint64_t try, old, max;
+
+ max = *global;
+ do {
+ old = max;
+ try = 1 + npages % ((max / 2) ? (max / 2) : 1);
+ max -= try;
+ } while ((max = atomic_compare_swap_u64(global, old, max)) != old);
+
+ return try;
+}
+
+struct thread_clear {
+ _Atomic(uint64_t) max;
+ int timeout;
+ int fd;
+};
+
+#define MAX_PAGE_TO_REQUEST 102400
+
+static void *thread_clear(void *data)
+{
+ struct thread_clear *arg = data;
+ unsigned long checked = 0;
+ int fd = arg->fd;
+ void *ptr;
+
+ igt_until_timeout(arg->timeout) {
+ struct drm_mode_create_dumb create = {};
+ uint64_t npages;
+
+ npages = random();
+ npages = npages << 32;
+ npages |= random();
+ npages = get_npages(&arg->max, npages);
+
+ for(uint64_t _npages = npages; npages > 0; npages -= _npages)
+ {
+ create.bpp = 32;
+ create.width = PAGE_SIZE / (create.bpp / 8);
+ _npages = npages <= MAX_PAGE_TO_REQUEST ? npages :
+ MAX_PAGE_TO_REQUEST;
+ create.height = _npages;
+
+ do_ioctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &create);
+
+ igt_assert(_npages == create.size / PAGE_SIZE);
+
+ ptr = kmstest_dumb_map_buffer(fd, create.handle,
+ create.size,
+ PROT_READ | PROT_WRITE);
+
+ for (uint64_t page = 0; page < _npages; page++) {
+ uint64_t x;
+ memcpy(&x, ptr + page * 4096 +
+ page % (4096 - sizeof(x)), sizeof(x));
+ igt_assert_eq_u64(x, 0);
+ }
+
+ if (ptr)
+ munmap(ptr, create.size);
+
+ kmstest_dumb_destroy(fd, create.handle);
+ atomic_fetch_add(&arg->max, _npages);
+ checked += _npages;
+ }
+
+ }
+
+ return (void *)(uintptr_t)checked;
+}
+
+static void always_clear(int fd, int timeout)
+{
+ struct thread_clear arg = {
+ .fd = fd,
+ .timeout = timeout,
+ .max = intel_get_avail_ram_mb() << (20 - 12), /* in pages */
+ };
+ const int ncpus = sysconf(_SC_NPROCESSORS_ONLN);
+ unsigned long checked;
+ pthread_t thread[ncpus];
+ void *result;
+
+ for (int i = 0; i < ncpus; i++)
+ pthread_create(&thread[i], NULL, thread_clear, &arg);
+
+ checked = 0;
+ for (int i = 0; i < ncpus; i++) {
+ pthread_join(thread[i], &result);
+ checked += (uintptr_t)result;
+ }
+ igt_info("Checked %'lu page allocations\n", checked);
+}
+
+igt_main
+{
+ int fd = -1;
+
+ igt_skip_on_simulation();
+
+ igt_fixture {
+ fd = drm_open_driver(DRIVER_ANY);
+ }
+
+ igt_subtest("invalid-bpp")
+ invalid_dimensions_test(fd);
+
+ igt_subtest("create-valid-dumb")
+ valid_dumb_creation_test(fd);
+
+ igt_subtest("create-valid-nonaligned")
+ valid_nonaligned_size(fd);
+
+ igt_subtest("create-invalid-nonaligned")
+ invalid_nonaligned_size(fd);
+
+ igt_subtest("map-valid")
+ valid_map(fd);
+
+ igt_subtest("map-invalid-size")
+ invalid_size_map(fd);
+
+ igt_subtest("create-clear")
+ always_clear(fd, 30);
+}
diff --git a/tests/meson.build b/tests/meson.build
index 755fc9e6f2d7..915a567d4a97 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -97,6 +97,7 @@ test_progs = [
'vc4_wait_seqno',
'vgem_basic',
'vgem_slow',
+ 'gem_dumb_buffer'
]
i915_progs = [
@@ -291,6 +292,14 @@ test_executables += executable('gem_create',
install : true)
test_list += 'gem_create'
+# test_executables += executable('gem_dumb_buffer',
+# join_paths('i915', 'gem_dumb_buffer.c'),
+# dependencies : test_deps + [ libatomic ],
+# install_dir : libexecdir,
+# install_rpath : libexecdir_rpathdir,
+# install : true)
+#test_list += 'gem_dumb_buffer'
+
test_executables += executable('gem_ctx_sseu',
join_paths('i915', 'gem_ctx_sseu.c'),
dependencies : test_deps + [ lib_igt_perf ],
--
2.20.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 5+ messages in thread* [igt-dev] [PATCH i-g-t v3 2/2] lib/kmstest_dumb_map_buffer: docs update
2019-11-28 18:09 [igt-dev] [PATCH i-g-t v3 1/2] " Ramalingam C
@ 2019-11-28 18:09 ` Ramalingam C
0 siblings, 0 replies; 5+ messages in thread
From: Ramalingam C @ 2019-11-28 18:09 UTC (permalink / raw)
To: igt-dev, Chris Wilson
Added the need for munmapping the returned pointer, after its usage.
Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
---
lib/igt_kms.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index e9b80b9bcb81..9242065ed36a 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -837,6 +837,7 @@ uint32_t kmstest_dumb_create(int fd, int width, int height, int bpp,
* @size: Length of the mapping, must be greater than 0
* @prot: Describes the memory protection of the mapping
* Returns: A pointer representing the start of the virtual mapping
+ * Caller of this function should munmap the pointer returned, after its usage.
*/
void *kmstest_dumb_map_buffer(int fd, uint32_t handle, uint64_t size,
unsigned prot)
--
2.20.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-11-29 11:53 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-29 11:24 [igt-dev] [PATCH i-g-t v3 1/2] tests/dumb_buffer: Tests for creation and map Ramalingam C
2019-11-29 11:24 ` [igt-dev] [PATCH i-g-t v3 2/2] lib/kmstest_dumb_map_buffer: docs update Ramalingam C
2019-11-29 11:37 ` [igt-dev] ✗ GitLab.Pipeline: warning for series starting with [i-g-t,v3,1/2] tests/dumb_buffer: Tests for creation and map Patchwork
2019-11-29 11:53 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2019-11-28 18:09 [igt-dev] [PATCH i-g-t v3 1/2] " Ramalingam C
2019-11-28 18:09 ` [igt-dev] [PATCH i-g-t v3 2/2] lib/kmstest_dumb_map_buffer: docs update Ramalingam C
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox