From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755939AbbI2HeW (ORCPT ); Tue, 29 Sep 2015 03:34:22 -0400 Received: from mga11.intel.com ([192.55.52.93]:4614 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755550AbbI2HeO (ORCPT ); Tue, 29 Sep 2015 03:34:14 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,606,1437462000"; d="scan'208";a="815093334" From: Jani Nikula To: Rasmus Villemoes , Daniel Vetter , David Airlie Cc: Rasmus Villemoes , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] drm/i915: Fix comparison bug In-Reply-To: <1443474531-11560-1-git-send-email-linux@rasmusvillemoes.dk> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <1443474531-11560-1-git-send-email-linux@rasmusvillemoes.dk> User-Agent: Notmuch/0.20.2+58~g39779b9 (http://notmuchmail.org) Emacs/24.4.1 (x86_64-pc-linux-gnu) Date: Tue, 29 Sep 2015 10:37:30 +0300 Message-ID: <87vbatislh.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 29 Sep 2015, Rasmus Villemoes wrote: > ->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) > -- > 2.1.3 > -- Jani Nikula, Intel Open Source Technology Center