From patchwork Mon Sep 28 21:08:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 7281671 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7B4A39FC34 for ; Tue, 29 Sep 2015 00:25:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2607B2072B for ; Tue, 29 Sep 2015 00:25:06 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 8CFE1206E8 for ; Tue, 29 Sep 2015 00:25:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DA3766E1F6; Mon, 28 Sep 2015 17:25:01 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-la0-f41.google.com (mail-la0-f41.google.com [209.85.215.41]) by gabe.freedesktop.org (Postfix) with ESMTPS id DF6F76E657 for ; Mon, 28 Sep 2015 14:09:10 -0700 (PDT) Received: by laer8 with SMTP id r8so45908806lae.2 for ; Mon, 28 Sep 2015 14:09:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=from:to:cc:subject:date:message-id; bh=KMJIUwOq5Lae3mwBc8yRJVfDfRpfK+bYMx3D0mH/HC0=; b=QfHAdPAk+yvMnXPgD9kRUcmI5rNe+aH/wejzMxP6+79MoAlU/jvFHK4kX6yY8J+jpA 30+ZsFtt5ub05BNsxLpO48umjfK+GnCsvBX4WVYlBm9u4/T0/+uM6DEfVijqvKa9Fm8b L3WKE1TQ1EhsXqPigCevWqw3saTR+wtMO8JJA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=KMJIUwOq5Lae3mwBc8yRJVfDfRpfK+bYMx3D0mH/HC0=; b=cO/dTChlA42bahzvYEFk9Rpr1z4gtmyGs3K5EK8uUlde3vwGnu+Ff6GmzXAnZ5rWjD ZGI29phgAkfYXAKbtXK2JKV4TnMVVQIfo0Ms53M5BexxaHTkDvgiqOx1oA+/mgDOLH5C 9Ntg+9XWmYITmZGHNOnp/27JBiFwaVOboNvzZi3bphePmd2OyvL7yGoInMwfV0LzEKFY pqHBeSVyk5EPjqXhBZSAvq/+GmH1ia/nNogV9J4HWhhDS+YFEvejn27QwxezFrQOO3EQ tQ6jXwfacjSMTUTSngu6tb94hziR7I4LMmdDCvUGOidr1c+6zmO7282zK9ORocgdpS8M R0Rw== X-Gm-Message-State: ALoCoQmqdNG6OwMXx8S5C/fYlbbvc2MLT+nFkQp5MvhqVAZmbE0u4hdSWENqE/O9suPUtdXJuRkL X-Received: by 10.112.32.72 with SMTP id g8mr6023263lbi.22.1443474548598; Mon, 28 Sep 2015 14:09:08 -0700 (PDT) Received: from spencer.imf.au.dk ([130.225.20.51]) by smtp.gmail.com with ESMTPSA id d5sm1752265lad.30.2015.09.28.14.09.07 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Sep 2015 14:09:08 -0700 (PDT) From: Rasmus Villemoes To: Daniel Vetter , Jani Nikula , David Airlie Subject: [PATCH] drm/i915: Fix comparison bug Date: Mon, 28 Sep 2015 23:08:50 +0200 Message-Id: <1443474531-11560-1-git-send-email-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.1.3 X-Mailman-Approved-At: Mon, 28 Sep 2015 17:25:00 -0700 Cc: intel-gfx@lists.freedesktop.org, Rasmus Villemoes , linux-kernel@vger.kernel.org, dri-devel@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-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP ->stolen->start has type u64 aka unsigned long long; relying on the difference (effectively cast to int) for sorting is wrong. It wouldn't be a problem in practice if the values compared are always within INT_MAX of each other (so that the difference is actually representable in an int), but 440fd5283a87 ("drm/mm: Support 4 GiB and larger ranges") strongly suggests that's not the case. Signed-off-by: Rasmus Villemoes Reviewed-by: Jani Nikula --- drivers/gpu/drm/i915/i915_debugfs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index e3ec9049081f..5207e681a987 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c @@ -258,7 +258,11 @@ static int obj_rank_by_stolen(void *priv, struct drm_i915_gem_object *b = container_of(B, struct drm_i915_gem_object, obj_exec_link); - return a->stolen->start - b->stolen->start; + if (a->stolen->start < b->stolen->start) + return -1; + if (a->stolen->start > b->stolen->start) + return 1; + return 0; } static int i915_gem_stolen_list_info(struct seq_file *m, void *data)