From patchwork Fri Jun 10 09:28:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12877197 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 57B5CCCA47B for ; Fri, 10 Jun 2022 09:30:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id ED50A11B31A; Fri, 10 Jun 2022 09:30:23 +0000 (UTC) Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by gabe.freedesktop.org (Postfix) with ESMTPS id 50BB111B280 for ; Fri, 10 Jun 2022 09:30:15 +0000 (UTC) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id AF4F65C01C0; Fri, 10 Jun 2022 05:30:14 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Fri, 10 Jun 2022 05:30:14 -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=1654853414; x=1654939814; bh=Ae cD8/M9MRxOJgAzUW3cq6H5rVrme+/a4dPnA/GjLUg=; b=FU2gqhW/AYy19Y5UQ2 KtCbHho5B+yCXHdqI1qc+eEHjWKKeP0O3Pb+nCcp95fmn7U+GTl3JJrYJwkITG1B 5RXTEvu6/YQN0ZpG6My+/MZ44LvHZB45iD5HTXO5zygMh8Cgz+lfrdqlW1nJK0fZ aR6l5WBdgU94XzrBhOloZCoOtdRzZ7GpFDszDlmfMrv25iHjIPthA7sgnSlT8Oy9 UdtDg4Qc3mdSeCUBZIjSymTIoOSkT94gUBsEGB/bOFGdVExXXqgbcNR3lu++i7OT x8/9eBWzdEuvFYRwh2YMoDhopt+7eF9vrY6YRgt6FjzaLm/A52c5NIhqSZX00dsk 31jQ== 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=1654853414; x=1654939814; bh=AecD8/M9MRxOJ gAzUW3cq6H5rVrme+/a4dPnA/GjLUg=; b=GYzutzZIBzXPxt3t70hJLXGug/5Dh IUWaELMwDjGpFu0c5gJPIGtsOTlMXTHj1AHzEKuAjnRmYcNrN95An8gUq8n6AJ27 dmTKS/T5jfuuoGT3h9sMFWvNJiYHKQvzWD5suqYfqSZwfO1sOiehq3bp8171/q/a ec9askleNCwQ0gPR6FRolm8fatoFARFTLhH8KdvAUR8wg/4d3TD+kBPXDHdGl5LD 5Y7Jh3b0/WVSf5jX32H4fpZzsZbKoUfXRLo/6T1Em5Eq0jwn4b0lOTh1bJOyuXry wRf778OBGFIZHhDLAFeJjncqt5PiqjInyQf4R02yO0kwKTIugFuHTxPyA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudduuddgudehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpeelkeefteduhfekjeeihfetudfguedvveekkeetteekhfekhfdtlefgfedu vdejhfenucevlhhushhtvghrufhiiigvpeehnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 10 Jun 2022 05:30:14 -0400 (EDT) From: Maxime Ripard To: Daniel Vetter , David Airlie , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard Subject: [PATCH 26/64] drm/vc4: dpi: Switch to DRM-managed encoder initialization Date: Fri, 10 Jun 2022 11:28:46 +0200 Message-Id: <20220610092924.754942-27-maxime@cerno.tech> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220610092924.754942-1-maxime@cerno.tech> References: <20220610092924.754942-1-maxime@cerno.tech> 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: dri-devel@lists.freedesktop.org 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. Signed-off-by: Maxime Ripard Reviewed-by: Dave Stevenson --- drivers/gpu/drm/vc4/vc4_dpi.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_dpi.c b/drivers/gpu/drm/vc4/vc4_dpi.c index 4e24dbad77f2..8a50de2c40d9 100644 --- a/drivers/gpu/drm/vc4/vc4_dpi.c +++ b/drivers/gpu/drm/vc4/vc4_dpi.c @@ -296,35 +296,25 @@ static int vc4_dpi_bind(struct device *dev, struct device *master, void *data) if (ret) return ret; - drm_simple_encoder_init(drm, &dpi->encoder.base, DRM_MODE_ENCODER_DPI); + ret = drmm_simple_encoder_init(drm, &dpi->encoder.base, DRM_MODE_ENCODER_DPI); + if (ret) + return ret; + drm_encoder_helper_add(&dpi->encoder.base, &vc4_dpi_encoder_helper_funcs); ret = vc4_dpi_init_bridge(dpi); if (ret) - goto err_destroy_encoder; + return ret; dev_set_drvdata(dev, dpi); vc4_debugfs_add_regset32(drm, "dpi_regs", &dpi->regset); return 0; - -err_destroy_encoder: - drm_encoder_cleanup(&dpi->encoder.base); - return ret; -} - -static void vc4_dpi_unbind(struct device *dev, struct device *master, - void *data) -{ - struct vc4_dpi *dpi = dev_get_drvdata(dev); - - drm_encoder_cleanup(&dpi->encoder.base); } static const struct component_ops vc4_dpi_ops = { .bind = vc4_dpi_bind, - .unbind = vc4_dpi_unbind, }; static int vc4_dpi_dev_probe(struct platform_device *pdev)