From patchwork Mon Apr 25 22:33:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 8933151 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 96E979F372 for ; Mon, 25 Apr 2016 22:34:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 943BD201BB for ; Mon, 25 Apr 2016 22:34:35 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 740C62011D for ; Mon, 25 Apr 2016 22:34:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BB73F6E6FE; Mon, 25 Apr 2016 22:34:16 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yw0-f194.google.com (mail-yw0-f194.google.com [209.85.161.194]) by gabe.freedesktop.org (Postfix) with ESMTPS id 645B46E60E for ; Mon, 25 Apr 2016 22:33:54 +0000 (UTC) Received: by mail-yw0-f194.google.com with SMTP id i22so1253667ywc.1 for ; Mon, 25 Apr 2016 15:33:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gJniBz+jF8F3D6wb/7rY7t9csEQQ9gbGMHD/BTcD4Aw=; b=Z5+FKmXeZGj4BI2yXAbk9XjU9O/em0pE+I8uu+RWfjt6AX/rZ+T813Qqouxb9qxg/Q l+6CVk9+DF23k/bJ2J5N5/8mCm+27lhx4GKNIPJ1M/7THfFQTHDJJHfL8BAL878cNX9C L7zVdI1BkGKnfGGaLyu9tE9ZFXzssh9tesz/iRpvLVmbe5Z1e/a1x1bBSMUO8LFDoUUw QdUO8Amlc1+n9dH1PZmC8zamZl4Z6GPGLMkZAQBFGdRzslU8V1PrqoTqhFrG8bi4zqL1 yxlAhwjCjCLslQ+7cay1HxikY29CXSk4n5q4hqUk3cJzJuCRzzrFzsaIPyD9yqG2H1oh 6hsg== X-Gm-Message-State: AOPr4FXyOJ1UhXxY1S5OxDrCQWIyhzNHSdkaEMoV3JgtCW7lit/V5TXJnt4SCwaKL/gdRw== X-Received: by 10.13.251.65 with SMTP id l62mr25289334ywf.88.1461623632820; Mon, 25 Apr 2016 15:33:52 -0700 (PDT) Received: from jade.localdomain ([201.82.24.203]) by smtp.gmail.com with ESMTPSA id r8sm13840742ywb.20.2016.04.25.15.33.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Apr 2016 15:33:52 -0700 (PDT) From: Gustavo Padovan To: Greg Kroah-Hartman Subject: [RFC v2 4/8] drm/fence: allow fence waiting to be interrupted by userspace Date: Mon, 25 Apr 2016 19:33:24 -0300 Message-Id: <1461623608-29538-5-git-send-email-gustavo@padovan.org> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1461623608-29538-1-git-send-email-gustavo@padovan.org> References: <1461623608-29538-1-git-send-email-gustavo@padovan.org> Cc: devel@driverdev.osuosl.org, Daniel Stone , Daniel Vetter , Riley Andrews , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , Gustavo Padovan , John Harrison 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: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00, RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Gustavo Padovan If userspace is running an synchronously atomic commit and interrupts the atomic operation during fence_wait() it will hang until the timer expires, so here we change the wait to be interruptible so it stop immediately when userspace wants to quit. Also adds the necessary error checking for fence_wait(). v2: Comment by Daniel Vetter - Add error checking for fence_wait() Signed-off-by: Gustavo Padovan --- drivers/gpu/drm/drm_atomic_helper.c | 21 +++++++++++++++------ include/drm/drm_atomic_helper.h | 4 ++-- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index 7bf678e..f1cfcce 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -993,13 +993,15 @@ EXPORT_SYMBOL(drm_atomic_helper_commit_modeset_enables); * incoming fb's and stash it in the drm_plane_state. This is called after * drm_atomic_helper_swap_state() so it uses the current plane state (and * just uses the atomic state to find the changed planes) + * + * Return 0 on sucess or < 0 on error. */ -void drm_atomic_helper_wait_for_fences(struct drm_device *dev, - struct drm_atomic_state *state) +int drm_atomic_helper_wait_for_fences(struct drm_device *dev, + struct drm_atomic_state *state) { struct drm_plane *plane; struct drm_plane_state *plane_state; - int i; + int i, ret; for_each_plane_in_state(state, plane, plane_state, i) { if (!plane->state->fence) @@ -1007,10 +1009,14 @@ void drm_atomic_helper_wait_for_fences(struct drm_device *dev, WARN_ON(!plane->state->fb); - fence_wait(plane->state->fence, false); + ret = fence_wait(plane->state->fence, true); + if (ret) + return ret; fence_put(plane->state->fence); plane->state->fence = NULL; } + + return 0; } EXPORT_SYMBOL(drm_atomic_helper_wait_for_fences); @@ -1174,7 +1180,9 @@ int drm_atomic_helper_commit(struct drm_device *dev, * current layout. */ - drm_atomic_helper_wait_for_fences(dev, state); + ret = drm_atomic_helper_wait_for_fences(dev, state); + if (ret) + goto out; drm_atomic_helper_commit_modeset_disables(dev, state); @@ -1184,11 +1192,12 @@ int drm_atomic_helper_commit(struct drm_device *dev, drm_atomic_helper_wait_for_vblanks(dev, state); +out: drm_atomic_helper_cleanup_planes(dev, state); drm_atomic_state_free(state); - return 0; + return ret; } EXPORT_SYMBOL(drm_atomic_helper_commit); diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h index fe9d89c..3a5d2e5 100644 --- a/include/drm/drm_atomic_helper.h +++ b/include/drm/drm_atomic_helper.h @@ -42,8 +42,8 @@ int drm_atomic_helper_commit(struct drm_device *dev, struct drm_atomic_state *state, bool async); -void drm_atomic_helper_wait_for_fences(struct drm_device *dev, - struct drm_atomic_state *state); +int drm_atomic_helper_wait_for_fences(struct drm_device *dev, + struct drm_atomic_state *state); bool drm_atomic_helper_framebuffer_changed(struct drm_device *dev, struct drm_atomic_state *old_state, struct drm_crtc *crtc);