From patchwork Sun Apr 24 07:18:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 8919661 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 04C6A9F372 for ; Sun, 24 Apr 2016 07:19:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 12E67201ED for ; Sun, 24 Apr 2016 07:19:27 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 35B0A201C7 for ; Sun, 24 Apr 2016 07:19:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CE54F6E0FB; Sun, 24 Apr 2016 07:19:22 +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 9FABC6E09F for ; Sun, 24 Apr 2016 07:19:13 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id r12so14231634wme.0 for ; Sun, 24 Apr 2016 00:19:13 -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=Eh2UVqc6l+V2+7VR0QMuC6wWG22HT1ZBU9dnf2PPjFc=; b=v4aR2ncP/ca/T6HWIXN2scA7V4Q041TNnf2YNAMjQrTE/03ZdnPwaO8JBaNQpUxVdW DOz9Zh4L7Nu0+lf1/dg/Lbpbj6w1LZLaenh0wVYTe6JLOPS+znG4BQpyCBvZSXUKAWHd pb346puXfvBuTOvsvFJN1w7gL3yf5bReq3LSWGW/IGZiQd0jpCdeoLULvJtjtOWm0FH+ rcNc6orqFgMLdFeLKg1TMbW3HBP98zKfgLWRog5wj+pHVKj9XmOT70v0H19UP0orL6iF M65c8gWmNplnKUOqb30tb4mfxGb7lxm7qh9w6t/NXzRT5swJjN/yxE2pTS9BqCWlgO/S qvkw== 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=Eh2UVqc6l+V2+7VR0QMuC6wWG22HT1ZBU9dnf2PPjFc=; b=VEjKVXsW6QtK6vajLBhDz0RFu1qkICOFwEevgd5e3qsiBkih+oKTS/iY+xg+dlaVFs cRtA0moRVC+dESBbeuyhXUvrGbF2toBkjqTEoaQ8sVtjDsz4KZSRHFXfzD1cgdKQIR1r /FkZISWrdzj30iFuvi09JoDTfs6ikgShFSKJBnScxoCOv6ak7gFbgN6TflckS0KZzy30 /ZGgH6MPDIxXiqsdPT0qHt5BVZaKn8bWcA4lgXBgFtpPTq59lHiEichf40KSJV/o6MOR VbzMPbWa89iXYT9Vh0AgYChfUuu9YyK8aLgbm5bAvoGo6E8mPFr4K6qMAqPDRdvHMpOb mvyA== X-Gm-Message-State: AOPr4FVvdD91cSNf9Ql++Oqok96CggvVLJ/VPR5j8QaFps+Js52kW4LG1O3RfFM3ieiSww== X-Received: by 10.28.212.16 with SMTP id l16mr5943311wmg.50.1461482352123; Sun, 24 Apr 2016 00:19:12 -0700 (PDT) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id i11sm16937119wjn.36.2016.04.24.00.19.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 24 Apr 2016 00:19:11 -0700 (PDT) From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Sun, 24 Apr 2016 08:18:35 +0100 Message-Id: <1461482332-21975-4-git-send-email-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1461482332-21975-1-git-send-email-chris@chris-wilson.co.uk> References: <1461482332-21975-1-git-send-email-chris@chris-wilson.co.uk> Subject: [Intel-gfx] [PATCH 04/21] drm/i915: Introduce i915_vm_to_ggtt() 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=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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 In a couple of places, we have an i915_address_space that we know is really an i915_ggtt that we want to use. Create an inline helper to convert from the i915_address_space subclass into its container. Signed-off-by: Chris Wilson Cc: Joonas Lahtinen Cc: Tvrtko Ursulin Reviewed-by: Joonas Lahtinen Reviewed-by: Tvrtko Ursulin --- drivers/gpu/drm/i915/i915_gem_gtt.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c index 0d666b3f7e9b..4ddf2ed8501f 100644 --- a/drivers/gpu/drm/i915/i915_gem_gtt.c +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c @@ -93,6 +93,13 @@ * */ +static inline struct i915_ggtt * +i915_vm_to_ggtt(struct i915_address_space *vm) +{ + GEM_BUG_ON(!i915_is_ggtt(vm)); + return container_of(vm, struct i915_ggtt, base); +} + static int i915_get_ggtt_vma_pages(struct i915_vma *vma); @@ -2358,7 +2365,7 @@ static void gen8_ggtt_insert_entries(struct i915_address_space *vm, enum i915_cache_level level, u32 unused) { struct drm_i915_private *dev_priv = to_i915(vm->dev); - struct i915_ggtt *ggtt = &dev_priv->ggtt; + struct i915_ggtt *ggtt = i915_vm_to_ggtt(vm); unsigned first_entry = start >> PAGE_SHIFT; gen8_pte_t __iomem *gtt_entries = (gen8_pte_t __iomem *)ggtt->gsm + first_entry; @@ -2436,7 +2443,7 @@ static void gen6_ggtt_insert_entries(struct i915_address_space *vm, enum i915_cache_level level, u32 flags) { struct drm_i915_private *dev_priv = to_i915(vm->dev); - struct i915_ggtt *ggtt = &dev_priv->ggtt; + struct i915_ggtt *ggtt = i915_vm_to_ggtt(vm); unsigned first_entry = start >> PAGE_SHIFT; gen6_pte_t __iomem *gtt_entries = (gen6_pte_t __iomem *)ggtt->gsm + first_entry; @@ -2480,7 +2487,7 @@ static void gen8_ggtt_clear_range(struct i915_address_space *vm, bool use_scratch) { struct drm_i915_private *dev_priv = to_i915(vm->dev); - struct i915_ggtt *ggtt = &dev_priv->ggtt; + struct i915_ggtt *ggtt = i915_vm_to_ggtt(vm); unsigned first_entry = start >> PAGE_SHIFT; unsigned num_entries = length >> PAGE_SHIFT; gen8_pte_t scratch_pte, __iomem *gtt_base = @@ -2512,7 +2519,7 @@ static void gen6_ggtt_clear_range(struct i915_address_space *vm, bool use_scratch) { struct drm_i915_private *dev_priv = to_i915(vm->dev); - struct i915_ggtt *ggtt = &dev_priv->ggtt; + struct i915_ggtt *ggtt = i915_vm_to_ggtt(vm); unsigned first_entry = start >> PAGE_SHIFT; unsigned num_entries = length >> PAGE_SHIFT; gen6_pte_t scratch_pte, __iomem *gtt_base =