From patchwork Tue Jan 10 09:56: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: 9506843 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 73D64606E1 for ; Tue, 10 Jan 2017 09:56:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A01F27FB1 for ; Tue, 10 Jan 2017 09:56:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5EA802844A; Tue, 10 Jan 2017 09:56:47 +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 227F127FB1 for ; Tue, 10 Jan 2017 09:56:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8F0A96E634; Tue, 10 Jan 2017 09:56:44 +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 606466E624 for ; Tue, 10 Jan 2017 09:56:39 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id r126so8106973wmr.3 for ; Tue, 10 Jan 2017 01:56:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=0/+B/sZvgF6x8V8n0foNa+mTGRpUa42q2sb3MjCwris=; b=Tb3gADNA/pUoj8xVBeyV6g9Ya7tA7z3+bu63wbN7s7akld8MPzJVqJEt6P1FkdFiFZ qQubzNAiiWIFInMk1kSDXNB7WzhD1MEsrkobgvEveNiWTi9rMjilzGLqYQrdiPEPCZNt EjXmtqOzMIxmnz//rcD8qXtj8eELdMx71see+25FPGytdxioh/GYBbFiSgJvfn3mt13+ ZoymTFlgS/CceQswuyzyG9dG3Xh9E5Ss/4Us3dby2aPFlpb1b+tHJdwsLTyyNTA3b+us nKfC8RY0IDVNUAGl87uNl9IDwEcCaXRElDaT95tfa0XMA/9GLyJ+1Tb9QH3qsCwY6ZxC JVVg== 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:subject:date:message-id :in-reply-to:references; bh=0/+B/sZvgF6x8V8n0foNa+mTGRpUa42q2sb3MjCwris=; b=dLV6Xjq949BZeQzQtMUGjbcSzL/rdmURuLaCpx/cHzGsg3JXoeB9UKCrKeygmla2pW IHUCL0OanWz9akTfxV1MzjYrF04A68fJ1bnr7C1cnHlDAoYf6HLHoTgr6n/xmPE5ZoS2 okhuORjMb6hMjvtH79RhEflQoW9DgGfzOs511EQCFibyShPNjDy7SkJjJzFbTdW0tDCr nUpM1jO+9ca1fnd4Pl2dyVr3Lj3UBgSYqzh35xWguTmVi7uq+vxbLDwZDCCfAAo+LNJi Wr0HTWstbfPWajKTV5YBgOmqp6ACgT6gSHB5wPTI0eyddCDmyeEr5RFIafgCSktZhG2n hVtA== X-Gm-Message-State: AIkVDXLhlguLU2ZclkRZrqEUn3dGB8X5MfYjGy2sGwjAaIRJPPfE7TCjZrO39TujtXdWyw== X-Received: by 10.28.11.11 with SMTP id 11mr6545830wml.80.1484042197392; Tue, 10 Jan 2017 01:56:37 -0800 (PST) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id o132sm2805590wmo.17.2017.01.10.01.56.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Jan 2017 01:56:36 -0800 (PST) From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Tue, 10 Jan 2017 09:56:33 +0000 Message-Id: <20170110095633.6612-2-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170110095633.6612-1-chris@chris-wilson.co.uk> References: <20170110095633.6612-1-chris@chris-wilson.co.uk> Subject: [Intel-gfx] [CI 2/2] drm/i915: Clip the partial view against the object not vma 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 VMA is later clipped against the vm_area_struct before insertion of the faulting PTE so we are free to create the partial view as we desire. If we use the object as the extents rather than the area, this partial can then be used for other areas. Signed-off-by: Chris Wilson Reviewed-by: Joonas Lahtinen --- drivers/gpu/drm/i915/i915_gem.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 4833e21272a6..91d726f8bdfa 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -1751,7 +1751,6 @@ int i915_gem_mmap_gtt_version(void) static inline struct i915_ggtt_view compute_partial_view(struct drm_i915_gem_object *obj, - struct vm_area_struct *area, pgoff_t page_offset, unsigned int chunk) { @@ -1765,7 +1764,7 @@ compute_partial_view(struct drm_i915_gem_object *obj, view.params.partial.offset = rounddown(page_offset, chunk); view.params.partial.size = min_t(unsigned int, chunk, - vma_pages(area) - view.params.partial.offset); + (obj->base.size >> PAGE_SHIFT) - view.params.partial.offset); /* If the partial covers the entire object, just create a normal VMA. */ if (chunk >= obj->base.size >> PAGE_SHIFT) @@ -1852,8 +1851,7 @@ int i915_gem_fault(struct vm_area_struct *area, struct vm_fault *vmf) if (IS_ERR(vma)) { /* Use a partial view if it is bigger than available space */ struct i915_ggtt_view view = - compute_partial_view(obj, area, - page_offset, MIN_CHUNK_PAGES); + compute_partial_view(obj, page_offset, MIN_CHUNK_PAGES); /* Userspace is now writing through an untracked VMA, abandon * all hope that the hardware is able to track future writes.