From patchwork Thu Feb 2 15:02:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9552163 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 7CBEE60236 for ; Thu, 2 Feb 2017 15:03:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 775C027FAD for ; Thu, 2 Feb 2017 15:03:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C7232815E; Thu, 2 Feb 2017 15:03:01 +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 2185127FAD for ; Thu, 2 Feb 2017 15:03:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 127A46EA1A; Thu, 2 Feb 2017 15:03:00 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9D4AF6EA13 for ; Thu, 2 Feb 2017 15:02:56 +0000 (UTC) Received: by mail-wm0-x242.google.com with SMTP id u63so4748696wmu.2 for ; Thu, 02 Feb 2017 07:02:56 -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=d8Wj3bo/rJZctl0WUsHUT9Sq7iaQqZGyKpe1JHME3yc=; b=VcmmuttWfAt1+UVn1taM+Ii7b7Ao12fjgS9zxbTk3tGoHpELqr3o2iVB+hOMDQoewo Lo/ME6jn6zQbI3C8WMigJpitGO3czOHBjlps8obxxe61f4kVgLCLSEdOEy1sKTb2a+Cl 4Gh0D4dAxiTELJOY3ODBGYyCgo6BTYUy+d2YrN+FwqoOIDkqC726akx/MZXojVSSU/b0 VgjcQJ1b0FLRlY8ToEpJdlU9m6kMyhPU2X1o97GdE86Cf9vFPyPnmajFGX4Mn0EnjVIp /QZYHS8Wp6DzcMgeQPnrXG64FyGushnLTYWnHyfY4wYV+6ubd3j7U8i0ZSG9nKB9xU6m jmVg== 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=d8Wj3bo/rJZctl0WUsHUT9Sq7iaQqZGyKpe1JHME3yc=; b=ERrRnmn1mOd0hSDVMGKD38LNY2rgkRiRbWPYmNMmecjy6wsv6MQvKu3d/I00oI7wry FnkQ6Q9Erk61dzI7x7wqQLfMcKm7qDrmZEydq3kzLjl+HdVuB1AukZLN7jW1n/+yA5ib MoKMqLohEdAEIXa8UbJ2vRvsOQKTxKNLhQ5TZQTW9pCCnwbdlRRzRxBdPRKWrkTzLaO8 1UghbEuBshoYhUbKzZd0kfEfWdgiUFp50vs7gCYBvJtJrXawoScZI2JKUR+vKRDr0xKy N+thtDptqTwmvoTYkhe7FVzqXvKYhhG5ylMroJwhS3STbORv4Ls0NooZkyOQEAm7RNJZ 2m/A== X-Gm-Message-State: AMke39kqT5kkLUyBo19ddZsAOQpdWWgWIuiS9RHSXEjw8WFytoL4BwfG46gz/9z5wUwFzQ== X-Received: by 10.28.165.196 with SMTP id o187mr879371wme.6.1486047775352; Thu, 02 Feb 2017 07:02:55 -0800 (PST) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id i29sm15001899wrc.25.2017.02.02.07.02.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Feb 2017 07:02:54 -0800 (PST) From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Thu, 2 Feb 2017 15:02:33 +0000 Message-Id: <20170202150248.27860-4-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170202150248.27860-1-chris@chris-wilson.co.uk> References: <20170202150248.27860-1-chris@chris-wilson.co.uk> Cc: mika.kuoppala@intel.com Subject: [Intel-gfx] [PATCH 04/19] drm/i915: Don't special case teardown of aliasing_ppgtt 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 The aliasing_ppgtt is a regular ppgtt, and we can use the regular i915_ppgtt_put() to properly tear it down. Signed-off-by: Chris Wilson Reviewed-by: Matthew Auld --- drivers/gpu/drm/i915/i915_gem_gtt.c | 53 +++++++++++-------------------------- 1 file changed, 15 insertions(+), 38 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c index f503fc0d8530..921aa1e902b4 100644 --- a/drivers/gpu/drm/i915/i915_gem_gtt.c +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c @@ -2225,23 +2225,6 @@ static void gtt_write_workarounds(struct drm_i915_private *dev_priv) I915_WRITE(GEN8_L3_LRA_1_GPGPU, GEN9_L3_LRA_1_GPGPU_DEFAULT_VALUE_BXT); } -static int i915_ppgtt_init(struct i915_hw_ppgtt *ppgtt, - struct drm_i915_private *dev_priv, - struct drm_i915_file_private *file_priv, - const char *name) -{ - int ret; - - ret = __hw_ppgtt_init(ppgtt, dev_priv); - if (ret == 0) { - kref_init(&ppgtt->ref); - i915_address_space_init(&ppgtt->base, dev_priv, name); - ppgtt->base.file = file_priv; - } - - return ret; -} - int i915_ppgtt_init_hw(struct drm_i915_private *dev_priv) { gtt_write_workarounds(dev_priv); @@ -2279,12 +2262,16 @@ i915_ppgtt_create(struct drm_i915_private *dev_priv, if (!ppgtt) return ERR_PTR(-ENOMEM); - ret = i915_ppgtt_init(ppgtt, dev_priv, fpriv, name); + ret = __hw_ppgtt_init(ppgtt, dev_priv); if (ret) { kfree(ppgtt); return ERR_PTR(ret); } + kref_init(&ppgtt->ref); + i915_address_space_init(&ppgtt->base, dev_priv, name); + ppgtt->base.file = fpriv; + trace_i915_ppgtt_create(&ppgtt->base); return ppgtt; @@ -2775,21 +2762,17 @@ int i915_gem_init_ggtt(struct drm_i915_private *dev_priv) ggtt->base.total - PAGE_SIZE, PAGE_SIZE); if (USES_PPGTT(dev_priv) && !USES_FULL_PPGTT(dev_priv)) { - ppgtt = kzalloc(sizeof(*ppgtt), GFP_KERNEL); - if (!ppgtt) { - ret = -ENOMEM; + ppgtt = i915_ppgtt_create(dev_priv, NULL, "[alias]"); + if (IS_ERR(ppgtt)) { + ret = PTR_ERR(ppgtt); goto err; } - ret = __hw_ppgtt_init(ppgtt, dev_priv); - if (ret) - goto err_ppgtt; - if (ppgtt->base.allocate_va_range) { ret = ppgtt->base.allocate_va_range(&ppgtt->base, 0, ppgtt->base.total); if (ret) - goto err_ppgtt_cleanup; + goto err_ppgtt; } ppgtt->base.clear_range(&ppgtt->base, @@ -2803,10 +2786,8 @@ int i915_gem_init_ggtt(struct drm_i915_private *dev_priv) return 0; -err_ppgtt_cleanup: - ppgtt->base.cleanup(&ppgtt->base); err_ppgtt: - kfree(ppgtt); + i915_ppgtt_put(ppgtt); err: drm_mm_remove_node(&ggtt->error_capture); return ret; @@ -2829,26 +2810,22 @@ void i915_ggtt_cleanup_hw(struct drm_i915_private *dev_priv) WARN_ON(i915_vma_unbind(vma)); mutex_unlock(&dev_priv->drm.struct_mutex); - if (dev_priv->mm.aliasing_ppgtt) { - struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; - ppgtt->base.cleanup(&ppgtt->base); - kfree(ppgtt); - } - i915_gem_cleanup_stolen(&dev_priv->drm); + mutex_lock(&dev_priv->drm.struct_mutex); + if (dev_priv->mm.aliasing_ppgtt) + i915_ppgtt_put(dev_priv->mm.aliasing_ppgtt); + if (drm_mm_node_allocated(&ggtt->error_capture)) drm_mm_remove_node(&ggtt->error_capture); if (drm_mm_initialized(&ggtt->base.mm)) { intel_vgt_deballoon(dev_priv); - - mutex_lock(&dev_priv->drm.struct_mutex); i915_address_space_fini(&ggtt->base); - mutex_unlock(&dev_priv->drm.struct_mutex); } ggtt->base.cleanup(&ggtt->base); + mutex_unlock(&dev_priv->drm.struct_mutex); arch_phys_wc_del(ggtt->mtrr); io_mapping_fini(&ggtt->mappable);