From patchwork Thu Mar 30 07:30:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13193506 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 7EDB4C6FD1D for ; Thu, 30 Mar 2023 07:31:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9061210ED07; Thu, 30 Mar 2023 07:31:08 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by gabe.freedesktop.org (Postfix) with ESMTPS id E0B1F10ED07 for ; Thu, 30 Mar 2023 07:30:50 +0000 (UTC) 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 99A091FE8B; Thu, 30 Mar 2023 07:30:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1680161449; 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=tRARA2JOGwkKN3GuqmGeJK8JevwbZMv+7XbBIMWuabY=; b=unbfdeg/ZoUnytZNk2qoOkKj5B37e3TnRni/4HEbWDFClip1rnhg4rldqA4uFWyzfXqnJf v2cJMHaO4uEuFeGyOJZzw8xeTAuoPxUsZDKsHAqk5fSDoKE92p9m1dykMOV8yf5eDIMg8O Cyv47mpOlv7vMIydXGG7qeIO1VAUDxs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1680161449; 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=tRARA2JOGwkKN3GuqmGeJK8JevwbZMv+7XbBIMWuabY=; b=ycsAv8H3u2O+J2ENL0iHLoI19HmptPI6nHeIPUORsMMV+qcLLtov4eGDFVXWkaErDPLSKN XdOsZYCteyhkBtCA== 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 6B3021390D; Thu, 30 Mar 2023 07:30:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 2Ng6Gak6JWRNeAAAMHmgww (envelope-from ); Thu, 30 Mar 2023 07:30:49 +0000 From: Thomas Zimmermann To: linux@armlinux.org.uk, javierm@redhat.com, airlied@gmail.com, daniel@ffwll.ch Subject: [PATCH 1/4] drm/armada: Include Date: Thu, 30 Mar 2023 09:30:43 +0200 Message-Id: <20230330073046.7150-2-tzimmermann@suse.de> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330073046.7150-1-tzimmermann@suse.de> References: <20230330073046.7150-1-tzimmermann@suse.de> MIME-Version: 1.0 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: , Cc: Thomas Zimmermann , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Include to get declarations of of_node_put() and of_device_is_available(). No functional changes. Signed-off-by: Thomas Zimmermann Reviewed-by: Sui Jingfeng --- drivers/gpu/drm/armada/armada_drv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c index 0643887800b4..fd9842740a08 100644 --- a/drivers/gpu/drm/armada/armada_drv.c +++ b/drivers/gpu/drm/armada/armada_drv.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include From patchwork Thu Mar 30 07:30:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13193507 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 C3F00C6FD1D for ; Thu, 30 Mar 2023 07:31:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DE8E810E12D; Thu, 30 Mar 2023 07:31:14 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1F04710ED04 for ; Thu, 30 Mar 2023 07:30:51 +0000 (UTC) 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 C4CBB1FE8E; Thu, 30 Mar 2023 07:30:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1680161449; 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=EC8LFlENQsENM98He9moGigsZsCj9l+tIsoEPsYo9ak=; b=i7EgCDnq+q58LTm7P1urOqy9gt62nWBvDcIO++G5fxYH1YpXeHGF9u2cqABBzWTsHVjKEv ky2WIv8mbQH/ACB2CBxxdrLy/8of49y4dodRYbRiuA4eo32AhkJZBwH+AJvqAUPBTcUxv5 TLYdoBXBYhIRPBl6zaO0iQcZHh9NEcI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1680161449; 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=EC8LFlENQsENM98He9moGigsZsCj9l+tIsoEPsYo9ak=; b=gq1oKbZGM9CeZRn4ntFHSbH66YQJEg7EI9lrvtHloe9gwh7y8MdIXPbSh1ZeCVqR2Vc9Mo zxWwY1aOQmc65qDQ== 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 A08321348E; Thu, 30 Mar 2023 07:30:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id YLQfJqk6JWRNeAAAMHmgww (envelope-from ); Thu, 30 Mar 2023 07:30:49 +0000 From: Thomas Zimmermann To: linux@armlinux.org.uk, javierm@redhat.com, airlied@gmail.com, daniel@ffwll.ch Subject: [PATCH 2/4] drm/armada: Hide fbdev support behind config option Date: Thu, 30 Mar 2023 09:30:44 +0200 Message-Id: <20230330073046.7150-3-tzimmermann@suse.de> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330073046.7150-1-tzimmermann@suse.de> References: <20230330073046.7150-1-tzimmermann@suse.de> MIME-Version: 1.0 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: , Cc: Thomas Zimmermann , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Only build armada's fbdev emulation if CONFIG_DRM_FBDEV_EMULATION has been enabled. No functional changes, but allows to build armada without fbdev. Signed-off-by: Thomas Zimmermann Reviewed-by: Sui Jingfeng --- drivers/gpu/drm/armada/Makefile | 3 ++- drivers/gpu/drm/armada/armada_drm.h | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/armada/Makefile b/drivers/gpu/drm/armada/Makefile index 9bc3c3213724..dc75a7db9ed3 100644 --- a/drivers/gpu/drm/armada/Makefile +++ b/drivers/gpu/drm/armada/Makefile @@ -1,7 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 -armada-y := armada_crtc.o armada_drv.o armada_fb.o armada_fbdev.o \ +armada-y := armada_crtc.o armada_drv.o armada_fb.o \ armada_gem.o armada_overlay.o armada_plane.o armada_trace.o armada-y += armada_510.o armada-$(CONFIG_DEBUG_FS) += armada_debugfs.o +armada-$(CONFIG_DRM_FBDEV_EMULATION) += armada_fbdev.o obj-$(CONFIG_DRM_ARMADA) := armada.o diff --git a/drivers/gpu/drm/armada/armada_drm.h b/drivers/gpu/drm/armada/armada_drm.h index 6a5a87932576..1475146b1c47 100644 --- a/drivers/gpu/drm/armada/armada_drm.h +++ b/drivers/gpu/drm/armada/armada_drm.h @@ -75,8 +75,18 @@ struct armada_private { #define drm_to_armada_dev(dev) container_of(dev, struct armada_private, drm) -int armada_fbdev_init(struct drm_device *); -void armada_fbdev_fini(struct drm_device *); +#if defined(CONFIG_DRM_FBDEV_EMULATION) +int armada_fbdev_init(struct drm_device *dev); +void armada_fbdev_fini(struct drm_device *dev); +#else +static inline int armada_fbdev_init(struct drm_device *dev) +{ + return 0; +} + +static inline void armada_fbdev_fini(struct drm_device *dev) +{ } +#endif int armada_overlay_plane_create(struct drm_device *, unsigned long); From patchwork Thu Mar 30 07:30:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13193504 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 42931C6FD1D for ; Thu, 30 Mar 2023 07:31:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 746BB10ED03; Thu, 30 Mar 2023 07:30:59 +0000 (UTC) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5859210ED07 for ; Thu, 30 Mar 2023 07:30:51 +0000 (UTC) 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 E880B218E5; Thu, 30 Mar 2023 07:30:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1680161449; 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=FIipWtcPYLGUYNJ/w0WyTLqvPr0m5USIx4BqYyLdSY4=; b=Yl2Mr3VcQ5+g4vXeixuRVOBIScNWnpysZxQk5cS8ulnxQH14B8+7uXHgXhbRtMwecHlEPv t0JLa25dkHnPGV6eBeSxtli5nq0TB900QaYoaqI1o6EJEiqiui4W7ojLNT2GUc1OuOH4ZP 70jp4falEY+Bz1XEAr66oj273R03boY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1680161449; 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=FIipWtcPYLGUYNJ/w0WyTLqvPr0m5USIx4BqYyLdSY4=; b=EHJIppmHl7fo4PTrQApL+lzjOCbYmP3UEj4iRJ+V85VxutcylGW9hfJz/GJ9gcOy21Hyl0 hjZmQS2BMwwlpVAQ== 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 C928D1390D; Thu, 30 Mar 2023 07:30:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id IO9RMKk6JWRNeAAAMHmgww (envelope-from ); Thu, 30 Mar 2023 07:30:49 +0000 From: Thomas Zimmermann To: linux@armlinux.org.uk, javierm@redhat.com, airlied@gmail.com, daniel@ffwll.ch Subject: [PATCH 3/4] drm/armada: Initialize fbdev DRM client Date: Thu, 30 Mar 2023 09:30:45 +0200 Message-Id: <20230330073046.7150-4-tzimmermann@suse.de> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330073046.7150-1-tzimmermann@suse.de> References: <20230330073046.7150-1-tzimmermann@suse.de> MIME-Version: 1.0 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: , Cc: Thomas Zimmermann , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Initialize the fbdev client in the fbdev code with empty helper functions. Also clean up the client. The helpers will later implement various functionality of the DRM client. No functional changes. Signed-off-by: Thomas Zimmermann Reviewed-by: Javier Martinez Canillas --- drivers/gpu/drm/armada/armada_fbdev.c | 43 ++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/armada/armada_fbdev.c b/drivers/gpu/drm/armada/armada_fbdev.c index 0e44f53e9fa4..303c55704225 100644 --- a/drivers/gpu/drm/armada/armada_fbdev.c +++ b/drivers/gpu/drm/armada/armada_fbdev.c @@ -117,6 +117,32 @@ static const struct drm_fb_helper_funcs armada_fb_helper_funcs = { .fb_probe = armada_fb_probe, }; +/* + * Fbdev client and struct drm_client_funcs + */ + +static void armada_fbdev_client_unregister(struct drm_client_dev *client) +{ } + +static int armada_fbdev_client_restore(struct drm_client_dev *client) +{ + drm_fb_helper_lastclose(client->dev); + + return 0; +} + +static int armada_fbdev_client_hotplug(struct drm_client_dev *client) +{ + return 0; +} + +static const struct drm_client_funcs armada_fbdev_client_funcs = { + .owner = THIS_MODULE, + .unregister = armada_fbdev_client_unregister, + .restore = armada_fbdev_client_restore, + .hotplug = armada_fbdev_client_hotplug, +}; + int armada_fbdev_init(struct drm_device *dev) { struct armada_private *priv = drm_to_armada_dev(dev); @@ -131,22 +157,30 @@ int armada_fbdev_init(struct drm_device *dev) drm_fb_helper_prepare(dev, fbh, 32, &armada_fb_helper_funcs); + ret = drm_client_init(dev, &fbh->client, "armada-fbdev", + &armada_fbdev_client_funcs); + if (ret) + goto err_drm_fb_helper_unprepare; + ret = drm_fb_helper_init(dev, fbh); if (ret) { DRM_ERROR("failed to initialize drm fb helper\n"); - goto err_fb_helper; + goto err_drm_client_release; } ret = drm_fb_helper_initial_config(fbh); if (ret) { DRM_ERROR("failed to set initial config\n"); - goto err_fb_setup; + goto err_drm_fb_helper_fini; } return 0; - err_fb_setup: + +err_drm_fb_helper_fini: drm_fb_helper_fini(fbh); - err_fb_helper: +err_drm_client_release: + drm_client_release(&fbh->client); +err_drm_fb_helper_unprepare: drm_fb_helper_unprepare(fbh); priv->fbdev = NULL; return ret; @@ -161,6 +195,7 @@ void armada_fbdev_fini(struct drm_device *dev) drm_fb_helper_unregister_info(fbh); drm_fb_helper_fini(fbh); + drm_client_release(&fbh->client); if (fbh->fb) fbh->fb->funcs->destroy(fbh->fb); From patchwork Thu Mar 30 07:30:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13193505 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 59837C6FD1D for ; Thu, 30 Mar 2023 07:31:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6985510E150; Thu, 30 Mar 2023 07:30:59 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6833A10ED04 for ; Thu, 30 Mar 2023 07:30:51 +0000 (UTC) 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 1F2711FE8F; Thu, 30 Mar 2023 07:30:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1680161450; 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=k9OZ38+bm6jZeiS9LqKr2sD9S1IgjysCBOLblvU7vNg=; b=TxVcg92vL3AFP8WYfAsND3TOV1FnRMaSobgcyi+kqOTI+unwPz3CaJYSmgFXik70xraCAM wyR+wuxPbUi9PEhQj+wSYNB/ib2hDuoLnTvUNSbMzF0fOXJOVQH5BzoJsuiCNVYR56WE0H sh53Uo824Sqn5Ml6JmPFF+MtL/4rQe8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1680161450; 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=k9OZ38+bm6jZeiS9LqKr2sD9S1IgjysCBOLblvU7vNg=; b=sme6w4wozFw17LAPmhrIAVioIB3qf+biebvd3FWuhZQC3hy+xXk2NUN8zKNHvliftyk8iA l+uECMtRq4j6C0DA== 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 EC5DE1348E; Thu, 30 Mar 2023 07:30:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id cBriOKk6JWRNeAAAMHmgww (envelope-from ); Thu, 30 Mar 2023 07:30:49 +0000 From: Thomas Zimmermann To: linux@armlinux.org.uk, javierm@redhat.com, airlied@gmail.com, daniel@ffwll.ch Subject: [PATCH 4/4] drm/armada: Implement fbdev emulation as in-kernel client Date: Thu, 30 Mar 2023 09:30:46 +0200 Message-Id: <20230330073046.7150-5-tzimmermann@suse.de> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330073046.7150-1-tzimmermann@suse.de> References: <20230330073046.7150-1-tzimmermann@suse.de> MIME-Version: 1.0 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: , Cc: Thomas Zimmermann , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Move code from ad-hoc fbdev callbacks into DRM client functions and remove the old callbacks. The functions instruct the client to poll for changed output or restore the display. The DRM core calls both, the old callbacks and the new client helpers, from the same places. The new functions perform the same operation as before, so there's no change in functionality. Replace all code that initializes or releases fbdev emulation throughout the driver. Instead initialize the fbdev client by a single call to armada_fbdev_setup() after armada has registered its DRM device. As in most drivers, aramda's fbdev emulation now acts like a regular DRM client. The fbdev client setup consists of the initial preparation and the hot-plugging of the display. The latter creates the fbdev device and sets up the fbdev framebuffer. The setup performs display hot-plugging once. If no display can be detected, DRM probe helpers re-run the detection on each hotplug event. A call to drm_dev_unregister() releases the client automatically. No further action is required within armada. If the fbdev framebuffer has been fully set up, struct fb_ops.fb_destroy implements the release. For partially initialized emulation, the fbdev client reverts the initial setup. Signed-off-by: Thomas Zimmermann Reviewed-by: Javier Martinez Canillas --- drivers/gpu/drm/armada/armada_drm.h | 12 +-- drivers/gpu/drm/armada/armada_drv.c | 11 +-- drivers/gpu/drm/armada/armada_fb.c | 1 - drivers/gpu/drm/armada/armada_fbdev.c | 118 +++++++++++++++----------- 4 files changed, 73 insertions(+), 69 deletions(-) diff --git a/drivers/gpu/drm/armada/armada_drm.h b/drivers/gpu/drm/armada/armada_drm.h index 1475146b1c47..c303e8c7ff6c 100644 --- a/drivers/gpu/drm/armada/armada_drm.h +++ b/drivers/gpu/drm/armada/armada_drm.h @@ -16,7 +16,6 @@ struct armada_crtc; struct armada_gem_object; struct clk; struct drm_display_mode; -struct drm_fb_helper; static inline void armada_updatel(uint32_t val, uint32_t mask, void __iomem *ptr) @@ -55,7 +54,6 @@ extern const struct armada_variant armada510_ops; struct armada_private { struct drm_device drm; - struct drm_fb_helper *fbdev; struct armada_crtc *dcrtc[2]; struct drm_mm linear; /* protected by linear_lock */ struct mutex linear_lock; @@ -76,15 +74,9 @@ struct armada_private { #define drm_to_armada_dev(dev) container_of(dev, struct armada_private, drm) #if defined(CONFIG_DRM_FBDEV_EMULATION) -int armada_fbdev_init(struct drm_device *dev); -void armada_fbdev_fini(struct drm_device *dev); +void armada_fbdev_setup(struct drm_device *dev); #else -static inline int armada_fbdev_init(struct drm_device *dev) -{ - return 0; -} - -static inline void armada_fbdev_fini(struct drm_device *dev) +static inline void armada_fbdev_setup(struct drm_device *dev) { } #endif diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c index fd9842740a08..4d7ca9d461e4 100644 --- a/drivers/gpu/drm/armada/armada_drv.c +++ b/drivers/gpu/drm/armada/armada_drv.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include @@ -38,7 +37,6 @@ static const struct drm_ioctl_desc armada_ioctls[] = { DEFINE_DRM_GEM_FOPS(armada_drm_fops); static const struct drm_driver armada_drm_driver = { - .lastclose = drm_fb_helper_lastclose, .prime_handle_to_fd = drm_gem_prime_handle_to_fd, .prime_fd_to_handle = drm_gem_prime_fd_to_handle, .gem_prime_import = armada_gem_prime_import, @@ -56,7 +54,6 @@ static const struct drm_driver armada_drm_driver = { static const struct drm_mode_config_funcs armada_drm_mode_config_funcs = { .fb_create = armada_fb_create, - .output_poll_changed = drm_fb_helper_output_poll_changed, .atomic_check = drm_atomic_helper_check, .atomic_commit = drm_atomic_helper_commit, }; @@ -133,10 +130,6 @@ static int armada_drm_bind(struct device *dev) drm_mode_config_reset(&priv->drm); - ret = armada_fbdev_init(&priv->drm); - if (ret) - goto err_comp; - drm_kms_helper_poll_init(&priv->drm); ret = drm_dev_register(&priv->drm, 0); @@ -147,11 +140,12 @@ static int armada_drm_bind(struct device *dev) armada_drm_debugfs_init(priv->drm.primary); #endif + armada_fbdev_setup(&priv->drm); + return 0; err_poll: drm_kms_helper_poll_fini(&priv->drm); - armada_fbdev_fini(&priv->drm); err_comp: component_unbind_all(dev, &priv->drm); err_kms: @@ -166,7 +160,6 @@ static void armada_drm_unbind(struct device *dev) struct armada_private *priv = drm_to_armada_dev(drm); drm_kms_helper_poll_fini(&priv->drm); - armada_fbdev_fini(&priv->drm); drm_dev_unregister(&priv->drm); diff --git a/drivers/gpu/drm/armada/armada_fb.c b/drivers/gpu/drm/armada/armada_fb.c index b87c71703c85..cf2e88218dc0 100644 --- a/drivers/gpu/drm/armada/armada_fb.c +++ b/drivers/gpu/drm/armada/armada_fb.c @@ -4,7 +4,6 @@ */ #include -#include #include #include diff --git a/drivers/gpu/drm/armada/armada_fbdev.c b/drivers/gpu/drm/armada/armada_fbdev.c index 303c55704225..0a5fd1aa86eb 100644 --- a/drivers/gpu/drm/armada/armada_fbdev.c +++ b/drivers/gpu/drm/armada/armada_fbdev.c @@ -8,6 +8,8 @@ #include #include +#include +#include #include #include @@ -16,6 +18,19 @@ #include "armada_fb.h" #include "armada_gem.h" +static void armada_fbdev_fb_destroy(struct fb_info *info) +{ + struct drm_fb_helper *fbh = info->par; + + drm_fb_helper_fini(fbh); + + fbh->fb->funcs->destroy(fbh->fb); + + drm_client_release(&fbh->client); + drm_fb_helper_unprepare(fbh); + kfree(fbh); +} + static const struct fb_ops armada_fb_ops = { .owner = THIS_MODULE, DRM_FB_HELPER_DEFAULT_OPS, @@ -24,6 +39,7 @@ static const struct fb_ops armada_fb_ops = { .fb_fillrect = drm_fb_helper_cfb_fillrect, .fb_copyarea = drm_fb_helper_cfb_copyarea, .fb_imageblit = drm_fb_helper_cfb_imageblit, + .fb_destroy = armada_fbdev_fb_destroy, }; static int armada_fbdev_create(struct drm_fb_helper *fbh, @@ -122,7 +138,17 @@ static const struct drm_fb_helper_funcs armada_fb_helper_funcs = { */ static void armada_fbdev_client_unregister(struct drm_client_dev *client) -{ } +{ + struct drm_fb_helper *fbh = drm_fb_helper_from_client(client); + + if (fbh->info) { + drm_fb_helper_unregister_info(fbh); + } else { + drm_client_release(&fbh->client); + drm_fb_helper_unprepare(fbh); + kfree(fbh); + } +} static int armada_fbdev_client_restore(struct drm_client_dev *client) { @@ -133,7 +159,31 @@ static int armada_fbdev_client_restore(struct drm_client_dev *client) static int armada_fbdev_client_hotplug(struct drm_client_dev *client) { + struct drm_fb_helper *fbh = drm_fb_helper_from_client(client); + struct drm_device *dev = client->dev; + int ret; + + if (dev->fb_helper) + return drm_fb_helper_hotplug_event(dev->fb_helper); + + ret = drm_fb_helper_init(dev, fbh); + if (ret) + goto err_drm_err; + + if (!drm_drv_uses_atomic_modeset(dev)) + drm_helper_disable_unused_functions(dev); + + ret = drm_fb_helper_initial_config(fbh); + if (ret) + goto err_drm_fb_helper_fini; + return 0; + +err_drm_fb_helper_fini: + drm_fb_helper_fini(fbh); +err_drm_err: + drm_err(dev, "armada: Failed to setup fbdev emulation (ret=%d)\n", ret); + return ret; } static const struct drm_client_funcs armada_fbdev_client_funcs = { @@ -143,65 +193,35 @@ static const struct drm_client_funcs armada_fbdev_client_funcs = { .hotplug = armada_fbdev_client_hotplug, }; -int armada_fbdev_init(struct drm_device *dev) +void armada_fbdev_setup(struct drm_device *dev) { - struct armada_private *priv = drm_to_armada_dev(dev); struct drm_fb_helper *fbh; int ret; - fbh = devm_kzalloc(dev->dev, sizeof(*fbh), GFP_KERNEL); - if (!fbh) - return -ENOMEM; - - priv->fbdev = fbh; + drm_WARN(dev, !dev->registered, "Device has not been registered.\n"); + drm_WARN(dev, dev->fb_helper, "fb_helper is already set!\n"); + fbh = kzalloc(sizeof(*fbh), GFP_KERNEL); + if (!fbh) + return; drm_fb_helper_prepare(dev, fbh, 32, &armada_fb_helper_funcs); - ret = drm_client_init(dev, &fbh->client, "armada-fbdev", - &armada_fbdev_client_funcs); - if (ret) - goto err_drm_fb_helper_unprepare; - - ret = drm_fb_helper_init(dev, fbh); + ret = drm_client_init(dev, &fbh->client, "fbdev", &armada_fbdev_client_funcs); if (ret) { - DRM_ERROR("failed to initialize drm fb helper\n"); - goto err_drm_client_release; + drm_err(dev, "Failed to register client: %d\n", ret); + goto err_drm_client_init; } - ret = drm_fb_helper_initial_config(fbh); - if (ret) { - DRM_ERROR("failed to set initial config\n"); - goto err_drm_fb_helper_fini; - } - - return 0; - -err_drm_fb_helper_fini: - drm_fb_helper_fini(fbh); -err_drm_client_release: - drm_client_release(&fbh->client); -err_drm_fb_helper_unprepare: - drm_fb_helper_unprepare(fbh); - priv->fbdev = NULL; - return ret; -} - -void armada_fbdev_fini(struct drm_device *dev) -{ - struct armada_private *priv = drm_to_armada_dev(dev); - struct drm_fb_helper *fbh = priv->fbdev; - - if (fbh) { - drm_fb_helper_unregister_info(fbh); + ret = armada_fbdev_client_hotplug(&fbh->client); + if (ret) + drm_dbg_kms(dev, "client hotplug ret=%d\n", ret); - drm_fb_helper_fini(fbh); - drm_client_release(&fbh->client); + drm_client_register(&fbh->client); - if (fbh->fb) - fbh->fb->funcs->destroy(fbh->fb); + return; - drm_fb_helper_unprepare(fbh); - - priv->fbdev = NULL; - } +err_drm_client_init: + drm_fb_helper_unprepare(fbh); + kfree(fbh); + return; }