From patchwork Fri Dec 16 19:25:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9478321 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 09DF1601C2 for ; Fri, 16 Dec 2016 19:27:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0C3428772 for ; Fri, 16 Dec 2016 19:27:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E58C72879E; Fri, 16 Dec 2016 19:27:42 +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 9DA7E28772 for ; Fri, 16 Dec 2016 19:27:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 677636ECE4; Fri, 16 Dec 2016 19:27:30 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wj0-x244.google.com (mail-wj0-x244.google.com [IPv6:2a00:1450:400c:c01::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id BDB758916F; Fri, 16 Dec 2016 19:26:28 +0000 (UTC) Received: by mail-wj0-x244.google.com with SMTP id kp2so15646424wjc.0; Fri, 16 Dec 2016 11:26:28 -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=A6Pb0QUlf3qqLQR8HHfd3COVxXwbDJ8ZrgDmaFVS5kg=; b=FHFihK2KaK5GpwzA0Y97khKD3hrq68ra7DsxUOF1V9RPKQhuZve2oj9S56q3/p+qMB VCGQwsqVlKsaU32oovBRAuwHHLVQlUXMwS9Y34nDSj/xAyogqOxUTQTljt4/wuyQHmvR ptZh89EdQcQUN3AAokjB38O6jHODa2849KZFjVfTXi3k+vwym/J06n3YsCaMZB9Tc3pU Iyyrrgi7YStnadriiOLj1LBy9mhwLk+NFTmXh1CumPUITMFkmSAk4ZHaPQPVYW8BCfWT RaxL5SoD8BZNtQkBQT9j3v0x8qb0TAh9qbn/ogU9nDzcYSSXW4r9ImAGBycAVq787Z7u s09Q== 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=A6Pb0QUlf3qqLQR8HHfd3COVxXwbDJ8ZrgDmaFVS5kg=; b=F07xKyhVLxIPViYBu4iZQSHZ1gcSEkCyFCdCHitk99DPr1e/KsbZTUF0HXhZsCsh/C JZZG7G4UrgKz3cvP9idqwRCSOZ9GaJ+OjcdMVP5K6cLs85uJbDKwb2AUOeQOl11Zgp9Z 0Mav3mUZYl2a38Xw9tC1ewoif+0/Xmg2F3Z1gqYEqmP5sTZt0w5K2fWX/WjwaNIWNtxA 4+0dgNzoneYqMcZ7HJWo1eLVaLlGHlbwYa3I9TDfkJgap8qZOlyfJjs0nGwsmyStn21t rcvTGvYzmsr8vcZfLu0ZTIoka+2SZa8NgB+gzvPNiHcnpnpv3lMOlEhGpT2ce5V8zXkL vTqw== X-Gm-Message-State: AIkVDXK4/ALYAwS71/r9VyljCb0/hvY9MJoAwoxdsZX7A/virloS4I9s33dDcraICaS5MQ== X-Received: by 10.194.71.133 with SMTP id v5mr4148510wju.222.1481916386776; Fri, 16 Dec 2016 11:26:26 -0800 (PST) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id v2sm8125856wja.41.2016.12.16.11.26.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Dec 2016 11:26:26 -0800 (PST) From: Chris Wilson To: dri-devel@lists.freedesktop.org Subject: [PATCH v3 35/38] drm: Apply range restriction after color adjustment when allocation Date: Fri, 16 Dec 2016 19:25:47 +0000 Message-Id: <20161216192550.8352-36-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20161216192550.8352-1-chris@chris-wilson.co.uk> References: <20161216192550.8352-1-chris@chris-wilson.co.uk> Cc: intel-gfx@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP mm->color_adjust() compares the hole with its neighbouring nodes. They only abutt before we restrict the hole, so we have to apply color_adjust before we apply the range restriction. Signed-off-by: Chris Wilson Reviewed-by: Joonas Lahtinen --- drivers/gpu/drm/drm_mm.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c index c0024719f32b..e279ac7c7aaf 100644 --- a/drivers/gpu/drm/drm_mm.c +++ b/drivers/gpu/drm/drm_mm.c @@ -410,14 +410,12 @@ static void drm_mm_insert_helper_range(struct drm_mm_node *hole_node, DRM_MM_BUG_ON(!drm_mm_hole_follows(hole_node) || node->allocated); - if (adj_start < start) - adj_start = start; - if (adj_end > end) - adj_end = end; - if (mm->color_adjust) mm->color_adjust(hole_node, color, &adj_start, &adj_end); + adj_start = max(adj_start, start); + adj_end = min(adj_end, end); + if (flags & DRM_MM_CREATE_TOP) adj_start = adj_end - size; @@ -625,17 +623,15 @@ static struct drm_mm_node *drm_mm_search_free_in_range_generic(const struct drm_ flags & DRM_MM_SEARCH_BELOW) { u64 hole_size = adj_end - adj_start; - if (adj_start < start) - adj_start = start; - if (adj_end > end) - adj_end = end; - if (mm->color_adjust) { mm->color_adjust(entry, color, &adj_start, &adj_end); if (adj_end <= adj_start) continue; } + adj_start = max(adj_start, start); + adj_end = min(adj_end, end); + if (!check_free_hole(adj_start, adj_end, size, alignment)) continue;