From patchwork Thu Aug 4 19:52:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9264241 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 A6DB960839 for ; Thu, 4 Aug 2016 19:53:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 993322841C for ; Thu, 4 Aug 2016 19:53:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E43128425; Thu, 4 Aug 2016 19:53:36 +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]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42A552841C for ; Thu, 4 Aug 2016 19:53:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 91C4E6EA58; Thu, 4 Aug 2016 19:53:20 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id A637F6EA40 for ; Thu, 4 Aug 2016 19:53:02 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id o80so708593wme.0 for ; Thu, 04 Aug 2016 12:53:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=SKiYSBKe8fMsemrOJ3PnnsBK/kECnYgFoBkW/yCSZhs=; b=GFj37JNRAMgJONBJjcKyydYGwaJ28AR1aopIACFDyg0TQRPUtrlfSX9s2RZvqF3IBJ i1vdVfGnRKQYUqGSlnk252rImapV+OD76saT7ba74mCSTbCNYSekFcPO7rWuc87adNJt /YZ/S2ye3LQPi5ANoN4f6X35oaUIWiNXe3Vp7OBuSgPMrOJY+ZjBmsisSnaXpQTX9QmU kHautU/7u2T3DODRlP1otEvcDu59pRGM5G1twspJ6dwOsidA5dKR/fLu2KyLx38hkilJ Mr4Q6b1cBUNFuoldwWTCPKColkOIx7JfNQGYWOk5Ykm/UZdF/f+y8OyXAGnqbtfTvo7r 6Iww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=SKiYSBKe8fMsemrOJ3PnnsBK/kECnYgFoBkW/yCSZhs=; b=Yb7DepFMIW8mCCNHaO/MJBps9zWRxtaL/c61afXj8XKRJ7YEl5X3exkjOo7ifzqAT6 +2ThPLZB9IpYv3VxpOBoUsXmtNZ3bu2gn5dYMbysw6YQEGo+Cz6uOQHg1gIuEsx7AFz6 4BT0tPS7qpUz7EfqTvnhwl9VGFK93UYq52dEKAVz7orslTay1tLnnCZ2bfLDF/3dBs/F /w5LmbaDTncats6sBCLvLGnr9tBSkmkpzzRn/hFzlnlN3cQVKwK0cP6L1mkWqPrTY1IN 4WdxCPlm1zMNKYRnH3/+LBMUeoRB8amt/KZfK0XGNsVm+22Enq2vb/KzYz6VK7nwGCLl YanQ== X-Gm-Message-State: AEkooutuu3XJavVJQK2qERfd+P4Z3tAOwA8XyqaDz5TeixF1SpFdszAnrVmjXEnXmm9tHQ== X-Received: by 10.194.175.201 with SMTP id cc9mr67720017wjc.38.1470340379039; Thu, 04 Aug 2016 12:52:59 -0700 (PDT) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id i3sm14301931wjd.31.2016.08.04.12.52.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Aug 2016 12:52:58 -0700 (PDT) From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Thu, 4 Aug 2016 20:52:29 +0100 Message-Id: <1470340352-16118-17-git-send-email-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1470340352-16118-1-git-send-email-chris@chris-wilson.co.uk> References: <1470340352-16118-1-git-send-email-chris@chris-wilson.co.uk> Subject: [Intel-gfx] [PATCH 16/19] drm/i915: Remove locking for get_tiling 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 Since we are not concerned with userspace racing itself with set-tiling (the order is indeterminant even if we take a lock), then we can safely read back the single obj->tiling_mode and do the static lookup of swizzle mode without having to take a lock. get-tiling is reasonably frequent due to the back-channel passing around of tiling parameters in DRI2/DRI3. v2: Make tiling_mode a full unsigned int so that we can trivially use it with READ_ONCE(). Separating it out into manual control over the flags field was too noisy for a simple patch. Note that we could use the lower bits of obj->stride for the tiling mode. Signed-off-by: Chris Wilson Reviewed-by: Joonas Lahtinen --- drivers/gpu/drm/i915/i915_drv.h | 15 ++++++++------- drivers/gpu/drm/i915/i915_gem_tiling.c | 10 +++------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 31a614fe9ed7..f18d8761305c 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -2183,10 +2183,6 @@ struct drm_i915_gem_object { unsigned int madv:2; /** - * Current tiling mode for the object. - */ - unsigned int tiling_mode:2; - /** * Whether the tiling parameters for the currently associated fence * register have changed. Note that for the purposes of tracking * tiling changes we also treat the unfenced register, the register @@ -2218,6 +2214,14 @@ struct drm_i915_gem_object { atomic_t frontbuffer_bits; + /** + * Current tiling mode for the object. + */ + unsigned int tiling_mode; + + /** Current tiling stride for the object, if it's tiled. */ + uint32_t stride; + unsigned int has_wc_mmap; /** Count of VMA actually bound by this object */ unsigned int bind_count; @@ -2245,9 +2249,6 @@ struct drm_i915_gem_object { struct i915_gem_active last_write; struct i915_gem_active last_fence; - /** Current tiling stride for the object, if it's tiled. */ - uint32_t stride; - /** References from framebuffers, locks out tiling changes. */ unsigned long framebuffer_references; diff --git a/drivers/gpu/drm/i915/i915_gem_tiling.c b/drivers/gpu/drm/i915/i915_gem_tiling.c index b7f9875f69b4..c0e01333bddf 100644 --- a/drivers/gpu/drm/i915/i915_gem_tiling.c +++ b/drivers/gpu/drm/i915/i915_gem_tiling.c @@ -303,10 +303,8 @@ i915_gem_get_tiling(struct drm_device *dev, void *data, if (!obj) return -ENOENT; - mutex_lock(&dev->struct_mutex); - - args->tiling_mode = obj->tiling_mode; - switch (obj->tiling_mode) { + args->tiling_mode = READ_ONCE(obj->tiling_mode); + switch (args->tiling_mode) { case I915_TILING_X: args->swizzle_mode = dev_priv->mm.bit_6_swizzle_x; break; @@ -330,8 +328,6 @@ i915_gem_get_tiling(struct drm_device *dev, void *data, if (args->swizzle_mode == I915_BIT_6_SWIZZLE_9_10_17) args->swizzle_mode = I915_BIT_6_SWIZZLE_9_10; - i915_gem_object_put(obj); - mutex_unlock(&dev->struct_mutex); - + i915_gem_object_put_unlocked(obj); return 0; }