From patchwork Tue Nov 21 14:08:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 10068221 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 A3ACE602B7 for ; Tue, 21 Nov 2017 14:09:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 975B429648 for ; Tue, 21 Nov 2017 14:09:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8BCB029675; Tue, 21 Nov 2017 14:09: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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1FCED29648 for ; Tue, 21 Nov 2017 14:09:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751286AbdKUOIz (ORCPT ); Tue, 21 Nov 2017 09:08:55 -0500 Received: from mail-qt0-f196.google.com ([209.85.216.196]:33597 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751105AbdKUOIy (ORCPT ); Tue, 21 Nov 2017 09:08:54 -0500 Received: by mail-qt0-f196.google.com with SMTP id r58so19349618qtc.0; Tue, 21 Nov 2017 06:08:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=6H4Q1jFafiMdTYq+lD68oKGM4b4ecOAFjSapfszNOUA=; b=eR/1tqU4ILivCJYsEIzjferCco9m8NJO8QkNDOVTrvwOQWpTISUP3ta0M+2zl3bPoX g2pNLCEy6Z8Kbd4cbfjqEWwG967An1nwkEyAE6j9qHAOleZ+u4qzvL1rIRPznLDW1M0+ 2Sdlbc0+TGayrsGyMryH1Yj+4iQ8g2tReIND1teB0nfqjPgap29WMMhiWKgDVSkBnbYc AvaGFs6zuLFc5CYDVfZ3TcJo/cv81SDB/ovsNFxEjMqFdem3XmcNBMjKpsOSaylO3Utv CWx6ixx5NeyrvfEQVAfZgtfQN8Frl4+S/t5OQ+v4UURJPgXl3m1ed2AnlvfoG1iKIauE bihQ== 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; bh=6H4Q1jFafiMdTYq+lD68oKGM4b4ecOAFjSapfszNOUA=; b=W0N+ENqiGx32G3faQVb8gS357r8lw8mFcPZPceBQ5RnjrZRpakjZiGWAh++EWxi/lF X8AZt9LEh03pgy5PfDRfVeIl1y2TH+cza1M8WuLZYXHCcAnwKjrZ6tWCbxo51FPbWG53 nbRPogKIZjZFtobaJNfiZyUNorQUoXthGmyMBZPMubXJ4uUBBL24DEgWUso8ZYilZaxc WZIVy4dHwoyklq90jq7L85VZ45OGz2uHkdFFA4PxUstHHhBuG1Ip2Co435QmGVvhpAtw kX5i5CwS/MdJ2fGh2sSlSc2v8PSfSOUQaYpKAaRDQ/Lzb+jfmK/cpr+nNG9uDD6iP+BN /6dA== X-Gm-Message-State: AJaThX6AwXM09zyygDaS7u0TbC8U++z4r+VTay56P1BZ53NTSbckXkrk OsG7NwY/hp3PGOtQ0MAhGzU= X-Google-Smtp-Source: AGs4zMZIrlsYeWwVusVWzZzjs9qAYW7n031oA/YsVZ/qs9wZAGvuA/8zI7l1XXND/VO24DmuT6F0ew== X-Received: by 10.200.9.86 with SMTP id z22mr11567066qth.96.1511273333533; Tue, 21 Nov 2017 06:08:53 -0800 (PST) Received: from localhost ([144.121.20.162]) by smtp.gmail.com with ESMTPSA id x1sm2079926qti.91.2017.11.21.06.08.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Nov 2017 06:08:53 -0800 (PST) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: Rob Clark , Sumit Semwal , linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org Subject: [PATCH] reservation: don't wait when timeout=0 Date: Tue, 21 Nov 2017 09:08:46 -0500 Message-Id: <20171121140850.23401-1-robdclark@gmail.com> X-Mailer: git-send-email 2.13.6 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If we are testing if a reservation object's fences have been signaled with timeout=0 (non-blocking), we need to pass 0 for timeout to dma_fence_wait_timeout(). Plus bonus spelling correction. Signed-off-by: Rob Clark Reviewed-by: Christian König --- drivers/dma-buf/reservation.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c index dec3a815455d..71f51140a9ad 100644 --- a/drivers/dma-buf/reservation.c +++ b/drivers/dma-buf/reservation.c @@ -420,7 +420,7 @@ EXPORT_SYMBOL_GPL(reservation_object_get_fences_rcu); * * RETURNS * Returns -ERESTARTSYS if interrupted, 0 if the wait timed out, or - * greater than zer on success. + * greater than zero on success. */ long reservation_object_wait_timeout_rcu(struct reservation_object *obj, bool wait_all, bool intr, @@ -483,7 +483,14 @@ long reservation_object_wait_timeout_rcu(struct reservation_object *obj, goto retry; } - ret = dma_fence_wait_timeout(fence, intr, ret); + /* + * Note that dma_fence_wait_timeout() will return 1 if + * the fence is already signaled, so in the wait_all + * case when we go through the retry loop again, ret + * will be greater than 0 and we don't want this to + * cause _wait_timeout() to block + */ + ret = dma_fence_wait_timeout(fence, intr, timeout ? ret : 0); dma_fence_put(fence); if (ret > 0 && wait_all && (i + 1 < shared_count)) goto retry;