From patchwork Tue Aug 6 15:01:27 2019 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: 11085835 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 62D1118A6 for ; Fri, 9 Aug 2019 09:17:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 537C728B38 for ; Fri, 9 Aug 2019 09:17:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 479CE28C40; Fri, 9 Aug 2019 09:17:11 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable 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 10A1A28C56 for ; Fri, 9 Aug 2019 09:17:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7F4BA6EDCB; Fri, 9 Aug 2019 09:15:58 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by gabe.freedesktop.org (Postfix) with ESMTPS id C21BB6E3AC; Tue, 6 Aug 2019 15:01:37 +0000 (UTC) Received: by mail-wr1-x444.google.com with SMTP id c2so85014853wrm.8; Tue, 06 Aug 2019 08:01:37 -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:subject:date:message-id:mime-version :content-transfer-encoding; bh=rLPPYENgOoc631NZg5ylujQ9Ww/Oy03mgWH9mA4Vfho=; b=nUbeTTo31Q3JF4VIRfixPvjym5cT1gYTgM7CY9FLUcA2VIsjytrgEhoqISBEGAPhtI YMD1ZUKduo+YHtC/sx73Dl5PdVQhpOGu+jxsSvzebfW85b+K2E7EvPz6KbTFGLLuyUZ4 Yn2s6CSc0DLraToSkY7z/TQaLbnZjmW7/JIOboq8+EOAbWJ4S6ACMn5Ao3tFqcpIEOgH ZNIMZ97xCGWTEnjX3+2KucVO+5kIqc4eLy31xgh1qXAP8A8fb9zLGGk2v7EkVAdeU5RY 0dRkpTeNs2+qS56Ra4wYuer46DebPZ5rmTdSh2hNQAdJVKidBH1BnaUjWw8uYc6Ci6eg bsTg== X-Gm-Message-State: APjAAAW/lk29bUT4gMumt3I4ECu6ij/mVCW6bKgH/iGYLBF2VAb5EbD8 /bwgbzg3Hz65cf2S5oTGnubRZi1Y X-Google-Smtp-Source: APXvYqz6AcKhVWvcz+ipDVWpv+mwv6WdHOfeRXlIqGfRphZR2R8yUytCJlZ5FKlnzx8bJIHeQOnH1Q== X-Received: by 2002:a5d:6583:: with SMTP id q3mr5698550wru.184.1565103696222; Tue, 06 Aug 2019 08:01:36 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:d1e0:fffc:b0e3:c66d]) by smtp.gmail.com with ESMTPSA id g2sm78766828wmh.0.2019.08.06.08.01.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Aug 2019 08:01:35 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: intel-gfx@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, chris@chris-wilson.co.uk Date: Tue, 6 Aug 2019 17:01:27 +0200 Message-Id: <20190806150134.104222-1-christian.koenig@amd.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 09 Aug 2019 09:15:44 +0000 X-Mailman-Original-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=rLPPYENgOoc631NZg5ylujQ9Ww/Oy03mgWH9mA4Vfho=; b=NLJEnCXtzyj6NYFf4+43Y6hYJ2KP82uwMjCZ6yEtCz3cMQRTmyASFSYgo7phqMiuDU 7R1kLPssX/Fm66DJlACPHRKwnj2jaNWdusHDZ6Wq+ioa7ATRg+byQw4Rv54g5Pv6RtyM f0TJM1wNYX5G5F46WPmMjlBLcOYJ630RS5xapz/7MVjvwFkdpZt7KtkFtAwyjom3Dxbr Ux2Z2ncX+upxYhAqXggRaoCh8dYCEgkNu6MIm/32Px85iL6i6FB9Xqp20jxEH7HbKdok xMTmLrreLYSDu0L2PYvNe6V5DT6fM2ZaI4poKTOwZLvpNHl4q/4W+VTdPt4rE956+AYi j+TQ== Subject: [Intel-gfx] [PATCH 1/8] dma-buf: fix busy wait for new shared fences X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP When reservation_object_add_shared_fence is replacing an old fence with a new one we should not drop the old one before the new one is in place. Otherwise other cores can busy wait for the new one to appear. Signed-off-by: Christian König --- drivers/dma-buf/reservation.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c index c71b85c8c159..d59207ca72d2 100644 --- a/drivers/dma-buf/reservation.c +++ b/drivers/dma-buf/reservation.c @@ -196,6 +196,7 @@ void reservation_object_add_shared_fence(struct reservation_object *obj, struct dma_fence *fence) { struct reservation_object_list *fobj; + struct dma_fence *old; unsigned int i, count; dma_fence_get(fence); @@ -209,18 +210,16 @@ void reservation_object_add_shared_fence(struct reservation_object *obj, write_seqcount_begin(&obj->seq); for (i = 0; i < count; ++i) { - struct dma_fence *old_fence; - old_fence = rcu_dereference_protected(fobj->shared[i], - reservation_object_held(obj)); - if (old_fence->context == fence->context || - dma_fence_is_signaled(old_fence)) { - dma_fence_put(old_fence); + old = rcu_dereference_protected(fobj->shared[i], + reservation_object_held(obj)); + if (old->context == fence->context || + dma_fence_is_signaled(old)) goto replace; - } } BUG_ON(fobj->shared_count >= fobj->shared_max); + old = NULL; count++; replace: @@ -230,6 +229,7 @@ void reservation_object_add_shared_fence(struct reservation_object *obj, write_seqcount_end(&obj->seq); preempt_enable(); + dma_fence_put(old); } EXPORT_SYMBOL(reservation_object_add_shared_fence);