diff options
author | Dave Airlie <airlied@gmail.com> | 2013-08-07 04:09:03 -0400 |
---|---|---|
committer | Dave Airlie <airlied@gmail.com> | 2013-08-07 04:11:35 -0400 |
commit | 32c913e4369ce7bd1d16a9b6983f7b8975c13f5a (patch) | |
tree | da5868a2b7e7c068d4b733420330a15001786365 /drivers/gpu/drm/i915/i915_drv.c | |
parent | abf190351b49937335130970a99a0b4275402b5e (diff) | |
parent | cd234b0bfd5ab012e42274b24aae420fa1823d58 (diff) |
Merge tag 'drm-intel-next-2013-07-26-fixed' of git://people.freedesktop.org/~danvet/drm-intel into drm-next
Neat that QA (and Ben) keeps on humming along while I'm on vacation, so
you already get the next feature pull request:
- proper eLLC support for HSW from Ben
- more interrupt refactoring
- add w/a tags where we implement them already (Damien)
- hangcheck fixes (Chris) + hangcheck stats (Mika)
- flesh out the new vm structs for ppgtt and ggtt (Ben)
- PSR for Haswell, still disabled by default (Rodrigo et al.)
- pc8+ refclock sequence code from Paulo
- more interrupt refactoring from Paulo, unifying ilk/snb with the ivb/hsw
interrupt code
- full solution for the Haswell concurrent reg access issues (Chris)
- fix racy object accounting, used by some new leak tests
- fix sync polarity settings on ch7xxx dvo encoder
- random bits&pieces, little fixes and better debug output all over
[airlied: fix conflict with drm_mm cleanups]
* tag 'drm-intel-next-2013-07-26-fixed' of git://people.freedesktop.org/~danvet/drm-intel: (289 commits)
drm/i915: Do not dereference NULL crtc or fb until after checking
drm/i915: fix pnv display core clock readout out
drm/i915: Replace open-coded offset_in_page()
drm/i915: Retry DP aux_ch communications with a different clock after failure
drm/i915: Add messages useful for HPD storm detection debugging (v2)
drm/i915: dvo_ch7xxx: fix vsync polarity setting
drm/i915: fix the racy object accounting
drm/i915: Convert the register access tracepoint to be conditional
drm/i915: Squash gen lookup through multiple indirections inside GT access
drm/i915: Use the common register access functions for NOTRACE variants
drm/i915: Use a private interface for register access within GT
drm/i915: Colocate all GT access routines in the same file
drm/i915: fix reference counting in i915_gem_create
drm/i915: Use Graphics Base of Stolen Memory on all gen3+
drm/i915: disable stolen mem for OVERLAY_NEEDS_PHYSICAL
drm/i915: add functions to disable and restore LCPLL
drm/i915: disable CLKOUT_DP when it's not needed
drm/i915: extend lpt_enable_clkout_dp
drm/i915: fix up error cleanup in i915_gem_object_bind_to_gtt
drm/i915: Add some debug breadcrumbs to connector detection
...
Diffstat (limited to 'drivers/gpu/drm/i915/i915_drv.c')
-rw-r--r-- | drivers/gpu/drm/i915/i915_drv.c | 277 |
1 files changed, 11 insertions, 266 deletions
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c index cca12db6dbb7..13457e3e9cad 100644 --- a/drivers/gpu/drm/i915/i915_drv.c +++ b/drivers/gpu/drm/i915/i915_drv.c | |||
@@ -118,6 +118,10 @@ module_param_named(i915_enable_ppgtt, i915_enable_ppgtt, int, 0600); | |||
118 | MODULE_PARM_DESC(i915_enable_ppgtt, | 118 | MODULE_PARM_DESC(i915_enable_ppgtt, |
119 | "Enable PPGTT (default: true)"); | 119 | "Enable PPGTT (default: true)"); |
120 | 120 | ||
121 | int i915_enable_psr __read_mostly = 0; | ||
122 | module_param_named(enable_psr, i915_enable_psr, int, 0600); | ||
123 | MODULE_PARM_DESC(enable_psr, "Enable PSR (default: false)"); | ||
124 | |||
121 | unsigned int i915_preliminary_hw_support __read_mostly = 0; | 125 | unsigned int i915_preliminary_hw_support __read_mostly = 0; |
122 | module_param_named(preliminary_hw_support, i915_preliminary_hw_support, int, 0600); | 126 | module_param_named(preliminary_hw_support, i915_preliminary_hw_support, int, 0600); |
123 | MODULE_PARM_DESC(preliminary_hw_support, | 127 | MODULE_PARM_DESC(preliminary_hw_support, |
@@ -137,6 +141,11 @@ module_param_named(fastboot, i915_fastboot, bool, 0600); | |||
137 | MODULE_PARM_DESC(fastboot, "Try to skip unnecessary mode sets at boot time " | 141 | MODULE_PARM_DESC(fastboot, "Try to skip unnecessary mode sets at boot time " |
138 | "(default: false)"); | 142 | "(default: false)"); |
139 | 143 | ||
144 | bool i915_prefault_disable __read_mostly; | ||
145 | module_param_named(prefault_disable, i915_prefault_disable, bool, 0600); | ||
146 | MODULE_PARM_DESC(prefault_disable, | ||
147 | "Disable page prefaulting for pread/pwrite/reloc (default:false). For developers only."); | ||
148 | |||
140 | static struct drm_driver driver; | 149 | static struct drm_driver driver; |
141 | extern int intel_agp_enabled; | 150 | extern int intel_agp_enabled; |
142 | 151 | ||
@@ -714,7 +723,7 @@ static int i915_drm_thaw(struct drm_device *dev) | |||
714 | { | 723 | { |
715 | int error = 0; | 724 | int error = 0; |
716 | 725 | ||
717 | intel_gt_reset(dev); | 726 | intel_uncore_sanitize(dev); |
718 | 727 | ||
719 | if (drm_core_check_feature(dev, DRIVER_MODESET)) { | 728 | if (drm_core_check_feature(dev, DRIVER_MODESET)) { |
720 | mutex_lock(&dev->struct_mutex); | 729 | mutex_lock(&dev->struct_mutex); |
@@ -740,7 +749,7 @@ int i915_resume(struct drm_device *dev) | |||
740 | 749 | ||
741 | pci_set_master(dev->pdev); | 750 | pci_set_master(dev->pdev); |
742 | 751 | ||
743 | intel_gt_reset(dev); | 752 | intel_uncore_sanitize(dev); |
744 | 753 | ||
745 | /* | 754 | /* |
746 | * Platforms with opregion should have sane BIOS, older ones (gen3 and | 755 | * Platforms with opregion should have sane BIOS, older ones (gen3 and |
@@ -761,140 +770,6 @@ int i915_resume(struct drm_device *dev) | |||
761 | return 0; | 770 | return 0; |
762 | } | 771 | } |
763 | 772 | ||
764 | static int i8xx_do_reset(struct drm_device *dev) | ||
765 | { | ||
766 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
767 | |||
768 | if (IS_I85X(dev)) | ||
769 | return -ENODEV; | ||
770 | |||
771 | I915_WRITE(D_STATE, I915_READ(D_STATE) | DSTATE_GFX_RESET_I830); | ||
772 | POSTING_READ(D_STATE); | ||
773 | |||
774 | if (IS_I830(dev) || IS_845G(dev)) { | ||
775 | I915_WRITE(DEBUG_RESET_I830, | ||
776 | DEBUG_RESET_DISPLAY | | ||
777 | DEBUG_RESET_RENDER | | ||
778 | DEBUG_RESET_FULL); | ||
779 | POSTING_READ(DEBUG_RESET_I830); | ||
780 | msleep(1); | ||
781 | |||
782 | I915_WRITE(DEBUG_RESET_I830, 0); | ||
783 | POSTING_READ(DEBUG_RESET_I830); | ||
784 | } | ||
785 | |||
786 | msleep(1); | ||
787 | |||
788 | I915_WRITE(D_STATE, I915_READ(D_STATE) & ~DSTATE_GFX_RESET_I830); | ||
789 | POSTING_READ(D_STATE); | ||
790 | |||
791 | return 0; | ||
792 | } | ||
793 | |||
794 | static int i965_reset_complete(struct drm_device *dev) | ||
795 | { | ||
796 | u8 gdrst; | ||
797 | pci_read_config_byte(dev->pdev, I965_GDRST, &gdrst); | ||
798 | return (gdrst & GRDOM_RESET_ENABLE) == 0; | ||
799 | } | ||
800 | |||
801 | static int i965_do_reset(struct drm_device *dev) | ||
802 | { | ||
803 | int ret; | ||
804 | |||
805 | /* | ||
806 | * Set the domains we want to reset (GRDOM/bits 2 and 3) as | ||
807 | * well as the reset bit (GR/bit 0). Setting the GR bit | ||
808 | * triggers the reset; when done, the hardware will clear it. | ||
809 | */ | ||
810 | pci_write_config_byte(dev->pdev, I965_GDRST, | ||
811 | GRDOM_RENDER | GRDOM_RESET_ENABLE); | ||
812 | ret = wait_for(i965_reset_complete(dev), 500); | ||
813 | if (ret) | ||
814 | return ret; | ||
815 | |||
816 | /* We can't reset render&media without also resetting display ... */ | ||
817 | pci_write_config_byte(dev->pdev, I965_GDRST, | ||
818 | GRDOM_MEDIA | GRDOM_RESET_ENABLE); | ||
819 | |||
820 | ret = wait_for(i965_reset_complete(dev), 500); | ||
821 | if (ret) | ||
822 | return ret; | ||
823 | |||
824 | pci_write_config_byte(dev->pdev, I965_GDRST, 0); | ||
825 | |||
826 | return 0; | ||
827 | } | ||
828 | |||
829 | static int ironlake_do_reset(struct drm_device *dev) | ||
830 | { | ||
831 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
832 | u32 gdrst; | ||
833 | int ret; | ||
834 | |||
835 | gdrst = I915_READ(MCHBAR_MIRROR_BASE + ILK_GDSR); | ||
836 | gdrst &= ~GRDOM_MASK; | ||
837 | I915_WRITE(MCHBAR_MIRROR_BASE + ILK_GDSR, | ||
838 | gdrst | GRDOM_RENDER | GRDOM_RESET_ENABLE); | ||
839 | ret = wait_for(I915_READ(MCHBAR_MIRROR_BASE + ILK_GDSR) & 0x1, 500); | ||
840 | if (ret) | ||
841 | return ret; | ||
842 | |||
843 | /* We can't reset render&media without also resetting display ... */ | ||
844 | gdrst = I915_READ(MCHBAR_MIRROR_BASE + ILK_GDSR); | ||
845 | gdrst &= ~GRDOM_MASK; | ||
846 | I915_WRITE(MCHBAR_MIRROR_BASE + ILK_GDSR, | ||
847 | gdrst | GRDOM_MEDIA | GRDOM_RESET_ENABLE); | ||
848 | return wait_for(I915_READ(MCHBAR_MIRROR_BASE + ILK_GDSR) & 0x1, 500); | ||
849 | } | ||
850 | |||
851 | static int gen6_do_reset(struct drm_device *dev) | ||
852 | { | ||
853 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
854 | int ret; | ||
855 | unsigned long irqflags; | ||
856 | |||
857 | /* Hold gt_lock across reset to prevent any register access | ||
858 | * with forcewake not set correctly | ||
859 | */ | ||
860 | spin_lock_irqsave(&dev_priv->gt_lock, irqflags); | ||
861 | |||
862 | /* Reset the chip */ | ||
863 | |||
864 | /* GEN6_GDRST is not in the gt power well, no need to check | ||
865 | * for fifo space for the write or forcewake the chip for | ||
866 | * the read | ||
867 | */ | ||
868 | I915_WRITE_NOTRACE(GEN6_GDRST, GEN6_GRDOM_FULL); | ||
869 | |||
870 | /* Spin waiting for the device to ack the reset request */ | ||
871 | ret = wait_for((I915_READ_NOTRACE(GEN6_GDRST) & GEN6_GRDOM_FULL) == 0, 500); | ||
872 | |||
873 | /* If reset with a user forcewake, try to restore, otherwise turn it off */ | ||
874 | if (dev_priv->forcewake_count) | ||
875 | dev_priv->gt.force_wake_get(dev_priv); | ||
876 | else | ||
877 | dev_priv->gt.force_wake_put(dev_priv); | ||
878 | |||
879 | /* Restore fifo count */ | ||
880 | dev_priv->gt_fifo_count = I915_READ_NOTRACE(GT_FIFO_FREE_ENTRIES); | ||
881 | |||
882 | spin_unlock_irqrestore(&dev_priv->gt_lock, irqflags); | ||
883 | return ret; | ||
884 | } | ||
885 | |||
886 | int intel_gpu_reset(struct drm_device *dev) | ||
887 | { | ||
888 | switch (INTEL_INFO(dev)->gen) { | ||
889 | case 7: | ||
890 | case 6: return gen6_do_reset(dev); | ||
891 | case 5: return ironlake_do_reset(dev); | ||
892 | case 4: return i965_do_reset(dev); | ||
893 | case 2: return i8xx_do_reset(dev); | ||
894 | default: return -ENODEV; | ||
895 | } | ||
896 | } | ||
897 | |||
898 | /** | 773 | /** |
899 | * i915_reset - reset chip after a hang | 774 | * i915_reset - reset chip after a hang |
900 | * @dev: drm device to reset | 775 | * @dev: drm device to reset |
@@ -1224,133 +1099,3 @@ module_exit(i915_exit); | |||
1224 | MODULE_AUTHOR(DRIVER_AUTHOR); | 1099 | MODULE_AUTHOR(DRIVER_AUTHOR); |
1225 | MODULE_DESCRIPTION(DRIVER_DESC); | 1100 | MODULE_DESCRIPTION(DRIVER_DESC); |
1226 | MODULE_LICENSE("GPL and additional rights"); | 1101 | MODULE_LICENSE("GPL and additional rights"); |
1227 | |||
1228 | /* We give fast paths for the really cool registers */ | ||
1229 | #define NEEDS_FORCE_WAKE(dev_priv, reg) \ | ||
1230 | ((HAS_FORCE_WAKE((dev_priv)->dev)) && \ | ||
1231 | ((reg) < 0x40000) && \ | ||
1232 | ((reg) != FORCEWAKE)) | ||
1233 | static void | ||
1234 | ilk_dummy_write(struct drm_i915_private *dev_priv) | ||
1235 | { | ||
1236 | /* WaIssueDummyWriteToWakeupFromRC6:ilk Issue a dummy write to wake up | ||
1237 | * the chip from rc6 before touching it for real. MI_MODE is masked, | ||
1238 | * hence harmless to write 0 into. */ | ||
1239 | I915_WRITE_NOTRACE(MI_MODE, 0); | ||
1240 | } | ||
1241 | |||
1242 | static void | ||
1243 | hsw_unclaimed_reg_clear(struct drm_i915_private *dev_priv, u32 reg) | ||
1244 | { | ||
1245 | if (HAS_FPGA_DBG_UNCLAIMED(dev_priv->dev) && | ||
1246 | (I915_READ_NOTRACE(FPGA_DBG) & FPGA_DBG_RM_NOCLAIM)) { | ||
1247 | DRM_ERROR("Unknown unclaimed register before writing to %x\n", | ||
1248 | reg); | ||
1249 | I915_WRITE_NOTRACE(FPGA_DBG, FPGA_DBG_RM_NOCLAIM); | ||
1250 | } | ||
1251 | } | ||
1252 | |||
1253 | static void | ||
1254 | hsw_unclaimed_reg_check(struct drm_i915_private *dev_priv, u32 reg) | ||
1255 | { | ||
1256 | if (HAS_FPGA_DBG_UNCLAIMED(dev_priv->dev) && | ||
1257 | (I915_READ_NOTRACE(FPGA_DBG) & FPGA_DBG_RM_NOCLAIM)) { | ||
1258 | DRM_ERROR("Unclaimed write to %x\n", reg); | ||
1259 | I915_WRITE_NOTRACE(FPGA_DBG, FPGA_DBG_RM_NOCLAIM); | ||
1260 | } | ||
1261 | } | ||
1262 | |||
1263 | #define __i915_read(x, y) \ | ||
1264 | u##x i915_read##x(struct drm_i915_private *dev_priv, u32 reg) { \ | ||
1265 | u##x val = 0; \ | ||
1266 | if (IS_GEN5(dev_priv->dev)) \ | ||
1267 | ilk_dummy_write(dev_priv); \ | ||
1268 | if (NEEDS_FORCE_WAKE((dev_priv), (reg))) { \ | ||
1269 | unsigned long irqflags; \ | ||
1270 | spin_lock_irqsave(&dev_priv->gt_lock, irqflags); \ | ||
1271 | if (dev_priv->forcewake_count == 0) \ | ||
1272 | dev_priv->gt.force_wake_get(dev_priv); \ | ||
1273 | val = read##y(dev_priv->regs + reg); \ | ||
1274 | if (dev_priv->forcewake_count == 0) \ | ||
1275 | dev_priv->gt.force_wake_put(dev_priv); \ | ||
1276 | spin_unlock_irqrestore(&dev_priv->gt_lock, irqflags); \ | ||
1277 | } else { \ | ||
1278 | val = read##y(dev_priv->regs + reg); \ | ||
1279 | } \ | ||
1280 | trace_i915_reg_rw(false, reg, val, sizeof(val)); \ | ||
1281 | return val; \ | ||
1282 | } | ||
1283 | |||
1284 | __i915_read(8, b) | ||
1285 | __i915_read(16, w) | ||
1286 | __i915_read(32, l) | ||
1287 | __i915_read(64, q) | ||
1288 | #undef __i915_read | ||
1289 | |||
1290 | #define __i915_write(x, y) \ | ||
1291 | void i915_write##x(struct drm_i915_private *dev_priv, u32 reg, u##x val) { \ | ||
1292 | u32 __fifo_ret = 0; \ | ||
1293 | trace_i915_reg_rw(true, reg, val, sizeof(val)); \ | ||
1294 | if (NEEDS_FORCE_WAKE((dev_priv), (reg))) { \ | ||
1295 | __fifo_ret = __gen6_gt_wait_for_fifo(dev_priv); \ | ||
1296 | } \ | ||
1297 | if (IS_GEN5(dev_priv->dev)) \ | ||
1298 | ilk_dummy_write(dev_priv); \ | ||
1299 | hsw_unclaimed_reg_clear(dev_priv, reg); \ | ||
1300 | write##y(val, dev_priv->regs + reg); \ | ||
1301 | if (unlikely(__fifo_ret)) { \ | ||
1302 | gen6_gt_check_fifodbg(dev_priv); \ | ||
1303 | } \ | ||
1304 | hsw_unclaimed_reg_check(dev_priv, reg); \ | ||
1305 | } | ||
1306 | __i915_write(8, b) | ||
1307 | __i915_write(16, w) | ||
1308 | __i915_write(32, l) | ||
1309 | __i915_write(64, q) | ||
1310 | #undef __i915_write | ||
1311 | |||
1312 | static const struct register_whitelist { | ||
1313 | uint64_t offset; | ||
1314 | uint32_t size; | ||
1315 | uint32_t gen_bitmask; /* support gens, 0x10 for 4, 0x30 for 4 and 5, etc. */ | ||
1316 | } whitelist[] = { | ||
1317 | { RING_TIMESTAMP(RENDER_RING_BASE), 8, 0xF0 }, | ||
1318 | }; | ||
1319 | |||
1320 | int i915_reg_read_ioctl(struct drm_device *dev, | ||
1321 | void *data, struct drm_file *file) | ||
1322 | { | ||
1323 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
1324 | struct drm_i915_reg_read *reg = data; | ||
1325 | struct register_whitelist const *entry = whitelist; | ||
1326 | int i; | ||
1327 | |||
1328 | for (i = 0; i < ARRAY_SIZE(whitelist); i++, entry++) { | ||
1329 | if (entry->offset == reg->offset && | ||
1330 | (1 << INTEL_INFO(dev)->gen & entry->gen_bitmask)) | ||
1331 | break; | ||
1332 | } | ||
1333 | |||
1334 | if (i == ARRAY_SIZE(whitelist)) | ||
1335 | return -EINVAL; | ||
1336 | |||
1337 | switch (entry->size) { | ||
1338 | case 8: | ||
1339 | reg->val = I915_READ64(reg->offset); | ||
1340 | break; | ||
1341 | case 4: | ||
1342 | reg->val = I915_READ(reg->offset); | ||
1343 | break; | ||
1344 | case 2: | ||
1345 | reg->val = I915_READ16(reg->offset); | ||
1346 | break; | ||
1347 | case 1: | ||
1348 | reg->val = I915_READ8(reg->offset); | ||
1349 | break; | ||
1350 | default: | ||
1351 | WARN_ON(1); | ||
1352 | return -EINVAL; | ||
1353 | } | ||
1354 | |||
1355 | return 0; | ||
1356 | } | ||