Commit cec1b948 authored by Dave Airlie's avatar Dave Airlie

Merge tag 'imx-drm-fixes-2018-03-22' of git://git.pengutronix.de/git/pza/linux into drm-fixes

drm/imx: fixes for early vblank event issue, array underflow error

- fix an array underflow error by reordering the range check before the array
  subscript in ipu-prg.
- make some local functions static in ipuv3-plane.
- add a missng header for ipu_planes_assign_pre in ipuv3-plane.
- move arming of the vblank event from atomic_begin to atomic_flush, to avoid
  signalling atomic commit completion to userspace before plane atomic_update
  has finished, due to a race condition that is likely to be hit on i.MX6QP on
  PRE enabled channels.

* tag 'imx-drm-fixes-2018-03-22' of git://git.pengutronix.de/git/pza/linux:
  drm/imx: move arming of the vblank event to atomic_flush
  drm/imx: ipuv3-plane: Include "imx-drm.h" header file
  drm/imx: ipuv3-plane: Make functions static when possible
  gpu: ipu-v3: prg: avoid possible array underflow
parents 82269df3 6a055b92
...@@ -225,7 +225,11 @@ static void ipu_crtc_atomic_begin(struct drm_crtc *crtc, ...@@ -225,7 +225,11 @@ static void ipu_crtc_atomic_begin(struct drm_crtc *crtc,
struct drm_crtc_state *old_crtc_state) struct drm_crtc_state *old_crtc_state)
{ {
drm_crtc_vblank_on(crtc); drm_crtc_vblank_on(crtc);
}
static void ipu_crtc_atomic_flush(struct drm_crtc *crtc,
struct drm_crtc_state *old_crtc_state)
{
spin_lock_irq(&crtc->dev->event_lock); spin_lock_irq(&crtc->dev->event_lock);
if (crtc->state->event) { if (crtc->state->event) {
WARN_ON(drm_crtc_vblank_get(crtc)); WARN_ON(drm_crtc_vblank_get(crtc));
...@@ -293,6 +297,7 @@ static const struct drm_crtc_helper_funcs ipu_helper_funcs = { ...@@ -293,6 +297,7 @@ static const struct drm_crtc_helper_funcs ipu_helper_funcs = {
.mode_set_nofb = ipu_crtc_mode_set_nofb, .mode_set_nofb = ipu_crtc_mode_set_nofb,
.atomic_check = ipu_crtc_atomic_check, .atomic_check = ipu_crtc_atomic_check,
.atomic_begin = ipu_crtc_atomic_begin, .atomic_begin = ipu_crtc_atomic_begin,
.atomic_flush = ipu_crtc_atomic_flush,
.atomic_disable = ipu_crtc_atomic_disable, .atomic_disable = ipu_crtc_atomic_disable,
.atomic_enable = ipu_crtc_atomic_enable, .atomic_enable = ipu_crtc_atomic_enable,
}; };
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <drm/drm_plane_helper.h> #include <drm/drm_plane_helper.h>
#include "video/imx-ipu-v3.h" #include "video/imx-ipu-v3.h"
#include "imx-drm.h"
#include "ipuv3-plane.h" #include "ipuv3-plane.h"
struct ipu_plane_state { struct ipu_plane_state {
...@@ -272,7 +273,7 @@ static void ipu_plane_destroy(struct drm_plane *plane) ...@@ -272,7 +273,7 @@ static void ipu_plane_destroy(struct drm_plane *plane)
kfree(ipu_plane); kfree(ipu_plane);
} }
void ipu_plane_state_reset(struct drm_plane *plane) static void ipu_plane_state_reset(struct drm_plane *plane)
{ {
struct ipu_plane_state *ipu_state; struct ipu_plane_state *ipu_state;
...@@ -292,7 +293,8 @@ void ipu_plane_state_reset(struct drm_plane *plane) ...@@ -292,7 +293,8 @@ void ipu_plane_state_reset(struct drm_plane *plane)
plane->state = &ipu_state->base; plane->state = &ipu_state->base;
} }
struct drm_plane_state *ipu_plane_duplicate_state(struct drm_plane *plane) static struct drm_plane_state *
ipu_plane_duplicate_state(struct drm_plane *plane)
{ {
struct ipu_plane_state *state; struct ipu_plane_state *state;
...@@ -306,8 +308,8 @@ struct drm_plane_state *ipu_plane_duplicate_state(struct drm_plane *plane) ...@@ -306,8 +308,8 @@ struct drm_plane_state *ipu_plane_duplicate_state(struct drm_plane *plane)
return &state->base; return &state->base;
} }
void ipu_plane_destroy_state(struct drm_plane *plane, static void ipu_plane_destroy_state(struct drm_plane *plane,
struct drm_plane_state *state) struct drm_plane_state *state)
{ {
struct ipu_plane_state *ipu_state = to_ipu_plane_state(state); struct ipu_plane_state *ipu_state = to_ipu_plane_state(state);
......
...@@ -250,10 +250,14 @@ void ipu_prg_channel_disable(struct ipuv3_channel *ipu_chan) ...@@ -250,10 +250,14 @@ void ipu_prg_channel_disable(struct ipuv3_channel *ipu_chan)
{ {
int prg_chan = ipu_prg_ipu_to_prg_chan(ipu_chan->num); int prg_chan = ipu_prg_ipu_to_prg_chan(ipu_chan->num);
struct ipu_prg *prg = ipu_chan->ipu->prg_priv; struct ipu_prg *prg = ipu_chan->ipu->prg_priv;
struct ipu_prg_channel *chan = &prg->chan[prg_chan]; struct ipu_prg_channel *chan;
u32 val; u32 val;
if (!chan->enabled || prg_chan < 0) if (prg_chan < 0)
return;
chan = &prg->chan[prg_chan];
if (!chan->enabled)
return; return;
pm_runtime_get_sync(prg->dev); pm_runtime_get_sync(prg->dev);
...@@ -280,13 +284,15 @@ int ipu_prg_channel_configure(struct ipuv3_channel *ipu_chan, ...@@ -280,13 +284,15 @@ int ipu_prg_channel_configure(struct ipuv3_channel *ipu_chan,
{ {
int prg_chan = ipu_prg_ipu_to_prg_chan(ipu_chan->num); int prg_chan = ipu_prg_ipu_to_prg_chan(ipu_chan->num);
struct ipu_prg *prg = ipu_chan->ipu->prg_priv; struct ipu_prg *prg = ipu_chan->ipu->prg_priv;
struct ipu_prg_channel *chan = &prg->chan[prg_chan]; struct ipu_prg_channel *chan;
u32 val; u32 val;
int ret; int ret;
if (prg_chan < 0) if (prg_chan < 0)
return prg_chan; return prg_chan;
chan = &prg->chan[prg_chan];
if (chan->enabled) { if (chan->enabled) {
ipu_pre_update(prg->pres[chan->used_pre], *eba); ipu_pre_update(prg->pres[chan->used_pre], *eba);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment