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)