From patchwork Thu Dec 22 08:36:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9484451 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 4B7FD601D2 for ; Thu, 22 Dec 2016 08:39:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47CB1277D9 for ; Thu, 22 Dec 2016 08:39:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C97D281C3; Thu, 22 Dec 2016 08:39:10 +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 D1B47277D9 for ; Thu, 22 Dec 2016 08:39:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B46346F197; Thu, 22 Dec 2016 08:38:31 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wj0-x243.google.com (mail-wj0-x243.google.com [IPv6:2a00:1450:400c:c01::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 92FFF6F16E; Thu, 22 Dec 2016 08:37:17 +0000 (UTC) Received: by mail-wj0-x243.google.com with SMTP id ez4so670790wjd.1; Thu, 22 Dec 2016 00:37:17 -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=0ZFWNxQRe5t10/VWIToa8ACGx+tyY1uTzirKIrNFu/E=; b=h4v2E+TkGHtz5gyXZNhasYcpIfeF1RxO7HQt+WVzLN5NzRPf2bYN4+NAGWV8Fa63tj UkCMTRIH0FOwTTXpu7vHVa+hg26r7G3lhJ/+RFM2L2qp+W9SXZgZmLDkfZ1eB0oj0QEz 8HDESbxpppV2sfyQkOx9dxQ7a3uD3zgH37i9AHLv7MwDoqX2StzNOyMOXXDnWFEQJ0dv FhU7D7xCxvsWmi8iUWrxRWUaMLRBIQKGxcz2lYzefaqJF0IDkZuqTXZhd6LyG/Qc6MdM LYcVKhi2G97PFbivVNc9DqBLO/2IpBpW6nkPINK1dhgPdnFbxBqviL7jIZ4ablYRKN36 EreA== 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=0ZFWNxQRe5t10/VWIToa8ACGx+tyY1uTzirKIrNFu/E=; b=aNA+XQCN9ZcRNe7hR0JzCS08Gu8SISaIEHgMRVb7C6PU+2GCzZrBM7OV5lvdRl9oGn xyndaRmW0US+dg1TmNyBbsPGMWz1VwLwhkh+U5exYo21ZRSWTIefl2b6eooUJSTXfqHh EaWKzbvlXZFDO+ChKMUjuzTYLiFTpT9Od56dBWshT2n8L1TXdOR/Hv6KIF42f+gKN+Vl c6M2kYvlbvz8FB7/mlwnFqz/KZa2KWgGG4+j/9ip1OiI9EN1sesjOLNFPf3KewcCop7Q PJM+WQN+hPqp1Z7HTcE4jp8nQwHI0Ma5MbtD26+HAlGUo2ZHjEbWJZwNOKCMU8/03Y9K bbIA== X-Gm-Message-State: AIkVDXLb5ZlboryCdcwLKG8PXoR6gJRSuFaAF3NholYVZuVcvES9rzsOlLcNlHq5C3bqFQ== X-Received: by 10.194.249.72 with SMTP id ys8mr8961300wjc.92.1482395835599; Thu, 22 Dec 2016 00:37:15 -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.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Dec 2016 00:37:15 -0800 (PST) From: Chris Wilson To: dri-devel@lists.freedesktop.org Subject: [PATCH v4 29/38] drm: Fix application of color vs range restriction when scanning drm_mm Date: Thu, 22 Dec 2016 08:36:32 +0000 Message-Id: <20161222083641.2691-30-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 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 The range restriction should be applied after the color adjustment, or else we may inadvertently apply the color adjustment to the restricted hole (and not against its neighbours). Signed-off-by: Chris Wilson Reviewed-by: Joonas Lahtinen --- drivers/gpu/drm/drm_mm.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c index c68f79149b9a..1b5613bcb35e 100644 --- a/drivers/gpu/drm/drm_mm.c +++ b/drivers/gpu/drm/drm_mm.c @@ -772,6 +772,7 @@ bool drm_mm_scan_add_block(struct drm_mm_scan *scan, struct drm_mm *mm = scan->mm; struct drm_mm_node *hole; u64 hole_start, hole_end; + u64 col_start, col_end; u64 adj_start, adj_end; DRM_MM_BUG_ON(node->mm != mm); @@ -789,14 +790,16 @@ bool drm_mm_scan_add_block(struct drm_mm_scan *scan, node->node_list.next = &scan->prev_scanned_node->node_list; scan->prev_scanned_node = node; - hole_start = drm_mm_hole_node_start(hole); - hole_end = drm_mm_hole_node_end(hole); - - adj_start = max(hole_start, scan->range_start); - adj_end = min(hole_end, scan->range_end); + hole_start = __drm_mm_hole_node_start(hole); + hole_end = __drm_mm_hole_node_end(hole); + col_start = hole_start; + col_end = hole_end; if (mm->color_adjust) - mm->color_adjust(hole, scan->color, &adj_start, &adj_end); + mm->color_adjust(hole, scan->color, &col_start, &col_end); + + adj_start = max(col_start, scan->range_start); + adj_end = min(col_end, scan->range_end); if (check_free_hole(adj_start, adj_end, scan->size, scan->alignment)) {