From patchwork Fri Oct 11 06:43:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13832148 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 12DE7D2447F for ; Fri, 11 Oct 2024 06:57:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0807110EA4E; Fri, 11 Oct 2024 06:57:12 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by gabe.freedesktop.org (Postfix) with ESMTPS id 88E6510EA4A for ; Fri, 11 Oct 2024 06:57:10 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 5B3BB1F7DB; Fri, 11 Oct 2024 06:57:09 +0000 (UTC) Authentication-Results: smtp-out2.suse.de; none Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 1DFF313AAF; Fri, 11 Oct 2024 06:57:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id iFIQBkXMCGcRfAAAD6G6ig (envelope-from ); Fri, 11 Oct 2024 06:57:09 +0000 From: Thomas Zimmermann To: maarten.lankhorst@linux.intel.com, mripard@kernel.org, airlied@gmail.com, simona@ffwll.ch, jani.nikula@linux.intel.com, airlied@redhat.com, jfalempe@redhat.com Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 1/7] drm/probe-helper: Call connector detect functions in single helper Date: Fri, 11 Oct 2024 08:43:06 +0200 Message-ID: <20241011065705.6728-2-tzimmermann@suse.de> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241011065705.6728-1-tzimmermann@suse.de> References: <20241011065705.6728-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Queue-Id: 5B3BB1F7DB X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" Move the logic to call the connector's detect helper into a single internal function. Reduces code duplication. Signed-off-by: Thomas Zimmermann Acked-by: Maxime Ripard --- drivers/gpu/drm/drm_probe_helper.c | 33 +++++++++++++++--------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c index 92f21764246f..62a2e5bcb315 100644 --- a/drivers/gpu/drm/drm_probe_helper.c +++ b/drivers/gpu/drm/drm_probe_helper.c @@ -338,10 +338,23 @@ void drm_kms_helper_poll_reschedule(struct drm_device *dev) } EXPORT_SYMBOL(drm_kms_helper_poll_reschedule); +static int detect_connector_status(struct drm_connector *connector, + struct drm_modeset_acquire_ctx *ctx, + bool force) +{ + const struct drm_connector_helper_funcs *funcs = connector->helper_private; + + if (funcs->detect_ctx) + return funcs->detect_ctx(connector, ctx, force); + else if (connector->funcs->detect) + return connector->funcs->detect(connector, force); + + return connector_status_connected; +} + static enum drm_connector_status drm_helper_probe_detect_ctx(struct drm_connector *connector, bool force) { - const struct drm_connector_helper_funcs *funcs = connector->helper_private; struct drm_modeset_acquire_ctx ctx; int ret; @@ -349,14 +362,8 @@ drm_helper_probe_detect_ctx(struct drm_connector *connector, bool force) retry: ret = drm_modeset_lock(&connector->dev->mode_config.connection_mutex, &ctx); - if (!ret) { - if (funcs->detect_ctx) - ret = funcs->detect_ctx(connector, &ctx, force); - else if (connector->funcs->detect) - ret = connector->funcs->detect(connector, force); - else - ret = connector_status_connected; - } + if (!ret) + ret = detect_connector_status(connector, &ctx, force); if (ret == -EDEADLK) { drm_modeset_backoff(&ctx); @@ -390,7 +397,6 @@ drm_helper_probe_detect(struct drm_connector *connector, struct drm_modeset_acquire_ctx *ctx, bool force) { - const struct drm_connector_helper_funcs *funcs = connector->helper_private; struct drm_device *dev = connector->dev; int ret; @@ -401,12 +407,7 @@ drm_helper_probe_detect(struct drm_connector *connector, if (ret) return ret; - if (funcs->detect_ctx) - ret = funcs->detect_ctx(connector, ctx, force); - else if (connector->funcs->detect) - ret = connector->funcs->detect(connector, force); - else - ret = connector_status_connected; + ret = detect_connector_status(connector, ctx, force); if (ret != connector->status) connector->epoch_counter += 1; From patchwork Fri Oct 11 06:43:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13832147 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B1A42D2447B for ; Fri, 11 Oct 2024 06:57:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CA70C10EA4B; Fri, 11 Oct 2024 06:57:11 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by gabe.freedesktop.org (Postfix) with ESMTPS id D122610EA4A for ; Fri, 11 Oct 2024 06:57:10 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 9EF811F829; Fri, 11 Oct 2024 06:57:09 +0000 (UTC) Authentication-Results: smtp-out2.suse.de; none Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 60F781370C; Fri, 11 Oct 2024 06:57:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id wIhaFkXMCGcRfAAAD6G6ig (envelope-from ); Fri, 11 Oct 2024 06:57:09 +0000 From: Thomas Zimmermann To: maarten.lankhorst@linux.intel.com, mripard@kernel.org, airlied@gmail.com, simona@ffwll.ch, jani.nikula@linux.intel.com, airlied@redhat.com, jfalempe@redhat.com Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 2/7] drm: Add physical status to connector Date: Fri, 11 Oct 2024 08:43:07 +0200 Message-ID: <20241011065705.6728-3-tzimmermann@suse.de> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241011065705.6728-1-tzimmermann@suse.de> References: <20241011065705.6728-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Queue-Id: 9EF811F829 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" Track the connector's physical status in addition to its logical status. The latter is directly derived from the former and for most connectors both values are in sync. Server chips with BMC, such as Aspeed, Matrox and HiSilicon, often provide virtual outputs for remote management. Without a connected display, fbcon or userspace compositors disabek the output and stop displaying to the BMC. Connectors have therefore to remain in connected status, even if the display has been physically disconnected. Tracking both physical and logical state in separate fields will enable that. The physical status is transparent to drivers and clients, but changes update the epoch counter. This generates a hotplug events for clients. Clients will then pick up changes to resolutions supported, if any. The ast driver already contains code to track the physical status. This commit generalizes the logic for use with other drivers. Candidates are mgag200 and hibmc. This commit adds the physical status and makes the regular, logical status a copy of it. A later change will add the flag for BMC support. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/drm_connector.c | 1 + drivers/gpu/drm/drm_probe_helper.c | 13 ++++++++----- include/drm/drm_connector.h | 7 +++++++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index fc35f47e2849..901d73416f98 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -282,6 +282,7 @@ static int __drm_connector_init(struct drm_device *dev, connector->edid_blob_ptr = NULL; connector->epoch_counter = 0; connector->tile_blob_ptr = NULL; + connector->physical_status = connector_status_unknown; connector->status = connector_status_unknown; connector->display_info.panel_orientation = DRM_MODE_PANEL_ORIENTATION_UNKNOWN; diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c index 62a2e5bcb315..df44be128e72 100644 --- a/drivers/gpu/drm/drm_probe_helper.c +++ b/drivers/gpu/drm/drm_probe_helper.c @@ -373,7 +373,7 @@ drm_helper_probe_detect_ctx(struct drm_connector *connector, bool force) if (WARN_ON(ret < 0)) ret = connector_status_unknown; - if (ret != connector->status) + if (ret != connector->physical_status) connector->epoch_counter += 1; drm_modeset_drop_locks(&ctx); @@ -409,7 +409,7 @@ drm_helper_probe_detect(struct drm_connector *connector, ret = detect_connector_status(connector, ctx, force); - if (ret != connector->status) + if (ret != connector->physical_status) connector->epoch_counter += 1; return ret; @@ -588,9 +588,11 @@ int drm_helper_probe_single_connector_modes(struct drm_connector *connector, if (connector->force) { if (connector->force == DRM_FORCE_ON || connector->force == DRM_FORCE_ON_DIGITAL) - connector->status = connector_status_connected; + connector->physical_status = connector_status_connected; else - connector->status = connector_status_disconnected; + connector->physical_status = connector_status_disconnected; + connector->status = connector->physical_status; + if (connector->funcs->force) connector->funcs->force(connector); } else { @@ -602,7 +604,8 @@ int drm_helper_probe_single_connector_modes(struct drm_connector *connector, } else if (WARN(ret < 0, "Invalid return value %i for connector detection\n", ret)) ret = connector_status_unknown; - connector->status = ret; + connector->physical_status = ret; + connector->status = connector->physical_status; } /* diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index e3fa43291f44..37e951f04ae8 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -1817,6 +1817,13 @@ struct drm_connector { */ struct list_head modes; + /** + * @physical_status: + * One of the drm_connector_status enums (connected, not, or unknown). + * Protected by &drm_mode_config.mutex. + */ + enum drm_connector_status physical_status; + /** * @status: * One of the drm_connector_status enums (connected, not, or unknown). From patchwork Fri Oct 11 06:43:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13832151 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 26E26CEDDBD for ; Fri, 11 Oct 2024 06:57:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E266810EA4C; Fri, 11 Oct 2024 06:57:12 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.b="xYtoZ7WU"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="1yT0MI+D"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="rCLyr+r0"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="ny8y7m43"; dkim-atps=neutral Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4FE8A10EA49 for ; Fri, 11 Oct 2024 06:57:11 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id E32F321A6F; Fri, 11 Oct 2024 06:57:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728629830; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PifacVumwg9pPaDWPoP6jBh129aR6RpTxJeS75jSS5s=; b=xYtoZ7WUq/Oh7GFa7koLYJ/cTQpGbdTlK5//Y8o4fnn3WjcOu1g3z/bzroAarOTzsMuXv2 Wp/XbY2JbHa3HqrnnCKmozLHrM6VDwXY+CQMXOEfWVuemWc/wtfw8xFZ9Bs5Kd9CWfZbcW hVTtvvToIACg33lzw/MiP04qRx0Fp2k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728629830; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PifacVumwg9pPaDWPoP6jBh129aR6RpTxJeS75jSS5s=; b=1yT0MI+DX+PLuApaf2shY6gsLJSuxpWCd7xKVu1lfuziv9cnG4bvFUTDqcrFna/3lMEbuo CrrOutv1zZSfkSAQ== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728629829; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PifacVumwg9pPaDWPoP6jBh129aR6RpTxJeS75jSS5s=; b=rCLyr+r0mg0rK1YCugXVaESnWECHhzbyaJ7fNaBHZRUTXGmZb0jNjbK0xj28Wwb/bl7W2/ RBXUmx9qqZ3lgeTNR2mfwiK+FoCTgBpJVRVpFz08E5O1K6eXUWVvsGZF0lOy9YXAcKMk/T rA+9vTrcyxqfeYCWpZOYQkr/eJXKJrc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728629829; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PifacVumwg9pPaDWPoP6jBh129aR6RpTxJeS75jSS5s=; b=ny8y7m43XZP+1QhR27NvygGajYD5UsXsX5dHtoK0JtOpcxBHFIDFCrKaH4Rh4vh6m1i/iM tbsVASv3XNU/DYAw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id A47B613AAF; Fri, 11 Oct 2024 06:57:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id IPb0JkXMCGcRfAAAD6G6ig (envelope-from ); Fri, 11 Oct 2024 06:57:09 +0000 From: Thomas Zimmermann To: maarten.lankhorst@linux.intel.com, mripard@kernel.org, airlied@gmail.com, simona@ffwll.ch, jani.nikula@linux.intel.com, airlied@redhat.com, jfalempe@redhat.com Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 3/7] drm: Add bmc_attached flag to connector Date: Fri, 11 Oct 2024 08:43:08 +0200 Message-ID: <20241011065705.6728-4-tzimmermann@suse.de> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241011065705.6728-1-tzimmermann@suse.de> References: <20241011065705.6728-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_SEVEN(0.00)[9]; FUZZY_BLOCKED(0.00)[rspamd.com]; FREEMAIL_TO(0.00)[linux.intel.com,kernel.org,gmail.com,ffwll.ch,redhat.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:mid]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" Add the bmc_attached flag to struct drm_connector to signal the presence of a virtual BMC output. The connector reports to be in status connected even without a physically connected display. Fbcon or userspace compositors would otherwise stop displaying to the BMC. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/drm_probe_helper.c | 6 +++++- include/drm/drm_connector.h | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c index df44be128e72..83c3f2d42d49 100644 --- a/drivers/gpu/drm/drm_probe_helper.c +++ b/drivers/gpu/drm/drm_probe_helper.c @@ -605,7 +605,11 @@ int drm_helper_probe_single_connector_modes(struct drm_connector *connector, ret = connector_status_unknown; connector->physical_status = ret; - connector->status = connector->physical_status; + + if (connector->bmc_attached) + connector->status = connector_status_connected; + else + connector->status = connector->physical_status; } /* diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index 37e951f04ae8..ed360ae35f21 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -1802,6 +1802,14 @@ struct drm_connector { */ bool ycbcr_420_allowed; + /** + * @ bmc_attached: + * The connector has a BMC transparently attached to it. It has to + * report a connected status, even without a physically connected + * display. + */ + bool bmc_attached; + /** * @registration_state: Is this connector initializing, exposed * (registered) with userspace, or unregistered? From patchwork Fri Oct 11 06:43:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13832149 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3346FCEDDA9 for ; Fri, 11 Oct 2024 06:57:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1023A10EA50; Fri, 11 Oct 2024 06:57:12 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8745E10EA4A for ; Fri, 11 Oct 2024 06:57:11 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 3268C1F82C; Fri, 11 Oct 2024 06:57:10 +0000 (UTC) Authentication-Results: smtp-out2.suse.de; none Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id E94461370C; Fri, 11 Oct 2024 06:57:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id gKjCN0XMCGcRfAAAD6G6ig (envelope-from ); Fri, 11 Oct 2024 06:57:09 +0000 From: Thomas Zimmermann To: maarten.lankhorst@linux.intel.com, mripard@kernel.org, airlied@gmail.com, simona@ffwll.ch, jani.nikula@linux.intel.com, airlied@redhat.com, jfalempe@redhat.com Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 4/7] drm/ast: sil164: Clear EDID if no display is connected Date: Fri, 11 Oct 2024 08:43:09 +0200 Message-ID: <20241011065705.6728-5-tzimmermann@suse.de> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241011065705.6728-1-tzimmermann@suse.de> References: <20241011065705.6728-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Queue-Id: 3268C1F82C X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" Do not keep the obsolete EDID around after unplugging the display form the connector. Signed-off-by: Thomas Zimmermann Fixes: d20c2f846428 ("drm/ast: sil164: Transparently handle BMC support") Cc: Thomas Zimmermann Cc: Jocelyn Falempe Cc: Dave Airlie Cc: dri-devel@lists.freedesktop.org --- drivers/gpu/drm/ast/ast_sil164.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/ast/ast_sil164.c b/drivers/gpu/drm/ast/ast_sil164.c index 6a72268d2314..be01254dd48a 100644 --- a/drivers/gpu/drm/ast/ast_sil164.c +++ b/drivers/gpu/drm/ast/ast_sil164.c @@ -29,6 +29,8 @@ static int ast_sil164_connector_helper_get_modes(struct drm_connector *connector if (ast_connector->physical_status == connector_status_connected) { count = drm_connector_helper_get_modes(connector); } else { + drm_edid_connector_update(connector, NULL); + /* * There's no EDID data without a connected monitor. Set BMC- * compatible modes in this case. The XGA default resolution From patchwork Fri Oct 11 06:43:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13832153 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2ABB0D2447F for ; Fri, 11 Oct 2024 06:57:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9C4EC10EA55; Fri, 11 Oct 2024 06:57:22 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.b="LdYrJmRY"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="ZbV+lnr1"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="LdYrJmRY"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="ZbV+lnr1"; dkim-atps=neutral Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by gabe.freedesktop.org (Postfix) with ESMTPS id 11F0B10EA51 for ; Fri, 11 Oct 2024 06:57:12 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 7405F1F83B; Fri, 11 Oct 2024 06:57:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728629830; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=240OxqMZ+evPhMs7RXqmZjEKRD5jfaQCPSFXvnuxXvU=; b=LdYrJmRYkCxJF3slT/yHNk+/L95Yi8ARolJ6PAF2OS4rzR9Zt0i2JzP3p9cKTKLnJWNlDp taqSdQrIx1NlpOn5HzptODcI43kVZFYNDyN/b678dENV7RJVlUjx9v/rkhDnfrexblriRu Ri6u6HGT8u0TpkOhzxWI7DCZXGEK9SU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728629830; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=240OxqMZ+evPhMs7RXqmZjEKRD5jfaQCPSFXvnuxXvU=; b=ZbV+lnr1kJGRQ+p1OA9Zh0/4I6VSdE8M4ddaCXyzmanWz8lDhquVc4KhyLhTnhN/GIN8uG +bmsvyFa4MdHueCw== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728629830; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=240OxqMZ+evPhMs7RXqmZjEKRD5jfaQCPSFXvnuxXvU=; b=LdYrJmRYkCxJF3slT/yHNk+/L95Yi8ARolJ6PAF2OS4rzR9Zt0i2JzP3p9cKTKLnJWNlDp taqSdQrIx1NlpOn5HzptODcI43kVZFYNDyN/b678dENV7RJVlUjx9v/rkhDnfrexblriRu Ri6u6HGT8u0TpkOhzxWI7DCZXGEK9SU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728629830; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=240OxqMZ+evPhMs7RXqmZjEKRD5jfaQCPSFXvnuxXvU=; b=ZbV+lnr1kJGRQ+p1OA9Zh0/4I6VSdE8M4ddaCXyzmanWz8lDhquVc4KhyLhTnhN/GIN8uG +bmsvyFa4MdHueCw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 382AB13AAF; Fri, 11 Oct 2024 06:57:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 8LaNDEbMCGcRfAAAD6G6ig (envelope-from ); Fri, 11 Oct 2024 06:57:10 +0000 From: Thomas Zimmermann To: maarten.lankhorst@linux.intel.com, mripard@kernel.org, airlied@gmail.com, simona@ffwll.ch, jani.nikula@linux.intel.com, airlied@redhat.com, jfalempe@redhat.com Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 5/7] drm/ast: vga: Clear EDID if no display is connected Date: Fri, 11 Oct 2024 08:43:10 +0200 Message-ID: <20241011065705.6728-6-tzimmermann@suse.de> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241011065705.6728-1-tzimmermann@suse.de> References: <20241011065705.6728-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:email]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; FREEMAIL_TO(0.00)[linux.intel.com,kernel.org,gmail.com,ffwll.ch,redhat.com]; RCPT_COUNT_SEVEN(0.00)[9]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; R_RATELIMIT(0.00)[to_ip_from(RLqirfcw6gnbcr9a9yhi49fhi6)]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" Do not keep the obsolete EDID around after unplugging the display form the connector. Signed-off-by: Thomas Zimmermann Fixes: 2a2391f857cd ("drm/ast: vga: Transparently handle BMC support") Cc: Thomas Zimmermann Cc: Jocelyn Falempe Cc: Dave Airlie Cc: dri-devel@lists.freedesktop.org --- drivers/gpu/drm/ast/ast_vga.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/ast/ast_vga.c b/drivers/gpu/drm/ast/ast_vga.c index 5c79b773af57..abe0fff8485c 100644 --- a/drivers/gpu/drm/ast/ast_vga.c +++ b/drivers/gpu/drm/ast/ast_vga.c @@ -29,6 +29,8 @@ static int ast_vga_connector_helper_get_modes(struct drm_connector *connector) if (ast_connector->physical_status == connector_status_connected) { count = drm_connector_helper_get_modes(connector); } else { + drm_edid_connector_update(connector, NULL); + /* * There's no EDID data without a connected monitor. Set BMC- * compatible modes in this case. The XGA default resolution From patchwork Fri Oct 11 06:43:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13832150 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 430ECD2447B for ; Fri, 11 Oct 2024 06:57:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C91FB10EA4A; Fri, 11 Oct 2024 06:57:12 +0000 (UTC) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by gabe.freedesktop.org (Postfix) with ESMTPS id E7C0810EA4C for ; Fri, 11 Oct 2024 06:57:11 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id BD5D921A74; Fri, 11 Oct 2024 06:57:10 +0000 (UTC) Authentication-Results: smtp-out1.suse.de; none Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 7A9CF1370C; Fri, 11 Oct 2024 06:57:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id mACvHEbMCGcRfAAAD6G6ig (envelope-from ); Fri, 11 Oct 2024 06:57:10 +0000 From: Thomas Zimmermann To: maarten.lankhorst@linux.intel.com, mripard@kernel.org, airlied@gmail.com, simona@ffwll.ch, jani.nikula@linux.intel.com, airlied@redhat.com, jfalempe@redhat.com Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 6/7] drm/ast: Track physical connector status in struct drm_connector Date: Fri, 11 Oct 2024 08:43:11 +0200 Message-ID: <20241011065705.6728-7-tzimmermann@suse.de> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241011065705.6728-1-tzimmermann@suse.de> References: <20241011065705.6728-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Queue-Id: BD5D921A74 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" Set bmc_attached for all connectors and let DRM's probe helpers track the physical and logical connector state. Remove such logic and related data structures from ast. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/ast/ast_dp.c | 21 ++++++--------------- drivers/gpu/drm/ast/ast_dp501.c | 17 ++++------------- drivers/gpu/drm/ast/ast_drv.h | 24 ++++-------------------- drivers/gpu/drm/ast/ast_sil164.c | 17 ++++------------- drivers/gpu/drm/ast/ast_vga.c | 28 ++++------------------------ 5 files changed, 22 insertions(+), 85 deletions(-) diff --git a/drivers/gpu/drm/ast/ast_dp.c b/drivers/gpu/drm/ast/ast_dp.c index 0e282b7b167c..b62c39479367 100644 --- a/drivers/gpu/drm/ast/ast_dp.c +++ b/drivers/gpu/drm/ast/ast_dp.c @@ -328,9 +328,9 @@ static void ast_astdp_encoder_helper_atomic_enable(struct drm_encoder *encoder, struct drm_atomic_state *state) { struct ast_device *ast = to_ast_device(encoder->dev); - struct ast_connector *ast_connector = &ast->output.astdp.connector; + struct drm_connector *connector = &ast->output.astdp.connector; - if (ast_connector->physical_status == connector_status_connected) { + if (connector->physical_status == connector_status_connected) { ast_dp_set_phy_sleep(ast, false); ast_dp_link_training(ast); @@ -360,10 +360,9 @@ static const struct drm_encoder_helper_funcs ast_astdp_encoder_helper_funcs = { static int ast_astdp_connector_helper_get_modes(struct drm_connector *connector) { - struct ast_connector *ast_connector = to_ast_connector(connector); int count; - if (ast_connector->physical_status == connector_status_connected) { + if (connector->physical_status == connector_status_connected) { struct ast_device *ast = to_ast_device(connector->dev); const struct drm_edid *drm_edid; @@ -391,7 +390,6 @@ static int ast_astdp_connector_helper_detect_ctx(struct drm_connector *connector struct drm_modeset_acquire_ctx *ctx, bool force) { - struct ast_connector *ast_connector = to_ast_connector(connector); struct ast_device *ast = to_ast_device(connector->dev); enum drm_connector_status status = connector_status_disconnected; bool phy_sleep; @@ -410,11 +408,7 @@ static int ast_astdp_connector_helper_detect_ctx(struct drm_connector *connector mutex_unlock(&ast->modeset_lock); - if (status != ast_connector->physical_status) - ++connector->epoch_counter; - ast_connector->physical_status = status; - - return connector_status_connected; + return status; } static const struct drm_connector_helper_funcs ast_astdp_connector_helper_funcs = { @@ -439,7 +433,6 @@ int ast_astdp_output_init(struct ast_device *ast) struct drm_device *dev = &ast->base; struct drm_crtc *crtc = &ast->crtc; struct drm_encoder *encoder; - struct ast_connector *ast_connector; struct drm_connector *connector; int ret; @@ -456,8 +449,7 @@ int ast_astdp_output_init(struct ast_device *ast) /* connector */ - ast_connector = &ast->output.astdp.connector; - connector = &ast_connector->base; + connector = &ast->output.astdp.connector; ret = drm_connector_init(dev, connector, &ast_astdp_connector_funcs, DRM_MODE_CONNECTOR_DisplayPort); if (ret) @@ -466,10 +458,9 @@ int ast_astdp_output_init(struct ast_device *ast) connector->interlace_allowed = 0; connector->doublescan_allowed = 0; + connector->bmc_attached = true; connector->polled = DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT; - ast_connector->physical_status = connector->status; - ret = drm_connector_attach_encoder(connector, encoder); if (ret) return ret; diff --git a/drivers/gpu/drm/ast/ast_dp501.c b/drivers/gpu/drm/ast/ast_dp501.c index 9e19d8c17730..8ffe30c74d3d 100644 --- a/drivers/gpu/drm/ast/ast_dp501.c +++ b/drivers/gpu/drm/ast/ast_dp501.c @@ -503,10 +503,9 @@ static const struct drm_encoder_helper_funcs ast_dp501_encoder_helper_funcs = { static int ast_dp501_connector_helper_get_modes(struct drm_connector *connector) { - struct ast_connector *ast_connector = to_ast_connector(connector); int count; - if (ast_connector->physical_status == connector_status_connected) { + if (connector->physical_status == connector_status_connected) { struct ast_device *ast = to_ast_device(connector->dev); const struct drm_edid *drm_edid; @@ -534,18 +533,13 @@ static int ast_dp501_connector_helper_detect_ctx(struct drm_connector *connector struct drm_modeset_acquire_ctx *ctx, bool force) { - struct ast_connector *ast_connector = to_ast_connector(connector); struct ast_device *ast = to_ast_device(connector->dev); enum drm_connector_status status = connector_status_disconnected; if (ast_dp501_is_connected(ast)) status = connector_status_connected; - if (status != ast_connector->physical_status) - ++connector->epoch_counter; - ast_connector->physical_status = status; - - return connector_status_connected; + return status; } static const struct drm_connector_helper_funcs ast_dp501_connector_helper_funcs = { @@ -570,7 +564,6 @@ int ast_dp501_output_init(struct ast_device *ast) struct drm_device *dev = &ast->base; struct drm_crtc *crtc = &ast->crtc; struct drm_encoder *encoder; - struct ast_connector *ast_connector; struct drm_connector *connector; int ret; @@ -587,8 +580,7 @@ int ast_dp501_output_init(struct ast_device *ast) /* connector */ - ast_connector = &ast->output.dp501.connector; - connector = &ast_connector->base; + connector = &ast->output.dp501.connector; ret = drm_connector_init(dev, connector, &ast_dp501_connector_funcs, DRM_MODE_CONNECTOR_DisplayPort); if (ret) @@ -597,10 +589,9 @@ int ast_dp501_output_init(struct ast_device *ast) connector->interlace_allowed = 0; connector->doublescan_allowed = 0; + connector->bmc_attached = true; connector->polled = DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT; - ast_connector->physical_status = connector->status; - ret = drm_connector_attach_encoder(connector, encoder); if (ret) return ret; diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h index 21ce3769bf0d..a6887e90dc17 100644 --- a/drivers/gpu/drm/ast/ast_drv.h +++ b/drivers/gpu/drm/ast/ast_drv.h @@ -141,22 +141,6 @@ static inline struct ast_plane *to_ast_plane(struct drm_plane *plane) return container_of(plane, struct ast_plane, base); } -/* - * Connector - */ - -struct ast_connector { - struct drm_connector base; - - enum drm_connector_status physical_status; -}; - -static inline struct ast_connector * -to_ast_connector(struct drm_connector *connector) -{ - return container_of(connector, struct ast_connector, base); -} - /* * Device */ @@ -190,19 +174,19 @@ struct ast_device { union { struct { struct drm_encoder encoder; - struct ast_connector connector; + struct drm_connector connector; } vga; struct { struct drm_encoder encoder; - struct ast_connector connector; + struct drm_connector connector; } sil164; struct { struct drm_encoder encoder; - struct ast_connector connector; + struct drm_connector connector; } dp501; struct { struct drm_encoder encoder; - struct ast_connector connector; + struct drm_connector connector; } astdp; } output; diff --git a/drivers/gpu/drm/ast/ast_sil164.c b/drivers/gpu/drm/ast/ast_sil164.c index be01254dd48a..aba5b8aa4307 100644 --- a/drivers/gpu/drm/ast/ast_sil164.c +++ b/drivers/gpu/drm/ast/ast_sil164.c @@ -23,10 +23,9 @@ static const struct drm_encoder_funcs ast_sil164_encoder_funcs = { static int ast_sil164_connector_helper_get_modes(struct drm_connector *connector) { - struct ast_connector *ast_connector = to_ast_connector(connector); int count; - if (ast_connector->physical_status == connector_status_connected) { + if (connector->physical_status == connector_status_connected) { count = drm_connector_helper_get_modes(connector); } else { drm_edid_connector_update(connector, NULL); @@ -48,16 +47,11 @@ static int ast_sil164_connector_helper_detect_ctx(struct drm_connector *connecto struct drm_modeset_acquire_ctx *ctx, bool force) { - struct ast_connector *ast_connector = to_ast_connector(connector); enum drm_connector_status status; status = drm_connector_helper_detect_from_ddc(connector, ctx, force); - if (status != ast_connector->physical_status) - ++connector->epoch_counter; - ast_connector->physical_status = status; - - return connector_status_connected; + return status; } static const struct drm_connector_helper_funcs ast_sil164_connector_helper_funcs = { @@ -83,7 +77,6 @@ int ast_sil164_output_init(struct ast_device *ast) struct drm_crtc *crtc = &ast->crtc; struct i2c_adapter *ddc; struct drm_encoder *encoder; - struct ast_connector *ast_connector; struct drm_connector *connector; int ret; @@ -104,8 +97,7 @@ int ast_sil164_output_init(struct ast_device *ast) /* connector */ - ast_connector = &ast->output.sil164.connector; - connector = &ast_connector->base; + connector = &ast->output.sil164.connector; ret = drm_connector_init_with_ddc(dev, connector, &ast_sil164_connector_funcs, DRM_MODE_CONNECTOR_DVII, ddc); if (ret) @@ -114,10 +106,9 @@ int ast_sil164_output_init(struct ast_device *ast) connector->interlace_allowed = 0; connector->doublescan_allowed = 0; + connector->bmc_attached = true; connector->polled = DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT; - ast_connector->physical_status = connector->status; - ret = drm_connector_attach_encoder(connector, encoder); if (ret) return ret; diff --git a/drivers/gpu/drm/ast/ast_vga.c b/drivers/gpu/drm/ast/ast_vga.c index abe0fff8485c..d78f00c47cc5 100644 --- a/drivers/gpu/drm/ast/ast_vga.c +++ b/drivers/gpu/drm/ast/ast_vga.c @@ -23,10 +23,9 @@ static const struct drm_encoder_funcs ast_vga_encoder_funcs = { static int ast_vga_connector_helper_get_modes(struct drm_connector *connector) { - struct ast_connector *ast_connector = to_ast_connector(connector); int count; - if (ast_connector->physical_status == connector_status_connected) { + if (connector->physical_status == connector_status_connected) { count = drm_connector_helper_get_modes(connector); } else { drm_edid_connector_update(connector, NULL); @@ -44,25 +43,9 @@ static int ast_vga_connector_helper_get_modes(struct drm_connector *connector) return count; } -static int ast_vga_connector_helper_detect_ctx(struct drm_connector *connector, - struct drm_modeset_acquire_ctx *ctx, - bool force) -{ - struct ast_connector *ast_connector = to_ast_connector(connector); - enum drm_connector_status status; - - status = drm_connector_helper_detect_from_ddc(connector, ctx, force); - - if (status != ast_connector->physical_status) - ++connector->epoch_counter; - ast_connector->physical_status = status; - - return connector_status_connected; -} - static const struct drm_connector_helper_funcs ast_vga_connector_helper_funcs = { .get_modes = ast_vga_connector_helper_get_modes, - .detect_ctx = ast_vga_connector_helper_detect_ctx, + .detect_ctx = drm_connector_helper_detect_from_ddc, }; static const struct drm_connector_funcs ast_vga_connector_funcs = { @@ -83,7 +66,6 @@ int ast_vga_output_init(struct ast_device *ast) struct drm_crtc *crtc = &ast->crtc; struct i2c_adapter *ddc; struct drm_encoder *encoder; - struct ast_connector *ast_connector; struct drm_connector *connector; int ret; @@ -104,8 +86,7 @@ int ast_vga_output_init(struct ast_device *ast) /* connector */ - ast_connector = &ast->output.vga.connector; - connector = &ast_connector->base; + connector = &ast->output.vga.connector; ret = drm_connector_init_with_ddc(dev, connector, &ast_vga_connector_funcs, DRM_MODE_CONNECTOR_VGA, ddc); if (ret) @@ -114,10 +95,9 @@ int ast_vga_output_init(struct ast_device *ast) connector->interlace_allowed = 0; connector->doublescan_allowed = 0; + connector->bmc_attached = true; connector->polled = DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT; - ast_connector->physical_status = connector->status; - ret = drm_connector_attach_encoder(connector, encoder); if (ret) return ret; From patchwork Fri Oct 11 06:43:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13832152 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C9E4DD2447F for ; Fri, 11 Oct 2024 06:57:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4767810EA52; Fri, 11 Oct 2024 06:57:20 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.b="Vy603nhZ"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="ZRB+PJ6Y"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Vy603nhZ"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="ZRB+PJ6Y"; dkim-atps=neutral Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7C3D610EA4C for ; Fri, 11 Oct 2024 06:57:12 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 060FA21A77; Fri, 11 Oct 2024 06:57:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728629831; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gE50FJfPXUIe0AgbV2fCywiznOF8gGtDL3nanKch2OI=; b=Vy603nhZL0QNlGNpndcUZab8Vgx2xdXHePqv6OU0J9evrOkPijjJGrU3QGnu5+qUYVefOA wFadCI3O28mSCLslbkHqOY1ON3KP1MnVF25FrERKfPaMJNxGsL0aWZfVBUguIjkQvyBH0s gsqW5/ya5ybgQxgX+DAC0k+pAsfddwU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728629831; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gE50FJfPXUIe0AgbV2fCywiznOF8gGtDL3nanKch2OI=; b=ZRB+PJ6YyoFImDOreBHUJPh7eak9+YtBNzgylPp78iuEFuoDhiH5d4v5J16LmnRl/ZBw7z 24sxqg8q6T6/vMCg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728629831; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gE50FJfPXUIe0AgbV2fCywiznOF8gGtDL3nanKch2OI=; b=Vy603nhZL0QNlGNpndcUZab8Vgx2xdXHePqv6OU0J9evrOkPijjJGrU3QGnu5+qUYVefOA wFadCI3O28mSCLslbkHqOY1ON3KP1MnVF25FrERKfPaMJNxGsL0aWZfVBUguIjkQvyBH0s gsqW5/ya5ybgQxgX+DAC0k+pAsfddwU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728629831; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gE50FJfPXUIe0AgbV2fCywiznOF8gGtDL3nanKch2OI=; b=ZRB+PJ6YyoFImDOreBHUJPh7eak9+YtBNzgylPp78iuEFuoDhiH5d4v5J16LmnRl/ZBw7z 24sxqg8q6T6/vMCg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id BED2F13AB0; Fri, 11 Oct 2024 06:57:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id KB5VLUbMCGcRfAAAD6G6ig (envelope-from ); Fri, 11 Oct 2024 06:57:10 +0000 From: Thomas Zimmermann To: maarten.lankhorst@linux.intel.com, mripard@kernel.org, airlied@gmail.com, simona@ffwll.ch, jani.nikula@linux.intel.com, airlied@redhat.com, jfalempe@redhat.com Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 7/7] drm/mgag200: Track physical connector status in struct drm_connector Date: Fri, 11 Oct 2024 08:43:12 +0200 Message-ID: <20241011065705.6728-8-tzimmermann@suse.de> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241011065705.6728-1-tzimmermann@suse.de> References: <20241011065705.6728-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:mid]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; FREEMAIL_TO(0.00)[linux.intel.com,kernel.org,gmail.com,ffwll.ch,redhat.com]; RCPT_COUNT_SEVEN(0.00)[9]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; R_RATELIMIT(0.00)[to_ip_from(RLqirfcw6gnbcr9a9yhi49fhi6)]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" Set bmc_attached for the VGA connector on servers and let DRM's probe helpers track the physical and logical connector state. Remove similar logic from mgag200. Also resolve a design issue, where mgag200 uses the connector's edid_blob_ptr. It is an internal value that drivers should not access directly. Reported-by: Jani Nikula Closes: https://lore.kernel.org/dri-devel/87msjtxk8f.fsf@intel.com/raw Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/mgag200/mgag200_vga_bmc.c | 32 +++++------------------ 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_vga_bmc.c b/drivers/gpu/drm/mgag200/mgag200_vga_bmc.c index a5a3ac108bd5..cff333572b29 100644 --- a/drivers/gpu/drm/mgag200/mgag200_vga_bmc.c +++ b/drivers/gpu/drm/mgag200/mgag200_vga_bmc.c @@ -54,9 +54,11 @@ static int mgag200_vga_bmc_connector_helper_get_modes(struct drm_connector *conn const struct mgag200_device_info *minfo = mdev->info; int count; - count = drm_connector_helper_get_modes(connector); + if (connector->physical_status == connector_status_connected) { + count = drm_connector_helper_get_modes(connector); + } else { + drm_edid_connector_update(connector, NULL); - if (!count) { /* * There's no EDID data without a connected monitor. Set BMC- * compatible modes in this case. The XGA default resolution @@ -70,32 +72,9 @@ static int mgag200_vga_bmc_connector_helper_get_modes(struct drm_connector *conn return count; } -/* - * There's no monitor connected if the DDC did not return an EDID. Still - * return 'connected' as there's always a BMC. Incrementing the connector's - * epoch counter triggers an update of the related properties. - */ -static int mgag200_vga_bmc_connector_helper_detect_ctx(struct drm_connector *connector, - struct drm_modeset_acquire_ctx *ctx, - bool force) -{ - enum drm_connector_status old_status, status; - - if (connector->edid_blob_ptr) - old_status = connector_status_connected; - else - old_status = connector_status_disconnected; - - status = drm_connector_helper_detect_from_ddc(connector, ctx, force); - - if (status != old_status) - ++connector->epoch_counter; - return connector_status_connected; -} - static const struct drm_connector_helper_funcs mgag200_vga_connector_helper_funcs = { .get_modes = mgag200_vga_bmc_connector_helper_get_modes, - .detect_ctx = mgag200_vga_bmc_connector_helper_detect_ctx, + .detect_ctx = drm_connector_helper_detect_from_ddc, }; static const struct drm_connector_funcs mgag200_vga_connector_funcs = { @@ -143,6 +122,7 @@ int mgag200_vga_bmc_output_init(struct mga_device *mdev) } drm_connector_helper_add(connector, &mgag200_vga_connector_helper_funcs); + connector->bmc_attached = true; connector->polled = DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT;