From nobody Sun Feb 8 00:38:53 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF5B730CD81; Fri, 23 Jan 2026 16:13:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769184813; cv=none; b=XiGccebxhFMEw1uPypoXicwFbAs2yq6DERIfb0vYaFbnJxnKPFqwrMhJZmtyMwr3Vd7S7mI0QOmUw7imEeCww2UEu0itVW6cdGj1DccAEwNaWfuyUdUcZNcPJjCpyxWZV59sV8BHOfOn9Xq1l6Ti/tXxy27sj34xuOl0gaCIepg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769184813; c=relaxed/simple; bh=awJFl+dM4odPDy7rin8H00QDJ/gI6x+Bv5XNVuspK6k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Qw7uhgKSTECwBYdS2WpIer7sGaqxburjlW/m7Yk3mvZ/4HZ/7ysnAh8rKhI+e59lZIbThhVBRZjlzvr9kZeE9VdZ2wR2pBNgg5J9kQhAc2RbeAPc/JyWrOnlMOLLqqS/scAMbdr2JkQPRN5b1bSFgmUXgpN/gaJ4qQhW86U83DA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=l33IwFhO; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="l33IwFhO" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 3ADEF4E42223; Fri, 23 Jan 2026 16:13:30 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 07FDC6070A; Fri, 23 Jan 2026 16:13:30 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 931AE119A87C6; Fri, 23 Jan 2026 17:13:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1769184808; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=/BKaoJ3T5C1k+ehrxNSj19qknnHMN8esUNvOs+C8dN0=; b=l33IwFhOStdoZhQmHdiw5bEPbDEdw5lXBZpeJKTmik8Fur1jkPnaOw4CdDrC6MxKVS1msw t2hXQvZUS6vvjpo9ZKiKugaFUKOJnhBtctOIMAVB1RJr/EXgC20j2mf/016uHxNcYmXu23 ApyBL+VONWELe/d0OYVrEW0QhAXDXjVLHoxUJIM5ZTgmMbqKdff6oMZ8vtmntpoj/Oawpv qP8SANJYf3oy73Wbgq0f5ISVaPguh/w8V9PA2KfaCiBIe1AArN2OQBJEtD6eqGVnemGA8n wqCOYk1omQGA3/RGsv5hW4YgEwqQrLdFJV0BGvWY2y+Ga1mGGGDcO0WqBwTrFA== From: "Kory Maincent (TI.com)" Date: Fri, 23 Jan 2026 17:12:34 +0100 Subject: [PATCH v5 16/25] drm/tilcdc: Modernize driver initialization and cleanup paths Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260123-feature_tilcdc-v5-16-5a44d2aa3f6f@bootlin.com> References: <20260123-feature_tilcdc-v5-0-5a44d2aa3f6f@bootlin.com> In-Reply-To: <20260123-feature_tilcdc-v5-0-5a44d2aa3f6f@bootlin.com> To: Jyri Sarha , Tomi Valkeinen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Russell King , Bartosz Golaszewski , Tony Lindgren , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec Cc: Markus Schneider-Pargmann , Bajjuri Praneeth , Luca Ceresoli , Louis Chauvet , Thomas Petazzoni , Miguel Gazquez , Herve Codina , dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, "Kory Maincent (TI.com)" X-Mailer: b4 0.15-dev-47773 X-Last-TLS-Session-Version: TLSv1.3 Refactor the driver initialization to use modern DRM managed resource APIs, simplifying the code. The tilcdc_init and tilcdc_fini wrapper functions are removed since they served no purpose after the component framework was eliminated. Their logic is integrated directly into probe and remove. Key changes: - Use devm_drm_dev_alloc() instead of drm_dev_alloc(). - Use drmm_mode_config_init() instead of drm_mode_config_init(). - Align the remove path with the probe error path to ensure consistent cleanup ordering in both success and failure cases. - Adjust platform_set_drvdata() to store the private structure instead of the drm_device, matching the new allocation pattern. These changes reduce error-prone code while maintaining the same functional behavior. Reviewed-by: Luca Ceresoli Signed-off-by: Kory Maincent (TI.com) --- Change in v3: - Split the patch between code move and cleanup for better diff readibility. --- drivers/gpu/drm/tilcdc/tilcdc_drv.c | 100 ++++++++++++--------------------= ---- drivers/gpu/drm/tilcdc/tilcdc_drv.h | 2 + 2 files changed, 35 insertions(+), 67 deletions(-) diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/t= ilcdc_drv.c index abe432b752dc0..2f35075b663ff 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c @@ -259,68 +259,33 @@ static int tilcdc_pm_resume(struct device *dev) static DEFINE_SIMPLE_DEV_PM_OPS(tilcdc_pm_ops, tilcdc_pm_suspend, tilcdc_pm_resume); =20 -static void tilcdc_fini(struct drm_device *dev) -{ - struct tilcdc_drm_private *priv =3D dev->dev_private; - -#ifdef CONFIG_CPU_FREQ - if (priv->freq_transition.notifier_call) - cpufreq_unregister_notifier(&priv->freq_transition, - CPUFREQ_TRANSITION_NOTIFIER); -#endif - - if (priv->crtc) - tilcdc_crtc_shutdown(priv->crtc); - - drm_dev_unregister(dev); - - drm_kms_helper_poll_fini(dev); - drm_atomic_helper_shutdown(dev); - tilcdc_irq_uninstall(dev); - drm_mode_config_cleanup(dev); - - if (priv->clk) - clk_put(priv->clk); - - if (priv->wq) - destroy_workqueue(priv->wq); - - dev->dev_private =3D NULL; - - pm_runtime_disable(dev->dev); - - drm_dev_put(dev); -} - -static int tilcdc_init(const struct drm_driver *ddrv, struct device *dev) +static int tilcdc_pdev_probe(struct platform_device *pdev) { - struct drm_device *ddev; - struct platform_device *pdev =3D to_platform_device(dev); - struct device_node *node =3D dev->of_node; + struct device_node *node =3D pdev->dev.of_node; struct tilcdc_drm_private *priv; + struct device *dev =3D &pdev->dev; enum tilcdc_variant variant; + struct drm_device *ddev; u32 bpp =3D 0; int ret; =20 - priv =3D devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); - if (!priv) - return -ENOMEM; - - ddev =3D drm_dev_alloc(ddrv, dev); - if (IS_ERR(ddev)) - return PTR_ERR(ddev); + priv =3D devm_drm_dev_alloc(dev, &tilcdc_driver, + struct tilcdc_drm_private, ddev); + if (IS_ERR(priv)) + return PTR_ERR(priv); =20 variant =3D (uintptr_t)of_device_get_match_data(dev); =20 ddev->dev_private =3D priv; - platform_set_drvdata(pdev, ddev); - drm_mode_config_init(ddev); + platform_set_drvdata(pdev, priv); + ddev =3D &priv->ddev; + ret =3D drmm_mode_config_init(ddev); + if (ret) + return ret; =20 priv->wq =3D alloc_ordered_workqueue("tilcdc", 0); - if (!priv->wq) { - ret =3D -ENOMEM; - goto put_drm; - } + if (!priv->wq) + return -ENOMEM; =20 priv->mmio =3D devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(priv->mmio)) { @@ -486,33 +451,34 @@ static int tilcdc_init(const struct drm_driver *ddrv,= struct device *dev) clk_put(priv->clk); free_wq: destroy_workqueue(priv->wq); -put_drm: - platform_set_drvdata(pdev, NULL); - ddev->dev_private =3D NULL; - drm_dev_put(ddev); =20 return ret; } =20 -static int tilcdc_pdev_probe(struct platform_device *pdev) -{ - /* bail out early if no DT data: */ - if (!pdev->dev.of_node) { - dev_err(&pdev->dev, "device-tree data is missing\n"); - return -ENXIO; - } - - return tilcdc_init(&tilcdc_driver, &pdev->dev); -} - static void tilcdc_pdev_remove(struct platform_device *pdev) { - tilcdc_fini(platform_get_drvdata(pdev)); + struct tilcdc_drm_private *priv =3D platform_get_drvdata(pdev); + struct drm_device *ddev =3D &priv->ddev; + + drm_dev_unregister(ddev); + drm_kms_helper_poll_fini(ddev); + tilcdc_irq_uninstall(ddev); +#ifdef CONFIG_CPU_FREQ + cpufreq_unregister_notifier(&priv->freq_transition, + CPUFREQ_TRANSITION_NOTIFIER); +#endif + tilcdc_crtc_destroy(priv->crtc); + pm_runtime_disable(&pdev->dev); + clk_put(priv->clk); + destroy_workqueue(priv->wq); } =20 static void tilcdc_pdev_shutdown(struct platform_device *pdev) { - drm_atomic_helper_shutdown(platform_get_drvdata(pdev)); + struct tilcdc_drm_private *priv =3D platform_get_drvdata(pdev); + struct drm_device *ddev =3D &priv->ddev; + + drm_atomic_helper_shutdown(ddev); } =20 static const struct of_device_id tilcdc_of_match[] =3D { diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.h b/drivers/gpu/drm/tilcdc/t= ilcdc_drv.h index 60e85e29b1063..e3d04a3eb25b4 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_drv.h +++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.h @@ -48,6 +48,8 @@ struct tilcdc_drm_private { =20 unsigned int irq; =20 + struct drm_device ddev; + /* don't attempt resolutions w/ higher W * H * Hz: */ uint32_t max_bandwidth; /* --=20 2.43.0