From patchwork Mon Jan 22 20:00:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 10179129 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 75F5B602B7 for ; Mon, 22 Jan 2018 20:00:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6653626E97 for ; Mon, 22 Jan 2018 20:00:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5965926E7B; Mon, 22 Jan 2018 20:00: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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID 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 D09C426E7B for ; Mon, 22 Jan 2018 20:00:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CBAC589EFF; Mon, 22 Jan 2018 20:00:07 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x242.google.com (mail-wr0-x242.google.com [IPv6:2a00:1450:400c:c0c::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id AAA3489E33 for ; Mon, 22 Jan 2018 20:00:06 +0000 (UTC) Received: by mail-wr0-x242.google.com with SMTP id 100so10010950wrb.7 for ; Mon, 22 Jan 2018 12:00:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=v9wb3NQw++Eq3nse15F+CEo3yom+BmgPc8j5Bo8snuw=; b=AetmrHnPtsZtJ8i3vuVPPV6K7L58Pn4z2j8VSXQaJErjrpyJqF+AWprqszTwoTGJz4 ZmqKSH+bmQeZ7c2wWMnTarQw/o5glc5ClIyB2Uhui8tCyPFxXMsxux0DmtZTAVAcxhGO dWuenlmX/dl7yE1Ih4tPvbi1wGI2gHIL3bcKsOIhQuynJ4gTl1I7pRf9hDvsio+SvFa9 hW+PKJLp/je+PHa3bzgoeQq9ZpcKLb2wPdYr7E2mWps7TQ0XvshP4fz8+AAWjSLe8VsE /Bkg9T+9rMuZEOCOcld6j+yYpWHCBppmUHjUIQDaAHaQOkb40NmUmUDI5uqcgz2DJGuR o+rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=v9wb3NQw++Eq3nse15F+CEo3yom+BmgPc8j5Bo8snuw=; b=MJDHGxVPzQWBHiPnkFD4NPJn0Y67ZSSNrEu4KDhrw/q15EnvQRsuHVq5mKIqFM/542 JvdNy6g1h0K/hQtvumAehjaf0/XDcitT1cf5grrsnxZJJUaZo5is1npGHlDNLJXiDnUS 0vaQMOoabOj2cQiOIlPNH52UaNOour6fcP/7n/4HBhDyiDFlr9qZ5QzE2pupSgiboA07 8zKDMTo0h7jsQTMg58vv7ZK9Wngp6bYuCdQxsQAk1ondRF0ICyQTlVpCEnO9YiRfh3Qg 6WuzHHjY/DbucImmlMQuS1Bqb/4IxvIEej2O5IbYDEIWCQ2/ivBEltvDSk9eaZIDFZuN ZO3Q== X-Gm-Message-State: AKwxytfZ/Y4Y7XlHI3HSfJRJQGSJK5X5nWkLewjuY9XPBPSV7i+oCezt QmY0Sh2S1EZLLRQdzZOHYQYhSQ== X-Google-Smtp-Source: AH8x226UCd/NyrEadah3Ll0WnQ2qKgyMdONTmuXB2FxiJQJxAboGWrxaUAngkfkCqm2spEY/I15y9g== X-Received: by 10.223.151.195 with SMTP id t3mr13191wrb.274.1516651204973; Mon, 22 Jan 2018 12:00:04 -0800 (PST) Received: from baker.fritz.box ([2a02:908:1251:8fc0:f8ce:1226:705c:db80]) by smtp.gmail.com with ESMTPSA id l8sm6729007wmg.46.2018.01.22.12.00.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Jan 2018 12:00:04 -0800 (PST) From: "=?UTF-8?q?Christian=20K=C3=B6nig?=" X-Google-Original-From: =?UTF-8?q?Christian=20K=C3=B6nig?= To: dri-devel@lists.freedesktop.org, chris@chris-wilson.co.uk, lyude@redhat.com Subject: [PATCH] dma-buf: fix reservation_object_wait_timeout_rcu once more v2 Date: Mon, 22 Jan 2018 21:00:03 +0100 Message-Id: <20180122200003.6665-1-christian.koenig@amd.com> X-Mailer: git-send-email 2.14.1 MIME-Version: 1.0 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 We need to set shared_count even if we already have a fence to wait for. v2: init i to -1 as well Signed-off-by: Christian König Cc: stable@vger.kernel.org Tested-by: Lyude Paul Reviewed-by: Lyude Paul Reviewed-by: Chris Wilson --- drivers/dma-buf/reservation.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c index 461afa9febd4..314eb1071cce 100644 --- a/drivers/dma-buf/reservation.c +++ b/drivers/dma-buf/reservation.c @@ -484,13 +484,15 @@ long reservation_object_wait_timeout_rcu(struct reservation_object *obj, unsigned long timeout) { struct dma_fence *fence; - unsigned seq, shared_count, i = 0; + unsigned seq, shared_count; long ret = timeout ? timeout : 1; + int i; retry: shared_count = 0; seq = read_seqcount_begin(&obj->seq); rcu_read_lock(); + i = -1; fence = rcu_dereference(obj->fence_excl); if (fence && !test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) { @@ -506,14 +508,14 @@ long reservation_object_wait_timeout_rcu(struct reservation_object *obj, fence = NULL; } - if (!fence && wait_all) { + if (wait_all) { struct reservation_object_list *fobj = rcu_dereference(obj->fence); if (fobj) shared_count = fobj->shared_count; - for (i = 0; i < shared_count; ++i) { + for (i = 0; !fence && i < shared_count; ++i) { struct dma_fence *lfence = rcu_dereference(fobj->shared[i]); if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT,