linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: daniel@ffwll.ch, airlied@linux.ie, alexander.deucher@amd.com,
	christian.koenig@amd.com, liviu.dudau@arm.com,
	brian.starkey@arm.com, sam@ravnborg.org, bbrezillon@kernel.org,
	nicolas.ferre@microchip.com, maarten.lankhorst@linux.intel.com,
	mripard@kernel.org, stefan@agner.ch, alison.wang@nxp.com,
	patrik.r.jakobsson@gmail.com, anitha.chrisanthus@intel.com,
	robdclark@gmail.com, edmund.j.dea@intel.com, sean@poorly.run,
	shawnguo@kernel.org, s.hauer@pengutronix.de,
	kernel@pengutronix.de, jyri.sarha@iki.fi, tomba@kernel.org,
	Dan.Sneddon@microchip.com, tomi.valkeinen@ideasonboard.com
Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	linux-arm-kernel@lists.infradead.org,
	linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org,
	Thomas Zimmermann <tzimmermann@suse.de>
Subject: [PATCH v2 11/14] drm/tilcdc: Convert to Linux IRQ interfaces
Date: Tue,  3 Aug 2021 11:07:01 +0200	[thread overview]
Message-ID: <20210803090704.32152-12-tzimmermann@suse.de> (raw)
In-Reply-To: <20210803090704.32152-1-tzimmermann@suse.de>

Drop the DRM IRQ midlayer in favor of Linux IRQ interfaces. DRM's
IRQ helpers are mostly useful for UMS drivers. Modern KMS drivers
don't benefit from using it.

DRM IRQ callbacks are now being called directly or inlined.

Calls to platform_get_irq() can fail with a negative errno code.
Abort initialization in this case. The DRM IRQ midlayer does not
handle this case correctly.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/gpu/drm/tilcdc/tilcdc_drv.c | 51 ++++++++++++++++++++++-------
 drivers/gpu/drm/tilcdc/tilcdc_drv.h |  3 ++
 2 files changed, 43 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index f1d3a9f919fd..6b03f89a98d4 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -20,7 +20,6 @@
 #include <drm/drm_fourcc.h>
 #include <drm/drm_gem_cma_helper.h>
 #include <drm/drm_gem_framebuffer_helper.h>
-#include <drm/drm_irq.h>
 #include <drm/drm_mm.h>
 #include <drm/drm_probe_helper.h>
 #include <drm/drm_vblank.h>
@@ -124,6 +123,39 @@ static int cpufreq_transition(struct notifier_block *nb,
 }
 #endif
 
+static irqreturn_t tilcdc_irq(int irq, void *arg)
+{
+	struct drm_device *dev = arg;
+	struct tilcdc_drm_private *priv = dev->dev_private;
+
+	return tilcdc_crtc_irq(priv->crtc);
+}
+
+static int tilcdc_irq_install(struct drm_device *dev, unsigned int irq)
+{
+	struct tilcdc_drm_private *priv = dev->dev_private;
+	int ret;
+
+	ret = request_irq(irq, tilcdc_irq, 0, dev->driver->name, dev);
+	if (ret)
+		return ret;
+
+	priv->irq_enabled = false;
+
+	return 0;
+}
+
+static void tilcdc_irq_uninstall(struct drm_device *dev)
+{
+	struct tilcdc_drm_private *priv = dev->dev_private;
+
+	if (!priv->irq_enabled)
+		return;
+
+	free_irq(priv->irq, dev);
+	priv->irq_enabled = false;
+}
+
 /*
  * DRM operations:
  */
@@ -145,7 +177,7 @@ static void tilcdc_fini(struct drm_device *dev)
 		drm_dev_unregister(dev);
 
 	drm_kms_helper_poll_fini(dev);
-	drm_irq_uninstall(dev);
+	tilcdc_irq_uninstall(dev);
 	drm_mode_config_cleanup(dev);
 
 	if (priv->clk)
@@ -336,7 +368,12 @@ static int tilcdc_init(const struct drm_driver *ddrv, struct device *dev)
 		goto init_failed;
 	}
 
-	ret = drm_irq_install(ddev, platform_get_irq(pdev, 0));
+	ret = platform_get_irq(pdev, 0);
+	if (ret < 0)
+		goto init_failed;
+	priv->irq = ret;
+
+	ret = tilcdc_irq_install(ddev, priv->irq);
 	if (ret < 0) {
 		dev_err(dev, "failed to install IRQ handler\n");
 		goto init_failed;
@@ -360,13 +397,6 @@ static int tilcdc_init(const struct drm_driver *ddrv, struct device *dev)
 	return ret;
 }
 
