From patchwork Tue Feb 21 09:30:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9584147 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 0F457602A7 for ; Tue, 21 Feb 2017 09:30:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DBAF2288AE for ; Tue, 21 Feb 2017 09:30:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D083B288E8; Tue, 21 Feb 2017 09:30:07 +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 9FA7F288AE for ; Tue, 21 Feb 2017 09:30:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DF9B76E5F9; Tue, 21 Feb 2017 09:30:04 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id F22126E5F9; Tue, 21 Feb 2017 09:30:03 +0000 (UTC) Received: by mail-wm0-x244.google.com with SMTP id v77so18585341wmv.0; Tue, 21 Feb 2017 01:30:03 -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; bh=wwTC6j8b1u5ZqnYduAuRG+Pa4FNFa5TtZAqvaOLWzos=; b=uwHBc6kS98r/FHkVU4ZeK+lqjEKgigaI/dUKSVMfiUX/Sq2Mskn6e6MryyBFcGxkBr RTKCLyWRg6Q0+TNF5uD3xGMXn1v2xJ6loF4e/PIciTCBP5AKmKWQFmjZXl3odnpvbdOB RYdG68XwWgbkUZ3knUV446RdD6HgPBNip/EGwhXOujPBnb9v0DYJIwVeoWZXfzgqy6on C2eF9pHUQsaVMSOTEOi4jWPQ0bgnbvGyBEqbk96f4Y1L5z0pUxgjV3frk9bv+lh24iuy eFyMU8JL4bCb+5uDxvTr+7TzM4kF4/SHj/No4a53loUB6VdVrHZmj5jfO9ZWIdCAtTiV Rcyw== 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; bh=wwTC6j8b1u5ZqnYduAuRG+Pa4FNFa5TtZAqvaOLWzos=; b=hLkh5Da4DMYgDasF3xfiq3mX4deivJkIVai/jLMDtW/B7oztqNNydhPcVg9+F7tHZe tlfqU5KYRHyQ/dX8V/nmC3A6kpXqB3S19b7JYvovLHHwusZuT9SoLOLpZ7ik5La1EElz K50MmBQr8KDaKaKSwD8EaExMLBklj8wKhXaGql5nMxKJg/N9hUACJp4wN992sJV3Rnpe zcOI3IazhLmzY4RSRCG4JOZiVJ8EYItPNcNeb8hgfKVKzyt356N538HGlCqpvtMCh5fW JOU5800n8pdTMF4+DGY3j/DRHVRctG0AVnC/p+zrzRgTAwcLA0ziqR90bgkU7pNW/Q4c LfnA== X-Gm-Message-State: AMke39nnIPB2ztZ1DoN4wSG6R+22Czleq0R9cY0iUTfqSsuIemeIPXb4gpctqwOgtAEazg== X-Received: by 10.28.22.146 with SMTP id 140mr13389426wmw.22.1487669402453; Tue, 21 Feb 2017 01:30:02 -0800 (PST) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id v128sm16825929wmv.2.2017.02.21.01.30.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Feb 2017 01:30:01 -0800 (PST) From: Chris Wilson To: dri-devel@lists.freedesktop.org Subject: [PATCH] dma-buf/reservation: Wrap ww_mutex_trylock Date: Tue, 21 Feb 2017 09:30:00 +0000 Message-Id: <20170221093000.22802-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.11.0 Cc: Daniel Vetter , intel-gfx@lists.freedesktop.org, Joonas Lahtinen 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-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. 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..28d544364e52 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. + * + * Returns true if the lock was acquired, false otherwise. + */ +static inline 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 *