Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+37 -35
+37 -35
drivers/gpu/drm/nouveau/nv50_display.c
··· 2103 2103 2104 2104 NV_ATOMIC(drm, "%s atomic_check %d\n", crtc->name, asyh->state.active); 2105 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 2107 if (conns->crtc == crtc) { 2108 2108 asyc = nouveau_conn_atom(conns); 2109 2109 break; ··· 3905 3905 nv50_disp_atomic_commit_tail(struct drm_atomic_state *state) 3906 3906 { 3907 3907 struct drm_device *dev = state->dev; 3908 - struct drm_crtc_state *crtc_state; 3908 + struct drm_crtc_state *new_crtc_state; 3909 3909 struct drm_crtc *crtc; 3910 - struct drm_plane_state *plane_state; 3910 + struct drm_plane_state *new_plane_state; 3911 3911 struct drm_plane *plane; 3912 3912 struct nouveau_drm *drm = nouveau_drm(dev); 3913 3913 struct nv50_disp *disp = nv50_disp(dev); ··· 3926 3926 mutex_lock(&disp->mutex); 3927 3927 3928 3928 /* Disable head(s). */ 3929 - for_each_crtc_in_state(state, crtc, crtc_state, i) { 3930 - struct nv50_head_atom *asyh = nv50_head_atom(crtc->state); 3929 + for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) { 3930 + struct nv50_head_atom *asyh = nv50_head_atom(new_crtc_state); 3931 3931 struct nv50_head *head = nv50_head(crtc); 3932 3932 3933 3933 NV_ATOMIC(drm, "%s: clr %04x (set %04x)\n", crtc->name, ··· 3940 3940 } 3941 3941 3942 3942 /* Disable plane(s). */ 3943 - for_each_plane_in_state(state, plane, plane_state, i) { 3944 - struct nv50_wndw_atom *asyw = nv50_wndw_atom(plane->state); 3943 + for_each_new_plane_in_state(state, plane, new_plane_state, i) { 3944 + struct nv50_wndw_atom *asyw = nv50_wndw_atom(new_plane_state); 3945 3945 struct nv50_wndw *wndw = nv50_wndw(plane); 3946 3946 3947 3947 NV_ATOMIC(drm, "%s: clr %02x (set %02x)\n", plane->name, ··· 4006 4006 } 4007 4007 4008 4008 /* Update head(s). */ 4009 - for_each_crtc_in_state(state, crtc, crtc_state, i) { 4010 - struct nv50_head_atom *asyh = nv50_head_atom(crtc->state); 4009 + for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) { 4010 + struct nv50_head_atom *asyh = nv50_head_atom(new_crtc_state); 4011 4011 struct nv50_head *head = nv50_head(crtc); 4012 4012 4013 4013 NV_ATOMIC(drm, "%s: set %04x (clr %04x)\n", crtc->name, ··· 4019 4019 } 4020 4020 } 4021 4021 4022 - for_each_crtc_in_state(state, crtc, crtc_state, i) { 4023 - if (crtc->state->event) 4022 + for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) { 4023 + if (new_crtc_state->event) 4024 4024 drm_crtc_vblank_get(crtc); 4025 4025 } 4026 4026 4027 4027 /* Update plane(s). */ 4028 - for_each_plane_in_state(state, plane, plane_state, i) { 4029 - struct nv50_wndw_atom *asyw = nv50_wndw_atom(plane->state); 4028 + for_each_new_plane_in_state(state, plane, new_plane_state, i) { 4029 + struct nv50_wndw_atom *asyw = nv50_wndw_atom(new_plane_state); 4030 4030 struct nv50_wndw *wndw = nv50_wndw(plane); 4031 4031 4032 4032 NV_ATOMIC(drm, "%s: set %02x (clr %02x)\n", plane->name, ··· 4056 4056 mutex_unlock(&disp->mutex); 4057 4057 4058 4058 /* Wait for HW to signal completion. */ 4059 - for_each_plane_in_state(state, plane, plane_state, i) { 4060 - struct nv50_wndw_atom *asyw = nv50_wndw_atom(plane->state); 4059 + for_each_new_plane_in_state(state, plane, new_plane_state, i) { 4060 + struct nv50_wndw_atom *asyw = nv50_wndw_atom(new_plane_state); 4061 4061 struct nv50_wndw *wndw = nv50_wndw(plane); 4062 4062 int ret = nv50_wndw_wait_armed(wndw, asyw); 4063 4063 if (ret) 4064 4064 NV_ERROR(drm, "%s: timeout\n", plane->name); 4065 4065 } 4066 4066 4067 - for_each_crtc_in_state(state, crtc, crtc_state, i) { 4068 - if (crtc->state->event) { 4067 + for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) { 4068 + if (new_crtc_state->event) { 4069 4069 unsigned long flags; 4070 4070 /* Get correct count/ts if racing with vblank irq */ 4071 4071 drm_crtc_accurate_vblank_count(crtc); 4072 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 4074 spin_unlock_irqrestore(&crtc->dev->event_lock, flags); 4075 - crtc->state->event = NULL; 4075 + new_crtc_state->event = NULL; 4076 4076 drm_crtc_vblank_put(crtc); 4077 4077 } 4078 4078 } ··· 4097 4097 { 4098 4098 struct nouveau_drm *drm = nouveau_drm(dev); 4099 4099 struct nv50_disp *disp = nv50_disp(dev); 4100 - struct drm_plane_state *plane_state; 4100 + struct drm_plane_state *old_plane_state; 4101 4101 struct drm_plane *plane; 4102 4102 struct drm_crtc *crtc; 4103 4103 bool active = false; ··· 4127 4127 if (ret) 4128 4128 goto err_cleanup; 4129 4129 4130 - for_each_plane_in_state(state, plane, plane_state, i) { 4131 - struct nv50_wndw_atom *asyw = nv50_wndw_atom(plane_state); 4130 + for_each_old_plane_in_state(state, plane, old_plane_state, i) { 4131 + struct nv50_wndw_atom *asyw = nv50_wndw_atom(old_plane_state); 4132 4132 struct nv50_wndw *wndw = nv50_wndw(plane); 4133 + 4133 4134 if (asyw->set.image) { 4134 4135 asyw->ntfy.handle = wndw->dmac->sync.handle; 4135 4136 asyw->ntfy.offset = wndw->ntfy; ··· 4193 4192 4194 4193 static int 4195 4194 nv50_disp_outp_atomic_check_clr(struct nv50_atom *atom, 4196 - struct drm_connector *connector) 4195 + struct drm_connector_state *old_connector_state) 4197 4196 { 4198 - struct drm_encoder *encoder = connector->state->best_encoder; 4199 - struct drm_crtc_state *crtc_state; 4197 + struct drm_encoder *encoder = old_connector_state->best_encoder; 4198 + struct drm_crtc_state *old_crtc_state, *new_crtc_state; 4200 4199 struct drm_crtc *crtc; 4201 4200 struct nv50_outp_atom *outp; 4202 4201 4203 - if (!(crtc = connector->state->crtc)) 4202 + if (!(crtc = old_connector_state->crtc)) 4204 4203 return 0; 4205 4204 4206 - crtc_state = drm_atomic_get_existing_crtc_state(&atom->state, crtc); 4207 - if (crtc->state->active && drm_atomic_crtc_needs_modeset(crtc_state)) { 4205 + old_crtc_state = drm_atomic_get_old_crtc_state(&atom->state, crtc); 4206 + new_crtc_state = drm_atomic_get_new_crtc_state(&atom->state, crtc); 4207 + if (old_crtc_state->active && drm_atomic_crtc_needs_modeset(new_crtc_state)) { 4208 4208 outp = nv50_disp_outp_atomic_add(atom, encoder); 4209 4209 if (IS_ERR(outp)) 4210 4210 return PTR_ERR(outp); ··· 4226 4224 struct drm_connector_state *connector_state) 4227 4225 { 4228 4226 struct drm_encoder *encoder = connector_state->best_encoder; 4229 - struct drm_crtc_state *crtc_state; 4227 + struct drm_crtc_state *new_crtc_state; 4230 4228 struct drm_crtc *crtc; 4231 4229 struct nv50_outp_atom *outp; 4232 4230 4233 4231 if (!(crtc = connector_state->crtc)) 4234 4232 return 0; 4235 4233 4236 - crtc_state = drm_atomic_get_existing_crtc_state(&atom->state, crtc); 4237 - if (crtc_state->active && drm_atomic_crtc_needs_modeset(crtc_state)) { 4234 + new_crtc_state = drm_atomic_get_new_crtc_state(&atom->state, crtc); 4235 + if (new_crtc_state->active && drm_atomic_crtc_needs_modeset(new_crtc_state)) { 4238 4236 outp = nv50_disp_outp_atomic_add(atom, encoder); 4239 4237 if (IS_ERR(outp)) 4240 4238 return PTR_ERR(outp); ··· 4250 4248 nv50_disp_atomic_check(struct drm_device *dev, struct drm_atomic_state *state) 4251 4249 { 4252 4250 struct nv50_atom *atom = nv50_atom(state); 4253 - struct drm_connector_state *connector_state; 4251 + struct drm_connector_state *old_connector_state, *new_connector_state; 4254 4252 struct drm_connector *connector; 4255 4253 int ret, i; 4256 4254 ··· 4258 4256 if (ret) 4259 4257 return ret; 4260 4258 4261 - for_each_connector_in_state(state, connector, connector_state, i) { 4262 - ret = nv50_disp_outp_atomic_check_clr(atom, connector); 4259 + for_each_oldnew_connector_in_state(state, connector, old_connector_state, new_connector_state, i) { 4260 + ret = nv50_disp_outp_atomic_check_clr(atom, old_connector_state); 4263 4261 if (ret) 4264 4262 return ret; 4265 4263 4266 - ret = nv50_disp_outp_atomic_check_set(atom, connector_state); 4264 + ret = nv50_disp_outp_atomic_check_set(atom, new_connector_state); 4267 4265 if (ret) 4268 4266 return ret; 4269 4267 }