Commit 93f55972 authored by Philipp Zabel's avatar Philipp Zabel Committed by Dave Airlie

drm/crtc: only store the necessary data for set_config rollback

drm_crtc_helper_set_config only potentially touches connector->encoder
and encoder->crtc, so we only have to store those for all connectors
and encoders, respectively.
Suggested-by: default avatarDaniel Vetter <daniel@ffwll.ch>
Signed-off-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent fffc5f59
...@@ -528,11 +528,11 @@ drm_crtc_helper_disable(struct drm_crtc *crtc) ...@@ -528,11 +528,11 @@ drm_crtc_helper_disable(struct drm_crtc *crtc)
int drm_crtc_helper_set_config(struct drm_mode_set *set) int drm_crtc_helper_set_config(struct drm_mode_set *set)
{ {
struct drm_device *dev; struct drm_device *dev;
struct drm_crtc *new_crtc; struct drm_crtc **save_encoder_crtcs, *new_crtc;
struct drm_encoder *save_encoders, *new_encoder, *encoder; struct drm_encoder **save_connector_encoders, *new_encoder, *encoder;
bool mode_changed = false; /* if true do a full mode set */ bool mode_changed = false; /* if true do a full mode set */
bool fb_changed = false; /* if true and !mode_changed just do a flip */ bool fb_changed = false; /* if true and !mode_changed just do a flip */
struct drm_connector *save_connectors, *connector; struct drm_connector *connector;
int count = 0, ro, fail = 0; int count = 0, ro, fail = 0;
const struct drm_crtc_helper_funcs *crtc_funcs; const struct drm_crtc_helper_funcs *crtc_funcs;
struct drm_mode_set save_set; struct drm_mode_set save_set;
...@@ -574,15 +574,15 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set) ...@@ -574,15 +574,15 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
* Allocate space for the backup of all (non-pointer) encoder and * Allocate space for the backup of all (non-pointer) encoder and
* connector data. * connector data.
*/ */
save_encoders = kzalloc(dev->mode_config.num_encoder * save_encoder_crtcs = kzalloc(dev->mode_config.num_encoder *
sizeof(struct drm_encoder), GFP_KERNEL); sizeof(struct drm_crtc *), GFP_KERNEL);
if (!save_encoders) if (!save_encoder_crtcs)
return -ENOMEM; return -ENOMEM;
save_connectors = kzalloc(dev->mode_config.num_connector * save_connector_encoders = kzalloc(dev->mode_config.num_connector *
sizeof(struct drm_connector), GFP_KERNEL); sizeof(struct drm_encoder *), GFP_KERNEL);
if (!save_connectors) { if (!save_connector_encoders) {
kfree(save_encoders); kfree(save_encoder_crtcs);
return -ENOMEM; return -ENOMEM;
} }
...@@ -593,12 +593,12 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set) ...@@ -593,12 +593,12 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
*/ */
count = 0; count = 0;
drm_for_each_encoder(encoder, dev) { drm_for_each_encoder(encoder, dev) {
save_encoders[count++] = *encoder; save_encoder_crtcs[count++] = encoder->crtc;
} }
count = 0; count = 0;
drm_for_each_connector(connector, dev) { drm_for_each_connector(connector, dev) {
save_connectors[count++] = *connector; save_connector_encoders[count++] = connector->encoder;
} }
save_set.crtc = set->crtc; save_set.crtc = set->crtc;
...@@ -758,20 +758,20 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set) ...@@ -758,20 +758,20 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
} }
} }
kfree(save_connectors); kfree(save_connector_encoders);
kfree(save_encoders); kfree(save_encoder_crtcs);
return 0; return 0;
fail: fail:
/* Restore all previous data. */ /* Restore all previous data. */
count = 0; count = 0;
drm_for_each_encoder(encoder, dev) { drm_for_each_encoder(encoder, dev) {
*encoder = save_encoders[count++]; encoder->crtc = save_encoder_crtcs[count++];
} }
count = 0; count = 0;
drm_for_each_connector(connector, dev) { drm_for_each_connector(connector, dev) {
*connector = save_connectors[count++]; connector->encoder = save_connector_encoders[count++];
} }
/* after fail drop reference on all unbound connectors in set, let /* after fail drop reference on all unbound connectors in set, let
...@@ -789,8 +789,8 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set) ...@@ -789,8 +789,8 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
save_set.y, save_set.fb)) save_set.y, save_set.fb))
DRM_ERROR("failed to restore config after modeset failure\n"); DRM_ERROR("failed to restore config after modeset failure\n");
kfree(save_connectors); kfree(save_connector_encoders);
kfree(save_encoders); kfree(save_encoder_crtcs);
return ret; return ret;
} }
EXPORT_SYMBOL(drm_crtc_helper_set_config); EXPORT_SYMBOL(drm_crtc_helper_set_config);
......
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