From patchwork Tue Aug 6 15:01:34 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: 11085789 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 A22B614F7 for ; Fri, 9 Aug 2019 09:16:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9283028B38 for ; Fri, 9 Aug 2019 09:16:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 863E728C3E; Fri, 9 Aug 2019 09:16: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 3D44F28B38 for ; Fri, 9 Aug 2019 09:16:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C82EE6ED5D; Fri, 9 Aug 2019 09:15:48 +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 3EB1A6E3CB; Tue, 6 Aug 2019 15:01:44 +0000 (UTC) Received: by mail-wm1-x344.google.com with SMTP id v15so78568317wml.0; Tue, 06 Aug 2019 08:01:44 -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=D94FqstqyitIQXHeEQsOPjB7sJ7kjAHDkqtPAZA0I+c=; b=dct6UAyh3vbJoclyZY4pUdqh/DCpK7qo6GECq0PQ8+11sap4xUAlzz7/OzxmWtjO2X RqM6ku7OzF/QARKZRuM2Eeh2yInb9olB3Ov+D0s6qaU4pqW7hy1PGRTGiX4azDnVEQcx pRhmW+jTvS+a0YY8QdkqD7T5/pMFgwu04ta/kqu2BbP88jnbNTZmGE6X3wB7/bLl45bE gjnLnhl/7i/NaiRKI5/IM6ra6+V0LBcQGhQ2mfqKiMfj0xA73MjS032as1ikfA3a+LD8 6t8FgsF1DHJAy13ecg4ulJ/nYuY2pmvJCeHieFZghBxgm2euYAp/IWWTfcP63sJSDbj1 YEwQ== X-Gm-Message-State: APjAAAUmvdktdmYqQ1bgR9Jn7/vD1F2sT/KPVY2TJZHrAzId4oQNeINE 6R9mXnR3KwT7xjREqvbhO/NpYK6h X-Google-Smtp-Source: APXvYqxVBfSBzWr806NXfxriD36Qyrcq50LCUciaqzuU1GpHszpLqFGl7aaAig4jn/oBkn9mupsKrg== X-Received: by 2002:a05:600c:20c1:: with SMTP id y1mr5463840wmm.10.1565103702622; Tue, 06 Aug 2019 08:01:42 -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.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Aug 2019 08:01:41 -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:34 +0200 Message-Id: <20190806150134.104222-8-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=D94FqstqyitIQXHeEQsOPjB7sJ7kjAHDkqtPAZA0I+c=; b=Jo7LZ0mEPDJXyAIZ6sBJ5tR9F/lQmWIKR2ELB0DuExXdm13zXgXAol1XjMsLH+NY4v FzPP77jOfHKPgZfuUdvFBvYNilFsayxwmTvHo8Key3ombSEUz3X2KjUQxZoTRQ4lV5gI KTWygsFQdZlKzKhoEU9xyn6mi0/f/nBZAyBEcWjYin4YNiS2bg0y1iS6fuJ2yWS4A/// uevOjWsE5vZLQgDoc4/Buzq0Z6L8jCR5bu1yxiYwU9d9ULyUKaM2SDSMcbnRZwRabBmK 6mvKAxK1C0vEoBDLCBs9r36iIyQ2ERg4Gumlhr+RZqjvkHQ9YdRkEbLFgiGu2tiwxEMV lHsQ== Subject: [Intel-gfx] [PATCH 8/8] dma-buf: nuke reservation_object seq number 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 The only remaining use for this is to protect against setting a new exclusive fence while we grab both exclusive and shared. That can also be archived by looking if the exclusive fence has changed or not after completing the operation. Signed-off-by: Christian König --- drivers/dma-buf/reservation.c | 20 +++----------------- include/linux/reservation.h | 9 ++------- 2 files changed, 5 insertions(+), 24 deletions(-) diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c index 839d72af7ad8..43549a4d6658 100644 --- a/drivers/dma-buf/reservation.c +++ b/drivers/dma-buf/reservation.c @@ -49,12 +49,6 @@ DEFINE_WD_CLASS(reservation_ww_class); EXPORT_SYMBOL(reservation_ww_class); -struct lock_class_key reservation_seqcount_class; -EXPORT_SYMBOL(reservation_seqcount_class); - -const char reservation_seqcount_string[] = "reservation_seqcount"; -EXPORT_SYMBOL(reservation_seqcount_string); - /** * reservation_object_list_alloc - allocate fence list * @shared_max: number of fences we need space for @@ -103,9 +97,6 @@ static void reservation_object_list_free(struct reservation_object_list *list) void reservation_object_init(struct reservation_object *obj) { ww_mutex_init(&obj->lock, &reservation_ww_class); - - __seqcount_init(&obj->seq, reservation_seqcount_string, - &reservation_seqcount_class); RCU_INIT_POINTER(obj->fence, NULL); RCU_INIT_POINTER(obj->fence_excl, NULL); } @@ -282,12 +273,10 @@ void reservation_object_add_excl_fence(struct reservation_object *obj, dma_fence_get(fence); preempt_disable(); - write_seqcount_begin(&obj->seq); - /* write_seqcount_begin provides the necessary memory barrier */ RCU_INIT_POINTER(obj->fence_excl, fence); + /* pointer update must be visible before we modify the shared_count */ if (old) - old->shared_count = 0; - write_seqcount_end(&obj->seq); + smp_store_mb(old->shared_count, 0); preempt_enable(); /* inplace update, no shared fences */ @@ -370,11 +359,8 @@ int reservation_object_copy_fences(struct reservation_object *dst, old = reservation_object_get_excl(dst); preempt_disable(); - write_seqcount_begin(&dst->seq); - /* write_seqcount_begin provides the necessary memory barrier */ RCU_INIT_POINTER(dst->fence_excl, new); - RCU_INIT_POINTER(dst->fence, dst_list); - write_seqcount_end(&dst->seq); + rcu_assign_pointer(dst->fence, dst_list); preempt_enable(); reservation_object_list_free(src_list); diff --git a/include/linux/reservation.h b/include/linux/reservation.h index b8b8273eef00..1dfaf7b1f1da 100644 --- a/include/linux/reservation.h +++ b/include/linux/reservation.h @@ -46,8 +46,6 @@ #include extern struct ww_class reservation_ww_class; -extern struct lock_class_key reservation_seqcount_class; -extern const char reservation_seqcount_string[]; /** * struct reservation_object_list - a list of shared fences @@ -71,7 +69,6 @@ struct reservation_object_list { */ struct reservation_object { struct ww_mutex lock; - seqcount_t seq; struct dma_fence __rcu *fence_excl; struct reservation_object_list __rcu *fence; @@ -155,13 +152,11 @@ reservation_object_fences(struct reservation_object *obj, struct dma_fence **excl, struct reservation_object_list **list) { - unsigned int seq; - do { - seq = read_seqcount_begin(&obj->seq); *excl = rcu_dereference(obj->fence_excl); *list = rcu_dereference(obj->fence); - } while (read_seqcount_retry(&obj->seq, seq)); + smp_rmb(); /* See reservation_object_add_excl_fence */ + } while (rcu_access_pointer(obj->fence_excl) != *excl); } /**