From patchwork Tue Oct 9 20:50:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 1571711 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id A5773DFFAD for ; Tue, 9 Oct 2012 21:58:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CFB909F784 for ; Tue, 9 Oct 2012 14:58:58 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-we0-f177.google.com (mail-we0-f177.google.com [74.125.82.177]) by gabe.freedesktop.org (Postfix) with ESMTP id C8AA99EF94 for ; Tue, 9 Oct 2012 14:58:48 -0700 (PDT) Received: by mail-we0-f177.google.com with SMTP id u50so3684575wey.36 for ; Tue, 09 Oct 2012 14:58:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=OOvKLvL/MbnPreQb3AtYtWITlQyGe0EO2oSwSmc3ad4=; b=KLlX+JaYqzTjKf6YYfuvnw45ghVyOd87O++va9zk4/0L6GG+3koYowjz2TfU5WOdxh pJRdXqgEu5T2LIIUJQzbTyp5RicrRMpxuiUx80FMJrjkUXJTU8QqfDfIa0Oxyikoyebh ZuzdWG2QY9zbhTLrw9JDrRjtBf4ovE6A1HZKk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=OOvKLvL/MbnPreQb3AtYtWITlQyGe0EO2oSwSmc3ad4=; b=HMNXaa4VVlnUGvQ1zAfCO8cAxCQwIIlXeh4HyS7tjbFs/X6fNdsbrha0vzYGycofyB LxurdOSwswnY+2mPbMd7cTG/9rI4PdHp+DIka3Do4Maw00sONymPc6es+yWi0rMITROR xuQSbsucvb4R7W79l09IJQKaa6OPsVHFwMlC27RdDKurNFwysgf8n2SW5p4OeA841EQL JoYNK3bTJvQOmJ4pD++D1+/hDg2j4UWHcmOzmkqfzFxfa+zaURUTiFTB8evZUqSDuOEu l2UK9LOQ/LXY34UkRgFndQ09DtDGu3hxfDcQTPIllszn53ygEoxsYQTwY3RVoQX9+OSy zvVA== Received: by 10.216.134.40 with SMTP id r40mr13254979wei.88.1349819927830; Tue, 09 Oct 2012 14:58:47 -0700 (PDT) Received: from wespe.ffwll.local (178-83-130-250.dynamic.hispeed.ch. [178.83.130.250]) by mx.google.com with ESMTPS id ay10sm30348522wib.2.2012.10.09.14.58.45 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 09 Oct 2012 14:58:46 -0700 (PDT) From: Daniel Vetter To: Intel Graphics Development Date: Tue, 9 Oct 2012 22:50:48 +0200 Message-Id: <1349815848-1824-1-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.7.11.2 In-Reply-To: <84c8a8$624sk4@orsmga001.jf.intel.com> References: <84c8a8$624sk4@orsmga001.jf.intel.com> X-Gm-Message-State: ALoCoQn7YYtUwrsCX2L/UpBb1Y2NEgwzL3n8WVdFyi/LjtYhygJzVpoKIGMB56v/oH0jQugOxe1A Cc: Daniel Vetter Subject: [Intel-gfx] [PATCH] drm/i915: fixup i915_gem_object_get_page inline helper X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org The obj->pages to obj->pages->sgl rework introduced this helper, but it doesn't actually work for n >= SG_MAX_SINGLE_ALLOC. For simplicity (and since right now I seem to be too stupid to see the bug), let's just grab the right page with a for_each_sg loop. This is exercised by the improved hangman tests and the gem_exec_big test in i-g-t. v2: Compared to v1, don't try to be clever since I seemingly only manage to prove that I'm not clever. Signed-off-by: Daniel Vetter Reviewed-by: Chris Wilson --- drivers/gpu/drm/i915/i915_drv.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 4f2831a..32a2e47 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -1340,12 +1340,14 @@ void i915_gem_lastclose(struct drm_device *dev); int __must_check i915_gem_object_get_pages(struct drm_i915_gem_object *obj); static inline struct page *i915_gem_object_get_page(struct drm_i915_gem_object *obj, int n) { - struct scatterlist *sg = obj->pages->sgl; - while (n >= SG_MAX_SINGLE_ALLOC) { - sg = sg_chain_ptr(sg + SG_MAX_SINGLE_ALLOC - 1); - n -= SG_MAX_SINGLE_ALLOC - 1; + struct scatterlist *sg; + int i; + + for_each_sg(obj->pages->sgl, sg, obj->pages->nents, i) { + if (i == n) + return sg_page(sg); } - return sg_page(sg+n); + return NULL; } static inline void i915_gem_object_pin_pages(struct drm_i915_gem_object *obj) {