From patchwork Tue Jun 30 13:53:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Zanoni X-Patchwork-Id: 6696171 Return-Path: X-Original-To: patchwork-intel-gfx@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 A53899F3A0 for ; Tue, 30 Jun 2015 13:54:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C0E7920457 for ; Tue, 30 Jun 2015 13:54:13 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id E0D3120495 for ; Tue, 30 Jun 2015 13:54:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5B12D6E6FD; Tue, 30 Jun 2015 06:54:12 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-qg0-f51.google.com (mail-qg0-f51.google.com [209.85.192.51]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1FAA06E6FD for ; Tue, 30 Jun 2015 06:54:11 -0700 (PDT) Received: by qgii30 with SMTP id i30so4071840qgi.1 for ; Tue, 30 Jun 2015 06:54:10 -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=GlYZe7tLNazmWYUGzVGqJ1+/BjVxUH5aiu4sFrMXx1o=; b=L462vU5kj6VpwOTK8UolyZfjRNECAg5bknfBh3LMZIlK0EANa3hITrzVLECkfqCTd6 S7saEmcDQcNuX6Mlt+d380hRphHk1XoEfbUdkZRbd2vNFirYpmyUOcek8Ob7q1Qyuejo 4+fAiGeS1SeCd4/0keYPK2yGzCrYGsWIZraEOrxq4JmqTqDwSDJRE1IeyR0ILQBjloEs BgCiQzwRTvGf6Il04DtwliIdAc5oW3VHk4rRdQwPaHAhkIRPgLGgtNQUxtpBKXCjOs1h xvNxvTE2zKKhpVy/ZUZbOHvgqQY1dQaa9xsOZ7eOnYKGCY36V+ZtPIbeO8/wbINuHVFm AITg== X-Received: by 10.140.109.199 with SMTP id l65mr25951149qgf.91.1435672450469; Tue, 30 Jun 2015 06:54:10 -0700 (PDT) Received: from localhost.localdomain (r130-pw-tresbarras.ibys.com.br. [189.76.1.243]) by mx.google.com with ESMTPSA id e10sm4651585qka.40.2015.06.30.06.54.09 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 30 Jun 2015 06:54:10 -0700 (PDT) From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Date: Tue, 30 Jun 2015 10:53:10 -0300 Message-Id: <1435672392-7329-7-git-send-email-przanoni@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1435672392-7329-1-git-send-email-przanoni@gmail.com> References: <1435672392-7329-1-git-send-email-przanoni@gmail.com> Cc: Paulo Zanoni Subject: [Intel-gfx] [PATCH 6/8] drm/i915: add struct_mutex WARNs to i915_gem_stolen.c 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-Spam-Status: No, score=-4.7 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 From: Paulo Zanoni Let's make sure the future Paulos don't forget that we need struct_mutex when touching dev_priv->mm.stolen. Signed-off-by: Paulo Zanoni --- drivers/gpu/drm/i915/i915_gem_stolen.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c index 793bcba..cac1bce 100644 --- a/drivers/gpu/drm/i915/i915_gem_stolen.c +++ b/drivers/gpu/drm/i915/i915_gem_stolen.c @@ -160,6 +160,8 @@ static int find_compression_threshold(struct drm_device *dev, int compression_threshold = 1; int ret; + WARN_ON(!mutex_is_locked(&dev->struct_mutex)); + /* HACK: This code depends on what we will do in *_enable_fbc. If that * code changes, this code needs to change as well. * @@ -198,6 +200,8 @@ static int i915_setup_compression(struct drm_device *dev, int size, int fb_cpp) struct drm_mm_node *uninitialized_var(compressed_llb); int ret; + WARN_ON(!mutex_is_locked(&dev->struct_mutex)); + ret = find_compression_threshold(dev, &dev_priv->fbc.compressed_fb, size, fb_cpp); if (!ret) @@ -250,6 +254,7 @@ int i915_gem_stolen_setup_compression(struct drm_device *dev, int size, int fb_c { struct drm_i915_private *dev_priv = dev->dev_private; + WARN_ON(!mutex_is_locked(&dev->struct_mutex)); WARN_ON(!mutex_is_locked(&dev_priv->fbc.lock)); if (!drm_mm_initialized(&dev_priv->mm.stolen)) @@ -287,6 +292,8 @@ void i915_gem_cleanup_stolen(struct drm_device *dev) { struct drm_i915_private *dev_priv = dev->dev_private; + WARN_ON(!mutex_is_locked(&dev->struct_mutex)); + if (!drm_mm_initialized(&dev_priv->mm.stolen)) return; @@ -349,6 +356,8 @@ i915_pages_create_for_stolen(struct drm_device *dev, struct sg_table *st; struct scatterlist *sg; + WARN_ON(!mutex_is_locked(&dev->struct_mutex)); + DRM_DEBUG_DRIVER("offset=0x%x, size=%d\n", offset, size); BUG_ON(offset > dev_priv->gtt.stolen_size - size); @@ -445,6 +454,8 @@ i915_gem_object_create_stolen(struct drm_device *dev, u32 size) struct drm_mm_node *stolen; int ret; + WARN_ON(!mutex_is_locked(&dev->struct_mutex)); + if (!drm_mm_initialized(&dev_priv->mm.stolen)) return NULL; @@ -485,6 +496,8 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev, struct i915_vma *vma; int ret; + WARN_ON(!mutex_is_locked(&dev->struct_mutex)); + if (!drm_mm_initialized(&dev_priv->mm.stolen)) return NULL;