From: Stefan Agner <stefan@agner.ch>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Marek Vasut <marex@denx.de>,
kernel@pengutronix.de, dri-devel@lists.freedesktop.org,
linux-imx@nxp.com
Subject: Re: [PATCH 13/21] drm: mxsfb: Don't touch AXI clock in IRQ context
Date: Mon, 23 Mar 2020 23:50:29 +0100 [thread overview]
Message-ID: <e4cac7a95851cc62c762cf887d0ad691@agner.ch> (raw)
In-Reply-To: <20200309195216.31042-14-laurent.pinchart@ideasonboard.com>
On 2020-03-09 20:52, Laurent Pinchart wrote:
> The driver attempts agressive power management by enabling and disabling
> the AXI clock around register accesses. This results in attempts to
> enable and disable the clock in the IRQ handler, which is a no-go as
> preparing or unpreparing the clock may sleep.
>
> On the other hand, the driver enables the AXI clock when enabling the
> CRTC and keeps it enabled until the CRTC is disabled. This is correct,
> and renders the power management attempt pointless, as interrupts are
> not supposed to occur when the CRTC is off.
>
> The same reasoning can be applied to the CRTC .enable_vblank() and
> .disable_vblank() that are not supposed to be called when the CRTC off
> and thus don't require manual handling of the AXI clock. Furthermore,
> vblank handling is never enabled, which results in the vblank enable and
> disable handlers never being called.
>
> To fix this, remove the manual clock handling in the IRQ, the CRTC
> .enable_vblank() and .disable_vblank() handlers and the plane
> .atomic_update() handler. We however need to handle the clock manually
> in mxsfb_irq_disable() as is calls .disable_vblank() manually and is
> used both at probe and remove time.
>
> The clock disabling is also moved to the last step of the
> mxsfb_crtc_atomic_disable() function, to prepare for enabling vblank
> handling.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Looks good to me!
Reviewed-by: Stefan Agner <stefan@agner.ch>
> ---
> drivers/gpu/drm/mxsfb/mxsfb_drv.c | 6 ++----
> drivers/gpu/drm/mxsfb/mxsfb_kms.c | 15 ++++-----------
> 2 files changed, 6 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
> b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
> index a8da92976d13..e324bd2a63a5 100644
> --- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
> +++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
> @@ -231,7 +231,9 @@ static void mxsfb_irq_disable(struct drm_device *drm)
> {
> struct mxsfb_drm_private *mxsfb = drm->dev_private;
>
> + mxsfb_enable_axi_clk(mxsfb);
> mxsfb->crtc.funcs->disable_vblank(&mxsfb->crtc);
> + mxsfb_disable_axi_clk(mxsfb);
> }
>
> static irqreturn_t mxsfb_irq_handler(int irq, void *data)
> @@ -240,8 +242,6 @@ static irqreturn_t mxsfb_irq_handler(int irq, void *data)
> struct mxsfb_drm_private *mxsfb = drm->dev_private;
> u32 reg;
>
> - mxsfb_enable_axi_clk(mxsfb);
> -
> reg = readl(mxsfb->base + LCDC_CTRL1);
>
> if (reg & CTRL1_CUR_FRAME_DONE_IRQ)
> @@ -249,8 +249,6 @@ static irqreturn_t mxsfb_irq_handler(int irq, void *data)
>
> writel(CTRL1_CUR_FRAME_DONE_IRQ, mxsfb->base + LCDC_CTRL1 + REG_CLR);
>
> - mxsfb_disable_axi_clk(mxsfb);
> -
> return IRQ_HANDLED;
> }
>
> diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c
> b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
> index ebe0785694cb..ac2696c8483d 100644
> --- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c
> +++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
> @@ -344,9 +344,6 @@ static void mxsfb_crtc_atomic_disable(struct drm_crtc *crtc,
> struct drm_pending_vblank_event *event;
>
> mxsfb_disable_controller(mxsfb);
> - mxsfb_disable_axi_clk(mxsfb);
> -
> - pm_runtime_put_sync(drm->dev);
>
> spin_lock_irq(&drm->event_lock);
> event = crtc->state->event;
> @@ -355,6 +352,9 @@ static void mxsfb_crtc_atomic_disable(struct drm_crtc *crtc,
> drm_crtc_send_vblank_event(crtc, event);
> }
> spin_unlock_irq(&drm->event_lock);
> +
> + mxsfb_disable_axi_clk(mxsfb);
> + pm_runtime_put_sync(drm->dev);
> }
>
> static int mxsfb_crtc_enable_vblank(struct drm_crtc *crtc)
> @@ -362,10 +362,8 @@ static int mxsfb_crtc_enable_vblank(struct drm_crtc *crtc)
> struct mxsfb_drm_private *mxsfb = to_mxsfb_drm_private(crtc->dev);
>
> /* Clear and enable VBLANK IRQ */
> - mxsfb_enable_axi_clk(mxsfb);
> writel(CTRL1_CUR_FRAME_DONE_IRQ, mxsfb->base + LCDC_CTRL1 + REG_CLR);
> writel(CTRL1_CUR_FRAME_DONE_IRQ_EN, mxsfb->base + LCDC_CTRL1 + REG_SET);
> - mxsfb_disable_axi_clk(mxsfb);
>
> return 0;
> }
> @@ -375,10 +373,8 @@ static void mxsfb_crtc_disable_vblank(struct
> drm_crtc *crtc)
> struct mxsfb_drm_private *mxsfb = to_mxsfb_drm_private(crtc->dev);
>
> /* Disable and clear VBLANK IRQ */
> - mxsfb_enable_axi_clk(mxsfb);
> writel(CTRL1_CUR_FRAME_DONE_IRQ_EN, mxsfb->base + LCDC_CTRL1 + REG_CLR);
> writel(CTRL1_CUR_FRAME_DONE_IRQ, mxsfb->base + LCDC_CTRL1 + REG_CLR);
> - mxsfb_disable_axi_clk(mxsfb);
> }
>
> static const struct drm_crtc_helper_funcs mxsfb_crtc_helper_funcs = {
> @@ -433,11 +429,8 @@ static void mxsfb_plane_atomic_update(struct
> drm_plane *plane,
> dma_addr_t paddr;
>
> paddr = mxsfb_get_fb_paddr(mxsfb);
> - if (paddr) {
> - mxsfb_enable_axi_clk(mxsfb);
> + if (paddr)
> writel(paddr, mxsfb->base + mxsfb->devdata->next_buf);
> - mxsfb_disable_axi_clk(mxsfb);
> - }
> }
>
> static const struct drm_plane_helper_funcs mxsfb_plane_helper_funcs = {
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2020-03-23 22:50 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-09 19:51 [PATCH 00/21] drm: mxsfb: Add i.MX7 support Laurent Pinchart
2020-03-09 19:51 ` [PATCH 01/21] drm: mxsfb: Remove fbdev leftovers Laurent Pinchart
2020-03-23 20:23 ` Stefan Agner
2020-03-09 19:51 ` [PATCH 02/21] drm: mxsfb: Use drm_panel_bridge Laurent Pinchart
2020-03-23 21:27 ` Stefan Agner
2020-03-23 21:38 ` Sam Ravnborg
2020-03-23 23:50 ` Stefan Agner
2020-05-30 2:14 ` Laurent Pinchart
2020-06-02 13:12 ` Daniel Vetter
2020-06-02 14:34 ` Stefan Agner
2020-06-02 17:18 ` Laurent Pinchart
2020-06-02 17:13 ` Laurent Pinchart
2020-06-03 8:16 ` Daniel Vetter
2020-06-04 20:10 ` Sam Ravnborg
2020-03-09 19:51 ` [PATCH 03/21] drm: mxsfb: Use BIT() macro to define register bitfields Laurent Pinchart
2020-03-23 21:34 ` Stefan Agner
2020-03-09 19:51 ` [PATCH 04/21] drm: mxsfb: Remove unused macros from mxsfb_regs.h Laurent Pinchart
2020-03-23 21:36 ` Stefan Agner
2020-03-09 19:52 ` [PATCH 05/21] drm: mxsfb: Clarify format and bus width configuration Laurent Pinchart
2020-03-23 21:42 ` Stefan Agner
2020-03-09 19:52 ` [PATCH 06/21] drm: mxsfb: Pass mxsfb_drm_private pointer to mxsfb_reset_block() Laurent Pinchart
2020-03-23 21:43 ` Stefan Agner
2020-03-09 19:52 ` [PATCH 07/21] drm: mxsfb: Use LCDC_CTRL register name explicitly Laurent Pinchart
2020-03-23 21:48 ` Stefan Agner
2020-03-09 19:52 ` [PATCH 08/21] drm: mxsfb: Remove register definitions from mxsfb_crtc.c Laurent Pinchart
2020-03-23 21:49 ` Stefan Agner
2020-03-09 19:52 ` [PATCH 09/21] drm: mxsfb: Remove unneeded includes Laurent Pinchart
2020-03-23 21:53 ` Stefan Agner
2020-05-30 0:33 ` Laurent Pinchart
2020-03-09 19:52 ` [PATCH 10/21] drm: mxsfb: Stop using DRM simple display pipeline helper Laurent Pinchart
2020-03-23 22:30 ` Stefan Agner
2020-03-09 19:52 ` [PATCH 11/21] drm: mxsfb: Rename mxsfb_crtc.c to mxsfb_kms.c Laurent Pinchart
2020-03-23 22:31 ` Stefan Agner
2020-03-09 19:52 ` [PATCH 12/21] drm: mxsfb: Move vblank event arm to CRTC .atomic_flush() Laurent Pinchart
2020-03-23 22:38 ` Stefan Agner
2020-03-09 19:52 ` [PATCH 13/21] drm: mxsfb: Don't touch AXI clock in IRQ context Laurent Pinchart
2020-03-23 22:50 ` Stefan Agner [this message]
2020-03-09 19:52 ` [PATCH 14/21] drm: mxsfb: Enable vblank handling Laurent Pinchart
2020-03-23 23:08 ` Stefan Agner
2020-03-24 10:37 ` Stefan Agner
2020-03-09 19:52 ` [PATCH 15/21] drm: mxsfb: Remove mxsfb_devdata unused fields Laurent Pinchart
2020-03-23 23:15 ` Stefan Agner
2020-03-09 19:52 ` [PATCH 16/21] drm: mxsfb: Add i.MX7 to the list of supported SoCs in Kconfig Laurent Pinchart
2020-03-10 16:28 ` Fabio Estevam
2020-03-10 16:32 ` Laurent Pinchart
2020-03-10 16:37 ` [PATCH v1.1 " Laurent Pinchart
2020-03-23 23:18 ` [PATCH " Stefan Agner
2020-03-09 19:52 ` [PATCH 17/21] drm: mxsfb: Update internal IP version number for i.MX6SX Laurent Pinchart
2020-03-23 23:20 ` Stefan Agner
2020-03-09 19:52 ` [PATCH 18/21] drm: mxsfb: Drop non-OF support Laurent Pinchart
2020-03-23 23:23 ` Stefan Agner
2020-03-09 19:52 ` [PATCH 19/21] drm: mxsfb: Turn mxsfb_set_pixel_fmt() into a void function Laurent Pinchart
2020-03-23 23:28 ` Stefan Agner
2020-03-09 19:52 ` [PATCH 20/21] drm: mxsfb: Merge mxsfb_set_pixel_fmt() and mxsfb_set_bus_fmt() Laurent Pinchart
2020-03-23 23:34 ` Stefan Agner
2020-03-09 19:52 ` [PATCH 21/21] drm: mxsfb: Support the alpha plane Laurent Pinchart
2020-03-23 23:48 ` Stefan Agner
2020-05-30 2:44 ` Laurent Pinchart
2020-03-19 9:36 ` [PATCH 00/21] drm: mxsfb: Add i.MX7 support Laurent Pinchart
2020-04-12 16:37 ` Guido Günther
2020-05-26 15:13 ` Stefan Agner
2020-05-30 0:29 ` Laurent Pinchart
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=e4cac7a95851cc62c762cf887d0ad691@agner.ch \
--to=stefan@agner.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel@pengutronix.de \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-imx@nxp.com \
--cc=marex@denx.de \
/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).