From mboxrd@z Thu Jan 1 00:00:00 1970 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 539B6C43334 for ; Wed, 22 Jun 2022 14:34:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3247610E6BA; Wed, 22 Jun 2022 14:33:59 +0000 (UTC) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by gabe.freedesktop.org (Postfix) with ESMTPS id E3C2110E6BA for ; Wed, 22 Jun 2022 14:33:57 +0000 (UTC) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 8F9403200974; Wed, 22 Jun 2022 10:33:56 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 22 Jun 2022 10:33:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm1; t=1655908435; x=1655994835; bh=T/ IxpHABAY+ZyQ/TnWrVF3VGXfblrTJYMWFjxV5OqNE=; b=a8HsqdqXY0D1ng9kK5 FZRsOncAcBDg1nn9bFX9h6Re718NTMXpWCWgbbdqwXNKm4jLSI1RKAFG5Vc5WyOz vtbK1DCByczjaS9wb5h6q3O+rrxHJDMw0yDCH5nSzfNZN0TwvmpPdyA4HR91ruho h/s1X3/nZ1kjZZ/J55PDimwGWrvAzjiCJ1R71EGa4g4a7O0U24sd0bH9HqMnnHU3 qE9zarfEUxq13fta8Z7iaEpUVIB9X4lu6trMMnUT8p90YBFn4ShjvnOCCIwCWTGh aDsPIuIQ2GybMzhft5HLnnX86b/pwhlNsAg+2ciePo+sYlWLXbuvELNcm45RL69Y VCWQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1655908435; x=1655994835; bh=T/IxpHABAY+Zy Q/TnWrVF3VGXfblrTJYMWFjxV5OqNE=; b=jccZ5H4LUnyphIA/JCAI6/+gJFOEo b/tz8CuAbnUhWl9wU0z86/iyewltjV4hONSVuICQqwdq8s1m9L1NQrCRuFHSZvjl 7zLOzvSNJ9Jq9HdiPuXOdr3wLoa2Mvbln7+eYBJnUxJ2KqsX9u2GAIyWWPGasAkw WfGoSZHV0vkiLJ3RffM76y+MPTpQKfuc0C/otM41MILH7lJZzyBJ07KtPgK0NIRO elLOwupoT54GVLP9daUqZ6cUzl0JkP88wpuPUX1Wf0uMrB7QGTXpEhV44NeJrj8Y 7XL9V5oWz9ctHBxgyHsgxvWWARlzHgP3y/euP7JfVKiYG7jSs8P8IzK4w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudefhedgjeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpeelkeefteduhfekjeeihfetudfguedvveekkeetteekhfekhfdtlefgfedu vdejhfenucevlhhushhtvghrufhiiigvpeeinecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 22 Jun 2022 10:33:54 -0400 (EDT) From: Maxime Ripard To: Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Daniel Vetter , David Airlie Subject: [PATCH v2 32/68] drm/vc4: dsi: Switch to DRM-managed encoder initialization Date: Wed, 22 Jun 2022 16:31:33 +0200 Message-Id: <20220622143209.600298-33-maxime@cerno.tech> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220622143209.600298-1-maxime@cerno.tech> References: <20220622143209.600298-1-maxime@cerno.tech> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: dri-devel@lists.freedesktop.org, Dave Stevenson Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The current code will call drm_encoder_cleanup() when the device is unbound. However, by then, there might still be some references held to that encoder, including by the userspace that might still have the DRM device open. Let's switch to a DRM-managed initialization to clean up after ourselves only once the DRM device has been last closed. Reviewed-by: Dave Stevenson Signed-off-by: Maxime Ripard --- drivers/gpu/drm/vc4/vc4_dsi.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_dsi.c b/drivers/gpu/drm/vc4/vc4_dsi.c index dbb3f6fb39b4..f3214675f8b3 100644 --- a/drivers/gpu/drm/vc4/vc4_dsi.c +++ b/drivers/gpu/drm/vc4/vc4_dsi.c @@ -1599,7 +1599,13 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data) if (ret) return ret; - drm_simple_encoder_init(drm, encoder, DRM_MODE_ENCODER_DSI); + ret = drmm_encoder_init(drm, encoder, + NULL, + DRM_MODE_ENCODER_DSI, + NULL); + if (ret) + return ret; + drm_encoder_helper_add(encoder, &vc4_dsi_encoder_helper_funcs); ret = drm_bridge_attach(encoder, dsi->bridge, NULL, 0); @@ -1632,7 +1638,6 @@ static void vc4_dsi_unbind(struct device *dev, struct device *master, * normally. */ list_splice_init(&dsi->bridge_chain, &encoder->bridge_chain); - drm_encoder_cleanup(encoder); } static const struct component_ops vc4_dsi_ops = { -- 2.36.1