[Mesa-dev] [PATCH v1] radv: Prevent Coverity warning
Prevent Coverity seeing potential errors when src is no initialized in the switch case. Coverity-Id: 1396397 Signed-off-by: Robert Foss --- Patch can be found here: https://git.collabora.com/cgit/user/robertfoss/mesa.git/log/?h=cov_1396397_v1 src/amd/vulkan/radv_cmd_buffer.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c index c4e8324a33..c671e78523 100644 --- a/src/amd/vulkan/radv_cmd_buffer.c +++ b/src/amd/vulkan/radv_cmd_buffer.c @@ -415,6 +415,8 @@ radv_update_multisample_state(struct radv_cmd_buffer *cmd_buffer, case 16: src = cmd_buffer->device->sample_locations_16x; break; + default: + unreachable("unknown number of samples"); } memcpy(samples_ptr, src, num_samples * 4 * 2); -- 2.11.0.453.g787f75f05 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v1] i965: Prevent coverity warning
Add assert checking that num_sources is never larger than 3. This prevents Coverity from concluding that the improperly handled cases of num_sources not being 0-3 are relevant. Coverity-Id: 1399480-1399489 Signed-off-by: Robert Foss --- Patch can be found here: https://git.collabora.com/cgit/user/robertfoss/mesa.git/log/?h=cov_1399480_1399489_v1 src/mesa/drivers/dri/i965/brw_eu_validate.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/drivers/dri/i965/brw_eu_validate.c b/src/mesa/drivers/dri/i965/brw_eu_validate.c index 226539445d..02e578e084 100644 --- a/src/mesa/drivers/dri/i965/brw_eu_validate.c +++ b/src/mesa/drivers/dri/i965/brw_eu_validate.c @@ -177,6 +177,7 @@ num_sources_from_inst(const struct gen_device_info *devinfo, return 0; } } else { + assert(desc->nsrc >= 4); return desc->nsrc; } -- 2.11.0.453.g787f75f05 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v1] i965: Prevent coverity warning
On 2017-01-30 05:37 PM, Timothy Arceri wrote: On Mon, 2017-01-30 at 16:27 -0500, Robert Foss wrote: Add assert checking that num_sources is never larger than 3. This prevents Coverity from concluding that the improperly handled cases of num_sources not being 0-3 are relevant. Coverity-Id: 1399480-1399489 Signed-off-by: Robert Foss --- Patch can be found here: https://git.collabora.com/cgit/user/robertfoss/mesa.git/log/?h=cov_ 1399480_1399489_v1 src/mesa/drivers/dri/i965/brw_eu_validate.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/drivers/dri/i965/brw_eu_validate.c b/src/mesa/drivers/dri/i965/brw_eu_validate.c index 226539445d..02e578e084 100644 --- a/src/mesa/drivers/dri/i965/brw_eu_validate.c +++ b/src/mesa/drivers/dri/i965/brw_eu_validate.c @@ -177,6 +177,7 @@ num_sources_from_inst(const struct gen_device_info *devinfo, return 0; } } else { + assert(desc->nsrc >= 4); This seems like the opposite of what you are describing in the commit message. Did you want? assert(desc->nsrc < 4); Bah! Of course. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2] i965: Prevent coverity warning
Add assert checking that num_sources is never larger than 3. This prevents Coverity from concluding that the improperly handled cases of num_sources not being 0-3 are relevant. Coverity-Id: 1399480-1399489 Signed-off-by: Robert Foss --- src/mesa/drivers/dri/i965/brw_eu_validate.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/drivers/dri/i965/brw_eu_validate.c b/src/mesa/drivers/dri/i965/brw_eu_validate.c index 226539445d..64615af44a 100644 --- a/src/mesa/drivers/dri/i965/brw_eu_validate.c +++ b/src/mesa/drivers/dri/i965/brw_eu_validate.c @@ -177,6 +177,7 @@ num_sources_from_inst(const struct gen_device_info *devinfo, return 0; } } else { + assert(desc->nsrc < 4); return desc->nsrc; } -- 2.11.0.453.g787f75f05 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3] i965: Prevent coverity warning
Add assert checking that num_sources is never larger than 3. This prevents Coverity from concluding that the unhandled cases of num_sources not being 0-3 are relevant. Coverity-Id: 1399480-1399489 Signed-off-by: Robert Foss Reviewed-by: Anuj Phogat --- src/mesa/drivers/dri/i965/brw_eu_validate.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/drivers/dri/i965/brw_eu_validate.c b/src/mesa/drivers/dri/i965/brw_eu_validate.c index 226539445d..64615af44a 100644 --- a/src/mesa/drivers/dri/i965/brw_eu_validate.c +++ b/src/mesa/drivers/dri/i965/brw_eu_validate.c @@ -177,6 +177,7 @@ num_sources_from_inst(const struct gen_device_info *devinfo, return 0; } } else { + assert(desc->nsrc < 4); return desc->nsrc; } -- 2.11.0.453.g787f75f05 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v4] i965: Prevent coverity warning
Add assert checking that num_sources is never larger than 3. This prevents Coverity from concluding that the unhandled cases of num_sources not being 0-3 are relevant. Coverity-Id: 1399480-1399489 Signed-off-by: Robert Foss Reviewed-by: Anuj Phogat Reviewed-by: Iago Toral Quiroga --- src/mesa/drivers/dri/i965/brw_eu_validate.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/drivers/dri/i965/brw_eu_validate.c b/src/mesa/drivers/dri/i965/brw_eu_validate.c index 226539445d..64615af44a 100644 --- a/src/mesa/drivers/dri/i965/brw_eu_validate.c +++ b/src/mesa/drivers/dri/i965/brw_eu_validate.c @@ -177,6 +177,7 @@ num_sources_from_inst(const struct gen_device_info *devinfo, return 0; } } else { + assert(desc->nsrc < 4); return desc->nsrc; } -- 2.11.0.453.g787f75f05 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [RFC 00/12] egl, i965: Support EGL_ANDROID_native_fence_sync (v2)
On 2016-10-11 01:37 PM, Chad Versace wrote: On Tue 11 Oct 2016, Emil Velikov wrote: On 10 October 2016 at 20:41, Rob Clark wrote: On Mon, Oct 10, 2016 at 1:43 PM, Chad Versace wrote: Testing: I haven't yet tested EGL_ANDROID_native_fence_sync with these patches, but the series does build. I just wanted to get these patches on the list as a status-update. I'm slowly working on getting Rob Clark's hacked-up kmscube to work on this series. I did test that this series doesn't break any dEQP-EGL sync tests. But my dEQP doesn't include any EGL_ANDROID_native_fence_sync tests. From a quick skim neither one of CTS/dEQP/piglit had EGL_ANDROID_native_fence_sync tests. I've mentioned to Rob F that adding a few piglits might be a good idea. It would be good to coordinate to avoid writing the same tests twice ;-) Yes, we should have tests before committing this feature. I am releasing any lock I may had held on test writing, as I don't have time to tackle that this week. Writing the tests is not on my table at the moment. Perhaps some time can be scraped together for it at a later point, but not now. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [RFC 00/12] egl, i965: Support EGL_ANDROID_native_fence_sync (v2)
On 2016-10-13 04:37 PM, Rafael Antognolli wrote: Hi all, On Tue, Oct 11, 2016 at 01:47:37PM -0400, Robert Foss wrote: On 2016-10-11 01:37 PM, Chad Versace wrote: On Tue 11 Oct 2016, Emil Velikov wrote: On 10 October 2016 at 20:41, Rob Clark wrote: On Mon, Oct 10, 2016 at 1:43 PM, Chad Versace wrote: Testing: I haven't yet tested EGL_ANDROID_native_fence_sync with these patches, but the series does build. I just wanted to get these patches on the list as a status-update. I'm slowly working on getting Rob Clark's hacked-up kmscube to work on this series. I did test that this series doesn't break any dEQP-EGL sync tests. But my dEQP doesn't include any EGL_ANDROID_native_fence_sync tests. From a quick skim neither one of CTS/dEQP/piglit had EGL_ANDROID_native_fence_sync tests. I've mentioned to Rob F that adding a few piglits might be a good idea. It would be good to coordinate to avoid writing the same tests twice ;-) Yes, we should have tests before committing this feature. I am releasing any lock I may had held on test writing, as I don't have time to tackle that this week. Writing the tests is not on my table at the moment. Perhaps some time can be scraped together for it at a later point, but not now. If nobody has started writing piglit tests yet, and it's OK with you guys, I would like to give it a try since I'm also interested in this feature. Also if I understood correctly, the initial thing to test is whether WaitSync and ClientWaitSync respect input fences, right? I'll try to come up with a list of other things to test, like invalid fences and so on, but if you guys already have a list of things to test in mind, please let me know. Anyway, is it fine if I start working on this? That would be very welcome! ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v1 00/13] Implement sw_sync test
From: Robert Foss This series implements the sw_sync test and the lib/sw_sync helper functions for said test. Gustavo Padovans sw_sync series was just de-staged in gregkh-staging/staging-next [1], and this test is targeted at verifying the functionality implemented in that series. The sw_sync subtests range from very basic tests of the sw_sync functionality, to stress testing and randomized tests. [1] http://git.kernel.org/cgit/linux/kernel/git/gregkh/staging.git/ Robert Foss (13): lib/sw_sync: Add helper functions for managing synchronization primitives tests/sw_sync: Add sw_sync test tests/sw_sync: Add subtest test_alloc_fence tests/sw_sync: Add subtest test_alloc_fence_invalid_timeline tests/sw_sync: Add subtest test_alloc_merge_fence tests/sw_sync: Add subtest test_sync_wait tests/sw_sync: Add subtest test_sync_merge tests/sw_sync: Add subtest test_sync_merge_same tests/sw_sync: Add subtest test_sync_multi_consumer tests/sw_sync: Add subtest test_sync_multi_consumer_producer tests/sw_sync: Add subtest test_sync_random_merge tests/sw_sync: Add subtest test_sync_multi_timeline_wait tests/sw_sync: Add subtest test_sync_multi_producer_single_consumer lib/Makefile.sources | 2 + lib/sw_sync.c | 237 + lib/sw_sync.h | 49 tests/Makefile.sources | 1 + tests/sw_sync.c| 693 + 5 files changed, 982 insertions(+) create mode 100644 lib/sw_sync.c create mode 100644 lib/sw_sync.h create mode 100644 tests/sw_sync.c -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v1 01/13] lib/sw_sync: Add helper functions for managing synchronization primitives
From: Robert Foss Base functions to help testing the Sync File Framework (explicit fencing mechanism ported from Android). These functions allow you to create, use and destroy timelines and fences. Signed-off-by: Gustavo Padovan Signed-off-by: Robert Foss --- lib/Makefile.sources | 2 + lib/sw_sync.c| 238 +++ lib/sw_sync.h| 49 +++ 3 files changed, 289 insertions(+) create mode 100644 lib/sw_sync.c create mode 100644 lib/sw_sync.h diff --git a/lib/Makefile.sources b/lib/Makefile.sources index bac9a7f..3dc7c3c 100644 --- a/lib/Makefile.sources +++ b/lib/Makefile.sources @@ -61,6 +61,8 @@ lib_source_list = \ rendercopy_gen8.c \ rendercopy_gen9.c \ rendercopy.h\ + sw_sync.c \ + sw_sync.h \ intel_reg_map.c \ intel_iosf.c\ igt_kms.c \ diff --git a/lib/sw_sync.c b/lib/sw_sync.c new file mode 100644 index 000..c4e7d07 --- /dev/null +++ b/lib/sw_sync.c @@ -0,0 +1,238 @@ +/* + * Copyright 2012 Google, Inc + * Copyright © 2016 Collabora, Ltd. + * + * Based on the implementation from the Android Open Source Project + * + * 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: + *Robert Foss + */ + +#ifndef ANDROID +#define _GNU_SOURCE +#else +#include +#endif +#include +#include +#include +#include +#include + +#include "sw_sync.h" +#include "drmtest.h" +#include "ioctl_wrappers.h" + +#ifndef SW_SYNC_IOC_INC +struct sw_sync_create_fence_data { + __u32 value; + charname[32]; + __s32 fence; +}; + +#define SW_SYNC_IOC_MAGIC 'W' +#define SW_SYNC_IOC_CREATE_FENCE _IOWR(SW_SYNC_IOC_MAGIC, 0,\ + struct sw_sync_create_fence_data) +#define SW_SYNC_IOC_INC_IOW(SW_SYNC_IOC_MAGIC, 1, __u32) +#endif + +int sw_sync_fd_is_valid(int fd) +{ + int status; + + if (fd == -1) + return 0; + + status = fcntl(fd, F_GETFD, 0); + return status >= 0; +} + +static +void sw_sync_fd_close(int fd) +{ + if (fd == -1) + return; + + if (fcntl(fd, F_GETFD, 0) < 0) + return; + + close(fd); +} + +int sw_sync_timeline_create(void) +{ + int fd = open("/dev/sw_sync", O_RDWR); + + if (!sw_sync_fd_is_valid(fd)) + fd = open("/sys/kernel/debug/sync/sw_sync", O_RDWR); + + igt_assert(sw_sync_fd_is_valid(fd)); + + return fd; +} + +void sw_sync_timeline_destroy(int fd) +{ + return sw_sync_fd_close(fd); +} + +void sw_sync_fence_destroy(int fd) +{ + return sw_sync_fd_close(fd); +} + +int sw_sync_fence_create(int fd, int32_t seqno) +{ + struct sw_sync_create_fence_data data = {}; + + data.value = seqno; + if (fd >= 0) { + do_ioctl(fd, SW_SYNC_IOC_CREATE_FENCE, &data); + return data.fence; + } else { + do_ioctl_err(fd, SW_SYNC_IOC_CREATE_FENCE, &data, EBADF); + return -1; + } +} + +void sw_sync_timeline_inc(int fd, uint32_t count) +{ + uint32_t arg = count; + + if (fd == 0 || fd == -1) + return; + + do_ioctl(fd, SW_SYNC_IOC_INC, &arg); +} + +int sw_sync_merge(int fd1, int fd2) +{ + struct sync_merge_data data = {}; + int err; + + data.fd2 = fd2; + + err = ioctl(fd1, SYNC_IOC_MERGE, &data); + if (err < 0) + return err; + + sw_sync_fd_is_valid(data.fence); + + return data.fence; +} + +int sw_sync_wait(int fence, int timeout) +{ + struct pollfd fds; + int ret; + + fds.fd = fence; + fds.events = POLLI
[Mesa-dev] [PATCH v1 12/13] tests/sw_sync: Add subtest test_sync_multi_timeline_wait
From: Robert Foss This subtest verifies that waiting, timing out on a wait and that counting fences in various states works. Signed-off-by: Robert Foss --- tests/sw_sync.c | 66 + 1 file changed, 66 insertions(+) diff --git a/tests/sw_sync.c b/tests/sw_sync.c index 8e5a7c9..9ff5088 100644 --- a/tests/sw_sync.c +++ b/tests/sw_sync.c @@ -214,6 +214,69 @@ static void test_sync_merge_same(void) sw_sync_timeline_destroy(timeline); } +static void test_sync_multi_timeline_wait(void) +{ + int timeline[3]; + int in_fence[3]; + int fence_merge; + int active, signaled, ret; + + timeline[0] = sw_sync_timeline_create(); + timeline[1] = sw_sync_timeline_create(); + timeline[2] = sw_sync_timeline_create(); + + in_fence[0] = sw_sync_fence_create(timeline[0], 5); + in_fence[1] = sw_sync_fence_create(timeline[1], 5); + in_fence[2] = sw_sync_fence_create(timeline[2], 5); + + fence_merge = sw_sync_merge(in_fence[0], in_fence[1]); + fence_merge = sw_sync_merge(in_fence[2], fence_merge); + + /* Confirm fence isn't signaled */ + active = sw_sync_fence_count_status(fence_merge, + SW_SYNC_FENCE_STATUS_ACTIVE); + igt_assert_f(active == 3, "Fence signaled too early\n"); + + ret = sw_sync_wait(fence_merge, 0); + igt_assert_f(ret == 0, "Failure waiting on fence until timeout\n"); + + sw_sync_timeline_inc(timeline[0], 5); + active = sw_sync_fence_count_status(fence_merge, + SW_SYNC_FENCE_STATUS_ACTIVE); + signaled = sw_sync_fence_count_status(fence_merge, + SW_SYNC_FENCE_STATUS_SIGNALED); + igt_assert_f(active == 2 && signaled == 1, + "Fence did not signal properly\n"); + + sw_sync_timeline_inc(timeline[1], 5); + active = sw_sync_fence_count_status(fence_merge, + SW_SYNC_FENCE_STATUS_ACTIVE); + signaled = sw_sync_fence_count_status(fence_merge, + SW_SYNC_FENCE_STATUS_SIGNALED); + igt_assert_f(active == 1 && signaled == 2, + "Fence did not signal properly\n"); + + sw_sync_timeline_inc(timeline[2], 5); + active = sw_sync_fence_count_status(fence_merge, + SW_SYNC_FENCE_STATUS_ACTIVE); + signaled = sw_sync_fence_count_status(fence_merge, + SW_SYNC_FENCE_STATUS_SIGNALED); + igt_assert_f(active == 0 && signaled == 3, +"Fence did not signal properly\n"); + + /* confirm you can successfully wait */ + ret = sw_sync_wait(fence_merge, 100); + igt_assert_f(ret > 0, "Failure waiting on signaled fence\n"); + + sw_sync_fence_destroy(in_fence[0]); + sw_sync_fence_destroy(in_fence[1]); + sw_sync_fence_destroy(in_fence[2]); + sw_sync_fence_destroy(fence_merge); + sw_sync_timeline_destroy(timeline[0]); + sw_sync_timeline_destroy(timeline[1]); + sw_sync_timeline_destroy(timeline[2]); +} + static void * test_sync_multi_consumer_thread(void *arg) { data_t *data = arg; @@ -476,6 +539,9 @@ igt_main igt_subtest("sync_merge_same") test_sync_merge_same(); + igt_subtest("sync_multi_timeline_wait") + test_sync_multi_timeline_wait(); + igt_subtest("sync_multi_consumer") test_sync_multi_consumer(); -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v1 05/13] tests/sw_sync: Add subtest test_alloc_merge_fence
From: Robert Foss This subtest verifies that merging two fences works in the simples possible case. Signed-off-by: Robert Foss --- tests/sw_sync.c | 23 +++ 1 file changed, 23 insertions(+) diff --git a/tests/sw_sync.c b/tests/sw_sync.c index 102647d..851430e 100644 --- a/tests/sw_sync.c +++ b/tests/sw_sync.c @@ -60,6 +60,26 @@ static void test_alloc_fence_invalid_timeline(void) sw_sync_fence_create(-1, 0); } +static void test_alloc_merge_fence(void) +{ + int in_fence[2]; + int fence_merge; + int timeline[2]; + + timeline[0] = sw_sync_timeline_create(); + timeline[1] = sw_sync_timeline_create(); + + in_fence[0] = sw_sync_fence_create(timeline[0], 1); + in_fence[1] = sw_sync_fence_create(timeline[1], 1); + fence_merge = sw_sync_merge(in_fence[1], in_fence[0]); + + sw_sync_fence_destroy(in_fence[0]); + sw_sync_fence_destroy(in_fence[1]); + sw_sync_fence_destroy(fence_merge); + sw_sync_timeline_destroy(timeline[0]); + sw_sync_timeline_destroy(timeline[1]); +} + igt_main { igt_subtest("alloc_timeline") @@ -70,5 +90,8 @@ igt_main igt_subtest("alloc_fence_invalid_timeline") test_alloc_fence_invalid_timeline(); + + igt_subtest("alloc_merge_fence") + test_alloc_merge_fence(); } -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v1 02/13] tests/sw_sync: Add sw_sync test
From: Robert Foss Add initial tests for sw_sync. Signed-off-by: Gustavo Padovan Signed-off-by: Robert Foss --- lib/sw_sync.c | 13 ++--- lib/sw_sync.h | 2 +- tests/Makefile.sources | 1 + tests/sw_sync.c| 51 ++ 4 files changed, 59 insertions(+), 8 deletions(-) create mode 100644 tests/sw_sync.c diff --git a/lib/sw_sync.c b/lib/sw_sync.c index c4e7d07..e3d5f85 100644 --- a/lib/sw_sync.c +++ b/lib/sw_sync.c @@ -150,8 +150,6 @@ int sw_sync_wait(int fence, int timeout) ret = poll(&fds, 1, timeout); - sw_sync_fd_close(fence); - return ret; } @@ -179,9 +177,10 @@ static struct sync_file_info *sync_file_info(int fd) info->num_fences = num_fences; fence_info = calloc(num_fences, sizeof(struct sync_fence_info)); - if (!fence_info) + if (!fence_info) { free(info); return NULL; + } info->sync_fence_info = (uint64_t)(unsigned long) (fence_info); @@ -217,18 +216,18 @@ int sw_sync_fence_size(int fd) return count; } -int sw_sync_fence_count_with_status(int fd, int status) +int sw_sync_fence_count_status(int fd, int status) { int i, count = 0; - struct sync_fence_info *fenceInfo = NULL; + struct sync_fence_info *fence_info = NULL; struct sync_file_info *info = sync_file_info(fd); if (!info) return -1; - fenceInfo = (struct sync_fence_info *)(uintptr_t)info->sync_fence_info; + fence_info = (struct sync_fence_info *)(uintptr_t)info->sync_fence_info; for (i = 0 ; i < info->num_fences ; i++) { - if (fenceInfo[i].status == status) + if (fence_info[i].status == status) count++; } diff --git a/lib/sw_sync.h b/lib/sw_sync.h index b179adf..1092608 100644 --- a/lib/sw_sync.h +++ b/lib/sw_sync.h @@ -43,7 +43,7 @@ void sw_sync_timeline_inc(int fd, uint32_t count); int sw_sync_merge(int fd1, int fd2); int sw_sync_wait(int fence, int timeout); int sw_sync_fence_size(int fd); -int sw_sync_fence_count_with_status(int fd, int status); +int sw_sync_fence_count_status(int fd, int status); #endif diff --git a/tests/Makefile.sources b/tests/Makefile.sources index 72a58ad..0ba769f 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -125,6 +125,7 @@ TESTS_progs_M = \ prime_mmap_kms \ prime_self_import \ prime_vgem \ + sw_sync \ template \ vgem_basic \ vgem_slow \ diff --git a/tests/sw_sync.c b/tests/sw_sync.c new file mode 100644 index 000..d2d4c42 --- /dev/null +++ b/tests/sw_sync.c @@ -0,0 +1,51 @@ +/* + * Copyright 2012 Google, Inc + * Copyright © 2016 Collabora, Ltd. + * + * Based on the implementation from the Android Open Source Project + * + * 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: + *Robert Foss + */ + +#include + +#include "sw_sync.h" +#include "igt.h" +#include "igt_aux.h" + +IGT_TEST_DESCRIPTION("Test SW Sync Framework"); + +static void test_alloc_timeline(void) +{ + int timeline; + + timeline = sw_sync_timeline_create(); + sw_sync_timeline_destroy(timeline); +} + +igt_main +{ + igt_subtest("alloc_timeline") + test_alloc_timeline(); +} + -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v1 08/13] tests/sw_sync: Add subtest test_sync_merge_same
From: Robert Foss This subtest verifies merging a fence with itself does not fail. Signed-off-by: Robert Foss --- tests/sw_sync.c | 27 +++ 1 file changed, 27 insertions(+) diff --git a/tests/sw_sync.c b/tests/sw_sync.c index 00ac44b..db03f48 100644 --- a/tests/sw_sync.c +++ b/tests/sw_sync.c @@ -179,6 +179,30 @@ static void test_sync_merge(void) sw_sync_timeline_destroy(timeline); } +static void test_sync_merge_same(void) +{ + int in_fence[2]; + int timeline; + int signaled; + + timeline = sw_sync_timeline_create(); + in_fence[0] = sw_sync_fence_create(timeline, 1); + in_fence[1] = sw_sync_merge(in_fence[0], in_fence[0]); + + signaled = sw_sync_fence_count_status(in_fence[0], + SW_SYNC_FENCE_STATUS_SIGNALED); + igt_assert_f(signaled == 0, "fence signaled too early\n"); + + sw_sync_timeline_inc(timeline, 1); + signaled = sw_sync_fence_count_status(in_fence[0], + SW_SYNC_FENCE_STATUS_SIGNALED); + igt_assert_f(signaled == 1, "fence did not signal\n"); + + sw_sync_fence_destroy(in_fence[0]); + sw_sync_fence_destroy(in_fence[1]); + sw_sync_timeline_destroy(timeline); +} + igt_main { igt_subtest("alloc_timeline") @@ -198,5 +222,8 @@ igt_main igt_subtest("sync_merge") test_sync_merge(); + + igt_subtest("sync_merge_same") + test_sync_merge_same(); } -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v1 09/13] tests/sw_sync: Add subtest test_sync_multi_consumer
From: Robert Foss This subtest verifies the access ordering of multiple consumer threads. Signed-off-by: Robert Foss --- tests/sw_sync.c | 103 1 file changed, 103 insertions(+) diff --git a/tests/sw_sync.c b/tests/sw_sync.c index db03f48..0c9c923 100644 --- a/tests/sw_sync.c +++ b/tests/sw_sync.c @@ -27,6 +27,8 @@ *Robert Foss */ +#include +#include #include #include "sw_sync.h" @@ -35,6 +37,15 @@ IGT_TEST_DESCRIPTION("Test SW Sync Framework"); +typedef struct { + int timeline; + uint32_t thread_id; + uint32_t nbr_threads; + uint32_t nbr_iterations; + volatile uint32_t * volatile counter; + sem_t *sem; +} data_t; + static void test_alloc_timeline(void) { int timeline; @@ -203,6 +214,95 @@ static void test_sync_merge_same(void) sw_sync_timeline_destroy(timeline); } +static void * test_sync_multi_consumer_thread(void *arg) +{ + data_t *data = arg; + int thread_id = data->thread_id; + int nbr_threads = data->nbr_threads; + int timeline = data->timeline; + int iterations = data->nbr_iterations; + int ret, i; + + for (i = 0; i < iterations; i++) { + int next_point = i * nbr_threads + thread_id; + int fence = sw_sync_fence_create(timeline, next_point); + + ret = sw_sync_wait(fence, 1000); + if (ret <= 0) + { + return (void *) 1; + } + + if (*(data->counter) != next_point) + { + return (void *) 1; + } + + sem_post(data->sem); + sw_sync_fence_destroy(fence); + } + return NULL; +} + +static void test_sync_multi_consumer(void) +{ + const uint32_t nbr_threads = 8; + const uint32_t nbr_iterations = 1 << 14; + data_t data_arr[nbr_threads]; + pthread_t thread_arr[nbr_threads]; + sem_t sem; + int timeline; + volatile uint32_t counter = 0; + uintptr_t thread_ret = 0; + data_t data; + int i, ret; + + sem_init(&sem, 0, 0); + timeline = sw_sync_timeline_create(); + + data.nbr_iterations = nbr_iterations; + data.nbr_threads = nbr_threads; + data.counter = &counter; + data.timeline = timeline; + data.sem = &sem; + + /* Start sync threads. */ + for (i = 0; i < nbr_threads; i++) + { + data_arr[i] = data; + data_arr[i].thread_id = i; + ret = pthread_create(&thread_arr[i], NULL, +test_sync_multi_consumer_thread, +(void *) &(data_arr[i])); + igt_assert_eq(ret, 0); + } + + /* Produce 'content'. */ + for (i = 0; i < nbr_threads * nbr_iterations; i++) + { + sem_wait(&sem); + + counter++; + sw_sync_timeline_inc(timeline, 1); + } + + /* Wait for threads to complete. */ + for (i = 0; i < nbr_threads; i++) + { + uintptr_t local_thread_ret; + pthread_join(thread_arr[i], (void **)&local_thread_ret); + thread_ret |= local_thread_ret; + } + + sw_sync_timeline_destroy(timeline); + sem_destroy(&sem); + + igt_assert_f(counter == nbr_threads * nbr_iterations, +"Counter has unexpected value.\n"); + + igt_assert_f(thread_ret == 0, "A sync thread reported failure.\n"); +} + igt_main { igt_subtest("alloc_timeline") @@ -225,5 +325,8 @@ igt_main igt_subtest("sync_merge_same") test_sync_merge_same(); + + igt_subtest("sync_multi_consumer") + test_sync_multi_consumer(); } -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v1 06/13] tests/sw_sync: Add subtest test_sync_wait
From: Robert Foss This subtest verifies that waiting on fences works properly. Signed-off-by: Robert Foss --- tests/sw_sync.c | 38 ++ 1 file changed, 38 insertions(+) diff --git a/tests/sw_sync.c b/tests/sw_sync.c index 851430e..07e9638 100644 --- a/tests/sw_sync.c +++ b/tests/sw_sync.c @@ -80,6 +80,41 @@ static void test_alloc_merge_fence(void) sw_sync_timeline_destroy(timeline[1]); } +static void test_sync_wait(void) +{ + int fence, ret; + int timeline; + + timeline = sw_sync_timeline_create(); + fence = sw_sync_fence_create(timeline, 5); + + /* Wait on fence until timeout */ + ret = sw_sync_wait(fence, 0); + igt_assert_f(ret == 0, "Failure waiting on fence until timeout\n"); + + /* Advance timeline from 0 -> 1 */ + sw_sync_timeline_inc(timeline, 1); + + /* Wait on fence until timeout */ + ret = sw_sync_wait(fence, 0); + igt_assert_f(ret == 0, "Failure waiting on fence until timeout\n"); + + /* Signal the fence */ + sw_sync_timeline_inc(timeline, 4); + + /* Wait successfully */ + ret = sw_sync_wait(fence, 0); + igt_assert_f(ret > 0, "Failure waiting on fence\n"); + + /* Go even further, and confirm wait still succeeds */ + sw_sync_timeline_inc(timeline, 10); + ret = sw_sync_wait(fence, 0); + igt_assert_f(ret > 0, "Failure waiting ahead\n"); + + sw_sync_fence_destroy(fence); + sw_sync_timeline_destroy(timeline); +} + igt_main { igt_subtest("alloc_timeline") @@ -93,5 +128,8 @@ igt_main igt_subtest("alloc_merge_fence") test_alloc_merge_fence(); + + igt_subtest("sync_wait") + test_sync_wait(); } -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v1 07/13] tests/sw_sync: Add subtest test_sync_merge
From: Robert Foss Add subtest test_sync_merge that tests merging fences and the validity of the resulting merged fence. Signed-off-by: Robert Foss --- tests/sw_sync.c | 67 + 1 file changed, 67 insertions(+) diff --git a/tests/sw_sync.c b/tests/sw_sync.c index 07e9638..00ac44b 100644 --- a/tests/sw_sync.c +++ b/tests/sw_sync.c @@ -115,6 +115,70 @@ static void test_sync_wait(void) sw_sync_timeline_destroy(timeline); } +static void test_sync_merge(void) +{ + int in_fence[3]; + int fence_merge; + int timeline; + int active, signaled; + + timeline = sw_sync_timeline_create(); + in_fence[0] = sw_sync_fence_create(timeline, 1); + in_fence[1] = sw_sync_fence_create(timeline, 2); + in_fence[2] = sw_sync_fence_create(timeline, 3); + + fence_merge = sw_sync_merge(in_fence[0], in_fence[1]); + fence_merge = sw_sync_merge(in_fence[2], fence_merge); + + /* confirm all fences have one active point (even d) */ + active = sw_sync_fence_count_status(in_fence[0], + SW_SYNC_FENCE_STATUS_ACTIVE); + igt_assert_f(active == 1, "in_fence[0] has too many active fences\n"); + active = sw_sync_fence_count_status(in_fence[1], + SW_SYNC_FENCE_STATUS_ACTIVE); + igt_assert_f(active == 1, "in_fence[1] has too many active fences\n"); + active = sw_sync_fence_count_status(in_fence[2], + SW_SYNC_FENCE_STATUS_ACTIVE); + igt_assert_f(active == 1, "in_fence[2] has too many active fences\n"); + active = sw_sync_fence_count_status(fence_merge, + SW_SYNC_FENCE_STATUS_ACTIVE); + igt_assert_f(active == 1, "fence_merge has too many active fences\n"); + + /* confirm that fence_merge is not signaled until the max of fence 0,1,2 */ + sw_sync_timeline_inc(timeline, 1); + signaled = sw_sync_fence_count_status(in_fence[0], + SW_SYNC_FENCE_STATUS_SIGNALED); + active = sw_sync_fence_count_status(fence_merge, + SW_SYNC_FENCE_STATUS_ACTIVE); + igt_assert_f(signaled == 1, "in_fence[0] did not signal\n"); + igt_assert_f(active == 1, "fence_merge signaled too early\n"); + + sw_sync_timeline_inc(timeline, 1); + signaled = sw_sync_fence_count_status(in_fence[1], + SW_SYNC_FENCE_STATUS_SIGNALED); + active = sw_sync_fence_count_status(fence_merge, + SW_SYNC_FENCE_STATUS_ACTIVE); + igt_assert_f(signaled == 1, "in_fence[1] did not signal\n"); + igt_assert_f(active == 1, "fence_merge signaled too early\n"); + + sw_sync_timeline_inc(timeline, 1); + signaled = sw_sync_fence_count_status(in_fence[2], + SW_SYNC_FENCE_STATUS_SIGNALED); + igt_assert_f(signaled == 1, "in_fence[2] did not signal\n"); + signaled = sw_sync_fence_count_status(fence_merge, + SW_SYNC_FENCE_STATUS_SIGNALED); + active = sw_sync_fence_count_status(fence_merge, + SW_SYNC_FENCE_STATUS_ACTIVE); + igt_assert_f(active == 0 && signaled == 1, +"fence_merge did not signal\n"); + + sw_sync_fence_destroy(in_fence[0]); + sw_sync_fence_destroy(in_fence[1]); + sw_sync_fence_destroy(in_fence[2]); + sw_sync_fence_destroy(fence_merge); + sw_sync_timeline_destroy(timeline); +} + igt_main { igt_subtest("alloc_timeline") @@ -131,5 +195,8 @@ igt_main igt_subtest("sync_wait") test_sync_wait(); + + igt_subtest("sync_merge") + test_sync_merge(); } -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v1 10/13] tests/sw_sync: Add subtest test_sync_multi_consumer_producer
From: Robert Foss This test verifies that stressing the kernel by creating multiple consumer/producer threads that wait on a single timeline to be incremented by another conumer/producer thread does not fail. And that the order amongst the threads is maintained. Signed-off-by: Robert Foss --- tests/sw_sync.c | 83 + 1 file changed, 83 insertions(+) diff --git a/tests/sw_sync.c b/tests/sw_sync.c index 0c9c923..0e67ad5 100644 --- a/tests/sw_sync.c +++ b/tests/sw_sync.c @@ -303,6 +303,86 @@ static void test_sync_multi_consumer(void) igt_assert_f(thread_ret == 0, "A sync thread reported failure.\n"); } +static void * test_sync_multi_consumer_producer_thread(void *arg) +{ + data_t *data = arg; + int thread_id = data->thread_id; + int nbr_threads = data->nbr_threads; + int timeline = data->timeline; + int iterations = data->nbr_iterations; + int ret, i; + + for (i = 0; i < iterations; i++) { + int next_point = i * nbr_threads + thread_id; + int fence = sw_sync_fence_create(timeline, next_point); + + ret = sw_sync_wait(fence, 1000); + if (ret <= 0) + { + return (void *) 1; + } + + if (*(data->counter) != next_point) + { + return (void *) 1; + } + + (*data->counter)++; + + /* Kick off the next thread. */ + sw_sync_timeline_inc(timeline, 1); + + sw_sync_fence_destroy(fence); + } + return NULL; +} + +static void test_sync_multi_consumer_producer(void) +{ + const uint32_t nbr_threads = 8; + const uint32_t nbr_iterations = 1 << 14; + data_t data_arr[nbr_threads]; + pthread_t thread_arr[nbr_threads]; + int timeline; + volatile uint32_t counter = 0; + uintptr_t thread_ret = 0; + data_t data; + int i, ret; + + timeline = sw_sync_timeline_create(); + + data.nbr_iterations = nbr_iterations; + data.nbr_threads = nbr_threads; + data.counter = &counter; + data.timeline = timeline; + + /* Start consumer threads. */ + for (i = 0; i < nbr_threads; i++) + { + data_arr[i] = data; + data_arr[i].thread_id = i; + ret = pthread_create(&thread_arr[i], NULL, +test_sync_multi_consumer_producer_thread, +(void *) &(data_arr[i])); + igt_assert_eq(ret, 0); + } + + /* Wait for threads to complete. */ + for (i = 0; i < nbr_threads; i++) + { + uintptr_t local_thread_ret; + pthread_join(thread_arr[i], (void **)&local_thread_ret); + thread_ret |= local_thread_ret; + } + + sw_sync_timeline_destroy(timeline); + + igt_assert_f(counter == nbr_threads * nbr_iterations, +"Counter has unexpected value.\n"); + + igt_assert_f(thread_ret == 0, "A sync thread reported failure.\n"); +} + igt_main { igt_subtest("alloc_timeline") @@ -328,5 +408,8 @@ igt_main igt_subtest("sync_multi_consumer") test_sync_multi_consumer(); + + igt_subtest("sync_multi_consumer_producer") + test_sync_multi_consumer_producer(); } -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v1 11/13] tests/sw_sync: Add subtest test_sync_random_merge
From: Robert Foss This subtest verifies that creating many timelines and merging random fences from each timeline with eachother results in merged fences that are fully functional. Signed-off-by: Robert Foss --- tests/sw_sync.c | 73 + 1 file changed, 73 insertions(+) diff --git a/tests/sw_sync.c b/tests/sw_sync.c index 0e67ad5..8e5a7c9 100644 --- a/tests/sw_sync.c +++ b/tests/sw_sync.c @@ -383,6 +383,76 @@ static void test_sync_multi_consumer_producer(void) igt_assert_f(thread_ret == 0, "A sync thread reported failure.\n"); } +static void test_sync_random_merge(void) +{ + int i, size, ret; + const int nbr_timeline = 32; + const int nbr_merge = 1024; + int fence_map[nbr_timeline]; + int timeline_arr[nbr_timeline]; + int fence, tmpfence, merged; + int timeline, timeline_offset, sync_pt; + + srand(time(NULL)); + + for (i = 0; i < nbr_timeline; i++) + timeline_arr[i] = sw_sync_timeline_create(); + + memset(fence_map, -1, sizeof(fence_map)); + + sync_pt = rand(); + fence = sw_sync_fence_create(timeline_arr[0], sync_pt); + + fence_map[0] = sync_pt; + + /* Randomly create syncpoints out of a fixed set of timelines, +* and merge them together. +*/ + for (i = 0; i < nbr_merge; i++) { + /* Generate syncpoint. */ + timeline_offset = rand() % nbr_timeline; + timeline = timeline_arr[timeline_offset]; + sync_pt = rand(); + + /* Keep track of the latest sync_pt in each timeline. */ + if (fence_map[timeline_offset] == -1) + fence_map[timeline_offset] = sync_pt; + else if (fence_map[timeline_offset] < sync_pt) + fence_map[timeline_offset] = sync_pt; + + /* Merge. */ + tmpfence = sw_sync_fence_create(timeline, sync_pt); + merged = sw_sync_merge(tmpfence, fence); + sw_sync_fence_destroy(tmpfence); + sw_sync_fence_destroy(fence); + fence = merged; + } + + size = 0; + for (i = 0; i < nbr_timeline; i++) + if (fence_map[i] != -1) + size++; + + /* Trigger the merged fence. */ + for (i = 0; i < nbr_timeline; i++) { + if (fence_map[i] != -1) { + ret = sw_sync_wait(fence, 0); + igt_assert_f(ret == 0, + "Failure waiting on fence until timeout\n"); + /* Increment the timeline to the last sync_pt */ + sw_sync_timeline_inc(timeline_arr[i], fence_map[i]); + } + } + + /* Check that the fence is triggered. */ + ret = sw_sync_wait(fence, 0); + igt_assert_f(ret > 0, "Failure triggering fence\n"); + + sw_sync_fence_destroy(fence); + for (i = 0; i < nbr_timeline; i++) + sw_sync_timeline_destroy(timeline_arr[i]); +} + igt_main { igt_subtest("alloc_timeline") @@ -411,5 +481,8 @@ igt_main igt_subtest("sync_multi_consumer_producer") test_sync_multi_consumer_producer(); + + igt_subtest("sync_random_merge") + test_sync_random_merge(); } -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v1 13/13] tests/sw_sync: Add subtest test_sync_multi_producer_single_consumer
From: Robert Foss This subtest runs a single consumer thread and multiple producer thread that are synchronized using multiple timelines. Signed-off-by: Robert Foss --- tests/sw_sync.c | 139 1 file changed, 139 insertions(+) diff --git a/tests/sw_sync.c b/tests/sw_sync.c index 9ff5088..2accdee 100644 --- a/tests/sw_sync.c +++ b/tests/sw_sync.c @@ -446,6 +446,142 @@ static void test_sync_multi_consumer_producer(void) igt_assert_f(thread_ret == 0, "A sync thread reported failure.\n"); } +static int test_mspc_wait_on_fence(int fence) +{ + int error, active; + + do { + error = sw_sync_fence_count_status(fence, + SW_SYNC_FENCE_STATUS_ERROR); + igt_assert_f(error == 0, "Error occurred on fence\n"); + active = sw_sync_fence_count_status(fence, + SW_SYNC_FENCE_STATUS_ACTIVE); + } while (active); + + return 0; +} + +static struct { + int iterations; + int threads; + int counter; + int cons_timeline; + int *prod_timeline; + pthread_mutex_t lock; +} test_mpsc_data; + +static int mpsc_producer_thread(void *d) +{ + int id = (long)d; + int fence, i; + int *prod_timeline = test_mpsc_data.prod_timeline; + int cons_timeline = test_mpsc_data.cons_timeline; + int iterations = test_mpsc_data.iterations; + + for (i = 0; i < iterations; i++) { + fence = sw_sync_fence_create(cons_timeline, i); + + /* Wait for the consumer to finish. Use alternate +* means of waiting on the fence +*/ + if ((iterations + id) % 8 != 0) { + igt_assert_f(sw_sync_wait(fence, -1) > 0, +"Failure waiting on fence\n"); + } else { + igt_assert_f(test_mspc_wait_on_fence(fence) == 0, +"Failure waiting on fence\n"); + } + + /* Every producer increments the counter, the consumer +* checks and erases it +*/ + pthread_mutex_lock(&test_mpsc_data.lock); + test_mpsc_data.counter++; + pthread_mutex_unlock(&test_mpsc_data.lock); + + sw_sync_timeline_inc(prod_timeline[id], 1); + sw_sync_fence_destroy(fence); + } + + return 0; +} + +static int mpsc_consumer_thread(void) +{ + int fence, merged, tmp, it, i; + int *prod_timeline = test_mpsc_data.prod_timeline; + int cons_timeline = test_mpsc_data.cons_timeline; + int iterations = test_mpsc_data.iterations; + int n = test_mpsc_data.threads; + + for (it = 1; it <= iterations; it++) { + fence = sw_sync_fence_create(prod_timeline[0], it); + for (i = 1; i < n; i++) { + tmp = sw_sync_fence_create(prod_timeline[i], it); + merged = sw_sync_merge(tmp, fence); + sw_sync_fence_destroy(tmp); + sw_sync_fence_destroy(fence); + fence = merged; + } + + /* Make sure we see an increment from every producer thread. +* Vary the means by which we wait. +*/ + if (iterations % 8 != 0) { + igt_assert_f(sw_sync_wait(fence, -1) == 0, + "Producers did not increment as expected\n"); + } else { + igt_assert_f(test_mspc_wait_on_fence(fence) == 0, +"Failure waiting on fence\n"); + } + + igt_assert_f(test_mpsc_data.counter == n * it, +"Counter value mismatch\n"); + + /* Release the producer threads */ + sw_sync_timeline_inc(cons_timeline, 1); + sw_sync_fence_destroy(fence); + } + + return 0; +} + +/* IMPORTANT NOTE: if you see this test failing on your system, it may be + * due to a shortage of file descriptors. Please ensure your system has + * a sensible limit for this test to finish correctly. + */ +static void test_sync_multi_producer_single_consumer(void) +{ + int iterations = 1 << 12; + int n = 5; + int prod_timeline[n]; + int cons_timeline; + pthread_t threads[n]; + long i; + + cons_timeline = sw_sync_timeline_create(); + for (i = 0; i < n; i++) + prod_timeline[i] = sw_sync_timeline_create(); + + test_mpsc_data.prod_timeline = prod_timeline; + test_mpsc_data.cons_timeline = cons_timeline; + test_mpsc_data.iterations = iterations;
[Mesa-dev] [PATCH v1 04/13] tests/sw_sync: Add subtest test_alloc_fence_invalid_timeline
From: Robert Foss This subtests tests that creating fences on negative timelines fail. Signed-off-by: Robert Foss --- tests/sw_sync.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/tests/sw_sync.c b/tests/sw_sync.c index a8c8ca4..102647d 100644 --- a/tests/sw_sync.c +++ b/tests/sw_sync.c @@ -55,6 +55,10 @@ static void test_alloc_fence(void) sw_sync_timeline_destroy(timeline); } +static void test_alloc_fence_invalid_timeline(void) +{ + sw_sync_fence_create(-1, 0); +} igt_main { @@ -63,5 +67,8 @@ igt_main igt_subtest("alloc_fence") test_alloc_fence(); + + igt_subtest("alloc_fence_invalid_timeline") + test_alloc_fence_invalid_timeline(); } -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v1 03/13] tests/sw_sync: Add subtest test_alloc_fence
From: Robert Foss Add subtest alloc_fence that verifies that it's possible to allocate a fence on a timeline. Signed-off-by: Robert Foss --- tests/sw_sync.c | 16 1 file changed, 16 insertions(+) diff --git a/tests/sw_sync.c b/tests/sw_sync.c index d2d4c42..a8c8ca4 100644 --- a/tests/sw_sync.c +++ b/tests/sw_sync.c @@ -43,9 +43,25 @@ static void test_alloc_timeline(void) sw_sync_timeline_destroy(timeline); } +static void test_alloc_fence(void) +{ + int in_fence; + int timeline; + + timeline = sw_sync_timeline_create(); + in_fence = sw_sync_fence_create(timeline, 0); + + sw_sync_fence_destroy(in_fence); + sw_sync_timeline_destroy(timeline); +} + + igt_main { igt_subtest("alloc_timeline") test_alloc_timeline(); + + igt_subtest("alloc_fence") + test_alloc_fence(); } -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v1 00/13] Implement sw_sync test
On 2016-08-24 02:01 AM, Daniel Vetter wrote: On Tue, Aug 23, 2016 at 01:56:02PM -0400, robert.f...@collabora.com wrote: From: Robert Foss This series implements the sw_sync test and the lib/sw_sync helper functions for said test. Gustavo Padovans sw_sync series was just de-staged in gregkh-staging/staging-next [1], and this test is targeted at verifying the functionality implemented in that series. The sw_sync subtests range from very basic tests of the sw_sync functionality, to stress testing and randomized tests. [1] http://git.kernel.org/cgit/linux/kernel/git/gregkh/staging.git/ This seems to be patches against igt (but the series is lacking the i-g-t- subject tag per CONTRIBUTING). I'm ok with that, but I thought the idea was to merge these testcases into the kernel's selftests? Did the plan change? -Daniel Of course igt should've been added. I think a some miscommunication must've happened :) The kernel's selftests already does some of these tests, but apart from the sw_sync test, more subtests in kms_atomic and another test (kms_fence) are on scheduled for upstreaming. Since the kernel isn't really a great place for a testing framework, collecting all of this functionality in one place might make more sense. Robert Foss (13): lib/sw_sync: Add helper functions for managing synchronization primitives tests/sw_sync: Add sw_sync test tests/sw_sync: Add subtest test_alloc_fence tests/sw_sync: Add subtest test_alloc_fence_invalid_timeline tests/sw_sync: Add subtest test_alloc_merge_fence tests/sw_sync: Add subtest test_sync_wait tests/sw_sync: Add subtest test_sync_merge tests/sw_sync: Add subtest test_sync_merge_same tests/sw_sync: Add subtest test_sync_multi_consumer tests/sw_sync: Add subtest test_sync_multi_consumer_producer tests/sw_sync: Add subtest test_sync_random_merge tests/sw_sync: Add subtest test_sync_multi_timeline_wait tests/sw_sync: Add subtest test_sync_multi_producer_single_consumer lib/Makefile.sources | 2 + lib/sw_sync.c | 237 + lib/sw_sync.h | 49 tests/Makefile.sources | 1 + tests/sw_sync.c| 693 + 5 files changed, 982 insertions(+) create mode 100644 lib/sw_sync.c create mode 100644 lib/sw_sync.h create mode 100644 tests/sw_sync.c -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v1 00/13] Implement sw_sync test
On 2016-08-23 06:56 PM, Eric Engestrom wrote: On Tue, Aug 23, 2016 at 01:56:02PM -0400, robert.f...@collabora.com wrote: From: Robert Foss This series implements the sw_sync test and the lib/sw_sync helper functions for said test. Gustavo Padovans sw_sync series was just de-staged in gregkh-staging/staging-next [1], and this test is targeted at verifying the functionality implemented in that series. The sw_sync subtests range from very basic tests of the sw_sync functionality, to stress testing and randomized tests. [1] http://git.kernel.org/cgit/linux/kernel/git/gregkh/staging.git/ Robert Foss (13): lib/sw_sync: Add helper functions for managing synchronization primitives tests/sw_sync: Add sw_sync test tests/sw_sync: Add subtest test_alloc_fence tests/sw_sync: Add subtest test_alloc_fence_invalid_timeline tests/sw_sync: Add subtest test_alloc_merge_fence tests/sw_sync: Add subtest test_sync_wait tests/sw_sync: Add subtest test_sync_merge tests/sw_sync: Add subtest test_sync_merge_same tests/sw_sync: Add subtest test_sync_multi_consumer tests/sw_sync: Add subtest test_sync_multi_consumer_producer tests/sw_sync: Add subtest test_sync_random_merge tests/sw_sync: Add subtest test_sync_multi_timeline_wait tests/sw_sync: Add subtest test_sync_multi_producer_single_consumer lib/Makefile.sources | 2 + lib/sw_sync.c | 237 + lib/sw_sync.h | 49 tests/Makefile.sources | 1 + tests/sw_sync.c| 693 + 5 files changed, 982 insertions(+) create mode 100644 lib/sw_sync.c create mode 100644 lib/sw_sync.h create mode 100644 tests/sw_sync.c -- 2.7.4 Thanks for your work! I sent some specific comments directly to a few patches, but everything else looks good to me. With the issues raised in patches 1 & 2 fixed (and with or without my suggestions), the whole series is: Reviewed-by: Eric Engestrom Cheers, Eric Thanks for the quick feedback! All of the suggested changes have been fixed for v2, which is upcoming. Rob. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 0/13] Implement sw_sync test
From: Robert Foss This series implements the sw_sync test and the lib/sw_sync helper functions for said test. Gustavo Padovans sw_sync series was just de-staged in gregkh-staging/staging-next [1], and this test is targeted at verifying the functionality implemented in that series. The sw_sync subtests range from very basic tests of the sw_sync functionality, to stress testing and randomized tests. [1] http://git.kernel.org/cgit/linux/kernel/git/gregkh/staging.git/ Changes since v1: Added "Reviewed-by: Eric Engestrom " tag lib/sw_sync: - Fixed fd value checking - Fixed fd validity check in sw_sync_fd_close() - Moved sw_sync related paths to define - Switched from malloc+memset to calloc in sync_file_info() - Switched sizeof to dereferenced ptr tests/sw_sync: - Moved lib/sw_sync related code to lib/sw_sync commit - Replaced memset with assignment in loop Robert Foss (13): lib/sw_sync: Add helper functions for managing synchronization primitives tests/sw_sync: Add sw_sync test tests/sw_sync: Add subtest test_alloc_fence tests/sw_sync: Add subtest test_alloc_fence_invalid_timeline tests/sw_sync: Add subtest test_alloc_merge_fence tests/sw_sync: Add subtest test_sync_wait tests/sw_sync: Add subtest test_sync_merge tests/sw_sync: Add subtest test_sync_merge_same tests/sw_sync: Add subtest test_sync_multi_consumer tests/sw_sync: Add subtest test_sync_multi_consumer_producer tests/sw_sync: Add subtest test_sync_random_merge tests/sw_sync: Add subtest test_sync_multi_timeline_wait tests/sw_sync: Add subtest test_sync_multi_producer_single_consumer lib/Makefile.sources | 2 +- lib/sw_sync.c | 237 ++- lib/sw_sync.h | 49 +++- tests/Makefile.sources | 1 +- tests/sw_sync.c| 693 ++- 5 files changed, 982 insertions(+), 0 deletions(-) create mode 100644 lib/sw_sync.c create mode 100644 lib/sw_sync.h create mode 100644 tests/sw_sync.c -- git-series 0.8.10 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 1/13] lib/sw_sync: Add helper functions for managing synchronization primitives
From: Robert Foss Base functions to help testing the Sync File Framework (explicit fencing mechanism ported from Android). These functions allow you to create, use and destroy timelines and fences. Signed-off-by: Gustavo Padovan Signed-off-by: Robert Foss Reviewed-by: Eric Engestrom --- lib/Makefile.sources | 2 +- lib/sw_sync.c| 237 - lib/sw_sync.h| 49 +- 3 files changed, 288 insertions(+), 0 deletions(-) create mode 100644 lib/sw_sync.c create mode 100644 lib/sw_sync.h diff --git a/lib/Makefile.sources b/lib/Makefile.sources index bac9a7f..3dc7c3c 100644 --- a/lib/Makefile.sources +++ b/lib/Makefile.sources @@ -61,6 +61,8 @@ lib_source_list = \ rendercopy_gen8.c \ rendercopy_gen9.c \ rendercopy.h\ + sw_sync.c \ + sw_sync.h \ intel_reg_map.c \ intel_iosf.c\ igt_kms.c \ diff --git a/lib/sw_sync.c b/lib/sw_sync.c new file mode 100644 index 000..179a473 --- /dev/null +++ b/lib/sw_sync.c @@ -0,0 +1,237 @@ +/* + * Copyright 2012 Google, Inc + * Copyright © 2016 Collabora, Ltd. + * + * Based on the implementation from the Android Open Source Project + * + * 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: + *Robert Foss + */ + +#ifndef ANDROID +#define _GNU_SOURCE +#else +#include +#endif +#include +#include +#include +#include +#include + +#include "sw_sync.h" +#include "drmtest.h" +#include "ioctl_wrappers.h" + +#ifndef SW_SYNC_IOC_INC +struct sw_sync_create_fence_data { + __u32 value; + charname[32]; + __s32 fence; +}; + +#define SW_SYNC_IOC_MAGIC 'W' +#define SW_SYNC_IOC_CREATE_FENCE _IOWR(SW_SYNC_IOC_MAGIC, 0,\ + struct sw_sync_create_fence_data) +#define SW_SYNC_IOC_INC_IOW(SW_SYNC_IOC_MAGIC, 1, __u32) +#endif + +#define DEVFS_SW_SYNC "/dev/sw_sync" +#define DEBUGFS_SW_SYNC "/sys/kernel/debug/sync/sw_sync" + + +int sw_sync_fd_is_valid(int fd) +{ + int status; + + if (fd < 0) + return 0; + + status = fcntl(fd, F_GETFD, 0); + return status >= 0; +} + +static +void sw_sync_fd_close(int fd) +{ + if (!sw_sync_fd_is_valid(fd)) + return; + + close(fd); +} + +int sw_sync_timeline_create(void) +{ + int fd = open(DEVFS_SW_SYNC, O_RDWR); + + if (!sw_sync_fd_is_valid(fd)) + fd = open(DEBUGFS_SW_SYNC, O_RDWR); + + igt_assert(sw_sync_fd_is_valid(fd)); + + return fd; +} + +void sw_sync_timeline_destroy(int fd) +{ + return sw_sync_fd_close(fd); +} + +void sw_sync_fence_destroy(int fd) +{ + return sw_sync_fd_close(fd); +} + +int sw_sync_fence_create(int fd, int32_t seqno) +{ + struct sw_sync_create_fence_data data = {}; + data.value = seqno; + + if (fd >= 0) { + do_ioctl(fd, SW_SYNC_IOC_CREATE_FENCE, &data); + return data.fence; + } else { + do_ioctl_err(fd, SW_SYNC_IOC_CREATE_FENCE, &data, EBADF); + return -1; + } +} + +void sw_sync_timeline_inc(int fd, uint32_t count) +{ + uint32_t arg = count; + + if (fd == 0 || fd == -1) + return; + + do_ioctl(fd, SW_SYNC_IOC_INC, &arg); +} + +int sw_sync_merge(int fd1, int fd2) +{ + struct sync_merge_data data = {}; + int err; + + data.fd2 = fd2; + + err = ioctl(fd1, SYNC_IOC_MERGE, &data); + if (err < 0) + return err; + + sw_sync_fd_is_valid(data.fence); + + return data.fence; +} + +int sw_sync_wait(int fence, int timeout) +{ + struct pollfd fds; +
[Mesa-dev] [PATCH v2 2/13] tests/sw_sync: Add sw_sync test
From: Robert Foss Add initial tests for sw_sync. Signed-off-by: Robert Foss Signed-off-by: Gustavo Padovan Reviewed-by: Eric Engestrom --- tests/Makefile.sources | 1 +- tests/sw_sync.c| 51 +++- 2 files changed, 52 insertions(+), 0 deletions(-) create mode 100644 tests/sw_sync.c diff --git a/tests/Makefile.sources b/tests/Makefile.sources index 72a58ad..0ba769f 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -125,6 +125,7 @@ TESTS_progs_M = \ prime_mmap_kms \ prime_self_import \ prime_vgem \ + sw_sync \ template \ vgem_basic \ vgem_slow \ diff --git a/tests/sw_sync.c b/tests/sw_sync.c new file mode 100644 index 000..d2d4c42 --- /dev/null +++ b/tests/sw_sync.c @@ -0,0 +1,51 @@ +/* + * Copyright 2012 Google, Inc + * Copyright © 2016 Collabora, Ltd. + * + * Based on the implementation from the Android Open Source Project + * + * 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: + *Robert Foss + */ + +#include + +#include "sw_sync.h" +#include "igt.h" +#include "igt_aux.h" + +IGT_TEST_DESCRIPTION("Test SW Sync Framework"); + +static void test_alloc_timeline(void) +{ + int timeline; + + timeline = sw_sync_timeline_create(); + sw_sync_timeline_destroy(timeline); +} + +igt_main +{ + igt_subtest("alloc_timeline") + test_alloc_timeline(); +} + -- git-series 0.8.10 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 10/13] tests/sw_sync: Add subtest test_sync_multi_consumer_producer
From: Robert Foss This test verifies that stressing the kernel by creating multiple consumer/producer threads that wait on a single timeline to be incremented by another conumer/producer thread does not fail. And that the order amongst the threads is maintained. Signed-off-by: Robert Foss Reviewed-by: Eric Engestrom --- tests/sw_sync.c | 83 ++- 1 file changed, 83 insertions(+), 0 deletions(-) diff --git a/tests/sw_sync.c b/tests/sw_sync.c index 0c9c923..0e67ad5 100644 --- a/tests/sw_sync.c +++ b/tests/sw_sync.c @@ -303,6 +303,86 @@ static void test_sync_multi_consumer(void) igt_assert_f(thread_ret == 0, "A sync thread reported failure.\n"); } +static void * test_sync_multi_consumer_producer_thread(void *arg) +{ + data_t *data = arg; + int thread_id = data->thread_id; + int nbr_threads = data->nbr_threads; + int timeline = data->timeline; + int iterations = data->nbr_iterations; + int ret, i; + + for (i = 0; i < iterations; i++) { + int next_point = i * nbr_threads + thread_id; + int fence = sw_sync_fence_create(timeline, next_point); + + ret = sw_sync_wait(fence, 1000); + if (ret <= 0) + { + return (void *) 1; + } + + if (*(data->counter) != next_point) + { + return (void *) 1; + } + + (*data->counter)++; + + /* Kick off the next thread. */ + sw_sync_timeline_inc(timeline, 1); + + sw_sync_fence_destroy(fence); + } + return NULL; +} + +static void test_sync_multi_consumer_producer(void) +{ + const uint32_t nbr_threads = 8; + const uint32_t nbr_iterations = 1 << 14; + data_t data_arr[nbr_threads]; + pthread_t thread_arr[nbr_threads]; + int timeline; + volatile uint32_t counter = 0; + uintptr_t thread_ret = 0; + data_t data; + int i, ret; + + timeline = sw_sync_timeline_create(); + + data.nbr_iterations = nbr_iterations; + data.nbr_threads = nbr_threads; + data.counter = &counter; + data.timeline = timeline; + + /* Start consumer threads. */ + for (i = 0; i < nbr_threads; i++) + { + data_arr[i] = data; + data_arr[i].thread_id = i; + ret = pthread_create(&thread_arr[i], NULL, +test_sync_multi_consumer_producer_thread, +(void *) &(data_arr[i])); + igt_assert_eq(ret, 0); + } + + /* Wait for threads to complete. */ + for (i = 0; i < nbr_threads; i++) + { + uintptr_t local_thread_ret; + pthread_join(thread_arr[i], (void **)&local_thread_ret); + thread_ret |= local_thread_ret; + } + + sw_sync_timeline_destroy(timeline); + + igt_assert_f(counter == nbr_threads * nbr_iterations, +"Counter has unexpected value.\n"); + + igt_assert_f(thread_ret == 0, "A sync thread reported failure.\n"); +} + igt_main { igt_subtest("alloc_timeline") @@ -328,5 +408,8 @@ igt_main igt_subtest("sync_multi_consumer") test_sync_multi_consumer(); + + igt_subtest("sync_multi_consumer_producer") + test_sync_multi_consumer_producer(); } -- git-series 0.8.10 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 11/13] tests/sw_sync: Add subtest test_sync_random_merge
From: Robert Foss This subtest verifies that creating many timelines and merging random fences from each timeline with eachother results in merged fences that are fully functional. Signed-off-by: Robert Foss Reviewed-by: Eric Engestrom --- tests/sw_sync.c | 73 ++- 1 file changed, 73 insertions(+), 0 deletions(-) diff --git a/tests/sw_sync.c b/tests/sw_sync.c index 0e67ad5..93f4151 100644 --- a/tests/sw_sync.c +++ b/tests/sw_sync.c @@ -383,6 +383,76 @@ static void test_sync_multi_consumer_producer(void) igt_assert_f(thread_ret == 0, "A sync thread reported failure.\n"); } +static void test_sync_random_merge(void) +{ + int i, size, ret; + const int nbr_timeline = 32; + const int nbr_merge = 1024; + int fence_map[nbr_timeline]; + int timeline_arr[nbr_timeline]; + int fence, tmpfence, merged; + int timeline, timeline_offset, sync_pt; + + srand(time(NULL)); + + for (i = 0; i < nbr_timeline; i++) { + timeline_arr[i] = sw_sync_timeline_create(); + fence_map[i] = -1; + } + + sync_pt = rand(); + fence = sw_sync_fence_create(timeline_arr[0], sync_pt); + + fence_map[0] = sync_pt; + + /* Randomly create syncpoints out of a fixed set of timelines, +* and merge them together. +*/ + for (i = 0; i < nbr_merge; i++) { + /* Generate syncpoint. */ + timeline_offset = rand() % nbr_timeline; + timeline = timeline_arr[timeline_offset]; + sync_pt = rand(); + + /* Keep track of the latest sync_pt in each timeline. */ + if (fence_map[timeline_offset] == -1) + fence_map[timeline_offset] = sync_pt; + else if (fence_map[timeline_offset] < sync_pt) + fence_map[timeline_offset] = sync_pt; + + /* Merge. */ + tmpfence = sw_sync_fence_create(timeline, sync_pt); + merged = sw_sync_merge(tmpfence, fence); + sw_sync_fence_destroy(tmpfence); + sw_sync_fence_destroy(fence); + fence = merged; + } + + size = 0; + for (i = 0; i < nbr_timeline; i++) + if (fence_map[i] != -1) + size++; + + /* Trigger the merged fence. */ + for (i = 0; i < nbr_timeline; i++) { + if (fence_map[i] != -1) { + ret = sw_sync_wait(fence, 0); + igt_assert_f(ret == 0, + "Failure waiting on fence until timeout\n"); + /* Increment the timeline to the last sync_pt */ + sw_sync_timeline_inc(timeline_arr[i], fence_map[i]); + } + } + + /* Check that the fence is triggered. */ + ret = sw_sync_wait(fence, 0); + igt_assert_f(ret > 0, "Failure triggering fence\n"); + + sw_sync_fence_destroy(fence); + for (i = 0; i < nbr_timeline; i++) + sw_sync_timeline_destroy(timeline_arr[i]); +} + igt_main { igt_subtest("alloc_timeline") @@ -411,5 +481,8 @@ igt_main igt_subtest("sync_multi_consumer_producer") test_sync_multi_consumer_producer(); + + igt_subtest("sync_random_merge") + test_sync_random_merge(); } -- git-series 0.8.10 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 5/13] tests/sw_sync: Add subtest test_alloc_merge_fence
From: Robert Foss This subtest verifies that merging two fences works in the simples possible case. Signed-off-by: Robert Foss Reviewed-by: Eric Engestrom --- tests/sw_sync.c | 23 +++ 1 file changed, 23 insertions(+), 0 deletions(-) diff --git a/tests/sw_sync.c b/tests/sw_sync.c index 102647d..851430e 100644 --- a/tests/sw_sync.c +++ b/tests/sw_sync.c @@ -60,6 +60,26 @@ static void test_alloc_fence_invalid_timeline(void) sw_sync_fence_create(-1, 0); } +static void test_alloc_merge_fence(void) +{ + int in_fence[2]; + int fence_merge; + int timeline[2]; + + timeline[0] = sw_sync_timeline_create(); + timeline[1] = sw_sync_timeline_create(); + + in_fence[0] = sw_sync_fence_create(timeline[0], 1); + in_fence[1] = sw_sync_fence_create(timeline[1], 1); + fence_merge = sw_sync_merge(in_fence[1], in_fence[0]); + + sw_sync_fence_destroy(in_fence[0]); + sw_sync_fence_destroy(in_fence[1]); + sw_sync_fence_destroy(fence_merge); + sw_sync_timeline_destroy(timeline[0]); + sw_sync_timeline_destroy(timeline[1]); +} + igt_main { igt_subtest("alloc_timeline") @@ -70,5 +90,8 @@ igt_main igt_subtest("alloc_fence_invalid_timeline") test_alloc_fence_invalid_timeline(); + + igt_subtest("alloc_merge_fence") + test_alloc_merge_fence(); } -- git-series 0.8.10 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 13/13] tests/sw_sync: Add subtest test_sync_multi_producer_single_consumer
From: Robert Foss This subtest runs a single consumer thread and multiple producer thread that are synchronized using multiple timelines. Signed-off-by: Robert Foss Reviewed-by: Eric Engestrom --- tests/sw_sync.c | 139 +- 1 file changed, 139 insertions(+), 0 deletions(-) diff --git a/tests/sw_sync.c b/tests/sw_sync.c index 322c7b1..4336659 100644 --- a/tests/sw_sync.c +++ b/tests/sw_sync.c @@ -446,6 +446,142 @@ static void test_sync_multi_consumer_producer(void) igt_assert_f(thread_ret == 0, "A sync thread reported failure.\n"); } +static int test_mspc_wait_on_fence(int fence) +{ + int error, active; + + do { + error = sw_sync_fence_count_status(fence, + SW_SYNC_FENCE_STATUS_ERROR); + igt_assert_f(error == 0, "Error occurred on fence\n"); + active = sw_sync_fence_count_status(fence, + SW_SYNC_FENCE_STATUS_ACTIVE); + } while (active); + + return 0; +} + +static struct { + int iterations; + int threads; + int counter; + int cons_timeline; + int *prod_timeline; + pthread_mutex_t lock; +} test_mpsc_data; + +static int mpsc_producer_thread(void *d) +{ + int id = (long)d; + int fence, i; + int *prod_timeline = test_mpsc_data.prod_timeline; + int cons_timeline = test_mpsc_data.cons_timeline; + int iterations = test_mpsc_data.iterations; + + for (i = 0; i < iterations; i++) { + fence = sw_sync_fence_create(cons_timeline, i); + + /* Wait for the consumer to finish. Use alternate +* means of waiting on the fence +*/ + if ((iterations + id) % 8 != 0) { + igt_assert_f(sw_sync_wait(fence, -1) > 0, +"Failure waiting on fence\n"); + } else { + igt_assert_f(test_mspc_wait_on_fence(fence) == 0, +"Failure waiting on fence\n"); + } + + /* Every producer increments the counter, the consumer +* checks and erases it +*/ + pthread_mutex_lock(&test_mpsc_data.lock); + test_mpsc_data.counter++; + pthread_mutex_unlock(&test_mpsc_data.lock); + + sw_sync_timeline_inc(prod_timeline[id], 1); + sw_sync_fence_destroy(fence); + } + + return 0; +} + +static int mpsc_consumer_thread(void) +{ + int fence, merged, tmp, it, i; + int *prod_timeline = test_mpsc_data.prod_timeline; + int cons_timeline = test_mpsc_data.cons_timeline; + int iterations = test_mpsc_data.iterations; + int n = test_mpsc_data.threads; + + for (it = 1; it <= iterations; it++) { + fence = sw_sync_fence_create(prod_timeline[0], it); + for (i = 1; i < n; i++) { + tmp = sw_sync_fence_create(prod_timeline[i], it); + merged = sw_sync_merge(tmp, fence); + sw_sync_fence_destroy(tmp); + sw_sync_fence_destroy(fence); + fence = merged; + } + + /* Make sure we see an increment from every producer thread. +* Vary the means by which we wait. +*/ + if (iterations % 8 != 0) { + igt_assert_f(sw_sync_wait(fence, -1) == 0, + "Producers did not increment as expected\n"); + } else { + igt_assert_f(test_mspc_wait_on_fence(fence) == 0, +"Failure waiting on fence\n"); + } + + igt_assert_f(test_mpsc_data.counter == n * it, +"Counter value mismatch\n"); + + /* Release the producer threads */ + sw_sync_timeline_inc(cons_timeline, 1); + sw_sync_fence_destroy(fence); + } + + return 0; +} + +/* IMPORTANT NOTE: if you see this test failing on your system, it may be + * due to a shortage of file descriptors. Please ensure your system has + * a sensible limit for this test to finish correctly. + */ +static void test_sync_multi_producer_single_consumer(void) +{ + int iterations = 1 << 12; + int n = 5; + int prod_timeline[n]; + int cons_timeline; + pthread_t threads[n]; + long i; + + cons_timeline = sw_sync_timeline_create(); + for (i = 0; i < n; i++) + prod_timeline[i] = sw_sync_timeline_create(); + + test_mpsc_data.prod_timeline = prod_timeline; + test_mpsc_data.cons_timeline = cons_timeline; + test_mpsc_d
[Mesa-dev] [PATCH v2 4/13] tests/sw_sync: Add subtest test_alloc_fence_invalid_timeline
From: Robert Foss This subtests tests that creating fences on negative timelines fail. Signed-off-by: Robert Foss Reviewed-by: Eric Engestrom --- tests/sw_sync.c | 7 +++ 1 file changed, 7 insertions(+), 0 deletions(-) diff --git a/tests/sw_sync.c b/tests/sw_sync.c index a8c8ca4..102647d 100644 --- a/tests/sw_sync.c +++ b/tests/sw_sync.c @@ -55,6 +55,10 @@ static void test_alloc_fence(void) sw_sync_timeline_destroy(timeline); } +static void test_alloc_fence_invalid_timeline(void) +{ + sw_sync_fence_create(-1, 0); +} igt_main { @@ -63,5 +67,8 @@ igt_main igt_subtest("alloc_fence") test_alloc_fence(); + + igt_subtest("alloc_fence_invalid_timeline") + test_alloc_fence_invalid_timeline(); } -- git-series 0.8.10 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 12/13] tests/sw_sync: Add subtest test_sync_multi_timeline_wait
From: Robert Foss This subtest verifies that waiting, timing out on a wait and that counting fences in various states works. Signed-off-by: Robert Foss Reviewed-by: Eric Engestrom --- tests/sw_sync.c | 66 ++- 1 file changed, 66 insertions(+), 0 deletions(-) diff --git a/tests/sw_sync.c b/tests/sw_sync.c index 93f4151..322c7b1 100644 --- a/tests/sw_sync.c +++ b/tests/sw_sync.c @@ -214,6 +214,69 @@ static void test_sync_merge_same(void) sw_sync_timeline_destroy(timeline); } +static void test_sync_multi_timeline_wait(void) +{ + int timeline[3]; + int in_fence[3]; + int fence_merge; + int active, signaled, ret; + + timeline[0] = sw_sync_timeline_create(); + timeline[1] = sw_sync_timeline_create(); + timeline[2] = sw_sync_timeline_create(); + + in_fence[0] = sw_sync_fence_create(timeline[0], 5); + in_fence[1] = sw_sync_fence_create(timeline[1], 5); + in_fence[2] = sw_sync_fence_create(timeline[2], 5); + + fence_merge = sw_sync_merge(in_fence[0], in_fence[1]); + fence_merge = sw_sync_merge(in_fence[2], fence_merge); + + /* Confirm fence isn't signaled */ + active = sw_sync_fence_count_status(fence_merge, + SW_SYNC_FENCE_STATUS_ACTIVE); + igt_assert_f(active == 3, "Fence signaled too early\n"); + + ret = sw_sync_wait(fence_merge, 0); + igt_assert_f(ret == 0, "Failure waiting on fence until timeout\n"); + + sw_sync_timeline_inc(timeline[0], 5); + active = sw_sync_fence_count_status(fence_merge, + SW_SYNC_FENCE_STATUS_ACTIVE); + signaled = sw_sync_fence_count_status(fence_merge, + SW_SYNC_FENCE_STATUS_SIGNALED); + igt_assert_f(active == 2 && signaled == 1, + "Fence did not signal properly\n"); + + sw_sync_timeline_inc(timeline[1], 5); + active = sw_sync_fence_count_status(fence_merge, + SW_SYNC_FENCE_STATUS_ACTIVE); + signaled = sw_sync_fence_count_status(fence_merge, + SW_SYNC_FENCE_STATUS_SIGNALED); + igt_assert_f(active == 1 && signaled == 2, + "Fence did not signal properly\n"); + + sw_sync_timeline_inc(timeline[2], 5); + active = sw_sync_fence_count_status(fence_merge, + SW_SYNC_FENCE_STATUS_ACTIVE); + signaled = sw_sync_fence_count_status(fence_merge, + SW_SYNC_FENCE_STATUS_SIGNALED); + igt_assert_f(active == 0 && signaled == 3, +"Fence did not signal properly\n"); + + /* confirm you can successfully wait */ + ret = sw_sync_wait(fence_merge, 100); + igt_assert_f(ret > 0, "Failure waiting on signaled fence\n"); + + sw_sync_fence_destroy(in_fence[0]); + sw_sync_fence_destroy(in_fence[1]); + sw_sync_fence_destroy(in_fence[2]); + sw_sync_fence_destroy(fence_merge); + sw_sync_timeline_destroy(timeline[0]); + sw_sync_timeline_destroy(timeline[1]); + sw_sync_timeline_destroy(timeline[2]); +} + static void * test_sync_multi_consumer_thread(void *arg) { data_t *data = arg; @@ -476,6 +539,9 @@ igt_main igt_subtest("sync_merge_same") test_sync_merge_same(); + igt_subtest("sync_multi_timeline_wait") + test_sync_multi_timeline_wait(); + igt_subtest("sync_multi_consumer") test_sync_multi_consumer(); -- git-series 0.8.10 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 9/13] tests/sw_sync: Add subtest test_sync_multi_consumer
From: Robert Foss This subtest verifies the access ordering of multiple consumer threads. Signed-off-by: Robert Foss Reviewed-by: Eric Engestrom --- tests/sw_sync.c | 103 +- 1 file changed, 103 insertions(+), 0 deletions(-) diff --git a/tests/sw_sync.c b/tests/sw_sync.c index db03f48..0c9c923 100644 --- a/tests/sw_sync.c +++ b/tests/sw_sync.c @@ -27,6 +27,8 @@ *Robert Foss */ +#include +#include #include #include "sw_sync.h" @@ -35,6 +37,15 @@ IGT_TEST_DESCRIPTION("Test SW Sync Framework"); +typedef struct { + int timeline; + uint32_t thread_id; + uint32_t nbr_threads; + uint32_t nbr_iterations; + volatile uint32_t * volatile counter; + sem_t *sem; +} data_t; + static void test_alloc_timeline(void) { int timeline; @@ -203,6 +214,95 @@ static void test_sync_merge_same(void) sw_sync_timeline_destroy(timeline); } +static void * test_sync_multi_consumer_thread(void *arg) +{ + data_t *data = arg; + int thread_id = data->thread_id; + int nbr_threads = data->nbr_threads; + int timeline = data->timeline; + int iterations = data->nbr_iterations; + int ret, i; + + for (i = 0; i < iterations; i++) { + int next_point = i * nbr_threads + thread_id; + int fence = sw_sync_fence_create(timeline, next_point); + + ret = sw_sync_wait(fence, 1000); + if (ret <= 0) + { + return (void *) 1; + } + + if (*(data->counter) != next_point) + { + return (void *) 1; + } + + sem_post(data->sem); + sw_sync_fence_destroy(fence); + } + return NULL; +} + +static void test_sync_multi_consumer(void) +{ + const uint32_t nbr_threads = 8; + const uint32_t nbr_iterations = 1 << 14; + data_t data_arr[nbr_threads]; + pthread_t thread_arr[nbr_threads]; + sem_t sem; + int timeline; + volatile uint32_t counter = 0; + uintptr_t thread_ret = 0; + data_t data; + int i, ret; + + sem_init(&sem, 0, 0); + timeline = sw_sync_timeline_create(); + + data.nbr_iterations = nbr_iterations; + data.nbr_threads = nbr_threads; + data.counter = &counter; + data.timeline = timeline; + data.sem = &sem; + + /* Start sync threads. */ + for (i = 0; i < nbr_threads; i++) + { + data_arr[i] = data; + data_arr[i].thread_id = i; + ret = pthread_create(&thread_arr[i], NULL, +test_sync_multi_consumer_thread, +(void *) &(data_arr[i])); + igt_assert_eq(ret, 0); + } + + /* Produce 'content'. */ + for (i = 0; i < nbr_threads * nbr_iterations; i++) + { + sem_wait(&sem); + + counter++; + sw_sync_timeline_inc(timeline, 1); + } + + /* Wait for threads to complete. */ + for (i = 0; i < nbr_threads; i++) + { + uintptr_t local_thread_ret; + pthread_join(thread_arr[i], (void **)&local_thread_ret); + thread_ret |= local_thread_ret; + } + + sw_sync_timeline_destroy(timeline); + sem_destroy(&sem); + + igt_assert_f(counter == nbr_threads * nbr_iterations, +"Counter has unexpected value.\n"); + + igt_assert_f(thread_ret == 0, "A sync thread reported failure.\n"); +} + igt_main { igt_subtest("alloc_timeline") @@ -225,5 +325,8 @@ igt_main igt_subtest("sync_merge_same") test_sync_merge_same(); + + igt_subtest("sync_multi_consumer") + test_sync_multi_consumer(); } -- git-series 0.8.10 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 7/13] tests/sw_sync: Add subtest test_sync_merge
From: Robert Foss Add subtest test_sync_merge that tests merging fences and the validity of the resulting merged fence. Signed-off-by: Robert Foss Reviewed-by: Eric Engestrom --- tests/sw_sync.c | 67 ++- 1 file changed, 67 insertions(+), 0 deletions(-) diff --git a/tests/sw_sync.c b/tests/sw_sync.c index 07e9638..00ac44b 100644 --- a/tests/sw_sync.c +++ b/tests/sw_sync.c @@ -115,6 +115,70 @@ static void test_sync_wait(void) sw_sync_timeline_destroy(timeline); } +static void test_sync_merge(void) +{ + int in_fence[3]; + int fence_merge; + int timeline; + int active, signaled; + + timeline = sw_sync_timeline_create(); + in_fence[0] = sw_sync_fence_create(timeline, 1); + in_fence[1] = sw_sync_fence_create(timeline, 2); + in_fence[2] = sw_sync_fence_create(timeline, 3); + + fence_merge = sw_sync_merge(in_fence[0], in_fence[1]); + fence_merge = sw_sync_merge(in_fence[2], fence_merge); + + /* confirm all fences have one active point (even d) */ + active = sw_sync_fence_count_status(in_fence[0], + SW_SYNC_FENCE_STATUS_ACTIVE); + igt_assert_f(active == 1, "in_fence[0] has too many active fences\n"); + active = sw_sync_fence_count_status(in_fence[1], + SW_SYNC_FENCE_STATUS_ACTIVE); + igt_assert_f(active == 1, "in_fence[1] has too many active fences\n"); + active = sw_sync_fence_count_status(in_fence[2], + SW_SYNC_FENCE_STATUS_ACTIVE); + igt_assert_f(active == 1, "in_fence[2] has too many active fences\n"); + active = sw_sync_fence_count_status(fence_merge, + SW_SYNC_FENCE_STATUS_ACTIVE); + igt_assert_f(active == 1, "fence_merge has too many active fences\n"); + + /* confirm that fence_merge is not signaled until the max of fence 0,1,2 */ + sw_sync_timeline_inc(timeline, 1); + signaled = sw_sync_fence_count_status(in_fence[0], + SW_SYNC_FENCE_STATUS_SIGNALED); + active = sw_sync_fence_count_status(fence_merge, + SW_SYNC_FENCE_STATUS_ACTIVE); + igt_assert_f(signaled == 1, "in_fence[0] did not signal\n"); + igt_assert_f(active == 1, "fence_merge signaled too early\n"); + + sw_sync_timeline_inc(timeline, 1); + signaled = sw_sync_fence_count_status(in_fence[1], + SW_SYNC_FENCE_STATUS_SIGNALED); + active = sw_sync_fence_count_status(fence_merge, + SW_SYNC_FENCE_STATUS_ACTIVE); + igt_assert_f(signaled == 1, "in_fence[1] did not signal\n"); + igt_assert_f(active == 1, "fence_merge signaled too early\n"); + + sw_sync_timeline_inc(timeline, 1); + signaled = sw_sync_fence_count_status(in_fence[2], + SW_SYNC_FENCE_STATUS_SIGNALED); + igt_assert_f(signaled == 1, "in_fence[2] did not signal\n"); + signaled = sw_sync_fence_count_status(fence_merge, + SW_SYNC_FENCE_STATUS_SIGNALED); + active = sw_sync_fence_count_status(fence_merge, + SW_SYNC_FENCE_STATUS_ACTIVE); + igt_assert_f(active == 0 && signaled == 1, +"fence_merge did not signal\n"); + + sw_sync_fence_destroy(in_fence[0]); + sw_sync_fence_destroy(in_fence[1]); + sw_sync_fence_destroy(in_fence[2]); + sw_sync_fence_destroy(fence_merge); + sw_sync_timeline_destroy(timeline); +} + igt_main { igt_subtest("alloc_timeline") @@ -131,5 +195,8 @@ igt_main igt_subtest("sync_wait") test_sync_wait(); + + igt_subtest("sync_merge") + test_sync_merge(); } -- git-series 0.8.10 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 8/13] tests/sw_sync: Add subtest test_sync_merge_same
From: Robert Foss This subtest verifies merging a fence with itself does not fail. Signed-off-by: Robert Foss Reviewed-by: Eric Engestrom --- tests/sw_sync.c | 27 +++ 1 file changed, 27 insertions(+), 0 deletions(-) diff --git a/tests/sw_sync.c b/tests/sw_sync.c index 00ac44b..db03f48 100644 --- a/tests/sw_sync.c +++ b/tests/sw_sync.c @@ -179,6 +179,30 @@ static void test_sync_merge(void) sw_sync_timeline_destroy(timeline); } +static void test_sync_merge_same(void) +{ + int in_fence[2]; + int timeline; + int signaled; + + timeline = sw_sync_timeline_create(); + in_fence[0] = sw_sync_fence_create(timeline, 1); + in_fence[1] = sw_sync_merge(in_fence[0], in_fence[0]); + + signaled = sw_sync_fence_count_status(in_fence[0], + SW_SYNC_FENCE_STATUS_SIGNALED); + igt_assert_f(signaled == 0, "fence signaled too early\n"); + + sw_sync_timeline_inc(timeline, 1); + signaled = sw_sync_fence_count_status(in_fence[0], + SW_SYNC_FENCE_STATUS_SIGNALED); + igt_assert_f(signaled == 1, "fence did not signal\n"); + + sw_sync_fence_destroy(in_fence[0]); + sw_sync_fence_destroy(in_fence[1]); + sw_sync_timeline_destroy(timeline); +} + igt_main { igt_subtest("alloc_timeline") @@ -198,5 +222,8 @@ igt_main igt_subtest("sync_merge") test_sync_merge(); + + igt_subtest("sync_merge_same") + test_sync_merge_same(); } -- git-series 0.8.10 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 6/13] tests/sw_sync: Add subtest test_sync_wait
From: Robert Foss This subtest verifies that waiting on fences works properly. Signed-off-by: Robert Foss Reviewed-by: Eric Engestrom --- tests/sw_sync.c | 38 ++ 1 file changed, 38 insertions(+), 0 deletions(-) diff --git a/tests/sw_sync.c b/tests/sw_sync.c index 851430e..07e9638 100644 --- a/tests/sw_sync.c +++ b/tests/sw_sync.c @@ -80,6 +80,41 @@ static void test_alloc_merge_fence(void) sw_sync_timeline_destroy(timeline[1]); } +static void test_sync_wait(void) +{ + int fence, ret; + int timeline; + + timeline = sw_sync_timeline_create(); + fence = sw_sync_fence_create(timeline, 5); + + /* Wait on fence until timeout */ + ret = sw_sync_wait(fence, 0); + igt_assert_f(ret == 0, "Failure waiting on fence until timeout\n"); + + /* Advance timeline from 0 -> 1 */ + sw_sync_timeline_inc(timeline, 1); + + /* Wait on fence until timeout */ + ret = sw_sync_wait(fence, 0); + igt_assert_f(ret == 0, "Failure waiting on fence until timeout\n"); + + /* Signal the fence */ + sw_sync_timeline_inc(timeline, 4); + + /* Wait successfully */ + ret = sw_sync_wait(fence, 0); + igt_assert_f(ret > 0, "Failure waiting on fence\n"); + + /* Go even further, and confirm wait still succeeds */ + sw_sync_timeline_inc(timeline, 10); + ret = sw_sync_wait(fence, 0); + igt_assert_f(ret > 0, "Failure waiting ahead\n"); + + sw_sync_fence_destroy(fence); + sw_sync_timeline_destroy(timeline); +} + igt_main { igt_subtest("alloc_timeline") @@ -93,5 +128,8 @@ igt_main igt_subtest("alloc_merge_fence") test_alloc_merge_fence(); + + igt_subtest("sync_wait") + test_sync_wait(); } -- git-series 0.8.10 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 3/13] tests/sw_sync: Add subtest test_alloc_fence
From: Robert Foss Add subtest alloc_fence that verifies that it's possible to allocate a fence on a timeline. Signed-off-by: Robert Foss Reviewed-by: Eric Engestrom --- tests/sw_sync.c | 16 1 file changed, 16 insertions(+), 0 deletions(-) diff --git a/tests/sw_sync.c b/tests/sw_sync.c index d2d4c42..a8c8ca4 100644 --- a/tests/sw_sync.c +++ b/tests/sw_sync.c @@ -43,9 +43,25 @@ static void test_alloc_timeline(void) sw_sync_timeline_destroy(timeline); } +static void test_alloc_fence(void) +{ + int in_fence; + int timeline; + + timeline = sw_sync_timeline_create(); + in_fence = sw_sync_fence_create(timeline, 0); + + sw_sync_fence_destroy(in_fence); + sw_sync_timeline_destroy(timeline); +} + + igt_main { igt_subtest("alloc_timeline") test_alloc_timeline(); + + igt_subtest("alloc_fence") + test_alloc_fence(); } -- git-series 0.8.10 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [RFC] mesa: drop current draw/read buffer when ctx is released
I gave this patch a spin on a Qemu+Virgl+AOSP setup, and it seems to work rather well. Thanks Rob! Tested-by: Robert Foss ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [RFC 10/10] virgl: native fence fd support
Thanks for upstreaming this, this patch has been tested and confirmed working on a qemu setup. Tested-by: Robert Foss On Fri, 2016-11-18 at 08:39 -0500, Rob Clark wrote: > From: Gustavo Padovan > > --- > src/gallium/drivers/virgl/virgl_context.c | 47 +++- > - > src/gallium/drivers/virgl/virgl_screen.c | 12 +++- > src/gallium/drivers/virgl/virgl_winsys.h | 16 - > src/gallium/winsys/virgl/drm/virgl_drm_winsys.c| 78 > +- > src/gallium/winsys/virgl/drm/virgl_drm_winsys.h| 2 + > src/gallium/winsys/virgl/drm/virtgpu_drm.h | 16 - > .../winsys/virgl/vtest/virgl_vtest_winsys.c| 8 ++- > 7 files changed, 162 insertions(+), 17 deletions(-) > > diff --git a/src/gallium/drivers/virgl/virgl_context.c > b/src/gallium/drivers/virgl/virgl_context.c > index bda9515..66bd4e8 100644 > --- a/src/gallium/drivers/virgl/virgl_context.c > +++ b/src/gallium/drivers/virgl/virgl_context.c > @@ -21,6 +21,8 @@ > * USE OR OTHER DEALINGS IN THE SOFTWARE. > */ > > +#include > + > #include "pipe/p_shader_tokens.h" > > #include "pipe/p_context.h" > @@ -623,13 +625,20 @@ static void virgl_draw_vbo(struct pipe_context > *ctx, > > } > > -static void virgl_flush_eq(struct virgl_context *ctx, void *closure) > +static void virgl_flush_eq(struct virgl_context *ctx, void *closure, > + struct pipe_fence_handle **fence) > { > struct virgl_screen *rs = virgl_screen(ctx->base.screen); > + int out_fence_fd = -1; > > /* send the buffer to the remote side for decoding */ > ctx->num_transfers = ctx->num_draws = 0; > - rs->vws->submit_cmd(rs->vws, ctx->cbuf); > + > + rs->vws->submit_cmd(rs->vws, ctx->cbuf, ctx->cbuf->in_fence_fd, > + ctx->cbuf->needs_out_fence_fd ? &out_fence_fd > : NULL); > + > + if (fence) > + *fence = rs->vws->cs_create_fence(rs->vws, out_fence_fd); > > virgl_encoder_set_sub_ctx(ctx, ctx->hw_sub_ctx_id); > > @@ -642,11 +651,10 @@ static void virgl_flush_from_st(struct > pipe_context *ctx, > enum pipe_flush_flags flags) > { > struct virgl_context *vctx = virgl_context(ctx); > - struct virgl_screen *rs = virgl_screen(ctx->screen); > struct virgl_buffer *buf, *tmp; > > - if (fence) > - *fence = rs->vws->cs_create_fence(rs->vws); > + if (flags & PIPE_FLUSH_FENCE_FD) > + vctx->cbuf->needs_out_fence_fd = true; > > LIST_FOR_EACH_ENTRY_SAFE(buf, tmp, &vctx->to_flush_bufs, > flush_list) { > struct pipe_resource *res = &buf->base.u.b; > @@ -656,7 +664,13 @@ static void virgl_flush_from_st(struct > pipe_context *ctx, > pipe_resource_reference(&res, NULL); > > } > - virgl_flush_eq(vctx, vctx); > + virgl_flush_eq(vctx, vctx, fence); > + > + if (vctx->cbuf->in_fence_fd != -1) { > + close(vctx->cbuf->in_fence_fd); > + vctx->cbuf->in_fence_fd = -1; > + } > + vctx->cbuf->needs_out_fence_fd = false; > } > > static struct pipe_sampler_view *virgl_create_sampler_view(struct > pipe_context *ctx, > @@ -846,6 +860,23 @@ static void virgl_blit(struct pipe_context *ctx, > blit); > } > > +static void virgl_create_fence_fd(struct pipe_context *ctx, > + struct pipe_fence_handle **fence, > int fd) > +{ > + struct virgl_screen *rs = virgl_screen(ctx->screen); > + > + *fence = rs->vws->cs_create_fence(rs->vws, fd); > +} > + > +static void virgl_fence_server_sync(struct pipe_context *ctx, > + struct pipe_fence_handle *fence) > +{ > + struct virgl_context *vctx = virgl_context(ctx); > + struct virgl_screen *rs = virgl_screen(ctx->screen); > + > + rs->vws->fence_server_sync(rs->vws, vctx->cbuf, fence); > +} > + > static void > virgl_context_destroy( struct pipe_context *ctx ) > { > @@ -855,7 +886,7 @@ virgl_context_destroy( struct pipe_context *ctx ) > vctx->framebuffer.zsbuf = NULL; > vctx->framebuffer.nr_cbufs = 0; > virgl_encoder_destroy_sub_ctx(vctx, vctx->hw_sub_ctx_id); > - virgl_flush_eq(vctx, vctx); > + virgl_flush_eq(vctx, vctx, NULL); > > rs->vws->cmd_buf_destroy(vctx->cbuf); > if (vctx->uploader) > @@ -937,6 +968,8 @@ struct pipe_context *virgl_context_create(struct > pipe_screen *pscreen, > vctx->base.resource_copy_region = virgl_resource_copy_region; > vctx->
Re: [Mesa-dev] [PATCH 0/5] Cleanup dead code
On 2/10/19 6:58 PM, Robert Foss wrote: This patch is s/patch/series Reviewed-by: Robert Foss On 2/9/19 2:21 AM, Alyssa Rosenzweig wrote: Via the prototyping cycle, a substantial amount of dead code and other cruft has accumulated in the Panfrost tree, which is a burden for both maintenance and aesthetic. This patch series removes dead code when it's trivial to do so, or refactors in order to remove dead code when nontrivial to do so. After these patches, all "#if 0" code is removed except for the wallpapering routine which will be another series in and of itself ;) Alyssa Rosenzweig (5): panfrost: Remove if 0'd dead code panfrost: Specify supported draw modes per-context panfrost: Overhaul viewport code; fix scissor test panfrost: Remove speculative if 0'd format bit code panfrost: Elucidate texture op scheduling comment .../drivers/panfrost/midgard/cmdline.c | 11 -- .../panfrost/midgard/midgard_compile.c | 9 +- src/gallium/drivers/panfrost/pan_assemble.c | 14 -- .../drivers/panfrost/pan_blend_shaders.c | 16 --- src/gallium/drivers/panfrost/pan_context.c | 129 +- src/gallium/drivers/panfrost/pan_context.h | 3 + src/gallium/drivers/panfrost/pan_swizzle.c | 37 - 7 files changed, 69 insertions(+), 150 deletions(-) ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 0/5] Cleanup dead code
This patch is Reviewed-by: Robert Foss On 2/9/19 2:21 AM, Alyssa Rosenzweig wrote: Via the prototyping cycle, a substantial amount of dead code and other cruft has accumulated in the Panfrost tree, which is a burden for both maintenance and aesthetic. This patch series removes dead code when it's trivial to do so, or refactors in order to remove dead code when nontrivial to do so. After these patches, all "#if 0" code is removed except for the wallpapering routine which will be another series in and of itself ;) Alyssa Rosenzweig (5): panfrost: Remove if 0'd dead code panfrost: Specify supported draw modes per-context panfrost: Overhaul viewport code; fix scissor test panfrost: Remove speculative if 0'd format bit code panfrost: Elucidate texture op scheduling comment .../drivers/panfrost/midgard/cmdline.c| 11 -- .../panfrost/midgard/midgard_compile.c| 9 +- src/gallium/drivers/panfrost/pan_assemble.c | 14 -- .../drivers/panfrost/pan_blend_shaders.c | 16 --- src/gallium/drivers/panfrost/pan_context.c| 129 +- src/gallium/drivers/panfrost/pan_context.h| 3 + src/gallium/drivers/panfrost/pan_swizzle.c| 37 - 7 files changed, 69 insertions(+), 150 deletions(-) ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] spirv_to_nir: Avoid out of bounds access to nir src array.
From: Robert Foss Avoid out of bounds access of the array 'src'. 'src' is passed along: nir_eval_const_opcode() evaluate_bitfield_insert() In evaluate_bitfield_insert() an access to src[3] is made if bit_size==32 wich it always will be due to the assert(bit_size == 32) on spirv_to_nir.c:1045. Since 'src' is of length 3, this is out of bounds. Coverity id: 1358582 Signed-off-by: Robert Foss --- src/compiler/spirv/spirv_to_nir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c index 99514b4..46ede6a 100644 --- a/src/compiler/spirv/spirv_to_nir.c +++ b/src/compiler/spirv/spirv_to_nir.c @@ -1035,7 +1035,7 @@ vtn_handle_constant(struct vtn_builder *b, SpvOp opcode, unsigned bit_size = glsl_get_bit_size(glsl_get_base_type(val->const_type)); - nir_const_value src[3]; + nir_const_value src[4]; assert(count <= 7); for (unsigned i = 0; i < count - 4; i++) { nir_constant *c = -- 2.5.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] vid_enc: Fix resource leak on OMX_ErrorNone
From: Robert Foss Avoid leaking buffer allocated for task if an error has occured. Coverity id: 1213929 Signed-off-by: Robert Foss --- src/gallium/state_trackers/omx/vid_enc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/state_trackers/omx/vid_enc.c b/src/gallium/state_trackers/omx/vid_enc.c index 4505fe1..de62166 100644 --- a/src/gallium/state_trackers/omx/vid_enc.c +++ b/src/gallium/state_trackers/omx/vid_enc.c @@ -1152,6 +1152,7 @@ static OMX_ERRORTYPE vid_enc_EncodeFrame(omx_base_PortType *port, OMX_BUFFERHEAD /* --- load input image into video buffer */ err = enc_LoadImage(port, buf, task->buf); if (err != OMX_ErrorNone) + FREE(task); return err; } -- 2.5.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] spirv: Avoid out of bounds access to nir src array.
From: Robert Foss Avoid out of bounds access of the array 'src'. 'src' is passed along: nir_eval_const_opcode() evaluate_bitfield_insert() In evaluate_bitfield_insert() an access to src[3] is made if bit_size==32 wich it always will be due to the assert(bit_size == 32) on spirv_to_nir.c:1045. Since 'src' is of length 3, this is out of bounds. Coverity id: 1358582 Signed-off-by: Robert Foss --- src/compiler/spirv/spirv_to_nir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c index 99514b4..46ede6a 100644 --- a/src/compiler/spirv/spirv_to_nir.c +++ b/src/compiler/spirv/spirv_to_nir.c @@ -1035,7 +1035,7 @@ vtn_handle_constant(struct vtn_builder *b, SpvOp opcode, unsigned bit_size = glsl_get_bit_size(glsl_get_base_type(val->const_type)); - nir_const_value src[3]; + nir_const_value src[4]; assert(count <= 7); for (unsigned i = 0; i < count - 4; i++) { nir_constant *c = -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] spirv: Avoid out of bounds access to nir src array.
Alright, I'll mark this as rejected in patchwork. On 2016-06-03 01:28 PM, Jason Ekstrand wrote: None of the Opcode's evaluated as specialization constants have four sources so this will never be a problem. Hence the assert on the next line. I think we should just mark this as a false positive. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v1 3/4] freedreno/a2xx: Make fd2_program_validate return failure information.
From: Robert Foss Make fd2_program_validate return failure information to avoid de-allocated memory from being used. coverity: 1362467 Signed-off-by: Robert Foss --- src/gallium/drivers/freedreno/a2xx/fd2_program.c | 12 +--- src/gallium/drivers/freedreno/a2xx/fd2_program.h | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_program.c b/src/gallium/drivers/freedreno/a2xx/fd2_program.c index 4f31772..1819c52 100644 --- a/src/gallium/drivers/freedreno/a2xx/fd2_program.c +++ b/src/gallium/drivers/freedreno/a2xx/fd2_program.c @@ -237,7 +237,7 @@ patch_tex_fetches(struct fd_context *ctx, struct fd2_shader_stateobj *so, } } -void +bool fd2_program_validate(struct fd_context *ctx) { struct fd_program_stateobj *prog = &ctx->prog; @@ -248,10 +248,14 @@ fd2_program_validate(struct fd_context *ctx) * need to recompile both vert and frag shader. */ if (ctx->dirty & FD_SHADER_DIRTY_FP) - compile(prog, prog->fp); + { + if (compile(prog, prog->fp) == NULL) + return false; + } if (ctx->dirty & (FD_SHADER_DIRTY_FP | FD_SHADER_DIRTY_VP)) - compile(prog, prog->vp); + if (compile(prog, prog->vp) == NULL) + return false; /* if necessary, fix up vertex fetch instructions: */ if (ctx->dirty & (FD_DIRTY_VTXSTATE | FD_DIRTY_PROG)) @@ -262,6 +266,8 @@ fd2_program_validate(struct fd_context *ctx) patch_tex_fetches(ctx, prog->vp, &ctx->verttex); patch_tex_fetches(ctx, prog->fp, &ctx->fragtex); } + + return true; } void diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_program.h b/src/gallium/drivers/freedreno/a2xx/fd2_program.h index 170b22a..935661c 100644 --- a/src/gallium/drivers/freedreno/a2xx/fd2_program.h +++ b/src/gallium/drivers/freedreno/a2xx/fd2_program.h @@ -74,7 +74,7 @@ struct fd2_shader_stateobj { void fd2_program_emit(struct fd_ringbuffer *ring, struct fd_program_stateobj *prog); -void fd2_program_validate(struct fd_context *ctx); +bool fd2_program_validate(struct fd_context *ctx); void fd2_prog_init(struct pipe_context *pctx); -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v1 1/4] freedreno/a2xx: Check for fd2_emit_state to failures.
From: Robert Foss Make sure that fd2_emit_state does not fail. If it does fail, some of shader data structes may be de-allocated. coverity: 1362467 Signed-off-by: Robert Foss --- src/gallium/drivers/freedreno/a2xx/fd2_draw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_draw.c b/src/gallium/drivers/freedreno/a2xx/fd2_draw.c index 14620ac..df5cf77 100644 --- a/src/gallium/drivers/freedreno/a2xx/fd2_draw.c +++ b/src/gallium/drivers/freedreno/a2xx/fd2_draw.c @@ -87,7 +87,8 @@ fd2_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *info) if (ctx->dirty & FD_DIRTY_VTXBUF) emit_vertexbufs(ctx); - fd2_emit_state(ctx, ctx->dirty); + if (fd2_emit_state(ctx, ctx->dirty) == false) + return false; OUT_PKT3(ring, CP_SET_CONSTANT, 2); OUT_RING(ring, CP_REG(REG_A2XX_VGT_INDX_OFFSET)); -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v1 2/4] freedreno/a2xx: Check for fd2_program_validate failures.
From: Robert Foss Make sure that fd2_program_validate does not fail. If it does fail, some of shader data structes may be de-allocated. Also fd2_draw_vbo to return booleans to indicate failure. coverity: 1362467 Signed-off-by: Robert Foss --- src/gallium/drivers/freedreno/a2xx/fd2_emit.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_emit.c b/src/gallium/drivers/freedreno/a2xx/fd2_emit.c index 4f667ab..edf0e7e 100644 --- a/src/gallium/drivers/freedreno/a2xx/fd2_emit.c +++ b/src/gallium/drivers/freedreno/a2xx/fd2_emit.c @@ -179,7 +179,7 @@ fd2_emit_vertex_bufs(struct fd_ringbuffer *ring, uint32_t val, } } -void +bool fd2_emit_state(struct fd_context *ctx, uint32_t dirty) { struct fd2_blend_stateobj *blend = fd2_blend_stateobj(ctx->blend); @@ -278,7 +278,8 @@ fd2_emit_state(struct fd_context *ctx, uint32_t dirty) } if (dirty & (FD_DIRTY_PROG | FD_DIRTY_VTXSTATE | FD_DIRTY_TEXSTATE)) { - fd2_program_validate(ctx); + if (fd2_program_validate(ctx) == false) + return false; fd2_program_emit(ring, &ctx->prog); } -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v1 4/4] freedreno/a2xx: Make delete_shader set the ptr to NULL to simplify debugging.
From: Robert Foss Make delete_shader set the fd2_shader_stateobj ptr to NULL, to simplify debugging and finding use after free errors. Signed-off-by: Robert Foss --- src/gallium/drivers/freedreno/a2xx/fd2_program.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_program.c b/src/gallium/drivers/freedreno/a2xx/fd2_program.c index 1819c52..5925f49 100644 --- a/src/gallium/drivers/freedreno/a2xx/fd2_program.c +++ b/src/gallium/drivers/freedreno/a2xx/fd2_program.c @@ -58,6 +58,7 @@ delete_shader(struct fd2_shader_stateobj *so) free(so->tokens); free(so->bin); free(so); + so = NULL; } static struct fd2_shader_stateobj * -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/2] gbm: add API to to import FD with modifier
This patch has been tested on Android on the iMX6. Tested-by: Robert Foss On Thu, 2017-06-08 at 20:56 +0200, Lucas Stach wrote: > This allows to import an FD with an explicit modifier passed through > userspace protocols. > > Signed-off-by: Lucas Stach > --- > src/gbm/main/gbm.h | 12 > 1 file changed, 12 insertions(+) > > diff --git a/src/gbm/main/gbm.h b/src/gbm/main/gbm.h > index b52137ed01d4..6a9bf1fc2a80 100644 > --- a/src/gbm/main/gbm.h > +++ b/src/gbm/main/gbm.h > @@ -252,6 +252,7 @@ gbm_bo_create_with_modifiers(struct gbm_device > *gbm, > #define GBM_BO_IMPORT_WL_BUFFER 0x5501 > #define GBM_BO_IMPORT_EGL_IMAGE 0x5502 > #define GBM_BO_IMPORT_FD0x5503 > +#define GBM_BO_IMPORT_FD_MODIFIER 0x5504 > > struct gbm_import_fd_data { > int fd; > @@ -261,6 +262,17 @@ struct gbm_import_fd_data { > uint32_t format; > }; > > +struct gbm_import_fd_modifier_data { > + uint32_t width; > + uint32_t height; > + uint32_t format; > + uint32_t num_fds; > + int fds[4]; > + int strides[4]; > + int offsets[4]; > + uint64_t modifier; > +}; > + > struct gbm_bo * > gbm_bo_import(struct gbm_device *gbm, uint32_t type, > void *buffer, uint32_t usage); ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/2] gbm: implement FD import with modifier
This patch has been tested on Android on the iMX6. Tested-by: Robert Foss On Thu, 2017-06-08 at 20:56 +0200, Lucas Stach wrote: > This implements a way to import FDs with modifiers on plain GBM > devices, > without the need to go through EGL. This is mostly to the benefit of > gbm_gralloc, which can keep its dependencies low. > > Signed-off-by: Lucas Stach > --- > src/gbm/backends/dri/gbm_dri.c | 54 > ++ > 1 file changed, 54 insertions(+) > > diff --git a/src/gbm/backends/dri/gbm_dri.c > b/src/gbm/backends/dri/gbm_dri.c > index 7fb569078b27..19be440d48e3 100644 > --- a/src/gbm/backends/dri/gbm_dri.c > +++ b/src/gbm/backends/dri/gbm_dri.c > @@ -932,6 +932,60 @@ gbm_dri_bo_import(struct gbm_device *gbm, > break; > } > > + case GBM_BO_IMPORT_FD_MODIFIER: > + { > + struct gbm_import_fd_modifier_data *fd_data = buffer; > + unsigned int error; > + int fourcc; > + > + /* Import with modifier requires createImageFromDmaBufs2 */ > + if (dri->image == NULL || dri->image->base.version < 15 || > + dri->image->createImageFromDmaBufs2 == NULL) { > + errno = ENOSYS; > + return NULL; > + } > + > + switch(fd_data->format) { > + case GBM_FORMAT_RGB565: > + fourcc = __DRI_IMAGE_FOURCC_RGB565; > + break; > + case GBM_FORMAT_ARGB: > + case GBM_BO_FORMAT_ARGB: > + fourcc = __DRI_IMAGE_FOURCC_ARGB; > + break; > + case GBM_FORMAT_XRGB: > + case GBM_BO_FORMAT_XRGB: > + fourcc = __DRI_IMAGE_FOURCC_XRGB; > + break; > + case GBM_FORMAT_ABGR: > + fourcc = __DRI_IMAGE_FOURCC_ABGR; > + break; > + case GBM_FORMAT_XBGR: > + fourcc = __DRI_IMAGE_FOURCC_XBGR; > + break; > + default: > + errno = EINVAL; > + return NULL; > + } > + > + image = dri->image->createImageFromDmaBufs2(dri->screen, > fd_data->width, > + fd_data->height, > fourcc, > + fd_data->modifier, > + fd_data->fds, > + fd_data->num_fds, > + fd_data->strides, > + fd_data->offsets, > + 0, 0, 0, 0, > + &error, NULL); > + if (image == NULL) { > + errno = ENOSYS; > + return NULL; > + } > + > + gbm_format = fd_data->format; > + break; > + } > + > default: > errno = ENOSYS; > return NULL; ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] egl/android: Partially handle HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED
From: Tomasz Figa There is no API available to properly query the IMPLEMENTATION_DEFINED format. As a workaround we rely here on gralloc allocating either an arbitrary YCbCr 4:2:0 or RGBX_, with the latter being recognized by lock_ycbcr failing. Reviewed-on: https://chromium-review.googlesource.com/566793 Signed-off-by: Tomasz Figa Reviewed-by: Chad Versace Signed-off-by: Robert Foss --- src/egl/drivers/dri2/platform_android.c | 39 +++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c index 63223e9a69..ae914d79c1 100644 --- a/src/egl/drivers/dri2/platform_android.c +++ b/src/egl/drivers/dri2/platform_android.c @@ -59,6 +59,10 @@ static const struct droid_yuv_format droid_yuv_formats[] = { { HAL_PIXEL_FORMAT_YCbCr_420_888, 0, 1, __DRI_IMAGE_FOURCC_YUV420 }, { HAL_PIXEL_FORMAT_YCbCr_420_888, 1, 1, __DRI_IMAGE_FOURCC_YVU420 }, { HAL_PIXEL_FORMAT_YV12,1, 1, __DRI_IMAGE_FOURCC_YVU420 }, + /* HACK: See droid_create_image_from_prime_fd() and b/32077885. */ + { HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 0, 2, __DRI_IMAGE_FOURCC_NV12 }, + { HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 0, 1, __DRI_IMAGE_FOURCC_YUV420 }, + { HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 1, 1, __DRI_IMAGE_FOURCC_YVU420 }, }; static int @@ -90,6 +94,11 @@ get_format_bpp(int native) switch (native) { case HAL_PIXEL_FORMAT_RGBA_: + case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED: + /* + * HACK: Hardcode this to RGBX_ as per cros_gralloc hack. + * TODO: Remove this once b/32077885 is fixed. + */ case HAL_PIXEL_FORMAT_RGBX_: case HAL_PIXEL_FORMAT_BGRA_: bpp = 4; @@ -112,6 +121,11 @@ static int get_fourcc(int native) case HAL_PIXEL_FORMAT_RGB_565: return __DRI_IMAGE_FOURCC_RGB565; case HAL_PIXEL_FORMAT_BGRA_: return __DRI_IMAGE_FOURCC_ARGB; case HAL_PIXEL_FORMAT_RGBA_: return __DRI_IMAGE_FOURCC_ABGR; + case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED: + /* + * HACK: Hardcode this to RGBX_ as per cros_gralloc hack. + * TODO: Remove this once b/32077885 is fixed. + */ case HAL_PIXEL_FORMAT_RGBX_: return __DRI_IMAGE_FOURCC_XBGR; default: _eglLog(_EGL_WARNING, "unsupported native buffer format 0x%x", native); @@ -125,6 +139,11 @@ static int get_format(int format) case HAL_PIXEL_FORMAT_BGRA_: return __DRI_IMAGE_FORMAT_ARGB; case HAL_PIXEL_FORMAT_RGB_565: return __DRI_IMAGE_FORMAT_RGB565; case HAL_PIXEL_FORMAT_RGBA_: return __DRI_IMAGE_FORMAT_ABGR; + case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED: + /* + * HACK: Hardcode this to RGBX_ as per cros_gralloc hack. + * TODO: Revert this once b/32077885 is fixed. + */ case HAL_PIXEL_FORMAT_RGBX_: return __DRI_IMAGE_FORMAT_XBGR; default: _eglLog(_EGL_WARNING, "unsupported native buffer format 0x%x", format); @@ -678,6 +697,10 @@ droid_create_image_from_prime_fd_yuv(_EGLDisplay *disp, _EGLContext *ctx, ret = dri2_dpy->gralloc->lock_ycbcr(dri2_dpy->gralloc, buf->handle, 0, 0, 0, 0, 0, &ycbcr); if (ret) { + /* HACK: See droid_create_image_from_prime_fd() and b/32077885. */ + if (buf->format == HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED) + return NULL; + _eglLog(_EGL_WARNING, "gralloc->lock_ycbcr failed: %d", ret); return NULL; } @@ -757,8 +780,20 @@ droid_create_image_from_prime_fd(_EGLDisplay *disp, _EGLContext *ctx, { unsigned int pitch; - if (is_yuv(buf->format)) - return droid_create_image_from_prime_fd_yuv(disp, ctx, buf, fd); + if (is_yuv(buf->format)) { + _EGLImage *image; + + image = droid_create_image_from_prime_fd_yuv(disp, ctx, buf, fd); + /* + * HACK: b/32077885 + * There is no API available to properly query the IMPLEMENTATION_DEFINED + * format. As a workaround we rely here on gralloc allocating either + * an arbitrary YCbCr 4:2:0 or RGBX_, with the latter being recognized + * by lock_ycbcr failing. + */ + if (image || buf->format != HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED) + return image; + } const int fourcc = get_fourcc(buf->format); if (fourcc == -1) { -- 2.14.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] egl/android: Partially handle HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED
Hey Rob, On Mon, 2017-11-27 at 13:42 -0600, Rob Herring wrote: > On Mon, Nov 27, 2017 at 8:14 AM, Robert Foss om> wrote: > > From: Tomasz Figa > > > > There is no API available to properly query the > > IMPLEMENTATION_DEFINED > > format. As a workaround we rely here on gralloc allocating either > > an arbitrary YCbCr 4:2:0 or RGBX_, with the latter being > > recognized > > by lock_ycbcr failing. > > > > Reviewed-on: https://chromium-review.googlesource.com/566793 > > > > Signed-off-by: Tomasz Figa > > Reviewed-by: Chad Versace > > Signed-off-by: Robert Foss > > --- > > src/egl/drivers/dri2/platform_android.c | 39 > > +++-- > > 1 file changed, 37 insertions(+), 2 deletions(-) > > > > diff --git a/src/egl/drivers/dri2/platform_android.c > > b/src/egl/drivers/dri2/platform_android.c > > index 63223e9a69..ae914d79c1 100644 > > --- a/src/egl/drivers/dri2/platform_android.c > > +++ b/src/egl/drivers/dri2/platform_android.c > > @@ -59,6 +59,10 @@ static const struct droid_yuv_format > > droid_yuv_formats[] = { > > { HAL_PIXEL_FORMAT_YCbCr_420_888, 0, 1, > > __DRI_IMAGE_FOURCC_YUV420 }, > > { HAL_PIXEL_FORMAT_YCbCr_420_888, 1, 1, > > __DRI_IMAGE_FOURCC_YVU420 }, > > { HAL_PIXEL_FORMAT_YV12,1, 1, > > __DRI_IMAGE_FOURCC_YVU420 }, > > + /* HACK: See droid_create_image_from_prime_fd() and b/32077885. > > */ > > + { HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 0, 2, > > __DRI_IMAGE_FOURCC_NV12 }, > > + { HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 0, 1, > > __DRI_IMAGE_FOURCC_YUV420 }, > > + { HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 1, 1, > > __DRI_IMAGE_FOURCC_YVU420 }, > > }; > > > > static int > > @@ -90,6 +94,11 @@ get_format_bpp(int native) > > > > switch (native) { > > case HAL_PIXEL_FORMAT_RGBA_: > > + case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED: > > + /* > > + * HACK: Hardcode this to RGBX_ as per cros_gralloc > > hack. > > Does this work with other grallocs? Not necessarily, it is implementation specific. The implementation specific part is lock_ycbcr() failing for non YUV formats, which allows the application to disambiguate between YCbCr 4:2:0 or RGBX_. > > > + * TODO: Remove this once b/32077885 is fixed. > > Is that a public bug? A full url would be better if so. Unfortunately it isn't, I maintained the link since it is better than nothing. And to be clear, I don't have access to that URL either at this moment. Rob. signature.asc Description: This is a digitally signed message part ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] egl/android: Partially handle HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED
Hey, On Tue, 2017-11-28 at 11:49 +, Emil Velikov wrote: > On 28 November 2017 at 10:45, Tapani Pälli > wrote: > > Hi; > > > > > > On 11/27/2017 04:14 PM, Robert Foss wrote: > > > > > > From: Tomasz Figa > > > > > > There is no API available to properly query the > > > IMPLEMENTATION_DEFINED > > > format. As a workaround we rely here on gralloc allocating either > > > an arbitrary YCbCr 4:2:0 or RGBX_, with the latter being > > > recognized > > > by lock_ycbcr failing. > > > > > > Reviewed-on: https://chromium-review.googlesource.com/566793 > > > > > > Signed-off-by: Tomasz Figa > > > Reviewed-by: Chad Versace > > > Signed-off-by: Robert Foss > > > --- > > > src/egl/drivers/dri2/platform_android.c | 39 > > > +++-- > > > 1 file changed, 37 insertions(+), 2 deletions(-) > > > > > > diff --git a/src/egl/drivers/dri2/platform_android.c > > > b/src/egl/drivers/dri2/platform_android.c > > > index 63223e9a69..ae914d79c1 100644 > > > --- a/src/egl/drivers/dri2/platform_android.c > > > +++ b/src/egl/drivers/dri2/platform_android.c > > > @@ -59,6 +59,10 @@ static const struct droid_yuv_format > > > droid_yuv_formats[] = { > > > { HAL_PIXEL_FORMAT_YCbCr_420_888, 0, 1, > > > __DRI_IMAGE_FOURCC_YUV420 > > > }, > > > { HAL_PIXEL_FORMAT_YCbCr_420_888, 1, 1, > > > __DRI_IMAGE_FOURCC_YVU420 > > > }, > > > { HAL_PIXEL_FORMAT_YV12,1, 1, > > > __DRI_IMAGE_FOURCC_YVU420 > > > }, > > > + /* HACK: See droid_create_image_from_prime_fd() and > > > b/32077885. */ > > > + { HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 0, 2, > > > __DRI_IMAGE_FOURCC_NV12 }, > > > + { HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 0, 1, > > > __DRI_IMAGE_FOURCC_YUV420 }, > > > + { HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 1, 1, > > > __DRI_IMAGE_FOURCC_YVU420 }, > > > > > > One alternative way would be to ask gralloc about these formats. On > > gralloc0 > > this would need a perform() hook and gralloc1 has getFormat(). This > > is how > > it is done currently on Android-IA, see following commits: > > > > https://github.com/intel/external-mesa/commit/deb323eafa321c725805a > > 702ed19cb4983346b60 > > > > https://github.com/intel/external-mesa/commit/7cc01beaf540e29862853 > > 561ef93c6c4e86c4c1a > > > > Do you think this approach would work with Chromium as well? > > > > i think the Android-IA approach looks good, although it depends on > local gralloc0 changes. With gralloc1 on the horizon, I don't know > how > much sense it makes to extend the predecessor. > AFAICT the patch should not cause any issues and it's nicely > documented. I had a look at the chromiumos/minigbm implementation, and it does not contain a gralloc1 implementation as far as I can see. I assume that it is available somewhere, but maybe not on a public branch. Would it be possible to make the minigbm gralloc1 impl. public? That way I could submit a patch mirroring what intel/minigbm does. If you fine folks as at Google prefer to roll it yourselves, just give me a poke. Those are the two options I'm seeing. As for gralloc0 support, would it be needed? > > Perhaps someone from the Google/CrOS team can assist in making the > bug > public, although even then it might be better to focus on a 'perfect' > gralloc1? > > IMHO the patch looks perfectly reasonable and we could merge it even, > if we were to switch to gralloc1 in the not too distant future ;-) Maybe doing both is reasonable. signature.asc Description: This is a digitally signed message part ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] egl/android: Partially handle HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED
On Thu, 2017-11-30 at 11:14 -0600, Rob Herring wrote: > On Thu, Nov 30, 2017 at 12:11 AM, Tapani Pälli m> wrote: > > > > > > On 11/30/2017 06:13 AM, Tomasz Figa wrote: > > > > > > On Thu, Nov 30, 2017 at 3:43 AM, Robert Foss > > ra.com> > > > wrote: > > > > > > > > Hey, > > > > > > > > On Tue, 2017-11-28 at 11:49 +, Emil Velikov wrote: > > > > > > > > > > On 28 November 2017 at 10:45, Tapani Pälli > > > > l.com> > > > > > wrote: > > > > > > > > > > > > Hi; > > > > > > > > > > > > > > > > > > On 11/27/2017 04:14 PM, Robert Foss wrote: > > > > > > > > > > > > > > > > > > > > > From: Tomasz Figa > > > > > > > > > > > > > > There is no API available to properly query the > > > > > > > IMPLEMENTATION_DEFINED > > > > > > > format. As a workaround we rely here on gralloc > > > > > > > allocating either > > > > > > > an arbitrary YCbCr 4:2:0 or RGBX_, with the latter > > > > > > > being > > > > > > > recognized > > > > > > > by lock_ycbcr failing. > > > > > > > > > > > > > > Reviewed-on: https://chromium-review.googlesource.com/566 > > > > > > > 793 > > > > > > > > > > > > > > Signed-off-by: Tomasz Figa > > > > > > > Reviewed-by: Chad Versace > > > > > > > Signed-off-by: Robert Foss > > > > > > > --- > > > > > > >src/egl/drivers/dri2/platform_android.c | 39 > > > > > > > +++-- > > > > > > >1 file changed, 37 insertions(+), 2 deletions(-) > > > > > > > > > > > > > > diff --git a/src/egl/drivers/dri2/platform_android.c > > > > > > > b/src/egl/drivers/dri2/platform_android.c > > > > > > > index 63223e9a69..ae914d79c1 100644 > > > > > > > --- a/src/egl/drivers/dri2/platform_android.c > > > > > > > +++ b/src/egl/drivers/dri2/platform_android.c > > > > > > > @@ -59,6 +59,10 @@ static const struct droid_yuv_format > > > > > > > droid_yuv_formats[] = { > > > > > > > { HAL_PIXEL_FORMAT_YCbCr_420_888, 0, 1, > > > > > > > __DRI_IMAGE_FOURCC_YUV420 > > > > > > > }, > > > > > > > { HAL_PIXEL_FORMAT_YCbCr_420_888, 1, 1, > > > > > > > __DRI_IMAGE_FOURCC_YVU420 > > > > > > > }, > > > > > > > { HAL_PIXEL_FORMAT_YV12,1, 1, > > > > > > > __DRI_IMAGE_FOURCC_YVU420 > > > > > > > }, > > > > > > > + /* HACK: See droid_create_image_from_prime_fd() and > > > > > > > b/32077885. */ > > > > > > > + { HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 0, 2, > > > > > > > __DRI_IMAGE_FOURCC_NV12 }, > > > > > > > + { HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 0, 1, > > > > > > > __DRI_IMAGE_FOURCC_YUV420 }, > > > > > > > + { HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 1, 1, > > > > > > > __DRI_IMAGE_FOURCC_YVU420 }, > > > > > > > > > > > > > > > > > > > > > > > > One alternative way would be to ask gralloc about these > > > > > > formats. On > > > > > > gralloc0 > > > > > > this would need a perform() hook and gralloc1 has > > > > > > getFormat(). This > > > > > > is how > > > > > > it is done currently on Android-IA, see following commits: > > > > > > > > > > > > https://github.com/intel/external-mesa/commit/deb323eafa321 > > > > > > c725805a > > > > > > 702ed19cb4983346b60 > > > > > > > > > > > > https://github.com/intel/external-mesa/commit/7cc01beaf540e > > > > > > 29862853 > > > > > > 561ef93c6c4e86c4c1a > > > > > > > > > > > > Do you think this approach would work with Chromium as > > > > > > well? &
[Mesa-dev] [PATCH v2] egl/android: Partially handle HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED
From: Tomasz Figa There is no API available to properly query the IMPLEMENTATION_DEFINED format. As a workaround we rely here on gralloc allocating either an arbitrary YCbCr 4:2:0 or RGBX_, with the latter being recognized by lock_ycbcr failing. Reviewed-on: https://chromium-review.googlesource.com/566793 Signed-off-by: Tomasz Figa Reviewed-by: Chad Versace Signed-off-by: Robert Foss --- Changes since v1: - Replaced bug id with full link src/egl/drivers/dri2/platform_android.c | 41 +++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c index 63223e9a69..2320fb6f21 100644 --- a/src/egl/drivers/dri2/platform_android.c +++ b/src/egl/drivers/dri2/platform_android.c @@ -59,6 +59,11 @@ static const struct droid_yuv_format droid_yuv_formats[] = { { HAL_PIXEL_FORMAT_YCbCr_420_888, 0, 1, __DRI_IMAGE_FOURCC_YUV420 }, { HAL_PIXEL_FORMAT_YCbCr_420_888, 1, 1, __DRI_IMAGE_FOURCC_YVU420 }, { HAL_PIXEL_FORMAT_YV12,1, 1, __DRI_IMAGE_FOURCC_YVU420 }, + /* HACK: See droid_create_image_from_prime_fd() and +* https://issuetracker.google.com/32077885. */ + { HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 0, 2, __DRI_IMAGE_FOURCC_NV12 }, + { HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 0, 1, __DRI_IMAGE_FOURCC_YUV420 }, + { HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 1, 1, __DRI_IMAGE_FOURCC_YVU420 }, }; static int @@ -90,6 +95,11 @@ get_format_bpp(int native) switch (native) { case HAL_PIXEL_FORMAT_RGBA_: + case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED: + /* + * HACK: Hardcode this to RGBX_ as per cros_gralloc hack. + * TODO: Remove this once https://issuetracker.google.com/32077885 is fixed. + */ case HAL_PIXEL_FORMAT_RGBX_: case HAL_PIXEL_FORMAT_BGRA_: bpp = 4; @@ -112,6 +122,11 @@ static int get_fourcc(int native) case HAL_PIXEL_FORMAT_RGB_565: return __DRI_IMAGE_FOURCC_RGB565; case HAL_PIXEL_FORMAT_BGRA_: return __DRI_IMAGE_FOURCC_ARGB; case HAL_PIXEL_FORMAT_RGBA_: return __DRI_IMAGE_FOURCC_ABGR; + case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED: + /* + * HACK: Hardcode this to RGBX_ as per cros_gralloc hack. + * TODO: Remove this once https://issuetracker.google.com/32077885 is fixed. + */ case HAL_PIXEL_FORMAT_RGBX_: return __DRI_IMAGE_FOURCC_XBGR; default: _eglLog(_EGL_WARNING, "unsupported native buffer format 0x%x", native); @@ -125,6 +140,11 @@ static int get_format(int format) case HAL_PIXEL_FORMAT_BGRA_: return __DRI_IMAGE_FORMAT_ARGB; case HAL_PIXEL_FORMAT_RGB_565: return __DRI_IMAGE_FORMAT_RGB565; case HAL_PIXEL_FORMAT_RGBA_: return __DRI_IMAGE_FORMAT_ABGR; + case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED: + /* + * HACK: Hardcode this to RGBX_ as per cros_gralloc hack. + * TODO: Revert this once https://issuetracker.google.com/32077885 is fixed. + */ case HAL_PIXEL_FORMAT_RGBX_: return __DRI_IMAGE_FORMAT_XBGR; default: _eglLog(_EGL_WARNING, "unsupported native buffer format 0x%x", format); @@ -678,6 +698,11 @@ droid_create_image_from_prime_fd_yuv(_EGLDisplay *disp, _EGLContext *ctx, ret = dri2_dpy->gralloc->lock_ycbcr(dri2_dpy->gralloc, buf->handle, 0, 0, 0, 0, 0, &ycbcr); if (ret) { + /* HACK: See droid_create_image_from_prime_fd() and + * https://issuetracker.google.com/32077885.*/ + if (buf->format == HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED) + return NULL; + _eglLog(_EGL_WARNING, "gralloc->lock_ycbcr failed: %d", ret); return NULL; } @@ -757,8 +782,20 @@ droid_create_image_from_prime_fd(_EGLDisplay *disp, _EGLContext *ctx, { unsigned int pitch; - if (is_yuv(buf->format)) - return droid_create_image_from_prime_fd_yuv(disp, ctx, buf, fd); + if (is_yuv(buf->format)) { + _EGLImage *image; + + image = droid_create_image_from_prime_fd_yuv(disp, ctx, buf, fd); + /* + * HACK: https://issuetracker.google.com/32077885 + * There is no API available to properly query the IMPLEMENTATION_DEFINED + * format. As a workaround we rely here on gralloc allocating either + * an arbitrary YCbCr 4:2:0 or RGBX_, with the latter being recognized + * by lock_ycbcr failing. + */ + if (image || buf->format != HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED) + return image; + } const int fourcc = get_fourcc(buf->format); if (fourcc == -1) { -- 2.14.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] egl/android: Partially handle HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED
On Tue, 2017-12-05 at 18:22 +0900, Tomasz Figa wrote: > On Sat, Dec 2, 2017 at 4:43 AM, Rob Herring wrote: > > On Fri, Dec 1, 2017 at 8:44 AM, Tomasz Figa > > wrote: > > > On Fri, Dec 1, 2017 at 11:20 PM, Rob Herring > > > wrote: > > > > On Fri, Dec 1, 2017 at 7:30 AM, Robert Foss > > > ora.com> wrote: > > > > > On Thu, 2017-11-30 at 11:14 -0600, Rob Herring wrote: > > > > > > On Thu, Nov 30, 2017 at 12:11 AM, Tapani Pälli > > > > > i...@intel.co > > > > > > m> wrote: > > > > > > > > > > > > > > > > > > > > > On 11/30/2017 06:13 AM, Tomasz Figa wrote: > > > > > > > > > > > > > > > > On Thu, Nov 30, 2017 at 3:43 AM, Robert Foss > > > > > > > ss@collabo > > > > > > > > ra.com> > > > > > > > > wrote: > > > > [...] > > > > > > > > > > (As a side note, I had an idea to create a new > > > > > > > > interface, > > > > > > > > standardized > > > > > > > > by Mesa, let's say libdri_android, completely free of > > > > > > > > any > > > > > > > > gralloc-internals. It would have to be exposed > > > > > > > > additionally by > > > > > > > > any > > > > > > > > Android that intends to run Mesa. Given the need to > > > > > > > > deal with 3 > > > > > > > > different gralloc versions already, it could be > > > > > > > > something easier > > > > > > > > to > > > > > > > > manage.) > > > > > > > > > > > > > > > > > > > > > Makes sense, it is a bit messy and we have bit too much > > > > > > > patches on > > > > > > > our tree > > > > > > > because of these differences. > > > > > > > > > > > > Seems overly complicated to me. The information needed is > > > > > > within the > > > > > > ints in the native_handle in most/all implementations. I > > > > > > don't think > > > > > > there's another way to globally store dmabuf metadata > > > > > > unless you have > > > > > > a custom interface in your DRM driver. So standardizing to > > > > > > a common > > > > > > library implies a common handle struct here. I think the > > > > > > options are: > > > > > > > > > > > > - common struct definition (native_handle_t + dmabuf fd(s) > > > > > > + width, > > > > > > height, stride, format, usage, etc.) > > > > > > - common struct plus inline accessor functions > > > > > > - common opaque struct plus accessor library > > > > > > > > > > So these common parts would be much like what currently > > > > > exists in > > > > > minigbm/cros_gralloc_handle.h and > > > > > gbm_gralloc/gralloc_drm_handle.h > > > > > then, but extended with the above suggestions? > > > > > > > > Yes, but which part do you think needs to be extended? > > > > > > > > As we discussed on IRC, I think perhaps we just need to change > > > > the > > > > handle format field in gralloc_drm_handle.h to use fourcc (aka > > > > DRM and > > > > GBM formats) instead of the Android format. I think all the > > > > users just > > > > end up converting it to their own internal format anyway. > > > > > > We keep the handle opaque for consumers and even minigbm > > > dereferences > > > it only when creating/registering the buffer, further using the > > > handle > > > pointer only as a key to internal bookkeeping map. > > > > What you say implies that you don't need any metadata in the > > handle, > > but you do have pretty much all the same data. Whether you > > > > > Relying on the struct itself is not only error prone, as there is > > > no > > > way to check if the struct on gralloc implementation side matches > > > what > > > we expect, but also makes it difficult to change the handle > > > struct at > > > our co
[Mesa-dev] [PATCH v1 2/7] etnaviv: Add return statement to etna_amode so compiler is happy
From: Tomeu Vizoso Signed-off-by: Robert Foss --- src/gallium/drivers/etnaviv/etnaviv_compiler.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c b/src/gallium/drivers/etnaviv/etnaviv_compiler.c index eafb511bb8..8f73113059 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c +++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c @@ -885,6 +885,8 @@ etna_amode(struct tgsi_ind_register indirect) default: assert(!"Invalid swizzle"); } + + return 0; } /* convert destination operand */ -- 2.11.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v1 1/7] egl/android: Fix typ-o
Signed-off-by: Robert Foss --- src/egl/drivers/dri2/platform_android.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c index 7a73419d14..5550f580a8 100644 --- a/src/egl/drivers/dri2/platform_android.c +++ b/src/egl/drivers/dri2/platform_android.c @@ -752,7 +752,7 @@ droid_create_image_from_prime_fd_yuv(_EGLDisplay *disp, _EGLContext *ctx, } if (ycbcr.chroma_step == 2) { - /* Semi-planar Y + CbCr or Y + CbCr format. */ + /* Semi-planar Y + CbCr or Y + CrCb format. */ const EGLint attr_list_2plane[] = { EGL_WIDTH, buf->width, EGL_HEIGHT, buf->height, -- 2.11.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v1 0/7] Android etnaviv and imx support
This series enables etnaviv and imx for the android platform. This is done through updating the Android build scripts. Additionally 4 small fixes are included in the series. Rob Herring (4): gallium: os_process fixes for Android gbm: add XBGR support for dumb buffers android: enable texture-float android: add etnaviv driver build support Robert Foss (1): egl/android: Fix typ-o Tomeu Vizoso (2): etnaviv: Add return statement to etna_amode so compiler is happy android: build imx-drm winsys Android.common.mk | 1 + Android.mk | 6 ++-- src/egl/drivers/dri2/platform_android.c| 2 +- src/gallium/Android.mk | 2 ++ src/gallium/auxiliary/Android.mk | 5 +-- src/gallium/auxiliary/os/os_process.c | 5 +-- src/gallium/auxiliary/renderonly/renderonly.c | 1 + src/gallium/drivers/etnaviv/Android.mk | 47 ++ src/gallium/drivers/etnaviv/etnaviv_compiler.c | 2 ++ src/gallium/winsys/etnaviv/drm/Android.mk | 35 +++ src/gallium/winsys/imx/drm/Android.mk | 40 ++ src/gbm/backends/dri/gbm_dri.c | 2 +- 12 files changed, 140 insertions(+), 8 deletions(-) create mode 100644 src/gallium/drivers/etnaviv/Android.mk create mode 100644 src/gallium/winsys/etnaviv/drm/Android.mk create mode 100644 src/gallium/winsys/imx/drm/Android.mk -- 2.11.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v1 7/7] android: build imx-drm winsys
From: Tomeu Vizoso Signed-off-by: Tomeu Vizoso --- Android.mk| 5 +++-- src/gallium/Android.mk| 1 + src/gallium/winsys/imx/drm/Android.mk | 40 +++ 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 src/gallium/winsys/imx/drm/Android.mk diff --git a/Android.mk b/Android.mk index b4dc8321a6..7622004d2d 100644 --- a/Android.mk +++ b/Android.mk @@ -24,7 +24,7 @@ # BOARD_GPU_DRIVERS should be defined. The valid values are # # classic drivers: i915 i965 -# gallium drivers: swrast freedreno i915g nouveau r300g r600g radeonsi vc4 virgl vmwgfx etnaviv +# gallium drivers: swrast freedreno i915g nouveau r300g r600g radeonsi vc4 virgl vmwgfx etnaviv imx # # The main target is libGLES_mesa. For each classic driver enabled, a DRI # module will also be built. DRI modules will be loaded by libGLES_mesa. @@ -57,7 +57,8 @@ gallium_drivers := \ vmwgfx.HAVE_GALLIUM_VMWGFX \ vc4.HAVE_GALLIUM_VC4 \ virgl.HAVE_GALLIUM_VIRGL \ - etnaviv.HAVE_GALLIUM_ETNAVIV + etnaviv.HAVE_GALLIUM_ETNAVIV \ + imx.HAVE_GALLIUM_IMX ifeq ($(BOARD_GPU_DRIVERS),all) MESA_BUILD_CLASSIC := $(filter HAVE_%, $(subst ., , $(classic_drivers))) diff --git a/src/gallium/Android.mk b/src/gallium/Android.mk index 0280574405..2710831588 100644 --- a/src/gallium/Android.mk +++ b/src/gallium/Android.mk @@ -44,6 +44,7 @@ SUBDIRS += winsys/vc4/drm drivers/vc4 SUBDIRS += winsys/virgl/drm winsys/virgl/vtest drivers/virgl SUBDIRS += winsys/svga/drm drivers/svga SUBDIRS += winsys/etnaviv/drm drivers/etnaviv drivers/renderonly +SUBDIRS += winsys/imx/drm SUBDIRS += state_trackers/dri # sort to eliminate any duplicates diff --git a/src/gallium/winsys/imx/drm/Android.mk b/src/gallium/winsys/imx/drm/Android.mk new file mode 100644 index 00..d4144f34aa --- /dev/null +++ b/src/gallium/winsys/imx/drm/Android.mk @@ -0,0 +1,40 @@ +# Copyright (C) 2016 Linaro, Ltd, Rob Herring +# +# 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 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. + +LOCAL_PATH := $(call my-dir) + +# get C_SOURCES +#include $(LOCAL_PATH)/Makefile.sources + +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := imx_drm_winsys.c + +LOCAL_SHARED_LIBRARIES := libdrm_etnaviv + +LOCAL_MODULE := libmesa_winsys_imx + +include $(GALLIUM_COMMON_MK) +include $(BUILD_STATIC_LIBRARY) + +ifneq ($(HAVE_GALLIUM_FREEDRENO),) +$(eval GALLIUM_LIBS += $(LOCAL_MODULE) libmesa_winsys_freedreno) +$(eval GALLIUM_SHARED_LIBS += $(LOCAL_SHARED_LIBRARIES)) +endif -- 2.11.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v1 4/7] gbm: add XBGR8888 support for dumb buffers
From: Rob Herring Signed-off-by: Rob Herring --- src/gbm/backends/dri/gbm_dri.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c index 19be440d48..58b62ac361 100644 --- a/src/gbm/backends/dri/gbm_dri.c +++ b/src/gbm/backends/dri/gbm_dri.c @@ -1067,7 +1067,7 @@ create_dumb(struct gbm_device *gbm, is_cursor = (usage & GBM_BO_USE_CURSOR) != 0 && format == GBM_FORMAT_ARGB; is_scanout = (usage & GBM_BO_USE_SCANOUT) != 0 && - format == GBM_FORMAT_XRGB; + (format == GBM_FORMAT_XRGB || format == GBM_FORMAT_XBGR); if (!is_cursor && !is_scanout) { errno = EINVAL; return NULL; -- 2.11.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v1 5/7] android: enable texture-float
From: Rob Herring This is required by freedreno at least for GLES3 support. See docs/patents.txt for information about turning this on for s/w renderers. Signed-off-by: Rob Herring --- Android.common.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/Android.common.mk b/Android.common.mk index 6bd30816bc..6f93c828b0 100644 --- a/Android.common.mk +++ b/Android.common.mk @@ -67,6 +67,7 @@ LOCAL_CFLAGS += \ -DHAVE_DLOPEN \ -DHAVE_DL_ITERATE_PHDR \ -DMAJOR_IN_SYSMACROS \ + -DTEXTURE_FLOAT_ENABLED \ -fvisibility=hidden \ -Wno-sign-compare -- 2.11.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v1 6/7] android: add etnaviv driver build support
From: Rob Herring Add etnaviv to Android makefiles. Signed-off-by: Rob Herring --- Android.mk| 5 +-- src/gallium/Android.mk| 1 + src/gallium/auxiliary/Android.mk | 5 +-- src/gallium/auxiliary/renderonly/renderonly.c | 1 + src/gallium/drivers/etnaviv/Android.mk| 47 +++ src/gallium/winsys/etnaviv/drm/Android.mk | 35 6 files changed, 90 insertions(+), 4 deletions(-) create mode 100644 src/gallium/drivers/etnaviv/Android.mk create mode 100644 src/gallium/winsys/etnaviv/drm/Android.mk diff --git a/Android.mk b/Android.mk index de37f4600f..b4dc8321a6 100644 --- a/Android.mk +++ b/Android.mk @@ -24,7 +24,7 @@ # BOARD_GPU_DRIVERS should be defined. The valid values are # # classic drivers: i915 i965 -# gallium drivers: swrast freedreno i915g nouveau r300g r600g radeonsi vc4 virgl vmwgfx +# gallium drivers: swrast freedreno i915g nouveau r300g r600g radeonsi vc4 virgl vmwgfx etnaviv # # The main target is libGLES_mesa. For each classic driver enabled, a DRI # module will also be built. DRI modules will be loaded by libGLES_mesa. @@ -56,7 +56,8 @@ gallium_drivers := \ radeonsi.HAVE_GALLIUM_RADEONSI \ vmwgfx.HAVE_GALLIUM_VMWGFX \ vc4.HAVE_GALLIUM_VC4 \ - virgl.HAVE_GALLIUM_VIRGL + virgl.HAVE_GALLIUM_VIRGL \ + etnaviv.HAVE_GALLIUM_ETNAVIV ifeq ($(BOARD_GPU_DRIVERS),all) MESA_BUILD_CLASSIC := $(filter HAVE_%, $(subst ., , $(classic_drivers))) diff --git a/src/gallium/Android.mk b/src/gallium/Android.mk index 0915579127..0280574405 100644 --- a/src/gallium/Android.mk +++ b/src/gallium/Android.mk @@ -43,6 +43,7 @@ SUBDIRS += winsys/radeon/drm winsys/amdgpu/drm drivers/radeonsi drivers/radeon SUBDIRS += winsys/vc4/drm drivers/vc4 SUBDIRS += winsys/virgl/drm winsys/virgl/vtest drivers/virgl SUBDIRS += winsys/svga/drm drivers/svga +SUBDIRS += winsys/etnaviv/drm drivers/etnaviv drivers/renderonly SUBDIRS += state_trackers/dri # sort to eliminate any duplicates diff --git a/src/gallium/auxiliary/Android.mk b/src/gallium/auxiliary/Android.mk index e2a1fc214e..a562774a9a 100644 --- a/src/gallium/auxiliary/Android.mk +++ b/src/gallium/auxiliary/Android.mk @@ -31,7 +31,8 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES := \ $(C_SOURCES) \ $(NIR_SOURCES) \ - $(VL_STUB_SOURCES) + $(VL_STUB_SOURCES) \ + $(RENDERONLY_SOURCES) LOCAL_C_INCLUDES := \ $(GALLIUM_TOP)/auxiliary/util @@ -46,7 +47,7 @@ LOCAL_CPPFLAGS += -std=c++11 # We need libmesa_nir to get NIR's generated include directories. LOCAL_MODULE := libmesa_gallium -LOCAL_STATIC_LIBRARIES += libmesa_nir +LOCAL_STATIC_LIBRARIES += libmesa_nir libmesa_loader LOCAL_WHOLE_STATIC_LIBRARIES += cpufeatures diff --git a/src/gallium/auxiliary/renderonly/renderonly.c b/src/gallium/auxiliary/renderonly/renderonly.c index d3ed214f4e..dda7f4471a 100644 --- a/src/gallium/auxiliary/renderonly/renderonly.c +++ b/src/gallium/auxiliary/renderonly/renderonly.c @@ -35,6 +35,7 @@ #include "pipe/p_screen.h" #include "util/u_inlines.h" #include "util/u_memory.h" +#include "loader.h" struct renderonly * renderonly_dup(const struct renderonly *ro) diff --git a/src/gallium/drivers/etnaviv/Android.mk b/src/gallium/drivers/etnaviv/Android.mk new file mode 100644 index 00..7e9b2ae1b2 --- /dev/null +++ b/src/gallium/drivers/etnaviv/Android.mk @@ -0,0 +1,47 @@ +# Copyright (C) 2016 Linaro, Ltd, Rob Herring +# +# 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 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. + +LOCAL_PATH := $(call my-dir) + +# get C_SOURCES +include $(LOCAL_PATH)/Makefile.sources + +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + $(C_SOURCES) + +LOCAL_C_INCLUDES := \ + $(LOCAL_PATH)/hw + +#LOCAL_GENERATED_SOURCES := $(MESA_GEN_NIR_H) + +LOCAL_SHARED_LIBRARIES := libdrm_etnaviv +#LOCAL_STATIC_LIBRARIES := libmesa_glsl libmesa_nir +LOCAL_MODULE := lib
[Mesa-dev] [PATCH v1 3/7] gallium: os_process fixes for Android
From: Rob Herring Signed-off-by: Rob Herring --- src/gallium/auxiliary/os/os_process.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/os/os_process.c b/src/gallium/auxiliary/os/os_process.c index 6622b9b2bc..af5d22bf84 100644 --- a/src/gallium/auxiliary/os/os_process.c +++ b/src/gallium/auxiliary/os/os_process.c @@ -34,7 +34,7 @@ # include #elif defined(__GLIBC__) || defined(__CYGWIN__) # include -#elif defined(PIPE_OS_BSD) || defined(PIPE_OS_APPLE) +#elif defined(PIPE_OS_BSD) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_ANDROID) # include #elif defined(PIPE_OS_HAIKU) # include @@ -59,6 +59,7 @@ os_get_process_name(char *procname, size_t size) { const char *name; + /* First, check if the GALLIUM_PROCESS_NAME env var is set to * override the normal process name query. */ @@ -86,7 +87,7 @@ os_get_process_name(char *procname, size_t size) #elif defined(__GLIBC__) || defined(__CYGWIN__) name = program_invocation_short_name; -#elif defined(PIPE_OS_BSD) || defined(PIPE_OS_APPLE) +#elif defined(PIPE_OS_BSD) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_ANDROID) /* *BSD and OS X */ name = getprogname(); #elif defined(PIPE_OS_HAIKU) -- 2.11.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 1/5] etnaviv: Add unreachable statement to etna_amode to fix compilation warnings
From: Tomeu Vizoso Signed-off-by: Robert Foss Reviewed-by: Tapani Pälli --- Changes since v1: Emil Velikov - Switch return statement to unreachable call src/gallium/drivers/etnaviv/etnaviv_compiler.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c b/src/gallium/drivers/etnaviv/etnaviv_compiler.c index eafb511bb8..b5396a3f0d 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c +++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c @@ -885,6 +885,8 @@ etna_amode(struct tgsi_ind_register indirect) default: assert(!"Invalid swizzle"); } + + unreachable("bad swizzle"); } /* convert destination operand */ -- 2.11.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 2/5] gallium: os_process fixes for Android
From: Rob Herring The function getprogname() is available on Android, since it reuses various BSD solutions C runtime. Signed-off-by: Rob Herring Reviewed-by: Tapani Pälli Reviewed-by: Emil Velikov --- Changes since v1: Emil Velikov - Added commit msg - Dropped whitepace change src/gallium/auxiliary/os/os_process.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/os/os_process.c b/src/gallium/auxiliary/os/os_process.c index 6622b9b2bc..035bd228e7 100644 --- a/src/gallium/auxiliary/os/os_process.c +++ b/src/gallium/auxiliary/os/os_process.c @@ -34,7 +34,7 @@ # include #elif defined(__GLIBC__) || defined(__CYGWIN__) # include -#elif defined(PIPE_OS_BSD) || defined(PIPE_OS_APPLE) +#elif defined(PIPE_OS_BSD) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_ANDROID) # include #elif defined(PIPE_OS_HAIKU) # include @@ -86,7 +86,7 @@ os_get_process_name(char *procname, size_t size) #elif defined(__GLIBC__) || defined(__CYGWIN__) name = program_invocation_short_name; -#elif defined(PIPE_OS_BSD) || defined(PIPE_OS_APPLE) +#elif defined(PIPE_OS_BSD) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_ANDROID) /* *BSD and OS X */ name = getprogname(); #elif defined(PIPE_OS_HAIKU) -- 2.11.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 1/5] etnaviv: Add unreachable statement to etna_amode to fix compilation warnings
From: Tomeu Vizoso Signed-off-by: Robert Foss Reviewed-by: Tapani Pälli --- Changes since v1: Emil Velikov - Replaced return with unreachable call src/gallium/drivers/etnaviv/etnaviv_compiler.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c b/src/gallium/drivers/etnaviv/etnaviv_compiler.c index eafb511bb8..b5396a3f0d 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c +++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c @@ -885,6 +885,8 @@ etna_amode(struct tgsi_ind_register indirect) default: assert(!"Invalid swizzle"); } + + unreachable("bad swizzle"); } /* convert destination operand */ -- 2.11.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 0/5] Android etnaviv and imx support
This series enables etnaviv and imx for the android platform. This is done through updating the Android build scripts. Rob Herring (3): gallium: os_process fixes for Android gbm: add XBGR support for dumb buffers android: add etnaviv driver build support Tomeu Vizoso (2): etnaviv: Add unreachable statement to etna_amode to fix compilation warnings android: build imx-drm winsys Android.mk | 6 ++-- src/gallium/Android.mk | 2 ++ src/gallium/auxiliary/Android.mk | 3 +- src/gallium/auxiliary/os/os_process.c | 4 +-- src/gallium/drivers/etnaviv/Android.mk | 40 ++ src/gallium/drivers/etnaviv/etnaviv_compiler.c | 2 ++ src/gallium/winsys/etnaviv/drm/Android.mk | 33 + src/gallium/winsys/imx/drm/Android.mk | 39 + src/gbm/backends/dri/gbm_dri.c | 2 +- 9 files changed, 125 insertions(+), 6 deletions(-) create mode 100644 src/gallium/drivers/etnaviv/Android.mk create mode 100644 src/gallium/winsys/etnaviv/drm/Android.mk create mode 100644 src/gallium/winsys/imx/drm/Android.mk -- 2.11.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 3/5] gbm: add XBGR8888 support for dumb buffers
From: Rob Herring Add GBM_FORMAT_XBGR format support which is needed for Android. Signed-off-by: Rob Herring Reviewed-by: Tapani Pälli Reviewed-by: Daniel Stone Reviewed-by: Emil Velikov --- Changes since v1: Emil Velikov - Added commit msg src/gbm/backends/dri/gbm_dri.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c index 19be440d48..58b62ac361 100644 --- a/src/gbm/backends/dri/gbm_dri.c +++ b/src/gbm/backends/dri/gbm_dri.c @@ -1067,7 +1067,7 @@ create_dumb(struct gbm_device *gbm, is_cursor = (usage & GBM_BO_USE_CURSOR) != 0 && format == GBM_FORMAT_ARGB; is_scanout = (usage & GBM_BO_USE_SCANOUT) != 0 && - format == GBM_FORMAT_XRGB; + (format == GBM_FORMAT_XRGB || format == GBM_FORMAT_XBGR); if (!is_cursor && !is_scanout) { errno = EINVAL; return NULL; -- 2.11.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 4/5] android: add etnaviv driver build support
From: Rob Herring Add etnaviv to Android makefiles. Signed-off-by: Rob Herring Reviewed-by: Tapani Pälli --- Changes since v1: Tapani Pälli - Remove copy-pasta Emil Velikov - Remove libmesa_loader inclusion - Remove copy-pasta - Remove spurious include - Fix C_SOURCES include Android.mk| 5 ++-- src/gallium/Android.mk| 1 + src/gallium/auxiliary/Android.mk | 3 ++- src/gallium/drivers/etnaviv/Android.mk| 40 +++ src/gallium/winsys/etnaviv/drm/Android.mk | 33 + 5 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 src/gallium/drivers/etnaviv/Android.mk create mode 100644 src/gallium/winsys/etnaviv/drm/Android.mk diff --git a/Android.mk b/Android.mk index 418570e607..2118405e1a 100644 --- a/Android.mk +++ b/Android.mk @@ -24,7 +24,7 @@ # BOARD_GPU_DRIVERS should be defined. The valid values are # # classic drivers: i915 i965 -# gallium drivers: swrast freedreno i915g nouveau pl111 r300g r600g radeonsi vc4 virgl vmwgfx +# gallium drivers: swrast freedreno i915g nouveau pl111 r300g r600g radeonsi vc4 virgl vmwgfx etnaviv # # The main target is libGLES_mesa. For each classic driver enabled, a DRI # module will also be built. DRI modules will be loaded by libGLES_mesa. @@ -57,7 +57,8 @@ gallium_drivers := \ radeonsi.HAVE_GALLIUM_RADEONSI \ vmwgfx.HAVE_GALLIUM_VMWGFX \ vc4.HAVE_GALLIUM_VC4 \ - virgl.HAVE_GALLIUM_VIRGL + virgl.HAVE_GALLIUM_VIRGL \ + etnaviv.HAVE_GALLIUM_ETNAVIV ifeq ($(BOARD_GPU_DRIVERS),all) MESA_BUILD_CLASSIC := $(filter HAVE_%, $(subst ., , $(classic_drivers))) diff --git a/src/gallium/Android.mk b/src/gallium/Android.mk index 451bba4d17..dc98fa00ed 100644 --- a/src/gallium/Android.mk +++ b/src/gallium/Android.mk @@ -44,6 +44,7 @@ SUBDIRS += winsys/radeon/drm winsys/amdgpu/drm drivers/radeonsi drivers/radeon SUBDIRS += winsys/vc4/drm drivers/vc4 SUBDIRS += winsys/virgl/drm winsys/virgl/vtest drivers/virgl SUBDIRS += winsys/svga/drm drivers/svga +SUBDIRS += winsys/etnaviv/drm drivers/etnaviv drivers/renderonly SUBDIRS += state_trackers/dri # sort to eliminate any duplicates diff --git a/src/gallium/auxiliary/Android.mk b/src/gallium/auxiliary/Android.mk index e2a1fc214e..ed4bcc8b71 100644 --- a/src/gallium/auxiliary/Android.mk +++ b/src/gallium/auxiliary/Android.mk @@ -31,7 +31,8 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES := \ $(C_SOURCES) \ $(NIR_SOURCES) \ - $(VL_STUB_SOURCES) + $(VL_STUB_SOURCES) \ + $(RENDERONLY_SOURCES) LOCAL_C_INCLUDES := \ $(GALLIUM_TOP)/auxiliary/util diff --git a/src/gallium/drivers/etnaviv/Android.mk b/src/gallium/drivers/etnaviv/Android.mk new file mode 100644 index 00..a0c55a464b --- /dev/null +++ b/src/gallium/drivers/etnaviv/Android.mk @@ -0,0 +1,40 @@ +# Copyright (C) 2016 Linaro, Ltd, Rob Herring +# +# 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 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. + +LOCAL_PATH := $(call my-dir) + +# get C_SOURCES +include $(LOCAL_PATH)/Makefile.sources + +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + $(C_SOURCES) + +LOCAL_SHARED_LIBRARIES := libdrm_etnaviv +LOCAL_MODULE := libmesa_pipe_etnaviv + +include $(GALLIUM_COMMON_MK) +include $(BUILD_STATIC_LIBRARY) + +ifneq ($(HAVE_GALLIUM_ETNAVIV),) +$(eval GALLIUM_LIBS += $(LOCAL_MODULE) libmesa_winsys_etnaviv) +$(eval GALLIUM_SHARED_LIBS += $(LOCAL_SHARED_LIBRARIES)) +endif diff --git a/src/gallium/winsys/etnaviv/drm/Android.mk b/src/gallium/winsys/etnaviv/drm/Android.mk new file mode 100644 index 00..32091bea0e --- /dev/null +++ b/src/gallium/winsys/etnaviv/drm/Android.mk @@ -0,0 +1,33 @@ +# Copyright (C) 2016 Linaro, Ltd, Rob Herring +# +# 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 r
[Mesa-dev] [PATCH v2 5/5] android: build imx-drm winsys
From: Tomeu Vizoso Signed-off-by: Tomeu Vizoso Reviewed-by: Tapani Pälli --- Changes since v1: Emil Velikov - Fix C_SOURCES include - Fix GALLIUM_LIBS assignment Android.mk| 5 +++-- src/gallium/Android.mk| 1 + src/gallium/winsys/imx/drm/Android.mk | 39 +++ 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 src/gallium/winsys/imx/drm/Android.mk diff --git a/Android.mk b/Android.mk index 2118405e1a..479a975999 100644 --- a/Android.mk +++ b/Android.mk @@ -24,7 +24,7 @@ # BOARD_GPU_DRIVERS should be defined. The valid values are # # classic drivers: i915 i965 -# gallium drivers: swrast freedreno i915g nouveau pl111 r300g r600g radeonsi vc4 virgl vmwgfx etnaviv +# gallium drivers: swrast freedreno i915g nouveau pl111 r300g r600g radeonsi vc4 virgl vmwgfx etnaviv imx # # The main target is libGLES_mesa. For each classic driver enabled, a DRI # module will also be built. DRI modules will be loaded by libGLES_mesa. @@ -58,7 +58,8 @@ gallium_drivers := \ vmwgfx.HAVE_GALLIUM_VMWGFX \ vc4.HAVE_GALLIUM_VC4 \ virgl.HAVE_GALLIUM_VIRGL \ - etnaviv.HAVE_GALLIUM_ETNAVIV + etnaviv.HAVE_GALLIUM_ETNAVIV \ + imx.HAVE_GALLIUM_IMX ifeq ($(BOARD_GPU_DRIVERS),all) MESA_BUILD_CLASSIC := $(filter HAVE_%, $(subst ., , $(classic_drivers))) diff --git a/src/gallium/Android.mk b/src/gallium/Android.mk index dc98fa00ed..8743dd6d26 100644 --- a/src/gallium/Android.mk +++ b/src/gallium/Android.mk @@ -45,6 +45,7 @@ SUBDIRS += winsys/vc4/drm drivers/vc4 SUBDIRS += winsys/virgl/drm winsys/virgl/vtest drivers/virgl SUBDIRS += winsys/svga/drm drivers/svga SUBDIRS += winsys/etnaviv/drm drivers/etnaviv drivers/renderonly +SUBDIRS += winsys/imx/drm SUBDIRS += state_trackers/dri # sort to eliminate any duplicates diff --git a/src/gallium/winsys/imx/drm/Android.mk b/src/gallium/winsys/imx/drm/Android.mk new file mode 100644 index 00..51649f8b87 --- /dev/null +++ b/src/gallium/winsys/imx/drm/Android.mk @@ -0,0 +1,39 @@ +# Copyright (C) 2016 Linaro, Ltd, Rob Herring +# +# 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 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. + +LOCAL_PATH := $(call my-dir) + +include $(LOCAL_PATH)/Makefile.sources + +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := $(C_SOURCES) + +LOCAL_SHARED_LIBRARIES := libdrm_etnaviv + +LOCAL_MODULE := libmesa_winsys_imx + +include $(GALLIUM_COMMON_MK) +include $(BUILD_STATIC_LIBRARY) + +ifneq ($(HAVE_GALLIUM_FREEDRENO),) +$(eval GALLIUM_LIBS += $(LOCAL_MODULE) libmesa_winsys_imx) +$(eval GALLIUM_SHARED_LIBS += $(LOCAL_SHARED_LIBRARIES)) +endif -- 2.11.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 1/5] etnaviv: Add unreachable statement to etna_amode to fix compilation warnings
From: Tomeu Vizoso Signed-off-by: Robert Foss Reviewed-by: Tapani Pälli --- Chages since v2: - Rebased on upstream/master Changes since v1: Emil Velikov - Replaced return with unreachable call src/gallium/drivers/etnaviv/etnaviv_compiler.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c b/src/gallium/drivers/etnaviv/etnaviv_compiler.c index af0f76b586..2e8dd8643a 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c +++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c @@ -885,6 +885,8 @@ etna_amode(struct tgsi_ind_register indirect) default: assert(!"Invalid swizzle"); } + + unreachable("bad swizzle"); } /* convert destination operand */ -- 2.11.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 0/5] Android etnaviv and imx support
This series enables etnaviv and imx for the android platform. This is done through updating the Android build scripts. Rob Herring (3): gallium: os_process fixes for Android gbm: add XBGR support for dumb buffers android: add etnaviv driver build support Tomeu Vizoso (2): etnaviv: Add unreachable statement to etna_amode to fix compilation warnings android: build imx-drm winsys Android.mk | 6 ++-- src/gallium/Android.mk | 2 ++ src/gallium/auxiliary/os/os_process.c | 4 +-- src/gallium/drivers/etnaviv/Android.mk | 40 ++ src/gallium/drivers/etnaviv/etnaviv_compiler.c | 2 ++ src/gallium/winsys/etnaviv/drm/Android.mk | 33 + src/gallium/winsys/imx/drm/Android.mk | 39 + src/gbm/backends/dri/gbm_dri.c | 2 +- 8 files changed, 123 insertions(+), 5 deletions(-) create mode 100644 src/gallium/drivers/etnaviv/Android.mk create mode 100644 src/gallium/winsys/etnaviv/drm/Android.mk create mode 100644 src/gallium/winsys/imx/drm/Android.mk -- 2.11.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 3/5] gbm: add XBGR8888 support for dumb buffers
From: Rob Herring Add GBM_FORMAT_XBGR format support which is needed for Android. Signed-off-by: Rob Herring Reviewed-by: Tapani Pälli Reviewed-by: Daniel Stone Reviewed-by: Emil Velikov --- Changes since v2: - Rebased on upstream/master Changes since v1: Emil Velikov - Added commit msg src/gbm/backends/dri/gbm_dri.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c index 19be440d48..58b62ac361 100644 --- a/src/gbm/backends/dri/gbm_dri.c +++ b/src/gbm/backends/dri/gbm_dri.c @@ -1067,7 +1067,7 @@ create_dumb(struct gbm_device *gbm, is_cursor = (usage & GBM_BO_USE_CURSOR) != 0 && format == GBM_FORMAT_ARGB; is_scanout = (usage & GBM_BO_USE_SCANOUT) != 0 && - format == GBM_FORMAT_XRGB; + (format == GBM_FORMAT_XRGB || format == GBM_FORMAT_XBGR); if (!is_cursor && !is_scanout) { errno = EINVAL; return NULL; -- 2.11.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 2/5] gallium: os_process fixes for Android
From: Rob Herring The function getprogname() is available on Android, since it reuses various BSD solutions C runtime. Signed-off-by: Rob Herring Reviewed-by: Tapani Pälli Reviewed-by: Emil Velikov --- Changes since v2: - Rebased on upstream/master Changes since v1: Emil Velikov - Added commit msg - Dropped whitepace change src/gallium/auxiliary/os/os_process.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/os/os_process.c b/src/gallium/auxiliary/os/os_process.c index 6622b9b2bc..035bd228e7 100644 --- a/src/gallium/auxiliary/os/os_process.c +++ b/src/gallium/auxiliary/os/os_process.c @@ -34,7 +34,7 @@ # include #elif defined(__GLIBC__) || defined(__CYGWIN__) # include -#elif defined(PIPE_OS_BSD) || defined(PIPE_OS_APPLE) +#elif defined(PIPE_OS_BSD) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_ANDROID) # include #elif defined(PIPE_OS_HAIKU) # include @@ -86,7 +86,7 @@ os_get_process_name(char *procname, size_t size) #elif defined(__GLIBC__) || defined(__CYGWIN__) name = program_invocation_short_name; -#elif defined(PIPE_OS_BSD) || defined(PIPE_OS_APPLE) +#elif defined(PIPE_OS_BSD) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_ANDROID) /* *BSD and OS X */ name = getprogname(); #elif defined(PIPE_OS_HAIKU) -- 2.11.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 4/5] android: add etnaviv driver build support
From: Rob Herring Add etnaviv to Android makefiles. Signed-off-by: Rob Herring Reviewed-by: Tapani Pälli --- Changes since v2: - Rebased on upstream/master Changes since v1: Tapani Pälli - Remove copy-pasta Emil Velikov - Remove libmesa_loader inclusion - Remove copy-pasta - Remove spurious include - Fix C_SOURCES include Android.mk| 5 ++-- src/gallium/Android.mk| 1 + src/gallium/drivers/etnaviv/Android.mk| 40 +++ src/gallium/winsys/etnaviv/drm/Android.mk | 33 + 4 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 src/gallium/drivers/etnaviv/Android.mk create mode 100644 src/gallium/winsys/etnaviv/drm/Android.mk diff --git a/Android.mk b/Android.mk index 418570e607..2118405e1a 100644 --- a/Android.mk +++ b/Android.mk @@ -24,7 +24,7 @@ # BOARD_GPU_DRIVERS should be defined. The valid values are # # classic drivers: i915 i965 -# gallium drivers: swrast freedreno i915g nouveau pl111 r300g r600g radeonsi vc4 virgl vmwgfx +# gallium drivers: swrast freedreno i915g nouveau pl111 r300g r600g radeonsi vc4 virgl vmwgfx etnaviv # # The main target is libGLES_mesa. For each classic driver enabled, a DRI # module will also be built. DRI modules will be loaded by libGLES_mesa. @@ -57,7 +57,8 @@ gallium_drivers := \ radeonsi.HAVE_GALLIUM_RADEONSI \ vmwgfx.HAVE_GALLIUM_VMWGFX \ vc4.HAVE_GALLIUM_VC4 \ - virgl.HAVE_GALLIUM_VIRGL + virgl.HAVE_GALLIUM_VIRGL \ + etnaviv.HAVE_GALLIUM_ETNAVIV ifeq ($(BOARD_GPU_DRIVERS),all) MESA_BUILD_CLASSIC := $(filter HAVE_%, $(subst ., , $(classic_drivers))) diff --git a/src/gallium/Android.mk b/src/gallium/Android.mk index 451bba4d17..dc98fa00ed 100644 --- a/src/gallium/Android.mk +++ b/src/gallium/Android.mk @@ -44,6 +44,7 @@ SUBDIRS += winsys/radeon/drm winsys/amdgpu/drm drivers/radeonsi drivers/radeon SUBDIRS += winsys/vc4/drm drivers/vc4 SUBDIRS += winsys/virgl/drm winsys/virgl/vtest drivers/virgl SUBDIRS += winsys/svga/drm drivers/svga +SUBDIRS += winsys/etnaviv/drm drivers/etnaviv drivers/renderonly SUBDIRS += state_trackers/dri # sort to eliminate any duplicates diff --git a/src/gallium/drivers/etnaviv/Android.mk b/src/gallium/drivers/etnaviv/Android.mk new file mode 100644 index 00..a0c55a464b --- /dev/null +++ b/src/gallium/drivers/etnaviv/Android.mk @@ -0,0 +1,40 @@ +# Copyright (C) 2016 Linaro, Ltd, Rob Herring +# +# 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 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. + +LOCAL_PATH := $(call my-dir) + +# get C_SOURCES +include $(LOCAL_PATH)/Makefile.sources + +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + $(C_SOURCES) + +LOCAL_SHARED_LIBRARIES := libdrm_etnaviv +LOCAL_MODULE := libmesa_pipe_etnaviv + +include $(GALLIUM_COMMON_MK) +include $(BUILD_STATIC_LIBRARY) + +ifneq ($(HAVE_GALLIUM_ETNAVIV),) +$(eval GALLIUM_LIBS += $(LOCAL_MODULE) libmesa_winsys_etnaviv) +$(eval GALLIUM_SHARED_LIBS += $(LOCAL_SHARED_LIBRARIES)) +endif diff --git a/src/gallium/winsys/etnaviv/drm/Android.mk b/src/gallium/winsys/etnaviv/drm/Android.mk new file mode 100644 index 00..32091bea0e --- /dev/null +++ b/src/gallium/winsys/etnaviv/drm/Android.mk @@ -0,0 +1,33 @@ +# Copyright (C) 2016 Linaro, Ltd, Rob Herring +# +# 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 shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY
[Mesa-dev] [PATCH v3 5/5] android: build imx-drm winsys
From: Tomeu Vizoso Add Android.mk for winsys/imx/drm. Signed-off-by: Tomeu Vizoso Reviewed-by: Tapani Pälli --- Changes since v2: - Rebased on upstream/master - Added commit message Changes since v1: Emil Velikov - Fix C_SOURCES include - Fix GALLIUM_LIBS assignment Android.mk| 5 +++-- src/gallium/Android.mk| 1 + src/gallium/winsys/imx/drm/Android.mk | 39 +++ 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 src/gallium/winsys/imx/drm/Android.mk diff --git a/Android.mk b/Android.mk index 2118405e1a..479a975999 100644 --- a/Android.mk +++ b/Android.mk @@ -24,7 +24,7 @@ # BOARD_GPU_DRIVERS should be defined. The valid values are # # classic drivers: i915 i965 -# gallium drivers: swrast freedreno i915g nouveau pl111 r300g r600g radeonsi vc4 virgl vmwgfx etnaviv +# gallium drivers: swrast freedreno i915g nouveau pl111 r300g r600g radeonsi vc4 virgl vmwgfx etnaviv imx # # The main target is libGLES_mesa. For each classic driver enabled, a DRI # module will also be built. DRI modules will be loaded by libGLES_mesa. @@ -58,7 +58,8 @@ gallium_drivers := \ vmwgfx.HAVE_GALLIUM_VMWGFX \ vc4.HAVE_GALLIUM_VC4 \ virgl.HAVE_GALLIUM_VIRGL \ - etnaviv.HAVE_GALLIUM_ETNAVIV + etnaviv.HAVE_GALLIUM_ETNAVIV \ + imx.HAVE_GALLIUM_IMX ifeq ($(BOARD_GPU_DRIVERS),all) MESA_BUILD_CLASSIC := $(filter HAVE_%, $(subst ., , $(classic_drivers))) diff --git a/src/gallium/Android.mk b/src/gallium/Android.mk index dc98fa00ed..8743dd6d26 100644 --- a/src/gallium/Android.mk +++ b/src/gallium/Android.mk @@ -45,6 +45,7 @@ SUBDIRS += winsys/vc4/drm drivers/vc4 SUBDIRS += winsys/virgl/drm winsys/virgl/vtest drivers/virgl SUBDIRS += winsys/svga/drm drivers/svga SUBDIRS += winsys/etnaviv/drm drivers/etnaviv drivers/renderonly +SUBDIRS += winsys/imx/drm SUBDIRS += state_trackers/dri # sort to eliminate any duplicates diff --git a/src/gallium/winsys/imx/drm/Android.mk b/src/gallium/winsys/imx/drm/Android.mk new file mode 100644 index 00..51649f8b87 --- /dev/null +++ b/src/gallium/winsys/imx/drm/Android.mk @@ -0,0 +1,39 @@ +# Copyright (C) 2016 Linaro, Ltd, Rob Herring +# +# 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 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. + +LOCAL_PATH := $(call my-dir) + +include $(LOCAL_PATH)/Makefile.sources + +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := $(C_SOURCES) + +LOCAL_SHARED_LIBRARIES := libdrm_etnaviv + +LOCAL_MODULE := libmesa_winsys_imx + +include $(GALLIUM_COMMON_MK) +include $(BUILD_STATIC_LIBRARY) + +ifneq ($(HAVE_GALLIUM_FREEDRENO),) +$(eval GALLIUM_LIBS += $(LOCAL_MODULE) libmesa_winsys_imx) +$(eval GALLIUM_SHARED_LIBS += $(LOCAL_SHARED_LIBRARIES)) +endif -- 2.11.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v1 3/3] gallium/hud: Prevent buffer overflow in hud_thread_busy_install
Switch to using strncopy to avoid potential overflow of name array in struct hud_graph. Coverity-id: 1413760 Signed-off-by: Robert Foss --- src/gallium/auxiliary/hud/hud_cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/hud/hud_cpu.c b/src/gallium/auxiliary/hud/hud_cpu.c index 468c36207b..ceadccb377 100644 --- a/src/gallium/auxiliary/hud/hud_cpu.c +++ b/src/gallium/auxiliary/hud/hud_cpu.c @@ -288,7 +288,7 @@ hud_thread_busy_install(struct hud_pane *pane, const char *name, bool main) if (!gr) return; - strcpy(gr->name, name); + strcpy(gr->name, name, HUD_GRAPH_NAME_LEN); gr->query_data = CALLOC_STRUCT(thread_info); if (!gr->query_data) { -- 2.11.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v1 1/3] gallium/hud: Add define for struct hud_graph name array
Define the length of the name field of struct hud_graph with HUD_GRAPH_NAME_LEN. Signed-off-by: Robert Foss --- src/gallium/auxiliary/hud/hud_private.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/hud/hud_private.h b/src/gallium/auxiliary/hud/hud_private.h index 2b1717d2c4..3a958d3146 100644 --- a/src/gallium/auxiliary/hud/hud_private.h +++ b/src/gallium/auxiliary/hud/hud_private.h @@ -87,6 +87,7 @@ struct hud_context { bool has_srgb; }; +#define HUD_GRAPH_NAME_LEN 128 struct hud_graph { /* initialized by common code */ struct list_head head; @@ -95,7 +96,7 @@ struct hud_graph { float *vertices; /* ring buffer of vertices */ /* name and query */ - char name[128]; + char name[HUD_GRAPH_NAME_LEN]; void *query_data; void (*begin_query)(struct hud_graph *gr); void (*query_new_value)(struct hud_graph *gr); -- 2.11.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v1 2/3] gallium/hud: Prevent buffer overflow in hud_thread_counter_install
Switch to using strncopy to avoid potential overflow of name array in struct hud_graph. Coverity-id: 1413761 Signed-off-by: Robert Foss --- src/gallium/auxiliary/hud/hud_cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/hud/hud_cpu.c b/src/gallium/auxiliary/hud/hud_cpu.c index 4caaab6977..468c36207b 100644 --- a/src/gallium/auxiliary/hud/hud_cpu.c +++ b/src/gallium/auxiliary/hud/hud_cpu.c @@ -362,7 +362,7 @@ void hud_thread_counter_install(struct hud_pane *pane, const char *name, if (!gr) return; - strcpy(gr->name, name); + strncpy(gr->name, name, HUD_GRAPH_NAME_LEN); gr->query_data = CALLOC_STRUCT(counter_info); if (!gr->query_data) { -- 2.11.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 2/3] gallium/hud: Prevent buffer overflow in hud_thread_counter_install
Switch to using strncopy to avoid potential overflow of name array in struct hud_graph. Coverity-id: 1413761 Signed-off-by: Robert Foss --- src/gallium/auxiliary/hud/hud_cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/hud/hud_cpu.c b/src/gallium/auxiliary/hud/hud_cpu.c index 4caaab6977..468c36207b 100644 --- a/src/gallium/auxiliary/hud/hud_cpu.c +++ b/src/gallium/auxiliary/hud/hud_cpu.c @@ -362,7 +362,7 @@ void hud_thread_counter_install(struct hud_pane *pane, const char *name, if (!gr) return; - strcpy(gr->name, name); + strncpy(gr->name, name, HUD_GRAPH_NAME_LEN); gr->query_data = CALLOC_STRUCT(counter_info); if (!gr->query_data) { -- 2.11.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 1/3] gallium/hud: Add define for struct hud_graph name array
Define the length of the name field of struct hud_graph with HUD_GRAPH_NAME_LEN. Signed-off-by: Robert Foss --- src/gallium/auxiliary/hud/hud_private.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/hud/hud_private.h b/src/gallium/auxiliary/hud/hud_private.h index 2b1717d2c4..3a958d3146 100644 --- a/src/gallium/auxiliary/hud/hud_private.h +++ b/src/gallium/auxiliary/hud/hud_private.h @@ -87,6 +87,7 @@ struct hud_context { bool has_srgb; }; +#define HUD_GRAPH_NAME_LEN 128 struct hud_graph { /* initialized by common code */ struct list_head head; @@ -95,7 +96,7 @@ struct hud_graph { float *vertices; /* ring buffer of vertices */ /* name and query */ - char name[128]; + char name[HUD_GRAPH_NAME_LEN]; void *query_data; void (*begin_query)(struct hud_graph *gr); void (*query_new_value)(struct hud_graph *gr); -- 2.11.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 3/3] gallium/hud: Prevent buffer overflow in hud_thread_busy_install
Switch to using strncopy to avoid potential overflow of name array in struct hud_graph. Coverity-id: 1413760 Signed-off-by: Robert Foss --- Changes since v1: Gustaw Smolarczyk - Fix strcpy -> strncpy typo src/gallium/auxiliary/hud/hud_cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/hud/hud_cpu.c b/src/gallium/auxiliary/hud/hud_cpu.c index 468c36207b..ceadccb377 100644 --- a/src/gallium/auxiliary/hud/hud_cpu.c +++ b/src/gallium/auxiliary/hud/hud_cpu.c @@ -288,7 +288,7 @@ hud_thread_busy_install(struct hud_pane *pane, const char *name, bool main) if (!gr) return; - strcpy(gr->name, name); + strcpy(gr->name, name, HUD_GRAPH_NAME_LEN); gr->query_data = CALLOC_STRUCT(thread_info); if (!gr->query_data) { -- 2.11.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v2 2/3] gallium/hud: Prevent buffer overflow in hud_thread_counter_install
Hey Brian, On Thu, 2017-06-29 at 07:28 -0600, Brian Paul wrote: > On 06/29/2017 07:21 AM, Robert Foss wrote: > > Switch to using strncopy to avoid potential overflow of > > name array in struct hud_graph. > > > > Coverity-id: 1413761 > > > > Signed-off-by: Robert Foss > > --- > > src/gallium/auxiliary/hud/hud_cpu.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/src/gallium/auxiliary/hud/hud_cpu.c > > b/src/gallium/auxiliary/hud/hud_cpu.c > > index 4caaab6977..468c36207b 100644 > > --- a/src/gallium/auxiliary/hud/hud_cpu.c > > +++ b/src/gallium/auxiliary/hud/hud_cpu.c > > @@ -362,7 +362,7 @@ void hud_thread_counter_install(struct hud_pane > > *pane, const char *name, > > if (!gr) > > return; > > > > - strcpy(gr->name, name); > > + strncpy(gr->name, name, HUD_GRAPH_NAME_LEN); > > strncpy() doesn't null terminate the destination if strlen(name) >= > HUD_GRAPH_NAME_LEN > > If you're concerned with overflow, you need to address that too. > > You might looks if we have a gallium util function for strncpy with > null > termination. Ack, I had a look in u_string.h, and util_strncmp does not exists, so I'll add it and use it in v3. > > > Also, the change in patch 3/3 won't compile. You didn't change the > function name. > > > > > gr->query_data = CALLOC_STRUCT(counter_info); > > if (!gr->query_data) { > > > > AFAIC, you could combine all three patches. It's a simple change. Do you mind if I keep the strcpy changes in separate commits since they apply to two separate coverity issues? ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v3 5/5] android: build imx-drm winsys
On Thu, 2017-06-29 at 15:28 +0100, Emil Velikov wrote: > On 28 June 2017 at 22:52, Robert Foss > wrote: > > From: Tomeu Vizoso > > > > Add Android.mk for winsys/imx/drm. > > > > Signed-off-by: Tomeu Vizoso > > Reviewed-by: Tapani Pälli > > --- > > Changes since v2: > > - Rebased on upstream/master > > - Added commit message > > > > Changes since v1: > > Emil Velikov > > - Fix C_SOURCES include > > - Fix GALLIUM_LIBS assignment > > > > Android.mk| 5 +++-- > > src/gallium/Android.mk| 1 + > > src/gallium/winsys/imx/drm/Android.mk | 39 > > +++ > > 3 files changed, 43 insertions(+), 2 deletions(-) > > create mode 100644 src/gallium/winsys/imx/drm/Android.mk > > > > diff --git a/Android.mk b/Android.mk > > index 2118405e1a..479a975999 100644 > > --- a/Android.mk > > +++ b/Android.mk > > @@ -24,7 +24,7 @@ > > # BOARD_GPU_DRIVERS should be defined. The valid values are > > # > > # classic drivers: i915 i965 > > -# gallium drivers: swrast freedreno i915g nouveau pl111 r300g > > r600g radeonsi vc4 virgl vmwgfx etnaviv > > +# gallium drivers: swrast freedreno i915g nouveau pl111 r300g > > r600g radeonsi vc4 virgl vmwgfx etnaviv imx > > # > > # The main target is libGLES_mesa. For each classic driver > > enabled, a DRI > > # module will also be built. DRI modules will be loaded by > > libGLES_mesa. > > @@ -58,7 +58,8 @@ gallium_drivers := \ > > vmwgfx.HAVE_GALLIUM_VMWGFX \ > > vc4.HAVE_GALLIUM_VC4 \ > > virgl.HAVE_GALLIUM_VIRGL \ > > - etnaviv.HAVE_GALLIUM_ETNAVIV > > + etnaviv.HAVE_GALLIUM_ETNAVIV \ > > + imx.HAVE_GALLIUM_IMX > > > > ifeq ($(BOARD_GPU_DRIVERS),all) > > MESA_BUILD_CLASSIC := $(filter HAVE_%, $(subst ., , > > $(classic_drivers))) > > diff --git a/src/gallium/Android.mk b/src/gallium/Android.mk > > index dc98fa00ed..8743dd6d26 100644 > > --- a/src/gallium/Android.mk > > +++ b/src/gallium/Android.mk > > @@ -45,6 +45,7 @@ SUBDIRS += winsys/vc4/drm drivers/vc4 > > SUBDIRS += winsys/virgl/drm winsys/virgl/vtest drivers/virgl > > SUBDIRS += winsys/svga/drm drivers/svga > > SUBDIRS += winsys/etnaviv/drm drivers/etnaviv drivers/renderonly > > +SUBDIRS += winsys/imx/drm > > SUBDIRS += state_trackers/dri > > > > # sort to eliminate any duplicates > > diff --git a/src/gallium/winsys/imx/drm/Android.mk > > b/src/gallium/winsys/imx/drm/Android.mk > > new file mode 100644 > > index 00..51649f8b87 > > --- /dev/null > > +++ b/src/gallium/winsys/imx/drm/Android.mk > > @@ -0,0 +1,39 @@ > > +# Copyright (C) 2016 Linaro, Ltd, Rob Herring > > +# > > +# 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 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. > > + > > +LOCAL_PATH := $(call my-dir) > > + > > +include $(LOCAL_PATH)/Makefile.sources > > + > > +include $(CLEAR_VARS) > > + > > +LOCAL_SRC_FILES := $(C_SOURCES) > > + > > +LOCAL_SHARED_LIBRARIES := libdrm_etnaviv > > + > > +LOCAL_MODULE := libmesa_winsys_imx > > + > > +include $(GALLIUM_COMMON_MK) > > +include $(BUILD_STATIC_LIBRARY) > > + > > +ifneq ($(HAVE_GALLIUM_FREEDRENO),) > > s/FREE
Re: [Mesa-dev] [PATCH v3 1/5] etnaviv: Add unreachable statement to etna_amode to fix compilation warnings
On Thu, 2017-06-29 at 15:29 +0100, Emil Velikov wrote: > On 28 June 2017 at 22:52, Robert Foss > wrote: > > From: Tomeu Vizoso > > > > Signed-off-by: Robert Foss > > Reviewed-by: Tapani Pälli > > Fwiw > Reviewed-by: Emil Velikov > > Any additional changes (change the int:4 to enum foo:4 in the > headers, > propagate that through the codebase, drop the default case) can be > done at a later stage. You mean something like this? - unsigned Swizzle : 2; /* TGSI_SWIZZLE_ */ + enum_swizzle Swizzle : 2; /* TGSI_SWIZZLE_ */ > > -Emil ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v2 2/3] gallium/hud: Prevent buffer overflow in hud_thread_counter_install
On Thu, 2017-06-29 at 07:28 -0600, Brian Paul wrote: > On 06/29/2017 07:21 AM, Robert Foss wrote: > > Switch to using strncopy to avoid potential overflow of > > name array in struct hud_graph. > > > > Coverity-id: 1413761 > > > > Signed-off-by: Robert Foss > > --- > > src/gallium/auxiliary/hud/hud_cpu.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/src/gallium/auxiliary/hud/hud_cpu.c > > b/src/gallium/auxiliary/hud/hud_cpu.c > > index 4caaab6977..468c36207b 100644 > > --- a/src/gallium/auxiliary/hud/hud_cpu.c > > +++ b/src/gallium/auxiliary/hud/hud_cpu.c > > @@ -362,7 +362,7 @@ void hud_thread_counter_install(struct hud_pane > > *pane, const char *name, > > if (!gr) > > return; > > > > - strcpy(gr->name, name); > > + strncpy(gr->name, name, HUD_GRAPH_NAME_LEN); > > strncpy() doesn't null terminate the destination if strlen(name) >= > HUD_GRAPH_NAME_LEN > > If you're concerned with overflow, you need to address that too. > > You might looks if we have a gallium util function for strncpy with > null > termination. I had a look at adding a stncpy analog to src/util/u_string.h but it would seem that these implementation are only intended for _WIN32 platforms. Were you thinking of another bunch of util functions? Or am I misunderstanding something else? Rob. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 1/3] util: Add util_strncpy
Add strncpy wrapper that makes sure that the string is always ends with a null byte. Signed-off-by: Robert Foss --- Changes since v2: Brian Paul - Patch added src/util/u_string.h | 9 + 1 file changed, 9 insertions(+) diff --git a/src/util/u_string.h b/src/util/u_string.h index e88e13f42c..a8fb92174e 100644 --- a/src/util/u_string.h +++ b/src/util/u_string.h @@ -48,6 +48,15 @@ extern "C" { #endif +static inline char* +util_strncpy(char *dst, const char *src, size_t n) +{ + strncpy(dst, src, n); + dst[n-1] = '\0'; + + return dst; +} + #ifdef _GNU_SOURCE #define util_strchrnul strchrnul -- 2.11.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 3/3] gallium/hud: Prevent buffer overflow in hud_thread_busy_install
Switch to using util_strncat to avoid potential overflow of name array in struct hud_graph. Coverity-id: 1413760 Signed-off-by: Robert Foss --- Changes since v2: Brian Paul - Switch to using new util_strncpy function Changes since v1: Gustaw Smolarczyk - Fix strcpy -> strncpy typo src/gallium/auxiliary/hud/hud_cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/hud/hud_cpu.c b/src/gallium/auxiliary/hud/hud_cpu.c index 0a4ebf93bc..64836dab2c 100644 --- a/src/gallium/auxiliary/hud/hud_cpu.c +++ b/src/gallium/auxiliary/hud/hud_cpu.c @@ -289,7 +289,7 @@ hud_thread_busy_install(struct hud_pane *pane, const char *name, bool main) if (!gr) return; - strcpy(gr->name, name); + util_strncpy(gr->name, name, HUD_GRAPH_NAME_LEN); gr->query_data = CALLOC_STRUCT(thread_info); if (!gr->query_data) { -- 2.11.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 2/3] gallium/hud: Prevent buffer overflow in hud_thread_counter_install
Switch to using util_strncpy to avoid potential overflow of name array in struct hud_graph. Also extract the name element length into a define so that it can be used for strncpy et al. Coverity-id: 1413761 Signed-off-by: Robert Foss --- Changes since v2: Brian Paul - Combined patch with precious patch that only added define - Switched to using new util_strncpy function src/gallium/auxiliary/hud/hud_cpu.c | 3 ++- src/gallium/auxiliary/hud/hud_private.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/hud/hud_cpu.c b/src/gallium/auxiliary/hud/hud_cpu.c index 4caaab6977..0a4ebf93bc 100644 --- a/src/gallium/auxiliary/hud/hud_cpu.c +++ b/src/gallium/auxiliary/hud/hud_cpu.c @@ -33,6 +33,7 @@ #include "os/os_thread.h" #include "util/u_memory.h" #include "util/u_queue.h" +#include "util/u_string.h" #include #include #ifdef PIPE_OS_WINDOWS @@ -362,7 +363,7 @@ void hud_thread_counter_install(struct hud_pane *pane, const char *name, if (!gr) return; - strcpy(gr->name, name); + util_strncpy(gr->name, name, HUD_GRAPH_NAME_LEN); gr->query_data = CALLOC_STRUCT(counter_info); if (!gr->query_data) { diff --git a/src/gallium/auxiliary/hud/hud_private.h b/src/gallium/auxiliary/hud/hud_private.h index 2b1717d2c4..3a958d3146 100644 --- a/src/gallium/auxiliary/hud/hud_private.h +++ b/src/gallium/auxiliary/hud/hud_private.h @@ -87,6 +87,7 @@ struct hud_context { bool has_srgb; }; +#define HUD_GRAPH_NAME_LEN 128 struct hud_graph { /* initialized by common code */ struct list_head head; @@ -95,7 +96,7 @@ struct hud_graph { float *vertices; /* ring buffer of vertices */ /* name and query */ - char name[128]; + char name[HUD_GRAPH_NAME_LEN]; void *query_data; void (*begin_query)(struct hud_graph *gr); void (*query_new_value)(struct hud_graph *gr); -- 2.11.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v3 1/3] util: Add util_strncpy
On Sun, 2017-07-02 at 21:06 -0700, Matt Turner wrote: > Otherwise known as strlcpy()? I didn't realize this, a wrapper would be needed for all platformsou that don't support it natively. Do you know which platforms support strlcpy? Rob. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v4 2/2] android: build imx-drm winsys
From: Tomeu Vizoso Add Android.mk for winsys/imx/drm. Signed-off-by: Tomeu Vizoso Reviewed-by: Tapani Pälli Reviewed-by: Emil Velikov --- Changes sicne v3: Emil Velikov - Add GALLIUM_TARGET_DRIVERS addition Changes since v2: - Rebased on upstream/master - Added commit message Changes since v1: Emil Velikov - Fix C_SOURCES include - Fix GALLIUM_LIBS assignment Android.mk| 5 +++-- src/gallium/Android.mk| 1 + src/gallium/winsys/imx/drm/Android.mk | 40 +++ 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 src/gallium/winsys/imx/drm/Android.mk diff --git a/Android.mk b/Android.mk index e9e3e5f7a4..6571161c87 100644 --- a/Android.mk +++ b/Android.mk @@ -24,7 +24,7 @@ # BOARD_GPU_DRIVERS should be defined. The valid values are # # classic drivers: i915 i965 -# gallium drivers: swrast freedreno i915g nouveau pl111 r300g r600g radeonsi vc4 virgl vmwgfx etnaviv +# gallium drivers: swrast freedreno i915g nouveau pl111 r300g r600g radeonsi vc4 virgl vmwgfx etnaviv imx # # The main target is libGLES_mesa. For each classic driver enabled, a DRI # module will also be built. DRI modules will be loaded by libGLES_mesa. @@ -58,7 +58,8 @@ gallium_drivers := \ vmwgfx.HAVE_GALLIUM_VMWGFX \ vc4.HAVE_GALLIUM_VC4 \ virgl.HAVE_GALLIUM_VIRGL \ - etnaviv.HAVE_GALLIUM_ETNAVIV + etnaviv.HAVE_GALLIUM_ETNAVIV \ + imx.HAVE_GALLIUM_IMX ifeq ($(BOARD_GPU_DRIVERS),all) MESA_BUILD_CLASSIC := $(filter HAVE_%, $(subst ., , $(classic_drivers))) diff --git a/src/gallium/Android.mk b/src/gallium/Android.mk index dc98fa00ed..8743dd6d26 100644 --- a/src/gallium/Android.mk +++ b/src/gallium/Android.mk @@ -45,6 +45,7 @@ SUBDIRS += winsys/vc4/drm drivers/vc4 SUBDIRS += winsys/virgl/drm winsys/virgl/vtest drivers/virgl SUBDIRS += winsys/svga/drm drivers/svga SUBDIRS += winsys/etnaviv/drm drivers/etnaviv drivers/renderonly +SUBDIRS += winsys/imx/drm SUBDIRS += state_trackers/dri # sort to eliminate any duplicates diff --git a/src/gallium/winsys/imx/drm/Android.mk b/src/gallium/winsys/imx/drm/Android.mk new file mode 100644 index 00..d001974d5d --- /dev/null +++ b/src/gallium/winsys/imx/drm/Android.mk @@ -0,0 +1,40 @@ +# Copyright (C) 2016 Linaro, Ltd, Rob Herring +# +# 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 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. + +LOCAL_PATH := $(call my-dir) + +include $(LOCAL_PATH)/Makefile.sources + +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := $(C_SOURCES) + +LOCAL_SHARED_LIBRARIES := libdrm_etnaviv + +LOCAL_MODULE := libmesa_winsys_imx + +include $(GALLIUM_COMMON_MK) +include $(BUILD_STATIC_LIBRARY) + +ifneq ($(HAVE_GALLIUM_IMX),) +GALLIUM_TARGET_DRIVERS += imx-drm +$(eval GALLIUM_LIBS += $(LOCAL_MODULE) libmesa_winsys_etnaviv) +$(eval GALLIUM_SHARED_LIBS += $(LOCAL_SHARED_LIBRARIES)) +endif -- 2.11.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v4 0/2] Android etnaviv and imx support
This series enables etnaviv and imx for the android platform. This is done through updating the Android build scripts. Rob Herring (1): android: add etnaviv driver build support Tomeu Vizoso (1): android: build imx-drm winsys Android.mk| 6 +++-- src/gallium/Android.mk| 2 ++ src/gallium/drivers/etnaviv/Android.mk| 41 +++ src/gallium/winsys/etnaviv/drm/Android.mk | 33 + src/gallium/winsys/imx/drm/Android.mk | 40 ++ 5 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 src/gallium/drivers/etnaviv/Android.mk create mode 100644 src/gallium/winsys/etnaviv/drm/Android.mk create mode 100644 src/gallium/winsys/imx/drm/Android.mk -- 2.11.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v4 1/2] android: add etnaviv driver build support
From: Rob Herring Add etnaviv to Android makefiles. Signed-off-by: Rob Herring Reviewed-by: Tapani Pälli Reviewed-by: Emil Velikov --- Changes sicne v3: Emil Velikov - Add GALLIUM_TARGET_DRIVERS addition Changes since v2: - Rebased on upstream/master Changes since v1: Tapani Pälli - Remove copy-pasta Emil Velikov - Remove libmesa_loader inclusion - Remove copy-pasta - Remove spurious include - Fix C_SOURCES include Android.mk| 5 ++-- src/gallium/Android.mk| 1 + src/gallium/drivers/etnaviv/Android.mk| 41 +++ src/gallium/winsys/etnaviv/drm/Android.mk | 33 + 4 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 src/gallium/drivers/etnaviv/Android.mk create mode 100644 src/gallium/winsys/etnaviv/drm/Android.mk diff --git a/Android.mk b/Android.mk index 9203c87a4e..e9e3e5f7a4 100644 --- a/Android.mk +++ b/Android.mk @@ -24,7 +24,7 @@ # BOARD_GPU_DRIVERS should be defined. The valid values are # # classic drivers: i915 i965 -# gallium drivers: swrast freedreno i915g nouveau pl111 r300g r600g radeonsi vc4 virgl vmwgfx +# gallium drivers: swrast freedreno i915g nouveau pl111 r300g r600g radeonsi vc4 virgl vmwgfx etnaviv # # The main target is libGLES_mesa. For each classic driver enabled, a DRI # module will also be built. DRI modules will be loaded by libGLES_mesa. @@ -57,7 +57,8 @@ gallium_drivers := \ radeonsi.HAVE_GALLIUM_RADEONSI \ vmwgfx.HAVE_GALLIUM_VMWGFX \ vc4.HAVE_GALLIUM_VC4 \ - virgl.HAVE_GALLIUM_VIRGL + virgl.HAVE_GALLIUM_VIRGL \ + etnaviv.HAVE_GALLIUM_ETNAVIV ifeq ($(BOARD_GPU_DRIVERS),all) MESA_BUILD_CLASSIC := $(filter HAVE_%, $(subst ., , $(classic_drivers))) diff --git a/src/gallium/Android.mk b/src/gallium/Android.mk index 451bba4d17..dc98fa00ed 100644 --- a/src/gallium/Android.mk +++ b/src/gallium/Android.mk @@ -44,6 +44,7 @@ SUBDIRS += winsys/radeon/drm winsys/amdgpu/drm drivers/radeonsi drivers/radeon SUBDIRS += winsys/vc4/drm drivers/vc4 SUBDIRS += winsys/virgl/drm winsys/virgl/vtest drivers/virgl SUBDIRS += winsys/svga/drm drivers/svga +SUBDIRS += winsys/etnaviv/drm drivers/etnaviv drivers/renderonly SUBDIRS += state_trackers/dri # sort to eliminate any duplicates diff --git a/src/gallium/drivers/etnaviv/Android.mk b/src/gallium/drivers/etnaviv/Android.mk new file mode 100644 index 00..6976d223c2 --- /dev/null +++ b/src/gallium/drivers/etnaviv/Android.mk @@ -0,0 +1,41 @@ +# Copyright (C) 2016 Linaro, Ltd, Rob Herring +# +# 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 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. + +LOCAL_PATH := $(call my-dir) + +# get C_SOURCES +include $(LOCAL_PATH)/Makefile.sources + +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + $(C_SOURCES) + +LOCAL_SHARED_LIBRARIES := libdrm_etnaviv +LOCAL_MODULE := libmesa_pipe_etnaviv + +include $(GALLIUM_COMMON_MK) +include $(BUILD_STATIC_LIBRARY) + +ifneq ($(HAVE_GALLIUM_ETNAVIV),) +GALLIUM_TARGET_DRIVERS += etnaviv +$(eval GALLIUM_LIBS += $(LOCAL_MODULE) libmesa_winsys_etnaviv) +$(eval GALLIUM_SHARED_LIBS += $(LOCAL_SHARED_LIBRARIES)) +endif diff --git a/src/gallium/winsys/etnaviv/drm/Android.mk b/src/gallium/winsys/etnaviv/drm/Android.mk new file mode 100644 index 00..32091bea0e --- /dev/null +++ b/src/gallium/winsys/etnaviv/drm/Android.mk @@ -0,0 +1,33 @@ +# Copyright (C) 2016 Linaro, Ltd, Rob Herring +# +# 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 not
[Mesa-dev] [PATCH v4 2/3] gallium/hud: Prevent buffer overflow in hud_thread_counter_install
Switch to using util_strlcpy to avoid potential overflow of name array in struct hud_graph. Also extract the name element length into a define so that it can be used for strncpy et al. Coverity-id: 1413761 Signed-off-by: Robert Foss --- Changes since v3: Matt Turner - Switch from util_strncpy to util_strlcpy Changes since v2: Brian Paul - Combined patch with precious patch that only added define - Switched to using new util_strncpy function src/gallium/auxiliary/hud/hud_cpu.c | 3 ++- src/gallium/auxiliary/hud/hud_private.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/hud/hud_cpu.c b/src/gallium/auxiliary/hud/hud_cpu.c index 4caaab6977..755f8a08bb 100644 --- a/src/gallium/auxiliary/hud/hud_cpu.c +++ b/src/gallium/auxiliary/hud/hud_cpu.c @@ -33,6 +33,7 @@ #include "os/os_thread.h" #include "util/u_memory.h" #include "util/u_queue.h" +#include "util/u_string.h" #include #include #ifdef PIPE_OS_WINDOWS @@ -362,7 +363,7 @@ void hud_thread_counter_install(struct hud_pane *pane, const char *name, if (!gr) return; - strcpy(gr->name, name); + util_strlcpy(gr->name, name, HUD_GRAPH_NAME_LEN); gr->query_data = CALLOC_STRUCT(counter_info); if (!gr->query_data) { diff --git a/src/gallium/auxiliary/hud/hud_private.h b/src/gallium/auxiliary/hud/hud_private.h index 2b1717d2c4..3a958d3146 100644 --- a/src/gallium/auxiliary/hud/hud_private.h +++ b/src/gallium/auxiliary/hud/hud_private.h @@ -87,6 +87,7 @@ struct hud_context { bool has_srgb; }; +#define HUD_GRAPH_NAME_LEN 128 struct hud_graph { /* initialized by common code */ struct list_head head; @@ -95,7 +96,7 @@ struct hud_graph { float *vertices; /* ring buffer of vertices */ /* name and query */ - char name[128]; + char name[HUD_GRAPH_NAME_LEN]; void *query_data; void (*begin_query)(struct hud_graph *gr); void (*query_new_value)(struct hud_graph *gr); -- 2.11.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v4 3/3] gallium/hud: Prevent buffer overflow in hud_thread_busy_install
Switch to using util_strlcpy to avoid potential overflow of name array in struct hud_graph. Coverity-id: 1413760 Signed-off-by: Robert Foss --- Changes since v3: Matt Turner - Switch from util_strncpy to util_strlcpy Brian Paul - Fix comment to mention the correct string copy function Changes since v2: Brian Paul - Switch to using new util_strncpy function Changes since v1: Gustaw Smolarczyk - Fix strcpy -> strncpy typo src/gallium/auxiliary/hud/hud_cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/hud/hud_cpu.c b/src/gallium/auxiliary/hud/hud_cpu.c index 755f8a08bb..55e1b58538 100644 --- a/src/gallium/auxiliary/hud/hud_cpu.c +++ b/src/gallium/auxiliary/hud/hud_cpu.c @@ -289,7 +289,7 @@ hud_thread_busy_install(struct hud_pane *pane, const char *name, bool main) if (!gr) return; - strcpy(gr->name, name); + util_strlcpy(gr->name, name, HUD_GRAPH_NAME_LEN); gr->query_data = CALLOC_STRUCT(thread_info); if (!gr->query_data) { -- 2.11.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v4 1/3] util: Add util_strlcpy
Add local strlcpy implementation. Signed-off-by: Robert Foss --- Changes since v3: Matt Turner - Change name of util_strncpy to util_strlcpy Changes since v2: Brian Paul - Patch added src/util/u_string.h | 9 + 1 file changed, 9 insertions(+) diff --git a/src/util/u_string.h b/src/util/u_string.h index e88e13f42c..77014bc744 100644 --- a/src/util/u_string.h +++ b/src/util/u_string.h @@ -48,6 +48,15 @@ extern "C" { #endif +static inline char* +util_strlcpy(char *dst, const char *src, size_t n) +{ + strncpy(dst, src, n); + dst[n-1] = '\0'; + + return dst; +} + #ifdef _GNU_SOURCE #define util_strchrnul strchrnul -- 2.11.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v5 1/3] util: Add util_strlcpy
Add local strlcpy implementation. Signed-off-by: Robert Foss --- Changes since v4: Gustaw Smolarczyk - Make util_strlcpy have the same behaviour as strlcpy Changes since v3: Matt Turner - Change name of util_strncpy to util_strlcpy Changes since v2: Brian Paul - Patch added src/util/u_string.h | 9 + 1 file changed, 9 insertions(+) diff --git a/src/util/u_string.h b/src/util/u_string.h index e88e13f42c..77014bc744 100644 --- a/src/util/u_string.h +++ b/src/util/u_string.h @@ -48,6 +48,15 @@ extern "C" { #endif +static inline char* +util_strlcpy(char *dst, const char *src, size_t n) +{ + strncpy(dst, src, n); + dst[n-1] = '\0'; + + return dst; +} + #ifdef _GNU_SOURCE #define util_strchrnul strchrnul -- 2.11.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev