diff mbox series

[v1,1/1] drm/mediatek: fixup crtc event null pointer issue

Message ID 20220314074239.28507-2-yongqiang.niu@mediatek.com (mailing list archive)
State New, archived
Headers show
Series [v1,1/1] drm/mediatek: fixup crtc event null pointer issue | expand

Commit Message

Yongqiang Niu March 14, 2022, 7:42 a.m. UTC
if crtc event is null pointer, do not send vblank event

Signed-off-by: Yongqiang Niu <yongqiang.niu@mediatek.com>
---
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Rex-BC Chen (陳柏辰) March 17, 2022, 12:49 p.m. UTC | #1
On Mon, 2022-03-14 at 15:42 +0800, Yongqiang Niu wrote:
> if crtc event is null pointer, do not send vblank event
> 
> Signed-off-by: Yongqiang Niu <yongqiang.niu@mediatek.com>
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> index d661edf7e0fe..265fed446628 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> @@ -92,6 +92,9 @@ static void mtk_drm_crtc_finish_page_flip(struct
> mtk_drm_crtc *mtk_crtc)
>  	struct drm_crtc *crtc = &mtk_crtc->base;
>  	unsigned long flags;
>  
> +	if (!mtk_crtc->event)
> +		return;
> +

Reviewed-by: Rex-BC Chen <rex-bc.chen@mediatek.com>

>  	spin_lock_irqsave(&crtc->dev->event_lock, flags);
>  	drm_crtc_send_vblank_event(crtc, mtk_crtc->event);
>  	drm_crtc_vblank_put(crtc);
CK Hu (胡俊光) March 28, 2022, 9:34 a.m. UTC | #2
Hi, Yongqiang:

On Mon, 2022-03-14 at 15:42 +0800, Yongqiang Niu wrote:
> if crtc event is null pointer, do not send vblank event

This is a bug-fix, so add a Fixes tag here.

> 
> Signed-off-by: Yongqiang Niu <yongqiang.niu@mediatek.com>
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> index d661edf7e0fe..265fed446628 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> @@ -92,6 +92,9 @@ static void mtk_drm_crtc_finish_page_flip(struct
> mtk_drm_crtc *mtk_crtc)
>  	struct drm_crtc *crtc = &mtk_crtc->base;
>  	unsigned long flags;
>  
> +	if (!mtk_crtc->event)
> +		return;
> +
>  	spin_lock_irqsave(&crtc->dev->event_lock, flags);
>  	drm_crtc_send_vblank_event(crtc, mtk_crtc->event);

I think pending_needs_vblank is used to protect this situation. It
seems that pending_needs_vblank should be protected by critical
section.

Regards,
CK

>  	drm_crtc_vblank_put(crtc);
Yongqiang Niu May 11, 2022, 10:08 a.m. UTC | #3
On Mon, 2022-03-28 at 17:34 +0800, CK Hu wrote:
> Hi, Yongqiang:
> 
> On Mon, 2022-03-14 at 15:42 +0800, Yongqiang Niu wrote:
> > if crtc event is null pointer, do not send vblank event
> 
> This is a bug-fix, so add a Fixes tag here.

Fixes tag will be added in next version.
> 
> > 
> > Signed-off-by: Yongqiang Niu <yongqiang.niu@mediatek.com>
> > ---
> >  drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > index d661edf7e0fe..265fed446628 100644
> > --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > @@ -92,6 +92,9 @@ static void mtk_drm_crtc_finish_page_flip(struct
> > mtk_drm_crtc *mtk_crtc)
> >  	struct drm_crtc *crtc = &mtk_crtc->base;
> >  	unsigned long flags;
> >  
> > +	if (!mtk_crtc->event)
> > +		return;
> > +
> >  	spin_lock_irqsave(&crtc->dev->event_lock, flags);
> >  	drm_crtc_send_vblank_event(crtc, mtk_crtc->event);
> 
> I think pending_needs_vblank is used to protect this situation. It
> seems that pending_needs_vblank should be protected by critical
> section.
> 
> Regards,
> CK
actually, in the NG case pending_needs_vblank is true, but crtc->event
is null.

> 
> >  	drm_crtc_vblank_put(crtc);
> 
>
CK Hu (胡俊光) May 12, 2022, 5:20 a.m. UTC | #4
Hi, Yongqiang:

On Wed, 2022-05-11 at 18:08 +0800, yongqiang.niu wrote:
> On Mon, 2022-03-28 at 17:34 +0800, CK Hu wrote:
> > Hi, Yongqiang:
> > 
> > On Mon, 2022-03-14 at 15:42 +0800, Yongqiang Niu wrote:
> > > if crtc event is null pointer, do not send vblank event
> > 
> > This is a bug-fix, so add a Fixes tag here.
> 
> Fixes tag will be added in next version.
> > 
> > > 
> > > Signed-off-by: Yongqiang Niu <yongqiang.niu@mediatek.com>
> > > ---
> > >  drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 3 +++
> > >  1 file changed, 3 insertions(+)
> > > 
> > > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > > b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > > index d661edf7e0fe..265fed446628 100644
> > > --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > > +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > > @@ -92,6 +92,9 @@ static void
> > > mtk_drm_crtc_finish_page_flip(struct
> > > mtk_drm_crtc *mtk_crtc)
> > >  	struct drm_crtc *crtc = &mtk_crtc->base;
> > >  	unsigned long flags;
> > >  
> > > +	if (!mtk_crtc->event)
> > > +		return;
> > > +
> > >  	spin_lock_irqsave(&crtc->dev->event_lock, flags);
> > >  	drm_crtc_send_vblank_event(crtc, mtk_crtc->event);
> > 
> > I think pending_needs_vblank is used to protect this situation. It
> > seems that pending_needs_vblank should be protected by critical
> > section.
> > 
> > Regards,
> > CK
> 
> actually, in the NG case pending_needs_vblank is true, but crtc-
> >event
> is null.

It looks like that other driver access an invalid address which store
mtk_crtc->event, so mediatek drm driver has no bug and we should fix
the bug from other driver. This work around does not fix bug but just
hide the bug. So try to fix this bug in other driver.

Regards,
CK

> 
> > 
> > >  	drm_crtc_vblank_put(crtc);
> > 
> > 
> 
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
index d661edf7e0fe..265fed446628 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
@@ -92,6 +92,9 @@  static void mtk_drm_crtc_finish_page_flip(struct mtk_drm_crtc *mtk_crtc)
 	struct drm_crtc *crtc = &mtk_crtc->base;
 	unsigned long flags;
 
+	if (!mtk_crtc->event)
+		return;
+
 	spin_lock_irqsave(&crtc->dev->event_lock, flags);
 	drm_crtc_send_vblank_event(crtc, mtk_crtc->event);
 	drm_crtc_vblank_put(crtc);