aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Zabel <p.zabel@pengutronix.de>2016-06-02 13:27:52 -0400
committerDave Airlie <airlied@redhat.com>2016-06-14 20:47:54 -0400
commit93f55972bc0fef0e394bbed3d46dc06b9afd3d17 (patch)
tree7776d0ded35bbfe9b2d4ed30835337e23554f406
parentfffc5f59f2c68ca859c3f92b224393ed3adbe1ca (diff)
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: Daniel Vetter <daniel@ffwll.ch> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r--drivers/gpu/drm/drm_crtc_helper.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
index 1c4d6746f90c..26feb2f8453f 100644
--- a/drivers/gpu/drm/drm_crtc_helper.c
+++ b/drivers/gpu/drm/drm_crtc_helper.c
@@ -528,11 +528,11 @@ drm_crtc_helper_disable(struct drm_crtc *crtc)
528int drm_crtc_helper_set_config(struct drm_mode_set *set) 528int drm_crtc_helper_set_config(struct drm_mode_set *set)
529{ 529{
530 struct drm_device *dev; 530 struct drm_device *dev;
531 struct drm_crtc *new_crtc; 531 struct drm_crtc **save_encoder_crtcs, *new_crtc;
532 struct drm_encoder *save_encoders, *new_encoder, *encoder; 532 struct drm_encoder **save_connector_encoders, *new_encoder, *encoder;
533 bool mode_changed = false; /* if true do a full mode set */ 533 bool mode_changed = false; /* if true do a full mode set */
534 bool fb_changed = false; /* if true and !mode_changed just do a flip */ 534 bool fb_changed = false; /* if true and !mode_changed just do a flip */
535 struct drm_connector *save_connectors, *connector; 535 struct drm_connector *connector;
536 int count = 0, ro, fail = 0; 536 int count = 0, ro, fail = 0;
537 const struct drm_crtc_helper_funcs *crtc_funcs; 537 const struct drm_crtc_helper_funcs *crtc_funcs;
538 struct drm_mode_set save_set; 538 struct drm_mode_set save_set;
@@ -574,15 +574,15 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
574 * Allocate space for the backup of all (non-pointer) encoder and 574 * Allocate space for the backup of all (non-pointer) encoder and
575 * connector data. 575 * connector data.
576 */ 576 */
577 save_encoders = kzalloc(dev->mode_config.num_encoder * 577 save_encoder_crtcs = kzalloc(dev->mode_config.num_encoder *
578 sizeof(struct drm_encoder), GFP_KERNEL); 578 sizeof(struct drm_crtc *), GFP_KERNEL);
579 if (!save_encoders) 579 if (!save_encoder_crtcs)
580 return -ENOMEM; 580 return -ENOMEM;
581 581
582 save_connectors = kzalloc(dev->mode_config.num_connector * 582 save_connector_encoders = kzalloc(dev->mode_config.num_connector *
583 sizeof(struct drm_connector), GFP_KERNEL); 583 sizeof(struct drm_encoder *), GFP_KERNEL);
584 if (!save_connectors) { 584 if (!save_connector_encoders) {
585 kfree(save_encoders); 585 kfree(save_encoder_crtcs);
586 return -ENOMEM; 586 return -ENOMEM;
587 } 587 }
588 588
@@ -593,12 +593,12 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
593 */ 593 */
594 count = 0; 594 count = 0;
595 drm_for_each_encoder(encoder, dev) { 595 drm_for_each_encoder(encoder, dev) {
596 save_encoders[count++] = *encoder; 596 save_encoder_crtcs[count++] = encoder->crtc;
597 } 597 }
598 598
599 count = 0; 599 count = 0;
600 drm_for_each_connector(connector, dev) { 600 drm_for_each_connector(connector, dev) {
601 save_connectors[count++] = *connector; 601 save_connector_encoders[count++] = connector->encoder;
602 } 602 }
603 603
604 save_set.crtc = set->crtc; 604 save_set.crtc = set->crtc;
@@ -758,20 +758,20 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
758 } 758 }
759 } 759 }
760 760
761 kfree(save_connectors); 761 kfree(save_connector_encoders);
762 kfree(save_encoders); 762 kfree(save_encoder_crtcs);
763 return 0; 763 return 0;
764 764
765fail: 765fail:
766 /* Restore all previous data. */ 766 /* Restore all previous data. */
767 count = 0; 767 count = 0;
768 drm_for_each_encoder(encoder, dev) { 768 drm_for_each_encoder(encoder, dev) {
769 *encoder = save_encoders[count++]; 769 encoder->crtc = save_encoder_crtcs[count++];
770 } 770 }
771 771
772 count = 0; 772 count = 0;
773 drm_for_each_connector(connector, dev) { 773 drm_for_each_connector(connector, dev) {
774 *connector = save_connectors[count++]; 774 connector->encoder = save_connector_encoders[count++];
775 } 775 }
776 776
777 /* after fail drop reference on all unbound connectors in set, let 777 /* after fail drop reference on all unbound connectors in set, let
@@ -789,8 +789,8 @@ fail:
789 save_set.y, save_set.fb)) 789 save_set.y, save_set.fb))
790 DRM_ERROR("failed to restore config after modeset failure\n"); 790 DRM_ERROR("failed to restore config after modeset failure\n");
791 791
792 kfree(save_connectors); 792 kfree(save_connector_encoders);
793 kfree(save_encoders); 793 kfree(save_encoder_crtcs);
794 return ret; 794 return ret;
795} 795}
796EXPORT_SYMBOL(drm_crtc_helper_set_config); 796EXPORT_SYMBOL(drm_crtc_helper_set_config);