Add encoder_mask to crtc_state, v2.
Subsystems (3)
Maarten Lankhorst
maintainercover Add encoder_mask to crtc_state, v2.
Another attempt at adding encoder_mask, with some behavioral fixes.
Maarten Lankhorst (5):
drm/core: Add drm_encoder_index.
drm/core: Add drm_for_each_encoder_mask, v2. drm/i915: Do not touch best_encoder for load detect. drm/atomic: Do not unset crtc when an encoder is stolen drm/atomic: Add encoder_mask to crtc_state, v2.
drivers/gpu/drm/drm_atomic_helper.c | 46 ++++++++++++++++++++++++++++++------ drivers/gpu/drm/drm_crtc.c | 23 ++++++++++++++++++ drivers/gpu/drm/i915/intel_display.c | 5 ++-- include/drm/drm_crtc.h | 14 +++++++++++ 4 files changed, 79 insertions(+), 9 deletions(-)
Signature · 6 lines
2.1.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Maarten Lankhorst
maintainerPATCH 1/5 drm/core: Add drm_encoder_index.
This is useful for adding encoder_mask in crtc_state.
--- drivers/gpu/drm/drm_crtc.c | 23 +++++++++++++++++++++++ include/drm/drm_crtc.h | 1 + 2 files changed, 24 insertions(+)
drivers/gpu/drm/drm_crtc.c +23 -0
@@ -1161,6 +1161,29 @@ out_unlock:EXPORT_SYMBOL (drm_encoder_init);/** +* drm_encoder_index - find the index of a registered encoder +* @encoder: encoder to find index for +* +* Given a registered encoder, return the index of that encoder within a DRM +* device's list of encoders. +*/ +unsigned int drm_encoder_index (struct drm_encoder *encoder) +{ +unsigned int index =0 ; +struct drm_encoder *tmp; + +drm_for_each_encoder (tmp, encoder->dev) { +if (tmp == encoder) +return index; + + index++; + } + +BUG (); +} +EXPORT_SYMBOL (drm_encoder_index); + +/** * drm_encoder_cleanup - cleans up an initialised encoder * @encoder: encoder to cleanup *
include/drm/drm_crtc.h +1 -0
@@ -2225,6 +2225,7 @@ int drm_encoder_init(struct drm_device *dev,struct drm_encoder *encoder, const struct drm_encoder_funcs *funcs, int encoder_type, const char *name, ...); +extern unsigned int drm_encoder_index (struct drm_encoder *encoder);/** * drm_encoder_crtc_ok - can a given crtc drive a given encoder?
Signature · 6 lines
2.1.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [Intel-gfx] [PATCH 1/5] drm/core: Add drm_encoder_index.
Hi Maarten,
2016-01-07 Maarten Lankhorst <[email protected]>:
Quoted 7 lines
This is useful for adding
encoder_maskincrtc_state.Signed-off-by Maarten Lankhorst <[email protected]>--- drivers/gpu/drm/drm_crtc.c | 23 +++++++++++++++++++++++ include/drm/drm_crtc.h | 1 + 2 files changed, 24 insertions(+)
Gustavo
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Maarten Lankhorst
maintainerPATCH 2/5 drm/core: Add drm_for_each_encoder_mask, v2.
In reply to Maarten LankhorstThis is similar to the other drm_for_each_*_mask functions.
Changes since v1:
- Use for_each_if
--- include/drm/drm_crtc.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
include/drm/drm_crtc.h +11 -0
@@ -2153,6 +2153,17 @@ struct drm_mode_config { list_for_each_entry((plane), &(dev)->mode_config.plane_list, head) \for_each_if ((plane_mask) & (1 <<drm_plane_index (plane))) +/** +* drm_for_each_encoder_mask - iterate over encoders specified by bitmask +* @encoder: the loop cursor +* @dev: the DRM device +* @encoder_mask: bitmask of encoder indices +* +* Iterate over all encoders specified by bitmask. + */ +#define drm_for_each_encoder_mask (encoder, dev, encoder_mask) \ + list_for_each_entry((encoder), &(dev)->mode_config.encoder_list, head) \ + for_each_if ((encoder_mask) & (1 << drm_encoder_index(encoder)))#define obj_to_crtc (x) container_of(x, struct drm_crtc, base)#define obj_to_connector (x) container_of(x, struct drm_connector, base)
Signature · 6 lines
2.1.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/5] drm/core: Add drm_for_each_encoder_mask, v2.
Hi Maarten,
2016-01-07 Maarten Lankhorst <[email protected]>:
Quoted 9 lines
This is similar to the other drm_for_each_*_mask functions.
Changes since v1:
- Usefor_each_ifSigned-off-by Maarten Lankhorst <[email protected]>--- include/drm/drm_crtc.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
Gustavo
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Maarten Lankhorst
maintainerPATCH 3/5 drm/i915: Do not touch best_encoder for load detect.
In reply to Maarten LankhorstThis should only be touched by drm_atomic_helper.
--- drivers/gpu/drm/i915/intel_display.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/i915/intel_display.c +0 -2
@@ -10549,7 +10549,6 @@ retry: } connector_state->crtc = crtc; - connector_state->best_encoder = &intel_encoder->base; crtc_state =intel_atomic_get_crtc_state (state, intel_crtc);if (IS_ERR (crtc_state)) {
@@ -10645,7 +10644,6 @@ void intel_release_load_detect_pipe(struct drm_connector *connector,if (IS_ERR (crtc_state)) goto fail; - connector_state->best_encoder =NULL ; connector_state->crtc =NULL ; crtc_state->base.enable = crtc_state->base.active = false;
Signature · 6 lines
2.1.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/5] drm/i915: Do not touch best_encoder for load detect.
Hi Maarten,
2016-01-07 Maarten Lankhorst <[email protected]>:
Quoted 6 lines
This should only be touched by
drm_atomic_helper.Signed-off-by Maarten Lankhorst <[email protected]>--- drivers/gpu/drm/i915/intel_display.c | 2 -- 1 file changed, 2 deletions(-)
Gustavo
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Maarten Lankhorst
maintainerPATCH 4/5 drm/atomic: Do not unset crtc when an encoder is stolen
In reply to Maarten LankhorstWhile we steal the encoder away from the connector the connector may be updated to use a different encoder.
Without this change if 2 connectors swap encoders one of them will end up without a crtc.
--- drivers/gpu/drm/drm_atomic_helper.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +0 -4
@@ -134,7 +134,6 @@ steal_encoder(struct drm_atomic_state *state,struct drm_crtc_state *crtc_state;struct drm_connector *connector;struct drm_connector_state *connector_state; -int ret;/* * We can only steal an encoder coming from a connector, which means we
@@ -165,9 +164,6 @@ steal_encoder(struct drm_atomic_state *state,if (IS_ERR (connector_state))return PTR_ERR (connector_state); - ret =drm_atomic_set_crtc_for_connector (connector_state,NULL ); -if (ret) -return ret; connector_state->best_encoder =NULL ; }
Signature · 6 lines
2.1.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 4/5] drm/atomic: Do not unset crtc when an encoder is stolen
Hi Maarten,
2016-01-07 Maarten Lankhorst <[email protected]>:
Quoted 10 lines
While we steal the encoder away from the connector the connector may be updated to use a different encoder.
Without this change if 2 connectors swap encoders one of them will end up without a crtc.
Signed-off-by Maarten Lankhorst <[email protected]>--- drivers/gpu/drm/drm_atomic_helper.c | 4 ---- 1 file changed, 4 deletions(-)
Gustavo
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Maarten Lankhorst
maintainerPATCH 5/5 drm/atomic: Add encoder_mask to crtc_state, v2.
In reply to Maarten LankhorstThis allows iteration over encoders using drm_for_each_encoder_mask without inspecting all connector_states, which requires connection_mutex.
Changes since v1:
- Add a set_best_encoder helper function and update encoder_mask inside it.
--- drivers/gpu/drm/drm_atomic_helper.c | 42 +++++++++++++++++++++++++++++++++--- drivers/gpu/drm/i915/intel_display.c | 3 +++ include/drm/drm_crtc.h | 2 ++ 3 files changed, 44 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +39 -3
@@ -125,6 +125,41 @@ get_current_crtc_for_encoder(struct drm_device *dev,return NULL ; } +static void +set_best_encoder (struct drm_atomic_state *state, +struct drm_connector_state *conn_state, +struct drm_encoder *encoder) +{ +struct drm_crtc_state *crtc_state; +struct drm_crtc *crtc; + +if (conn_state->best_encoder) { +/* Unset the encoder_mask in the old crtc state. */ + crtc = conn_state->connector->state->crtc; + +WARN_ON (!crtc); +if (crtc) { + crtc_state =drm_atomic_get_existing_crtc_state (state, crtc); + + crtc_state->encoder_mask &= + ~(1 <<drm_encoder_index (conn_state->best_encoder)); + } + } + +if (encoder) { + crtc = conn_state->crtc; +WARN_ON (!crtc); +if (crtc) { + crtc_state =drm_atomic_get_existing_crtc_state (state, crtc); + + crtc_state->encoder_mask |= +1 <<drm_encoder_index (encoder); + } + } + + conn_state->best_encoder = encoder; +} + static int steal_encoder(struct drm_atomic_state *state, struct drm_encoder *encoder,
@@ -164,7 +199,7 @@ steal_encoder(struct drm_atomic_state *state,if (IS_ERR (connector_state))return PTR_ERR (connector_state); - connector_state->best_encoder =NULL ; +set_best_encoder (state, connector_state,NULL ); }return 0 ;
@@ -212,7 +247,7 @@ update_connector_routing(struct drm_atomic_state *state, int conn_idx) connector->base.id, connector->name); - connector_state->best_encoder =NULL ; +set_best_encoder (state, connector_state,NULL );return 0 ; }
@@ -275,7 +310,8 @@ update_connector_routing(struct drm_atomic_state *state, int conn_idx)if (WARN_ON (!connector_state->crtc))return -EINVAL ; - connector_state->best_encoder = new_encoder; +set_best_encoder (state, connector_state, new_encoder); + idx =drm_crtc_index (connector_state->crtc); crtc_state = state->crtc_states[idx];
drivers/gpu/drm/i915/intel_display.c +3 -0
@@ -15604,6 +15604,7 @@ static void intel_sanitize_crtc(struct intel_crtc *crtc) crtc->base.state->active = crtc->active; crtc->base.enabled = crtc->active; crtc->base.state->connector_mask =0 ; + crtc->base.state->encoder_mask =0 ;/* Because we only establish the connector -> encoder -> * crtc links if something is active, this means the
@@ -15843,6 +15844,8 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)*/ encoder->base.crtc->state->connector_mask |=1 <<drm_connector_index (&connector->base); + encoder->base.crtc->state->encoder_mask |= +1 <<drm_encoder_index (&encoder->base); } }else {
include/drm/drm_crtc.h +2 -0
@@ -307,6 +307,7 @@ struct drm_plane_helper_funcs;* @connectors_changed: connectors to this crtc have been updated * @plane_mask: bitmask of (1 << drm_plane_index(plane)) of attached planes * @connector_mask: bitmask of (1 << drm_connector_index(connector)) of attached connectors +* @encoder_mask: bitmask of (1 << drm_encoder_index(encoder)) of attached encoders * @last_vblank_count: for helpers and drivers to capture the vblank of the * update to ensure framebuffer cleanup isn't done too early * @adjusted_mode: for use by helpers and drivers to compute adjusted mode timings
@@ -341,6 +342,7 @@ struct drm_crtc_state {u32 plane_mask;u32 connector_mask; +u32 encoder_mask;/* last_vblank_count: for vblank waits before cleanup */ u32 last_vblank_count;
Signature · 6 lines
2.1.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Maarten Lankhorst
maintainerRe: [PATCH 5/5] drm/atomic: Add encoder_mask to crtc_state, v2.
A diff to make this v3. Found when running this through IGT bat.
- Keeping an encoder but moving it to a different crtc resulted, in encoder_mask not being updated.
- Add some paranoia when best_encoder was already updated to a different encoder in steal_encoder. This could happen in theory.
- Relax the WARN_ON(!crtc) when resuming after resume and add an explanation what the WARN_ON is for.
---
drivers/gpu/drm/drm_atomic_helper.c +12 -1
@@ -137,7 +137,13 @@ set_best_encoder(struct drm_atomic_state *state,/* Unset the encoder_mask in the old crtc state. */ crtc = conn_state->connector->state->crtc; -WARN_ON (!crtc); +/* A NULL crtc is an error here because we should have +* duplicated a NULL best_encoder when crtc was NULL. +* As an exception restoring duplicated atomic state +* during resume is allowed, so don't warn when +* best_encoder is equal to encoder we intend to set. +*/ +WARN_ON (!crtc && encoder != conn_state->best_encoder);if (crtc) { crtc_state =drm_atomic_get_existing_crtc_state (state, crtc);
@@ -199,6 +205,9 @@ steal_encoder(struct drm_atomic_state *state,if (IS_ERR (connector_state))return PTR_ERR (connector_state); +if (connector_state->best_encoder != encoder) +continue ; +set_best_encoder (state, connector_state,NULL ); }
@@ -276,6 +285,8 @@ update_connector_routing(struct drm_atomic_state *state, int conn_idx) }if (new_encoder == connector_state->best_encoder) { +set_best_encoder (state, connector_state, new_encoder); + DRM_DEBUG_ATOMIC("[CONNECTOR:%d:%s] keeps [ENCODER:%d:%s], now on [CRTC:%d:%s]\n", connector->base.id, connector->name,
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Maarten Lankhorst
maintainerPATCH v3 5/5 drm/atomic: Add encoder_mask to crtc_state, v3.
In reply to Maarten LankhorstThis allows iteration over encoders without requiring connection_mutex.
Changes since v1:
- Add a set_best_encoder helper function and update encoder_mask inside it.
Changes since v2:
- Relax the WARN_ON(!crtc), with explanation.
- Call set_best_encoder when connector is moved between crtc's.
- Add some paranoia to steal_encoder to prevent accidentally setting best_encoder to NULL.
---
drivers/gpu/drm/drm_atomic_helper.c +50 -3
@@ -125,6 +125,47 @@ get_current_crtc_for_encoder(struct drm_device *dev,return NULL ; } +static void +set_best_encoder (struct drm_atomic_state *state, +struct drm_connector_state *conn_state, +struct drm_encoder *encoder) +{ +struct drm_crtc_state *crtc_state; +struct drm_crtc *crtc; + +if (conn_state->best_encoder) { +/* Unset the encoder_mask in the old crtc state. */ + crtc = conn_state->connector->state->crtc; + +/* A NULL crtc is an error here because we should have +* duplicated a NULL best_encoder when crtc was NULL. +* As an exception restoring duplicated atomic state +* during resume is allowed, so don't warn when +* best_encoder is equal to encoder we intend to set. +*/ +WARN_ON (!crtc && encoder != conn_state->best_encoder); +if (crtc) { + crtc_state =drm_atomic_get_existing_crtc_state (state, crtc); + + crtc_state->encoder_mask &= + ~(1 <<drm_encoder_index (conn_state->best_encoder)); + } + } + +if (encoder) { + crtc = conn_state->crtc; +WARN_ON (!crtc); +if (crtc) { + crtc_state =drm_atomic_get_existing_crtc_state (state, crtc); + + crtc_state->encoder_mask |= +1 <<drm_encoder_index (encoder); + } + } + + conn_state->best_encoder = encoder; +} + static int steal_encoder(struct drm_atomic_state *state, struct drm_encoder *encoder,
@@ -164,7 +205,10 @@ steal_encoder(struct drm_atomic_state *state,if (IS_ERR (connector_state))return PTR_ERR (connector_state); - connector_state->best_encoder =NULL ; +if (connector_state->best_encoder != encoder) +continue ; + +set_best_encoder (state, connector_state,NULL ); }return 0 ;
@@ -212,7 +256,7 @@ update_connector_routing(struct drm_atomic_state *state, int conn_idx) connector->base.id, connector->name); - connector_state->best_encoder =NULL ; +set_best_encoder (state, connector_state,NULL );return 0 ; }
@@ -241,6 +285,8 @@ update_connector_routing(struct drm_atomic_state *state, int conn_idx) }if (new_encoder == connector_state->best_encoder) { +set_best_encoder (state, connector_state, new_encoder); + DRM_DEBUG_ATOMIC("[CONNECTOR:%d:%s] keeps [ENCODER:%d:%s], now on [CRTC:%d:%s]\n", connector->base.id, connector->name,
@@ -275,7 +321,8 @@ update_connector_routing(struct drm_atomic_state *state, int conn_idx)if (WARN_ON (!connector_state->crtc))return -EINVAL ; - connector_state->best_encoder = new_encoder; +set_best_encoder (state, connector_state, new_encoder); + idx =drm_crtc_index (connector_state->crtc); crtc_state = state->crtc_states[idx];
drivers/gpu/drm/i915/intel_display.c +3 -0
@@ -15604,6 +15604,7 @@ static void intel_sanitize_crtc(struct intel_crtc *crtc) crtc->base.state->active = crtc->active; crtc->base.enabled = crtc->active; crtc->base.state->connector_mask =0 ; + crtc->base.state->encoder_mask =0 ;/* Because we only establish the connector -> encoder -> * crtc links if something is active, this means the
@@ -15843,6 +15844,8 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)*/ encoder->base.crtc->state->connector_mask |=1 <<drm_connector_index (&connector->base); + encoder->base.crtc->state->encoder_mask |= +1 <<drm_encoder_index (&encoder->base); } }else {
include/drm/drm_crtc.h +2 -0
@@ -307,6 +307,7 @@ struct drm_plane_helper_funcs;* @connectors_changed: connectors to this crtc have been updated * @plane_mask: bitmask of (1 << drm_plane_index(plane)) of attached planes * @connector_mask: bitmask of (1 << drm_connector_index(connector)) of attached connectors +* @encoder_mask: bitmask of (1 << drm_encoder_index(encoder)) of attached encoders * @last_vblank_count: for helpers and drivers to capture the vblank of the * update to ensure framebuffer cleanup isn't done too early * @adjusted_mode: for use by helpers and drivers to compute adjusted mode timings
@@ -341,6 +342,7 @@ struct drm_crtc_state {u32 plane_mask;u32 connector_mask; +u32 encoder_mask;/* last_vblank_count: for vblank waits before cleanup */ u32 last_vblank_count;
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v3 5/5] drm/atomic: Add encoder_mask to crtc_state, v3.
Hi Maarten,
2016-01-28 Maarten Lankhorst <[email protected]>:
Quoted 11 lines
This allows iteration over encoders without requiring
connection_mutex.Changes since v1:
- Add aset_best_encoderhelper function and updateencoder_maskinside it.
Changes since v2:
- Relax theWARN_ON(!crtc), with explanation.
- Callset_best_encoderwhen connector is moved between crtc's.
- Add some paranoia tosteal_encoderto prevent accidentally settingbest_encoderto NULL.
Quoted 1 line
Signed-off-by Maarten Lankhorst <[email protected]>
Gustavo
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 5/5] drm/atomic: Add encoder_mask to crtc_state, v3.
Quoted 15 lines · Gustavo Padovan
Hi Maarten,
2016-01-28 Maarten Lankhorst <[email protected]>:
Quoted 11 lines
This allows iteration over encoders without requiring
connection_mutex.Changes since v1:
- Add aset_best_encoderhelper function and updateencoder_maskinside it.
Changes since v2:
- Relax theWARN_ON(!crtc), with explanation.
- Callset_best_encoderwhen connector is moved between crtc's.
- Add some paranoia tosteal_encoderto prevent accidentally settingbest_encoderto NULL.
Quoted 3 lines
Quoted 1 line
Signed-off-by Maarten Lankhorst <[email protected]>Reviewed-by Gustavo Padovan <[email protected]>
All merged to drm-misc, thanks.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ warning: Fi.CI.BAT
In reply to Maarten Lankhorst== Summary ==
== Summary ==
Built on ff88655b3a5467bbc3be8c67d3e05ebf182557d3 drm-intel-nightly: 2016y-01m-11d-07h-30m-16s UTC integration manifest
Test gem_storedw_loop:
Subgroup basic-render:
dmesg-warn -> PASS (bdw-ultra)
dmesg-warn -> PASS (skl-i7k-2) UNSTABLE
Test kms_flip:
Subgroup basic-flip-vs-dpms:
dmesg-warn -> PASS (ilk-hp8440p)
Subgroup basic-flip-vs-modeset:
pass -> DMESG-WARN (ilk-hp8440p)
Test kms_pipe_crc_basic:
Subgroup read-crc-pipe-b:
dmesg-warn -> PASS (byt-nuc)bdw-ultra total:138 pass:132 dwarn:0 dfail:0 fail:0 skip:6 bsw-nuc-2 total:141 pass:114 dwarn:3 dfail:0 fail:0 skip:24 byt-nuc total:141 pass:119 dwarn:7 dfail:0 fail:0 skip:15 hsw-brixbox total:141 pass:134 dwarn:0 dfail:0 fail:0 skip:7 hsw-gt2 total:141 pass:137 dwarn:0 dfail:0 fail:0 skip:4 hsw-xps12 total:138 pass:133 dwarn:1 dfail:0 fail:0 skip:4 ilk-hp8440p total:141 pass:100 dwarn:4 dfail:0 fail:0 skip:37 skl-i5k-2 total:141 pass:132 dwarn:1 dfail:0 fail:0 skip:8 skl-i7k-2 total:141 pass:132 dwarn:1 dfail:0 fail:0 skip:8 snb-dellxps total:141 pass:122 dwarn:5 dfail:0 fail:0 skip:14 snb-x220t total:141 pass:122 dwarn:5 dfail:0 fail:1 skip:13
Results at /archive/results/CI_IGT_test/Patchwork_1110/
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx