From patchwork Thu Mar 31 20:23:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 8716471 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 02FCD9F30C for ; Thu, 31 Mar 2016 20:24:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 11A5D202E5 for ; Thu, 31 Mar 2016 20:24:09 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 3BC63202F0 for ; Thu, 31 Mar 2016 20:24:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 01E4E6E2A4; Thu, 31 Mar 2016 20:24:00 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qg0-x229.google.com (mail-qg0-x229.google.com [IPv6:2607:f8b0:400d:c04::229]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4568E6E2A7 for ; Thu, 31 Mar 2016 20:23:57 +0000 (UTC) Received: by mail-qg0-x229.google.com with SMTP id j35so76826188qge.0 for ; Thu, 31 Mar 2016 13:23:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hGoSwv1FRDZ81bqBJzEW+oGaL3udB88ka22BgL6MHoE=; b=oKlPTH3mh0YWS8aqQ6cetLLRHSNPL9UunLtt67vdkIr8Gzhe+QqTwyQ92OXiJF+5HS MEAAaC55DFssGuy+dktCFgS2BZn23y7vcnJPfgSJygpTJpM65xrV97bAlmMAH22agmTj Yy0CY3EFy5nSJA6I2CMoo9BvBurI94dN/OcaQXFMmPv84etxVGnF+h0pWWmuKSaUD8L2 CiJF+7ItAFaKhE1hXzm1V2SyCVaHlxFgpoYBnOzdI+Vu7NSzoPTru+2d75rhZczzeg6m yER/9FD10jynn9aVrYNx40M0K+ZT+MgGmqROD43jKHpkULLRmhI2mYq5SiL2O9kszprG wqNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hGoSwv1FRDZ81bqBJzEW+oGaL3udB88ka22BgL6MHoE=; b=Ag1OLEluLWaB8l/jlZ8FnAsIwNg1oz7ExwicnzGXc9cMg60XMT2fF1psjP1wFblF8q i3Tc8gUGVEuR9P2Prmo1/Kbx4rpXyjPiaCS3cIfmQB0UVzFGHUKKWQVDoD66TWaggelW KSVCHhrU2nQLUt1OSB0gL/4HpGQ8zldqbddcU7270diK0FKc57OjjFlAdS7bdEwRZ4kS Gj2toxUeortnDGP+MrnOxGyIL/yrfWCqhOszschNP+wIvtOp1eVLT56OtpCVbaEeCLJN t7sTaIWgW3XOks+KqaQwpnq3LNkhOWOGo+QJGEobyk9yl4JCJMOcIFcC3rSiIUuL/YxF 7cTQ== X-Gm-Message-State: AD7BkJIxoR4YJIZji3Q8LGd6YxGtXjeQdxgk0pdOp3XG50OfM2h3x9T6juUYSznJyP1Z5w== X-Received: by 10.140.32.116 with SMTP id g107mr1732935qgg.5.1459455835610; Thu, 31 Mar 2016 13:23:55 -0700 (PDT) Received: from localhost (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id h5sm4632775qge.48.2016.03.31.13.23.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Mar 2016 13:23:54 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Subject: [PATCH 01/11] reservation: add reservation_object_get_excl_unlocked() Date: Thu, 31 Mar 2016 16:23:51 -0400 Message-Id: <1459455831-16085-1-git-send-email-robdclark@gmail.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1458342904-23326-2-git-send-email-robdclark@gmail.com> References: <1458342904-23326-2-git-send-email-robdclark@gmail.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In the atomic modesetting path, each driver simply wants to grab a ref to the exclusive fence from a reservation object to store in the incoming drm_plane_state, without doing the whole RCU dance. Since each driver will need to do this, lets make a helper. v2: rename to _rcu instead of _unlocked to be more consistent Signed-off-by: Rob Clark --- Note that danvet also suggested addition of headerdoc. But it was a trap! In the process I discovered that some files were missing from the DocBook tmpl, some fixup needed, and complete lack of reservation related headerdoc. So the patchset to fixup all that will follow in a few minutes. But danvet's punishment for tricking me into fixing that all up is that the headerdoc he wants applies on top of the patch that I want ;-) include/linux/reservation.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/reservation.h b/include/linux/reservation.h index 5a0b64c..49d0576 100644 --- a/include/linux/reservation.h +++ b/include/linux/reservation.h @@ -120,6 +120,24 @@ reservation_object_get_excl(struct reservation_object *obj) reservation_object_held(obj)); } +static inline struct fence * +reservation_object_get_excl_rcu(struct reservation_object *obj) +{ + struct fence *fence; + unsigned seq; +retry: + seq = read_seqcount_begin(&obj->seq); + rcu_read_lock(); + fence = rcu_dereference(obj->fence_excl); + if (read_seqcount_retry(&obj->seq, seq)) { + rcu_read_unlock(); + goto retry; + } + fence = fence_get(fence); + rcu_read_unlock(); + return fence; +} + int reservation_object_reserve_shared(struct reservation_object *obj); void reservation_object_add_shared_fence(struct reservation_object *obj, struct fence *fence);