From patchwork Mon Jan 23 10:05:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 645634 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2FB02C61D9D for ; Mon, 23 Jan 2023 10:06:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230231AbjAWKGK (ORCPT ); Mon, 23 Jan 2023 05:06:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231560AbjAWKGJ (ORCPT ); Mon, 23 Jan 2023 05:06:09 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 063A016315; Mon, 23 Jan 2023 02:06:04 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 5508C1F889; Mon, 23 Jan 2023 10:06:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1674468363; 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=bkFQqvsdRxbFh+T/xgjgYaZo/8sz/0LHQ7jzsk0ZmNc=; b=IxlggJCX5eptJEbbt89dsYsqOQL3CcCd/jl8HcCrVk+gHfhuQbOGvIeZUZ1QvzTW+GmCAh oFxI/I5i+AHptXDxJCidonU+b60L7fM9lg9Zutu37sq1YfrtLl7PBRrl7/weCuvjU2uHIe hJbwEazwJg00FMjnfTJydL/P9idlQh4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1674468363; 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=bkFQqvsdRxbFh+T/xgjgYaZo/8sz/0LHQ7jzsk0ZmNc=; b=WeOHZ9iU/M+5h2CI9xHfchLimjDaFF64H+dR4bpe8MQpfjAFxYS7/j0oBSsxSRmZiWXYj+ T6/6w+8j+csotLCQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 0E54A139FE; Mon, 23 Jan 2023 10:06:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id wG2YAgtczmO+DwAAMHmgww (envelope-from ); Mon, 23 Jan 2023 10:06:03 +0000 From: Thomas Zimmermann To: airlied@gmail.com, daniel@ffwll.ch, maarten.lankhorst@linux.intel.com, mripard@kernel.org, javierm@redhat.com Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-tegra@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 01/10] drm/client: Test for connectors before sending hotplug event Date: Mon, 23 Jan 2023 11:05:50 +0100 Message-Id: <20230123100559.12351-2-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230123100559.12351-1-tzimmermann@suse.de> References: <20230123100559.12351-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Test for connectors in the client code and remove a similar test from the generic fbdev emulation. Do nothing if the test fails. Not having connectors indicates a driver bug. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/drm_client.c | 5 +++++ drivers/gpu/drm/drm_fbdev_generic.c | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_client.c b/drivers/gpu/drm/drm_client.c index 262ec64d4397..09ac191c202d 100644 --- a/drivers/gpu/drm/drm_client.c +++ b/drivers/gpu/drm/drm_client.c @@ -198,6 +198,11 @@ void drm_client_dev_hotplug(struct drm_device *dev) if (!drm_core_check_feature(dev, DRIVER_MODESET)) return; + if (!dev->mode_config.num_connector) { + drm_dbg_kms(dev, "No connectors found, will not send hotplug events!\n"); + return; + } + mutex_lock(&dev->clientlist_mutex); list_for_each_entry(client, &dev->clientlist, list) { if (!client->funcs || !client->funcs->hotplug) diff --git a/drivers/gpu/drm/drm_fbdev_generic.c b/drivers/gpu/drm/drm_fbdev_generic.c index 0a4c160e0e58..3d455a2e3fb5 100644 --- a/drivers/gpu/drm/drm_fbdev_generic.c +++ b/drivers/gpu/drm/drm_fbdev_generic.c @@ -389,11 +389,6 @@ static int drm_fbdev_client_hotplug(struct drm_client_dev *client) if (dev->fb_helper) return drm_fb_helper_hotplug_event(dev->fb_helper); - if (!dev->mode_config.num_connector) { - drm_dbg_kms(dev, "No connectors found, will not create framebuffer!\n"); - return 0; - } - drm_fb_helper_prepare(dev, fb_helper, &drm_fb_helper_generic_funcs); ret = drm_fb_helper_init(dev, fb_helper); From patchwork Mon Jan 23 10:05:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 647320 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5337C61DA4 for ; Mon, 23 Jan 2023 10:06:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231758AbjAWKGK (ORCPT ); Mon, 23 Jan 2023 05:06:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231580AbjAWKGJ (ORCPT ); Mon, 23 Jan 2023 05:06:09 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 078E95592; Mon, 23 Jan 2023 02:06:04 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id A00C61F88C; Mon, 23 Jan 2023 10:06:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1674468363; 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=Eo0f0ziBdtPN9cBdDtmQB+JADnGJzSFyqXzDLQUPm/A=; b=zn1EzsA4Vvl2Rh9l9KA6K26MQLR4gRVmSr2zawZzgSAbaL5uxxA7fLd0HHFXOEvJcvRIvW h0WM8NusZ0mgvwXX/wONGr9flFvPc7DxumevX7kV9qNmyCoQsAoBVQaiutx79kma+JsPxa sGmnUgyofmUrPx+RyTDCEcdVF2qBGnI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1674468363; 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=Eo0f0ziBdtPN9cBdDtmQB+JADnGJzSFyqXzDLQUPm/A=; b=5OVL8DNr970iC4orZjkgJlH2phFiM3gBS1DZ8B8HZrsfuN6X2/dq1+Hq4roHhNp+vapzwG kPTAd36Zj8cpsEDQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 58BF6134F5; Mon, 23 Jan 2023 10:06:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id SIXSFAtczmO+DwAAMHmgww (envelope-from ); Mon, 23 Jan 2023 10:06:03 +0000 From: Thomas Zimmermann To: airlied@gmail.com, daniel@ffwll.ch, maarten.lankhorst@linux.intel.com, mripard@kernel.org, javierm@redhat.com Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-tegra@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 02/10] drm/client: Add hotplug_failed flag Date: Mon, 23 Jan 2023 11:05:51 +0100 Message-Id: <20230123100559.12351-3-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230123100559.12351-1-tzimmermann@suse.de> References: <20230123100559.12351-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Signal failed hotplugging with a flag in struct drm_client_dev. If set, the client helpers will not further try to set up the fbdev display. This used to be signalled with a combination of cleared pointers in struct drm_fb_helper, which prevents us from initializing these pointers early after allocation. The change also harmonizes behavior among DRM clients. Additional DRM clients will now handle failed hotplugging like fbdev does. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/drm_client.c | 5 +++++ drivers/gpu/drm/drm_fbdev_generic.c | 4 ---- include/drm/drm_client.h | 8 ++++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_client.c b/drivers/gpu/drm/drm_client.c index 09ac191c202d..009e7b10455c 100644 --- a/drivers/gpu/drm/drm_client.c +++ b/drivers/gpu/drm/drm_client.c @@ -208,8 +208,13 @@ void drm_client_dev_hotplug(struct drm_device *dev) if (!client->funcs || !client->funcs->hotplug) continue; + if (client->hotplug_failed) + continue; + ret = client->funcs->hotplug(client); drm_dbg_kms(dev, "%s: ret=%d\n", client->name, ret); + if (ret) + client->hotplug_failed = true; } mutex_unlock(&dev->clientlist_mutex); } diff --git a/drivers/gpu/drm/drm_fbdev_generic.c b/drivers/gpu/drm/drm_fbdev_generic.c index 3d455a2e3fb5..135d58b8007b 100644 --- a/drivers/gpu/drm/drm_fbdev_generic.c +++ b/drivers/gpu/drm/drm_fbdev_generic.c @@ -382,10 +382,6 @@ static int drm_fbdev_client_hotplug(struct drm_client_dev *client) struct drm_device *dev = client->dev; int ret; - /* Setup is not retried if it has failed */ - if (!fb_helper->dev && fb_helper->funcs) - return 0; - if (dev->fb_helper) return drm_fb_helper_hotplug_event(dev->fb_helper); diff --git a/include/drm/drm_client.h b/include/drm/drm_client.h index 4fc8018eddda..39482527a775 100644 --- a/include/drm/drm_client.h +++ b/include/drm/drm_client.h @@ -106,6 +106,14 @@ struct drm_client_dev { * @modesets: CRTC configurations */ struct drm_mode_set *modesets; + + /** + * @hotplug failed: + * + * Set by client hotplug helpers if the hotplugging failed + * before. It is usually not tried again. + */ + bool hotplug_failed; }; int drm_client_init(struct drm_device *dev, struct drm_client_dev *client, From patchwork Mon Jan 23 10:05:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 645632 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2441BC636CC for ; Mon, 23 Jan 2023 10:06:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231768AbjAWKGM (ORCPT ); Mon, 23 Jan 2023 05:06:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231614AbjAWKGJ (ORCPT ); Mon, 23 Jan 2023 05:06:09 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CE3CA25E; Mon, 23 Jan 2023 02:06:05 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id E92381F88D; Mon, 23 Jan 2023 10:06:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1674468363; 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=0bIGptZFfSoD5WJxS1vaUVITwwhclc5PpfsYYgkXcHI=; b=SUuP23Q2ZFfkocL6W6/SsSFMDE9DCgHq2PwTyXJ63EtN4k3uDowLlxKnJiZoo4k14lrd6s XHIWDrd6U7Lti81xzBd7yvJFZi0FkQp9vfA7Tds7n9QzWMlNUN1a/f+Y92vHA3kEdt5gZk 9CqVv0eO3+sCfTpQG+RPm4Tn7ObNE9w= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1674468363; 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=0bIGptZFfSoD5WJxS1vaUVITwwhclc5PpfsYYgkXcHI=; b=QDNDK0JM/de1SMaCMBI6LrdbgBb5bphjkE32rI4pK6sb5JRz0/CnctANbug6kkkkRkZA0/ 2mIFKk8hX030pbDA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id A3E22139FE; Mon, 23 Jan 2023 10:06:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id WJ4PJwtczmO+DwAAMHmgww (envelope-from ); Mon, 23 Jan 2023 10:06:03 +0000 From: Thomas Zimmermann To: airlied@gmail.com, daniel@ffwll.ch, maarten.lankhorst@linux.intel.com, mripard@kernel.org, javierm@redhat.com Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-tegra@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 03/10] drm/fb-helper: Introduce drm_fb_helper_unprepare() Date: Mon, 23 Jan 2023 11:05:52 +0100 Message-Id: <20230123100559.12351-4-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230123100559.12351-1-tzimmermann@suse.de> References: <20230123100559.12351-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Move the fb-helper clean-up code into drm_fb_helper_unprepare(). No functional changes. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/drm_fb_helper.c | 14 +++++++++++++- include/drm/drm_fb_helper.h | 4 ++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index c5c13e192b64..4379bcd7718b 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -435,6 +435,18 @@ void drm_fb_helper_prepare(struct drm_device *dev, struct drm_fb_helper *helper, } EXPORT_SYMBOL(drm_fb_helper_prepare); +/** + * drm_fb_helper_unprepare - clean up a drm_fb_helper structure + * @fb_helper: driver-allocated fbdev helper structure to set up + * + * Cleans up the framebuffer helper. Inverse of drm_fb_helper_prepare(). + */ +void drm_fb_helper_unprepare(struct drm_fb_helper *fb_helper) +{ + mutex_destroy(&fb_helper->lock); +} +EXPORT_SYMBOL(drm_fb_helper_unprepare); + /** * drm_fb_helper_init - initialize a &struct drm_fb_helper * @dev: drm device @@ -561,7 +573,7 @@ void drm_fb_helper_fini(struct drm_fb_helper *fb_helper) } mutex_unlock(&kernel_fb_helper_lock); - mutex_destroy(&fb_helper->lock); + drm_fb_helper_unprepare(fb_helper); if (!fb_helper->client.funcs) drm_client_release(&fb_helper->client); diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h index f443e1f11654..123f2ef035c5 100644 --- a/include/drm/drm_fb_helper.h +++ b/include/drm/drm_fb_helper.h @@ -230,6 +230,7 @@ drm_fb_helper_from_client(struct drm_client_dev *client) #ifdef CONFIG_DRM_FBDEV_EMULATION void drm_fb_helper_prepare(struct drm_device *dev, struct drm_fb_helper *helper, const struct drm_fb_helper_funcs *funcs); +void drm_fb_helper_unprepare(struct drm_fb_helper *fb_helper); int drm_fb_helper_init(struct drm_device *dev, struct drm_fb_helper *helper); void drm_fb_helper_fini(struct drm_fb_helper *helper); int drm_fb_helper_blank(int blank, struct fb_info *info); @@ -295,6 +296,9 @@ static inline void drm_fb_helper_prepare(struct drm_device *dev, const struct drm_fb_helper_funcs *funcs) { } +void drm_fb_helper_unprepare(struct drm_fb_helper *fb_helper) +{ +} static inline int drm_fb_helper_init(struct drm_device *dev, struct drm_fb_helper *helper) From patchwork Mon Jan 23 10:05:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 645633 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32732C61DB3 for ; Mon, 23 Jan 2023 10:06:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231741AbjAWKGL (ORCPT ); Mon, 23 Jan 2023 05:06:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231602AbjAWKGJ (ORCPT ); Mon, 23 Jan 2023 05:06:09 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CB34A25C; Mon, 23 Jan 2023 02:06:05 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 3C7271F88E; Mon, 23 Jan 2023 10:06:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1674468364; 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=/JNXSH2jIbyrZQ/ublt+0Y9YLxXlg5ibmb+zIaFCthg=; b=v0ipOVKW+5HbZeCnPjx/h3dH6elhmcluoYIHKQnZtD+Lme43fZIgP/KmKLp1qLVlJVD+xr eFtxyeFivhDhEG19Fp1egwdmS1r7mWTrg/RosM8XjSS+wSv+53LLzKsgVBgmZqvMbxmcG7 vsUa8pnrH0gU1LgbZ27mPCswYFL7/Gw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1674468364; 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=/JNXSH2jIbyrZQ/ublt+0Y9YLxXlg5ibmb+zIaFCthg=; b=lEYBjAsoXnbb87EjUyIdrE5Z1+Pq08Hl5eLEJWAzdQcZdOoREGSnqkkHHPv8hv7KMxZovD KhtnOhgv8aTtBeDg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id EEAED134F5; Mon, 23 Jan 2023 10:06:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id SDAXOQtczmO+DwAAMHmgww (envelope-from ); Mon, 23 Jan 2023 10:06:03 +0000 From: Thomas Zimmermann To: airlied@gmail.com, daniel@ffwll.ch, maarten.lankhorst@linux.intel.com, mripard@kernel.org, javierm@redhat.com Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-tegra@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 04/10] drm/fbdev-generic: Initialize fb-helper structure in generic setup Date: Mon, 23 Jan 2023 11:05:53 +0100 Message-Id: <20230123100559.12351-5-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230123100559.12351-1-tzimmermann@suse.de> References: <20230123100559.12351-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Initialize the fb-helper structure immediately after its allocation in drm_fbdev_generic_setup(). That will make it easier to fill it with driver-specific values, such as the preferred BPP. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/drm_fbdev_generic.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_fbdev_generic.c b/drivers/gpu/drm/drm_fbdev_generic.c index 135d58b8007b..63f66325a8a5 100644 --- a/drivers/gpu/drm/drm_fbdev_generic.c +++ b/drivers/gpu/drm/drm_fbdev_generic.c @@ -385,8 +385,6 @@ static int drm_fbdev_client_hotplug(struct drm_client_dev *client) if (dev->fb_helper) return drm_fb_helper_hotplug_event(dev->fb_helper); - drm_fb_helper_prepare(dev, fb_helper, &drm_fb_helper_generic_funcs); - ret = drm_fb_helper_init(dev, fb_helper); if (ret) goto err; @@ -456,12 +454,12 @@ void drm_fbdev_generic_setup(struct drm_device *dev, fb_helper = kzalloc(sizeof(*fb_helper), GFP_KERNEL); if (!fb_helper) return; + drm_fb_helper_prepare(dev, fb_helper, &drm_fb_helper_generic_funcs); ret = drm_client_init(dev, &fb_helper->client, "fbdev", &drm_fbdev_client_funcs); if (ret) { - kfree(fb_helper); drm_err(dev, "Failed to register client: %d\n", ret); - return; + goto err_drm_client_init; } /* @@ -484,5 +482,12 @@ void drm_fbdev_generic_setup(struct drm_device *dev, drm_dbg_kms(dev, "client hotplug ret=%d\n", ret); drm_client_register(&fb_helper->client); + + return; + +err_drm_client_init: + drm_fb_helper_unprepare(fb_helper); + kfree(fb_helper); + return; } EXPORT_SYMBOL(drm_fbdev_generic_setup); From patchwork Mon Jan 23 10:05:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 647318 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ED09DC636D3 for ; Mon, 23 Jan 2023 10:06:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231779AbjAWKGM (ORCPT ); Mon, 23 Jan 2023 05:06:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231550AbjAWKGJ (ORCPT ); Mon, 23 Jan 2023 05:06:09 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FFFACC3C; Mon, 23 Jan 2023 02:06:06 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 859FD1F891; Mon, 23 Jan 2023 10:06:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1674468364; 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=mHNXQj920Mp49rolvcUr11B4LETXxMqwdnjXrBs6lqg=; b=YBlRgIZ45NwXldKeG7v5yWfXo1SqCQU8ZaWmIsamYcrFqU/dA8GheJtdCoKbm3BTJ2Swt0 Fr1PkVySeFkEn681xWxuT3490qP7SNYmyf4kXOs+hp40FjXmuFMhUhFhiEh3sCF5n4Cn6Y TKgXUHhyqj8ZTFo5BA6a+Uhz8T4Q40k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1674468364; 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=mHNXQj920Mp49rolvcUr11B4LETXxMqwdnjXrBs6lqg=; b=Ez1WMinI4TCH3gUJ3B5bDOBcJUSpoxJrySc0p7pgl6KHxc0w+5HE1qs6TL9Rlff17tzIpf xgCNwRZz6reDwdBA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 41D8D139FE; Mon, 23 Jan 2023 10:06:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 6IYiDwxczmO+DwAAMHmgww (envelope-from ); Mon, 23 Jan 2023 10:06:04 +0000 From: Thomas Zimmermann To: airlied@gmail.com, daniel@ffwll.ch, maarten.lankhorst@linux.intel.com, mripard@kernel.org, javierm@redhat.com Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-tegra@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 05/10] drm/fb-helper: Remove preferred_bpp parameter from fbdev internals Date: Mon, 23 Jan 2023 11:05:54 +0100 Message-Id: <20230123100559.12351-6-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230123100559.12351-1-tzimmermann@suse.de> References: <20230123100559.12351-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Store the console's preferred BPP value in struct drm_fb_helper and remove the respective function parameters from the internal fbdev code. The BPP value is only required as a fallback and will now always be available in the fb-helper instance. No functional changes. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/drm_fb_helper.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 4379bcd7718b..258103d317ac 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -1786,7 +1786,7 @@ static uint32_t drm_fb_helper_find_color_mode_format(struct drm_fb_helper *fb_he return drm_fb_helper_find_format(fb_helper, formats, format_count, bpp, depth); } -static int __drm_fb_helper_find_sizes(struct drm_fb_helper *fb_helper, int preferred_bpp, +static int __drm_fb_helper_find_sizes(struct drm_fb_helper *fb_helper, struct drm_fb_helper_surface_size *sizes) { struct drm_client_dev *client = &fb_helper->client; @@ -1831,7 +1831,7 @@ static int __drm_fb_helper_find_sizes(struct drm_fb_helper *fb_helper, int prefe surface_format = drm_fb_helper_find_color_mode_format(fb_helper, plane->format_types, plane->format_count, - preferred_bpp); + fb_helper->preferred_bpp); if (surface_format != DRM_FORMAT_INVALID) break; /* found supported format */ } @@ -1903,7 +1903,7 @@ static int __drm_fb_helper_find_sizes(struct drm_fb_helper *fb_helper, int prefe return 0; } -static int drm_fb_helper_find_sizes(struct drm_fb_helper *fb_helper, int preferred_bpp, +static int drm_fb_helper_find_sizes(struct drm_fb_helper *fb_helper, struct drm_fb_helper_surface_size *sizes) { struct drm_client_dev *client = &fb_helper->client; @@ -1912,7 +1912,7 @@ static int drm_fb_helper_find_sizes(struct drm_fb_helper *fb_helper, int preferr int ret; mutex_lock(&client->modeset_mutex); - ret = __drm_fb_helper_find_sizes(fb_helper, preferred_bpp, sizes); + ret = __drm_fb_helper_find_sizes(fb_helper, sizes); mutex_unlock(&client->modeset_mutex); if (ret) @@ -1934,15 +1934,14 @@ static int drm_fb_helper_find_sizes(struct drm_fb_helper *fb_helper, int preferr * Allocates the backing storage and sets up the fbdev info structure through * the ->fb_probe callback. */ -static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper, - int preferred_bpp) +static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper) { struct drm_client_dev *client = &fb_helper->client; struct drm_device *dev = fb_helper->dev; struct drm_fb_helper_surface_size sizes; int ret; - ret = drm_fb_helper_find_sizes(fb_helper, preferred_bpp, &sizes); + ret = drm_fb_helper_find_sizes(fb_helper, &sizes); if (ret) { /* First time: disable all crtc's.. */ if (!fb_helper->deferred_setup) @@ -2125,8 +2124,7 @@ static void drm_setup_crtcs_fb(struct drm_fb_helper *fb_helper) /* Note: Drops fb_helper->lock before returning. */ static int -__drm_fb_helper_initial_config_and_unlock(struct drm_fb_helper *fb_helper, - int bpp_sel) +__drm_fb_helper_initial_config_and_unlock(struct drm_fb_helper *fb_helper) { struct drm_device *dev = fb_helper->dev; struct fb_info *info; @@ -2137,10 +2135,9 @@ __drm_fb_helper_initial_config_and_unlock(struct drm_fb_helper *fb_helper, height = dev->mode_config.max_height; drm_client_modeset_probe(&fb_helper->client, width, height); - ret = drm_fb_helper_single_fb_probe(fb_helper, bpp_sel); + ret = drm_fb_helper_single_fb_probe(fb_helper); if (ret < 0) { if (ret == -EAGAIN) { - fb_helper->preferred_bpp = bpp_sel; fb_helper->deferred_setup = true; ret = 0; } @@ -2231,8 +2228,10 @@ int drm_fb_helper_initial_config(struct drm_fb_helper *fb_helper, int bpp_sel) if (!drm_fbdev_emulation) return 0; + fb_helper->preferred_bpp = bpp_sel; + mutex_lock(&fb_helper->lock); - ret = __drm_fb_helper_initial_config_and_unlock(fb_helper, bpp_sel); + ret = __drm_fb_helper_initial_config_and_unlock(fb_helper); return ret; } @@ -2268,8 +2267,7 @@ int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper) mutex_lock(&fb_helper->lock); if (fb_helper->deferred_setup) { - err = __drm_fb_helper_initial_config_and_unlock(fb_helper, - fb_helper->preferred_bpp); + err = __drm_fb_helper_initial_config_and_unlock(fb_helper); return err; } From patchwork Mon Jan 23 10:05:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 647317 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA719C54EED for ; Mon, 23 Jan 2023 10:06:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231781AbjAWKGO (ORCPT ); Mon, 23 Jan 2023 05:06:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231709AbjAWKGK (ORCPT ); Mon, 23 Jan 2023 05:06:10 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52B77D513; Mon, 23 Jan 2023 02:06:06 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id E355234210; Mon, 23 Jan 2023 10:06:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1674468364; 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=O/xtJivrfLTY54rz6F/LCUIR8SHSDSSrKAoLo5uPV4g=; b=BebsJxR9ibAHXGgqkKr1mThg8UQRPdsZZec4uYa9P8oqFZrB6CzXXUoflLe4K0gHbG2JCt wj1HgKx+cFzoAUMkHiGldPFeO0CgQ079cuI74il8pjrEXburRmCfx5rhbXUXr89rwkkfrK 5SO532eLMeDRMrc4qHEdKRCnDRgO0kM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1674468364; 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=O/xtJivrfLTY54rz6F/LCUIR8SHSDSSrKAoLo5uPV4g=; b=TGz+xtAz6rmHRsa3Q2GprzZGZGFdwFXTz6oSFq0HGdOZAHoxx4pHsCfTJkwHbD72Q/A9sN YoJ2mZehQlQs4iBQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8C355134F5; Mon, 23 Jan 2023 10:06:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id AGRNIQxczmO+DwAAMHmgww (envelope-from ); Mon, 23 Jan 2023 10:06:04 +0000 From: Thomas Zimmermann To: airlied@gmail.com, daniel@ffwll.ch, maarten.lankhorst@linux.intel.com, mripard@kernel.org, javierm@redhat.com Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-tegra@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 06/10] drm/fb-helper: Initialize fb-helper's preferred BPP in prepare function Date: Mon, 23 Jan 2023 11:05:55 +0100 Message-Id: <20230123100559.12351-7-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230123100559.12351-1-tzimmermann@suse.de> References: <20230123100559.12351-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Initialize the fb-helper's preferred_bpp field early from within drm_fb_helper_prepare(); instead of the later client hot-plugging callback. This simplifies the generic fbdev setup function. No real changes, but all drivers' fbdev code has to be adapted. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/armada/armada_fbdev.c | 4 ++-- drivers/gpu/drm/drm_fb_helper.c | 22 ++++++++++++++++++---- drivers/gpu/drm/drm_fbdev_generic.c | 19 ++----------------- drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 4 ++-- drivers/gpu/drm/gma500/framebuffer.c | 4 ++-- drivers/gpu/drm/i915/display/intel_fbdev.c | 11 ++++++----- drivers/gpu/drm/msm/msm_fbdev.c | 4 ++-- drivers/gpu/drm/omapdrm/omap_fbdev.c | 4 ++-- drivers/gpu/drm/radeon/radeon_fb.c | 4 ++-- drivers/gpu/drm/tegra/fb.c | 7 +++---- include/drm/drm_fb_helper.h | 3 ++- 11 files changed, 43 insertions(+), 43 deletions(-) diff --git a/drivers/gpu/drm/armada/armada_fbdev.c b/drivers/gpu/drm/armada/armada_fbdev.c index 584cee123bd8..07e410c62b7a 100644 --- a/drivers/gpu/drm/armada/armada_fbdev.c +++ b/drivers/gpu/drm/armada/armada_fbdev.c @@ -129,7 +129,7 @@ int armada_fbdev_init(struct drm_device *dev) priv->fbdev = fbh; - drm_fb_helper_prepare(dev, fbh, &armada_fb_helper_funcs); + drm_fb_helper_prepare(dev, fbh, 32, &armada_fb_helper_funcs); ret = drm_fb_helper_init(dev, fbh); if (ret) { @@ -137,7 +137,7 @@ int armada_fbdev_init(struct drm_device *dev) goto err_fb_helper; } - ret = drm_fb_helper_initial_config(fbh, 32); + ret = drm_fb_helper_initial_config(fbh); if (ret) { DRM_ERROR("failed to set initial config\n"); goto err_fb_setup; diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 258103d317ac..28c428e9c530 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -416,14 +416,30 @@ static void drm_fb_helper_damage_work(struct work_struct *work) * drm_fb_helper_prepare - setup a drm_fb_helper structure * @dev: DRM device * @helper: driver-allocated fbdev helper structure to set up + * @preferred_bpp: Preferred bits per pixel for the device. * @funcs: pointer to structure of functions associate with this helper * * Sets up the bare minimum to make the framebuffer helper usable. This is * useful to implement race-free initialization of the polling helpers. */ void drm_fb_helper_prepare(struct drm_device *dev, struct drm_fb_helper *helper, + unsigned int preferred_bpp, const struct drm_fb_helper_funcs *funcs) { + /* + * Pick a preferred bpp of 32 if no value has been given. This + * will select XRGB8888 for the framebuffer formats. All drivers + * have to support XRGB8888 for backwards compatibility with legacy + * userspace, so it's the safe choice here. + * + * TODO: Replace struct drm_mode_config.preferred_depth and this + * bpp value with a preferred format that is given as struct + * drm_format_info. Then derive all other values from the + * format. + */ + if (!preferred_bpp) + preferred_bpp = 32; + INIT_LIST_HEAD(&helper->kernel_fb_list); spin_lock_init(&helper->damage_lock); INIT_WORK(&helper->resume_work, drm_fb_helper_resume_worker); @@ -432,6 +448,7 @@ void drm_fb_helper_prepare(struct drm_device *dev, struct drm_fb_helper *helper, mutex_init(&helper->lock); helper->funcs = funcs; helper->dev = dev; + helper->preferred_bpp = preferred_bpp; } EXPORT_SYMBOL(drm_fb_helper_prepare); @@ -2183,7 +2200,6 @@ __drm_fb_helper_initial_config_and_unlock(struct drm_fb_helper *fb_helper) /** * drm_fb_helper_initial_config - setup a sane initial connector configuration * @fb_helper: fb_helper device struct - * @bpp_sel: bpp value to use for the framebuffer configuration * * Scans the CRTCs and connectors and tries to put together an initial setup. * At the moment, this is a cloned configuration across all heads with @@ -2221,15 +2237,13 @@ __drm_fb_helper_initial_config_and_unlock(struct drm_fb_helper *fb_helper) * RETURNS: * Zero if everything went ok, nonzero otherwise. */ -int drm_fb_helper_initial_config(struct drm_fb_helper *fb_helper, int bpp_sel) +int drm_fb_helper_initial_config(struct drm_fb_helper *fb_helper) { int ret; if (!drm_fbdev_emulation) return 0; - fb_helper->preferred_bpp = bpp_sel; - mutex_lock(&fb_helper->lock); ret = __drm_fb_helper_initial_config_and_unlock(fb_helper); diff --git a/drivers/gpu/drm/drm_fbdev_generic.c b/drivers/gpu/drm/drm_fbdev_generic.c index 63f66325a8a5..6ae014040df3 100644 --- a/drivers/gpu/drm/drm_fbdev_generic.c +++ b/drivers/gpu/drm/drm_fbdev_generic.c @@ -392,7 +392,7 @@ static int drm_fbdev_client_hotplug(struct drm_client_dev *client) if (!drm_drv_uses_atomic_modeset(dev)) drm_helper_disable_unused_functions(dev); - ret = drm_fb_helper_initial_config(fb_helper, fb_helper->preferred_bpp); + ret = drm_fb_helper_initial_config(fb_helper); if (ret) goto err_cleanup; @@ -454,7 +454,7 @@ void drm_fbdev_generic_setup(struct drm_device *dev, fb_helper = kzalloc(sizeof(*fb_helper), GFP_KERNEL); if (!fb_helper) return; - drm_fb_helper_prepare(dev, fb_helper, &drm_fb_helper_generic_funcs); + drm_fb_helper_prepare(dev, fb_helper, preferred_bpp, &drm_fb_helper_generic_funcs); ret = drm_client_init(dev, &fb_helper->client, "fbdev", &drm_fbdev_client_funcs); if (ret) { @@ -462,21 +462,6 @@ void drm_fbdev_generic_setup(struct drm_device *dev, goto err_drm_client_init; } - /* - * Pick a preferred bpp of 32 if no value has been given. This - * will select XRGB8888 for the framebuffer formats. All drivers - * have to support XRGB8888 for backwards compatibility with legacy - * userspace, so it's the safe choice here. - * - * TODO: Replace struct drm_mode_config.preferred_depth and this - * bpp value with a preferred format that is given as struct - * drm_format_info. Then derive all other values from the - * format. - */ - if (!preferred_bpp) - preferred_bpp = 32; - fb_helper->preferred_bpp = preferred_bpp; - ret = drm_fbdev_client_hotplug(&fb_helper->client); if (ret) drm_dbg_kms(dev, "client hotplug ret=%d\n", ret); diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c index 55c92372fca0..b89e33af8da8 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c @@ -163,7 +163,7 @@ int exynos_drm_fbdev_init(struct drm_device *dev) private->fb_helper = helper = &fbdev->drm_fb_helper; - drm_fb_helper_prepare(dev, helper, &exynos_drm_fb_helper_funcs); + drm_fb_helper_prepare(dev, helper, PREFERRED_BPP, &exynos_drm_fb_helper_funcs); ret = drm_fb_helper_init(dev, helper); if (ret < 0) { @@ -172,7 +172,7 @@ int exynos_drm_fbdev_init(struct drm_device *dev) goto err_init; } - ret = drm_fb_helper_initial_config(helper, PREFERRED_BPP); + ret = drm_fb_helper_initial_config(helper); if (ret < 0) { DRM_DEV_ERROR(dev->dev, "failed to set up hw configuration.\n"); diff --git a/drivers/gpu/drm/gma500/framebuffer.c b/drivers/gpu/drm/gma500/framebuffer.c index 52ae3ade9a61..1f04c07ee180 100644 --- a/drivers/gpu/drm/gma500/framebuffer.c +++ b/drivers/gpu/drm/gma500/framebuffer.c @@ -409,7 +409,7 @@ int psb_fbdev_init(struct drm_device *dev) dev_priv->fb_helper = fb_helper; - drm_fb_helper_prepare(dev, fb_helper, &psb_fb_helper_funcs); + drm_fb_helper_prepare(dev, fb_helper, 32, &psb_fb_helper_funcs); ret = drm_fb_helper_init(dev, fb_helper); if (ret) @@ -418,7 +418,7 @@ int psb_fbdev_init(struct drm_device *dev) /* disable all the possible outputs/crtcs before entering KMS mode */ drm_helper_disable_unused_functions(dev); - ret = drm_fb_helper_initial_config(fb_helper, 32); + ret = drm_fb_helper_initial_config(fb_helper); if (ret) goto fini; diff --git a/drivers/gpu/drm/i915/display/intel_fbdev.c b/drivers/gpu/drm/i915/display/intel_fbdev.c index 19f3b5d92a55..ed197db5861d 100644 --- a/drivers/gpu/drm/i915/display/intel_fbdev.c +++ b/drivers/gpu/drm/i915/display/intel_fbdev.c @@ -520,10 +520,12 @@ int intel_fbdev_init(struct drm_device *dev) return -ENOMEM; mutex_init(&ifbdev->hpd_lock); - drm_fb_helper_prepare(dev, &ifbdev->helper, &intel_fb_helper_funcs); + drm_fb_helper_prepare(dev, &ifbdev->helper, 32, &intel_fb_helper_funcs); - if (!intel_fbdev_init_bios(dev, ifbdev)) - ifbdev->preferred_bpp = 32; + if (intel_fbdev_init_bios(dev, ifbdev)) + ifbdev->helper.preferred_bpp = ifbdev->preferred_bpp; + else + ifbdev->preferred_bpp = ifbdev->helper.preferred_bpp; ret = drm_fb_helper_init(dev, &ifbdev->helper); if (ret) { @@ -542,8 +544,7 @@ static void intel_fbdev_initial_config(void *data, async_cookie_t cookie) struct intel_fbdev *ifbdev = data; /* Due to peculiar init order wrt to hpd handling this is separate. */ - if (drm_fb_helper_initial_config(&ifbdev->helper, - ifbdev->preferred_bpp)) + if (drm_fb_helper_initial_config(&ifbdev->helper)) intel_fbdev_unregister(to_i915(ifbdev->helper.dev)); } diff --git a/drivers/gpu/drm/msm/msm_fbdev.c b/drivers/gpu/drm/msm/msm_fbdev.c index 31e1e30cb52a..915b213f3a5c 100644 --- a/drivers/gpu/drm/msm/msm_fbdev.c +++ b/drivers/gpu/drm/msm/msm_fbdev.c @@ -146,7 +146,7 @@ struct drm_fb_helper *msm_fbdev_init(struct drm_device *dev) helper = &fbdev->base; - drm_fb_helper_prepare(dev, helper, &msm_fb_helper_funcs); + drm_fb_helper_prepare(dev, helper, 32, &msm_fb_helper_funcs); ret = drm_fb_helper_init(dev, helper); if (ret) { @@ -159,7 +159,7 @@ struct drm_fb_helper *msm_fbdev_init(struct drm_device *dev) if (ret) goto fini; - ret = drm_fb_helper_initial_config(helper, 32); + ret = drm_fb_helper_initial_config(helper); if (ret) goto fini; diff --git a/drivers/gpu/drm/omapdrm/omap_fbdev.c b/drivers/gpu/drm/omapdrm/omap_fbdev.c index 98d8758048fc..fc5f52d567c6 100644 --- a/drivers/gpu/drm/omapdrm/omap_fbdev.c +++ b/drivers/gpu/drm/omapdrm/omap_fbdev.c @@ -239,13 +239,13 @@ void omap_fbdev_init(struct drm_device *dev) helper = &fbdev->base; - drm_fb_helper_prepare(dev, helper, &omap_fb_helper_funcs); + drm_fb_helper_prepare(dev, helper, 32, &omap_fb_helper_funcs); ret = drm_fb_helper_init(dev, helper); if (ret) goto fail; - ret = drm_fb_helper_initial_config(helper, 32); + ret = drm_fb_helper_initial_config(helper); if (ret) goto fini; diff --git a/drivers/gpu/drm/radeon/radeon_fb.c b/drivers/gpu/drm/radeon/radeon_fb.c index fe4087bfdb3c..6e5eed0e157c 100644 --- a/drivers/gpu/drm/radeon/radeon_fb.c +++ b/drivers/gpu/drm/radeon/radeon_fb.c @@ -348,7 +348,7 @@ int radeon_fbdev_init(struct radeon_device *rdev) rfbdev->rdev = rdev; rdev->mode_info.rfbdev = rfbdev; - drm_fb_helper_prepare(rdev->ddev, &rfbdev->helper, + drm_fb_helper_prepare(rdev->ddev, &rfbdev->helper, bpp_sel, &radeon_fb_helper_funcs); ret = drm_fb_helper_init(rdev->ddev, &rfbdev->helper); @@ -358,7 +358,7 @@ int radeon_fbdev_init(struct radeon_device *rdev) /* disable all the possible outputs/crtcs before entering KMS mode */ drm_helper_disable_unused_functions(rdev->ddev); - ret = drm_fb_helper_initial_config(&rfbdev->helper, bpp_sel); + ret = drm_fb_helper_initial_config(&rfbdev->helper); if (ret) goto fini; diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c index a900300ae5bd..153c39c32c71 100644 --- a/drivers/gpu/drm/tegra/fb.c +++ b/drivers/gpu/drm/tegra/fb.c @@ -308,7 +308,7 @@ static struct tegra_fbdev *tegra_fbdev_create(struct drm_device *drm) return ERR_PTR(-ENOMEM); } - drm_fb_helper_prepare(drm, &fbdev->base, &tegra_fb_helper_funcs); + drm_fb_helper_prepare(drm, &fbdev->base, 32, &tegra_fb_helper_funcs); return fbdev; } @@ -319,7 +319,6 @@ static void tegra_fbdev_free(struct tegra_fbdev *fbdev) } static int tegra_fbdev_init(struct tegra_fbdev *fbdev, - unsigned int preferred_bpp, unsigned int num_crtc, unsigned int max_connectors) { @@ -333,7 +332,7 @@ static int tegra_fbdev_init(struct tegra_fbdev *fbdev, return err; } - err = drm_fb_helper_initial_config(&fbdev->base, preferred_bpp); + err = drm_fb_helper_initial_config(&fbdev->base); if (err < 0) { dev_err(drm->dev, "failed to set initial configuration: %d\n", err); @@ -396,7 +395,7 @@ int tegra_drm_fb_init(struct drm_device *drm) struct tegra_drm *tegra = drm->dev_private; int err; - err = tegra_fbdev_init(tegra->fbdev, 32, drm->mode_config.num_crtc, + err = tegra_fbdev_init(tegra->fbdev, drm->mode_config.num_crtc, drm->mode_config.num_connector); if (err < 0) return err; diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h index 123f2ef035c5..9331c36bdab6 100644 --- a/include/drm/drm_fb_helper.h +++ b/include/drm/drm_fb_helper.h @@ -229,6 +229,7 @@ drm_fb_helper_from_client(struct drm_client_dev *client) #ifdef CONFIG_DRM_FBDEV_EMULATION void drm_fb_helper_prepare(struct drm_device *dev, struct drm_fb_helper *helper, + unsigned int preferred_bpp, const struct drm_fb_helper_funcs *funcs); void drm_fb_helper_unprepare(struct drm_fb_helper *fb_helper); int drm_fb_helper_init(struct drm_device *dev, struct drm_fb_helper *helper); @@ -284,7 +285,7 @@ int drm_fb_helper_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg); int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper); -int drm_fb_helper_initial_config(struct drm_fb_helper *fb_helper, int bpp_sel); +int drm_fb_helper_initial_config(struct drm_fb_helper *fb_helper); int drm_fb_helper_debug_enter(struct fb_info *info); int drm_fb_helper_debug_leave(struct fb_info *info); From patchwork Mon Jan 23 10:05:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 647319 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E570FC61D97 for ; Mon, 23 Jan 2023 10:06:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231808AbjAWKGN (ORCPT ); Mon, 23 Jan 2023 05:06:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231733AbjAWKGK (ORCPT ); Mon, 23 Jan 2023 05:06:10 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 963BADBD6; Mon, 23 Jan 2023 02:06:06 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 3A40034212; Mon, 23 Jan 2023 10:06:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1674468365; 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=afz1DQI5FyPuRzZBzvdALN3LMLNkwLW65z09Mk9nstc=; b=SxfnKyJXVol4gZcNqz7fEh/XPseQJyy+W0m2lyLzfpH34h2GthouCTdstUX3cW6KFtf4c9 r1UeLUhBv5NDX8/N/zOGi40ZqMu9JOxYHNqyDxY7ccUXTvAZojy3jQ6IXQIkgfi3SGlWXq 98Eyre5jD+l51FS8LKVRxSrGG16Qk5o= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1674468365; 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=afz1DQI5FyPuRzZBzvdALN3LMLNkwLW65z09Mk9nstc=; b=pnmn2yW4wpQHnx6JMnrvEYydHCE6deLLwj7Twp2SI1ZteGUQxSPShXQcI2+XsK0HHpaGHJ FIvWj+yymJMV0jCQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id E94C7139FE; Mon, 23 Jan 2023 10:06:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id yJMCOAxczmO+DwAAMHmgww (envelope-from ); Mon, 23 Jan 2023 10:06:04 +0000 From: Thomas Zimmermann To: airlied@gmail.com, daniel@ffwll.ch, maarten.lankhorst@linux.intel.com, mripard@kernel.org, javierm@redhat.com Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-tegra@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 07/10] drm/fbdev-generic: Minimize hotplug error handling Date: Mon, 23 Jan 2023 11:05:56 +0100 Message-Id: <20230123100559.12351-8-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230123100559.12351-1-tzimmermann@suse.de> References: <20230123100559.12351-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Call drm_fb_helper_init() in the generic-fbdev hotplug helper to revert the effects of drm_fb_helper_init(). No full cleanup is required. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/drm_fbdev_generic.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/drm_fbdev_generic.c b/drivers/gpu/drm/drm_fbdev_generic.c index 6ae014040df3..dd8be5e0f271 100644 --- a/drivers/gpu/drm/drm_fbdev_generic.c +++ b/drivers/gpu/drm/drm_fbdev_generic.c @@ -387,25 +387,21 @@ static int drm_fbdev_client_hotplug(struct drm_client_dev *client) ret = drm_fb_helper_init(dev, fb_helper); if (ret) - goto err; + goto err_drm_err; if (!drm_drv_uses_atomic_modeset(dev)) drm_helper_disable_unused_functions(dev); ret = drm_fb_helper_initial_config(fb_helper); if (ret) - goto err_cleanup; + goto err_drm_fb_helper_fini; return 0; -err_cleanup: - drm_fbdev_cleanup(fb_helper); -err: - fb_helper->dev = NULL; - fb_helper->info = NULL; - +err_drm_fb_helper_fini: + drm_fb_helper_fini(fb_helper); +err_drm_err: drm_err(dev, "fbdev: Failed to setup generic emulation (ret=%d)\n", ret); - return ret; } From patchwork Mon Jan 23 10:05:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 645630 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A612C636D7 for ; Mon, 23 Jan 2023 10:06:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231830AbjAWKGQ (ORCPT ); Mon, 23 Jan 2023 05:06:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231821AbjAWKGN (ORCPT ); Mon, 23 Jan 2023 05:06:13 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CAFB5594; Mon, 23 Jan 2023 02:06:10 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 860211F893; Mon, 23 Jan 2023 10:06:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1674468365; 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=XMyeRGuoo+55td93mO4bkBeGed5LCflHIeRxk9vJaJo=; b=EIqyh+EeAaayJr/hTOd1BYItTjmC4OcazATxf3jGCdamF0dszbiPKc4eJjQ9PVtiGAw67/ oSHe5toX/01udpBrGDyvsFE/A9nxsz7AWJGQRlXUs+8k/R1bj931PCE+GZTe4NHHguBmzo vdbkPVfevcV6/fsC/+oVa3SUZWwhUac= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1674468365; 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=XMyeRGuoo+55td93mO4bkBeGed5LCflHIeRxk9vJaJo=; b=IL1P5cgu+0vii/7tnYjEeNvQRoiPbOavm2JWUYaa5MLMK31sQVYJeNq0aAYkl600YBzgrP ygYWX00QxAG/yqBA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 40692134F5; Mon, 23 Jan 2023 10:06:05 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id EK7ODg1czmO+DwAAMHmgww (envelope-from ); Mon, 23 Jan 2023 10:06:05 +0000 From: Thomas Zimmermann To: airlied@gmail.com, daniel@ffwll.ch, maarten.lankhorst@linux.intel.com, mripard@kernel.org, javierm@redhat.com Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-tegra@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 08/10] drm/fbdev-generic: Minimize client unregistering Date: Mon, 23 Jan 2023 11:05:57 +0100 Message-Id: <20230123100559.12351-9-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230123100559.12351-1-tzimmermann@suse.de> References: <20230123100559.12351-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org For uninitialized framebuffers, only release the DRM client and free the fbdev memory. Do not attempt to clean up the framebuffer. DRM fbdev clients have a two-step initialization: first create the DRM client; then create the framebuffer device on the first successful hotplug event. In cases where the client never creates the framebuffer, only the client state needs to be released. We can detect which case it is, full or client-only cleanup, be looking at the presence of fb_helper's info field. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/drm_fbdev_generic.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_fbdev_generic.c b/drivers/gpu/drm/drm_fbdev_generic.c index dd8be5e0f271..bd5b59551c06 100644 --- a/drivers/gpu/drm/drm_fbdev_generic.c +++ b/drivers/gpu/drm/drm_fbdev_generic.c @@ -362,11 +362,13 @@ static void drm_fbdev_client_unregister(struct drm_client_dev *client) { struct drm_fb_helper *fb_helper = drm_fb_helper_from_client(client); - if (fb_helper->info) - /* drm_fbdev_fb_destroy() takes care of cleanup */ + if (fb_helper->info) { drm_fb_helper_unregister_info(fb_helper); - else - drm_fbdev_release(fb_helper); + } else { + drm_fb_helper_unprepare(fb_helper); + drm_client_release(&fb_helper->client); + kfree(fb_helper); + } } static int drm_fbdev_client_restore(struct drm_client_dev *client) From patchwork Mon Jan 23 10:05:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 645631 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E67B7C61DA2 for ; Mon, 23 Jan 2023 10:06:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231709AbjAWKGP (ORCPT ); Mon, 23 Jan 2023 05:06:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231800AbjAWKGN (ORCPT ); Mon, 23 Jan 2023 05:06:13 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CCCA9EEB; Mon, 23 Jan 2023 02:06:10 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id CE6211F890; Mon, 23 Jan 2023 10:06:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1674468365; 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=2VgE09XLFEUxGZIl8GpJvdvKa3ICIDbfnLkW4QnI0ig=; b=A5YbltqwEp305G1G7xjRuDcqW+hgox8RsvVhwt6lKqVa04JKbUKW1U+ncFaut2jFT2aaP9 wy8Qk8uuXap39VU30nQSsCVQFG7MgDt8twkPJV36mbJ+YsNTYLR6hMda2Ja/1br1H72fk+ 0vXJg1I5oUHOg+HslTpWYRWqgfcLjwE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1674468365; 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=2VgE09XLFEUxGZIl8GpJvdvKa3ICIDbfnLkW4QnI0ig=; b=/uK/3RxSdgxo9M4bM7CU171IyLpKlX5QGq43ZKfxu9HGR2+v5bGybuYUkw646guTuExURD T5Mr7wplZEGW/UDA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8A236139FE; Mon, 23 Jan 2023 10:06:05 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id wPbcIA1czmO+DwAAMHmgww (envelope-from ); Mon, 23 Jan 2023 10:06:05 +0000 From: Thomas Zimmermann To: airlied@gmail.com, daniel@ffwll.ch, maarten.lankhorst@linux.intel.com, mripard@kernel.org, javierm@redhat.com Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-tegra@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 09/10] drm/fbdev-generic: Inline clean-up helpers into drm_fbdev_fb_destroy() Date: Mon, 23 Jan 2023 11:05:58 +0100 Message-Id: <20230123100559.12351-10-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230123100559.12351-1-tzimmermann@suse.de> References: <20230123100559.12351-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The fbdev framebuffer cleanup in drm_fbdev_fb_destroy() calls drm_fbdev_release() and drm_fbdev_cleanup(). Inline both into the caller. No functional changes. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/drm_fbdev_generic.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/drm_fbdev_generic.c b/drivers/gpu/drm/drm_fbdev_generic.c index bd5b59551c06..49a0bba86ce7 100644 --- a/drivers/gpu/drm/drm_fbdev_generic.c +++ b/drivers/gpu/drm/drm_fbdev_generic.c @@ -43,8 +43,9 @@ static int drm_fbdev_fb_release(struct fb_info *info, int user) return 0; } -static void drm_fbdev_cleanup(struct drm_fb_helper *fb_helper) +static void drm_fbdev_fb_destroy(struct fb_info *info) { + struct drm_fb_helper *fb_helper = info->par; struct fb_info *fbi = fb_helper->info; void *shadow = NULL; @@ -66,24 +67,10 @@ static void drm_fbdev_cleanup(struct drm_fb_helper *fb_helper) drm_client_buffer_vunmap(fb_helper->buffer); drm_client_framebuffer_delete(fb_helper->buffer); -} - -static void drm_fbdev_release(struct drm_fb_helper *fb_helper) -{ - drm_fbdev_cleanup(fb_helper); drm_client_release(&fb_helper->client); kfree(fb_helper); } -/* - * fb_ops.fb_destroy is called by the last put_fb_info() call at the end of - * unregister_framebuffer() or fb_release(). - */ -static void drm_fbdev_fb_destroy(struct fb_info *info) -{ - drm_fbdev_release(info->par); -} - static int drm_fbdev_fb_mmap(struct fb_info *info, struct vm_area_struct *vma) { struct drm_fb_helper *fb_helper = info->par; From patchwork Mon Jan 23 10:05:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 647316 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 829B6C64EC4 for ; Mon, 23 Jan 2023 10:06:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231821AbjAWKGQ (ORCPT ); Mon, 23 Jan 2023 05:06:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231733AbjAWKGN (ORCPT ); Mon, 23 Jan 2023 05:06:13 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EEE99EF1; Mon, 23 Jan 2023 02:06:10 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 22A841F894; Mon, 23 Jan 2023 10:06:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1674468366; 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=vDd9MXBTjKMXMh/f/QyfHcSewUkTmQXrhwWLESaTFTc=; b=I4TtmGYDyKvSOnbWkOxiQM5mENgnz2IBpk2sUXD3kE+W2SFSlaCIvtVg+lgRlkD/Wz/V4D P1yn33vBBIAdQHETcDkqiDrp0tUWNSyTz6VPPn7R5/f2zXicB25xcUXeiilpbONcmfYZ4t zSbyWVAbDjqztG0Nf78FCYwE7xpQYvg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1674468366; 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=vDd9MXBTjKMXMh/f/QyfHcSewUkTmQXrhwWLESaTFTc=; b=8FR2KJnsq+LEqZkKZWvc+UmQgBc9reVplThcIblGYUo8bC59zPBBsKmGhOGWmr3x5A3rdl eCDOwAESYDgvDdDg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id D4609134F5; Mon, 23 Jan 2023 10:06:05 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id AHHKMg1czmO+DwAAMHmgww (envelope-from ); Mon, 23 Jan 2023 10:06:05 +0000 From: Thomas Zimmermann To: airlied@gmail.com, daniel@ffwll.ch, maarten.lankhorst@linux.intel.com, mripard@kernel.org, javierm@redhat.com Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-tegra@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 10/10] drm/fbdev-generic: Rename struct fb_info 'fbi' to 'info' Date: Mon, 23 Jan 2023 11:05:59 +0100 Message-Id: <20230123100559.12351-11-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230123100559.12351-1-tzimmermann@suse.de> References: <20230123100559.12351-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The generic fbdev emulation names variables of type struct fb_info both 'fbi' and 'info'. The latter seems to be more common in fbdev code, so name fbi accordingly. Also replace the duplicate variable in drm_fbdev_fb_destroy(). Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/drm_fbdev_generic.c | 49 ++++++++++++++--------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/drivers/gpu/drm/drm_fbdev_generic.c b/drivers/gpu/drm/drm_fbdev_generic.c index 49a0bba86ce7..7633da5c13c3 100644 --- a/drivers/gpu/drm/drm_fbdev_generic.c +++ b/drivers/gpu/drm/drm_fbdev_generic.c @@ -46,17 +46,16 @@ static int drm_fbdev_fb_release(struct fb_info *info, int user) static void drm_fbdev_fb_destroy(struct fb_info *info) { struct drm_fb_helper *fb_helper = info->par; - struct fb_info *fbi = fb_helper->info; void *shadow = NULL; if (!fb_helper->dev) return; - if (fbi) { - if (fbi->fbdefio) - fb_deferred_io_cleanup(fbi); + if (info) { + if (info->fbdefio) + fb_deferred_io_cleanup(info); if (drm_fbdev_use_shadow_fb(fb_helper)) - shadow = fbi->screen_buffer; + shadow = info->screen_buffer; } drm_fb_helper_fini(fb_helper); @@ -173,7 +172,7 @@ static int drm_fbdev_fb_probe(struct drm_fb_helper *fb_helper, struct drm_device *dev = fb_helper->dev; struct drm_client_buffer *buffer; struct drm_framebuffer *fb; - struct fb_info *fbi; + struct fb_info *info; u32 format; struct iosys_map map; int ret; @@ -192,35 +191,35 @@ static int drm_fbdev_fb_probe(struct drm_fb_helper *fb_helper, fb_helper->fb = buffer->fb; fb = buffer->fb; - fbi = drm_fb_helper_alloc_info(fb_helper); - if (IS_ERR(fbi)) - return PTR_ERR(fbi); + info = drm_fb_helper_alloc_info(fb_helper); + if (IS_ERR(info)) + return PTR_ERR(info); - fbi->fbops = &drm_fbdev_fb_ops; - fbi->screen_size = sizes->surface_height * fb->pitches[0]; - fbi->fix.smem_len = fbi->screen_size; - fbi->flags = FBINFO_DEFAULT; + info->fbops = &drm_fbdev_fb_ops; + info->screen_size = sizes->surface_height * fb->pitches[0]; + info->fix.smem_len = info->screen_size; + info->flags = FBINFO_DEFAULT; - drm_fb_helper_fill_info(fbi, fb_helper, sizes); + drm_fb_helper_fill_info(info, fb_helper, sizes); if (drm_fbdev_use_shadow_fb(fb_helper)) { - fbi->screen_buffer = vzalloc(fbi->screen_size); - if (!fbi->screen_buffer) + info->screen_buffer = vzalloc(info->screen_size); + if (!info->screen_buffer) return -ENOMEM; - fbi->flags |= FBINFO_VIRTFB | FBINFO_READS_FAST; + info->flags |= FBINFO_VIRTFB | FBINFO_READS_FAST; - fbi->fbdefio = &drm_fbdev_defio; - fb_deferred_io_init(fbi); + info->fbdefio = &drm_fbdev_defio; + fb_deferred_io_init(info); } else { /* buffer is mapped for HW framebuffer */ ret = drm_client_buffer_vmap(fb_helper->buffer, &map); if (ret) return ret; if (map.is_iomem) { - fbi->screen_base = map.vaddr_iomem; + info->screen_base = map.vaddr_iomem; } else { - fbi->screen_buffer = map.vaddr; - fbi->flags |= FBINFO_VIRTFB; + info->screen_buffer = map.vaddr; + info->flags |= FBINFO_VIRTFB; } /* @@ -229,10 +228,10 @@ static int drm_fbdev_fb_probe(struct drm_fb_helper *fb_helper, * case. */ #if IS_ENABLED(CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM) - if (fb_helper->hint_leak_smem_start && fbi->fix.smem_start == 0 && + if (fb_helper->hint_leak_smem_start && info->fix.smem_start == 0 && !drm_WARN_ON_ONCE(dev, map.is_iomem)) - fbi->fix.smem_start = - page_to_phys(virt_to_page(fbi->screen_buffer)); + info->fix.smem_start = + page_to_phys(virt_to_page(info->screen_buffer)); #endif }