From patchwork Fri Dec 16 07:47:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9477485 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 5DE32601C2 for ; Fri, 16 Dec 2016 07:52:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D72A1FF12 for ; Fri, 16 Dec 2016 07:52:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4023C2882B; Fri, 16 Dec 2016 07:52:37 +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 C728F28798 for ; Fri, 16 Dec 2016 07:52:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 075006EB70; Fri, 16 Dec 2016 07:52:10 +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 70EC66EB3D; Fri, 16 Dec 2016 07:48:03 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id m203so3516125wma.3; Thu, 15 Dec 2016 23:48:03 -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=zlZJth7C48c/9WdCPbOM/6vxWkG0+wjc75xKw+E8fD8=; b=f/AjTyUcFPJTaH1G5ull/NlZIj+9sonC0TtJhT2yjJs3Nxy3IplGuoPalZyxAYD2ZJ yYwSRQE/7mUikFqSg3lpUWadB+POkZVvIZRSy6JxiMg+vWijfmXLdw51MRLxRjQSfWSH yxLR+zbyUBMs1swyiuStkeADdFl34niFJ/5QvjyryXUNSf7p1LiGsq12AALJ/MJTNit5 FHta2oz5wyV6ScHIPOK4b43sSUE4HN7KDrP+foHm69wZYBYDD2/2bN8aJ1d5feXLGFCZ H1dO9w2cQPnKiAHmxsF1Ykja3MRSoj2Xs2f4xDHPvkdIuw/Z8TBWS7+57YMoNQdwQm9z HE3g== 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=zlZJth7C48c/9WdCPbOM/6vxWkG0+wjc75xKw+E8fD8=; b=RK6vpHGoLA1Msg+2GMoyynefSIS0ghNOgqRsH4qM+ZkUwk9KvQA5NI5Kv/WOcQ0lt+ ufGLQuxRlXHixhr5qJf3sDDlrrTyC0G0BryyB0ZFjvq0/csRHvZm1sggm1bHBdU9vwCn nLxGZcHPoeUUE39RUpzhrrjO1ThrDw+1imEWtrznX7a5sYnHSLJKlxLqTJOaY5gFkmd8 HzUZD3w040KEO/HmPMcfs8o+AblA5pAr+Vg5OrrToFLH+iRaQMa6QWUc8ZRkxto9n3R6 T76IAgtsyV3S+7iTQS3Gad8uao5xVXl7NNNtaXlqLp9DCv4e26fbhxZwY6fm5ZvsKNgH cMDA== X-Gm-Message-State: AIkVDXLdBBKEfP1cA9+riPGERSeclRJZSSPea4p6xWQ32C1TqUcgaQQ5sXJLTwJYxA4hXA== X-Received: by 10.28.221.11 with SMTP id u11mr1934008wmg.123.1481874481733; Thu, 15 Dec 2016 23:48:01 -0800 (PST) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id c202sm2792407wme.1.2016.12.15.23.48.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Dec 2016 23:48:01 -0800 (PST) From: Chris Wilson To: dri-devel@lists.freedesktop.org Date: Fri, 16 Dec 2016 07:47:15 +0000 Message-Id: <20161216074718.32500-38-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20161216074718.32500-1-chris@chris-wilson.co.uk> References: <20161216074718.32500-1-chris@chris-wilson.co.uk> Cc: intel-gfx@lists.freedesktop.org Subject: [Intel-gfx] [PATCH v2 37/40] 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 da9f98690e97..062a2a82efd6 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;