From patchwork Fri Dec 16 19:25:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9478385 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 10C6D601C2 for ; Fri, 16 Dec 2016 19:29:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02F2928772 for ; Fri, 16 Dec 2016 19:29:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC30E287DB; Fri, 16 Dec 2016 19:29:50 +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 B948E28772 for ; Fri, 16 Dec 2016 19:29:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 71B676ECF8; Fri, 16 Dec 2016 19:29:42 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id AF59E6ECE0; Fri, 16 Dec 2016 19:26:23 +0000 (UTC) Received: by mail-wm0-x242.google.com with SMTP id g23so7268529wme.1; Fri, 16 Dec 2016 11:26:23 -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=rwk6ZWYr4HWoBTdRC2PAk9bQQH3R61w5yv0J7If9mO9O6Ia4o4VibCXR7jId8eikiU bwski42Yd/AvWlAJSXe00QjS2vOAN9w05e5gFKL52QfqaNu820xe9oqzvJyPyEHQxRIl TM3H1gtyY853J0iIeGa3Jk0dFrv9ORLe6qYoXxLAZBZ+nPoq2bmwT2YWvAHerNcJCMZk fw8lkCVC3+3ae41pn5QCoSbCmflxLJu7D16exNjEM2PNdIX3ADet683vdUZtSQd3LDjk RC5jvFE+P+eS61rFKj4wFXhyNk968ovlW/Su8BmzQ/dgk0NdTIbN0KZMp+F98cTd2xpT ckfA== 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=nFxdX1ilP0CYSCJWHdpIrS7+mN7+Ksn8kB5DMabDC7/5Jx4lE5Q9dkLme51aZHm0hM bdYwfj0xKhAa1LTWOGdixy7NnUCNNVRU9fJ6XJURSNpXwAZxME0iNbueV11dpNNPvfVK +Z25bdS7YGINyIoVPAxM6RegB8QXM+uxpObfjKL5fMZyfM/raM9B9JednFZZK7kZne1g AFdK48QqofjcAQjIWl/7XOCYrRGx/WIKTiwTZulydJcYOppo/4A9mPv1PPd/4f7jkVpS ABd0h39AhrE6ghDJFcoPcCOOO+PDp1O8nQntUATqtBWfyaVDe4bKdlRDyGGOQYeOFQBx bKew== X-Gm-Message-State: AIkVDXJnpZUIIf2K2M+BC/iojUyIhUMPoy7gp29PFQBlrf4RT330S+JpTxqOlneTJRegrw== X-Received: by 10.28.18.194 with SMTP id 185mr4314112wms.124.1481916381893; Fri, 16 Dec 2016 11:26:21 -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.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Dec 2016 11:26:21 -0800 (PST) From: Chris Wilson To: dri-devel@lists.freedesktop.org Subject: [PATCH v3 29/38] drm: Fix application of color vs range restriction when scanning drm_mm Date: Fri, 16 Dec 2016 19:25:41 +0000 Message-Id: <20161216192550.8352-30-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 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)) {