From patchwork Mon Jun 3 11:54:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume Tucker X-Patchwork-Id: 10972797 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DF0431398 for ; Mon, 3 Jun 2019 11:55:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFCAA287A5 for ; Mon, 3 Jun 2019 11:55:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD54A287C3; Mon, 3 Jun 2019 11:55:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 86B662015F for ; Mon, 3 Jun 2019 11:55:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C445489257; Mon, 3 Jun 2019 11:55:03 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6C20A891AD; Mon, 3 Jun 2019 11:55:02 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: gtucker) with ESMTPSA id DC7B0281DC5 From: Guillaume Tucker To: Arkadiusz Hiler , Petri Latvala Date: Mon, 3 Jun 2019 12:54:47 +0100 Message-Id: <73773a5061681c502db373df698d2d24b4ad267a.1559562608.git.guillaume.tucker@collabora.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 1/4] tests: add libatomic dependency X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: igt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Add dependency to libatomic in order to be able to use the __atomic_* functions instead of the older __sync_* ones. This is to enable atomic operations on a wider number of architectures including MIPS. Signed-off-by: Guillaume Tucker Reviewed-by: Arkadiusz Hiler --- meson.build | 1 + tests/meson.build | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 6268c58d3634..4e5bb323fa49 100644 --- a/meson.build +++ b/meson.build @@ -179,6 +179,7 @@ math = cc.find_library('m') realtime = cc.find_library('rt') dlsym = cc.find_library('dl') zlib = cc.find_library('z') +libatomic = cc.find_library('atomic') if cc.has_header('linux/kd.h') config.set('HAVE_LINUX_KD_H', 1) diff --git a/tests/meson.build b/tests/meson.build index 806766e51667..6877ccd59235 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -233,7 +233,7 @@ i915_progs = [ 'i915_suspend', ] -test_deps = [ igt_deps ] +test_deps = [ igt_deps, libatomic ] if libdrm_nouveau.found() test_progs += [ From patchwork Mon Jun 3 11:54:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume Tucker X-Patchwork-Id: 10972799 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 143D31398 for ; Mon, 3 Jun 2019 11:55:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0575728414 for ; Mon, 3 Jun 2019 11:55:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE01D2841D; Mon, 3 Jun 2019 11:55:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A7E18288A6 for ; Mon, 3 Jun 2019 11:55:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0892089263; Mon, 3 Jun 2019 11:55:07 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by gabe.freedesktop.org (Postfix) with ESMTPS id CF0C48925F; Mon, 3 Jun 2019 11:55:05 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: gtucker) with ESMTPSA id 7AC9E284191 From: Guillaume Tucker To: Arkadiusz Hiler , Petri Latvala Date: Mon, 3 Jun 2019 12:54:48 +0100 Message-Id: <11db9a1438142d413ad228e6d1953463dfbb9236.1559562608.git.guillaume.tucker@collabora.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <73773a5061681c502db373df698d2d24b4ad267a.1559562608.git.guillaume.tucker@collabora.com> References: <73773a5061681c502db373df698d2d24b4ad267a.1559562608.git.guillaume.tucker@collabora.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 2/4] gitlab-ci: add libatomic to Fedora docker image X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: igt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Add libatomic to the Fedora docker image so it can link binaries that use __atomic_* functions. Signed-off-by: Guillaume Tucker Reviewed-by: Arkadiusz Hiler --- Dockerfile.fedora | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.fedora b/Dockerfile.fedora index 6686e587613d..c84b412b0723 100644 --- a/Dockerfile.fedora +++ b/Dockerfile.fedora @@ -1,7 +1,7 @@ FROM fedora:30 RUN dnf install -y \ - gcc flex bison meson ninja-build xdotool \ + gcc flex bison libatomic meson ninja-build xdotool \ 'pkgconfig(libdrm)' \ 'pkgconfig(pciaccess)' \ 'pkgconfig(libkmod)' \ From patchwork Mon Jun 3 11:54:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume Tucker X-Patchwork-Id: 10972803 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5A37114C0 for ; Mon, 3 Jun 2019 11:55:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4A09D284B9 for ; Mon, 3 Jun 2019 11:55:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E708287A5; Mon, 3 Jun 2019 11:55:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E6C992874F for ; Mon, 3 Jun 2019 11:55:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 02EAE8926B; Mon, 3 Jun 2019 11:55:09 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4CC528925F; Mon, 3 Jun 2019 11:55:06 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: gtucker) with ESMTPSA id CEDFE260E09 From: Guillaume Tucker To: Arkadiusz Hiler , Petri Latvala Date: Mon, 3 Jun 2019 12:54:49 +0100 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: <73773a5061681c502db373df698d2d24b4ad267a.1559562608.git.guillaume.tucker@collabora.com> References: <73773a5061681c502db373df698d2d24b4ad267a.1559562608.git.guillaume.tucker@collabora.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 3/4] i915/gem_create: use __atomic_* instead of __sync_* X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: igt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Replace calls to the older __sync_* functions with the new __atomic_* standard ones. This fixes builds on some architectures, in particular MIPS which doesn't have __sync_add_and_fetch_8 and __sync_val_compare_and_swap_8 for 64-bit variable handling. Signed-off-by: Guillaume Tucker --- tests/Makefile.am | 2 +- tests/i915/gem_create.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 5097debf629c..18a0f1f20592 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -90,7 +90,7 @@ AM_LDFLAGS = -Wl,--as-needed drm_import_export_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS) drm_import_export_LDADD = $(LDADD) -lpthread gem_create_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS) -gem_create_LDADD = $(LDADD) -lpthread +gem_create_LDADD = $(LDADD) -lpthread -latomic gem_close_race_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS) gem_close_race_LDADD = $(LDADD) -lpthread gem_ctx_thrash_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS) diff --git a/tests/i915/gem_create.c b/tests/i915/gem_create.c index 43cbf45f289b..a4aeb94b3f93 100644 --- a/tests/i915/gem_create.c +++ b/tests/i915/gem_create.c @@ -156,6 +156,14 @@ static void invalid_nonaligned_size(int fd) gem_close(fd, create.handle); } +static uint64_t atomic_compare_swap_u64(uint64_t *ptr, uint64_t oldval, + uint64_t newval) +{ + __atomic_compare_exchange_n(ptr, &oldval, newval, 0, + __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); + return oldval; +} + static uint64_t get_npages(uint64_t *global, uint64_t npages) { uint64_t try, old, max; @@ -165,7 +173,7 @@ static uint64_t get_npages(uint64_t *global, uint64_t npages) old = max; try = 1 + npages % (max / 2); max -= try; - } while ((max = __sync_val_compare_and_swap(global, old, max)) != old); + } while ((max = atomic_compare_swap_u64(global, old, max)) != old); return try; } @@ -202,7 +210,7 @@ static void *thread_clear(void *data) } gem_close(i915, create.handle); - __sync_add_and_fetch(&arg->max, npages); + __atomic_add_fetch(&arg->max, npages, __ATOMIC_SEQ_CST); } return NULL; From patchwork Mon Jun 3 11:54:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume Tucker X-Patchwork-Id: 10972801 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5F1FC14C0 for ; Mon, 3 Jun 2019 11:55:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5081028414 for ; Mon, 3 Jun 2019 11:55:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 44C47288AE; Mon, 3 Jun 2019 11:55:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C81C22874F for ; Mon, 3 Jun 2019 11:55:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2DD5C89268; Mon, 3 Jun 2019 11:55:08 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by gabe.freedesktop.org (Postfix) with ESMTPS id D0CC18925F; Mon, 3 Jun 2019 11:55:06 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: gtucker) with ESMTPSA id 1B9A128A4FF From: Guillaume Tucker To: Arkadiusz Hiler , Petri Latvala Date: Mon, 3 Jun 2019 12:54:50 +0100 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: <73773a5061681c502db373df698d2d24b4ad267a.1559562608.git.guillaume.tucker@collabora.com> References: <73773a5061681c502db373df698d2d24b4ad267a.1559562608.git.guillaume.tucker@collabora.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 4/4] tests/sw_sync: use __atomic_* instead of __sync_* X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: igt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Replace calls to the older __sync_* functions with the new __atomic_* standard ones to be consistent with other tests and improve portability across CPU architectures. Signed-off-by: Guillaume Tucker --- tests/Makefile.am | 1 + tests/sw_sync.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 18a0f1f20592..71514d4d2e5a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -121,6 +121,7 @@ prime_self_import_LDADD = $(LDADD) -lpthread gem_userptr_blits_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS) gem_userptr_blits_LDADD = $(LDADD) -lpthread perf_pmu_LDADD = $(LDADD) $(top_builddir)/lib/libigt_perf.la +sw_sync_LDADD = $(LDADD) -latomic kms_flip_LDADD = $(LDADD) -lpthread diff --git a/tests/sw_sync.c b/tests/sw_sync.c index 950b8b614759..2ee1e1c60b32 100644 --- a/tests/sw_sync.c +++ b/tests/sw_sync.c @@ -517,7 +517,7 @@ static void test_sync_multi_consumer(void) { sem_wait(&sem); - __sync_fetch_and_add(&counter, 1); + __atomic_fetch_add(&counter, 1, __ATOMIC_SEQ_CST); sw_sync_timeline_inc(timeline, 1); } @@ -554,7 +554,8 @@ static void * test_sync_multi_consumer_producer_thread(void *arg) if (sync_fence_wait(fence, 1000) < 0) return (void *) 1; - if (__sync_fetch_and_add(data->counter, 1) != next_point) + if (__atomic_fetch_add(data->counter, 1, __ATOMIC_SEQ_CST) != + next_point) return (void *) 1; /* Kick off the next thread. */ @@ -900,4 +901,3 @@ igt_main igt_subtest("sync_random_merge") test_sync_random_merge(); } -