From patchwork Tue Jul 18 14:43:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 9848619 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 A1985602A7 for ; Tue, 18 Jul 2017 14:43:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 929AA237F1 for ; Tue, 18 Jul 2017 14:43:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 877C226785; Tue, 18 Jul 2017 14:43:35 +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.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED 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 3A0A2237F1 for ; Tue, 18 Jul 2017 14:43:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8FF8C6E368; Tue, 18 Jul 2017 14:43:27 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 518176E36E for ; Tue, 18 Jul 2017 14:43:26 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id CBE66AE22; Tue, 18 Jul 2017 14:43:23 +0000 (UTC) From: Takashi Iwai To: dri-devel@lists.freedesktop.org Subject: [PATCH 13/14] drm/mgag200: Add mode validation debugging code Date: Tue, 18 Jul 2017 16:43:19 +0200 Message-Id: <20170718144320.8354-14-tiwai@suse.de> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170718144320.8354-1-tiwai@suse.de> References: <20170718144320.8354-1-tiwai@suse.de> Cc: Egbert Eich , Dave Airlie , Mathieu Larouche , Daniel Vetter 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 From: Egbert Eich Give more verbose debug message at mode bandwidth checks. Signed-off-by: Egbert Eich Signed-off-by: Takashi Iwai --- drivers/gpu/drm/mgag200/mgag200_mode.c | 51 +++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index 77b8efcd3c65..50efb10f86c5 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -1698,6 +1698,21 @@ static uint32_t mga_vga_calculate_mode_bandwidth(struct drm_display_mode *mode, return (uint32_t)(bandwidth); } +static bool mga_vga_check_mode_bandwidth(struct drm_display_mode *mode, + int bits_per_pixel, + unsigned int max_bw) +{ + unsigned int bw; + + bw = mga_vga_calculate_mode_bandwidth(mode, bits_per_pixel); + if (bw > max_bw) { + DRM_DEBUG_KMS("Mode %d:%s exceeds bandwidth: %d > %d", + mode->base.id, mode->name, bw, max_bw); + return false; + } + return true; +} + #define MODE_BANDWIDTH MODE_BAD static int mga_vga_mode_valid(struct drm_connector *connector, @@ -1721,20 +1736,20 @@ static int mga_vga_mode_valid(struct drm_connector *connector, return MODE_VIRTUAL_X; if (mode->vdisplay > 1200) return MODE_VIRTUAL_Y; - if (mga_vga_calculate_mode_bandwidth(mode, bpp) - > (24400 * 1024)) + if (mga_vga_check_mode_bandwidth(mode, bpp, + 24400 * 1024)) return MODE_BANDWIDTH; } else if (mdev->unique_rev_id == 0x02) { if (mode->hdisplay > 1920) return MODE_VIRTUAL_X; if (mode->vdisplay > 1200) return MODE_VIRTUAL_Y; - if (mga_vga_calculate_mode_bandwidth(mode, bpp) - > (30100 * 1024)) + if (mga_vga_check_mode_bandwidth(mode, bpp, + 30100 * 1024)) return MODE_BANDWIDTH; } else { - if (mga_vga_calculate_mode_bandwidth(mode, bpp) - > (55000 * 1024)) + if (mga_vga_check_mode_bandwidth(mode, bpp, + 55000 * 1024)) return MODE_BANDWIDTH; } } else if (mdev->type == G200_WB) { @@ -1742,21 +1757,17 @@ static int mga_vga_mode_valid(struct drm_connector *connector, return MODE_VIRTUAL_X; if (mode->vdisplay > 1024) return MODE_VIRTUAL_Y; - if (mga_vga_calculate_mode_bandwidth(mode, - bpp > (31877 * 1024))) + if (mga_vga_check_mode_bandwidth(mode, bpp, 31877 * 1024)) + return MODE_BANDWIDTH; + } else if (mdev->type == G200_EV) { + if (mga_vga_check_mode_bandwidth(mode, bpp, 32700 * 1024)) + return MODE_BANDWIDTH; + } else if (mdev->type == G200_EH) { + if (mga_vga_check_mode_bandwidth(mode, bpp, 37500 * 1024)) + return MODE_BANDWIDTH; + } else if (mdev->type == G200_ER) { + if (mga_vga_check_mode_bandwidth(mode, bpp, 55000 * 1024)) return MODE_BANDWIDTH; - } else if (mdev->type == G200_EV && - (mga_vga_calculate_mode_bandwidth(mode, bpp) - > (32700 * 1024))) { - return MODE_BANDWIDTH; - } else if (mdev->type == G200_EH && - (mga_vga_calculate_mode_bandwidth(mode, bpp) - > (37500 * 1024))) { - return MODE_BANDWIDTH; - } else if (mdev->type == G200_ER && - (mga_vga_calculate_mode_bandwidth(mode, - bpp) > (55000 * 1024))) { - return MODE_BANDWIDTH; } if ((mode->hdisplay % 8) != 0 || (mode->hsync_start % 8) != 0 ||