From patchwork Mon Sep 4 23:06:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 9937639 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 F374960237 for ; Mon, 4 Sep 2017 23:06:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E59BE28761 for ; Mon, 4 Sep 2017 23:06:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DACB6287A8; Mon, 4 Sep 2017 23:06:20 +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 0222D28761 for ; Mon, 4 Sep 2017 23:06:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B90BB6E388; Mon, 4 Sep 2017 23:06:14 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt0-f194.google.com (mail-qt0-f194.google.com [209.85.216.194]) by gabe.freedesktop.org (Postfix) with ESMTPS id F02CC6E388 for ; Mon, 4 Sep 2017 23:06:12 +0000 (UTC) Received: by mail-qt0-f194.google.com with SMTP id h21so1175950qth.4 for ; Mon, 04 Sep 2017 16:06:12 -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=ljb1D14yJ9OTDAIVxp7H5PyQWHAYl6MjjZG96yfr/TmhOJ5HOA+dj4edv5ko6vJuIr UDIzbXein4iK1sMdNRLScQvS/aVNz9wPf4tvDfJc5sfspHB2L0rLtCMoLFHSr/RpZoEN rJy8Zgvt3Ia7HTTFd2b6LJz94sErVtePSfz8s9nWJpsY0rUG3exYWwQtvLYwwp1lMFEh LYDaII/d2KBWkMy25z6kfB+G5Pcm4T7sqMpJEqwLCx30lgfVZyOx3Ezr0sXYZ7Yg9eLG EsJqBEtGNZy6t1Be4GsBo8yuJaHMNNJZN5Uo6ddlqwmTAZljEuq1x/dKWrHLzV+tfYZJ PNfA== X-Gm-Message-State: AHPjjUjZ9gI+EG1gb/uSBm93V2d7K8V+flbOfzKzURkDR+1KbK2GOZ6B j7Nn3Wojo2WmGFfRWvA= X-Google-Smtp-Source: ADKCNb5GJw57BAU9mDz9AOgz3ohRMUo5i9Qquc5VMgJ7fcJlpVZcu2AB4gwJS+6Xf1fdfUACtbYcNA== X-Received: by 10.200.22.231 with SMTP id y36mr2926778qtk.31.1504566371776; Mon, 04 Sep 2017 16:06:11 -0700 (PDT) Received: from localhost.localdomain ([187.10.21.246]) by smtp.gmail.com with ESMTPSA id s77sm743495qke.47.2017.09.04.16.06.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 04 Sep 2017 16:06:10 -0700 (PDT) From: Gustavo Padovan To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/2] selftests: sync: add test that waits on a destroyed timeline Date: Mon, 4 Sep 2017 20:06:03 -0300 Message-Id: <20170904230604.12757-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);