aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/i915_drv.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@gmail.com>2013-08-07 04:09:03 -0400
committerDave Airlie <airlied@gmail.com>2013-08-07 04:11:35 -0400
commit32c913e4369ce7bd1d16a9b6983f7b8975c13f5a (patch)
treeda5868a2b7e7c068d4b733420330a15001786365 /drivers/gpu/drm/i915/i915_drv.c
parentabf190351b49937335130970a99a0b4275402b5e (diff)
parentcd234b0bfd5ab012e42274b24aae420fa1823d58 (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.c277
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);
118MODULE_PARM_DESC(i915_enable_ppgtt, 118MODULE_PARM_DESC(i915_enable_ppgtt,
119 "Enable PPGTT (default: true)"); 119 "Enable PPGTT (default: true)");
120 120
121int i915_enable_psr __read_mostly = 0;
122module_param_named(enable_psr, i915_enable_psr, int, 0600);
123MODULE_PARM_DESC(enable_psr, "Enable PSR (default: false)");
124
121unsigned int i915_preliminary_hw_support __read_mostly = 0; 125unsigned int i915_preliminary_hw_support __read_mostly = 0;
122module_param_named(preliminary_hw_support, i915_preliminary_hw_support, int, 0600); 126module_param_named(preliminary_hw_support, i915_preliminary_hw_support, int, 0600);
123MODULE_PARM_DESC(preliminary_hw_support, 127MODULE_PARM_DESC(preliminary_hw_support,
@@ -137,6 +141,11 @@ module_param_named(fastboot, i915_fastboot, bool, 0600);
137MODULE_PARM_DESC(fastboot, "Try to skip unnecessary mode sets at boot time " 141MODULE_PARM_DESC(fastboot, "Try to skip unnecessary mode sets at boot time "
138 "(default: false)"); 142 "(default: false)");
139 143
144bool i915_prefault_disable __read_mostly;
145module_param_named(prefault_disable, i915_prefault_disable, bool, 0600);
146MODULE_PARM_DESC(prefault_disable,
147 "Disable page prefaulting for pread/pwrite/reloc (default:false). For developers only.");
148
140static struct drm_driver driver; 149static struct drm_driver driver;
141extern int intel_agp_enabled; 150extern 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
764static 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
794static 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
801static 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
829static 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
851static 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
886int 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);
1224MODULE_AUTHOR(DRIVER_AUTHOR); 1099MODULE_AUTHOR(DRIVER_AUTHOR);
1225MODULE_DESCRIPTION(DRIVER_DESC); 1100MODULE_DESCRIPTION(DRIVER_DESC);
1226MODULE_LICENSE("GPL and additional rights"); 1101MODULE_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))
1233static void
1234ilk_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
1242static void
1243hsw_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
1253static void
1254hsw_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) \
1264u##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) \
1291void 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
1312static 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
1320int 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}