From patchwork Mon Aug 5 15:45:53 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: 11085725 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 04EA5912 for ; Fri, 9 Aug 2019 09:16:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA49028B38 for ; Fri, 9 Aug 2019 09:16:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF21E28C3E; Fri, 9 Aug 2019 09:16:12 +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 A406128B38 for ; Fri, 9 Aug 2019 09:16:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F32786ED49; Fri, 9 Aug 2019 09:15:46 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by gabe.freedesktop.org (Postfix) with ESMTPS id 883946E4A5; Mon, 5 Aug 2019 15:46:00 +0000 (UTC) Received: by mail-wr1-x441.google.com with SMTP id f9so5985566wre.12; Mon, 05 Aug 2019 08:46:00 -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=a4ZZo1KUS4v5eA927ZZztm7GQeLvgm0C/yGY+IBScNk=; b=HgHKz0ky44AVh2fiF8KDNj4qxdbRxE6lK55M9xRUtlm/jAT8JjJdYxeFXB2G/7+v4Q ph9lqFD2uwdG65UhNjOFRsX96TQCbBC886ks9nRJxmeZwoYZW1v5dbkgfg3BYpTazj4R gwPwcS/FPgo5KkAgIqA63G9ClD5eFIvGi2XRzo1BlJN4izSBl30DtekpLpvE+LhCwIAG ng4syeAGlSR03Lt/fVx6Kg4Lwrrb6UJv4UrXgmDdFX1vTl2mcwJnWcp3FyQwdLKNrjkz HeDXMA2NM1HHOBDU1KEUISxxPhQa19IAziJ53cm9RLYQ8t+qDmJdkND7draGItHfZ/te UuTw== X-Gm-Message-State: APjAAAXxU0KsNHbV+/SM5Mn5sOw4l9/gAvzLtUkpHkb6KN8xpJaEfAHC 6+SBATfCY+m1D3JrGq1fhgq7PxV5 X-Google-Smtp-Source: APXvYqyKtWz2oAW1/rv7hSkrkd2h3z7inIhLfCt8NJpgwvZgCZQvI+8ki0rdQlhG46LV+7qztvPF4w== X-Received: by 2002:a5d:6389:: with SMTP id p9mr1126311wru.297.1565019958875; Mon, 05 Aug 2019 08:45:58 -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.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Aug 2019 08:45:58 -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:53 +0200 Message-Id: <20190805154554.3476-4-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=a4ZZo1KUS4v5eA927ZZztm7GQeLvgm0C/yGY+IBScNk=; b=c8lKjumQ802qAfCvsp5WXfL6BHjFMbZ03rSET63kgSVQxwL/Si4kP11+H9pHt9SeC8 NBKpD0r8ULstE6FSP+fQdLCvtGGyH/qMhQUScICPY7e3ZLr8bDXUj4R1Scn6dYI4pOyn eL+OWq0smywS6iFlWZQnphIY48FUqJ1Iv4D+S0hk/xSnywiDLWApC4PmPVswHUxzp2Dt AdA6MQwxUQquKYm66Vcv4+HKNz6Bcw1v1VndIYGPs7OEDiryqfcp8AaS+qzZQQWKhyD4 SI4xZu/j0j7DktO6fvtfDA9+/bdcwg5kx5ZXqeP2JEQpJHyjvFJGoA1i9OUPXvDWBwmr UhNw== Subject: [Intel-gfx] [PATCH 4/5] 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 6eaca469005f..69c826553c72 100644 --- a/drivers/dma-buf/reservation.c +++ b/drivers/dma-buf/reservation.c @@ -426,13 +426,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)) { @@ -447,6 +440,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; @@ -454,9 +452,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);