Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1590382ybv; Thu, 20 Feb 2020 23:52:27 -0800 (PST) X-Google-Smtp-Source: APXvYqxD3/+kyPWcboie+KgNbVq89tMHkY0gcM4ekHU6JVlZGc4jA7T2CBifL5MAV0nessUX43fE X-Received: by 2002:a05:6808:3ae:: with SMTP id n14mr944727oie.63.1582271546901; Thu, 20 Feb 2020 23:52:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582271546; cv=none; d=google.com; s=arc-20160816; b=PYBA6Uc2tLc01XmrucyGAglI/RSuRz2kgs0ypqvqT8wGvxqP5Nr2acpkhlqxvz1CDo yUMkQNrUzmqBQXbKBsBKBrQ8qGeoTKwi+wLYfD1jD7bNXUhGANmpTZVaTQITBxsXD3I4 hhlBgh9/Zp/n4Ua/VztUuEhMZG7bmqsIQpsUxai3e54FtAV44ENh99jtUyZUycOosC+r GIoR+IsfHsP1xACnvPfHpPVsQJ3UYVK/5h5ExrZneqv+8iSmmzuK1nVVXM+JDgqI5AET HDiy4BUVrg4hULawv9oIyN8QS7j2xiqaFfR59i66LTb5M7m2qtbnKPevJC/RHO8UGczW 1gYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dEz9fBPYXmo4yWCl20RLSYHAisJRwy8QOnJnzW9SE/U=; b=UWHoXNXn9OOdAhpLMFJX31haAkkaHPUYXO2cpmPhy9sxclNdgLZIIzf8rcGCNyxZL5 yFLG2UolHef4WsY/JOtDsU2yAa9+OVtYleCp4/3KRP9EsbBEsebjlOlgpFad2AaVyjEI WKyOtwzknzfCkBEwQn9P1t6KkzV/9p47XDMQasAzgmOEsNiuQq6QtJZNhCrkpvhacQBF NnHg6hm4XBbnjNodOKNE/Lpc82ysnUnXeDSOLhhkvBXEm9P7VdTupfvGhOmDjxVHCPrH FQrbXUS9f13eujKP6TGB7aNLBgVLG66dA2SguGEHdxTibmMS8G8huJFKTpIyVIzmbMQE iSCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=P9CjUSgP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l20si1042271otr.202.2020.02.20.23.52.14; Thu, 20 Feb 2020 23:52:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=P9CjUSgP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729856AbgBUHwL (ORCPT + 99 others); Fri, 21 Feb 2020 02:52:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:49872 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728922AbgBUHwJ (ORCPT ); Fri, 21 Feb 2020 02:52:09 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E55562073A; Fri, 21 Feb 2020 07:52:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582271528; bh=SGwJ19PYYNJ30y9HmCXBx8/78rLo48SVOdN2zqLluVU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P9CjUSgPObZjpGmXxlFfXkukA0PK80roPX3OeegNv8rUjRPyUazWwb6K2bpzyCF6E mGyr8h+PKUywulBdbZZJYrr4pfKBq794jgmcJxSH8LFxRH/gqXBZ3yMxTWhpd07kWW 1Rc2PtnbNzwF/E853DrDcxO0b58CQulKmlbdt2kA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Dave Airlie , Manasi Navare , Sasha Levin Subject: [PATCH 5.5 193/399] drm/fbdev: Fallback to non tiled mode if all tiles not present Date: Fri, 21 Feb 2020 08:38:38 +0100 Message-Id: <20200221072421.574891894@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200221072402.315346745@linuxfoundation.org> References: <20200221072402.315346745@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Manasi Navare [ Upstream commit f25c7a006cd1c07254780e3406e45cee4842b933 ] In case of tiled displays, if we hotplug just one connector, fbcon currently just selects the preferred mode and if it is tiled mode then that becomes a problem if rest of the tiles are not present. So in the fbdev driver on hotplug when we probe the client modeset, if we dont find all the connectors for all tiles, then on a connector with one tile, just fallback to the first available non tiled mode to display over a single connector. On the hotplug of the consecutive tiled connectors, if the tiled mode no longer exists because of fbcon size limitation, then return no modes for consecutive tiles but retain the non tiled mode on the 0th tile. Use the same logic in case of connected boot case as well. This has been tested with Dell UP328K tiled monitor. v2: * Set the modes on consecutive hotplugged tiles to no mode if tiled mode is pruned (Dave) v1: * Just handle the 1st connector hotplug case * v1 Reviewed-by: Dave Airlie Suggested-by: Ville Syrjälä Suggested-by: Dave Airlie Cc: Ville Syrjälä Cc: Dave Airlie Signed-off-by: Manasi Navare Reviewed-by: Dave Airlie Link: https://patchwork.freedesktop.org/patch/msgid/20191113222952.9231-1-manasi.d.navare@intel.com Signed-off-by: Sasha Levin --- drivers/gpu/drm/drm_client_modeset.c | 72 ++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/drivers/gpu/drm/drm_client_modeset.c b/drivers/gpu/drm/drm_client_modeset.c index 895b73f23079a..6d4a29e99ae26 100644 --- a/drivers/gpu/drm/drm_client_modeset.c +++ b/drivers/gpu/drm/drm_client_modeset.c @@ -114,6 +114,33 @@ drm_client_find_modeset(struct drm_client_dev *client, struct drm_crtc *crtc) return NULL; } +static struct drm_display_mode * +drm_connector_get_tiled_mode(struct drm_connector *connector) +{ + struct drm_display_mode *mode; + + list_for_each_entry(mode, &connector->modes, head) { + if (mode->hdisplay == connector->tile_h_size && + mode->vdisplay == connector->tile_v_size) + return mode; + } + return NULL; +} + +static struct drm_display_mode * +drm_connector_fallback_non_tiled_mode(struct drm_connector *connector) +{ + struct drm_display_mode *mode; + + list_for_each_entry(mode, &connector->modes, head) { + if (mode->hdisplay == connector->tile_h_size && + mode->vdisplay == connector->tile_v_size) + continue; + return mode; + } + return NULL; +} + static struct drm_display_mode * drm_connector_has_preferred_mode(struct drm_connector *connector, int width, int height) { @@ -348,8 +375,15 @@ static bool drm_client_target_preferred(struct drm_connector **connectors, struct drm_connector *connector; u64 conn_configured = 0; int tile_pass = 0; + int num_tiled_conns = 0; int i; + for (i = 0; i < connector_count; i++) { + if (connectors[i]->has_tile && + connectors[i]->status == connector_status_connected) + num_tiled_conns++; + } + retry: for (i = 0; i < connector_count; i++) { connector = connectors[i]; @@ -399,6 +433,28 @@ retry: list_for_each_entry(modes[i], &connector->modes, head) break; } + /* + * In case of tiled mode if all tiles not present fallback to + * first available non tiled mode. + * After all tiles are present, try to find the tiled mode + * for all and if tiled mode not present due to fbcon size + * limitations, use first non tiled mode only for + * tile 0,0 and set to no mode for all other tiles. + */ + if (connector->has_tile) { + if (num_tiled_conns < + connector->num_h_tile * connector->num_v_tile || + (connector->tile_h_loc == 0 && + connector->tile_v_loc == 0 && + !drm_connector_get_tiled_mode(connector))) { + DRM_DEBUG_KMS("Falling back to non tiled mode on Connector %d\n", + connector->base.id); + modes[i] = drm_connector_fallback_non_tiled_mode(connector); + } else { + modes[i] = drm_connector_get_tiled_mode(connector); + } + } + DRM_DEBUG_KMS("found mode %s\n", modes[i] ? modes[i]->name : "none"); conn_configured |= BIT_ULL(i); @@ -515,6 +571,7 @@ static bool drm_client_firmware_config(struct drm_client_dev *client, bool fallback = true, ret = true; int num_connectors_enabled = 0; int num_connectors_detected = 0; + int num_tiled_conns = 0; struct drm_modeset_acquire_ctx ctx; if (!drm_drv_uses_atomic_modeset(dev)) @@ -532,6 +589,11 @@ static bool drm_client_firmware_config(struct drm_client_dev *client, memcpy(save_enabled, enabled, count); mask = GENMASK(count - 1, 0); conn_configured = 0; + for (i = 0; i < count; i++) { + if (connectors[i]->has_tile && + connectors[i]->status == connector_status_connected) + num_tiled_conns++; + } retry: conn_seq = conn_configured; for (i = 0; i < count; i++) { @@ -631,6 +693,16 @@ retry: connector->name); modes[i] = &connector->state->crtc->mode; } + /* + * In case of tiled modes, if all tiles are not present + * then fallback to a non tiled mode. + */ + if (connector->has_tile && + num_tiled_conns < connector->num_h_tile * connector->num_v_tile) { + DRM_DEBUG_KMS("Falling back to non tiled mode on Connector %d\n", + connector->base.id); + modes[i] = drm_connector_fallback_non_tiled_mode(connector); + } crtcs[i] = new_crtc; DRM_DEBUG_KMS("connector %s on [CRTC:%d:%s]: %dx%d%s\n", -- 2.20.1