From patchwork Tue Feb 21 12:48:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9584479 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8A192600C1 for ; Tue, 21 Feb 2017 12:48:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BD2C28528 for ; Tue, 21 Feb 2017 12:48:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7098D28669; Tue, 21 Feb 2017 12:48:22 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham 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 06B8A28528 for ; Tue, 21 Feb 2017 12:48:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 936246E2A1; Tue, 21 Feb 2017 12:48:20 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id D432F6E2A1 for ; Tue, 21 Feb 2017 12:48:18 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id v77so19539428wmv.0 for ; Tue, 21 Feb 2017 04:48:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=FWWcEl2IGiGOUWPE659jd6WUwtyZgJr6UExjiPX7wM4=; b=sFhfEaj1pRu+tjK6sAZoyGLK3OMV7I+T0+1c3xsym8RddmejZo/ecNMZCGnReMLgjo Oxu8Rom/opeB2A6KNvwOHbQVdKQS5gvm2X4YlQzjN9e+OBJN9J7qp52Qp4FoEGCjGCQG HcWY/prrXhyJ4pkgsYLTnvDnWCIe4F0raH8+SNeYnD48fJGSU7HB2Gu1ujshqxv/w+SK xESL9D5K6PhmLH2VwAM/+BiYpzFq3H0y8EK2QdGntE7//TKlvSPi+XpjUfiOhU1lq0HW imBgGQ3si5jNRW8ZCtAMW5Ph0LYCjA+t0WFcJmX6S/8mSOz3i4wV0RrelCUg9nSeaH9c E+Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=FWWcEl2IGiGOUWPE659jd6WUwtyZgJr6UExjiPX7wM4=; b=bA6T+V5Isg7UirPvNX2mW9RBq1++ujokr7ZU0lS7gKy3UHLX1JBp0OUbOCmZ6uWFKM oJuYtvEwVmrZLw9u6xxjy0GmomMpgvXvQizwt2i0Fx4vn7OkTEKEh+GKCSCsuEWx/z18 H+aivTDofMN+NNfPxj39nV9+jWiLplCZ11XIVWdFSphxO1TWnD8JxYgeErdX/XW2IzTL CcBJAKCMygQg/d+A4wODH87BB358uLo8ntec1RTOOxoFClgx9rJGQRU+dC5a3xHrLPAW OLAQXN669fdPgIFn5oFo57kN6xM+ZCuINx7JFyz6k6tp4TU+aPYcgtr8AbKJNPawz1yC /PWQ== X-Gm-Message-State: AMke39l2ZGQeCfCPKjL8OWWeQ7o7FLiEgadqLZoWXojI1P3UuZAvhywJsyD/bexMNfbgUg== X-Received: by 10.28.69.202 with SMTP id l71mr25374235wmi.68.1487681297289; Tue, 21 Feb 2017 04:48:17 -0800 (PST) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id 10sm17498815wmk.26.2017.02.21.04.48.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Feb 2017 04:48:16 -0800 (PST) From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Tue, 21 Feb 2017 12:48:13 +0000 Message-Id: <20170221124813.776-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <1487680687.3137.3.camel@linux.intel.com> References: <1487680687.3137.3.camel@linux.intel.com> Cc: Daniel Vetter , Sumit Semwal Subject: [Intel-gfx] [PATCH v2] dma-buf/reservation: Wrap ww_mutex_trylock X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP In a similar fashion to reservation_object_lock() and reservation_object_unlock(), ww_mutex_trylock is also useful and so is worth wrapping for consistency. v2: Add __must_check Signed-off-by: Chris Wilson Cc: Sumit Semwal Cc: Joonas Lahtinen Cc: Daniel Vetter Reviewed-by: Joonas Lahtinen --- include/linux/reservation.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/linux/reservation.h b/include/linux/reservation.h index 24da961b085d..dcac9a4d9bad 100644 --- a/include/linux/reservation.h +++ b/include/linux/reservation.h @@ -151,6 +151,26 @@ reservation_object_lock(struct reservation_object *obj, } /** + * reservation_object_trylock - trylock the reservation object + * @obj: the reservation object + * + * Tries to lock the reservation object for exclusive access and modification. + * Note, that the lock is only against other writers, readers will run + * concurrently with a writer under RCU. The seqlock is used to notify readers + * if they overlap with a writer. + * + * Also note that since no context is provided, no deadlock protection is + * possible, see ww_mutex_trylock(). + * + * Returns true if the lock was acquired, false otherwise. + */ +static inline __must_check bool +reservation_object_trylock(struct reservation_object *obj) +{ + return ww_mutex_trylock(&obj->lock); +} + +/** * reservation_object_unlock - unlock the reservation object * @obj: the reservation object *