From patchwork Mon Aug 5 15:45:51 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: 11085925 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 8B3A61395 for ; Fri, 9 Aug 2019 09:18:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C8ED28BBC for ; Fri, 9 Aug 2019 09:18:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7079228C3E; Fri, 9 Aug 2019 09:18:46 +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 3CC0628BBC for ; Fri, 9 Aug 2019 09:18:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AA5E46EDA9; Fri, 9 Aug 2019 09:18:38 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by gabe.freedesktop.org (Postfix) with ESMTPS id A71A36E492; Mon, 5 Aug 2019 15:45:58 +0000 (UTC) Received: by mail-wr1-x443.google.com with SMTP id z1so84901484wru.13; Mon, 05 Aug 2019 08:45:58 -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:in-reply-to :references:mime-version:content-transfer-encoding; bh=rLPPYENgOoc631NZg5ylujQ9Ww/Oy03mgWH9mA4Vfho=; b=G3r+uNp3UXbOBg16c6BrFDfmkoILuRLt2+xE7QsRAr5iLU1ZY9bgSZVb/G9/mzzubD 1zNL7cUhRULsnWA9dg7CfydDIDalnsL6VXK+Fdud7emujva7LDhizIh59xZvovfZRKgx hRsXbJtB1hiqqO7Zs5JASQtYn7ma2cXbq8cszSn4sJDuEvxtWKTvLzJ1EIbe13A54aMR d66cgtc0lpM+gX836qhkpJJ+1v0e3RIWSbzSPgcyYeGo1+sdfCP0u0ddd6H92M4mVRWX nQylhCndBLftm4jb1j3xVfdhHWbJ0FUO8XSM2wNYQANJniRWklMi5DZyRaq/iM6Y2Dcu fEXA== X-Gm-Message-State: APjAAAU08nvNOPZX5CCJIRhSf91rKXFudC/UYPzDwUBOkGcmhUenkFlC XPHhx8d7oshbAs4omgmwH/hux5wr X-Google-Smtp-Source: APXvYqzBprTtDw6edlmqIDiUmJARW7G/OtGF/lCyUR20zOiLqI+2QZmZi/Tqpnx0vU3E2ILqGfvMww== X-Received: by 2002:a5d:564e:: with SMTP id j14mr1799712wrw.1.1565019957178; Mon, 05 Aug 2019 08:45:57 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:fdbd:6233:4990:5a8d]) by smtp.gmail.com with ESMTPSA id 91sm171836865wrp.3.2019.08.05.08.45.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Aug 2019 08:45:56 -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, linux-media@vger.kernel.org, chris@chris-wilson.co.uk Date: Mon, 5 Aug 2019 17:45:51 +0200 Message-Id: <20190805154554.3476-2-christian.koenig@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190805154554.3476-1-christian.koenig@amd.com> References: <20190805154554.3476-1-christian.koenig@amd.com> 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:in-reply-to:references:mime-version :content-transfer-encoding; bh=rLPPYENgOoc631NZg5ylujQ9Ww/Oy03mgWH9mA4Vfho=; b=uUMttogETRTbgFeSAW6AxRt+C/hSaMGFvi3mp332QoCPwvz8IWurSQBJyJZOR7bOeh t3ZG8sKWLHmomyK1KkW6laa+1rkPlb2s6S7QLjGuLHIGU6mFCWzgKyX03MYFGac/PX3f 3FnoVZBhJNwniqasz7bjYzRcYHCGc7RShvCwvYl0KzWBYFpbx0kyIORqWht2191zBDHz Y3CTXzhkS44iwXBeQLT+vO4Z5kzpL6G5vo9DrLaozfCFZvMs+Wn9RBp8yQaEa0EJxXMd qPMg93CgzwNyEG7odpHdapiM1CXQ7Ke1wCd5xjdaY8/jfeVjVAiB9Ij2vv4o2WHx0ycg FPkQ== Subject: [Intel-gfx] [PATCH 2/5] 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);