From patchwork Tue Aug 6 15:01:32 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: 11085805 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 8BFF614F7 for ; Fri, 9 Aug 2019 09:16:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 77DAE28B38 for ; Fri, 9 Aug 2019 09:16:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6873F28C3E; Fri, 9 Aug 2019 09:16:53 +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 285CA28B38 for ; Fri, 9 Aug 2019 09:16:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E2F0E6EDB7; Fri, 9 Aug 2019 09:15:55 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by gabe.freedesktop.org (Postfix) with ESMTPS id 02BDB6E3C4; Tue, 6 Aug 2019 15:01:42 +0000 (UTC) Received: by mail-wm1-x344.google.com with SMTP id a15so78545049wmj.5; Tue, 06 Aug 2019 08:01:42 -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=kQ9oFDS/I3lsIGSETmAE0qxXzfKIwv2YeSX45z+1rwU=; b=fQVuM/A64JTGGcNOsoZ2kPEo/0ARoMoNO3jN6rijXilF0BcmyfVogqFXf6X/CAeF2m Lgdpn/ZWTF6+KTdGy/kLUKKsNO4zNbkYiGCEctaRoHR1xNuJ9Kp6T27KZzPBE0nMARMR BxVIKGNbDvBd4NMSPPMR+ADxBKw3c7/k/dwICdXpmBmyqo2wfX+se0H1C2l8rKCFs7Sn FJVdwbOXKcDvUb+x03Cho0fM+6JgG0yVSeZtjdSq2My3gWDNrnhVZyXMmD4sHj/YH0G6 9PWKAfvoJTPxQBp32/8i0Jd7Rw9wwxgKRU9RCR7HTHnHMNghJiCX20+hAXtPDC+XAVs7 iIow== X-Gm-Message-State: APjAAAUdrfmAil9K9eWAR2kowDB6JbAma5g8r1R8Dd4R/F3Yklua3GDR 9HvP8bwFfB0cNwcciyy9Bxk0kMp/ X-Google-Smtp-Source: APXvYqwFCBO5hyfet3W1WHFKzyIH4Ndd/neVuTx3uu0wvJrvR5qA7G120GL5TnfpgpjOWpp47xu6aA== X-Received: by 2002:a1c:7fc3:: with SMTP id a186mr5558656wmd.151.1565103700841; Tue, 06 Aug 2019 08:01:40 -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.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Aug 2019 08:01:40 -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:32 +0200 Message-Id: <20190806150134.104222-6-christian.koenig@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190806150134.104222-1-christian.koenig@amd.com> References: <20190806150134.104222-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=kQ9oFDS/I3lsIGSETmAE0qxXzfKIwv2YeSX45z+1rwU=; b=i1cBb1BQCN0p4oigi/iL1jY9Ho82kwhliVr37bv5pVNV4lGHfgGAO5e2tp5LGhYirK GvjTL6iApeucBvKG2kg9ztQn5mKyjAw6BbGw6+gAadNS1A2mI4ni4s71DWfo3KQMNk85 CKVlnqevx663JQodzTby2c5zziquL5r6oRgVQI+HL7tzMidOg2OVWIq6G4ISmVO9zPS1 Yx+VET6ZJjOI7ICsip6/V1CYpAFrluAZEHvZq9HqFlni9TFeFVKQGcuXzTLOljSxvkJa IePV1EXoXoaPQXBfzhknFWitwHOMID+06JCPJMA6VmlYLMgEj5dBrjUWjsxI4jwBoT7P HLEw== Subject: [Intel-gfx] [PATCH 6/8] dma-buf: simplify reservation_object_get_fences_rcu a bit 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 We can add the exclusive fence to the list after making sure we got a consistent state. Signed-off-by: Christian König --- drivers/dma-buf/reservation.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c index 944d962ddddf..7505eb289023 100644 --- a/drivers/dma-buf/reservation.c +++ b/drivers/dma-buf/reservation.c @@ -453,13 +453,6 @@ int reservation_object_get_fences_rcu(struct reservation_object *obj, if (!dma_fence_get_rcu(shared[i])) break; } - - if (!pfence_excl && fence_excl) { - shared[i] = fence_excl; - fence_excl = NULL; - ++i; - ++shared_count; - } } if (i != shared_count || read_seqcount_retry(&obj->seq, seq)) { @@ -474,6 +467,11 @@ int reservation_object_get_fences_rcu(struct reservation_object *obj, rcu_read_unlock(); } while (ret); + if (pfence_excl) + *pfence_excl = fence_excl; + else if (fence_excl) + shared[++shared_count] = fence_excl; + if (!shared_count) { kfree(shared); shared = NULL; @@ -481,9 +479,6 @@ int reservation_object_get_fences_rcu(struct reservation_object *obj, *pshared_count = shared_count; *pshared = shared; - if (pfence_excl) - *pfence_excl = fence_excl; - return ret; } EXPORT_SYMBOL_GPL(reservation_object_get_fences_rcu);