aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorMaarten Lankhorst <maarten.lankhorst@linux.intel.com>2017-07-19 10:39:19 -0400
committerMaarten Lankhorst <maarten.lankhorst@linux.intel.com>2017-08-01 05:08:46 -0400
commit3c847d6cdadb6d64f3cd93b9f6b7b9fb6dbed795 (patch)
treec704d2eca04905d8fb58551c607757b66c28015d /drivers/gpu
parent34d88237388bb6d7b8258e6ba4e71e4d1be32d02 (diff)
drm/nouveau: Convert nouveau to use new iterator macros, v2.
Use the new atomic iterator macros, the old ones are about to be removed. With the new macros, it's more easy to get old and new state so get them from the macros instead of from obj->state. Changes since v1: - Don't mix up old and new state. (danvet) - Rebase on top of interruptible swap_state changes. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Cc: Ben Skeggs <bskeggs@redhat.com> Cc: nouveau@lists.freedesktop.org Link: https://patchwork.freedesktop.org/patch/msgid/20170719143920.25685-7-maarten.lankhorst@linux.intel.com Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/nouveau/nv50_display.c72
1 files changed, 37 insertions, 35 deletions
diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c
index 747c99c1e474..7abfb561b00c 100644
--- a/drivers/gpu/drm/nouveau/nv50_display.c
+++ b/drivers/gpu/drm/nouveau/nv50_display.c
@@ -2103,7 +2103,7 @@ nv50_head_atomic_check(struct drm_crtc *crtc, struct drm_crtc_state *state)
2103 2103
2104 NV_ATOMIC(drm, "%s atomic_check %d\n", crtc->name, asyh->state.active); 2104 NV_ATOMIC(drm, "%s atomic_check %d\n", crtc->name, asyh->state.active);
2105 if (asyh->state.active) { 2105 if (asyh->state.active) {
2106 for_each_connector_in_state(asyh->state.state, conn, conns, i) { 2106 for_each_new_connector_in_state(asyh->state.state, conn, conns, i) {
2107 if (conns->crtc == crtc) { 2107 if (conns->crtc == crtc) {
2108 asyc = nouveau_conn_atom(conns); 2108 asyc = nouveau_conn_atom(conns);
2109 break; 2109 break;
@@ -3905,9 +3905,9 @@ static void
3905nv50_disp_atomic_commit_tail(struct drm_atomic_state *state) 3905nv50_disp_atomic_commit_tail(struct drm_atomic_state *state)
3906{ 3906{
3907 struct drm_device *dev = state->dev; 3907 struct drm_device *dev = state->dev;
3908 struct drm_crtc_state *crtc_state; 3908 struct drm_crtc_state *new_crtc_state;
3909 struct drm_crtc *crtc; 3909 struct drm_crtc *crtc;
3910 struct drm_plane_state *plane_state; 3910 struct drm_plane_state *new_plane_state;
3911 struct drm_plane *plane; 3911 struct drm_plane *plane;
3912 struct nouveau_drm *drm = nouveau_drm(dev); 3912 struct nouveau_drm *drm = nouveau_drm(dev);
3913 struct nv50_disp *disp = nv50_disp(dev); 3913 struct nv50_disp *disp = nv50_disp(dev);
@@ -3926,8 +3926,8 @@ nv50_disp_atomic_commit_tail(struct drm_atomic_state *state)
3926 mutex_lock(&disp->mutex); 3926 mutex_lock(&disp->mutex);
3927 3927
3928 /* Disable head(s). */ 3928 /* Disable head(s). */
3929 for_each_crtc_in_state(state, crtc, crtc_state, i) { 3929 for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
3930 struct nv50_head_atom *asyh = nv50_head_atom(crtc->state); 3930 struct nv50_head_atom *asyh = nv50_head_atom(new_crtc_state);
3931 struct nv50_head *head = nv50_head(crtc); 3931 struct nv50_head *head = nv50_head(crtc);
3932 3932
3933 NV_ATOMIC(drm, "%s: clr %04x (set %04x)\n", crtc->name, 3933 NV_ATOMIC(drm, "%s: clr %04x (set %04x)\n", crtc->name,
@@ -3940,8 +3940,8 @@ nv50_disp_atomic_commit_tail(struct drm_atomic_state *state)
3940 } 3940 }
3941 3941
3942 /* Disable plane(s). */ 3942 /* Disable plane(s). */
3943 for_each_plane_in_state(state, plane, plane_state, i) { 3943 for_each_new_plane_in_state(state, plane, new_plane_state, i) {
3944 struct nv50_wndw_atom *asyw = nv50_wndw_atom(plane->state); 3944 struct nv50_wndw_atom *asyw = nv50_wndw_atom(new_plane_state);
3945 struct nv50_wndw *wndw = nv50_wndw(plane); 3945 struct nv50_wndw *wndw = nv50_wndw(plane);
3946 3946
3947 NV_ATOMIC(drm, "%s: clr %02x (set %02x)\n", plane->name, 3947 NV_ATOMIC(drm, "%s: clr %02x (set %02x)\n", plane->name,
@@ -4006,8 +4006,8 @@ nv50_disp_atomic_commit_tail(struct drm_atomic_state *state)
4006 } 4006 }
4007 4007
4008 /* Update head(s). */ 4008 /* Update head(s). */
4009 for_each_crtc_in_state(state, crtc, crtc_state, i) { 4009 for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
4010 struct nv50_head_atom *asyh = nv50_head_atom(crtc->state); 4010 struct nv50_head_atom *asyh = nv50_head_atom(new_crtc_state);
4011 struct nv50_head *head = nv50_head(crtc); 4011 struct nv50_head *head = nv50_head(crtc);
4012 4012
4013 NV_ATOMIC(drm, "%s: set %04x (clr %04x)\n", crtc->name, 4013 NV_ATOMIC(drm, "%s: set %04x (clr %04x)\n", crtc->name,
@@ -4019,14 +4019,14 @@ nv50_disp_atomic_commit_tail(struct drm_atomic_state *state)
4019 } 4019 }
4020 } 4020 }
4021 4021
4022 for_each_crtc_in_state(state, crtc, crtc_state, i) { 4022 for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
4023 if (crtc->state->event) 4023 if (new_crtc_state->event)
4024 drm_crtc_vblank_get(crtc); 4024 drm_crtc_vblank_get(crtc);
4025 } 4025 }
4026 4026
4027 /* Update plane(s). */ 4027 /* Update plane(s). */
4028 for_each_plane_in_state(state, plane, plane_state, i) { 4028 for_each_new_plane_in_state(state, plane, new_plane_state, i) {
4029 struct nv50_wndw_atom *asyw = nv50_wndw_atom(plane->state); 4029 struct nv50_wndw_atom *asyw = nv50_wndw_atom(new_plane_state);
4030 struct nv50_wndw *wndw = nv50_wndw(plane); 4030 struct nv50_wndw *wndw = nv50_wndw(plane);
4031 4031
4032 NV_ATOMIC(drm, "%s: set %02x (clr %02x)\n", plane->name, 4032 NV_ATOMIC(drm, "%s: set %02x (clr %02x)\n", plane->name,
@@ -4056,23 +4056,23 @@ nv50_disp_atomic_commit_tail(struct drm_atomic_state *state)
4056 mutex_unlock(&disp->mutex); 4056 mutex_unlock(&disp->mutex);
4057 4057
4058 /* Wait for HW to signal completion. */ 4058 /* Wait for HW to signal completion. */
4059 for_each_plane_in_state(state, plane, plane_state, i) { 4059 for_each_new_plane_in_state(state, plane, new_plane_state, i) {
4060 struct nv50_wndw_atom *asyw = nv50_wndw_atom(plane->state); 4060 struct nv50_wndw_atom *asyw = nv50_wndw_atom(new_plane_state);
4061 struct nv50_wndw *wndw = nv50_wndw(plane); 4061 struct nv50_wndw *wndw = nv50_wndw(plane);
4062 int ret = nv50_wndw_wait_armed(wndw, asyw); 4062 int ret = nv50_wndw_wait_armed(wndw, asyw);
4063 if (ret) 4063 if (ret)
4064 NV_ERROR(drm, "%s: timeout\n", plane->name); 4064 NV_ERROR(drm, "%s: timeout\n", plane->name);
4065 } 4065 }
4066 4066
4067 for_each_crtc_in_state(state, crtc, crtc_state, i) { 4067 for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
4068 if (crtc->state->event) { 4068 if (new_crtc_state->event) {
4069 unsigned long flags; 4069 unsigned long flags;
4070 /* Get correct count/ts if racing with vblank irq */ 4070 /* Get correct count/ts if racing with vblank irq */
4071 drm_crtc_accurate_vblank_count(crtc); 4071 drm_crtc_accurate_vblank_count(crtc);
4072 spin_lock_irqsave(&crtc->dev->event_lock, flags); 4072 spin_lock_irqsave(&crtc->dev->event_lock, flags);
4073 drm_crtc_send_vblank_event(crtc, crtc->state->event); 4073 drm_crtc_send_vblank_event(crtc, new_crtc_state->event);
4074 spin_unlock_irqrestore(&crtc->dev->event_lock, flags); 4074 spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
4075 crtc->state->event = NULL; 4075 new_crtc_state->event = NULL;
4076 drm_crtc_vblank_put(crtc); 4076 drm_crtc_vblank_put(crtc);
4077 } 4077 }
4078 } 4078 }
@@ -4097,7 +4097,7 @@ nv50_disp_atomic_commit(struct drm_device *dev,
4097{ 4097{
4098 struct nouveau_drm *drm = nouveau_drm(dev); 4098 struct nouveau_drm *drm = nouveau_drm(dev);
4099 struct nv50_disp *disp = nv50_disp(dev); 4099 struct nv50_disp *disp = nv50_disp(dev);
4100 struct drm_plane_state *plane_state; 4100 struct drm_plane_state *old_plane_state;
4101 struct drm_plane *plane; 4101 struct drm_plane *plane;
4102 struct drm_crtc *crtc; 4102 struct drm_crtc *crtc;
4103 bool active = false; 4103 bool active = false;
@@ -4127,9 +4127,10 @@ nv50_disp_atomic_commit(struct drm_device *dev,
4127 if (ret) 4127 if (ret)
4128 goto err_cleanup; 4128 goto err_cleanup;
4129 4129
4130 for_each_plane_in_state(state, plane, plane_state, i) { 4130 for_each_old_plane_in_state(state, plane, old_plane_state, i) {
4131 struct nv50_wndw_atom *asyw = nv50_wndw_atom(plane_state); 4131 struct nv50_wndw_atom *asyw = nv50_wndw_atom(old_plane_state);
4132 struct nv50_wndw *wndw = nv50_wndw(plane); 4132 struct nv50_wndw *wndw = nv50_wndw(plane);
4133
4133 if (asyw->set.image) { 4134 if (asyw->set.image) {
4134 asyw->ntfy.handle = wndw->dmac->sync.handle; 4135 asyw->ntfy.handle = wndw->dmac->sync.handle;
4135 asyw->ntfy.offset = wndw->ntfy; 4136 asyw->ntfy.offset = wndw->ntfy;
@@ -4192,18 +4193,19 @@ nv50_disp_outp_atomic_add(struct nv50_atom *atom, struct drm_encoder *encoder)
4192 4193
4193static int 4194static int
4194nv50_disp_outp_atomic_check_clr(struct nv50_atom *atom, 4195nv50_disp_outp_atomic_check_clr(struct nv50_atom *atom,
4195 struct drm_connector *connector) 4196 struct drm_connector_state *old_connector_state)
4196{ 4197{
4197 struct drm_encoder *encoder = connector->state->best_encoder; 4198 struct drm_encoder *encoder = old_connector_state->best_encoder;
4198 struct drm_crtc_state *crtc_state; 4199 struct drm_crtc_state *old_crtc_state, *new_crtc_state;
4199 struct drm_crtc *crtc; 4200 struct drm_crtc *crtc;
4200 struct nv50_outp_atom *outp; 4201 struct nv50_outp_atom *outp;
4201 4202
4202 if (!(crtc = connector->state->crtc)) 4203 if (!(crtc = old_connector_state->crtc))
4203 return 0; 4204 return 0;
4204 4205
4205 crtc_state = drm_atomic_get_existing_crtc_state(&atom->state, crtc); 4206 old_crtc_state = drm_atomic_get_old_crtc_state(&atom->state, crtc);
4206 if (crtc->state->active && drm_atomic_crtc_needs_modeset(crtc_state)) { 4207 new_crtc_state = drm_atomic_get_new_crtc_state(&atom->state, crtc);
4208 if (old_crtc_state->active && drm_atomic_crtc_needs_modeset(new_crtc_state)) {
4207 outp = nv50_disp_outp_atomic_add(atom, encoder); 4209 outp = nv50_disp_outp_atomic_add(atom, encoder);
4208 if (IS_ERR(outp)) 4210 if (IS_ERR(outp))
4209 return PTR_ERR(outp); 4211 return PTR_ERR(outp);
@@ -4224,15 +4226,15 @@ nv50_disp_outp_atomic_check_set(struct nv50_atom *atom,
4224 struct drm_connector_state *connector_state) 4226 struct drm_connector_state *connector_state)
4225{ 4227{
4226 struct drm_encoder *encoder = connector_state->best_encoder; 4228 struct drm_encoder *encoder = connector_state->best_encoder;
4227 struct drm_crtc_state *crtc_state; 4229 struct drm_crtc_state *new_crtc_state;
4228 struct drm_crtc *crtc; 4230 struct drm_crtc *crtc;
4229 struct nv50_outp_atom *outp; 4231 struct nv50_outp_atom *outp;
4230 4232
4231 if (!(crtc = connector_state->crtc)) 4233 if (!(crtc = connector_state->crtc))
4232 return 0; 4234 return 0;
4233 4235
4234 crtc_state = drm_atomic_get_existing_crtc_state(&atom->state, crtc); 4236 new_crtc_state = drm_atomic_get_new_crtc_state(&atom->state, crtc);
4235 if (crtc_state->active && drm_atomic_crtc_needs_modeset(crtc_state)) { 4237 if (new_crtc_state->active && drm_atomic_crtc_needs_modeset(new_crtc_state)) {
4236 outp = nv50_disp_outp_atomic_add(atom, encoder); 4238 outp = nv50_disp_outp_atomic_add(atom, encoder);
4237 if (IS_ERR(outp)) 4239 if (IS_ERR(outp))
4238 return PTR_ERR(outp); 4240 return PTR_ERR(outp);
@@ -4248,7 +4250,7 @@ static int
4248nv50_disp_atomic_check(struct drm_device *dev, struct drm_atomic_state *state) 4250nv50_disp_atomic_check(struct drm_device *dev, struct drm_atomic_state *state)
4249{ 4251{
4250 struct nv50_atom *atom = nv50_atom(state); 4252 struct nv50_atom *atom = nv50_atom(state);
4251 struct drm_connector_state *connector_state; 4253 struct drm_connector_state *old_connector_state, *new_connector_state;
4252 struct drm_connector *connector; 4254 struct drm_connector *connector;
4253 int ret, i; 4255 int ret, i;
4254 4256
@@ -4256,12 +4258,12 @@ nv50_disp_atomic_check(struct drm_device *dev, struct drm_atomic_state *state)
4256 if (ret) 4258 if (ret)
4257 return ret; 4259 return ret;
4258 4260
4259 for_each_connector_in_state(state, connector, connector_state, i) { 4261 for_each_oldnew_connector_in_state(state, connector, old_connector_state, new_connector_state, i) {
4260 ret = nv50_disp_outp_atomic_check_clr(atom, connector); 4262 ret = nv50_disp_outp_atomic_check_clr(atom, old_connector_state);
4261 if (ret) 4263 if (ret)
4262 return ret; 4264 return ret;
4263 4265
4264 ret = nv50_disp_outp_atomic_check_set(atom, connector_state); 4266 ret = nv50_disp_outp_atomic_check_set(atom, new_connector_state);
4265 if (ret) 4267 if (ret)
4266 return ret; 4268 return ret;
4267 } 4269 }