From patchwork Mon Apr 20 09:46:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 6241311 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 D460D9F313 for ; Mon, 20 Apr 2015 09:46:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 05F8720374 for ; Mon, 20 Apr 2015 09:46:24 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 0466F20361 for ; Mon, 20 Apr 2015 09:46:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4CCB36E33D; Mon, 20 Apr 2015 02:46:22 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from fireflyinternet.com (mail.fireflyinternet.com [87.106.93.118]) by gabe.freedesktop.org (Postfix) with ESMTP id 00F496E33D for ; Mon, 20 Apr 2015 02:46:19 -0700 (PDT) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from nuc-i3427.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 39060419-1500048 for multiple; Mon, 20 Apr 2015 10:47:07 +0100 Received: by nuc-i3427.alporthouse.com (sSMTP sendmail emulation); Mon, 20 Apr 2015 10:46:08 +0100 Date: Mon, 20 Apr 2015 10:46:08 +0100 From: Chris Wilson To: Radek =?iso-8859-1?Q?Dost=E1l?= Subject: Re: [PATCHv2] drm: fb_helper: prefer to use mode, which is not DRM_MODE_TYPE_USERDEF Message-ID: <20150420094608.GD25451@nuc-i3427.alporthouse.com> Mail-Followup-To: Chris Wilson , Radek =?iso-8859-1?Q?Dost=E1l?= , airlied@linux.ie, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <1429477553-10294-1-git-send-email-rd@radekdostal.com> <1429507593-21172-1-git-send-email-rd@radekdostal.com> <20150420090929.GC25451@nuc-i3427.alporthouse.com> <5534C884.8080101@radekdostal.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <5534C884.8080101@radekdostal.com> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 On Mon, Apr 20, 2015 at 11:36:04AM +0200, Radek Dostál wrote: > Hi Chris, > > On 04/20/2015 11:09 AM, Chris Wilson wrote: > > The EDID modes should be earlier in the list, and so higher priority > > than the cmdline mode. The only instance I see that breaking down is if > > the mode gets created by drm_pick_cmdline_mode, i.e. > > indeed at the beginning the command line mode is added to the end of the > list, but later on it seems to me that all modes are reordered based on > the resolution and clock and than mode generated by > drm_helper_probe_add_cmdline_mode gets upper in the list as it has > higher clock value. Please see attached output of dmesg. Ah thanks, drm_mode_sort()! -Chris diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c index 213b11e..9c8357f 100644 --- a/drivers/gpu/drm/drm_modes.c +++ b/drivers/gpu/drm/drm_modes.c @@ -1127,6 +1127,7 @@ static int drm_mode_compare(void *priv, struct list_head *lh_a, struct list_head ((a->type & DRM_MODE_TYPE_PREFERRED) != 0); if (diff) return diff; + diff = b->hdisplay * b->vdisplay - a->hdisplay * a->vdisplay; if (diff) return diff; @@ -1136,7 +1137,16 @@ static int drm_mode_compare(void *priv, struct list_head *lh_a, struct list_head return diff; diff = b->clock - a->clock; - return diff; + if (diff) + return diff; + + /* sort user-defined modes after reported modes of same resolution */ + diff = ((a->type & DRM_MODE_TYPE_USERDEF) != 0) - + ((b->type & DRM_MODE_TYPE_USERDEF) != 0); + if (diff) + return diff; + + return 0; } Perhaps?