-static irqreturn_t tilcdc_irq(int irq, void *arg)
-{
-	struct drm_device *dev = arg;
-	struct tilcdc_drm_private *priv = dev->dev_private;
-	return tilcdc_crtc_irq(priv->crtc);
-}
-
 #if defined(CONFIG_DEBUG_FS)
 static const struct {
 	const char *name;
@@ -454,7 +484,6 @@ DEFINE_DRM_GEM_CMA_FOPS(fops);
 
 static const struct drm_driver tilcdc_driver = {
 	.driver_features    = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
-	.irq_handler        = tilcdc_irq,
 	DRM_GEM_CMA_DRIVER_OPS,
 #ifdef CONFIG_DEBUG_FS
 	.debugfs_init       = tilcdc_debugfs_init,
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.h b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
index d29806ca8817..b818448c83f6 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.h
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
@@ -46,6 +46,8 @@ struct tilcdc_drm_private {
 	struct clk *clk;         /* functional clock */
 	int rev;                 /* IP revision */
 
+	unsigned int irq;
+
 	/* don't attempt resolutions w/ higher W * H * Hz: */
 	uint32_t max_bandwidth;
 	/*
@@ -82,6 +84,7 @@ struct tilcdc_drm_private {
 
 	bool is_registered;
 	bool is_componentized;
+	bool irq_enabled;
 };
 
 /* Sub-module for display.  Since we don't know at compile time what panels
-- 
2.32.0


  parent reply	other threads:[~2021-08-03  9:07 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-03  9:06 [PATCH v2 00/14] drm: Make DRM's IRQ helpers legacy Thomas Zimmermann
2021-08-03  9:06 ` [PATCH v2 01/14] drm/amdgpu: Convert to Linux IRQ interfaces Thomas Zimmermann
2021-08-03  9:06 ` [PATCH v2 02/14] drm/arm/hdlcd: " Thomas Zimmermann
2021-08-20 16:05   ` Liviu Dudau
2021-08-03  9:06 ` [PATCH v2 03/14] drm/atmel-hlcdc: " Thomas Zimmermann
2021-08-03  9:06 ` [PATCH v2 04/14] drm/fsl-dcu: " Thomas Zimmermann
2021-08-03  9:06 ` [PATCH v2 05/14] drm/gma500: " Thomas Zimmermann
2021-08-03  9:06 ` [PATCH v2 06/14] drm/kmb: " Thomas Zimmermann
2021-08-03  9:06 ` [PATCH v2 07/14] drm/msm: " Thomas Zimmermann
2021-08-03  9:37   ` Dmitry Baryshkov
2021-08-03 15:04     ` Rob Clark
2021-08-07 17:08     ` Rob Clark
2021-08-07 18:40       ` Thomas Zimmermann
2021-08-07 18:50         ` Rob Clark
2021-08-03 17:20   ` [Freedreno] " abhinavk
2021-08-03  9:06 ` [PATCH v2 08/14] drm/mxsfb: " Thomas Zimmermann
2021-08-03  9:06 ` [PATCH v2 09/14] drm/radeon: " Thomas Zimmermann
2021-08-03  9:07 ` [PATCH v2 10/14] drm/tidss: " Thomas Zimmermann
2021-08-03  9:07 ` Thomas Zimmermann [this message]
     [not found]   ` <YQlZ+EQVbO9N3Mla@ravnborg.org>
2021-08-04 18:30     ` [PATCH v2 11/14] drm/tilcdc: " Thomas Zimmermann
2021-08-03  9:07 ` [PATCH v2 12/14] drm/vc4: " Thomas Zimmermann
2021-08-03  9:07 ` [PATCH v2 13/14] drm: Remove unused devm_drm_irq_install() Thomas Zimmermann
2021-08-03  9:07 ` [PATCH v2 14/14] drm: IRQ midlayer is now legacy Thomas Zimmermann
     [not found] ` <YQlbFjbrnyeWv7QP@ravnborg.org>
2021-08-03 18:36   ` [PATCH v2 00/14] drm: Make DRM's IRQ helpers legacy Chrisanthus, Anitha
2021-08-04  7:10     ` Thomas Zimmermann
2021-08-05 23:59       ` Chrisanthus, Anitha
2021-08-07  6:51         ` Thomas Zimmermann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210803090704.32152-12-tzimmermann@suse.de \
    --to=tzimmermann@suse.de \
    --cc=Dan.Sneddon@microchip.com \
    --cc=airlied@linux.ie \
    --cc=alexander.deucher@amd.com \
    --cc=alison.wang@nxp.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=anitha.chrisanthus@intel.com \
    --cc=bbrezillon@kernel.org \
    --cc=brian.starkey@arm.com \
    --cc=christian.koenig@amd.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=edmund.j.dea@intel.com \
    --cc=freedreno@lists.freedesktop.org \
    --cc=jyri.sarha@iki.fi \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=liviu.dudau@arm.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=nicolas.ferre@microchip.com \
    --cc=patrik.r.jakobsson@gmail.com \
    --cc=robdclark@gmail.com \
    --cc=s.hauer@pengutronix.de \
    --cc=sam@ravnborg.org \
    --cc=sean@poorly.run \
    --cc=shawnguo@kernel.org \
    --cc=stefan@agner.ch \
    --cc=tomba@kernel.org \
    --cc=tomi.valkeinen@ideasonboard.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).