From patchwork Mon Nov 14 20:40:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9428329 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 B454C602F0 for ; Mon, 14 Nov 2016 20:41:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4CEB28AD3 for ; Mon, 14 Nov 2016 20:41:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 982EB28ADD; Mon, 14 Nov 2016 20:41: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 4148E28AD3 for ; Mon, 14 Nov 2016 20:41:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 58D7E6E50A; Mon, 14 Nov 2016 20:41:16 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x234.google.com (mail-wm0-x234.google.com [IPv6:2a00:1450:400c:c09::234]) by gabe.freedesktop.org (Postfix) with ESMTPS id 32F646E50B for ; Mon, 14 Nov 2016 20:41:10 +0000 (UTC) Received: by mail-wm0-x234.google.com with SMTP id f82so122498171wmf.1 for ; Mon, 14 Nov 2016 12:41:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=cZ+CbopMWd+nUmmb5sd4fRRYYE/GleQMD96raMeFx2M=; b=g5jk4qXafZzjuwoynhhtDpgtAPFy2irRPvdGsRFysPgXMly7vNxqB0QcTTjQsVho4H J7VFKUsLzx9z7AoTjGpcjpBNWjIEoX/PTG8F2x20GCuq2GLaT0ip+ZVkIFe2WVzgi9+A Wb3iB8zCYap2urXtSDDoCoPweiRQG9cSff1CUXYj4qm0MU8DSso6rdTCXAKR9b/e/4wV oiVP1vJhh3e3KltyXOaOdlCazKPb4qgfxENsqUsxv65/d1oSycmDDMVNyhd8a2HiT/y8 jOqk9WmwQ/C0Qxv0LoPMlljtchtEe9X+POak5cx5jW1cHGnoB22gMZ3iJynBHLyq5Wnw SZxQ== 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:subject:date:message-id :in-reply-to:references; bh=cZ+CbopMWd+nUmmb5sd4fRRYYE/GleQMD96raMeFx2M=; b=XeIG70vKFJUkvCYK+VYdxxzyOSOPP4h9BThTljJuvSYvFTDBy/ZgyPbQxm7hBxq3v7 8E6wGeARQzM7qZVr6qb3lJ8LqikicB4Q25nZ6sv93K7BM1j2KIgKO3M2q9wpJz26Gnf5 hMQAae9UTQNx1IL7JLFL1XAsN46aBInJMwOHstpD159PqGuIJVk+Eq2wU1QpuP6iyw6T y56QdQZchrJi/JjFY+Dd2t8phsify/LkrT1zywGI32/kC3znxsYSh0MhM3VqBF9ZS9Uf 0lqTiIiYzWozSEWgcqWYUWh+dF/mw6qFFXF6G+2HRc7ehEzt0VrLIQYygrRpoVVNl2EL zDHQ== X-Gm-Message-State: ABUngvdbGD2UY5KuPNXMb1Zssb+rHSE+tePRA0Iar0d4TKfpuUr5VS3ES0p6PE6f8vivnQ== X-Received: by 10.28.161.67 with SMTP id k64mr230991wme.69.1479156068513; Mon, 14 Nov 2016 12:41:08 -0800 (PST) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id j6sm30628364wjk.25.2016.11.14.12.41.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Nov 2016 12:41:07 -0800 (PST) From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Mon, 14 Nov 2016 20:40:57 +0000 Message-Id: <20161114204105.29171-2-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161114204105.29171-1-chris@chris-wilson.co.uk> References: <20161114204105.29171-1-chris@chris-wilson.co.uk> Subject: [Intel-gfx] [CI 02/10] drm/i915: Create distinct lockclasses for execution vs user timelines 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 order to simplify the lockdep annotation, as they become more complex in the future with deferred execution and multiple paths through the same functions, create a separate lockclass for the user timeline and the hardware execution timeline. We should only ever be locking the user timeline and the execution timeline in parallel so we only need to create two lock classes, rather than a separate class for every timeline. v2: Rename the lock classes to be more consistent with other lockdep. Signed-off-by: Chris Wilson Reviewed-by: Joonas Lahtinen --- drivers/gpu/drm/i915/i915_gem.c | 4 +--- drivers/gpu/drm/i915/i915_gem_request.c | 2 +- drivers/gpu/drm/i915/i915_gem_timeline.c | 33 ++++++++++++++++++++++++++++---- drivers/gpu/drm/i915/i915_gem_timeline.h | 1 + 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index ed4465d22dde..a6ae3efd1d6a 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -4432,9 +4432,7 @@ i915_gem_load_init(struct drm_device *dev) mutex_lock(&dev_priv->drm.struct_mutex); INIT_LIST_HEAD(&dev_priv->gt.timelines); - err = i915_gem_timeline_init(dev_priv, - &dev_priv->gt.global_timeline, - "[execution]"); + err = i915_gem_timeline_init__global(dev_priv); mutex_unlock(&dev_priv->drm.struct_mutex); if (err) goto err_requests; diff --git a/drivers/gpu/drm/i915/i915_gem_request.c b/drivers/gpu/drm/i915/i915_gem_request.c index 5050464c5401..f25b537d6e64 100644 --- a/drivers/gpu/drm/i915/i915_gem_request.c +++ b/drivers/gpu/drm/i915/i915_gem_request.c @@ -346,7 +346,7 @@ submit_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state) request->ring->vaddr + request->postfix); engine->submit_request(request); - spin_lock_nested(&request->timeline->lock, SINGLE_DEPTH_NESTING); + spin_lock(&request->timeline->lock); list_move_tail(&request->link, &timeline->requests); spin_unlock(&request->timeline->lock); diff --git a/drivers/gpu/drm/i915/i915_gem_timeline.c b/drivers/gpu/drm/i915/i915_gem_timeline.c index fc8f13a79f8f..bf8a471b61e6 100644 --- a/drivers/gpu/drm/i915/i915_gem_timeline.c +++ b/drivers/gpu/drm/i915/i915_gem_timeline.c @@ -24,9 +24,11 @@ #include "i915_drv.h" -int i915_gem_timeline_init(struct drm_i915_private *i915, - struct i915_gem_timeline *timeline, - const char *name) +static int __i915_gem_timeline_init(struct drm_i915_private *i915, + struct i915_gem_timeline *timeline, + const char *name, + struct lock_class_key *lockclass, + const char *lockname) { unsigned int i; u64 fences; @@ -47,8 +49,11 @@ int i915_gem_timeline_init(struct drm_i915_private *i915, tl->fence_context = fences++; tl->common = timeline; - +#ifdef CONFIG_DEBUG_SPINLOCK + __raw_spin_lock_init(&tl->lock.rlock, lockname, lockclass); +#else spin_lock_init(&tl->lock); +#endif init_request_active(&tl->last_request, NULL); INIT_LIST_HEAD(&tl->requests); } @@ -56,6 +61,26 @@ int i915_gem_timeline_init(struct drm_i915_private *i915, return 0; } +int i915_gem_timeline_init(struct drm_i915_private *i915, + struct i915_gem_timeline *timeline, + const char *name) +{ + static struct lock_class_key class; + + return __i915_gem_timeline_init(i915, timeline, name, + &class, "&timeline->lock"); +} + +int i915_gem_timeline_init__global(struct drm_i915_private *i915) +{ + static struct lock_class_key class; + + return __i915_gem_timeline_init(i915, + &i915->gt.global_timeline, + "[execution]", + &class, "&global_timeline->lock"); +} + void i915_gem_timeline_fini(struct i915_gem_timeline *tl) { lockdep_assert_held(&tl->i915->drm.struct_mutex); diff --git a/drivers/gpu/drm/i915/i915_gem_timeline.h b/drivers/gpu/drm/i915/i915_gem_timeline.h index f2bf7b1d49a1..98d99a62b4ae 100644 --- a/drivers/gpu/drm/i915/i915_gem_timeline.h +++ b/drivers/gpu/drm/i915/i915_gem_timeline.h @@ -67,6 +67,7 @@ struct i915_gem_timeline { int i915_gem_timeline_init(struct drm_i915_private *i915, struct i915_gem_timeline *tl, const char *name); +int i915_gem_timeline_init__global(struct drm_i915_private *i915); void i915_gem_timeline_fini(struct i915_gem_timeline *tl); #endif