From patchwork Thu Sep 7 19:02:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 9942753 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 09917602B3 for ; Thu, 7 Sep 2017 19:03:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D179E1FF1F for ; Thu, 7 Sep 2017 19:03:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C5A0C1FFAE; Thu, 7 Sep 2017 19:03:15 +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=-3.7 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM 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 E39D520090 for ; Thu, 7 Sep 2017 19:03:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4F3C16E037; Thu, 7 Sep 2017 19:02:55 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt0-f193.google.com (mail-qt0-f193.google.com [209.85.216.193]) by gabe.freedesktop.org (Postfix) with ESMTPS id AA9EC6E037 for ; Thu, 7 Sep 2017 19:02:54 +0000 (UTC) Received: by mail-qt0-f193.google.com with SMTP id k2so352378qte.5 for ; Thu, 07 Sep 2017 12:02:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=CaVOSNp2HpADRBjYvD9i1yY/lWPq54wVAP7JSIY8Wm8=; b=iYlTtiD//FZLhCk82uBfDUg/n5XBL9BiafJjp0lT0vVi/XZTCrcDU51E0TegTERBUY oj6a8RJ0Pz3VJwcCKr91Fzo0smVWuCh3rqZeyZCg2s3v/+mwOarXIRiRMdGGFGt1i9lw x0ABwmioVkyc2EvMVPfWjToAfXQJ9rDE5u3hxI+etldNt4tFW2u4UrKulJONigGP+swC gYtA9Q/nG5+htJuUS6v6gDAA4kkAzw+v3DKlE+ot61JDYiVNN0aMBg3m3n3Le14BV1vj c4lmLLCI2EyTBazZi6rD7Kw03YPYudpnVUTz8R5rk1A4pSNGcNfBa63O3Cgjs+hjZzUi orfA== X-Gm-Message-State: AHPjjUgklRBPcdVRpXLcVsDSP8PwmZk8r8ZP+FB5+Jbt1ewrDMzQKoGg I2Ms2ikTEnHf/DM45jM= X-Google-Smtp-Source: AOwi7QD/3QjIcw5lYdwR6xiduBaYY0OPAbT7J38xetuQFR0gDPzS/5vA3iLADD99oBSQVQFE48Nl2w== X-Received: by 10.200.37.21 with SMTP id 21mr561715qtm.74.1504810973467; Thu, 07 Sep 2017 12:02:53 -0700 (PDT) Received: from localhost.localdomain ([187.10.21.246]) by smtp.gmail.com with ESMTPSA id k2sm16244qkc.36.2017.09.07.12.02.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Sep 2017 12:02:52 -0700 (PDT) From: Gustavo Padovan To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 1/2] selftests: sync: add test that waits on a destroyed timeline Date: Thu, 7 Sep 2017 16:02:45 -0300 Message-Id: <20170907190246.16425-1-gustavo@padovan.org> X-Mailer: git-send-email 2.13.5 MIME-Version: 1.0 Cc: =?UTF-8?q?Emilio=20L=C3=B3pez?= , Shuah Khan , linux-kselftest@vger.kernel.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Emilio López If a sw_sync_timeline is destroyed the fences associated to it need to be signalled. This test checks that. Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Signed-off-by: Emilio López Signed-off-by: Gustavo Padovan --- tools/testing/selftests/sync/sync_test.c | 1 + tools/testing/selftests/sync/sync_wait.c | 58 ++++++++++++++++++++++++++++++++ tools/testing/selftests/sync/synctest.h | 1 + 3 files changed, 60 insertions(+) diff --git a/tools/testing/selftests/sync/sync_test.c b/tools/testing/selftests/sync/sync_test.c index 62fa666e501a..5d93c9dcc290 100644 --- a/tools/testing/selftests/sync/sync_test.c +++ b/tools/testing/selftests/sync/sync_test.c @@ -79,6 +79,7 @@ int main(void) err += RUN_TEST(test_fence_one_timeline_merge); err += RUN_TEST(test_fence_merge_same_fence); err += RUN_TEST(test_fence_multi_timeline_wait); + err += RUN_TEST(test_fence_wait_on_destroyed_timeline); err += RUN_TEST(test_stress_two_threads_shared_timeline); err += RUN_TEST(test_consumer_stress_multi_producer_single_consumer); err += RUN_TEST(test_merge_stress_random_merge); diff --git a/tools/testing/selftests/sync/sync_wait.c b/tools/testing/selftests/sync/sync_wait.c index d69b752f6550..82ad9f519959 100644 --- a/tools/testing/selftests/sync/sync_wait.c +++ b/tools/testing/selftests/sync/sync_wait.c @@ -25,6 +25,7 @@ * OTHER DEALINGS IN THE SOFTWARE. */ +#include #include "sync.h" #include "sw_sync.h" #include "synctest.h" @@ -89,3 +90,60 @@ int test_fence_multi_timeline_wait(void) return 0; } + +struct fds_test { + int timeline; + int fencesig, fencekill; + int result; +}; + +static int test_fence_wait_on_destroyed_timeline_thread(void *d) +{ + struct fds_test *data = d; + int ret; + + /* in case of errors */ + data->result = 1; + + ret = sw_sync_timeline_inc(data->timeline, 100); + ASSERT(ret == 0, "Failure advancing timeline\n"); + + ret = sync_wait(data->fencekill, -1); + ASSERT(ret == 1, "Failure waiting on fence\n"); + + /* no errors occurred */ + data->result = 0; + return 0; +} + +int test_fence_wait_on_destroyed_timeline(void) +{ + struct fds_test data; + pthread_t thread; + int valid; + + data.timeline = sw_sync_timeline_create(); + valid = sw_sync_timeline_is_valid(data.timeline); + ASSERT(valid, "Failure allocating timeline\n"); + + data.fencesig = sw_sync_fence_create(data.timeline, "allocFence", 100); + data.fencekill = sw_sync_fence_create(data.timeline, "allocFence", 200); + + /* Spawn a thread to wait on a fence when the timeline is killed */ + pthread_create(&thread, NULL, (void *(*)(void *)) + test_fence_wait_on_destroyed_timeline_thread, &data); + + /* Wait for the thread to spool up */ + sync_wait(data.fencesig, -1); + + /* Kill the timeline */ + sw_sync_timeline_destroy(data.timeline); + + /* wait for the thread to clean up */ + pthread_join(thread, NULL); + + sw_sync_fence_destroy(data.fencesig); + sw_sync_fence_destroy(data.fencekill); + + return data.result; +} diff --git a/tools/testing/selftests/sync/synctest.h b/tools/testing/selftests/sync/synctest.h index e7d1d57dba7a..1cbe1e3658b3 100644 --- a/tools/testing/selftests/sync/synctest.h +++ b/tools/testing/selftests/sync/synctest.h @@ -53,6 +53,7 @@ int test_fence_merge_same_fence(void); /* Fence wait tests */ int test_fence_multi_timeline_wait(void); +int test_fence_wait_on_destroyed_timeline(void); /* Stress test - parallelism */ int test_stress_two_threads_shared_timeline(void);