aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2011-06-29 03:30:34 -0400
committerKeith Packard <keithp@keithp.com>2011-06-29 14:20:45 -0400
commitd70bed1947772f34d66ada3bd923bfc12ea2452b (patch)
treeba0c438e8f2a996bf504923ef2dcf296581ad59a /drivers/gpu
parent0d72c6fcb5cd215eeab824fac216ea42c5b574aa (diff)
drm/i915: Hold struct_mutex during i915_save_state/i915_restore_state
Lots of register access in these functions, some of which requires the struct mutex. These functions now hold the struct mutex across the calls to i915_save_display and i915_restore_display, and so the internal mutex calls in those functions have been removed. To ensure that no-one else was calling them (and hence violating the new required locking invarient), those functions have been made static. gen6_enable_rps locks the struct mutex, and so i915_restore_state unlocks the mutex around calls to that function. Reviewed-by: Ben Widawsky <ben@bwidawsk.net> Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h2
-rw-r--r--drivers/gpu/drm/i915/i915_suspend.c19
2 files changed, 13 insertions, 8 deletions
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index eddabf68e97a..1c8bfb1300d7 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -997,8 +997,6 @@ extern unsigned int i915_enable_fbc;
997 997
998extern int i915_suspend(struct drm_device *dev, pm_message_t state); 998extern int i915_suspend(struct drm_device *dev, pm_message_t state);
999extern int i915_resume(struct drm_device *dev); 999extern int i915_resume(struct drm_device *dev);
1000extern void i915_save_display(struct drm_device *dev);
1001extern void i915_restore_display(struct drm_device *dev);
1002extern int i915_master_create(struct drm_device *dev, struct drm_master *master); 1000extern int i915_master_create(struct drm_device *dev, struct drm_master *master);
1003extern void i915_master_destroy(struct drm_device *dev, struct drm_master *master); 1001extern void i915_master_destroy(struct drm_device *dev, struct drm_master *master);
1004 1002
diff --git a/drivers/gpu/drm/i915/i915_suspend.c b/drivers/gpu/drm/i915/i915_suspend.c
index e8152d23d5b6..5257cfc34c35 100644
--- a/drivers/gpu/drm/i915/i915_suspend.c
+++ b/drivers/gpu/drm/i915/i915_suspend.c
@@ -597,7 +597,7 @@ static void i915_restore_modeset_reg(struct drm_device *dev)
597 return; 597 return;
598} 598}
599 599
600void i915_save_display(struct drm_device *dev) 600static void i915_save_display(struct drm_device *dev)
601{ 601{
602 struct drm_i915_private *dev_priv = dev->dev_private; 602 struct drm_i915_private *dev_priv = dev->dev_private;
603 603
@@ -678,7 +678,6 @@ void i915_save_display(struct drm_device *dev)
678 } 678 }
679 679
680 /* VGA state */ 680 /* VGA state */
681 mutex_lock(&dev->struct_mutex);
682 dev_priv->saveVGA0 = I915_READ(VGA0); 681 dev_priv->saveVGA0 = I915_READ(VGA0);
683 dev_priv->saveVGA1 = I915_READ(VGA1); 682 dev_priv->saveVGA1 = I915_READ(VGA1);
684 dev_priv->saveVGA_PD = I915_READ(VGA_PD); 683 dev_priv->saveVGA_PD = I915_READ(VGA_PD);
@@ -688,10 +687,9 @@ void i915_save_display(struct drm_device *dev)
688 dev_priv->saveVGACNTRL = I915_READ(VGACNTRL); 687 dev_priv->saveVGACNTRL = I915_READ(VGACNTRL);
689 688
690 i915_save_vga(dev); 689 i915_save_vga(dev);
691 mutex_unlock(&dev->struct_mutex);
692} 690}
693 691
694void i915_restore_display(struct drm_device *dev) 692static void i915_restore_display(struct drm_device *dev)
695{ 693{
696 struct drm_i915_private *dev_priv = dev->dev_private; 694 struct drm_i915_private *dev_priv = dev->dev_private;
697 695
@@ -783,7 +781,6 @@ void i915_restore_display(struct drm_device *dev)
783 else 781 else
784 I915_WRITE(VGACNTRL, dev_priv->saveVGACNTRL); 782 I915_WRITE(VGACNTRL, dev_priv->saveVGACNTRL);
785 783
786 mutex_lock(&dev->struct_mutex);
787 I915_WRITE(VGA0, dev_priv->saveVGA0); 784 I915_WRITE(VGA0, dev_priv->saveVGA0);
788 I915_WRITE(VGA1, dev_priv->saveVGA1); 785 I915_WRITE(VGA1, dev_priv->saveVGA1);
789 I915_WRITE(VGA_PD, dev_priv->saveVGA_PD); 786 I915_WRITE(VGA_PD, dev_priv->saveVGA_PD);
@@ -791,7 +788,6 @@ void i915_restore_display(struct drm_device *dev)
791 udelay(150); 788 udelay(150);
792 789
793 i915_restore_vga(dev); 790 i915_restore_vga(dev);
794 mutex_unlock(&dev->struct_mutex);
795} 791}
796 792
797int i915_save_state(struct drm_device *dev) 793int i915_save_state(struct drm_device *dev)
@@ -801,6 +797,8 @@ int i915_save_state(struct drm_device *dev)
801 797
802 pci_read_config_byte(dev->pdev, LBB, &dev_priv->saveLBB); 798 pci_read_config_byte(dev->pdev, LBB, &dev_priv->saveLBB);
803 799
800 mutex_lock(&dev->struct_mutex);
801
804 /* Hardware status page */ 802 /* Hardware status page */
805 dev_priv->saveHWS = I915_READ(HWS_PGA); 803 dev_priv->saveHWS = I915_READ(HWS_PGA);
806 804
@@ -840,6 +838,8 @@ int i915_save_state(struct drm_device *dev)
840 for (i = 0; i < 3; i++) 838 for (i = 0; i < 3; i++)
841 dev_priv->saveSWF2[i] = I915_READ(SWF30 + (i << 2)); 839 dev_priv->saveSWF2[i] = I915_READ(SWF30 + (i << 2));
842 840
841 mutex_unlock(&dev->struct_mutex);
842
843 return 0; 843 return 0;
844} 844}
845 845
@@ -850,6 +850,8 @@ int i915_restore_state(struct drm_device *dev)
850 850
851 pci_write_config_byte(dev->pdev, LBB, dev_priv->saveLBB); 851 pci_write_config_byte(dev->pdev, LBB, dev_priv->saveLBB);
852 852
853 mutex_lock(&dev->struct_mutex);
854
853 /* Hardware status page */ 855 /* Hardware status page */
854 I915_WRITE(HWS_PGA, dev_priv->saveHWS); 856 I915_WRITE(HWS_PGA, dev_priv->saveHWS);
855 857
@@ -867,6 +869,7 @@ int i915_restore_state(struct drm_device *dev)
867 I915_WRITE(IER, dev_priv->saveIER); 869 I915_WRITE(IER, dev_priv->saveIER);
868 I915_WRITE(IMR, dev_priv->saveIMR); 870 I915_WRITE(IMR, dev_priv->saveIMR);
869 } 871 }
872 mutex_unlock(&dev->struct_mutex);
870 873
871 intel_init_clock_gating(dev); 874 intel_init_clock_gating(dev);
872 875
@@ -878,6 +881,8 @@ int i915_restore_state(struct drm_device *dev)
878 if (IS_GEN6(dev)) 881 if (IS_GEN6(dev))
879 gen6_enable_rps(dev_priv); 882 gen6_enable_rps(dev_priv);
880 883
884 mutex_lock(&dev->struct_mutex);
885
881 /* Cache mode state */ 886 /* Cache mode state */
882 I915_WRITE (CACHE_MODE_0, dev_priv->saveCACHE_MODE_0 | 0xffff0000); 887 I915_WRITE (CACHE_MODE_0, dev_priv->saveCACHE_MODE_0 | 0xffff0000);
883 888
@@ -891,6 +896,8 @@ int i915_restore_state(struct drm_device *dev)
891 for (i = 0; i < 3; i++) 896 for (i = 0; i < 3; i++)
892 I915_WRITE(SWF30 + (i << 2), dev_priv->saveSWF2[i]); 897 I915_WRITE(SWF30 + (i << 2), dev_priv->saveSWF2[i]);
893 898
899 mutex_unlock(&dev->struct_mutex);
900
894 intel_i2c_reset(dev); 901 intel_i2c_reset(dev);
895 902
896 return 0; 903 return 0;