From patchwork Thu Dec 22 08:36:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9484479 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 7B3B3601D2 for ; Thu, 22 Dec 2016 08:41:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 77341277D9 for ; Thu, 22 Dec 2016 08:41:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6A7FA281C3; Thu, 22 Dec 2016 08:41:13 +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=unavailable 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 13231277D9 for ; Thu, 22 Dec 2016 08:41:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0F2736F196; Thu, 22 Dec 2016 08:41:12 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@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 3DE1F6F02A; Thu, 22 Dec 2016 08:37:24 +0000 (UTC) Received: by mail-wj0-x244.google.com with SMTP id ez4so671089wjd.1; Thu, 22 Dec 2016 00:37:24 -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=SUcgq8uJ7hjiPjakPVg+1hJ7nN35psOivvLD+W9CoTEX9P7ZOSg3DCdoysBfZZu5Xp +R6da+9D8kFLbba5c0wmTQ7DfM82D99yO3v4WXN2CYpkyxFi70KGq6vdyFKllyfqIEwN A+DYgaGiyttlX4KAiGTR4/04U+SEaTFSZX3yEuP0B1iueFPPzh043t8ir2tAJ0W2rlDi hSy851OEhIRaCPNWSnvgD0El0pCreiEjkoRzbbzI62kRnuKXOPdR73oiW2GipHoYJgGy xlQFNOu2UudmDE/ukByWlRZT7SF6+w0iefQk9S3qSPlYgY86YlYtylNK5Gx2e7E43ZtZ ms4Q== 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=XlC9VO9LaTQC2AMBkpn9yJE4NbrAK/ovqaJ8QrsgJzCazskwvqc/jcGBj29/NXgxzf 575xX1IlXmDMsdW1nrMPoN4LwmhAt2IJNJUGN0RgZ1xOXqhh3G/BTy/HKAAgT53wPZVb wcRLQ7mWf88W/Fy7DBdXTcSGZP7QwmytYk4rVIa4N/3avG4x8kXaQjXHx9rUTurRFDMJ QtBeZ61YP80JrgQzNCT8/fMCtl6N5lSSsORw2PWaNGDlsybavJw5/WASPTSQ+FG6FJUo 1J9W7YnPrev6aHCZy1WVCWjzitKwN53tV8S5GIlnVlbRFIyMoWR/PWjf0R2VavfcRWWv D0Xw== X-Gm-Message-State: AIkVDXLnN8KO/H9VlzCYmy3aVT9NbN1qAxnuKFGh+CvRYfheN9M8nyH/aLxoEUUgGJRGUA== X-Received: by 10.194.9.34 with SMTP id w2mr7676565wja.24.1482395842021; Thu, 22 Dec 2016 00:37:22 -0800 (PST) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id di9sm34442318wjc.37.2016.12.22.00.37.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Dec 2016 00:37:21 -0800 (PST) From: Chris Wilson To: dri-devel@lists.freedesktop.org Date: Thu, 22 Dec 2016 08:36:38 +0000 Message-Id: <20161222083641.2691-36-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20161222083641.2691-1-chris@chris-wilson.co.uk> References: <20161222083641.2691-1-chris@chris-wilson.co.uk> Cc: intel-gfx@lists.freedesktop.org Subject: [Intel-gfx] [PATCH v4 35/38] drm: Apply range restriction after color adjustment when allocation 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 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;