From: Mark yao <mark.yao@rock-chips.com>
To: Daniel Kurtz <djkurtz@chromium.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
dri-devel <dri-devel@lists.freedesktop.org>,
"open list:ARM/Rockchip SoC..."
<linux-rockchip@lists.infradead.org>
Subject: Re: [PATCH] drm/rockchip: vop: power off until vop standby take effect
Date: Mon, 02 Feb 2015 10:30:09 +0800 [thread overview]
Message-ID: <54CEE131.1020600@rock-chips.com> (raw)
In-Reply-To: <CAGS+omA70JADHR3PhGq-qC8MYobQjsR91MLw6RXdQ6xag0UQWg@mail.gmail.com>
On 2015年02月02日 10:07, Daniel Kurtz wrote:
> Hi Mark, Heiko,
>
> On Sat, Jan 31, 2015 at 4:41 PM, Mark Yao <mark.yao@rock-chips.com> wrote:
>> Vop standby will take effect end of current frame,
>> if dsp_hold_valid_irq happen, it means vop standby complete.
>>
>> we must wait standby complete when we want to disable aclk,
>> if not, memory bus maybe dead.
>>
>> Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
>> ---
>> drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 76 ++++++++++++++++++++++-----
>> 1 file changed, 63 insertions(+), 13 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
>> index fb25836..47ea61f 100644
>> --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
>> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
>> @@ -89,6 +89,7 @@ struct vop {
>> /* mutex vsync_ work */
>> struct mutex vsync_mutex;
>> bool vsync_work_pending;
>> + struct completion dsp_hold_completion;
>>
>> const struct vop_data *data;
>>
>> @@ -382,6 +383,34 @@ static bool is_alpha_support(uint32_t format)
>> }
>> }
>>
>> +static void vop_dsp_hold_valid_irq_enable(struct vop *vop)
>> +{
>> + unsigned long flags;
>> +
>> + BUG_ON(!vop->is_enabled);
> Re: Heiko "use a WARN_ON":
>
> If the VOP clock is off, then the system will just hang when trying to
> write the VOP register so in this case, BUG_ON gives a more reliable
> crash dump than the hang.
In this way, you are right, if vop clocks is disabled, write vop
register will hang system, and the WARN_ON
crash dump may be have no chance to print.
>
>> +
>> + spin_lock_irqsave(&vop->irq_lock, flags);
>> +
>> + vop_mask_write(vop, INTR_CTRL0, DSP_HOLD_VALID_INTR_MASK,
>> + DSP_HOLD_VALID_INTR_EN(1));
>> +
>> + spin_unlock_irqrestore(&vop->irq_lock, flags);
>> +}
>> +
>> +static void vop_dsp_hold_valid_irq_disable(struct vop *vop)
>> +{
>> + unsigned long flags;
>> +
>> + BUG_ON(!vop->is_enabled);
>> +
>> + spin_lock_irqsave(&vop->irq_lock, flags);
>> +
>> + vop_mask_write(vop, INTR_CTRL0, DSP_HOLD_VALID_INTR_MASK,
>> + DSP_HOLD_VALID_INTR_EN(0));
>> +
>> + spin_unlock_irqrestore(&vop->irq_lock, flags);
>> +}
>> +
>> static void vop_enable(struct drm_crtc *crtc)
>> {
>> struct vop *vop = to_vop(crtc);
>> @@ -454,26 +483,36 @@ static void vop_disable(struct drm_crtc *crtc)
>>
>> drm_vblank_off(crtc->dev, vop->pipe);
>>
>> - disable_irq(vop->irq);
>> -
>> /*
>> - * TODO: Since standby doesn't take effect until the next vblank,
>> - * when we turn off dclk below, the vop is probably still active.
>> + * Vop standby will take effect until end of current frame,
> "Vop standby will take effect at end of current frame"
OK
>> + * if dsp hold valid irq happen, it means standby complete.
>> + *
>> + * we must wait standby complete when we want to disable aclk,
>> + * if not, memory bus maybe dead.
>> */
>> + reinit_completion(&vop->dsp_hold_completion);
>> + vop_dsp_hold_valid_irq_enable(vop);
>> +
>> spin_lock(&vop->reg_lock);
>>
>> VOP_CTRL_SET(vop, standby, 1);
>>
>> spin_unlock(&vop->reg_lock);
>>
>> + wait_for_completion(&vop->dsp_hold_completion);
>> +
>> + vop_dsp_hold_valid_irq_disable(vop);
>> +
>> + disable_irq(vop->irq);
>> +
>> vop->is_enabled = false;
>> +
>> /*
>> - * disable dclk to stop frame scan, so we can safely detach iommu,
>> + * vop standby complete, so iommu detach is safe.
>> */
>> - clk_disable(vop->dclk);
>> -
>> rockchip_drm_dma_detach_device(vop->drm_dev, vop->dev);
>>
>> + clk_disable(vop->dclk);
>> clk_disable(vop->aclk);
>> clk_disable(vop->hclk);
>> }
>> @@ -1086,6 +1125,7 @@ static irqreturn_t vop_isr(int irq, void *data)
>> struct vop *vop = data;
>> uint32_t intr0_reg, active_irqs;
>> unsigned long flags;
>> + int ret = IRQ_NONE;
>>
>> /*
>> * INTR_CTRL0 register has interrupt status, enable and clear bits, we
>> @@ -1104,15 +1144,24 @@ static irqreturn_t vop_isr(int irq, void *data)
>> if (!active_irqs)
>> return IRQ_NONE;
>>
>> - /* Only Frame Start Interrupt is enabled; other irqs are spurious. */
>> - if (!(active_irqs & FS_INTR)) {
>> - DRM_ERROR("Unknown VOP IRQs: %#02x\n", active_irqs);
>> - return IRQ_NONE;
>> + if (active_irqs & DSP_HOLD_VALID_INTR) {
>> + if (!completion_done(&vop->dsp_hold_completion))
> Why is this "completion_done" check needed?
> I guess it doesn't help, but isn't strictly needed, since the
> dsp_hold_completion is a one shot, right?
Right, the DSP_HOLD_VALID_INTR only happen when standby complete, one
standby one irq.
Mark
> In any case, this should work as it is, so:
>
> Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>
>
>> + complete(&vop->dsp_hold_completion);
>> + active_irqs &= ~DSP_HOLD_VALID_INTR;
>> + ret = IRQ_HANDLED;
>> }
>>
>> - drm_handle_vblank(vop->drm_dev, vop->pipe);
>> + if (active_irqs & FS_INTR) {
>> + drm_handle_vblank(vop->drm_dev, vop->pipe);
>> + active_irqs &= ~FS_INTR;
>> + ret = (vop->vsync_work_pending) ? IRQ_WAKE_THREAD : IRQ_HANDLED;
>> + }
>>
>> - return (vop->vsync_work_pending) ? IRQ_WAKE_THREAD : IRQ_HANDLED;
>> + /* Unhandled irqs are spurious. */
>> + if (active_irqs)
>> + DRM_ERROR("Unknown VOP IRQs: %#02x\n", active_irqs);
>> +
>> + return ret;
>> }
>>
>> static int vop_create_crtc(struct vop *vop)
>> @@ -1194,6 +1243,7 @@ static int vop_create_crtc(struct vop *vop)
>> goto err_cleanup_crtc;
>> }
>>
>> + init_completion(&vop->dsp_hold_completion);
>> crtc->port = port;
>> vop->pipe = drm_crtc_index(crtc);
>> rockchip_register_crtc_funcs(drm_dev, &private_crtc_funcs, vop->pipe);
>> --
>> 1.7.9.5
>>
>>
>
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
WARNING: multiple messages have this Message-ID (diff)
From: Mark yao <mark.yao@rock-chips.com>
To: Daniel Kurtz <djkurtz@chromium.org>
Cc: David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
Rob Clark <robdclark@gmail.com>,
Philipp Zabel <p.zabel@pengutronix.de>,
dri-devel <dri-devel@lists.freedesktop.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"open list:ARM/Rockchip SoC..."
<linux-rockchip@lists.infradead.org>
Subject: Re: [PATCH] drm/rockchip: vop: power off until vop standby take effect
Date: Mon, 02 Feb 2015 10:30:09 +0800 [thread overview]
Message-ID: <54CEE131.1020600@rock-chips.com> (raw)
In-Reply-To: <CAGS+omA70JADHR3PhGq-qC8MYobQjsR91MLw6RXdQ6xag0UQWg@mail.gmail.com>
On 2015年02月02日 10:07, Daniel Kurtz wrote:
> Hi Mark, Heiko,
>
> On Sat, Jan 31, 2015 at 4:41 PM, Mark Yao <mark.yao@rock-chips.com> wrote:
>> Vop standby will take effect end of current frame,
>> if dsp_hold_valid_irq happen, it means vop standby complete.
>>
>> we must wait standby complete when we want to disable aclk,
>> if not, memory bus maybe dead.
>>
>> Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
>> ---
>> drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 76 ++++++++++++++++++++++-----
>> 1 file changed, 63 insertions(+), 13 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
>> index fb25836..47ea61f 100644
>> --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
>> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
>> @@ -89,6 +89,7 @@ struct vop {
>> /* mutex vsync_ work */
>> struct mutex vsync_mutex;
>> bool vsync_work_pending;
>> + struct completion dsp_hold_completion;
>>
>> const struct vop_data *data;
>>
>> @@ -382,6 +383,34 @@ static bool is_alpha_support(uint32_t format)
>> }
>> }
>>
>> +static void vop_dsp_hold_valid_irq_enable(struct vop *vop)
>> +{
>> + unsigned long flags;
>> +
>> + BUG_ON(!vop->is_enabled);
> Re: Heiko "use a WARN_ON":
>
> If the VOP clock is off, then the system will just hang when trying to
> write the VOP register so in this case, BUG_ON gives a more reliable
> crash dump than the hang.
In this way, you are right, if vop clocks is disabled, write vop
register will hang system, and the WARN_ON
crash dump may be have no chance to print.
>
>> +
>> + spin_lock_irqsave(&vop->irq_lock, flags);
>> +
>> + vop_mask_write(vop, INTR_CTRL0, DSP_HOLD_VALID_INTR_MASK,
>> + DSP_HOLD_VALID_INTR_EN(1));
>> +
>> + spin_unlock_irqrestore(&vop->irq_lock, flags);
>> +}
>> +
>> +static void vop_dsp_hold_valid_irq_disable(struct vop *vop)
>> +{
>> + unsigned long flags;
>> +
>> + BUG_ON(!vop->is_enabled);
>> +
>> + spin_lock_irqsave(&vop->irq_lock, flags);
>> +
>> + vop_mask_write(vop, INTR_CTRL0, DSP_HOLD_VALID_INTR_MASK,
>> + DSP_HOLD_VALID_INTR_EN(0));
>> +
>> + spin_unlock_irqrestore(&vop->irq_lock, flags);
>> +}
>> +
>> static void vop_enable(struct drm_crtc *crtc)
>> {
>> struct vop *vop = to_vop(crtc);
>> @@ -454,26 +483,36 @@ static void vop_disable(struct drm_crtc *crtc)
>>
>> drm_vblank_off(crtc->dev, vop->pipe);
>>
>> - disable_irq(vop->irq);
>> -
>> /*
>> - * TODO: Since standby doesn't take effect until the next vblank,
>> - * when we turn off dclk below, the vop is probably still active.
>> + * Vop standby will take effect until end of current frame,
> "Vop standby will take effect at end of current frame"
OK
>> + * if dsp hold valid irq happen, it means standby complete.
>> + *
>> + * we must wait standby complete when we want to disable aclk,
>> + * if not, memory bus maybe dead.
>> */
>> + reinit_completion(&vop->dsp_hold_completion);
>> + vop_dsp_hold_valid_irq_enable(vop);
>> +
>> spin_lock(&vop->reg_lock);
>>
>> VOP_CTRL_SET(vop, standby, 1);
>>
>> spin_unlock(&vop->reg_lock);
>>
>> + wait_for_completion(&vop->dsp_hold_completion);
>> +
>> + vop_dsp_hold_valid_irq_disable(vop);
>> +
>> + disable_irq(vop->irq);
>> +
>> vop->is_enabled = false;
>> +
>> /*
>> - * disable dclk to stop frame scan, so we can safely detach iommu,
>> + * vop standby complete, so iommu detach is safe.
>> */
>> - clk_disable(vop->dclk);
>> -
>> rockchip_drm_dma_detach_device(vop->drm_dev, vop->dev);
>>
>> + clk_disable(vop->dclk);
>> clk_disable(vop->aclk);
>> clk_disable(vop->hclk);
>> }
>> @@ -1086,6 +1125,7 @@ static irqreturn_t vop_isr(int irq, void *data)
>> struct vop *vop = data;
>> uint32_t intr0_reg, active_irqs;
>> unsigned long flags;
>> + int ret = IRQ_NONE;
>>
>> /*
>> * INTR_CTRL0 register has interrupt status, enable and clear bits, we
>> @@ -1104,15 +1144,24 @@ static irqreturn_t vop_isr(int irq, void *data)
>> if (!active_irqs)
>> return IRQ_NONE;
>>
>> - /* Only Frame Start Interrupt is enabled; other irqs are spurious. */
>> - if (!(active_irqs & FS_INTR)) {
>> - DRM_ERROR("Unknown VOP IRQs: %#02x\n", active_irqs);
>> - return IRQ_NONE;
>> + if (active_irqs & DSP_HOLD_VALID_INTR) {
>> + if (!completion_done(&vop->dsp_hold_completion))
> Why is this "completion_done" check needed?
> I guess it doesn't help, but isn't strictly needed, since the
> dsp_hold_completion is a one shot, right?
Right, the DSP_HOLD_VALID_INTR only happen when standby complete, one
standby one irq.
Mark
> In any case, this should work as it is, so:
>
> Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>
>
>> + complete(&vop->dsp_hold_completion);
>> + active_irqs &= ~DSP_HOLD_VALID_INTR;
>> + ret = IRQ_HANDLED;
>> }
>>
>> - drm_handle_vblank(vop->drm_dev, vop->pipe);
>> + if (active_irqs & FS_INTR) {
>> + drm_handle_vblank(vop->drm_dev, vop->pipe);
>> + active_irqs &= ~FS_INTR;
>> + ret = (vop->vsync_work_pending) ? IRQ_WAKE_THREAD : IRQ_HANDLED;
>> + }
>>
>> - return (vop->vsync_work_pending) ? IRQ_WAKE_THREAD : IRQ_HANDLED;
>> + /* Unhandled irqs are spurious. */
>> + if (active_irqs)
>> + DRM_ERROR("Unknown VOP IRQs: %#02x\n", active_irqs);
>> +
>> + return ret;
>> }
>>
>> static int vop_create_crtc(struct vop *vop)
>> @@ -1194,6 +1243,7 @@ static int vop_create_crtc(struct vop *vop)
>> goto err_cleanup_crtc;
>> }
>>
>> + init_completion(&vop->dsp_hold_completion);
>> crtc->port = port;
>> vop->pipe = drm_crtc_index(crtc);
>> rockchip_register_crtc_funcs(drm_dev, &private_crtc_funcs, vop->pipe);
>> --
>> 1.7.9.5
>>
>>
>
>
next prev parent reply other threads:[~2015-02-02 2:30 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-31 8:41 [PATCH] drm/rockchip: vop: power off until vop standby take effect Mark Yao
2015-01-31 8:41 ` Mark Yao
2015-01-31 12:49 ` Heiko Stübner
2015-01-31 12:49 ` Heiko Stübner
2015-02-02 0:45 ` Mark yao
2015-02-02 0:45 ` Mark yao
2015-02-02 2:07 ` Daniel Kurtz
2015-02-02 2:07 ` Daniel Kurtz
2015-02-02 2:30 ` Mark yao [this message]
2015-02-02 2:30 ` Mark yao
2015-02-02 7:53 ` Daniel Vetter
2015-02-02 7:53 ` Daniel Vetter
2015-02-04 3:38 ` Mark yao
2015-02-04 3:38 ` Mark yao
2015-02-04 3:48 ` Daniel Kurtz
2015-02-04 3:48 ` Daniel Kurtz
2015-02-04 3:56 ` Mark yao
2015-02-04 3:56 ` Mark yao
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=54CEE131.1020600@rock-chips.com \
--to=mark.yao@rock-chips.com \
--cc=djkurtz@chromium.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.