Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'drm-intel-next-2016-02-14' of git://anongit.freedesktop.org/drm-intel into drm-next

- lots and lots of fbc work from Paulo
- max pixel clock checks from Mika Kahola
- prep work for nv12 offset handling from Ville
- piles of small fixes and refactorings all around

* tag 'drm-intel-next-2016-02-14' of git://anongit.freedesktop.org/drm-intel: (113 commits)
drm/i915: Update DRIVER_DATE to 20160214
drm/i915: edp resume/On time optimization.
agp/intel-gtt: Only register fake agp driver for gen1
drm/i915: TV pixel clock check
drm/i915: CRT pixel clock check
drm/i915: SDVO pixel clock check
drm/i915: DisplayPort-MST pixel clock check
drm/i915: HDMI pixel clock check
drm/i915: DisplayPort pixel clock check
drm/i915: check that rpm ref is held when accessing ringbuf in stolen mem
drm/i915: fix error path in intel_setup_gmbus()
drm/i915: Stop depending upon CONFIG_AGP_INTEL
agp/intel-gtt: Don't leak the scratch page
drm/i915: Capture PCI revision and subsytem details in error state
drm/i915: fix context/engine cleanup order
drm/i915: Handle PipeC fused off on IVB/HSW/BDW
drm/i915/skl: Fix typo in DPLL_CFGCR1 definition
drm/i915: Skip DDI PLL selection for DSI
drm/i915/skl: Explicitly check for eDP in skl_ddi_pll_select()
drm/i915/skl: Don't skip mst encoders in skl_ddi_pll_select()
...

+1569 -1094
+18 -14
drivers/char/agp/intel-gtt.c
··· 555 555 static void intel_gtt_teardown_scratch_page(void) 556 556 { 557 557 set_pages_wb(intel_private.scratch_page, 1); 558 - pci_unmap_page(intel_private.pcidev, intel_private.scratch_page_dma, 559 - PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); 558 + if (intel_private.needs_dmar) 559 + pci_unmap_page(intel_private.pcidev, 560 + intel_private.scratch_page_dma, 561 + PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); 560 562 __free_page(intel_private.scratch_page); 561 563 } 562 564 ··· 1348 1346 { 1349 1347 int i, mask; 1350 1348 1351 - /* 1352 - * Can be called from the fake agp driver but also directly from 1353 - * drm/i915.ko. Hence we need to check whether everything is set up 1354 - * already. 1355 - */ 1356 - if (intel_private.driver) { 1357 - intel_private.refcount++; 1358 - return 1; 1359 - } 1360 - 1361 1349 for (i = 0; intel_gtt_chipsets[i].name != NULL; i++) { 1362 1350 if (gpu_pdev) { 1363 1351 if (gpu_pdev->device == ··· 1368 1376 if (!intel_private.driver) 1369 1377 return 0; 1370 1378 1371 - intel_private.refcount++; 1372 - 1373 1379 #if IS_ENABLED(CONFIG_AGP_INTEL) 1374 1380 if (bridge) { 1381 + if (INTEL_GTT_GEN > 1) 1382 + return 0; 1383 + 1375 1384 bridge->driver = &intel_fake_agp_driver; 1376 1385 bridge->dev_private_data = &intel_private; 1377 1386 bridge->dev = bridge_pdev; 1378 1387 } 1379 1388 #endif 1389 + 1390 + 1391 + /* 1392 + * Can be called from the fake agp driver but also directly from 1393 + * drm/i915.ko. Hence we need to check whether everything is set up 1394 + * already. 1395 + */ 1396 + if (intel_private.refcount++) 1397 + return 1; 1380 1398 1381 1399 intel_private.bridge_dev = pci_dev_get(bridge_pdev); 1382 1400 ··· 1432 1430 if (--intel_private.refcount) 1433 1431 return; 1434 1432 1433 + if (intel_private.scratch_page) 1434 + intel_gtt_teardown_scratch_page(); 1435 1435 if (intel_private.pcidev) 1436 1436 pci_dev_put(intel_private.pcidev); 1437 1437 if (intel_private.bridge_dev)
-2
drivers/gpu/drm/i915/Kconfig
··· 2 2 tristate "Intel 8xx/9xx/G3x/G4x/HD Graphics" 3 3 depends on DRM 4 4 depends on X86 && PCI 5 - depends on (AGP || AGP=n) 6 5 select INTEL_GTT 7 - select AGP_INTEL if AGP 8 6 select INTERVAL_TREE 9 7 # we need shmfs for the swappable backing store, and in particular 10 8 # the shmem_readpage() which depends upon tmpfs
+20 -11
drivers/gpu/drm/i915/i915_debugfs.c
··· 2463 2463 2464 2464 for_each_ring(ring, dev_priv, i) { 2465 2465 seq_printf(m, "\tSubmissions: %llu %s\n", 2466 - client->submissions[i], 2466 + client->submissions[ring->guc_id], 2467 2467 ring->name); 2468 - tot += client->submissions[i]; 2468 + tot += client->submissions[ring->guc_id]; 2469 2469 } 2470 2470 seq_printf(m, "\tTotal: %llu\n", tot); 2471 2471 } ··· 2502 2502 2503 2503 seq_printf(m, "\nGuC submissions:\n"); 2504 2504 for_each_ring(ring, dev_priv, i) { 2505 - seq_printf(m, "\t%-24s: %10llu, last seqno 0x%08x %9d\n", 2506 - ring->name, guc.submissions[i], 2507 - guc.last_seqno[i], guc.last_seqno[i]); 2508 - total += guc.submissions[i]; 2505 + seq_printf(m, "\t%-24s: %10llu, last seqno 0x%08x\n", 2506 + ring->name, guc.submissions[ring->guc_id], 2507 + guc.last_seqno[ring->guc_id]); 2508 + total += guc.submissions[ring->guc_id]; 2509 2509 } 2510 2510 seq_printf(m, "\t%s: %llu\n", "Total", total); 2511 2511 ··· 2583 2583 enabled = true; 2584 2584 } 2585 2585 } 2586 + 2587 + seq_printf(m, "Main link in standby mode: %s\n", 2588 + yesno(dev_priv->psr.link_standby)); 2589 + 2586 2590 seq_printf(m, "HW Enabled & Active bit: %s", yesno(enabled)); 2587 2591 2588 2592 if (!HAS_DDI(dev)) ··· 3225 3221 { 3226 3222 int i; 3227 3223 int ret; 3224 + struct intel_engine_cs *ring; 3228 3225 struct drm_info_node *node = (struct drm_info_node *) m->private; 3229 3226 struct drm_device *dev = node->minor->dev; 3230 3227 struct drm_i915_private *dev_priv = dev->dev_private; 3228 + struct i915_workarounds *workarounds = &dev_priv->workarounds; 3231 3229 3232 3230 ret = mutex_lock_interruptible(&dev->struct_mutex); 3233 3231 if (ret) ··· 3237 3231 3238 3232 intel_runtime_pm_get(dev_priv); 3239 3233 3240 - seq_printf(m, "Workarounds applied: %d\n", dev_priv->workarounds.count); 3241 - for (i = 0; i < dev_priv->workarounds.count; ++i) { 3234 + seq_printf(m, "Workarounds applied: %d\n", workarounds->count); 3235 + for_each_ring(ring, dev_priv, i) 3236 + seq_printf(m, "HW whitelist count for %s: %d\n", 3237 + ring->name, workarounds->hw_whitelist_count[i]); 3238 + for (i = 0; i < workarounds->count; ++i) { 3242 3239 i915_reg_t addr; 3243 3240 u32 mask, value, read; 3244 3241 bool ok; 3245 3242 3246 - addr = dev_priv->workarounds.reg[i].addr; 3247 - mask = dev_priv->workarounds.reg[i].mask; 3248 - value = dev_priv->workarounds.reg[i].value; 3243 + addr = workarounds->reg[i].addr; 3244 + mask = workarounds->reg[i].mask; 3245 + value = workarounds->reg[i].value; 3249 3246 read = I915_READ(addr); 3250 3247 ok = (value & mask) == (read & mask); 3251 3248 seq_printf(m, "0x%X: 0x%08X, mask: 0x%08X, read: 0x%08x, status: %s\n",
+156 -106
drivers/gpu/drm/i915/i915_dma.c
··· 391 391 if (ret) 392 392 goto cleanup_vga_client; 393 393 394 - /* Initialise stolen first so that we may reserve preallocated 395 - * objects for the BIOS to KMS transition. 396 - */ 397 - ret = i915_gem_init_stolen(dev); 398 - if (ret) 399 - goto cleanup_vga_switcheroo; 400 - 401 394 intel_power_domains_init_hw(dev_priv, false); 402 395 403 396 intel_csr_ucode_init(dev_priv); 404 397 405 398 ret = intel_irq_install(dev_priv); 406 399 if (ret) 407 - goto cleanup_gem_stolen; 400 + goto cleanup_csr; 408 401 409 402 intel_setup_gmbus(dev); 410 403 ··· 444 451 445 452 cleanup_gem: 446 453 mutex_lock(&dev->struct_mutex); 447 - i915_gem_cleanup_ringbuffer(dev); 448 454 i915_gem_context_fini(dev); 455 + i915_gem_cleanup_engines(dev); 449 456 mutex_unlock(&dev->struct_mutex); 450 457 cleanup_irq: 451 458 intel_guc_ucode_fini(dev); 452 459 drm_irq_uninstall(dev); 453 460 intel_teardown_gmbus(dev); 454 - cleanup_gem_stolen: 455 - i915_gem_cleanup_stolen(dev); 456 - cleanup_vga_switcheroo: 461 + cleanup_csr: 462 + intel_csr_ucode_fini(dev_priv); 457 463 vga_switcheroo_unregister_client(dev->pdev); 458 464 cleanup_vga_client: 459 465 vga_client_register(dev->pdev, NULL, NULL, NULL); ··· 808 816 !(sfuse_strap & SFUSE_STRAP_FUSE_LOCK))) { 809 817 DRM_INFO("Display fused off, disabling\n"); 810 818 info->num_pipes = 0; 819 + } else if (fuse_strap & IVB_PIPE_C_DISABLE) { 820 + DRM_INFO("PipeC fused off\n"); 821 + info->num_pipes -= 1; 811 822 } 823 + } else if (info->num_pipes > 0 && INTEL_INFO(dev)->gen == 9) { 824 + u32 dfsm = I915_READ(SKL_DFSM); 825 + u8 disabled_mask = 0; 826 + bool invalid; 827 + int num_bits; 828 + 829 + if (dfsm & SKL_DFSM_PIPE_A_DISABLE) 830 + disabled_mask |= BIT(PIPE_A); 831 + if (dfsm & SKL_DFSM_PIPE_B_DISABLE) 832 + disabled_mask |= BIT(PIPE_B); 833 + if (dfsm & SKL_DFSM_PIPE_C_DISABLE) 834 + disabled_mask |= BIT(PIPE_C); 835 + 836 + num_bits = hweight8(disabled_mask); 837 + 838 + switch (disabled_mask) { 839 + case BIT(PIPE_A): 840 + case BIT(PIPE_B): 841 + case BIT(PIPE_A) | BIT(PIPE_B): 842 + case BIT(PIPE_A) | BIT(PIPE_C): 843 + invalid = true; 844 + break; 845 + default: 846 + invalid = false; 847 + } 848 + 849 + if (num_bits > info->num_pipes || invalid) 850 + DRM_ERROR("invalid pipe fuse configuration: 0x%x\n", 851 + disabled_mask); 852 + else 853 + info->num_pipes -= num_bits; 812 854 } 813 855 814 856 /* Initialize slice/subslice/EU info */ ··· 881 855 } 882 856 } 883 857 858 + static int i915_workqueues_init(struct drm_i915_private *dev_priv) 859 + { 860 + /* 861 + * The i915 workqueue is primarily used for batched retirement of 862 + * requests (and thus managing bo) once the task has been completed 863 + * by the GPU. i915_gem_retire_requests() is called directly when we 864 + * need high-priority retirement, such as waiting for an explicit 865 + * bo. 866 + * 867 + * It is also used for periodic low-priority events, such as 868 + * idle-timers and recording error state. 869 + * 870 + * All tasks on the workqueue are expected to acquire the dev mutex 871 + * so there is no point in running more than one instance of the 872 + * workqueue at any time. Use an ordered one. 873 + */ 874 + dev_priv->wq = alloc_ordered_workqueue("i915", 0); 875 + if (dev_priv->wq == NULL) 876 + goto out_err; 877 + 878 + dev_priv->hotplug.dp_wq = alloc_ordered_workqueue("i915-dp", 0); 879 + if (dev_priv->hotplug.dp_wq == NULL) 880 + goto out_free_wq; 881 + 882 + dev_priv->gpu_error.hangcheck_wq = 883 + alloc_ordered_workqueue("i915-hangcheck", 0); 884 + if (dev_priv->gpu_error.hangcheck_wq == NULL) 885 + goto out_free_dp_wq; 886 + 887 + return 0; 888 + 889 + out_free_dp_wq: 890 + destroy_workqueue(dev_priv->hotplug.dp_wq); 891 + out_free_wq: 892 + destroy_workqueue(dev_priv->wq); 893 + out_err: 894 + DRM_ERROR("Failed to allocate workqueues.\n"); 895 + 896 + return -ENOMEM; 897 + } 898 + 899 + static void i915_workqueues_cleanup(struct drm_i915_private *dev_priv) 900 + { 901 + destroy_workqueue(dev_priv->gpu_error.hangcheck_wq); 902 + destroy_workqueue(dev_priv->hotplug.dp_wq); 903 + destroy_workqueue(dev_priv->wq); 904 + } 905 + 906 + static int i915_mmio_setup(struct drm_device *dev) 907 + { 908 + struct drm_i915_private *dev_priv = to_i915(dev); 909 + int mmio_bar; 910 + int mmio_size; 911 + 912 + mmio_bar = IS_GEN2(dev) ? 1 : 0; 913 + /* 914 + * Before gen4, the registers and the GTT are behind different BARs. 915 + * However, from gen4 onwards, the registers and the GTT are shared 916 + * in the same BAR, so we want to restrict this ioremap from 917 + * clobbering the GTT which we want ioremap_wc instead. Fortunately, 918 + * the register BAR remains the same size for all the earlier 919 + * generations up to Ironlake. 920 + */ 921 + if (INTEL_INFO(dev)->gen < 5) 922 + mmio_size = 512 * 1024; 923 + else 924 + mmio_size = 2 * 1024 * 1024; 925 + dev_priv->regs = pci_iomap(dev->pdev, mmio_bar, mmio_size); 926 + if (dev_priv->regs == NULL) { 927 + DRM_ERROR("failed to map registers\n"); 928 + 929 + return -EIO; 930 + } 931 + 932 + /* Try to make sure MCHBAR is enabled before poking at it */ 933 + intel_setup_mchbar(dev); 934 + 935 + return 0; 936 + } 937 + 938 + static void i915_mmio_cleanup(struct drm_device *dev) 939 + { 940 + struct drm_i915_private *dev_priv = to_i915(dev); 941 + 942 + intel_teardown_mchbar(dev); 943 + pci_iounmap(dev->pdev, dev_priv->regs); 944 + } 945 + 884 946 /** 885 947 * i915_driver_load - setup chip and create an initial config 886 948 * @dev: DRM device ··· 984 870 { 985 871 struct drm_i915_private *dev_priv; 986 872 struct intel_device_info *info, *device_info; 987 - int ret = 0, mmio_bar, mmio_size; 873 + int ret = 0; 988 874 uint32_t aperture_size; 989 875 990 876 info = (struct intel_device_info *) flags; ··· 1011 897 mutex_init(&dev_priv->modeset_restore_lock); 1012 898 mutex_init(&dev_priv->av_mutex); 1013 899 900 + ret = i915_workqueues_init(dev_priv); 901 + if (ret < 0) 902 + goto out_free_priv; 903 + 1014 904 intel_pm_setup(dev); 1015 905 1016 906 intel_runtime_pm_get(dev_priv); ··· 1033 915 1034 916 if (i915_get_bridge_dev(dev)) { 1035 917 ret = -EIO; 1036 - goto free_priv; 918 + goto out_runtime_pm_put; 1037 919 } 1038 920 1039 - mmio_bar = IS_GEN2(dev) ? 1 : 0; 1040 - /* Before gen4, the registers and the GTT are behind different BARs. 1041 - * However, from gen4 onwards, the registers and the GTT are shared 1042 - * in the same BAR, so we want to restrict this ioremap from 1043 - * clobbering the GTT which we want ioremap_wc instead. Fortunately, 1044 - * the register BAR remains the same size for all the earlier 1045 - * generations up to Ironlake. 1046 - */ 1047 - if (info->gen < 5) 1048 - mmio_size = 512*1024; 1049 - else 1050 - mmio_size = 2*1024*1024; 1051 - 1052 - dev_priv->regs = pci_iomap(dev->pdev, mmio_bar, mmio_size); 1053 - if (!dev_priv->regs) { 1054 - DRM_ERROR("failed to map registers\n"); 1055 - ret = -EIO; 921 + ret = i915_mmio_setup(dev); 922 + if (ret < 0) 1056 923 goto put_bridge; 1057 - } 1058 924 1059 925 /* This must be called before any calls to HAS_PCH_* */ 1060 926 intel_detect_pch(dev); ··· 1047 945 1048 946 ret = i915_gem_gtt_init(dev); 1049 947 if (ret) 1050 - goto out_freecsr; 948 + goto out_uncore_fini; 1051 949 1052 950 /* WARNING: Apparently we must kick fbdev drivers before vgacon, 1053 951 * otherwise the vga fbdev driver falls over. */ ··· 1093 991 dev_priv->gtt.mtrr = arch_phys_wc_add(dev_priv->gtt.mappable_base, 1094 992 aperture_size); 1095 993 1096 - /* The i915 workqueue is primarily used for batched retirement of 1097 - * requests (and thus managing bo) once the task has been completed 1098 - * by the GPU. i915_gem_retire_requests() is called directly when we 1099 - * need high-priority retirement, such as waiting for an explicit 1100 - * bo. 1101 - * 1102 - * It is also used for periodic low-priority events, such as 1103 - * idle-timers and recording error state. 1104 - * 1105 - * All tasks on the workqueue are expected to acquire the dev mutex 1106 - * so there is no point in running more than one instance of the 1107 - * workqueue at any time. Use an ordered one. 1108 - */ 1109 - dev_priv->wq = alloc_ordered_workqueue("i915", 0); 1110 - if (dev_priv->wq == NULL) { 1111 - DRM_ERROR("Failed to create our workqueue.\n"); 1112 - ret = -ENOMEM; 1113 - goto out_mtrrfree; 1114 - } 1115 - 1116 - dev_priv->hotplug.dp_wq = alloc_ordered_workqueue("i915-dp", 0); 1117 - if (dev_priv->hotplug.dp_wq == NULL) { 1118 - DRM_ERROR("Failed to create our dp workqueue.\n"); 1119 - ret = -ENOMEM; 1120 - goto out_freewq; 1121 - } 1122 - 1123 - dev_priv->gpu_error.hangcheck_wq = 1124 - alloc_ordered_workqueue("i915-hangcheck", 0); 1125 - if (dev_priv->gpu_error.hangcheck_wq == NULL) { 1126 - DRM_ERROR("Failed to create our hangcheck workqueue.\n"); 1127 - ret = -ENOMEM; 1128 - goto out_freedpwq; 1129 - } 1130 - 1131 994 intel_irq_init(dev_priv); 1132 995 intel_uncore_sanitize(dev); 1133 996 1134 - /* Try to make sure MCHBAR is enabled before poking at it */ 1135 - intel_setup_mchbar(dev); 1136 997 intel_opregion_setup(dev); 1137 998 1138 - i915_gem_load(dev); 999 + i915_gem_load_init(dev); 1000 + i915_gem_shrinker_init(dev_priv); 1139 1001 1140 1002 /* On the 945G/GM, the chipset reports the MSI capability on the 1141 1003 * integrated graphics even though the support isn't actually there ··· 1112 1046 * be lost or delayed, but we use them anyways to avoid 1113 1047 * stuck interrupts on some machines. 1114 1048 */ 1115 - if (!IS_I945G(dev) && !IS_I945GM(dev)) 1116 - pci_enable_msi(dev->pdev); 1049 + if (!IS_I945G(dev) && !IS_I945GM(dev)) { 1050 + if (pci_enable_msi(dev->pdev) < 0) 1051 + DRM_DEBUG_DRIVER("can't enable MSI"); 1052 + } 1117 1053 1118 1054 intel_device_info_runtime_init(dev); 1119 1055 ··· 1165 1097 intel_power_domains_fini(dev_priv); 1166 1098 drm_vblank_cleanup(dev); 1167 1099 out_gem_unload: 1168 - WARN_ON(unregister_oom_notifier(&dev_priv->mm.oom_notifier)); 1169 - unregister_shrinker(&dev_priv->mm.shrinker); 1100 + i915_gem_shrinker_cleanup(dev_priv); 1170 1101 1171 1102 if (dev->pdev->msi_enabled) 1172 1103 pci_disable_msi(dev->pdev); 1173 1104 1174 1105 intel_teardown_mchbar(dev); 1175 1106 pm_qos_remove_request(&dev_priv->pm_qos); 1176 - destroy_workqueue(dev_priv->gpu_error.hangcheck_wq); 1177 - out_freedpwq: 1178 - destroy_workqueue(dev_priv->hotplug.dp_wq); 1179 - out_freewq: 1180 - destroy_workqueue(dev_priv->wq); 1181 - out_mtrrfree: 1182 1107 arch_phys_wc_del(dev_priv->gtt.mtrr); 1183 1108 io_mapping_free(dev_priv->gtt.mappable); 1184 1109 out_gtt: 1185 1110 i915_global_gtt_cleanup(dev); 1186 - out_freecsr: 1187 - intel_csr_ucode_fini(dev_priv); 1111 + out_uncore_fini: 1188 1112 intel_uncore_fini(dev); 1189 - pci_iounmap(dev->pdev, dev_priv->regs); 1113 + i915_mmio_cleanup(dev); 1190 1114 put_bridge: 1191 1115 pci_dev_put(dev_priv->bridge_dev); 1192 - free_priv: 1193 - kmem_cache_destroy(dev_priv->requests); 1194 - kmem_cache_destroy(dev_priv->vmas); 1195 - kmem_cache_destroy(dev_priv->objects); 1196 - 1116 + i915_gem_load_cleanup(dev); 1117 + out_runtime_pm_put: 1197 1118 intel_runtime_pm_put(dev_priv); 1198 - 1119 + i915_workqueues_cleanup(dev_priv); 1120 + out_free_priv: 1199 1121 kfree(dev_priv); 1122 + 1200 1123 return ret; 1201 1124 } 1202 1125 ··· 1212 1153 1213 1154 i915_teardown_sysfs(dev); 1214 1155 1215 - WARN_ON(unregister_oom_notifier(&dev_priv->mm.oom_notifier)); 1216 - unregister_shrinker(&dev_priv->mm.shrinker); 1156 + i915_gem_shrinker_cleanup(dev_priv); 1217 1157 1218 1158 io_mapping_free(dev_priv->gtt.mappable); 1219 1159 arch_phys_wc_del(dev_priv->gtt.mtrr); ··· 1240 1182 vga_switcheroo_unregister_client(dev->pdev); 1241 1183 vga_client_register(dev->pdev, NULL, NULL, NULL); 1242 1184 1185 + intel_csr_ucode_fini(dev_priv); 1186 + 1243 1187 /* Free error state after interrupts are fully disabled. */ 1244 1188 cancel_delayed_work_sync(&dev_priv->gpu_error.hangcheck_work); 1245 1189 i915_destroy_error_state(dev); ··· 1256 1196 1257 1197 intel_guc_ucode_fini(dev); 1258 1198 mutex_lock(&dev->struct_mutex); 1259 - i915_gem_cleanup_ringbuffer(dev); 1260 1199 i915_gem_context_fini(dev); 1200 + i915_gem_cleanup_engines(dev); 1261 1201 mutex_unlock(&dev->struct_mutex); 1262 1202 intel_fbc_cleanup_cfb(dev_priv); 1263 - i915_gem_cleanup_stolen(dev); 1264 1203 1265 - intel_csr_ucode_fini(dev_priv); 1266 - 1267 - intel_teardown_mchbar(dev); 1268 - 1269 - destroy_workqueue(dev_priv->hotplug.dp_wq); 1270 - destroy_workqueue(dev_priv->wq); 1271 - destroy_workqueue(dev_priv->gpu_error.hangcheck_wq); 1272 1204 pm_qos_remove_request(&dev_priv->pm_qos); 1273 1205 1274 1206 i915_global_gtt_cleanup(dev); 1275 1207 1276 1208 intel_uncore_fini(dev); 1277 - if (dev_priv->regs != NULL) 1278 - pci_iounmap(dev->pdev, dev_priv->regs); 1209 + i915_mmio_cleanup(dev); 1279 1210 1280 - kmem_cache_destroy(dev_priv->requests); 1281 - kmem_cache_destroy(dev_priv->vmas); 1282 - kmem_cache_destroy(dev_priv->objects); 1211 + i915_gem_load_cleanup(dev); 1283 1212 pci_dev_put(dev_priv->bridge_dev); 1213 + i915_workqueues_cleanup(dev_priv); 1284 1214 kfree(dev_priv); 1285 1215 1286 1216 return 0;
+63 -18
drivers/gpu/drm/i915/i915_drv.h
··· 59 59 60 60 #define DRIVER_NAME "i915" 61 61 #define DRIVER_DESC "Intel Graphics" 62 - #define DRIVER_DATE "20160124" 62 + #define DRIVER_DATE "20160214" 63 63 64 64 #undef WARN_ON 65 65 /* Many gcc seem to no see through this and fall over :( */ ··· 900 900 ORIGIN_DIRTYFB, 901 901 }; 902 902 903 - struct i915_fbc { 903 + struct intel_fbc { 904 904 /* This is always the inner lock when overlapping with struct_mutex and 905 905 * it's the outer lock when overlapping with stolen_lock. */ 906 906 struct mutex lock; 907 907 unsigned threshold; 908 - unsigned int fb_id; 909 908 unsigned int possible_framebuffer_bits; 910 909 unsigned int busy_bits; 910 + unsigned int visible_pipes_mask; 911 911 struct intel_crtc *crtc; 912 - int y; 913 912 914 913 struct drm_mm_node compressed_fb; 915 914 struct drm_mm_node *compressed_llb; ··· 918 919 bool enabled; 919 920 bool active; 920 921 922 + struct intel_fbc_state_cache { 923 + struct { 924 + unsigned int mode_flags; 925 + uint32_t hsw_bdw_pixel_rate; 926 + } crtc; 927 + 928 + struct { 929 + unsigned int rotation; 930 + int src_w; 931 + int src_h; 932 + bool visible; 933 + } plane; 934 + 935 + struct { 936 + u64 ilk_ggtt_offset; 937 + uint32_t pixel_format; 938 + unsigned int stride; 939 + int fence_reg; 940 + unsigned int tiling_mode; 941 + } fb; 942 + } state_cache; 943 + 944 + struct intel_fbc_reg_params { 945 + struct { 946 + enum pipe pipe; 947 + enum plane plane; 948 + unsigned int fence_y_offset; 949 + } crtc; 950 + 951 + struct { 952 + u64 ggtt_offset; 953 + uint32_t pixel_format; 954 + unsigned int stride; 955 + int fence_reg; 956 + } fb; 957 + 958 + int cfb_size; 959 + } params; 960 + 921 961 struct intel_fbc_work { 922 962 bool scheduled; 963 + u32 scheduled_vblank; 923 964 struct work_struct work; 924 - struct drm_framebuffer *fb; 925 - unsigned long enable_jiffies; 926 965 } work; 927 966 928 967 const char *no_fbc_reason; 929 - 930 - bool (*is_active)(struct drm_i915_private *dev_priv); 931 - void (*activate)(struct intel_crtc *crtc); 932 - void (*deactivate)(struct drm_i915_private *dev_priv); 933 968 }; 934 969 935 970 /** ··· 1003 970 unsigned busy_frontbuffer_bits; 1004 971 bool psr2_support; 1005 972 bool aux_frame_sync; 973 + bool link_standby; 1006 974 }; 1007 975 1008 976 enum intel_pch { ··· 1691 1657 u32 mask; 1692 1658 }; 1693 1659 1694 - #define I915_MAX_WA_REGS 16 1660 + /* 1661 + * RING_MAX_NONPRIV_SLOTS is per-engine but at this point we are only 1662 + * allowing it for RCS as we don't foresee any requirement of having 1663 + * a whitelist for other engines. When it is really required for 1664 + * other engines then the limit need to be increased. 1665 + */ 1666 + #define I915_MAX_WA_REGS (16 + RING_MAX_NONPRIV_SLOTS) 1695 1667 1696 1668 struct i915_workarounds { 1697 1669 struct i915_wa_reg reg[I915_MAX_WA_REGS]; 1698 1670 u32 count; 1671 + u32 hw_whitelist_count[I915_NUM_RINGS]; 1699 1672 }; 1700 1673 1701 1674 struct i915_virtual_gpu { ··· 1799 1758 u32 pipestat_irq_mask[I915_MAX_PIPES]; 1800 1759 1801 1760 struct i915_hotplug hotplug; 1802 - struct i915_fbc fbc; 1761 + struct intel_fbc fbc; 1803 1762 struct i915_drrs drrs; 1804 1763 struct intel_opregion opregion; 1805 1764 struct intel_vbt_data vbt; ··· 2034 1993 #define I915_GTT_OFFSET_NONE ((u32)-1) 2035 1994 2036 1995 struct drm_i915_gem_object_ops { 1996 + unsigned int flags; 1997 + #define I915_GEM_OBJECT_HAS_STRUCT_PAGE 0x1 1998 + 2037 1999 /* Interface between the GEM object and its backing storage. 2038 2000 * get_pages() is called once prior to the use of the associated set 2039 2001 * of pages before to binding them into the GTT, and put_pages() is ··· 2052 2008 */ 2053 2009 int (*get_pages)(struct drm_i915_gem_object *); 2054 2010 void (*put_pages)(struct drm_i915_gem_object *); 2011 + 2055 2012 int (*dmabuf_export)(struct drm_i915_gem_object *); 2056 2013 void (*release)(struct drm_i915_gem_object *); 2057 2014 }; ··· 2886 2841 struct drm_file *file_priv); 2887 2842 int i915_gem_wait_ioctl(struct drm_device *dev, void *data, 2888 2843 struct drm_file *file_priv); 2889 - void i915_gem_load(struct drm_device *dev); 2844 + void i915_gem_load_init(struct drm_device *dev); 2845 + void i915_gem_load_cleanup(struct drm_device *dev); 2890 2846 void *i915_gem_object_alloc(struct drm_device *dev); 2891 2847 void i915_gem_object_free(struct drm_i915_gem_object *obj); 2892 2848 void i915_gem_object_init(struct drm_i915_gem_object *obj, ··· 3058 3012 int __must_check i915_gem_init_hw(struct drm_device *dev); 3059 3013 int i915_gem_l3_remap(struct drm_i915_gem_request *req, int slice); 3060 3014 void i915_gem_init_swizzling(struct drm_device *dev); 3061 - void i915_gem_cleanup_ringbuffer(struct drm_device *dev); 3015 + void i915_gem_cleanup_engines(struct drm_device *dev); 3062 3016 int __must_check i915_gpu_idle(struct drm_device *dev); 3063 3017 int __must_check i915_gem_suspend(struct drm_device *dev); 3064 3018 void __i915_add_request(struct drm_i915_gem_request *req, ··· 3300 3254 #define I915_SHRINK_ACTIVE 0x8 3301 3255 unsigned long i915_gem_shrink_all(struct drm_i915_private *dev_priv); 3302 3256 void i915_gem_shrinker_init(struct drm_i915_private *dev_priv); 3257 + void i915_gem_shrinker_cleanup(struct drm_i915_private *dev_priv); 3303 3258 3304 3259 3305 3260 /* i915_gem_tiling.c */ ··· 3471 3424 u32 vlv_punit_read(struct drm_i915_private *dev_priv, u32 addr); 3472 3425 void vlv_punit_write(struct drm_i915_private *dev_priv, u32 addr, u32 val); 3473 3426 u32 vlv_nc_read(struct drm_i915_private *dev_priv, u8 addr); 3474 - u32 vlv_gpio_nc_read(struct drm_i915_private *dev_priv, u32 reg); 3475 - void vlv_gpio_nc_write(struct drm_i915_private *dev_priv, u32 reg, u32 val); 3427 + u32 vlv_iosf_sb_read(struct drm_i915_private *dev_priv, u8 port, u32 reg); 3428 + void vlv_iosf_sb_write(struct drm_i915_private *dev_priv, u8 port, u32 reg, u32 val); 3476 3429 u32 vlv_cck_read(struct drm_i915_private *dev_priv, u32 reg); 3477 3430 void vlv_cck_write(struct drm_i915_private *dev_priv, u32 reg, u32 val); 3478 3431 u32 vlv_ccu_read(struct drm_i915_private *dev_priv, u32 reg); 3479 3432 void vlv_ccu_write(struct drm_i915_private *dev_priv, u32 reg, u32 val); 3480 3433 u32 vlv_bunit_read(struct drm_i915_private *dev_priv, u32 reg); 3481 3434 void vlv_bunit_write(struct drm_i915_private *dev_priv, u32 reg, u32 val); 3482 - u32 vlv_gps_core_read(struct drm_i915_private *dev_priv, u32 reg); 3483 - void vlv_gps_core_write(struct drm_i915_private *dev_priv, u32 reg, u32 val); 3484 3435 u32 vlv_dpio_read(struct drm_i915_private *dev_priv, enum pipe pipe, int reg); 3485 3436 void vlv_dpio_write(struct drm_i915_private *dev_priv, enum pipe pipe, int reg, u32 val); 3486 3437 u32 intel_sbi_read(struct drm_i915_private *dev_priv, u16 reg,
+25 -16
drivers/gpu/drm/i915/i915_gem.c
··· 2680 2680 2681 2681 if (ctx) { 2682 2682 if (i915.enable_execlists && ctx != req->i915->kernel_context) 2683 - intel_lr_context_unpin(req); 2683 + intel_lr_context_unpin(ctx, req->ring); 2684 2684 2685 2685 i915_gem_context_unreference(ctx); 2686 2686 } ··· 4465 4465 } 4466 4466 4467 4467 static const struct drm_i915_gem_object_ops i915_gem_object_ops = { 4468 + .flags = I915_GEM_OBJECT_HAS_STRUCT_PAGE, 4468 4469 .get_pages = i915_gem_object_get_pages_gtt, 4469 4470 .put_pages = i915_gem_object_put_pages_gtt, 4470 4471 }; ··· 4913 4912 req = i915_gem_request_alloc(ring, NULL); 4914 4913 if (IS_ERR(req)) { 4915 4914 ret = PTR_ERR(req); 4916 - i915_gem_cleanup_ringbuffer(dev); 4915 + i915_gem_cleanup_engines(dev); 4917 4916 goto out; 4918 4917 } 4919 4918 ··· 4926 4925 if (ret && ret != -EIO) { 4927 4926 DRM_ERROR("PPGTT enable ring #%d failed %d\n", i, ret); 4928 4927 i915_gem_request_cancel(req); 4929 - i915_gem_cleanup_ringbuffer(dev); 4928 + i915_gem_cleanup_engines(dev); 4930 4929 goto out; 4931 4930 } 4932 4931 ··· 4934 4933 if (ret && ret != -EIO) { 4935 4934 DRM_ERROR("Context enable ring #%d failed %d\n", i, ret); 4936 4935 i915_gem_request_cancel(req); 4937 - i915_gem_cleanup_ringbuffer(dev); 4936 + i915_gem_cleanup_engines(dev); 4938 4937 goto out; 4939 4938 } 4940 4939 ··· 5009 5008 } 5010 5009 5011 5010 void 5012 - i915_gem_cleanup_ringbuffer(struct drm_device *dev) 5011 + i915_gem_cleanup_engines(struct drm_device *dev) 5013 5012 { 5014 5013 struct drm_i915_private *dev_priv = dev->dev_private; 5015 5014 struct intel_engine_cs *ring; ··· 5018 5017 for_each_ring(ring, dev_priv, i) 5019 5018 dev_priv->gt.cleanup_ring(ring); 5020 5019 5021 - if (i915.enable_execlists) 5022 - /* 5023 - * Neither the BIOS, ourselves or any other kernel 5024 - * expects the system to be in execlists mode on startup, 5025 - * so we need to reset the GPU back to legacy mode. 5026 - */ 5027 - intel_gpu_reset(dev); 5020 + if (i915.enable_execlists) { 5021 + /* 5022 + * Neither the BIOS, ourselves or any other kernel 5023 + * expects the system to be in execlists mode on startup, 5024 + * so we need to reset the GPU back to legacy mode. 5025 + */ 5026 + intel_gpu_reset(dev); 5027 + } 5028 5028 } 5029 5029 5030 5030 static void ··· 5036 5034 } 5037 5035 5038 5036 void 5039 - i915_gem_load(struct drm_device *dev) 5037 + i915_gem_load_init(struct drm_device *dev) 5040 5038 { 5041 5039 struct drm_i915_private *dev_priv = dev->dev_private; 5042 5040 int i; ··· 5102 5100 5103 5101 dev_priv->mm.interruptible = true; 5104 5102 5105 - i915_gem_shrinker_init(dev_priv); 5106 - 5107 5103 mutex_init(&dev_priv->fb_tracking.lock); 5104 + } 5105 + 5106 + void i915_gem_load_cleanup(struct drm_device *dev) 5107 + { 5108 + struct drm_i915_private *dev_priv = to_i915(dev); 5109 + 5110 + kmem_cache_destroy(dev_priv->requests); 5111 + kmem_cache_destroy(dev_priv->vmas); 5112 + kmem_cache_destroy(dev_priv->objects); 5108 5113 } 5109 5114 5110 5115 void i915_gem_release(struct drm_device *dev, struct drm_file *file) ··· 5311 5302 struct page *page; 5312 5303 5313 5304 /* Only default objects have per-page dirty tracking */ 5314 - if (WARN_ON(obj->ops != &i915_gem_object_ops)) 5305 + if (WARN_ON((obj->ops->flags & I915_GEM_OBJECT_HAS_STRUCT_PAGE) == 0)) 5315 5306 return NULL; 5316 5307 5317 5308 page = i915_gem_object_get_page(obj, n);
+16 -18
drivers/gpu/drm/i915/i915_gem_context.c
··· 321 321 return ERR_PTR(ret); 322 322 } 323 323 324 + static void i915_gem_context_unpin(struct intel_context *ctx, 325 + struct intel_engine_cs *engine) 326 + { 327 + if (i915.enable_execlists) { 328 + intel_lr_context_unpin(ctx, engine); 329 + } else { 330 + if (engine->id == RCS && ctx->legacy_hw_ctx.rcs_state) 331 + i915_gem_object_ggtt_unpin(ctx->legacy_hw_ctx.rcs_state); 332 + i915_gem_context_unreference(ctx); 333 + } 334 + } 335 + 324 336 void i915_gem_context_reset(struct drm_device *dev) 325 337 { 326 338 struct drm_i915_private *dev_priv = dev->dev_private; ··· 341 329 if (i915.enable_execlists) { 342 330 struct intel_context *ctx; 343 331 344 - list_for_each_entry(ctx, &dev_priv->context_list, link) { 332 + list_for_each_entry(ctx, &dev_priv->context_list, link) 345 333 intel_lr_context_reset(dev, ctx); 346 - } 347 - 348 - return; 349 334 } 350 335 351 336 for (i = 0; i < I915_NUM_RINGS; i++) { 352 337 struct intel_engine_cs *ring = &dev_priv->ring[i]; 353 - struct intel_context *lctx = ring->last_context; 354 338 355 - if (lctx) { 356 - if (lctx->legacy_hw_ctx.rcs_state && i == RCS) 357 - i915_gem_object_ggtt_unpin(lctx->legacy_hw_ctx.rcs_state); 358 - 359 - i915_gem_context_unreference(lctx); 339 + if (ring->last_context) { 340 + i915_gem_context_unpin(ring->last_context, ring); 360 341 ring->last_context = NULL; 361 342 } 362 343 } ··· 422 417 * to offset the do_switch part, so that i915_gem_context_unreference() 423 418 * can then free the base object correctly. */ 424 419 WARN_ON(!dev_priv->ring[RCS].last_context); 425 - if (dev_priv->ring[RCS].last_context == dctx) { 426 - /* Fake switch to NULL context */ 427 - WARN_ON(dctx->legacy_hw_ctx.rcs_state->active); 428 - i915_gem_object_ggtt_unpin(dctx->legacy_hw_ctx.rcs_state); 429 - i915_gem_context_unreference(dctx); 430 - dev_priv->ring[RCS].last_context = NULL; 431 - } 432 420 433 421 i915_gem_object_ggtt_unpin(dctx->legacy_hw_ctx.rcs_state); 434 422 } ··· 430 432 struct intel_engine_cs *ring = &dev_priv->ring[i]; 431 433 432 434 if (ring->last_context) { 433 - i915_gem_context_unreference(ring->last_context); 435 + i915_gem_context_unpin(ring->last_context, ring); 434 436 ring->last_context = NULL; 435 437 } 436 438 }
+2 -1
drivers/gpu/drm/i915/i915_gem_execbuffer.c
··· 1401 1401 bsd_idx = gen8_dispatch_bsd_ring(dev_priv, file); 1402 1402 } else if (bsd_idx >= I915_EXEC_BSD_RING1 && 1403 1403 bsd_idx <= I915_EXEC_BSD_RING2) { 1404 + bsd_idx >>= I915_EXEC_BSD_SHIFT; 1404 1405 bsd_idx--; 1405 1406 } else { 1406 1407 DRM_DEBUG("execbuf with unknown bsd ring: %u\n", ··· 1655 1654 * must be freed again. If it was submitted then it is being tracked 1656 1655 * on the active request list and no clean up is required here. 1657 1656 */ 1658 - if (ret && req) 1657 + if (ret && !IS_ERR_OR_NULL(req)) 1659 1658 i915_gem_request_cancel(req); 1660 1659 1661 1660 mutex_unlock(&dev->struct_mutex);
+44 -6
drivers/gpu/drm/i915/i915_gem_gtt.c
··· 2132 2132 list_add_tail(&vm->global_link, &dev_priv->vm_list); 2133 2133 } 2134 2134 2135 + static void gtt_write_workarounds(struct drm_device *dev) 2136 + { 2137 + struct drm_i915_private *dev_priv = dev->dev_private; 2138 + 2139 + /* This function is for gtt related workarounds. This function is 2140 + * called on driver load and after a GPU reset, so you can place 2141 + * workarounds here even if they get overwritten by GPU reset. 2142 + */ 2143 + /* WaIncreaseDefaultTLBEntries:chv,bdw,skl,bxt */ 2144 + if (IS_BROADWELL(dev)) 2145 + I915_WRITE(GEN8_L3_LRA_1_GPGPU, GEN8_L3_LRA_1_GPGPU_DEFAULT_VALUE_BDW); 2146 + else if (IS_CHERRYVIEW(dev)) 2147 + I915_WRITE(GEN8_L3_LRA_1_GPGPU, GEN8_L3_LRA_1_GPGPU_DEFAULT_VALUE_CHV); 2148 + else if (IS_SKYLAKE(dev)) 2149 + I915_WRITE(GEN8_L3_LRA_1_GPGPU, GEN9_L3_LRA_1_GPGPU_DEFAULT_VALUE_SKL); 2150 + else if (IS_BROXTON(dev)) 2151 + I915_WRITE(GEN8_L3_LRA_1_GPGPU, GEN9_L3_LRA_1_GPGPU_DEFAULT_VALUE_BXT); 2152 + } 2153 + 2135 2154 int i915_ppgtt_init(struct drm_device *dev, struct i915_hw_ppgtt *ppgtt) 2136 2155 { 2137 2156 struct drm_i915_private *dev_priv = dev->dev_private; ··· 2167 2148 2168 2149 int i915_ppgtt_init_hw(struct drm_device *dev) 2169 2150 { 2151 + gtt_write_workarounds(dev); 2152 + 2170 2153 /* In the case of execlists, PPGTT is enabled by the context descriptor 2171 2154 * and the PDPs are contained within the context itself. We don't 2172 2155 * need to do anything here. */ ··· 2830 2809 ppgtt->base.cleanup(&ppgtt->base); 2831 2810 } 2832 2811 2812 + i915_gem_cleanup_stolen(dev); 2813 + 2833 2814 if (drm_mm_initialized(&vm->mm)) { 2834 2815 if (intel_vgpu_active(dev)) 2835 2816 intel_vgt_deballoon(); ··· 3204 3181 if (ret) 3205 3182 return ret; 3206 3183 3184 + /* 3185 + * Initialise stolen early so that we may reserve preallocated 3186 + * objects for the BIOS to KMS transition. 3187 + */ 3188 + ret = i915_gem_init_stolen(dev); 3189 + if (ret) 3190 + goto out_gtt_cleanup; 3191 + 3207 3192 /* GMADR is the PCI mmio aperture into the global GTT. */ 3208 3193 DRM_INFO("Memory usable by graphics device = %lluM\n", 3209 3194 gtt->base.total >> 20); ··· 3231 3200 DRM_DEBUG_DRIVER("ppgtt mode: %i\n", i915.enable_ppgtt); 3232 3201 3233 3202 return 0; 3203 + 3204 + out_gtt_cleanup: 3205 + gtt->base.cleanup(&dev_priv->gtt.base); 3206 + 3207 + return ret; 3234 3208 } 3235 3209 3236 3210 void i915_gem_restore_gtt_mappings(struct drm_device *dev) ··· 3369 3333 static struct scatterlist * 3370 3334 rotate_pages(const dma_addr_t *in, unsigned int offset, 3371 3335 unsigned int width, unsigned int height, 3336 + unsigned int stride, 3372 3337 struct sg_table *st, struct scatterlist *sg) 3373 3338 { 3374 3339 unsigned int column, row; ··· 3381 3344 } 3382 3345 3383 3346 for (column = 0; column < width; column++) { 3384 - src_idx = width * (height - 1) + column; 3347 + src_idx = stride * (height - 1) + column; 3385 3348 for (row = 0; row < height; row++) { 3386 3349 st->nents++; 3387 3350 /* We don't need the pages, but need to initialize ··· 3392 3355 sg_dma_address(sg) = in[offset + src_idx]; 3393 3356 sg_dma_len(sg) = PAGE_SIZE; 3394 3357 sg = sg_next(sg); 3395 - src_idx -= width; 3358 + src_idx -= stride; 3396 3359 } 3397 3360 } 3398 3361 ··· 3400 3363 } 3401 3364 3402 3365 static struct sg_table * 3403 - intel_rotate_fb_obj_pages(struct i915_ggtt_view *ggtt_view, 3366 + intel_rotate_fb_obj_pages(struct intel_rotation_info *rot_info, 3404 3367 struct drm_i915_gem_object *obj) 3405 3368 { 3406 - struct intel_rotation_info *rot_info = &ggtt_view->params.rotation_info; 3407 3369 unsigned int size_pages = rot_info->size >> PAGE_SHIFT; 3408 3370 unsigned int size_pages_uv; 3409 3371 struct sg_page_iter sg_iter; ··· 3444 3408 /* Rotate the pages. */ 3445 3409 sg = rotate_pages(page_addr_list, 0, 3446 3410 rot_info->width_pages, rot_info->height_pages, 3411 + rot_info->width_pages, 3447 3412 st, NULL); 3448 3413 3449 3414 /* Append the UV plane if NV12. */ ··· 3460 3423 rotate_pages(page_addr_list, uv_start_page, 3461 3424 rot_info->width_pages_uv, 3462 3425 rot_info->height_pages_uv, 3426 + rot_info->width_pages_uv, 3463 3427 st, sg); 3464 3428 } 3465 3429 ··· 3542 3504 vma->ggtt_view.pages = vma->obj->pages; 3543 3505 else if (vma->ggtt_view.type == I915_GGTT_VIEW_ROTATED) 3544 3506 vma->ggtt_view.pages = 3545 - intel_rotate_fb_obj_pages(&vma->ggtt_view, vma->obj); 3507 + intel_rotate_fb_obj_pages(&vma->ggtt_view.params.rotated, vma->obj); 3546 3508 else if (vma->ggtt_view.type == I915_GGTT_VIEW_PARTIAL) 3547 3509 vma->ggtt_view.pages = 3548 3510 intel_partial_pages(&vma->ggtt_view, vma->obj); ··· 3636 3598 if (view->type == I915_GGTT_VIEW_NORMAL) { 3637 3599 return obj->base.size; 3638 3600 } else if (view->type == I915_GGTT_VIEW_ROTATED) { 3639 - return view->params.rotation_info.size; 3601 + return view->params.rotated.size; 3640 3602 } else if (view->type == I915_GGTT_VIEW_PARTIAL) { 3641 3603 return view->params.partial.size << PAGE_SHIFT; 3642 3604 } else {
+3 -1
drivers/gpu/drm/i915/i915_gem_gtt.h
··· 155 155 u64 offset; 156 156 unsigned int size; 157 157 } partial; 158 - struct intel_rotation_info rotation_info; 158 + struct intel_rotation_info rotated; 159 159 } params; 160 160 161 161 struct sg_table *pages; ··· 342 342 343 343 size_t stolen_size; /* Total size of stolen memory */ 344 344 size_t stolen_usable_size; /* Total size minus BIOS reserved */ 345 + size_t stolen_reserved_base; 346 + size_t stolen_reserved_size; 345 347 u64 mappable_end; /* End offset that we can CPU map */ 346 348 struct io_mapping *mappable; /* Mapping to our CPU mappable region */ 347 349 phys_addr_t mappable_base; /* PA of our GMADR */
+14 -2
drivers/gpu/drm/i915/i915_gem_shrinker.c
··· 367 367 dev_priv->mm.shrinker.scan_objects = i915_gem_shrinker_scan; 368 368 dev_priv->mm.shrinker.count_objects = i915_gem_shrinker_count; 369 369 dev_priv->mm.shrinker.seeks = DEFAULT_SEEKS; 370 - register_shrinker(&dev_priv->mm.shrinker); 370 + WARN_ON(register_shrinker(&dev_priv->mm.shrinker)); 371 371 372 372 dev_priv->mm.oom_notifier.notifier_call = i915_gem_shrinker_oom; 373 - register_oom_notifier(&dev_priv->mm.oom_notifier); 373 + WARN_ON(register_oom_notifier(&dev_priv->mm.oom_notifier)); 374 + } 375 + 376 + /** 377 + * i915_gem_shrinker_cleanup - Clean up i915 shrinker 378 + * @dev_priv: i915 device 379 + * 380 + * This function unregisters the i915 shrinker and OOM handler. 381 + */ 382 + void i915_gem_shrinker_cleanup(struct drm_i915_private *dev_priv) 383 + { 384 + WARN_ON(unregister_oom_notifier(&dev_priv->mm.oom_notifier)); 385 + unregister_shrinker(&dev_priv->mm.shrinker); 374 386 }
+3
drivers/gpu/drm/i915/i915_gem_stolen.c
··· 458 458 return 0; 459 459 } 460 460 461 + dev_priv->gtt.stolen_reserved_base = reserved_base; 462 + dev_priv->gtt.stolen_reserved_size = reserved_size; 463 + 461 464 /* It is possible for the reserved area to end before the end of stolen 462 465 * memory, so just consider the start. */ 463 466 reserved_total = stolen_top - reserved_base;
+51 -131
drivers/gpu/drm/i915/i915_gem_userptr.c
··· 49 49 struct hlist_node node; 50 50 struct mmu_notifier mn; 51 51 struct rb_root objects; 52 - struct list_head linear; 53 - bool has_linear; 54 52 }; 55 53 56 54 struct i915_mmu_object { 57 55 struct i915_mmu_notifier *mn; 56 + struct drm_i915_gem_object *obj; 58 57 struct interval_tree_node it; 59 58 struct list_head link; 60 - struct drm_i915_gem_object *obj; 61 59 struct work_struct work; 62 - bool active; 63 - bool is_linear; 60 + bool attached; 64 61 }; 65 62 66 - static void __cancel_userptr__worker(struct work_struct *work) 63 + static void cancel_userptr(struct work_struct *work) 67 64 { 68 65 struct i915_mmu_object *mo = container_of(work, typeof(*mo), work); 69 66 struct drm_i915_gem_object *obj = mo->obj; ··· 91 94 mutex_unlock(&dev->struct_mutex); 92 95 } 93 96 94 - static unsigned long cancel_userptr(struct i915_mmu_object *mo) 97 + static void add_object(struct i915_mmu_object *mo) 95 98 { 96 - unsigned long end = mo->obj->userptr.ptr + mo->obj->base.size; 99 + if (mo->attached) 100 + return; 97 101 98 - /* The mmu_object is released late when destroying the 99 - * GEM object so it is entirely possible to gain a 100 - * reference on an object in the process of being freed 101 - * since our serialisation is via the spinlock and not 102 - * the struct_mutex - and consequently use it after it 103 - * is freed and then double free it. 104 - */ 105 - if (mo->active && kref_get_unless_zero(&mo->obj->base.refcount)) { 106 - schedule_work(&mo->work); 107 - /* only schedule one work packet to avoid the refleak */ 108 - mo->active = false; 109 - } 102 + interval_tree_insert(&mo->it, &mo->mn->objects); 103 + mo->attached = true; 104 + } 110 105 111 - return end; 106 + static void del_object(struct i915_mmu_object *mo) 107 + { 108 + if (!mo->attached) 109 + return; 110 + 111 + interval_tree_remove(&mo->it, &mo->mn->objects); 112 + mo->attached = false; 112 113 } 113 114 114 115 static void i915_gem_userptr_mn_invalidate_range_start(struct mmu_notifier *_mn, ··· 117 122 struct i915_mmu_notifier *mn = 118 123 container_of(_mn, struct i915_mmu_notifier, mn); 119 124 struct i915_mmu_object *mo; 125 + struct interval_tree_node *it; 126 + LIST_HEAD(cancelled); 127 + 128 + if (RB_EMPTY_ROOT(&mn->objects)) 129 + return; 120 130 121 131 /* interval ranges are inclusive, but invalidate range is exclusive */ 122 132 end--; 123 133 124 134 spin_lock(&mn->lock); 125 - if (mn->has_linear) { 126 - list_for_each_entry(mo, &mn->linear, link) { 127 - if (mo->it.last < start || mo->it.start > end) 128 - continue; 135 + it = interval_tree_iter_first(&mn->objects, start, end); 136 + while (it) { 137 + /* The mmu_object is released late when destroying the 138 + * GEM object so it is entirely possible to gain a 139 + * reference on an object in the process of being freed 140 + * since our serialisation is via the spinlock and not 141 + * the struct_mutex - and consequently use it after it 142 + * is freed and then double free it. To prevent that 143 + * use-after-free we only acquire a reference on the 144 + * object if it is not in the process of being destroyed. 145 + */ 146 + mo = container_of(it, struct i915_mmu_object, it); 147 + if (kref_get_unless_zero(&mo->obj->base.refcount)) 148 + schedule_work(&mo->work); 129 149 130 - cancel_userptr(mo); 131 - } 132 - } else { 133 - struct interval_tree_node *it; 134 - 135 - it = interval_tree_iter_first(&mn->objects, start, end); 136 - while (it) { 137 - mo = container_of(it, struct i915_mmu_object, it); 138 - start = cancel_userptr(mo); 139 - it = interval_tree_iter_next(it, start, end); 140 - } 150 + list_add(&mo->link, &cancelled); 151 + it = interval_tree_iter_next(it, start, end); 141 152 } 153 + list_for_each_entry(mo, &cancelled, link) 154 + del_object(mo); 142 155 spin_unlock(&mn->lock); 143 156 } 144 157 ··· 167 164 spin_lock_init(&mn->lock); 168 165 mn->mn.ops = &i915_gem_userptr_notifier; 169 166 mn->objects = RB_ROOT; 170 - INIT_LIST_HEAD(&mn->linear); 171 - mn->has_linear = false; 172 167 173 168 /* Protected by mmap_sem (write-lock) */ 174 169 ret = __mmu_notifier_register(&mn->mn, mm); ··· 178 177 return mn; 179 178 } 180 179 181 - static int 182 - i915_mmu_notifier_add(struct drm_device *dev, 183 - struct i915_mmu_notifier *mn, 184 - struct i915_mmu_object *mo) 185 - { 186 - struct interval_tree_node *it; 187 - int ret = 0; 188 - 189 - /* By this point we have already done a lot of expensive setup that 190 - * we do not want to repeat just because the caller (e.g. X) has a 191 - * signal pending (and partly because of that expensive setup, X 192 - * using an interrupt timer is likely to get stuck in an EINTR loop). 193 - */ 194 - mutex_lock(&dev->struct_mutex); 195 - 196 - /* Make sure we drop the final active reference (and thereby 197 - * remove the objects from the interval tree) before we do 198 - * the check for overlapping objects. 199 - */ 200 - i915_gem_retire_requests(dev); 201 - 202 - spin_lock(&mn->lock); 203 - it = interval_tree_iter_first(&mn->objects, 204 - mo->it.start, mo->it.last); 205 - if (it) { 206 - struct drm_i915_gem_object *obj; 207 - 208 - /* We only need to check the first object in the range as it 209 - * either has cancelled gup work queued and we need to 210 - * return back to the user to give time for the gup-workers 211 - * to flush their object references upon which the object will 212 - * be removed from the interval-tree, or the the range is 213 - * still in use by another client and the overlap is invalid. 214 - * 215 - * If we do have an overlap, we cannot use the interval tree 216 - * for fast range invalidation. 217 - */ 218 - 219 - obj = container_of(it, struct i915_mmu_object, it)->obj; 220 - if (!obj->userptr.workers) 221 - mn->has_linear = mo->is_linear = true; 222 - else 223 - ret = -EAGAIN; 224 - } else 225 - interval_tree_insert(&mo->it, &mn->objects); 226 - 227 - if (ret == 0) 228 - list_add(&mo->link, &mn->linear); 229 - 230 - spin_unlock(&mn->lock); 231 - mutex_unlock(&dev->struct_mutex); 232 - 233 - return ret; 234 - } 235 - 236 - static bool i915_mmu_notifier_has_linear(struct i915_mmu_notifier *mn) 237 - { 238 - struct i915_mmu_object *mo; 239 - 240 - list_for_each_entry(mo, &mn->linear, link) 241 - if (mo->is_linear) 242 - return true; 243 - 244 - return false; 245 - } 246 - 247 - static void 248 - i915_mmu_notifier_del(struct i915_mmu_notifier *mn, 249 - struct i915_mmu_object *mo) 250 - { 251 - spin_lock(&mn->lock); 252 - list_del(&mo->link); 253 - if (mo->is_linear) 254 - mn->has_linear = i915_mmu_notifier_has_linear(mn); 255 - else 256 - interval_tree_remove(&mo->it, &mn->objects); 257 - spin_unlock(&mn->lock); 258 - } 259 - 260 180 static void 261 181 i915_gem_userptr_release__mmu_notifier(struct drm_i915_gem_object *obj) 262 182 { ··· 187 265 if (mo == NULL) 188 266 return; 189 267 190 - i915_mmu_notifier_del(mo->mn, mo); 268 + spin_lock(&mo->mn->lock); 269 + del_object(mo); 270 + spin_unlock(&mo->mn->lock); 191 271 kfree(mo); 192 272 193 273 obj->userptr.mmu_object = NULL; ··· 223 299 { 224 300 struct i915_mmu_notifier *mn; 225 301 struct i915_mmu_object *mo; 226 - int ret; 227 302 228 303 if (flags & I915_USERPTR_UNSYNCHRONIZED) 229 304 return capable(CAP_SYS_ADMIN) ? 0 : -EPERM; ··· 239 316 return -ENOMEM; 240 317 241 318 mo->mn = mn; 242 - mo->it.start = obj->userptr.ptr; 243 - mo->it.last = mo->it.start + obj->base.size - 1; 244 319 mo->obj = obj; 245 - INIT_WORK(&mo->work, __cancel_userptr__worker); 246 - 247 - ret = i915_mmu_notifier_add(obj->base.dev, mn, mo); 248 - if (ret) { 249 - kfree(mo); 250 - return ret; 251 - } 320 + mo->it.start = obj->userptr.ptr; 321 + mo->it.last = obj->userptr.ptr + obj->base.size - 1; 322 + INIT_WORK(&mo->work, cancel_userptr); 252 323 253 324 obj->userptr.mmu_object = mo; 254 325 return 0; ··· 469 552 /* In order to serialise get_pages with an outstanding 470 553 * cancel_userptr, we must drop the struct_mutex and try again. 471 554 */ 472 - if (!value || !work_pending(&obj->userptr.mmu_object->work)) 473 - obj->userptr.mmu_object->active = value; 555 + if (!value) 556 + del_object(obj->userptr.mmu_object); 557 + else if (!work_pending(&obj->userptr.mmu_object->work)) 558 + add_object(obj->userptr.mmu_object); 474 559 else 475 560 ret = -EAGAIN; 476 561 spin_unlock(&obj->userptr.mmu_object->mn->lock); ··· 708 789 } 709 790 710 791 static const struct drm_i915_gem_object_ops i915_gem_userptr_ops = { 711 - .dmabuf_export = i915_gem_userptr_dmabuf_export, 792 + .flags = I915_GEM_OBJECT_HAS_STRUCT_PAGE, 712 793 .get_pages = i915_gem_userptr_get_pages, 713 794 .put_pages = i915_gem_userptr_put_pages, 795 + .dmabuf_export = i915_gem_userptr_dmabuf_export, 714 796 .release = i915_gem_userptr_release, 715 797 }; 716 798
+4
drivers/gpu/drm/i915/i915_gpu_error.c
··· 365 365 err_printf(m, "Reset count: %u\n", error->reset_count); 366 366 err_printf(m, "Suspend count: %u\n", error->suspend_count); 367 367 err_printf(m, "PCI ID: 0x%04x\n", dev->pdev->device); 368 + err_printf(m, "PCI Revision: 0x%02x\n", dev->pdev->revision); 369 + err_printf(m, "PCI Subsystem: %04x:%04x\n", 370 + dev->pdev->subsystem_vendor, 371 + dev->pdev->subsystem_device); 368 372 err_printf(m, "IOMMU enabled?: %d\n", error->iommu); 369 373 370 374 if (HAS_CSR(dev)) {
+18 -47
drivers/gpu/drm/i915/i915_guc_submission.c
··· 376 376 static void guc_init_ctx_desc(struct intel_guc *guc, 377 377 struct i915_guc_client *client) 378 378 { 379 + struct drm_i915_private *dev_priv = guc_to_i915(guc); 380 + struct intel_engine_cs *ring; 379 381 struct intel_context *ctx = client->owner; 380 382 struct guc_context_desc desc; 381 383 struct sg_table *sg; ··· 390 388 desc.priority = client->priority; 391 389 desc.db_id = client->doorbell_id; 392 390 393 - for (i = 0; i < I915_NUM_RINGS; i++) { 394 - struct guc_execlist_context *lrc = &desc.lrc[i]; 395 - struct intel_ringbuffer *ringbuf = ctx->engine[i].ringbuf; 396 - struct intel_engine_cs *ring; 391 + for_each_ring(ring, dev_priv, i) { 392 + struct guc_execlist_context *lrc = &desc.lrc[ring->guc_id]; 397 393 struct drm_i915_gem_object *obj; 398 394 uint64_t ctx_desc; 399 395 ··· 406 406 if (!obj) 407 407 break; /* XXX: continue? */ 408 408 409 - ring = ringbuf->ring; 410 409 ctx_desc = intel_lr_context_descriptor(ctx, ring); 411 410 lrc->context_desc = (u32)ctx_desc; 412 411 ··· 413 414 lrc->ring_lcra = i915_gem_obj_ggtt_offset(obj) + 414 415 LRC_STATE_PN * PAGE_SIZE; 415 416 lrc->context_id = (client->ctx_index << GUC_ELC_CTXID_OFFSET) | 416 - (ring->id << GUC_ELC_ENGINE_OFFSET); 417 + (ring->guc_id << GUC_ELC_ENGINE_OFFSET); 417 418 418 - obj = ringbuf->obj; 419 + obj = ctx->engine[i].ringbuf->obj; 419 420 420 421 lrc->ring_begin = i915_gem_obj_ggtt_offset(obj); 421 422 lrc->ring_end = lrc->ring_begin + obj->base.size - 1; 422 423 lrc->ring_next_free_location = lrc->ring_begin; 423 424 lrc->ring_current_tail_pointer_value = 0; 424 425 425 - desc.engines_used |= (1 << ring->id); 426 + desc.engines_used |= (1 << ring->guc_id); 426 427 } 427 428 428 429 WARN_ON(desc.engines_used == 0); ··· 509 510 static int guc_add_workqueue_item(struct i915_guc_client *gc, 510 511 struct drm_i915_gem_request *rq) 511 512 { 512 - enum intel_ring_id ring_id = rq->ring->id; 513 513 struct guc_wq_item *wqi; 514 514 void *base; 515 515 u32 tail, wq_len, wq_off, space; ··· 542 544 wq_len = sizeof(struct guc_wq_item) / sizeof(u32) - 1; 543 545 wqi->header = WQ_TYPE_INORDER | 544 546 (wq_len << WQ_LEN_SHIFT) | 545 - (ring_id << WQ_TARGET_SHIFT) | 547 + (rq->ring->guc_id << WQ_TARGET_SHIFT) | 546 548 WQ_NO_WCFLUSH_WAIT; 547 549 548 550 /* The GuC wants only the low-order word of the context descriptor */ ··· 558 560 return 0; 559 561 } 560 562 561 - #define CTX_RING_BUFFER_START 0x08 562 - 563 - /* Update the ringbuffer pointer in a saved context image */ 564 - static void lr_context_update(struct drm_i915_gem_request *rq) 565 - { 566 - enum intel_ring_id ring_id = rq->ring->id; 567 - struct drm_i915_gem_object *ctx_obj = rq->ctx->engine[ring_id].state; 568 - struct drm_i915_gem_object *rb_obj = rq->ringbuf->obj; 569 - struct page *page; 570 - uint32_t *reg_state; 571 - 572 - BUG_ON(!ctx_obj); 573 - WARN_ON(!i915_gem_obj_is_pinned(ctx_obj)); 574 - WARN_ON(!i915_gem_obj_is_pinned(rb_obj)); 575 - 576 - page = i915_gem_object_get_dirty_page(ctx_obj, LRC_STATE_PN); 577 - reg_state = kmap_atomic(page); 578 - 579 - reg_state[CTX_RING_BUFFER_START+1] = i915_gem_obj_ggtt_offset(rb_obj); 580 - 581 - kunmap_atomic(reg_state); 582 - } 583 - 584 563 /** 585 564 * i915_guc_submit() - Submit commands through GuC 586 565 * @client: the guc client where commands will go through ··· 569 594 struct drm_i915_gem_request *rq) 570 595 { 571 596 struct intel_guc *guc = client->guc; 572 - enum intel_ring_id ring_id = rq->ring->id; 597 + unsigned int engine_id = rq->ring->guc_id; 573 598 int q_ret, b_ret; 574 - 575 - /* Need this because of the deferred pin ctx and ring */ 576 - /* Shall we move this right after ring is pinned? */ 577 - lr_context_update(rq); 578 599 579 600 q_ret = guc_add_workqueue_item(client, rq); 580 601 if (q_ret == 0) 581 602 b_ret = guc_ring_doorbell(client); 582 603 583 - client->submissions[ring_id] += 1; 604 + client->submissions[engine_id] += 1; 584 605 if (q_ret) { 585 606 client->q_fail += 1; 586 607 client->retcode = q_ret; ··· 586 615 } else { 587 616 client->retcode = 0; 588 617 } 589 - guc->submissions[ring_id] += 1; 590 - guc->last_seqno[ring_id] = rq->seqno; 618 + guc->submissions[engine_id] += 1; 619 + guc->last_seqno[engine_id] = rq->seqno; 591 620 592 621 return q_ret; 593 622 } ··· 819 848 policies->max_num_work_items = POLICY_MAX_NUM_WI; 820 849 821 850 for (p = 0; p < GUC_CTX_PRIORITY_NUM; p++) { 822 - for (i = 0; i < I915_NUM_RINGS; i++) { 851 + for (i = GUC_RENDER_ENGINE; i < GUC_MAX_ENGINES_NUM; i++) { 823 852 policy = &policies->policy[p][i]; 824 853 825 854 policy->execution_quantum = 1000000; ··· 871 900 ads->golden_context_lrca = ring->status_page.gfx_addr; 872 901 873 902 for_each_ring(ring, dev_priv, i) 874 - ads->eng_state_size[i] = intel_lr_context_size(ring); 903 + ads->eng_state_size[ring->guc_id] = intel_lr_context_size(ring); 875 904 876 905 /* GuC scheduling policies */ 877 906 policies = (void *)ads + sizeof(struct guc_ads); ··· 883 912 /* MMIO reg state */ 884 913 reg_state = (void *)policies + sizeof(struct guc_policies); 885 914 886 - for (i = 0; i < I915_NUM_RINGS; i++) { 887 - reg_state->mmio_white_list[i].mmio_start = 888 - dev_priv->ring[i].mmio_base + GUC_MMIO_WHITE_LIST_START; 915 + for_each_ring(ring, dev_priv, i) { 916 + reg_state->mmio_white_list[ring->guc_id].mmio_start = 917 + ring->mmio_base + GUC_MMIO_WHITE_LIST_START; 889 918 890 919 /* Nothing to be saved or restored for now. */ 891 - reg_state->mmio_white_list[i].count = 0; 920 + reg_state->mmio_white_list[ring->guc_id].count = 0; 892 921 } 893 922 894 923 ads->reg_state_addr = ads->scheduler_policies +
+2 -1
drivers/gpu/drm/i915/i915_params.c
··· 127 127 "(-1=auto [default], 0=disabled, 1=enabled)"); 128 128 129 129 module_param_named_unsafe(enable_psr, i915.enable_psr, int, 0600); 130 - MODULE_PARM_DESC(enable_psr, "Enable PSR (default: false)"); 130 + MODULE_PARM_DESC(enable_psr, "Enable PSR " 131 + "(0=disabled [default], 1=enabled - link mode chosen per-platform, 2=force link-standby mode, 3=force link-off mode)"); 131 132 132 133 module_param_named_unsafe(preliminary_hw_support, i915.preliminary_hw_support, int, 0600); 133 134 MODULE_PARM_DESC(preliminary_hw_support,
+41 -7
drivers/gpu/drm/i915/i915_reg.h
··· 610 610 #define IOSF_BYTE_ENABLES_SHIFT 4 611 611 #define IOSF_BAR_SHIFT 1 612 612 #define IOSF_SB_BUSY (1<<0) 613 - #define IOSF_PORT_BUNIT 0x3 614 - #define IOSF_PORT_PUNIT 0x4 613 + #define IOSF_PORT_BUNIT 0x03 614 + #define IOSF_PORT_PUNIT 0x04 615 615 #define IOSF_PORT_NC 0x11 616 616 #define IOSF_PORT_DPIO 0x12 617 - #define IOSF_PORT_DPIO_2 0x1a 618 617 #define IOSF_PORT_GPIO_NC 0x13 619 618 #define IOSF_PORT_CCK 0x14 620 - #define IOSF_PORT_CCU 0xA9 621 - #define IOSF_PORT_GPS_CORE 0x48 622 - #define IOSF_PORT_FLISDSI 0x1B 619 + #define IOSF_PORT_DPIO_2 0x1a 620 + #define IOSF_PORT_FLISDSI 0x1b 621 + #define IOSF_PORT_GPIO_SC 0x48 622 + #define IOSF_PORT_GPIO_SUS 0xa8 623 + #define IOSF_PORT_CCU 0xa9 623 624 #define VLV_IOSF_DATA _MMIO(VLV_DISPLAY_BASE + 0x2104) 624 625 #define VLV_IOSF_ADDR _MMIO(VLV_DISPLAY_BASE + 0x2108) 625 626 ··· 1635 1634 #define RING_WAIT_I8XX (1<<0) /* gen2, PRBx_HEAD */ 1636 1635 #define RING_WAIT (1<<11) /* gen3+, PRBx_CTL */ 1637 1636 #define RING_WAIT_SEMAPHORE (1<<10) /* gen6+ */ 1637 + 1638 + #define RING_FORCE_TO_NONPRIV(base, i) _MMIO(((base)+0x4D0) + (i)*4) 1639 + #define RING_MAX_NONPRIV_SLOTS 12 1638 1640 1639 1641 #define GEN7_TLB_RD_ADDR _MMIO(0x4700) 1640 1642 ··· 5949 5945 #define ILK_INTERNAL_GRAPHICS_DISABLE (1 << 31) 5950 5946 #define ILK_INTERNAL_DISPLAY_DISABLE (1 << 30) 5951 5947 #define ILK_DISPLAY_DEBUG_DISABLE (1 << 29) 5948 + #define IVB_PIPE_C_DISABLE (1 << 28) 5952 5949 #define ILK_HDCP_DISABLE (1 << 25) 5953 5950 #define ILK_eDP_A_DISABLE (1 << 24) 5954 5951 #define HSW_CDCLK_LIMIT (1 << 24) ··· 5996 5991 #define SKL_DFSM_CDCLK_LIMIT_540 (1 << 23) 5997 5992 #define SKL_DFSM_CDCLK_LIMIT_450 (2 << 23) 5998 5993 #define SKL_DFSM_CDCLK_LIMIT_337_5 (3 << 23) 5994 + #define SKL_DFSM_PIPE_A_DISABLE (1 << 30) 5995 + #define SKL_DFSM_PIPE_B_DISABLE (1 << 21) 5996 + #define SKL_DFSM_PIPE_C_DISABLE (1 << 28) 5997 + 5998 + #define GEN7_FF_SLICE_CS_CHICKEN1 _MMIO(0x20e0) 5999 + #define GEN9_FFSC_PERCTX_PREEMPT_CTRL (1<<14) 5999 6000 6000 6001 #define FF_SLICE_CS_CHICKEN2 _MMIO(0x20e4) 6001 6002 #define GEN9_TSG_BARRIER_ACK_DISABLE (1<<8) 6003 + 6004 + #define GEN9_CS_DEBUG_MODE1 _MMIO(0x20ec) 6005 + #define GEN8_CS_CHICKEN1 _MMIO(0x2580) 6002 6006 6003 6007 /* GEN7 chicken */ 6004 6008 #define GEN7_COMMON_SLICE_CHICKEN1 _MMIO(0x7010) ··· 6053 6039 #define HDC_FORCE_CONTEXT_SAVE_RESTORE_NON_COHERENT (1<<5) 6054 6040 #define HDC_FORCE_NON_COHERENT (1<<4) 6055 6041 #define HDC_BARRIER_PERFORMANCE_DISABLE (1<<10) 6042 + 6043 + #define GEN8_HDC_CHICKEN1 _MMIO(0x7304) 6056 6044 6057 6045 /* GEN9 chicken */ 6058 6046 #define SLICE_ECO_CHICKEN0 _MMIO(0x7308) ··· 6786 6770 6787 6771 #define VLV_PMWGICZ _MMIO(0x1300a4) 6788 6772 6773 + #define RC6_LOCATION _MMIO(0xD40) 6774 + #define RC6_CTX_IN_DRAM (1 << 0) 6775 + #define RC6_CTX_BASE _MMIO(0xD48) 6776 + #define RC6_CTX_BASE_MASK 0xFFFFFFF0 6777 + #define PWRCTX_MAXCNT_RCSUNIT _MMIO(0x2054) 6778 + #define PWRCTX_MAXCNT_VCSUNIT0 _MMIO(0x12054) 6779 + #define PWRCTX_MAXCNT_BCSUNIT _MMIO(0x22054) 6780 + #define PWRCTX_MAXCNT_VECSUNIT _MMIO(0x1A054) 6781 + #define PWRCTX_MAXCNT_VCSUNIT1 _MMIO(0x1C054) 6782 + #define IDLE_TIME_MASK 0xFFFFF 6789 6783 #define FORCEWAKE _MMIO(0xA18C) 6790 6784 #define FORCEWAKE_VLV _MMIO(0x1300b0) 6791 6785 #define FORCEWAKE_ACK_VLV _MMIO(0x1300b4) ··· 6934 6908 #define GEN6_RPDEUC _MMIO(0xA084) 6935 6909 #define GEN6_RPDEUCSW _MMIO(0xA088) 6936 6910 #define GEN6_RC_STATE _MMIO(0xA094) 6911 + #define RC6_STATE (1 << 18) 6937 6912 #define GEN6_RC1_WAKE_RATE_LIMIT _MMIO(0xA098) 6938 6913 #define GEN6_RC6_WAKE_RATE_LIMIT _MMIO(0xA09C) 6939 6914 #define GEN6_RC6pp_WAKE_RATE_LIMIT _MMIO(0xA0A0) ··· 7546 7519 #define DPLL_CFGCR2_PDIV_7 (4<<2) 7547 7520 #define DPLL_CFGCR2_CENTRAL_FREQ_MASK (3) 7548 7521 7549 - #define DPLL_CFGCR1(id) _MMIO_PIPE((id) - SKL_DPLL1, _DPLL1_CFGCR1, _DPLL2_CFGCR2) 7522 + #define DPLL_CFGCR1(id) _MMIO_PIPE((id) - SKL_DPLL1, _DPLL1_CFGCR1, _DPLL2_CFGCR1) 7550 7523 #define DPLL_CFGCR2(id) _MMIO_PIPE((id) - SKL_DPLL1, _DPLL1_CFGCR2, _DPLL2_CFGCR2) 7551 7524 7552 7525 /* BXT display engine PLL */ ··· 8185 8158 #define GEN9_MFX1_MOCS(i) _MMIO(0xca00 + (i) * 4) /* Media 1 MOCS registers */ 8186 8159 #define GEN9_VEBOX_MOCS(i) _MMIO(0xcb00 + (i) * 4) /* Video MOCS registers */ 8187 8160 #define GEN9_BLT_MOCS(i) _MMIO(0xcc00 + (i) * 4) /* Blitter MOCS registers */ 8161 + 8162 + /* gamt regs */ 8163 + #define GEN8_L3_LRA_1_GPGPU _MMIO(0x4dd4) 8164 + #define GEN8_L3_LRA_1_GPGPU_DEFAULT_VALUE_BDW 0x67F1427F /* max/min for LRA1/2 */ 8165 + #define GEN8_L3_LRA_1_GPGPU_DEFAULT_VALUE_CHV 0x5FF101FF /* max/min for LRA1/2 */ 8166 + #define GEN9_L3_LRA_1_GPGPU_DEFAULT_VALUE_SKL 0x67F1427F /* " " */ 8167 + #define GEN9_L3_LRA_1_GPGPU_DEFAULT_VALUE_BXT 0x5FF101FF /* " " */ 8188 8168 8189 8169 #endif /* _I915_REG_H_ */
+3 -3
drivers/gpu/drm/i915/i915_suspend.c
··· 49 49 dev_priv->regfile.savePP_ON_DELAYS = I915_READ(PCH_PP_ON_DELAYS); 50 50 dev_priv->regfile.savePP_OFF_DELAYS = I915_READ(PCH_PP_OFF_DELAYS); 51 51 dev_priv->regfile.savePP_DIVISOR = I915_READ(PCH_PP_DIVISOR); 52 - } else if (!IS_VALLEYVIEW(dev) && !IS_CHERRYVIEW(dev)) { 52 + } else if (INTEL_INFO(dev)->gen <= 4) { 53 53 dev_priv->regfile.savePP_CONTROL = I915_READ(PP_CONTROL); 54 54 dev_priv->regfile.savePP_ON_DELAYS = I915_READ(PP_ON_DELAYS); 55 55 dev_priv->regfile.savePP_OFF_DELAYS = I915_READ(PP_OFF_DELAYS); ··· 84 84 I915_WRITE(PCH_PP_OFF_DELAYS, dev_priv->regfile.savePP_OFF_DELAYS); 85 85 I915_WRITE(PCH_PP_DIVISOR, dev_priv->regfile.savePP_DIVISOR); 86 86 I915_WRITE(PCH_PP_CONTROL, dev_priv->regfile.savePP_CONTROL); 87 - } else if (!IS_VALLEYVIEW(dev) && !IS_CHERRYVIEW(dev)) { 87 + } else if (INTEL_INFO(dev)->gen <= 4) { 88 88 I915_WRITE(PP_ON_DELAYS, dev_priv->regfile.savePP_ON_DELAYS); 89 89 I915_WRITE(PP_OFF_DELAYS, dev_priv->regfile.savePP_OFF_DELAYS); 90 90 I915_WRITE(PP_DIVISOR, dev_priv->regfile.savePP_DIVISOR); ··· 92 92 } 93 93 94 94 /* only restore FBC info on the platform that supports FBC*/ 95 - intel_fbc_disable(dev_priv); 95 + intel_fbc_global_disable(dev_priv); 96 96 97 97 /* restore FBC interval */ 98 98 if (HAS_FBC(dev) && INTEL_INFO(dev)->gen <= 4 && !IS_G4X(dev))
+4
drivers/gpu/drm/i915/intel_crt.c
··· 216 216 struct drm_display_mode *mode) 217 217 { 218 218 struct drm_device *dev = connector->dev; 219 + int max_dotclk = to_i915(dev)->max_dotclk_freq; 219 220 220 221 int max_clock = 0; 221 222 if (mode->flags & DRM_MODE_FLAG_DBLSCAN) ··· 230 229 else 231 230 max_clock = 400000; 232 231 if (mode->clock > max_clock) 232 + return MODE_CLOCK_HIGH; 233 + 234 + if (mode->clock > max_dotclk) 233 235 return MODE_CLOCK_HIGH; 234 236 235 237 /* The FDI receiver on LPT only supports 8bpc and only has 2 lanes. */
+2 -1
drivers/gpu/drm/i915/intel_csr.c
··· 179 179 static const struct stepping_info skl_stepping_info[] = { 180 180 {'A', '0'}, {'B', '0'}, {'C', '0'}, 181 181 {'D', '0'}, {'E', '0'}, {'F', '0'}, 182 - {'G', '0'}, {'H', '0'}, {'I', '0'} 182 + {'G', '0'}, {'H', '0'}, {'I', '0'}, 183 + {'J', '0'}, {'K', '0'} 183 184 }; 184 185 185 186 static const struct stepping_info bxt_stepping_info[] = {
+8 -3
drivers/gpu/drm/i915/intel_ddi.c
··· 1531 1531 DPLL_CFGCR2_KDIV(wrpll_params.kdiv) | 1532 1532 DPLL_CFGCR2_PDIV(wrpll_params.pdiv) | 1533 1533 wrpll_params.central_freq; 1534 - } else if (intel_encoder->type == INTEL_OUTPUT_DISPLAYPORT) { 1534 + } else if (intel_encoder->type == INTEL_OUTPUT_DISPLAYPORT || 1535 + intel_encoder->type == INTEL_OUTPUT_DP_MST) { 1535 1536 switch (crtc_state->port_clock / 2) { 1536 1537 case 81000: 1537 1538 ctrl1 |= DPLL_CTRL1_LINK_RATE(DPLL_CTRL1_LINK_RATE_810, 0); ··· 1546 1545 } 1547 1546 1548 1547 cfgcr1 = cfgcr2 = 0; 1549 - } else /* eDP */ 1548 + } else if (intel_encoder->type == INTEL_OUTPUT_EDP) { 1550 1549 return true; 1550 + } else 1551 + return false; 1551 1552 1552 1553 memset(&crtc_state->dpll_hw_state, 0, 1553 1554 sizeof(crtc_state->dpll_hw_state)); ··· 3284 3281 intel_dig_port->saved_port_bits = I915_READ(DDI_BUF_CTL(port)) & 3285 3282 (DDI_BUF_PORT_REVERSAL | 3286 3283 DDI_A_4_LANES); 3287 - intel_dig_port->max_lanes = max_lanes; 3288 3284 3289 3285 /* 3290 3286 * Bspec says that DDI_A_4_LANES is the only supported configuration ··· 3296 3294 if (!(intel_dig_port->saved_port_bits & DDI_A_4_LANES)) { 3297 3295 DRM_DEBUG_KMS("BXT BIOS forgot to set DDI_A_4_LANES for port A; fixing\n"); 3298 3296 intel_dig_port->saved_port_bits |= DDI_A_4_LANES; 3297 + max_lanes = 4; 3299 3298 } 3300 3299 } 3300 + 3301 + intel_dig_port->max_lanes = max_lanes; 3301 3302 3302 3303 intel_encoder->type = INTEL_OUTPUT_UNKNOWN; 3303 3304 intel_encoder->crtc_mask = (1 << 0) | (1 << 1) | (1 << 2);
+71 -93
drivers/gpu/drm/i915/intel_display.c
··· 2284 2284 const struct drm_plane_state *plane_state) 2285 2285 { 2286 2286 struct drm_i915_private *dev_priv = to_i915(fb->dev); 2287 - struct intel_rotation_info *info = &view->params.rotation_info; 2287 + struct intel_rotation_info *info = &view->params.rotated; 2288 2288 unsigned int tile_size, tile_width, tile_height, cpp; 2289 2289 2290 2290 *view = i915_ggtt_view_normal; ··· 2306 2306 tile_size = intel_tile_size(dev_priv); 2307 2307 2308 2308 cpp = drm_format_plane_cpp(fb->pixel_format, 0); 2309 - tile_width = intel_tile_width(dev_priv, cpp, fb->modifier[0]); 2309 + tile_width = intel_tile_width(dev_priv, fb->modifier[0], cpp); 2310 2310 tile_height = tile_size / tile_width; 2311 2311 2312 2312 info->width_pages = DIV_ROUND_UP(fb->pitches[0], tile_width); ··· 2448 2448 2449 2449 /* Computes the linear offset to the base tile and adjusts x, y. bytes per pixel 2450 2450 * is assumed to be a power-of-two. */ 2451 - unsigned long intel_compute_tile_offset(struct drm_i915_private *dev_priv, 2452 - int *x, int *y, 2453 - uint64_t fb_modifier, 2454 - unsigned int cpp, 2455 - unsigned int pitch) 2451 + u32 intel_compute_tile_offset(struct drm_i915_private *dev_priv, 2452 + int *x, int *y, 2453 + uint64_t fb_modifier, 2454 + unsigned int cpp, 2455 + unsigned int pitch) 2456 2456 { 2457 2457 if (fb_modifier != DRM_FORMAT_MOD_NONE) { 2458 2458 unsigned int tile_size, tile_width, tile_height; ··· 2706 2706 struct drm_framebuffer *fb = plane_state->base.fb; 2707 2707 struct drm_i915_gem_object *obj = intel_fb_obj(fb); 2708 2708 int plane = intel_crtc->plane; 2709 - unsigned long linear_offset; 2710 - int x = plane_state->src.x1 >> 16; 2711 - int y = plane_state->src.y1 >> 16; 2709 + u32 linear_offset; 2712 2710 u32 dspcntr; 2713 2711 i915_reg_t reg = DSPCNTR(plane); 2714 - int pixel_size; 2715 - 2716 - pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); 2712 + int cpp = drm_format_plane_cpp(fb->pixel_format, 0); 2713 + int x = plane_state->src.x1 >> 16; 2714 + int y = plane_state->src.y1 >> 16; 2717 2715 2718 2716 dspcntr = DISPPLANE_GAMMA_ENABLE; 2719 2717 ··· 2769 2771 if (IS_G4X(dev)) 2770 2772 dspcntr |= DISPPLANE_TRICKLE_FEED_DISABLE; 2771 2773 2772 - linear_offset = y * fb->pitches[0] + x * pixel_size; 2774 + linear_offset = y * fb->pitches[0] + x * cpp; 2773 2775 2774 2776 if (INTEL_INFO(dev)->gen >= 4) { 2775 2777 intel_crtc->dspaddr_offset = 2776 2778 intel_compute_tile_offset(dev_priv, &x, &y, 2777 - fb->modifier[0], 2778 - pixel_size, 2779 + fb->modifier[0], cpp, 2779 2780 fb->pitches[0]); 2780 2781 linear_offset -= intel_crtc->dspaddr_offset; 2781 2782 } else { ··· 2791 2794 data and adding to linear_offset*/ 2792 2795 linear_offset += 2793 2796 (crtc_state->pipe_src_h - 1) * fb->pitches[0] + 2794 - (crtc_state->pipe_src_w - 1) * pixel_size; 2797 + (crtc_state->pipe_src_w - 1) * cpp; 2795 2798 } 2796 2799 2797 2800 intel_crtc->adjusted_x = x; ··· 2836 2839 struct drm_framebuffer *fb = plane_state->base.fb; 2837 2840 struct drm_i915_gem_object *obj = intel_fb_obj(fb); 2838 2841 int plane = intel_crtc->plane; 2839 - unsigned long linear_offset; 2842 + u32 linear_offset; 2840 2843 u32 dspcntr; 2841 2844 i915_reg_t reg = DSPCNTR(plane); 2842 - int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); 2845 + int cpp = drm_format_plane_cpp(fb->pixel_format, 0); 2843 2846 int x = plane_state->src.x1 >> 16; 2844 2847 int y = plane_state->src.y1 >> 16; 2845 2848 ··· 2878 2881 if (!IS_HASWELL(dev) && !IS_BROADWELL(dev)) 2879 2882 dspcntr |= DISPPLANE_TRICKLE_FEED_DISABLE; 2880 2883 2881 - linear_offset = y * fb->pitches[0] + x * pixel_size; 2884 + linear_offset = y * fb->pitches[0] + x * cpp; 2882 2885 intel_crtc->dspaddr_offset = 2883 2886 intel_compute_tile_offset(dev_priv, &x, &y, 2884 - fb->modifier[0], 2885 - pixel_size, 2887 + fb->modifier[0], cpp, 2886 2888 fb->pitches[0]); 2887 2889 linear_offset -= intel_crtc->dspaddr_offset; 2888 2890 if (plane_state->base.rotation == BIT(DRM_ROTATE_180)) { ··· 2895 2899 data and adding to linear_offset*/ 2896 2900 linear_offset += 2897 2901 (crtc_state->pipe_src_h - 1) * fb->pitches[0] + 2898 - (crtc_state->pipe_src_w - 1) * pixel_size; 2902 + (crtc_state->pipe_src_w - 1) * cpp; 2899 2903 } 2900 2904 } 2901 2905 ··· 2947 2951 offset = vma->node.start; 2948 2952 2949 2953 if (plane == 1) { 2950 - offset += vma->ggtt_view.params.rotation_info.uv_start_page * 2954 + offset += vma->ggtt_view.params.rotated.uv_start_page * 2951 2955 PAGE_SIZE; 2952 2956 } 2953 2957 ··· 3155 3159 struct drm_device *dev = crtc->dev; 3156 3160 struct drm_i915_private *dev_priv = dev->dev_private; 3157 3161 int pipe = to_intel_crtc(crtc)->pipe; 3158 - 3159 - if (dev_priv->fbc.deactivate) 3160 - dev_priv->fbc.deactivate(dev_priv); 3161 3162 3162 3163 I915_WRITE(PLANE_CTL(pipe, 0), 0); 3163 3164 I915_WRITE(PLANE_SURF(pipe, 0), 0); ··· 4796 4803 intel_update_watermarks(&crtc->base); 4797 4804 4798 4805 if (atomic->update_fbc) 4799 - intel_fbc_update(crtc); 4806 + intel_fbc_post_update(crtc); 4800 4807 4801 4808 if (atomic->post_enable_primary) 4802 4809 intel_post_enable_primary(&crtc->base); ··· 4804 4811 memset(atomic, 0, sizeof(*atomic)); 4805 4812 } 4806 4813 4807 - static void intel_pre_plane_update(struct intel_crtc *crtc) 4814 + static void intel_pre_plane_update(struct intel_crtc_state *old_crtc_state) 4808 4815 { 4816 + struct intel_crtc *crtc = to_intel_crtc(old_crtc_state->base.crtc); 4809 4817 struct drm_device *dev = crtc->base.dev; 4810 4818 struct drm_i915_private *dev_priv = dev->dev_private; 4811 4819 struct intel_crtc_atomic_commit *atomic = &crtc->atomic; 4812 4820 struct intel_crtc_state *pipe_config = 4813 4821 to_intel_crtc_state(crtc->base.state); 4822 + struct drm_atomic_state *old_state = old_crtc_state->base.state; 4823 + struct drm_plane *primary = crtc->base.primary; 4824 + struct drm_plane_state *old_pri_state = 4825 + drm_atomic_get_existing_plane_state(old_state, primary); 4826 + bool modeset = needs_modeset(&pipe_config->base); 4814 4827 4815 - if (atomic->disable_fbc) 4816 - intel_fbc_deactivate(crtc); 4828 + if (atomic->update_fbc) 4829 + intel_fbc_pre_update(crtc); 4817 4830 4818 - if (crtc->atomic.disable_ips) 4819 - hsw_disable_ips(crtc); 4831 + if (old_pri_state) { 4832 + struct intel_plane_state *primary_state = 4833 + to_intel_plane_state(primary->state); 4834 + struct intel_plane_state *old_primary_state = 4835 + to_intel_plane_state(old_pri_state); 4820 4836 4821 - if (atomic->pre_disable_primary) 4822 - intel_pre_disable_primary(&crtc->base); 4837 + if (old_primary_state->visible && 4838 + (modeset || !primary_state->visible)) 4839 + intel_pre_disable_primary(&crtc->base); 4840 + } 4823 4841 4824 4842 if (pipe_config->disable_cxsr) { 4825 4843 crtc->wm.cxsr_allowed = false; 4826 - intel_set_memory_cxsr(dev_priv, false); 4844 + 4845 + if (old_crtc_state->base.active) 4846 + intel_set_memory_cxsr(dev_priv, false); 4827 4847 } 4828 4848 4829 4849 if (!needs_modeset(&pipe_config->base) && pipe_config->wm_changed) ··· 4937 4931 if (intel_crtc->config->has_pch_encoder) 4938 4932 intel_wait_for_vblank(dev, pipe); 4939 4933 intel_set_pch_fifo_underrun_reporting(dev_priv, pipe, true); 4940 - 4941 - intel_fbc_enable(intel_crtc); 4942 4934 } 4943 4935 4944 4936 /* IPS only exists on ULT machines and is tied to pipe A. */ ··· 5049 5045 intel_wait_for_vblank(dev, hsw_workaround_pipe); 5050 5046 intel_wait_for_vblank(dev, hsw_workaround_pipe); 5051 5047 } 5052 - 5053 - intel_fbc_enable(intel_crtc); 5054 5048 } 5055 5049 5056 5050 static void ironlake_pfit_disable(struct intel_crtc *crtc, bool force) ··· 5129 5127 } 5130 5128 5131 5129 intel_set_pch_fifo_underrun_reporting(dev_priv, pipe, true); 5132 - 5133 - intel_fbc_disable_crtc(intel_crtc); 5134 5130 } 5135 5131 5136 5132 static void haswell_crtc_disable(struct drm_crtc *crtc) ··· 5179 5179 intel_set_pch_fifo_underrun_reporting(dev_priv, TRANSCODER_A, 5180 5180 true); 5181 5181 } 5182 - 5183 - intel_fbc_disable_crtc(intel_crtc); 5184 5182 } 5185 5183 5186 5184 static void i9xx_pfit_enable(struct intel_crtc *crtc) ··· 6289 6291 6290 6292 for_each_encoder_on_crtc(dev, crtc, encoder) 6291 6293 encoder->enable(encoder); 6292 - 6293 - intel_fbc_enable(intel_crtc); 6294 6294 } 6295 6295 6296 6296 static void i9xx_pfit_disable(struct intel_crtc *crtc) ··· 6351 6355 6352 6356 if (!IS_GEN2(dev)) 6353 6357 intel_set_cpu_fifo_underrun_reporting(dev_priv, pipe, false); 6354 - 6355 - intel_fbc_disable_crtc(intel_crtc); 6356 6358 } 6357 6359 6358 6360 static void intel_crtc_disable_noatomic(struct drm_crtc *crtc) ··· 6374 6380 6375 6381 dev_priv->display.crtc_disable(crtc); 6376 6382 intel_crtc->active = false; 6383 + intel_fbc_disable(intel_crtc); 6377 6384 intel_update_watermarks(crtc); 6378 6385 intel_disable_shared_dpll(intel_crtc); 6379 6386 ··· 9848 9853 static int haswell_crtc_compute_clock(struct intel_crtc *crtc, 9849 9854 struct intel_crtc_state *crtc_state) 9850 9855 { 9851 - if (!intel_ddi_pll_select(crtc, crtc_state)) 9852 - return -EINVAL; 9856 + struct intel_encoder *intel_encoder = 9857 + intel_ddi_get_crtc_new_encoder(crtc_state); 9858 + 9859 + if (intel_encoder->type != INTEL_OUTPUT_DSI) { 9860 + if (!intel_ddi_pll_select(crtc, crtc_state)) 9861 + return -EINVAL; 9862 + } 9853 9863 9854 9864 crtc->lowfreq_avail = false; 9855 9865 ··· 10914 10914 mutex_unlock(&dev->struct_mutex); 10915 10915 10916 10916 intel_frontbuffer_flip_complete(dev, to_intel_plane(primary)->frontbuffer_bit); 10917 + intel_fbc_post_update(crtc); 10917 10918 drm_framebuffer_unreference(work->old_fb); 10918 10919 10919 10920 BUG_ON(atomic_read(&crtc->unpin_work_count) == 0); ··· 11630 11629 11631 11630 crtc->primary->fb = fb; 11632 11631 update_state_fb(crtc->primary); 11632 + intel_fbc_pre_update(intel_crtc); 11633 11633 11634 11634 work->pending_flip_obj = obj; 11635 11635 ··· 11715 11713 to_intel_plane(primary)->frontbuffer_bit); 11716 11714 mutex_unlock(&dev->struct_mutex); 11717 11715 11718 - intel_fbc_deactivate(intel_crtc); 11719 11716 intel_frontbuffer_flip_prepare(dev, 11720 11717 to_intel_plane(primary)->frontbuffer_bit); 11721 11718 ··· 11725 11724 cleanup_unpin: 11726 11725 intel_unpin_fb_obj(fb, crtc->primary->state); 11727 11726 cleanup_pending: 11728 - if (request) 11727 + if (!IS_ERR_OR_NULL(request)) 11729 11728 i915_gem_request_cancel(request); 11730 11729 atomic_dec(&intel_crtc->unpin_work_count); 11731 11730 mutex_unlock(&dev->struct_mutex); ··· 11836 11835 struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 11837 11836 struct drm_plane *plane = plane_state->plane; 11838 11837 struct drm_device *dev = crtc->dev; 11839 - struct drm_i915_private *dev_priv = dev->dev_private; 11840 11838 struct intel_plane_state *old_plane_state = 11841 11839 to_intel_plane_state(plane->state); 11842 11840 int idx = intel_crtc->base.base.id, ret; ··· 11901 11901 11902 11902 switch (plane->type) { 11903 11903 case DRM_PLANE_TYPE_PRIMARY: 11904 - intel_crtc->atomic.pre_disable_primary = turn_off; 11905 11904 intel_crtc->atomic.post_enable_primary = turn_on; 11906 - 11907 - if (turn_off) { 11908 - /* 11909 - * FIXME: Actually if we will still have any other 11910 - * plane enabled on the pipe we could let IPS enabled 11911 - * still, but for now lets consider that when we make 11912 - * primary invisible by setting DSPCNTR to 0 on 11913 - * update_primary_plane function IPS needs to be 11914 - * disable. 11915 - */ 11916 - intel_crtc->atomic.disable_ips = true; 11917 - 11918 - intel_crtc->atomic.disable_fbc = true; 11919 - } 11920 - 11921 - /* 11922 - * FBC does not work on some platforms for rotated 11923 - * planes, so disable it when rotation is not 0 and 11924 - * update it when rotation is set back to 0. 11925 - * 11926 - * FIXME: This is redundant with the fbc update done in 11927 - * the primary plane enable function except that that 11928 - * one is done too late. We eventually need to unify 11929 - * this. 11930 - */ 11931 - 11932 - if (visible && 11933 - INTEL_INFO(dev)->gen <= 4 && !IS_G4X(dev) && 11934 - dev_priv->fbc.crtc == intel_crtc && 11935 - plane_state->rotation != BIT(DRM_ROTATE_0)) 11936 - intel_crtc->atomic.disable_fbc = true; 11905 + intel_crtc->atomic.update_fbc = true; 11937 11906 11938 11907 /* 11939 11908 * BDW signals flip done immediately if the plane ··· 11912 11943 if (turn_on && IS_BROADWELL(dev)) 11913 11944 intel_crtc->atomic.wait_vblank = true; 11914 11945 11915 - intel_crtc->atomic.update_fbc |= visible || mode_changed; 11916 11946 break; 11917 11947 case DRM_PLANE_TYPE_CURSOR: 11918 11948 break; ··· 13316 13348 static int intel_atomic_check(struct drm_device *dev, 13317 13349 struct drm_atomic_state *state) 13318 13350 { 13351 + struct drm_i915_private *dev_priv = to_i915(dev); 13319 13352 struct intel_atomic_state *intel_state = to_intel_atomic_state(state); 13320 13353 struct drm_crtc *crtc; 13321 13354 struct drm_crtc_state *crtc_state; ··· 13359 13390 return ret; 13360 13391 13361 13392 if (i915.fastboot && 13362 - intel_pipe_config_compare(state->dev, 13393 + intel_pipe_config_compare(dev, 13363 13394 to_intel_crtc_state(crtc->state), 13364 13395 pipe_config, true)) { 13365 13396 crtc_state->mode_changed = false; ··· 13385 13416 if (ret) 13386 13417 return ret; 13387 13418 } else 13388 - intel_state->cdclk = to_i915(state->dev)->cdclk_freq; 13419 + intel_state->cdclk = dev_priv->cdclk_freq; 13389 13420 13390 - ret = drm_atomic_helper_check_planes(state->dev, state); 13421 + ret = drm_atomic_helper_check_planes(dev, state); 13391 13422 if (ret) 13392 13423 return ret; 13393 13424 13425 + intel_fbc_choose_crtc(dev_priv, state); 13394 13426 calc_watermark_data(state); 13395 13427 13396 13428 return 0; ··· 13512 13542 if (!needs_modeset(crtc->state)) 13513 13543 continue; 13514 13544 13515 - intel_pre_plane_update(intel_crtc); 13545 + intel_pre_plane_update(to_intel_crtc_state(crtc_state)); 13516 13546 13517 13547 if (crtc_state->active) { 13518 13548 intel_crtc_disable_planes(crtc, crtc_state->plane_mask); 13519 13549 dev_priv->display.crtc_disable(crtc); 13520 13550 intel_crtc->active = false; 13551 + intel_fbc_disable(intel_crtc); 13521 13552 intel_disable_shared_dpll(intel_crtc); 13522 13553 13523 13554 /* ··· 13568 13597 } 13569 13598 13570 13599 if (!modeset) 13571 - intel_pre_plane_update(intel_crtc); 13600 + intel_pre_plane_update(to_intel_crtc_state(crtc_state)); 13601 + 13602 + if (crtc->state->active && intel_crtc->atomic.update_fbc) 13603 + intel_fbc_enable(intel_crtc); 13572 13604 13573 13605 if (crtc->state->active && 13574 13606 (crtc->state->planes_changed || update_pipe)) ··· 14656 14682 u32 gen = INTEL_INFO(dev)->gen; 14657 14683 14658 14684 if (gen >= 9) { 14685 + int cpp = drm_format_plane_cpp(pixel_format, 0); 14686 + 14659 14687 /* "The stride in bytes must not exceed the of the size of 8K 14660 14688 * pixels and 32K bytes." 14661 14689 */ 14662 - return min(8192*drm_format_plane_cpp(pixel_format, 0), 32768); 14690 + return min(8192 * cpp, 32768); 14663 14691 } else if (gen >= 5 && !IS_VALLEYVIEW(dev) && !IS_CHERRYVIEW(dev)) { 14664 14692 return 32*1024; 14665 14693 } else if (gen >= 4) { ··· 15910 15934 modeset_put_power_domains(dev_priv, put_domains); 15911 15935 } 15912 15936 intel_display_set_init_power(dev_priv, false); 15937 + 15938 + intel_fbc_init_pipe_state(dev_priv); 15913 15939 } 15914 15940 15915 15941 void intel_display_resume(struct drm_device *dev) ··· 16041 16063 16042 16064 intel_unregister_dsm_handler(); 16043 16065 16044 - intel_fbc_disable(dev_priv); 16066 + intel_fbc_global_disable(dev_priv); 16045 16067 16046 16068 /* flush any delayed tasks or pending work */ 16047 16069 flush_scheduled_work();
+21 -8
drivers/gpu/drm/i915/intel_dp.c
··· 203 203 struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode; 204 204 int target_clock = mode->clock; 205 205 int max_rate, mode_rate, max_lanes, max_link_clock; 206 + int max_dotclk = to_i915(connector->dev)->max_dotclk_freq; 206 207 207 208 if (is_edp(intel_dp) && fixed_mode) { 208 209 if (mode->hdisplay > fixed_mode->hdisplay) ··· 221 220 max_rate = intel_dp_max_data_rate(max_link_clock, max_lanes); 222 221 mode_rate = intel_dp_link_required(target_clock, 18); 223 222 224 - if (mode_rate > max_rate) 223 + if (mode_rate > max_rate || target_clock > max_dotclk) 225 224 return MODE_CLOCK_HIGH; 226 225 227 226 if (mode->clock < 10000) ··· 980 979 if (WARN_ON(txsize > 20)) 981 980 return -E2BIG; 982 981 983 - memcpy(txbuf + HEADER_SIZE, msg->buffer, msg->size); 982 + if (msg->buffer) 983 + memcpy(txbuf + HEADER_SIZE, msg->buffer, msg->size); 984 + else 985 + WARN_ON(msg->size); 984 986 985 987 ret = intel_dp_aux_ch(intel_dp, txbuf, txsize, rxbuf, rxsize); 986 988 if (ret > 0) { ··· 1802 1798 1803 1799 static void wait_panel_power_cycle(struct intel_dp *intel_dp) 1804 1800 { 1801 + ktime_t panel_power_on_time; 1802 + s64 panel_power_off_duration; 1803 + 1805 1804 DRM_DEBUG_KMS("Wait for panel power cycle\n"); 1805 + 1806 + /* take the difference of currrent time and panel power off time 1807 + * and then make panel wait for t11_t12 if needed. */ 1808 + panel_power_on_time = ktime_get_boottime(); 1809 + panel_power_off_duration = ktime_ms_delta(panel_power_on_time, intel_dp->panel_power_off_time); 1806 1810 1807 1811 /* When we disable the VDD override bit last we have to do the manual 1808 1812 * wait. */ 1809 - wait_remaining_ms_from_jiffies(intel_dp->last_power_cycle, 1810 - intel_dp->panel_power_cycle_delay); 1813 + if (panel_power_off_duration < (s64)intel_dp->panel_power_cycle_delay) 1814 + wait_remaining_ms_from_jiffies(jiffies, 1815 + intel_dp->panel_power_cycle_delay - panel_power_off_duration); 1811 1816 1812 1817 wait_panel_status(intel_dp, IDLE_CYCLE_MASK, IDLE_CYCLE_VALUE); 1813 1818 } ··· 1968 1955 I915_READ(pp_stat_reg), I915_READ(pp_ctrl_reg)); 1969 1956 1970 1957 if ((pp & POWER_TARGET_ON) == 0) 1971 - intel_dp->last_power_cycle = jiffies; 1958 + intel_dp->panel_power_off_time = ktime_get_boottime(); 1972 1959 1973 1960 power_domain = intel_display_port_aux_power_domain(intel_encoder); 1974 1961 intel_display_power_put(dev_priv, power_domain); ··· 2117 2104 I915_WRITE(pp_ctrl_reg, pp); 2118 2105 POSTING_READ(pp_ctrl_reg); 2119 2106 2120 - intel_dp->last_power_cycle = jiffies; 2107 + intel_dp->panel_power_off_time = ktime_get_boottime(); 2121 2108 wait_panel_off(intel_dp); 2122 2109 2123 2110 /* We got a reference when we enabled the VDD. */ ··· 4008 3995 } while (--attempts && count); 4009 3996 4010 3997 if (attempts == 0) { 4011 - DRM_ERROR("TIMEOUT: Sink CRC counter is not zeroed\n"); 3998 + DRM_DEBUG_KMS("TIMEOUT: Sink CRC counter is not zeroed after calculation is stopped\n"); 4012 3999 ret = -ETIMEDOUT; 4013 4000 } 4014 4001 ··· 5115 5102 5116 5103 static void intel_dp_init_panel_power_timestamps(struct intel_dp *intel_dp) 5117 5104 { 5118 - intel_dp->last_power_cycle = jiffies; 5105 + intel_dp->panel_power_off_time = ktime_get_boottime(); 5119 5106 intel_dp->last_power_on = jiffies; 5120 5107 intel_dp->last_backlight_off = jiffies; 5121 5108 }
+5
drivers/gpu/drm/i915/intel_dp_mst.c
··· 371 371 intel_dp_mst_mode_valid(struct drm_connector *connector, 372 372 struct drm_display_mode *mode) 373 373 { 374 + int max_dotclk = to_i915(connector->dev)->max_dotclk_freq; 375 + 374 376 /* TODO - validate mode against available PBN for link */ 375 377 if (mode->clock < 10000) 376 378 return MODE_CLOCK_LOW; 377 379 378 380 if (mode->flags & DRM_MODE_FLAG_DBLCLK) 379 381 return MODE_H_ILLEGAL; 382 + 383 + if (mode->clock > max_dotclk) 384 + return MODE_CLOCK_HIGH; 380 385 381 386 return MODE_OK; 382 387 }
+20 -15
drivers/gpu/drm/i915/intel_drv.h
··· 492 492 493 493 bool ips_enabled; 494 494 495 + bool enable_fbc; 496 + 495 497 bool double_wide; 496 498 497 499 bool dp_encoder_is_mst; ··· 544 542 */ 545 543 struct intel_crtc_atomic_commit { 546 544 /* Sleepable operations to perform before commit */ 547 - bool disable_fbc; 548 - bool disable_ips; 549 - bool pre_disable_primary; 550 545 551 546 /* Sleepable operations to perform after commit */ 552 547 unsigned fb_bits; 553 548 bool wait_vblank; 554 - bool update_fbc; 555 549 bool post_enable_primary; 556 550 unsigned update_sprite_watermarks; 551 + 552 + /* Sleepable operations to perform before and after commit */ 553 + bool update_fbc; 557 554 }; 558 555 559 556 struct intel_crtc { ··· 576 575 /* Display surface base address adjustement for pageflips. Note that on 577 576 * gen4+ this only adjusts up to a tile, offsets within a tile are 578 577 * handled in the hw itself (with the TILEOFF register). */ 579 - unsigned long dspaddr_offset; 578 + u32 dspaddr_offset; 580 579 int adjusted_x; 581 580 int adjusted_y; 582 581 ··· 771 770 int backlight_off_delay; 772 771 struct delayed_work panel_vdd_work; 773 772 bool want_panel_vdd; 774 - unsigned long last_power_cycle; 775 773 unsigned long last_power_on; 776 774 unsigned long last_backlight_off; 775 + ktime_t panel_power_off_time; 777 776 778 777 struct notifier_block edp_notifier; 779 778 ··· 1173 1172 void assert_pipe(struct drm_i915_private *dev_priv, enum pipe pipe, bool state); 1174 1173 #define assert_pipe_enabled(d, p) assert_pipe(d, p, true) 1175 1174 #define assert_pipe_disabled(d, p) assert_pipe(d, p, false) 1176 - unsigned long intel_compute_tile_offset(struct drm_i915_private *dev_priv, 1177 - int *x, int *y, 1178 - uint64_t fb_modifier, 1179 - unsigned int cpp, 1180 - unsigned int pitch); 1175 + u32 intel_compute_tile_offset(struct drm_i915_private *dev_priv, 1176 + int *x, int *y, 1177 + uint64_t fb_modifier, 1178 + unsigned int cpp, 1179 + unsigned int pitch); 1181 1180 void intel_prepare_reset(struct drm_device *dev); 1182 1181 void intel_finish_reset(struct drm_device *dev); 1183 1182 void hsw_enable_pc8(struct drm_i915_private *dev_priv); ··· 1328 1327 #endif 1329 1328 1330 1329 /* intel_fbc.c */ 1330 + void intel_fbc_choose_crtc(struct drm_i915_private *dev_priv, 1331 + struct drm_atomic_state *state); 1331 1332 bool intel_fbc_is_active(struct drm_i915_private *dev_priv); 1332 - void intel_fbc_deactivate(struct intel_crtc *crtc); 1333 - void intel_fbc_update(struct intel_crtc *crtc); 1333 + void intel_fbc_pre_update(struct intel_crtc *crtc); 1334 + void intel_fbc_post_update(struct intel_crtc *crtc); 1334 1335 void intel_fbc_init(struct drm_i915_private *dev_priv); 1336 + void intel_fbc_init_pipe_state(struct drm_i915_private *dev_priv); 1335 1337 void intel_fbc_enable(struct intel_crtc *crtc); 1336 - void intel_fbc_disable(struct drm_i915_private *dev_priv); 1337 - void intel_fbc_disable_crtc(struct intel_crtc *crtc); 1338 + void intel_fbc_disable(struct intel_crtc *crtc); 1339 + void intel_fbc_global_disable(struct drm_i915_private *dev_priv); 1338 1340 void intel_fbc_invalidate(struct drm_i915_private *dev_priv, 1339 1341 unsigned int frontbuffer_bits, 1340 1342 enum fb_op_origin origin); ··· 1563 1559 void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv, 1564 1560 struct skl_ddb_allocation *ddb /* out */); 1565 1561 uint32_t ilk_pipe_pixel_rate(const struct intel_crtc_state *pipe_config); 1562 + int sanitize_rc6_option(const struct drm_device *dev, int enable_rc6); 1566 1563 1567 1564 /* intel_sdvo.c */ 1568 1565 bool intel_sdvo_init(struct drm_device *dev,
+1 -1
drivers/gpu/drm/i915/intel_dsi.c
··· 478 478 479 479 DRM_DEBUG_KMS("\n"); 480 480 481 - intel_dsi_prepare(encoder); 482 481 intel_enable_dsi_pll(encoder); 482 + intel_dsi_prepare(encoder); 483 483 484 484 /* Panel Enable over CRC PMIC */ 485 485 if (intel_dsi->gpio_panel)
+23 -3
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c
··· 204 204 struct drm_device *dev = intel_dsi->base.base.dev; 205 205 struct drm_i915_private *dev_priv = dev->dev_private; 206 206 207 + if (dev_priv->vbt.dsi.seq_version >= 3) 208 + data++; 209 + 207 210 gpio = *data++; 208 211 209 212 /* pull up/down */ 210 - action = *data++; 213 + action = *data++ & 1; 214 + 215 + if (gpio >= ARRAY_SIZE(gtable)) { 216 + DRM_DEBUG_KMS("unknown gpio %u\n", gpio); 217 + goto out; 218 + } 219 + 220 + if (!IS_VALLEYVIEW(dev_priv)) { 221 + DRM_DEBUG_KMS("GPIO element not supported on this platform\n"); 222 + goto out; 223 + } 224 + 225 + if (dev_priv->vbt.dsi.seq_version >= 3) { 226 + DRM_DEBUG_KMS("GPIO element v3 not supported\n"); 227 + goto out; 228 + } 211 229 212 230 function = gtable[gpio].function_reg; 213 231 pad = gtable[gpio].pad_reg; ··· 234 216 if (!gtable[gpio].init) { 235 217 /* program the function */ 236 218 /* FIXME: remove constant below */ 237 - vlv_gpio_nc_write(dev_priv, function, 0x2000CC00); 219 + vlv_iosf_sb_write(dev_priv, IOSF_PORT_GPIO_NC, function, 220 + 0x2000CC00); 238 221 gtable[gpio].init = 1; 239 222 } 240 223 241 224 val = 0x4 | action; 242 225 243 226 /* pull up/down */ 244 - vlv_gpio_nc_write(dev_priv, pad, val); 227 + vlv_iosf_sb_write(dev_priv, IOSF_PORT_GPIO_NC, pad, val); 245 228 mutex_unlock(&dev_priv->sb_lock); 246 229 230 + out: 247 231 return data; 248 232 } 249 233
+543 -407
drivers/gpu/drm/i915/intel_fbc.c
··· 43 43 44 44 static inline bool fbc_supported(struct drm_i915_private *dev_priv) 45 45 { 46 - return dev_priv->fbc.activate != NULL; 46 + return HAS_FBC(dev_priv); 47 47 } 48 48 49 49 static inline bool fbc_on_pipe_a_only(struct drm_i915_private *dev_priv) ··· 54 54 static inline bool fbc_on_plane_a_only(struct drm_i915_private *dev_priv) 55 55 { 56 56 return INTEL_INFO(dev_priv)->gen < 4; 57 + } 58 + 59 + static inline bool no_fbc_on_multiple_pipes(struct drm_i915_private *dev_priv) 60 + { 61 + return INTEL_INFO(dev_priv)->gen <= 3; 57 62 } 58 63 59 64 /* ··· 79 74 * write to the PLANE_SIZE register. For BDW-, the hardware looks at the value 80 75 * we wrote to PIPESRC. 81 76 */ 82 - static void intel_fbc_get_plane_source_size(struct intel_crtc *crtc, 77 + static void intel_fbc_get_plane_source_size(struct intel_fbc_state_cache *cache, 83 78 int *width, int *height) 84 79 { 85 - struct intel_plane_state *plane_state = 86 - to_intel_plane_state(crtc->base.primary->state); 87 80 int w, h; 88 81 89 - if (intel_rotation_90_or_270(plane_state->base.rotation)) { 90 - w = drm_rect_height(&plane_state->src) >> 16; 91 - h = drm_rect_width(&plane_state->src) >> 16; 82 + if (intel_rotation_90_or_270(cache->plane.rotation)) { 83 + w = cache->plane.src_h; 84 + h = cache->plane.src_w; 92 85 } else { 93 - w = drm_rect_width(&plane_state->src) >> 16; 94 - h = drm_rect_height(&plane_state->src) >> 16; 86 + w = cache->plane.src_w; 87 + h = cache->plane.src_h; 95 88 } 96 89 97 90 if (width) ··· 98 95 *height = h; 99 96 } 100 97 101 - static int intel_fbc_calculate_cfb_size(struct intel_crtc *crtc, 102 - struct drm_framebuffer *fb) 98 + static int intel_fbc_calculate_cfb_size(struct drm_i915_private *dev_priv, 99 + struct intel_fbc_state_cache *cache) 103 100 { 104 - struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; 105 101 int lines; 106 102 107 - intel_fbc_get_plane_source_size(crtc, NULL, &lines); 103 + intel_fbc_get_plane_source_size(cache, NULL, &lines); 108 104 if (INTEL_INFO(dev_priv)->gen >= 7) 109 105 lines = min(lines, 2048); 110 106 111 107 /* Hardware needs the full buffer stride, not just the active area. */ 112 - return lines * fb->pitches[0]; 108 + return lines * cache->fb.stride; 113 109 } 114 110 115 111 static void i8xx_fbc_deactivate(struct drm_i915_private *dev_priv) 116 112 { 117 113 u32 fbc_ctl; 118 - 119 - dev_priv->fbc.active = false; 120 114 121 115 /* Disable compression */ 122 116 fbc_ctl = I915_READ(FBC_CONTROL); ··· 130 130 } 131 131 } 132 132 133 - static void i8xx_fbc_activate(struct intel_crtc *crtc) 133 + static void i8xx_fbc_activate(struct drm_i915_private *dev_priv) 134 134 { 135 - struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; 136 - struct drm_framebuffer *fb = crtc->base.primary->fb; 137 - struct drm_i915_gem_object *obj = intel_fb_obj(fb); 135 + struct intel_fbc_reg_params *params = &dev_priv->fbc.params; 138 136 int cfb_pitch; 139 137 int i; 140 138 u32 fbc_ctl; 141 139 142 - dev_priv->fbc.active = true; 143 - 144 140 /* Note: fbc.threshold == 1 for i8xx */ 145 - cfb_pitch = intel_fbc_calculate_cfb_size(crtc, fb) / FBC_LL_SIZE; 146 - if (fb->pitches[0] < cfb_pitch) 147 - cfb_pitch = fb->pitches[0]; 141 + cfb_pitch = params->cfb_size / FBC_LL_SIZE; 142 + if (params->fb.stride < cfb_pitch) 143 + cfb_pitch = params->fb.stride; 148 144 149 145 /* FBC_CTL wants 32B or 64B units */ 150 146 if (IS_GEN2(dev_priv)) ··· 157 161 158 162 /* Set it up... */ 159 163 fbc_ctl2 = FBC_CTL_FENCE_DBL | FBC_CTL_IDLE_IMM | FBC_CTL_CPU_FENCE; 160 - fbc_ctl2 |= FBC_CTL_PLANE(crtc->plane); 164 + fbc_ctl2 |= FBC_CTL_PLANE(params->crtc.plane); 161 165 I915_WRITE(FBC_CONTROL2, fbc_ctl2); 162 - I915_WRITE(FBC_FENCE_OFF, get_crtc_fence_y_offset(crtc)); 166 + I915_WRITE(FBC_FENCE_OFF, params->crtc.fence_y_offset); 163 167 } 164 168 165 169 /* enable it... */ ··· 169 173 if (IS_I945GM(dev_priv)) 170 174 fbc_ctl |= FBC_CTL_C3_IDLE; /* 945 needs special SR handling */ 171 175 fbc_ctl |= (cfb_pitch & 0xff) << FBC_CTL_STRIDE_SHIFT; 172 - fbc_ctl |= obj->fence_reg; 176 + fbc_ctl |= params->fb.fence_reg; 173 177 I915_WRITE(FBC_CONTROL, fbc_ctl); 174 178 } 175 179 ··· 178 182 return I915_READ(FBC_CONTROL) & FBC_CTL_EN; 179 183 } 180 184 181 - static void g4x_fbc_activate(struct intel_crtc *crtc) 185 + static void g4x_fbc_activate(struct drm_i915_private *dev_priv) 182 186 { 183 - struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; 184 - struct drm_framebuffer *fb = crtc->base.primary->fb; 185 - struct drm_i915_gem_object *obj = intel_fb_obj(fb); 187 + struct intel_fbc_reg_params *params = &dev_priv->fbc.params; 186 188 u32 dpfc_ctl; 187 189 188 - dev_priv->fbc.active = true; 189 - 190 - dpfc_ctl = DPFC_CTL_PLANE(crtc->plane) | DPFC_SR_EN; 191 - if (drm_format_plane_cpp(fb->pixel_format, 0) == 2) 190 + dpfc_ctl = DPFC_CTL_PLANE(params->crtc.plane) | DPFC_SR_EN; 191 + if (drm_format_plane_cpp(params->fb.pixel_format, 0) == 2) 192 192 dpfc_ctl |= DPFC_CTL_LIMIT_2X; 193 193 else 194 194 dpfc_ctl |= DPFC_CTL_LIMIT_1X; 195 - dpfc_ctl |= DPFC_CTL_FENCE_EN | obj->fence_reg; 195 + dpfc_ctl |= DPFC_CTL_FENCE_EN | params->fb.fence_reg; 196 196 197 - I915_WRITE(DPFC_FENCE_YOFF, get_crtc_fence_y_offset(crtc)); 197 + I915_WRITE(DPFC_FENCE_YOFF, params->crtc.fence_y_offset); 198 198 199 199 /* enable it... */ 200 200 I915_WRITE(DPFC_CONTROL, dpfc_ctl | DPFC_CTL_EN); ··· 199 207 static void g4x_fbc_deactivate(struct drm_i915_private *dev_priv) 200 208 { 201 209 u32 dpfc_ctl; 202 - 203 - dev_priv->fbc.active = false; 204 210 205 211 /* Disable compression */ 206 212 dpfc_ctl = I915_READ(DPFC_CONTROL); ··· 220 230 POSTING_READ(MSG_FBC_REND_STATE); 221 231 } 222 232 223 - static void ilk_fbc_activate(struct intel_crtc *crtc) 233 + static void ilk_fbc_activate(struct drm_i915_private *dev_priv) 224 234 { 225 - struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; 226 - struct drm_framebuffer *fb = crtc->base.primary->fb; 227 - struct drm_i915_gem_object *obj = intel_fb_obj(fb); 235 + struct intel_fbc_reg_params *params = &dev_priv->fbc.params; 228 236 u32 dpfc_ctl; 229 237 int threshold = dev_priv->fbc.threshold; 230 - unsigned int y_offset; 231 238 232 - dev_priv->fbc.active = true; 233 - 234 - dpfc_ctl = DPFC_CTL_PLANE(crtc->plane); 235 - if (drm_format_plane_cpp(fb->pixel_format, 0) == 2) 239 + dpfc_ctl = DPFC_CTL_PLANE(params->crtc.plane); 240 + if (drm_format_plane_cpp(params->fb.pixel_format, 0) == 2) 236 241 threshold++; 237 242 238 243 switch (threshold) { ··· 244 259 } 245 260 dpfc_ctl |= DPFC_CTL_FENCE_EN; 246 261 if (IS_GEN5(dev_priv)) 247 - dpfc_ctl |= obj->fence_reg; 262 + dpfc_ctl |= params->fb.fence_reg; 248 263 249 - y_offset = get_crtc_fence_y_offset(crtc); 250 - I915_WRITE(ILK_DPFC_FENCE_YOFF, y_offset); 251 - I915_WRITE(ILK_FBC_RT_BASE, i915_gem_obj_ggtt_offset(obj) | ILK_FBC_RT_VALID); 264 + I915_WRITE(ILK_DPFC_FENCE_YOFF, params->crtc.fence_y_offset); 265 + I915_WRITE(ILK_FBC_RT_BASE, params->fb.ggtt_offset | ILK_FBC_RT_VALID); 252 266 /* enable it... */ 253 267 I915_WRITE(ILK_DPFC_CONTROL, dpfc_ctl | DPFC_CTL_EN); 254 268 255 269 if (IS_GEN6(dev_priv)) { 256 270 I915_WRITE(SNB_DPFC_CTL_SA, 257 - SNB_CPU_FENCE_ENABLE | obj->fence_reg); 258 - I915_WRITE(DPFC_CPU_FENCE_OFFSET, y_offset); 271 + SNB_CPU_FENCE_ENABLE | params->fb.fence_reg); 272 + I915_WRITE(DPFC_CPU_FENCE_OFFSET, params->crtc.fence_y_offset); 259 273 } 260 274 261 275 intel_fbc_recompress(dev_priv); ··· 263 279 static void ilk_fbc_deactivate(struct drm_i915_private *dev_priv) 264 280 { 265 281 u32 dpfc_ctl; 266 - 267 - dev_priv->fbc.active = false; 268 282 269 283 /* Disable compression */ 270 284 dpfc_ctl = I915_READ(ILK_DPFC_CONTROL); ··· 277 295 return I915_READ(ILK_DPFC_CONTROL) & DPFC_CTL_EN; 278 296 } 279 297 280 - static void gen7_fbc_activate(struct intel_crtc *crtc) 298 + static void gen7_fbc_activate(struct drm_i915_private *dev_priv) 281 299 { 282 - struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; 283 - struct drm_framebuffer *fb = crtc->base.primary->fb; 284 - struct drm_i915_gem_object *obj = intel_fb_obj(fb); 300 + struct intel_fbc_reg_params *params = &dev_priv->fbc.params; 285 301 u32 dpfc_ctl; 286 302 int threshold = dev_priv->fbc.threshold; 287 303 288 - dev_priv->fbc.active = true; 289 - 290 304 dpfc_ctl = 0; 291 305 if (IS_IVYBRIDGE(dev_priv)) 292 - dpfc_ctl |= IVB_DPFC_CTL_PLANE(crtc->plane); 306 + dpfc_ctl |= IVB_DPFC_CTL_PLANE(params->crtc.plane); 293 307 294 - if (drm_format_plane_cpp(fb->pixel_format, 0) == 2) 308 + if (drm_format_plane_cpp(params->fb.pixel_format, 0) == 2) 295 309 threshold++; 296 310 297 311 switch (threshold) { ··· 315 337 ILK_FBCQ_DIS); 316 338 } else if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) { 317 339 /* WaFbcAsynchFlipDisableFbcQueue:hsw,bdw */ 318 - I915_WRITE(CHICKEN_PIPESL_1(crtc->pipe), 319 - I915_READ(CHICKEN_PIPESL_1(crtc->pipe)) | 340 + I915_WRITE(CHICKEN_PIPESL_1(params->crtc.pipe), 341 + I915_READ(CHICKEN_PIPESL_1(params->crtc.pipe)) | 320 342 HSW_FBCQ_DIS); 321 343 } 322 344 323 345 I915_WRITE(ILK_DPFC_CONTROL, dpfc_ctl | DPFC_CTL_EN); 324 346 325 347 I915_WRITE(SNB_DPFC_CTL_SA, 326 - SNB_CPU_FENCE_ENABLE | obj->fence_reg); 327 - I915_WRITE(DPFC_CPU_FENCE_OFFSET, get_crtc_fence_y_offset(crtc)); 348 + SNB_CPU_FENCE_ENABLE | params->fb.fence_reg); 349 + I915_WRITE(DPFC_CPU_FENCE_OFFSET, params->crtc.fence_y_offset); 328 350 329 351 intel_fbc_recompress(dev_priv); 352 + } 353 + 354 + static bool intel_fbc_hw_is_active(struct drm_i915_private *dev_priv) 355 + { 356 + if (INTEL_INFO(dev_priv)->gen >= 5) 357 + return ilk_fbc_is_active(dev_priv); 358 + else if (IS_GM45(dev_priv)) 359 + return g4x_fbc_is_active(dev_priv); 360 + else 361 + return i8xx_fbc_is_active(dev_priv); 362 + } 363 + 364 + static void intel_fbc_hw_activate(struct drm_i915_private *dev_priv) 365 + { 366 + struct intel_fbc *fbc = &dev_priv->fbc; 367 + 368 + fbc->active = true; 369 + 370 + if (INTEL_INFO(dev_priv)->gen >= 7) 371 + gen7_fbc_activate(dev_priv); 372 + else if (INTEL_INFO(dev_priv)->gen >= 5) 373 + ilk_fbc_activate(dev_priv); 374 + else if (IS_GM45(dev_priv)) 375 + g4x_fbc_activate(dev_priv); 376 + else 377 + i8xx_fbc_activate(dev_priv); 378 + } 379 + 380 + static void intel_fbc_hw_deactivate(struct drm_i915_private *dev_priv) 381 + { 382 + struct intel_fbc *fbc = &dev_priv->fbc; 383 + 384 + fbc->active = false; 385 + 386 + if (INTEL_INFO(dev_priv)->gen >= 5) 387 + ilk_fbc_deactivate(dev_priv); 388 + else if (IS_GM45(dev_priv)) 389 + g4x_fbc_deactivate(dev_priv); 390 + else 391 + i8xx_fbc_deactivate(dev_priv); 330 392 } 331 393 332 394 /** ··· 382 364 return dev_priv->fbc.active; 383 365 } 384 366 385 - static void intel_fbc_activate(const struct drm_framebuffer *fb) 386 - { 387 - struct drm_i915_private *dev_priv = fb->dev->dev_private; 388 - struct intel_crtc *crtc = dev_priv->fbc.crtc; 389 - 390 - dev_priv->fbc.activate(crtc); 391 - 392 - dev_priv->fbc.fb_id = fb->base.id; 393 - dev_priv->fbc.y = crtc->base.y; 394 - } 395 - 396 367 static void intel_fbc_work_fn(struct work_struct *__work) 397 368 { 398 369 struct drm_i915_private *dev_priv = 399 370 container_of(__work, struct drm_i915_private, fbc.work.work); 400 - struct intel_fbc_work *work = &dev_priv->fbc.work; 401 - struct intel_crtc *crtc = dev_priv->fbc.crtc; 402 - int delay_ms = 50; 371 + struct intel_fbc *fbc = &dev_priv->fbc; 372 + struct intel_fbc_work *work = &fbc->work; 373 + struct intel_crtc *crtc = fbc->crtc; 374 + struct drm_vblank_crtc *vblank = &dev_priv->dev->vblank[crtc->pipe]; 375 + 376 + if (drm_crtc_vblank_get(&crtc->base)) { 377 + DRM_ERROR("vblank not available for FBC on pipe %c\n", 378 + pipe_name(crtc->pipe)); 379 + 380 + mutex_lock(&fbc->lock); 381 + work->scheduled = false; 382 + mutex_unlock(&fbc->lock); 383 + return; 384 + } 403 385 404 386 retry: 405 387 /* Delay the actual enabling to let pageflipping cease and the ··· 408 390 * vblank to pass after disabling the FBC before we attempt 409 391 * to modify the control registers. 410 392 * 411 - * A more complicated solution would involve tracking vblanks 412 - * following the termination of the page-flipping sequence 413 - * and indeed performing the enable as a co-routine and not 414 - * waiting synchronously upon the vblank. 415 - * 416 393 * WaFbcWaitForVBlankBeforeEnable:ilk,snb 394 + * 395 + * It is also worth mentioning that since work->scheduled_vblank can be 396 + * updated multiple times by the other threads, hitting the timeout is 397 + * not an error condition. We'll just end up hitting the "goto retry" 398 + * case below. 417 399 */ 418 - wait_remaining_ms_from_jiffies(work->enable_jiffies, delay_ms); 400 + wait_event_timeout(vblank->queue, 401 + drm_crtc_vblank_count(&crtc->base) != work->scheduled_vblank, 402 + msecs_to_jiffies(50)); 419 403 420 - mutex_lock(&dev_priv->fbc.lock); 404 + mutex_lock(&fbc->lock); 421 405 422 406 /* Were we cancelled? */ 423 407 if (!work->scheduled) 424 408 goto out; 425 409 426 410 /* Were we delayed again while this function was sleeping? */ 427 - if (time_after(work->enable_jiffies + msecs_to_jiffies(delay_ms), 428 - jiffies)) { 429 - mutex_unlock(&dev_priv->fbc.lock); 411 + if (drm_crtc_vblank_count(&crtc->base) == work->scheduled_vblank) { 412 + mutex_unlock(&fbc->lock); 430 413 goto retry; 431 414 } 432 415 433 - if (crtc->base.primary->fb == work->fb) 434 - intel_fbc_activate(work->fb); 416 + intel_fbc_hw_activate(dev_priv); 435 417 436 418 work->scheduled = false; 437 419 438 420 out: 439 - mutex_unlock(&dev_priv->fbc.lock); 440 - } 441 - 442 - static void intel_fbc_cancel_work(struct drm_i915_private *dev_priv) 443 - { 444 - WARN_ON(!mutex_is_locked(&dev_priv->fbc.lock)); 445 - dev_priv->fbc.work.scheduled = false; 421 + mutex_unlock(&fbc->lock); 422 + drm_crtc_vblank_put(&crtc->base); 446 423 } 447 424 448 425 static void intel_fbc_schedule_activation(struct intel_crtc *crtc) 449 426 { 450 427 struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; 451 - struct intel_fbc_work *work = &dev_priv->fbc.work; 428 + struct intel_fbc *fbc = &dev_priv->fbc; 429 + struct intel_fbc_work *work = &fbc->work; 452 430 453 - WARN_ON(!mutex_is_locked(&dev_priv->fbc.lock)); 431 + WARN_ON(!mutex_is_locked(&fbc->lock)); 454 432 455 - /* It is useless to call intel_fbc_cancel_work() in this function since 456 - * we're not releasing fbc.lock, so it won't have an opportunity to grab 457 - * it to discover that it was cancelled. So we just update the expected 458 - * jiffy count. */ 459 - work->fb = crtc->base.primary->fb; 433 + if (drm_crtc_vblank_get(&crtc->base)) { 434 + DRM_ERROR("vblank not available for FBC on pipe %c\n", 435 + pipe_name(crtc->pipe)); 436 + return; 437 + } 438 + 439 + /* It is useless to call intel_fbc_cancel_work() or cancel_work() in 440 + * this function since we're not releasing fbc.lock, so it won't have an 441 + * opportunity to grab it to discover that it was cancelled. So we just 442 + * update the expected jiffy count. */ 460 443 work->scheduled = true; 461 - work->enable_jiffies = jiffies; 444 + work->scheduled_vblank = drm_crtc_vblank_count(&crtc->base); 445 + drm_crtc_vblank_put(&crtc->base); 462 446 463 447 schedule_work(&work->work); 464 448 } 465 449 466 - static void __intel_fbc_deactivate(struct drm_i915_private *dev_priv) 450 + static void intel_fbc_deactivate(struct drm_i915_private *dev_priv) 467 451 { 468 - WARN_ON(!mutex_is_locked(&dev_priv->fbc.lock)); 452 + struct intel_fbc *fbc = &dev_priv->fbc; 469 453 470 - intel_fbc_cancel_work(dev_priv); 454 + WARN_ON(!mutex_is_locked(&fbc->lock)); 471 455 472 - if (dev_priv->fbc.active) 473 - dev_priv->fbc.deactivate(dev_priv); 456 + /* Calling cancel_work() here won't help due to the fact that the work 457 + * function grabs fbc->lock. Just set scheduled to false so the work 458 + * function can know it was cancelled. */ 459 + fbc->work.scheduled = false; 460 + 461 + if (fbc->active) 462 + intel_fbc_hw_deactivate(dev_priv); 474 463 } 475 464 476 - /* 477 - * intel_fbc_deactivate - deactivate FBC if it's associated with crtc 478 - * @crtc: the CRTC 479 - * 480 - * This function deactivates FBC if it's associated with the provided CRTC. 481 - */ 482 - void intel_fbc_deactivate(struct intel_crtc *crtc) 465 + static bool multiple_pipes_ok(struct intel_crtc *crtc) 483 466 { 484 467 struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; 468 + struct drm_plane *primary = crtc->base.primary; 469 + struct intel_fbc *fbc = &dev_priv->fbc; 470 + enum pipe pipe = crtc->pipe; 485 471 486 - if (!fbc_supported(dev_priv)) 487 - return; 488 - 489 - mutex_lock(&dev_priv->fbc.lock); 490 - if (dev_priv->fbc.crtc == crtc) 491 - __intel_fbc_deactivate(dev_priv); 492 - mutex_unlock(&dev_priv->fbc.lock); 493 - } 494 - 495 - static void set_no_fbc_reason(struct drm_i915_private *dev_priv, 496 - const char *reason) 497 - { 498 - if (dev_priv->fbc.no_fbc_reason == reason) 499 - return; 500 - 501 - dev_priv->fbc.no_fbc_reason = reason; 502 - DRM_DEBUG_KMS("Disabling FBC: %s\n", reason); 503 - } 504 - 505 - static bool crtc_can_fbc(struct intel_crtc *crtc) 506 - { 507 - struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; 508 - 509 - if (fbc_on_pipe_a_only(dev_priv) && crtc->pipe != PIPE_A) 510 - return false; 511 - 512 - if (fbc_on_plane_a_only(dev_priv) && crtc->plane != PLANE_A) 513 - return false; 514 - 515 - return true; 516 - } 517 - 518 - static bool crtc_is_valid(struct intel_crtc *crtc) 519 - { 520 - if (!intel_crtc_active(&crtc->base)) 521 - return false; 522 - 523 - if (!to_intel_plane_state(crtc->base.primary->state)->visible) 524 - return false; 525 - 526 - return true; 527 - } 528 - 529 - static bool multiple_pipes_ok(struct drm_i915_private *dev_priv) 530 - { 531 - enum pipe pipe; 532 - int n_pipes = 0; 533 - struct drm_crtc *crtc; 534 - 535 - if (INTEL_INFO(dev_priv)->gen > 4) 472 + /* Don't even bother tracking anything we don't need. */ 473 + if (!no_fbc_on_multiple_pipes(dev_priv)) 536 474 return true; 537 475 538 - for_each_pipe(dev_priv, pipe) { 539 - crtc = dev_priv->pipe_to_crtc_mapping[pipe]; 476 + WARN_ON(!drm_modeset_is_locked(&primary->mutex)); 540 477 541 - if (intel_crtc_active(crtc) && 542 - to_intel_plane_state(crtc->primary->state)->visible) 543 - n_pipes++; 544 - } 478 + if (to_intel_plane_state(primary->state)->visible) 479 + fbc->visible_pipes_mask |= (1 << pipe); 480 + else 481 + fbc->visible_pipes_mask &= ~(1 << pipe); 545 482 546 - return (n_pipes < 2); 483 + return (fbc->visible_pipes_mask & ~(1 << pipe)) != 0; 547 484 } 548 485 549 486 static int find_compression_threshold(struct drm_i915_private *dev_priv, ··· 554 581 static int intel_fbc_alloc_cfb(struct intel_crtc *crtc) 555 582 { 556 583 struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; 557 - struct drm_framebuffer *fb = crtc->base.primary->state->fb; 584 + struct intel_fbc *fbc = &dev_priv->fbc; 558 585 struct drm_mm_node *uninitialized_var(compressed_llb); 559 586 int size, fb_cpp, ret; 560 587 561 - WARN_ON(drm_mm_node_allocated(&dev_priv->fbc.compressed_fb)); 588 + WARN_ON(drm_mm_node_allocated(&fbc->compressed_fb)); 562 589 563 - size = intel_fbc_calculate_cfb_size(crtc, fb); 564 - fb_cpp = drm_format_plane_cpp(fb->pixel_format, 0); 590 + size = intel_fbc_calculate_cfb_size(dev_priv, &fbc->state_cache); 591 + fb_cpp = drm_format_plane_cpp(fbc->state_cache.fb.pixel_format, 0); 565 592 566 - ret = find_compression_threshold(dev_priv, &dev_priv->fbc.compressed_fb, 593 + ret = find_compression_threshold(dev_priv, &fbc->compressed_fb, 567 594 size, fb_cpp); 568 595 if (!ret) 569 596 goto err_llb; ··· 572 599 573 600 } 574 601 575 - dev_priv->fbc.threshold = ret; 602 + fbc->threshold = ret; 576 603 577 604 if (INTEL_INFO(dev_priv)->gen >= 5) 578 - I915_WRITE(ILK_DPFC_CB_BASE, dev_priv->fbc.compressed_fb.start); 605 + I915_WRITE(ILK_DPFC_CB_BASE, fbc->compressed_fb.start); 579 606 else if (IS_GM45(dev_priv)) { 580 - I915_WRITE(DPFC_CB_BASE, dev_priv->fbc.compressed_fb.start); 607 + I915_WRITE(DPFC_CB_BASE, fbc->compressed_fb.start); 581 608 } else { 582 609 compressed_llb = kzalloc(sizeof(*compressed_llb), GFP_KERNEL); 583 610 if (!compressed_llb) ··· 588 615 if (ret) 589 616 goto err_fb; 590 617 591 - dev_priv->fbc.compressed_llb = compressed_llb; 618 + fbc->compressed_llb = compressed_llb; 592 619 593 620 I915_WRITE(FBC_CFB_BASE, 594 - dev_priv->mm.stolen_base + dev_priv->fbc.compressed_fb.start); 621 + dev_priv->mm.stolen_base + fbc->compressed_fb.start); 595 622 I915_WRITE(FBC_LL_BASE, 596 623 dev_priv->mm.stolen_base + compressed_llb->start); 597 624 } 598 625 599 626 DRM_DEBUG_KMS("reserved %llu bytes of contiguous stolen space for FBC, threshold: %d\n", 600 - dev_priv->fbc.compressed_fb.size, 601 - dev_priv->fbc.threshold); 627 + fbc->compressed_fb.size, fbc->threshold); 602 628 603 629 return 0; 604 630 605 631 err_fb: 606 632 kfree(compressed_llb); 607 - i915_gem_stolen_remove_node(dev_priv, &dev_priv->fbc.compressed_fb); 633 + i915_gem_stolen_remove_node(dev_priv, &fbc->compressed_fb); 608 634 err_llb: 609 635 pr_info_once("drm: not enough stolen space for compressed buffer (need %d more bytes), disabling. Hint: you may be able to increase stolen memory size in the BIOS to avoid this.\n", size); 610 636 return -ENOSPC; ··· 611 639 612 640 static void __intel_fbc_cleanup_cfb(struct drm_i915_private *dev_priv) 613 641 { 614 - if (drm_mm_node_allocated(&dev_priv->fbc.compressed_fb)) 615 - i915_gem_stolen_remove_node(dev_priv, 616 - &dev_priv->fbc.compressed_fb); 642 + struct intel_fbc *fbc = &dev_priv->fbc; 617 643 618 - if (dev_priv->fbc.compressed_llb) { 619 - i915_gem_stolen_remove_node(dev_priv, 620 - dev_priv->fbc.compressed_llb); 621 - kfree(dev_priv->fbc.compressed_llb); 644 + if (drm_mm_node_allocated(&fbc->compressed_fb)) 645 + i915_gem_stolen_remove_node(dev_priv, &fbc->compressed_fb); 646 + 647 + if (fbc->compressed_llb) { 648 + i915_gem_stolen_remove_node(dev_priv, fbc->compressed_llb); 649 + kfree(fbc->compressed_llb); 622 650 } 623 651 } 624 652 625 653 void intel_fbc_cleanup_cfb(struct drm_i915_private *dev_priv) 626 654 { 655 + struct intel_fbc *fbc = &dev_priv->fbc; 656 + 627 657 if (!fbc_supported(dev_priv)) 628 658 return; 629 659 630 - mutex_lock(&dev_priv->fbc.lock); 660 + mutex_lock(&fbc->lock); 631 661 __intel_fbc_cleanup_cfb(dev_priv); 632 - mutex_unlock(&dev_priv->fbc.lock); 662 + mutex_unlock(&fbc->lock); 633 663 } 634 664 635 665 static bool stride_is_valid(struct drm_i915_private *dev_priv, ··· 655 681 return true; 656 682 } 657 683 658 - static bool pixel_format_is_valid(struct drm_framebuffer *fb) 684 + static bool pixel_format_is_valid(struct drm_i915_private *dev_priv, 685 + uint32_t pixel_format) 659 686 { 660 - struct drm_device *dev = fb->dev; 661 - struct drm_i915_private *dev_priv = dev->dev_private; 662 - 663 - switch (fb->pixel_format) { 687 + switch (pixel_format) { 664 688 case DRM_FORMAT_XRGB8888: 665 689 case DRM_FORMAT_XBGR8888: 666 690 return true; 667 691 case DRM_FORMAT_XRGB1555: 668 692 case DRM_FORMAT_RGB565: 669 693 /* 16bpp not supported on gen2 */ 670 - if (IS_GEN2(dev)) 694 + if (IS_GEN2(dev_priv)) 671 695 return false; 672 696 /* WaFbcOnly1to1Ratio:ctg */ 673 697 if (IS_G4X(dev_priv)) ··· 685 713 static bool intel_fbc_hw_tracking_covers_screen(struct intel_crtc *crtc) 686 714 { 687 715 struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; 716 + struct intel_fbc *fbc = &dev_priv->fbc; 688 717 unsigned int effective_w, effective_h, max_w, max_h; 689 718 690 719 if (INTEL_INFO(dev_priv)->gen >= 8 || IS_HASWELL(dev_priv)) { ··· 699 726 max_h = 1536; 700 727 } 701 728 702 - intel_fbc_get_plane_source_size(crtc, &effective_w, &effective_h); 729 + intel_fbc_get_plane_source_size(&fbc->state_cache, &effective_w, 730 + &effective_h); 703 731 effective_w += crtc->adjusted_x; 704 732 effective_h += crtc->adjusted_y; 705 733 706 734 return effective_w <= max_w && effective_h <= max_h; 707 735 } 708 736 709 - /** 710 - * __intel_fbc_update - activate/deactivate FBC as needed, unlocked 711 - * @crtc: the CRTC that triggered the update 712 - * 713 - * This function completely reevaluates the status of FBC, then activates, 714 - * deactivates or maintains it on the same state. 715 - */ 716 - static void __intel_fbc_update(struct intel_crtc *crtc) 737 + static void intel_fbc_update_state_cache(struct intel_crtc *crtc) 717 738 { 718 739 struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; 719 - struct drm_framebuffer *fb; 740 + struct intel_fbc *fbc = &dev_priv->fbc; 741 + struct intel_fbc_state_cache *cache = &fbc->state_cache; 742 + struct intel_crtc_state *crtc_state = 743 + to_intel_crtc_state(crtc->base.state); 744 + struct intel_plane_state *plane_state = 745 + to_intel_plane_state(crtc->base.primary->state); 746 + struct drm_framebuffer *fb = plane_state->base.fb; 720 747 struct drm_i915_gem_object *obj; 721 - const struct drm_display_mode *adjusted_mode; 722 748 723 - WARN_ON(!mutex_is_locked(&dev_priv->fbc.lock)); 749 + WARN_ON(!drm_modeset_is_locked(&crtc->base.mutex)); 750 + WARN_ON(!drm_modeset_is_locked(&crtc->base.primary->mutex)); 724 751 725 - if (!multiple_pipes_ok(dev_priv)) { 726 - set_no_fbc_reason(dev_priv, "more than one pipe active"); 727 - goto out_disable; 728 - } 752 + cache->crtc.mode_flags = crtc_state->base.adjusted_mode.flags; 753 + if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) 754 + cache->crtc.hsw_bdw_pixel_rate = 755 + ilk_pipe_pixel_rate(crtc_state); 729 756 730 - if (!dev_priv->fbc.enabled || dev_priv->fbc.crtc != crtc) 757 + cache->plane.rotation = plane_state->base.rotation; 758 + cache->plane.src_w = drm_rect_width(&plane_state->src) >> 16; 759 + cache->plane.src_h = drm_rect_height(&plane_state->src) >> 16; 760 + cache->plane.visible = plane_state->visible; 761 + 762 + if (!cache->plane.visible) 731 763 return; 732 764 733 - if (!crtc_is_valid(crtc)) { 734 - set_no_fbc_reason(dev_priv, "no output"); 735 - goto out_disable; 765 + obj = intel_fb_obj(fb); 766 + 767 + /* FIXME: We lack the proper locking here, so only run this on the 768 + * platforms that need. */ 769 + if (INTEL_INFO(dev_priv)->gen >= 5 && INTEL_INFO(dev_priv)->gen < 7) 770 + cache->fb.ilk_ggtt_offset = i915_gem_obj_ggtt_offset(obj); 771 + cache->fb.pixel_format = fb->pixel_format; 772 + cache->fb.stride = fb->pitches[0]; 773 + cache->fb.fence_reg = obj->fence_reg; 774 + cache->fb.tiling_mode = obj->tiling_mode; 775 + } 776 + 777 + static bool intel_fbc_can_activate(struct intel_crtc *crtc) 778 + { 779 + struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; 780 + struct intel_fbc *fbc = &dev_priv->fbc; 781 + struct intel_fbc_state_cache *cache = &fbc->state_cache; 782 + 783 + if (!cache->plane.visible) { 784 + fbc->no_fbc_reason = "primary plane not visible"; 785 + return false; 736 786 } 737 787 738 - fb = crtc->base.primary->fb; 739 - obj = intel_fb_obj(fb); 740 - adjusted_mode = &crtc->config->base.adjusted_mode; 741 - 742 - if ((adjusted_mode->flags & DRM_MODE_FLAG_INTERLACE) || 743 - (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN)) { 744 - set_no_fbc_reason(dev_priv, "incompatible mode"); 745 - goto out_disable; 788 + if ((cache->crtc.mode_flags & DRM_MODE_FLAG_INTERLACE) || 789 + (cache->crtc.mode_flags & DRM_MODE_FLAG_DBLSCAN)) { 790 + fbc->no_fbc_reason = "incompatible mode"; 791 + return false; 746 792 } 747 793 748 794 if (!intel_fbc_hw_tracking_covers_screen(crtc)) { 749 - set_no_fbc_reason(dev_priv, "mode too large for compression"); 750 - goto out_disable; 795 + fbc->no_fbc_reason = "mode too large for compression"; 796 + return false; 751 797 } 752 798 753 799 /* The use of a CPU fence is mandatory in order to detect writes 754 800 * by the CPU to the scanout and trigger updates to the FBC. 755 801 */ 756 - if (obj->tiling_mode != I915_TILING_X || 757 - obj->fence_reg == I915_FENCE_REG_NONE) { 758 - set_no_fbc_reason(dev_priv, "framebuffer not tiled or fenced"); 759 - goto out_disable; 802 + if (cache->fb.tiling_mode != I915_TILING_X || 803 + cache->fb.fence_reg == I915_FENCE_REG_NONE) { 804 + fbc->no_fbc_reason = "framebuffer not tiled or fenced"; 805 + return false; 760 806 } 761 807 if (INTEL_INFO(dev_priv)->gen <= 4 && !IS_G4X(dev_priv) && 762 - crtc->base.primary->state->rotation != BIT(DRM_ROTATE_0)) { 763 - set_no_fbc_reason(dev_priv, "rotation unsupported"); 764 - goto out_disable; 808 + cache->plane.rotation != BIT(DRM_ROTATE_0)) { 809 + fbc->no_fbc_reason = "rotation unsupported"; 810 + return false; 765 811 } 766 812 767 - if (!stride_is_valid(dev_priv, fb->pitches[0])) { 768 - set_no_fbc_reason(dev_priv, "framebuffer stride not supported"); 769 - goto out_disable; 813 + if (!stride_is_valid(dev_priv, cache->fb.stride)) { 814 + fbc->no_fbc_reason = "framebuffer stride not supported"; 815 + return false; 770 816 } 771 817 772 - if (!pixel_format_is_valid(fb)) { 773 - set_no_fbc_reason(dev_priv, "pixel format is invalid"); 774 - goto out_disable; 818 + if (!pixel_format_is_valid(dev_priv, cache->fb.pixel_format)) { 819 + fbc->no_fbc_reason = "pixel format is invalid"; 820 + return false; 775 821 } 776 822 777 823 /* WaFbcExceedCdClockThreshold:hsw,bdw */ 778 824 if ((IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) && 779 - ilk_pipe_pixel_rate(crtc->config) >= 780 - dev_priv->cdclk_freq * 95 / 100) { 781 - set_no_fbc_reason(dev_priv, "pixel rate is too big"); 782 - goto out_disable; 825 + cache->crtc.hsw_bdw_pixel_rate >= dev_priv->cdclk_freq * 95 / 100) { 826 + fbc->no_fbc_reason = "pixel rate is too big"; 827 + return false; 783 828 } 784 829 785 830 /* It is possible for the required CFB size change without a ··· 810 819 * we didn't get any invalidate/deactivate calls, but this would require 811 820 * a lot of tracking just for a specific case. If we conclude it's an 812 821 * important case, we can implement it later. */ 813 - if (intel_fbc_calculate_cfb_size(crtc, fb) > 814 - dev_priv->fbc.compressed_fb.size * dev_priv->fbc.threshold) { 815 - set_no_fbc_reason(dev_priv, "CFB requirements changed"); 816 - goto out_disable; 822 + if (intel_fbc_calculate_cfb_size(dev_priv, &fbc->state_cache) > 823 + fbc->compressed_fb.size * fbc->threshold) { 824 + fbc->no_fbc_reason = "CFB requirements changed"; 825 + return false; 817 826 } 827 + 828 + return true; 829 + } 830 + 831 + static bool intel_fbc_can_choose(struct intel_crtc *crtc) 832 + { 833 + struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; 834 + struct intel_fbc *fbc = &dev_priv->fbc; 835 + 836 + if (intel_vgpu_active(dev_priv->dev)) { 837 + fbc->no_fbc_reason = "VGPU is active"; 838 + return false; 839 + } 840 + 841 + if (i915.enable_fbc < 0) { 842 + fbc->no_fbc_reason = "disabled per chip default"; 843 + return false; 844 + } 845 + 846 + if (!i915.enable_fbc) { 847 + fbc->no_fbc_reason = "disabled per module param"; 848 + return false; 849 + } 850 + 851 + if (fbc_on_pipe_a_only(dev_priv) && crtc->pipe != PIPE_A) { 852 + fbc->no_fbc_reason = "no enabled pipes can have FBC"; 853 + return false; 854 + } 855 + 856 + if (fbc_on_plane_a_only(dev_priv) && crtc->plane != PLANE_A) { 857 + fbc->no_fbc_reason = "no enabled planes can have FBC"; 858 + return false; 859 + } 860 + 861 + return true; 862 + } 863 + 864 + static void intel_fbc_get_reg_params(struct intel_crtc *crtc, 865 + struct intel_fbc_reg_params *params) 866 + { 867 + struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; 868 + struct intel_fbc *fbc = &dev_priv->fbc; 869 + struct intel_fbc_state_cache *cache = &fbc->state_cache; 870 + 871 + /* Since all our fields are integer types, use memset here so the 872 + * comparison function can rely on memcmp because the padding will be 873 + * zero. */ 874 + memset(params, 0, sizeof(*params)); 875 + 876 + params->crtc.pipe = crtc->pipe; 877 + params->crtc.plane = crtc->plane; 878 + params->crtc.fence_y_offset = get_crtc_fence_y_offset(crtc); 879 + 880 + params->fb.pixel_format = cache->fb.pixel_format; 881 + params->fb.stride = cache->fb.stride; 882 + params->fb.fence_reg = cache->fb.fence_reg; 883 + 884 + params->cfb_size = intel_fbc_calculate_cfb_size(dev_priv, cache); 885 + 886 + params->fb.ggtt_offset = cache->fb.ilk_ggtt_offset; 887 + } 888 + 889 + static bool intel_fbc_reg_params_equal(struct intel_fbc_reg_params *params1, 890 + struct intel_fbc_reg_params *params2) 891 + { 892 + /* We can use this since intel_fbc_get_reg_params() does a memset. */ 893 + return memcmp(params1, params2, sizeof(*params1)) == 0; 894 + } 895 + 896 + void intel_fbc_pre_update(struct intel_crtc *crtc) 897 + { 898 + struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; 899 + struct intel_fbc *fbc = &dev_priv->fbc; 900 + 901 + if (!fbc_supported(dev_priv)) 902 + return; 903 + 904 + mutex_lock(&fbc->lock); 905 + 906 + if (!multiple_pipes_ok(crtc)) { 907 + fbc->no_fbc_reason = "more than one pipe active"; 908 + goto deactivate; 909 + } 910 + 911 + if (!fbc->enabled || fbc->crtc != crtc) 912 + goto unlock; 913 + 914 + intel_fbc_update_state_cache(crtc); 915 + 916 + deactivate: 917 + intel_fbc_deactivate(dev_priv); 918 + unlock: 919 + mutex_unlock(&fbc->lock); 920 + } 921 + 922 + static void __intel_fbc_post_update(struct intel_crtc *crtc) 923 + { 924 + struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; 925 + struct intel_fbc *fbc = &dev_priv->fbc; 926 + struct intel_fbc_reg_params old_params; 927 + 928 + WARN_ON(!mutex_is_locked(&fbc->lock)); 929 + 930 + if (!fbc->enabled || fbc->crtc != crtc) 931 + return; 932 + 933 + if (!intel_fbc_can_activate(crtc)) { 934 + WARN_ON(fbc->active); 935 + return; 936 + } 937 + 938 + old_params = fbc->params; 939 + intel_fbc_get_reg_params(crtc, &fbc->params); 818 940 819 941 /* If the scanout has not changed, don't modify the FBC settings. 820 942 * Note that we make the fundamental assumption that the fb->obj 821 943 * cannot be unpinned (and have its GTT offset and fence revoked) 822 944 * without first being decoupled from the scanout and FBC disabled. 823 945 */ 824 - if (dev_priv->fbc.crtc == crtc && 825 - dev_priv->fbc.fb_id == fb->base.id && 826 - dev_priv->fbc.y == crtc->base.y && 827 - dev_priv->fbc.active) 946 + if (fbc->active && 947 + intel_fbc_reg_params_equal(&old_params, &fbc->params)) 828 948 return; 829 949 830 - if (intel_fbc_is_active(dev_priv)) { 831 - /* We update FBC along two paths, after changing fb/crtc 832 - * configuration (modeswitching) and after page-flipping 833 - * finishes. For the latter, we know that not only did 834 - * we disable the FBC at the start of the page-flip 835 - * sequence, but also more than one vblank has passed. 836 - * 837 - * For the former case of modeswitching, it is possible 838 - * to switch between two FBC valid configurations 839 - * instantaneously so we do need to disable the FBC 840 - * before we can modify its control registers. We also 841 - * have to wait for the next vblank for that to take 842 - * effect. However, since we delay enabling FBC we can 843 - * assume that a vblank has passed since disabling and 844 - * that we can safely alter the registers in the deferred 845 - * callback. 846 - * 847 - * In the scenario that we go from a valid to invalid 848 - * and then back to valid FBC configuration we have 849 - * no strict enforcement that a vblank occurred since 850 - * disabling the FBC. However, along all current pipe 851 - * disabling paths we do need to wait for a vblank at 852 - * some point. And we wait before enabling FBC anyway. 853 - */ 854 - DRM_DEBUG_KMS("deactivating FBC for update\n"); 855 - __intel_fbc_deactivate(dev_priv); 856 - } 857 - 950 + intel_fbc_deactivate(dev_priv); 858 951 intel_fbc_schedule_activation(crtc); 859 - dev_priv->fbc.no_fbc_reason = "FBC enabled (not necessarily active)"; 860 - return; 861 - 862 - out_disable: 863 - /* Multiple disables should be harmless */ 864 - if (intel_fbc_is_active(dev_priv)) { 865 - DRM_DEBUG_KMS("unsupported config, deactivating FBC\n"); 866 - __intel_fbc_deactivate(dev_priv); 867 - } 952 + fbc->no_fbc_reason = "FBC enabled (active or scheduled)"; 868 953 } 869 954 870 - /* 871 - * intel_fbc_update - activate/deactivate FBC as needed 872 - * @crtc: the CRTC that triggered the update 873 - * 874 - * This function reevaluates the overall state and activates or deactivates FBC. 875 - */ 876 - void intel_fbc_update(struct intel_crtc *crtc) 955 + void intel_fbc_post_update(struct intel_crtc *crtc) 877 956 { 878 957 struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; 958 + struct intel_fbc *fbc = &dev_priv->fbc; 879 959 880 960 if (!fbc_supported(dev_priv)) 881 961 return; 882 962 883 - mutex_lock(&dev_priv->fbc.lock); 884 - __intel_fbc_update(crtc); 885 - mutex_unlock(&dev_priv->fbc.lock); 963 + mutex_lock(&fbc->lock); 964 + __intel_fbc_post_update(crtc); 965 + mutex_unlock(&fbc->lock); 966 + } 967 + 968 + static unsigned int intel_fbc_get_frontbuffer_bit(struct intel_fbc *fbc) 969 + { 970 + if (fbc->enabled) 971 + return to_intel_plane(fbc->crtc->base.primary)->frontbuffer_bit; 972 + else 973 + return fbc->possible_framebuffer_bits; 886 974 } 887 975 888 976 void intel_fbc_invalidate(struct drm_i915_private *dev_priv, 889 977 unsigned int frontbuffer_bits, 890 978 enum fb_op_origin origin) 891 979 { 892 - unsigned int fbc_bits; 980 + struct intel_fbc *fbc = &dev_priv->fbc; 893 981 894 982 if (!fbc_supported(dev_priv)) 895 983 return; 896 984 897 - if (origin == ORIGIN_GTT) 985 + if (origin == ORIGIN_GTT || origin == ORIGIN_FLIP) 898 986 return; 899 987 900 - mutex_lock(&dev_priv->fbc.lock); 988 + mutex_lock(&fbc->lock); 901 989 902 - if (dev_priv->fbc.enabled) 903 - fbc_bits = INTEL_FRONTBUFFER_PRIMARY(dev_priv->fbc.crtc->pipe); 904 - else 905 - fbc_bits = dev_priv->fbc.possible_framebuffer_bits; 990 + fbc->busy_bits |= intel_fbc_get_frontbuffer_bit(fbc) & frontbuffer_bits; 906 991 907 - dev_priv->fbc.busy_bits |= (fbc_bits & frontbuffer_bits); 992 + if (fbc->enabled && fbc->busy_bits) 993 + intel_fbc_deactivate(dev_priv); 908 994 909 - if (dev_priv->fbc.busy_bits) 910 - __intel_fbc_deactivate(dev_priv); 911 - 912 - mutex_unlock(&dev_priv->fbc.lock); 995 + mutex_unlock(&fbc->lock); 913 996 } 914 997 915 998 void intel_fbc_flush(struct drm_i915_private *dev_priv, 916 999 unsigned int frontbuffer_bits, enum fb_op_origin origin) 917 1000 { 1001 + struct intel_fbc *fbc = &dev_priv->fbc; 1002 + 918 1003 if (!fbc_supported(dev_priv)) 919 1004 return; 920 1005 921 - if (origin == ORIGIN_GTT) 1006 + if (origin == ORIGIN_GTT || origin == ORIGIN_FLIP) 922 1007 return; 923 1008 924 - mutex_lock(&dev_priv->fbc.lock); 1009 + mutex_lock(&fbc->lock); 925 1010 926 - dev_priv->fbc.busy_bits &= ~frontbuffer_bits; 1011 + fbc->busy_bits &= ~frontbuffer_bits; 927 1012 928 - if (!dev_priv->fbc.busy_bits && dev_priv->fbc.enabled) { 929 - if (origin != ORIGIN_FLIP && dev_priv->fbc.active) { 1013 + if (!fbc->busy_bits && fbc->enabled && 1014 + (frontbuffer_bits & intel_fbc_get_frontbuffer_bit(fbc))) { 1015 + if (fbc->active) 930 1016 intel_fbc_recompress(dev_priv); 931 - } else { 932 - __intel_fbc_deactivate(dev_priv); 933 - __intel_fbc_update(dev_priv->fbc.crtc); 1017 + else 1018 + __intel_fbc_post_update(fbc->crtc); 1019 + } 1020 + 1021 + mutex_unlock(&fbc->lock); 1022 + } 1023 + 1024 + /** 1025 + * intel_fbc_choose_crtc - select a CRTC to enable FBC on 1026 + * @dev_priv: i915 device instance 1027 + * @state: the atomic state structure 1028 + * 1029 + * This function looks at the proposed state for CRTCs and planes, then chooses 1030 + * which pipe is going to have FBC by setting intel_crtc_state->enable_fbc to 1031 + * true. 1032 + * 1033 + * Later, intel_fbc_enable is going to look for state->enable_fbc and then maybe 1034 + * enable FBC for the chosen CRTC. If it does, it will set dev_priv->fbc.crtc. 1035 + */ 1036 + void intel_fbc_choose_crtc(struct drm_i915_private *dev_priv, 1037 + struct drm_atomic_state *state) 1038 + { 1039 + struct intel_fbc *fbc = &dev_priv->fbc; 1040 + struct drm_crtc *crtc; 1041 + struct drm_crtc_state *crtc_state; 1042 + struct drm_plane *plane; 1043 + struct drm_plane_state *plane_state; 1044 + bool fbc_crtc_present = false; 1045 + int i, j; 1046 + 1047 + mutex_lock(&fbc->lock); 1048 + 1049 + for_each_crtc_in_state(state, crtc, crtc_state, i) { 1050 + if (fbc->crtc == to_intel_crtc(crtc)) { 1051 + fbc_crtc_present = true; 1052 + break; 1053 + } 1054 + } 1055 + /* This atomic commit doesn't involve the CRTC currently tied to FBC. */ 1056 + if (!fbc_crtc_present && fbc->crtc != NULL) 1057 + goto out; 1058 + 1059 + /* Simply choose the first CRTC that is compatible and has a visible 1060 + * plane. We could go for fancier schemes such as checking the plane 1061 + * size, but this would just affect the few platforms that don't tie FBC 1062 + * to pipe or plane A. */ 1063 + for_each_plane_in_state(state, plane, plane_state, i) { 1064 + struct intel_plane_state *intel_plane_state = 1065 + to_intel_plane_state(plane_state); 1066 + 1067 + if (!intel_plane_state->visible) 1068 + continue; 1069 + 1070 + for_each_crtc_in_state(state, crtc, crtc_state, j) { 1071 + struct intel_crtc_state *intel_crtc_state = 1072 + to_intel_crtc_state(crtc_state); 1073 + 1074 + if (plane_state->crtc != crtc) 1075 + continue; 1076 + 1077 + if (!intel_fbc_can_choose(to_intel_crtc(crtc))) 1078 + break; 1079 + 1080 + intel_crtc_state->enable_fbc = true; 1081 + goto out; 934 1082 } 935 1083 } 936 1084 937 - mutex_unlock(&dev_priv->fbc.lock); 1085 + out: 1086 + mutex_unlock(&fbc->lock); 938 1087 } 939 1088 940 1089 /** 941 1090 * intel_fbc_enable: tries to enable FBC on the CRTC 942 1091 * @crtc: the CRTC 943 1092 * 944 - * This function checks if it's possible to enable FBC on the following CRTC, 945 - * then enables it. Notice that it doesn't activate FBC. 1093 + * This function checks if the given CRTC was chosen for FBC, then enables it if 1094 + * possible. Notice that it doesn't activate FBC. It is valid to call 1095 + * intel_fbc_enable multiple times for the same pipe without an 1096 + * intel_fbc_disable in the middle, as long as it is deactivated. 946 1097 */ 947 1098 void intel_fbc_enable(struct intel_crtc *crtc) 948 1099 { 949 1100 struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; 1101 + struct intel_fbc *fbc = &dev_priv->fbc; 950 1102 951 1103 if (!fbc_supported(dev_priv)) 952 1104 return; 953 1105 954 - mutex_lock(&dev_priv->fbc.lock); 1106 + mutex_lock(&fbc->lock); 955 1107 956 - if (dev_priv->fbc.enabled) { 957 - WARN_ON(dev_priv->fbc.crtc == crtc); 1108 + if (fbc->enabled) { 1109 + WARN_ON(fbc->crtc == NULL); 1110 + if (fbc->crtc == crtc) { 1111 + WARN_ON(!crtc->config->enable_fbc); 1112 + WARN_ON(fbc->active); 1113 + } 958 1114 goto out; 959 1115 } 960 1116 961 - WARN_ON(dev_priv->fbc.active); 962 - WARN_ON(dev_priv->fbc.crtc != NULL); 963 - 964 - if (intel_vgpu_active(dev_priv->dev)) { 965 - set_no_fbc_reason(dev_priv, "VGPU is active"); 1117 + if (!crtc->config->enable_fbc) 966 1118 goto out; 967 - } 968 1119 969 - if (i915.enable_fbc < 0) { 970 - set_no_fbc_reason(dev_priv, "disabled per chip default"); 971 - goto out; 972 - } 1120 + WARN_ON(fbc->active); 1121 + WARN_ON(fbc->crtc != NULL); 973 1122 974 - if (!i915.enable_fbc) { 975 - set_no_fbc_reason(dev_priv, "disabled per module param"); 976 - goto out; 977 - } 978 - 979 - if (!crtc_can_fbc(crtc)) { 980 - set_no_fbc_reason(dev_priv, "no enabled pipes can have FBC"); 981 - goto out; 982 - } 983 - 1123 + intel_fbc_update_state_cache(crtc); 984 1124 if (intel_fbc_alloc_cfb(crtc)) { 985 - set_no_fbc_reason(dev_priv, "not enough stolen memory"); 1125 + fbc->no_fbc_reason = "not enough stolen memory"; 986 1126 goto out; 987 1127 } 988 1128 989 1129 DRM_DEBUG_KMS("Enabling FBC on pipe %c\n", pipe_name(crtc->pipe)); 990 - dev_priv->fbc.no_fbc_reason = "FBC enabled but not active yet\n"; 1130 + fbc->no_fbc_reason = "FBC enabled but not active yet\n"; 991 1131 992 - dev_priv->fbc.enabled = true; 993 - dev_priv->fbc.crtc = crtc; 1132 + fbc->enabled = true; 1133 + fbc->crtc = crtc; 994 1134 out: 995 - mutex_unlock(&dev_priv->fbc.lock); 1135 + mutex_unlock(&fbc->lock); 996 1136 } 997 1137 998 1138 /** ··· 1135 1013 */ 1136 1014 static void __intel_fbc_disable(struct drm_i915_private *dev_priv) 1137 1015 { 1138 - struct intel_crtc *crtc = dev_priv->fbc.crtc; 1016 + struct intel_fbc *fbc = &dev_priv->fbc; 1017 + struct intel_crtc *crtc = fbc->crtc; 1139 1018 1140 - WARN_ON(!mutex_is_locked(&dev_priv->fbc.lock)); 1141 - WARN_ON(!dev_priv->fbc.enabled); 1142 - WARN_ON(dev_priv->fbc.active); 1143 - assert_pipe_disabled(dev_priv, crtc->pipe); 1019 + WARN_ON(!mutex_is_locked(&fbc->lock)); 1020 + WARN_ON(!fbc->enabled); 1021 + WARN_ON(fbc->active); 1022 + WARN_ON(crtc->active); 1144 1023 1145 1024 DRM_DEBUG_KMS("Disabling FBC on pipe %c\n", pipe_name(crtc->pipe)); 1146 1025 1147 1026 __intel_fbc_cleanup_cfb(dev_priv); 1148 1027 1149 - dev_priv->fbc.enabled = false; 1150 - dev_priv->fbc.crtc = NULL; 1028 + fbc->enabled = false; 1029 + fbc->crtc = NULL; 1151 1030 } 1152 1031 1153 1032 /** 1154 - * intel_fbc_disable_crtc - disable FBC if it's associated with crtc 1033 + * intel_fbc_disable - disable FBC if it's associated with crtc 1155 1034 * @crtc: the CRTC 1156 1035 * 1157 1036 * This function disables FBC if it's associated with the provided CRTC. 1158 1037 */ 1159 - void intel_fbc_disable_crtc(struct intel_crtc *crtc) 1038 + void intel_fbc_disable(struct intel_crtc *crtc) 1160 1039 { 1161 1040 struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; 1041 + struct intel_fbc *fbc = &dev_priv->fbc; 1162 1042 1163 1043 if (!fbc_supported(dev_priv)) 1164 1044 return; 1165 1045 1166 - mutex_lock(&dev_priv->fbc.lock); 1167 - if (dev_priv->fbc.crtc == crtc) { 1168 - WARN_ON(!dev_priv->fbc.enabled); 1169 - WARN_ON(dev_priv->fbc.active); 1046 + mutex_lock(&fbc->lock); 1047 + if (fbc->crtc == crtc) { 1048 + WARN_ON(!fbc->enabled); 1049 + WARN_ON(fbc->active); 1170 1050 __intel_fbc_disable(dev_priv); 1171 1051 } 1172 - mutex_unlock(&dev_priv->fbc.lock); 1052 + mutex_unlock(&fbc->lock); 1053 + 1054 + cancel_work_sync(&fbc->work.work); 1173 1055 } 1174 1056 1175 1057 /** 1176 - * intel_fbc_disable - globally disable FBC 1058 + * intel_fbc_global_disable - globally disable FBC 1177 1059 * @dev_priv: i915 device instance 1178 1060 * 1179 1061 * This function disables FBC regardless of which CRTC is associated with it. 1180 1062 */ 1181 - void intel_fbc_disable(struct drm_i915_private *dev_priv) 1063 + void intel_fbc_global_disable(struct drm_i915_private *dev_priv) 1182 1064 { 1065 + struct intel_fbc *fbc = &dev_priv->fbc; 1066 + 1183 1067 if (!fbc_supported(dev_priv)) 1184 1068 return; 1185 1069 1186 - mutex_lock(&dev_priv->fbc.lock); 1187 - if (dev_priv->fbc.enabled) 1070 + mutex_lock(&fbc->lock); 1071 + if (fbc->enabled) 1188 1072 __intel_fbc_disable(dev_priv); 1189 - mutex_unlock(&dev_priv->fbc.lock); 1073 + mutex_unlock(&fbc->lock); 1074 + 1075 + cancel_work_sync(&fbc->work.work); 1076 + } 1077 + 1078 + /** 1079 + * intel_fbc_init_pipe_state - initialize FBC's CRTC visibility tracking 1080 + * @dev_priv: i915 device instance 1081 + * 1082 + * The FBC code needs to track CRTC visibility since the older platforms can't 1083 + * have FBC enabled while multiple pipes are used. This function does the 1084 + * initial setup at driver load to make sure FBC is matching the real hardware. 1085 + */ 1086 + void intel_fbc_init_pipe_state(struct drm_i915_private *dev_priv) 1087 + { 1088 + struct intel_crtc *crtc; 1089 + 1090 + /* Don't even bother tracking anything if we don't need. */ 1091 + if (!no_fbc_on_multiple_pipes(dev_priv)) 1092 + return; 1093 + 1094 + for_each_intel_crtc(dev_priv->dev, crtc) 1095 + if (intel_crtc_active(&crtc->base) && 1096 + to_intel_plane_state(crtc->base.primary->state)->visible) 1097 + dev_priv->fbc.visible_pipes_mask |= (1 << crtc->pipe); 1190 1098 } 1191 1099 1192 1100 /** ··· 1227 1075 */ 1228 1076 void intel_fbc_init(struct drm_i915_private *dev_priv) 1229 1077 { 1078 + struct intel_fbc *fbc = &dev_priv->fbc; 1230 1079 enum pipe pipe; 1231 1080 1232 - INIT_WORK(&dev_priv->fbc.work.work, intel_fbc_work_fn); 1233 - mutex_init(&dev_priv->fbc.lock); 1234 - dev_priv->fbc.enabled = false; 1235 - dev_priv->fbc.active = false; 1236 - dev_priv->fbc.work.scheduled = false; 1081 + INIT_WORK(&fbc->work.work, intel_fbc_work_fn); 1082 + mutex_init(&fbc->lock); 1083 + fbc->enabled = false; 1084 + fbc->active = false; 1085 + fbc->work.scheduled = false; 1237 1086 1238 1087 if (!HAS_FBC(dev_priv)) { 1239 - dev_priv->fbc.no_fbc_reason = "unsupported by this chipset"; 1088 + fbc->no_fbc_reason = "unsupported by this chipset"; 1240 1089 return; 1241 1090 } 1242 1091 1243 1092 for_each_pipe(dev_priv, pipe) { 1244 - dev_priv->fbc.possible_framebuffer_bits |= 1093 + fbc->possible_framebuffer_bits |= 1245 1094 INTEL_FRONTBUFFER_PRIMARY(pipe); 1246 1095 1247 1096 if (fbc_on_pipe_a_only(dev_priv)) 1248 1097 break; 1249 1098 } 1250 1099 1251 - if (INTEL_INFO(dev_priv)->gen >= 7) { 1252 - dev_priv->fbc.is_active = ilk_fbc_is_active; 1253 - dev_priv->fbc.activate = gen7_fbc_activate; 1254 - dev_priv->fbc.deactivate = ilk_fbc_deactivate; 1255 - } else if (INTEL_INFO(dev_priv)->gen >= 5) { 1256 - dev_priv->fbc.is_active = ilk_fbc_is_active; 1257 - dev_priv->fbc.activate = ilk_fbc_activate; 1258 - dev_priv->fbc.deactivate = ilk_fbc_deactivate; 1259 - } else if (IS_GM45(dev_priv)) { 1260 - dev_priv->fbc.is_active = g4x_fbc_is_active; 1261 - dev_priv->fbc.activate = g4x_fbc_activate; 1262 - dev_priv->fbc.deactivate = g4x_fbc_deactivate; 1263 - } else { 1264 - dev_priv->fbc.is_active = i8xx_fbc_is_active; 1265 - dev_priv->fbc.activate = i8xx_fbc_activate; 1266 - dev_priv->fbc.deactivate = i8xx_fbc_deactivate; 1267 - 1268 - /* This value was pulled out of someone's hat */ 1100 + /* This value was pulled out of someone's hat */ 1101 + if (INTEL_INFO(dev_priv)->gen <= 4 && !IS_GM45(dev_priv)) 1269 1102 I915_WRITE(FBC_CONTROL, 500 << FBC_CTL_INTERVAL_SHIFT); 1270 - } 1271 1103 1272 1104 /* We still don't have any sort of hardware state readout for FBC, so 1273 1105 * deactivate it in case the BIOS activated it to make sure software 1274 1106 * matches the hardware state. */ 1275 - if (dev_priv->fbc.is_active(dev_priv)) 1276 - dev_priv->fbc.deactivate(dev_priv); 1107 + if (intel_fbc_hw_is_active(dev_priv)) 1108 + intel_fbc_hw_deactivate(dev_priv); 1277 1109 }
+3 -3
drivers/gpu/drm/i915/intel_guc.h
··· 46 46 uint32_t wq_head; 47 47 48 48 /* GuC submission statistics & status */ 49 - uint64_t submissions[I915_NUM_RINGS]; 49 + uint64_t submissions[GUC_MAX_ENGINES_NUM]; 50 50 uint32_t q_fail; 51 51 uint32_t b_fail; 52 52 int retcode; ··· 106 106 uint32_t action_fail; /* Total number of failures */ 107 107 int32_t action_err; /* Last error code */ 108 108 109 - uint64_t submissions[I915_NUM_RINGS]; 110 - uint32_t last_seqno[I915_NUM_RINGS]; 109 + uint64_t submissions[GUC_MAX_ENGINES_NUM]; 110 + uint32_t last_seqno[GUC_MAX_ENGINES_NUM]; 111 111 }; 112 112 113 113 /* intel_guc_loader.c */
+12 -5
drivers/gpu/drm/i915/intel_guc_fwif.h
··· 44 44 #define GUC_MAX_GPU_CONTEXTS 1024 45 45 #define GUC_INVALID_CTX_ID GUC_MAX_GPU_CONTEXTS 46 46 47 + #define GUC_RENDER_ENGINE 0 48 + #define GUC_VIDEO_ENGINE 1 49 + #define GUC_BLITTER_ENGINE 2 50 + #define GUC_VIDEOENHANCE_ENGINE 3 51 + #define GUC_VIDEO_ENGINE2 4 52 + #define GUC_MAX_ENGINES_NUM (GUC_VIDEO_ENGINE2 + 1) 53 + 47 54 /* Work queue item header definitions */ 48 55 #define WQ_STATUS_ACTIVE 1 49 56 #define WQ_STATUS_SUSPENDED 2 ··· 292 285 u64 db_trigger_phy; 293 286 u16 db_id; 294 287 295 - struct guc_execlist_context lrc[I915_NUM_RINGS]; 288 + struct guc_execlist_context lrc[GUC_MAX_ENGINES_NUM]; 296 289 297 290 u8 attribute; 298 291 ··· 351 344 } __packed; 352 345 353 346 struct guc_policies { 354 - struct guc_policy policy[GUC_CTX_PRIORITY_NUM][I915_NUM_RINGS]; 347 + struct guc_policy policy[GUC_CTX_PRIORITY_NUM][GUC_MAX_ENGINES_NUM]; 355 348 356 349 /* In micro seconds. How much time to allow before DPC processing is 357 350 * called back via interrupt (to prevent DPC queue drain starving). ··· 395 388 396 389 struct guc_mmio_reg_state { 397 390 struct guc_mmio_regset global_reg; 398 - struct guc_mmio_regset engine_reg[I915_NUM_RINGS]; 391 + struct guc_mmio_regset engine_reg[GUC_MAX_ENGINES_NUM]; 399 392 400 393 /* MMIO registers that are set as non privileged */ 401 394 struct __packed { 402 395 u32 mmio_start; 403 396 u32 offsets[GUC_MMIO_WHITE_LIST_MAX]; 404 397 u32 count; 405 - } mmio_white_list[I915_NUM_RINGS]; 398 + } mmio_white_list[GUC_MAX_ENGINES_NUM]; 406 399 } __packed; 407 400 408 401 /* GuC Additional Data Struct */ ··· 413 406 u32 golden_context_lrca; 414 407 u32 scheduler_policies; 415 408 u32 reserved0[3]; 416 - u32 eng_state_size[I915_NUM_RINGS]; 409 + u32 eng_state_size[GUC_MAX_ENGINES_NUM]; 417 410 u32 reserved2[4]; 418 411 } __packed; 419 412
+8
drivers/gpu/drm/i915/intel_hdmi.c
··· 1202 1202 struct drm_device *dev = intel_hdmi_to_dev(hdmi); 1203 1203 enum drm_mode_status status; 1204 1204 int clock; 1205 + int max_dotclk = to_i915(connector->dev)->max_dotclk_freq; 1205 1206 1206 1207 if (mode->flags & DRM_MODE_FLAG_DBLSCAN) 1207 1208 return MODE_NO_DBLESCAN; 1208 1209 1209 1210 clock = mode->clock; 1211 + 1212 + if ((mode->flags & DRM_MODE_FLAG_3D_MASK) == DRM_MODE_FLAG_3D_FRAME_PACKING) 1213 + clock *= 2; 1214 + 1215 + if (clock > max_dotclk) 1216 + return MODE_CLOCK_HIGH; 1217 + 1210 1218 if (mode->flags & DRM_MODE_FLAG_DBLCLK) 1211 1219 clock *= 2; 1212 1220
+1 -1
drivers/gpu/drm/i915/intel_i2c.c
··· 683 683 return 0; 684 684 685 685 err: 686 - while (--pin) { 686 + while (pin--) { 687 687 if (!intel_gmbus_is_valid_pin(dev_priv, pin)) 688 688 continue; 689 689
+51 -27
drivers/gpu/drm/i915/intel_lrc.c
··· 225 225 #define GEN8_CTX_ID_SHIFT 32 226 226 #define CTX_RCS_INDIRECT_CTX_OFFSET_DEFAULT 0x17 227 227 228 - static int intel_lr_context_pin(struct drm_i915_gem_request *rq); 228 + static int intel_lr_context_pin(struct intel_context *ctx, 229 + struct intel_engine_cs *engine); 229 230 static void lrc_setup_hardware_status_page(struct intel_engine_cs *ring, 230 231 struct drm_i915_gem_object *default_ctx_obj); 231 232 ··· 394 393 uint32_t *reg_state = rq->ctx->engine[ring->id].lrc_reg_state; 395 394 396 395 reg_state[CTX_RING_TAIL+1] = rq->tail; 397 - reg_state[CTX_RING_BUFFER_START+1] = rq->ringbuf->vma->node.start; 398 396 399 397 if (ppgtt && !USES_FULL_48BIT_PPGTT(ppgtt->base.dev)) { 400 398 /* True 32b PPGTT with dynamic page allocation: update PDP ··· 599 599 int num_elements = 0; 600 600 601 601 if (request->ctx != request->i915->kernel_context) 602 - intel_lr_context_pin(request); 602 + intel_lr_context_pin(request->ctx, ring); 603 603 604 604 i915_gem_request_reference(request); 605 605 ··· 704 704 } 705 705 706 706 if (request->ctx != request->i915->kernel_context) 707 - ret = intel_lr_context_pin(request); 707 + ret = intel_lr_context_pin(request->ctx, request->ring); 708 708 709 709 return ret; 710 710 } ··· 765 765 { 766 766 struct intel_ringbuffer *ringbuf = request->ringbuf; 767 767 struct drm_i915_private *dev_priv = request->i915; 768 + struct intel_engine_cs *engine = request->ring; 768 769 769 770 intel_logical_ring_advance(ringbuf); 770 771 request->tail = ringbuf->tail; ··· 780 779 intel_logical_ring_emit(ringbuf, MI_NOOP); 781 780 intel_logical_ring_advance(ringbuf); 782 781 783 - if (intel_ring_stopped(request->ring)) 782 + if (intel_ring_stopped(engine)) 784 783 return 0; 784 + 785 + if (engine->last_context != request->ctx) { 786 + if (engine->last_context) 787 + intel_lr_context_unpin(engine->last_context, engine); 788 + if (request->ctx != request->i915->kernel_context) { 789 + intel_lr_context_pin(request->ctx, engine); 790 + engine->last_context = request->ctx; 791 + } else { 792 + engine->last_context = NULL; 793 + } 794 + } 785 795 786 796 if (dev_priv->guc.execbuf_client) 787 797 i915_guc_submit(dev_priv->guc.execbuf_client, request); ··· 1027 1015 ctx->engine[ring->id].state; 1028 1016 1029 1017 if (ctx_obj && (ctx != req->i915->kernel_context)) 1030 - intel_lr_context_unpin(req); 1018 + intel_lr_context_unpin(ctx, ring); 1019 + 1031 1020 list_del(&req->execlist_link); 1032 1021 i915_gem_request_unreference(req); 1033 1022 } ··· 1072 1059 return 0; 1073 1060 } 1074 1061 1075 - static int intel_lr_context_do_pin(struct intel_engine_cs *ring, 1076 - struct intel_context *ctx) 1062 + static int intel_lr_context_do_pin(struct intel_context *ctx, 1063 + struct intel_engine_cs *ring) 1077 1064 { 1078 1065 struct drm_device *dev = ring->dev; 1079 1066 struct drm_i915_private *dev_priv = dev->dev_private; 1080 1067 struct drm_i915_gem_object *ctx_obj = ctx->engine[ring->id].state; 1081 1068 struct intel_ringbuffer *ringbuf = ctx->engine[ring->id].ringbuf; 1082 1069 struct page *lrc_state_page; 1070 + uint32_t *lrc_reg_state; 1083 1071 int ret; 1084 1072 1085 1073 WARN_ON(!mutex_is_locked(&ring->dev->struct_mutex)); ··· 1102 1088 1103 1089 ctx->engine[ring->id].lrc_vma = i915_gem_obj_to_ggtt(ctx_obj); 1104 1090 intel_lr_context_descriptor_update(ctx, ring); 1105 - ctx->engine[ring->id].lrc_reg_state = kmap(lrc_state_page); 1091 + lrc_reg_state = kmap(lrc_state_page); 1092 + lrc_reg_state[CTX_RING_BUFFER_START+1] = ringbuf->vma->node.start; 1093 + ctx->engine[ring->id].lrc_reg_state = lrc_reg_state; 1106 1094 ctx_obj->dirty = true; 1107 1095 1108 1096 /* Invalidate GuC TLB. */ ··· 1119 1103 return ret; 1120 1104 } 1121 1105 1122 - static int intel_lr_context_pin(struct drm_i915_gem_request *rq) 1106 + static int intel_lr_context_pin(struct intel_context *ctx, 1107 + struct intel_engine_cs *engine) 1123 1108 { 1124 1109 int ret = 0; 1125 - struct intel_engine_cs *ring = rq->ring; 1126 1110 1127 - if (rq->ctx->engine[ring->id].pin_count++ == 0) { 1128 - ret = intel_lr_context_do_pin(ring, rq->ctx); 1111 + if (ctx->engine[engine->id].pin_count++ == 0) { 1112 + ret = intel_lr_context_do_pin(ctx, engine); 1129 1113 if (ret) 1130 1114 goto reset_pin_count; 1115 + 1116 + i915_gem_context_reference(ctx); 1131 1117 } 1132 1118 return ret; 1133 1119 1134 1120 reset_pin_count: 1135 - rq->ctx->engine[ring->id].pin_count = 0; 1121 + ctx->engine[engine->id].pin_count = 0; 1136 1122 return ret; 1137 1123 } 1138 1124 1139 - void intel_lr_context_unpin(struct drm_i915_gem_request *rq) 1125 + void intel_lr_context_unpin(struct intel_context *ctx, 1126 + struct intel_engine_cs *engine) 1140 1127 { 1141 - struct intel_engine_cs *ring = rq->ring; 1142 - struct drm_i915_gem_object *ctx_obj = rq->ctx->engine[ring->id].state; 1143 - struct intel_ringbuffer *ringbuf = rq->ringbuf; 1128 + struct drm_i915_gem_object *ctx_obj = ctx->engine[engine->id].state; 1144 1129 1145 - WARN_ON(!mutex_is_locked(&ring->dev->struct_mutex)); 1130 + WARN_ON(!mutex_is_locked(&ctx->i915->dev->struct_mutex)); 1146 1131 1147 - if (!ctx_obj) 1132 + if (WARN_ON_ONCE(!ctx_obj)) 1148 1133 return; 1149 1134 1150 - if (--rq->ctx->engine[ring->id].pin_count == 0) { 1151 - kunmap(kmap_to_page(rq->ctx->engine[ring->id].lrc_reg_state)); 1152 - intel_unpin_ringbuffer_obj(ringbuf); 1135 + if (--ctx->engine[engine->id].pin_count == 0) { 1136 + kunmap(kmap_to_page(ctx->engine[engine->id].lrc_reg_state)); 1137 + intel_unpin_ringbuffer_obj(ctx->engine[engine->id].ringbuf); 1153 1138 i915_gem_object_ggtt_unpin(ctx_obj); 1154 - rq->ctx->engine[ring->id].lrc_vma = NULL; 1155 - rq->ctx->engine[ring->id].lrc_desc = 0; 1156 - rq->ctx->engine[ring->id].lrc_reg_state = NULL; 1139 + ctx->engine[engine->id].lrc_vma = NULL; 1140 + ctx->engine[engine->id].lrc_desc = 0; 1141 + ctx->engine[engine->id].lrc_reg_state = NULL; 1142 + 1143 + i915_gem_context_unreference(ctx); 1157 1144 } 1158 1145 } 1159 1146 ··· 2081 2062 goto error; 2082 2063 2083 2064 /* As this is the default context, always pin it */ 2084 - ret = intel_lr_context_do_pin(ring, dctx); 2065 + ret = intel_lr_context_do_pin(dctx, ring); 2085 2066 if (ret) { 2086 2067 DRM_ERROR( 2087 2068 "Failed to pin and map ringbuffer %s: %d\n", ··· 2105 2086 ring->name = "render ring"; 2106 2087 ring->id = RCS; 2107 2088 ring->exec_id = I915_EXEC_RENDER; 2089 + ring->guc_id = GUC_RENDER_ENGINE; 2108 2090 ring->mmio_base = RENDER_RING_BASE; 2109 2091 2110 2092 logical_ring_default_irqs(ring, GEN8_RCS_IRQ_SHIFT); ··· 2157 2137 ring->name = "bsd ring"; 2158 2138 ring->id = VCS; 2159 2139 ring->exec_id = I915_EXEC_BSD; 2140 + ring->guc_id = GUC_VIDEO_ENGINE; 2160 2141 ring->mmio_base = GEN6_BSD_RING_BASE; 2161 2142 2162 2143 logical_ring_default_irqs(ring, GEN8_VCS1_IRQ_SHIFT); ··· 2174 2153 ring->name = "bsd2 ring"; 2175 2154 ring->id = VCS2; 2176 2155 ring->exec_id = I915_EXEC_BSD; 2156 + ring->guc_id = GUC_VIDEO_ENGINE2; 2177 2157 ring->mmio_base = GEN8_BSD2_RING_BASE; 2178 2158 2179 2159 logical_ring_default_irqs(ring, GEN8_VCS2_IRQ_SHIFT); ··· 2191 2169 ring->name = "blitter ring"; 2192 2170 ring->id = BCS; 2193 2171 ring->exec_id = I915_EXEC_BLT; 2172 + ring->guc_id = GUC_BLITTER_ENGINE; 2194 2173 ring->mmio_base = BLT_RING_BASE; 2195 2174 2196 2175 logical_ring_default_irqs(ring, GEN8_BCS_IRQ_SHIFT); ··· 2208 2185 ring->name = "video enhancement ring"; 2209 2186 ring->id = VECS; 2210 2187 ring->exec_id = I915_EXEC_VEBOX; 2188 + ring->guc_id = GUC_VIDEOENHANCE_ENGINE; 2211 2189 ring->mmio_base = VEBOX_RING_BASE; 2212 2190 2213 2191 logical_ring_default_irqs(ring, GEN8_VECS_IRQ_SHIFT);
+2 -1
drivers/gpu/drm/i915/intel_lrc.h
··· 101 101 uint32_t intel_lr_context_size(struct intel_engine_cs *ring); 102 102 int intel_lr_context_deferred_alloc(struct intel_context *ctx, 103 103 struct intel_engine_cs *ring); 104 - void intel_lr_context_unpin(struct drm_i915_gem_request *req); 104 + void intel_lr_context_unpin(struct intel_context *ctx, 105 + struct intel_engine_cs *engine); 105 106 void intel_lr_context_reset(struct drm_device *dev, 106 107 struct intel_context *ctx); 107 108 uint64_t intel_lr_context_descriptor(struct intel_context *ctx,
+123 -72
drivers/gpu/drm/i915/intel_pm.c
··· 548 548 * intel_calculate_wm - calculate watermark level 549 549 * @clock_in_khz: pixel clock 550 550 * @wm: chip FIFO params 551 - * @pixel_size: display pixel size 551 + * @cpp: bytes per pixel 552 552 * @latency_ns: memory latency for the platform 553 553 * 554 554 * Calculate the watermark level (the level at which the display plane will ··· 564 564 */ 565 565 static unsigned long intel_calculate_wm(unsigned long clock_in_khz, 566 566 const struct intel_watermark_params *wm, 567 - int fifo_size, 568 - int pixel_size, 567 + int fifo_size, int cpp, 569 568 unsigned long latency_ns) 570 569 { 571 570 long entries_required, wm_size; ··· 575 576 * clocks go from a few thousand to several hundred thousand. 576 577 * latency is usually a few thousand 577 578 */ 578 - entries_required = ((clock_in_khz / 1000) * pixel_size * latency_ns) / 579 + entries_required = ((clock_in_khz / 1000) * cpp * latency_ns) / 579 580 1000; 580 581 entries_required = DIV_ROUND_UP(entries_required, wm->cacheline_size); 581 582 ··· 639 640 crtc = single_enabled_crtc(dev); 640 641 if (crtc) { 641 642 const struct drm_display_mode *adjusted_mode = &to_intel_crtc(crtc)->config->base.adjusted_mode; 642 - int pixel_size = crtc->primary->state->fb->bits_per_pixel / 8; 643 + int cpp = drm_format_plane_cpp(crtc->primary->state->fb->pixel_format, 0); 643 644 int clock = adjusted_mode->crtc_clock; 644 645 645 646 /* Display SR */ 646 647 wm = intel_calculate_wm(clock, &pineview_display_wm, 647 648 pineview_display_wm.fifo_size, 648 - pixel_size, latency->display_sr); 649 + cpp, latency->display_sr); 649 650 reg = I915_READ(DSPFW1); 650 651 reg &= ~DSPFW_SR_MASK; 651 652 reg |= FW_WM(wm, SR); ··· 655 656 /* cursor SR */ 656 657 wm = intel_calculate_wm(clock, &pineview_cursor_wm, 657 658 pineview_display_wm.fifo_size, 658 - pixel_size, latency->cursor_sr); 659 + cpp, latency->cursor_sr); 659 660 reg = I915_READ(DSPFW3); 660 661 reg &= ~DSPFW_CURSOR_SR_MASK; 661 662 reg |= FW_WM(wm, CURSOR_SR); ··· 664 665 /* Display HPLL off SR */ 665 666 wm = intel_calculate_wm(clock, &pineview_display_hplloff_wm, 666 667 pineview_display_hplloff_wm.fifo_size, 667 - pixel_size, latency->display_hpll_disable); 668 + cpp, latency->display_hpll_disable); 668 669 reg = I915_READ(DSPFW3); 669 670 reg &= ~DSPFW_HPLL_SR_MASK; 670 671 reg |= FW_WM(wm, HPLL_SR); ··· 673 674 /* cursor HPLL off SR */ 674 675 wm = intel_calculate_wm(clock, &pineview_cursor_hplloff_wm, 675 676 pineview_display_hplloff_wm.fifo_size, 676 - pixel_size, latency->cursor_hpll_disable); 677 + cpp, latency->cursor_hpll_disable); 677 678 reg = I915_READ(DSPFW3); 678 679 reg &= ~DSPFW_HPLL_CURSOR_MASK; 679 680 reg |= FW_WM(wm, HPLL_CURSOR); ··· 697 698 { 698 699 struct drm_crtc *crtc; 699 700 const struct drm_display_mode *adjusted_mode; 700 - int htotal, hdisplay, clock, pixel_size; 701 + int htotal, hdisplay, clock, cpp; 701 702 int line_time_us, line_count; 702 703 int entries, tlb_miss; 703 704 ··· 712 713 clock = adjusted_mode->crtc_clock; 713 714 htotal = adjusted_mode->crtc_htotal; 714 715 hdisplay = to_intel_crtc(crtc)->config->pipe_src_w; 715 - pixel_size = crtc->primary->state->fb->bits_per_pixel / 8; 716 + cpp = drm_format_plane_cpp(crtc->primary->state->fb->pixel_format, 0); 716 717 717 718 /* Use the small buffer method to calculate plane watermark */ 718 - entries = ((clock * pixel_size / 1000) * display_latency_ns) / 1000; 719 + entries = ((clock * cpp / 1000) * display_latency_ns) / 1000; 719 720 tlb_miss = display->fifo_size*display->cacheline_size - hdisplay * 8; 720 721 if (tlb_miss > 0) 721 722 entries += tlb_miss; ··· 727 728 /* Use the large buffer method to calculate cursor watermark */ 728 729 line_time_us = max(htotal * 1000 / clock, 1); 729 730 line_count = (cursor_latency_ns / line_time_us + 1000) / 1000; 730 - entries = line_count * crtc->cursor->state->crtc_w * pixel_size; 731 + entries = line_count * crtc->cursor->state->crtc_w * cpp; 731 732 tlb_miss = cursor->fifo_size*cursor->cacheline_size - hdisplay * 8; 732 733 if (tlb_miss > 0) 733 734 entries += tlb_miss; ··· 783 784 { 784 785 struct drm_crtc *crtc; 785 786 const struct drm_display_mode *adjusted_mode; 786 - int hdisplay, htotal, pixel_size, clock; 787 + int hdisplay, htotal, cpp, clock; 787 788 unsigned long line_time_us; 788 789 int line_count, line_size; 789 790 int small, large; ··· 799 800 clock = adjusted_mode->crtc_clock; 800 801 htotal = adjusted_mode->crtc_htotal; 801 802 hdisplay = to_intel_crtc(crtc)->config->pipe_src_w; 802 - pixel_size = crtc->primary->state->fb->bits_per_pixel / 8; 803 + cpp = drm_format_plane_cpp(crtc->primary->state->fb->pixel_format, 0); 803 804 804 805 line_time_us = max(htotal * 1000 / clock, 1); 805 806 line_count = (latency_ns / line_time_us + 1000) / 1000; 806 - line_size = hdisplay * pixel_size; 807 + line_size = hdisplay * cpp; 807 808 808 809 /* Use the minimum of the small and large buffer method for primary */ 809 - small = ((clock * pixel_size / 1000) * latency_ns) / 1000; 810 + small = ((clock * cpp / 1000) * latency_ns) / 1000; 810 811 large = line_count * line_size; 811 812 812 813 entries = DIV_ROUND_UP(min(small, large), display->cacheline_size); 813 814 *display_wm = entries + display->guard_size; 814 815 815 816 /* calculate the self-refresh watermark for display cursor */ 816 - entries = line_count * pixel_size * crtc->cursor->state->crtc_w; 817 + entries = line_count * cpp * crtc->cursor->state->crtc_w; 817 818 entries = DIV_ROUND_UP(entries, cursor->cacheline_size); 818 819 *cursor_wm = entries + cursor->guard_size; 819 820 ··· 905 906 static unsigned int vlv_wm_method2(unsigned int pixel_rate, 906 907 unsigned int pipe_htotal, 907 908 unsigned int horiz_pixels, 908 - unsigned int bytes_per_pixel, 909 + unsigned int cpp, 909 910 unsigned int latency) 910 911 { 911 912 unsigned int ret; 912 913 913 914 ret = (latency * pixel_rate) / (pipe_htotal * 10000); 914 - ret = (ret + 1) * horiz_pixels * bytes_per_pixel; 915 + ret = (ret + 1) * horiz_pixels * cpp; 915 916 ret = DIV_ROUND_UP(ret, 64); 916 917 917 918 return ret; ··· 940 941 int level) 941 942 { 942 943 struct drm_i915_private *dev_priv = to_i915(plane->base.dev); 943 - int clock, htotal, pixel_size, width, wm; 944 + int clock, htotal, cpp, width, wm; 944 945 945 946 if (dev_priv->wm.pri_latency[level] == 0) 946 947 return USHRT_MAX; ··· 948 949 if (!state->visible) 949 950 return 0; 950 951 951 - pixel_size = drm_format_plane_cpp(state->base.fb->pixel_format, 0); 952 + cpp = drm_format_plane_cpp(state->base.fb->pixel_format, 0); 952 953 clock = crtc->config->base.adjusted_mode.crtc_clock; 953 954 htotal = crtc->config->base.adjusted_mode.crtc_htotal; 954 955 width = crtc->config->pipe_src_w; ··· 964 965 */ 965 966 wm = 63; 966 967 } else { 967 - wm = vlv_wm_method2(clock, htotal, width, pixel_size, 968 + wm = vlv_wm_method2(clock, htotal, width, cpp, 968 969 dev_priv->wm.pri_latency[level] * 10); 969 970 } 970 971 ··· 1438 1439 int clock = adjusted_mode->crtc_clock; 1439 1440 int htotal = adjusted_mode->crtc_htotal; 1440 1441 int hdisplay = to_intel_crtc(crtc)->config->pipe_src_w; 1441 - int pixel_size = crtc->primary->state->fb->bits_per_pixel / 8; 1442 + int cpp = drm_format_plane_cpp(crtc->primary->state->fb->pixel_format, 0); 1442 1443 unsigned long line_time_us; 1443 1444 int entries; 1444 1445 ··· 1446 1447 1447 1448 /* Use ns/us then divide to preserve precision */ 1448 1449 entries = (((sr_latency_ns / line_time_us) + 1000) / 1000) * 1449 - pixel_size * hdisplay; 1450 + cpp * hdisplay; 1450 1451 entries = DIV_ROUND_UP(entries, I915_FIFO_LINE_SIZE); 1451 1452 srwm = I965_FIFO_SIZE - entries; 1452 1453 if (srwm < 0) ··· 1456 1457 entries, srwm); 1457 1458 1458 1459 entries = (((sr_latency_ns / line_time_us) + 1000) / 1000) * 1459 - pixel_size * crtc->cursor->state->crtc_w; 1460 + cpp * crtc->cursor->state->crtc_w; 1460 1461 entries = DIV_ROUND_UP(entries, 1461 1462 i965_cursor_wm_info.cacheline_size); 1462 1463 cursor_sr = i965_cursor_wm_info.fifo_size - ··· 1517 1518 crtc = intel_get_crtc_for_plane(dev, 0); 1518 1519 if (intel_crtc_active(crtc)) { 1519 1520 const struct drm_display_mode *adjusted_mode; 1520 - int cpp = crtc->primary->state->fb->bits_per_pixel / 8; 1521 + int cpp = drm_format_plane_cpp(crtc->primary->state->fb->pixel_format, 0); 1521 1522 if (IS_GEN2(dev)) 1522 1523 cpp = 4; 1523 1524 ··· 1539 1540 crtc = intel_get_crtc_for_plane(dev, 1); 1540 1541 if (intel_crtc_active(crtc)) { 1541 1542 const struct drm_display_mode *adjusted_mode; 1542 - int cpp = crtc->primary->state->fb->bits_per_pixel / 8; 1543 + int cpp = drm_format_plane_cpp(crtc->primary->state->fb->pixel_format, 0); 1543 1544 if (IS_GEN2(dev)) 1544 1545 cpp = 4; 1545 1546 ··· 1585 1586 int clock = adjusted_mode->crtc_clock; 1586 1587 int htotal = adjusted_mode->crtc_htotal; 1587 1588 int hdisplay = to_intel_crtc(enabled)->config->pipe_src_w; 1588 - int pixel_size = enabled->primary->state->fb->bits_per_pixel / 8; 1589 + int cpp = drm_format_plane_cpp(enabled->primary->state->fb->pixel_format, 0); 1589 1590 unsigned long line_time_us; 1590 1591 int entries; 1591 1592 ··· 1593 1594 1594 1595 /* Use ns/us then divide to preserve precision */ 1595 1596 entries = (((sr_latency_ns / line_time_us) + 1000) / 1000) * 1596 - pixel_size * hdisplay; 1597 + cpp * hdisplay; 1597 1598 entries = DIV_ROUND_UP(entries, wm_info->cacheline_size); 1598 1599 DRM_DEBUG_KMS("self-refresh entries: %d\n", entries); 1599 1600 srwm = wm_info->fifo_size - entries; ··· 1684 1685 } 1685 1686 1686 1687 /* latency must be in 0.1us units. */ 1687 - static uint32_t ilk_wm_method1(uint32_t pixel_rate, uint8_t bytes_per_pixel, 1688 - uint32_t latency) 1688 + static uint32_t ilk_wm_method1(uint32_t pixel_rate, uint8_t cpp, uint32_t latency) 1689 1689 { 1690 1690 uint64_t ret; 1691 1691 1692 1692 if (WARN(latency == 0, "Latency value missing\n")) 1693 1693 return UINT_MAX; 1694 1694 1695 - ret = (uint64_t) pixel_rate * bytes_per_pixel * latency; 1695 + ret = (uint64_t) pixel_rate * cpp * latency; 1696 1696 ret = DIV_ROUND_UP_ULL(ret, 64 * 10000) + 2; 1697 1697 1698 1698 return ret; ··· 1699 1701 1700 1702 /* latency must be in 0.1us units. */ 1701 1703 static uint32_t ilk_wm_method2(uint32_t pixel_rate, uint32_t pipe_htotal, 1702 - uint32_t horiz_pixels, uint8_t bytes_per_pixel, 1704 + uint32_t horiz_pixels, uint8_t cpp, 1703 1705 uint32_t latency) 1704 1706 { 1705 1707 uint32_t ret; ··· 1710 1712 return UINT_MAX; 1711 1713 1712 1714 ret = (latency * pixel_rate) / (pipe_htotal * 10000); 1713 - ret = (ret + 1) * horiz_pixels * bytes_per_pixel; 1715 + ret = (ret + 1) * horiz_pixels * cpp; 1714 1716 ret = DIV_ROUND_UP(ret, 64) + 2; 1715 1717 return ret; 1716 1718 } 1717 1719 1718 1720 static uint32_t ilk_wm_fbc(uint32_t pri_val, uint32_t horiz_pixels, 1719 - uint8_t bytes_per_pixel) 1721 + uint8_t cpp) 1720 1722 { 1721 1723 /* 1722 1724 * Neither of these should be possible since this function shouldn't be ··· 1724 1726 * extra paranoid to avoid a potential divide-by-zero if we screw up 1725 1727 * elsewhere in the driver. 1726 1728 */ 1727 - if (WARN_ON(!bytes_per_pixel)) 1729 + if (WARN_ON(!cpp)) 1728 1730 return 0; 1729 1731 if (WARN_ON(!horiz_pixels)) 1730 1732 return 0; 1731 1733 1732 - return DIV_ROUND_UP(pri_val * 64, horiz_pixels * bytes_per_pixel) + 2; 1734 + return DIV_ROUND_UP(pri_val * 64, horiz_pixels * cpp) + 2; 1733 1735 } 1734 1736 1735 1737 struct ilk_wm_maximums { ··· 1748 1750 uint32_t mem_value, 1749 1751 bool is_lp) 1750 1752 { 1751 - int bpp = pstate->base.fb ? pstate->base.fb->bits_per_pixel / 8 : 0; 1753 + int cpp = pstate->base.fb ? 1754 + drm_format_plane_cpp(pstate->base.fb->pixel_format, 0) : 0; 1752 1755 uint32_t method1, method2; 1753 1756 1754 1757 if (!cstate->base.active || !pstate->visible) 1755 1758 return 0; 1756 1759 1757 - method1 = ilk_wm_method1(ilk_pipe_pixel_rate(cstate), bpp, mem_value); 1760 + method1 = ilk_wm_method1(ilk_pipe_pixel_rate(cstate), cpp, mem_value); 1758 1761 1759 1762 if (!is_lp) 1760 1763 return method1; ··· 1763 1764 method2 = ilk_wm_method2(ilk_pipe_pixel_rate(cstate), 1764 1765 cstate->base.adjusted_mode.crtc_htotal, 1765 1766 drm_rect_width(&pstate->dst), 1766 - bpp, 1767 - mem_value); 1767 + cpp, mem_value); 1768 1768 1769 1769 return min(method1, method2); 1770 1770 } ··· 1776 1778 const struct intel_plane_state *pstate, 1777 1779 uint32_t mem_value) 1778 1780 { 1779 - int bpp = pstate->base.fb ? pstate->base.fb->bits_per_pixel / 8 : 0; 1781 + int cpp = pstate->base.fb ? 1782 + drm_format_plane_cpp(pstate->base.fb->pixel_format, 0) : 0; 1780 1783 uint32_t method1, method2; 1781 1784 1782 1785 if (!cstate->base.active || !pstate->visible) 1783 1786 return 0; 1784 1787 1785 - method1 = ilk_wm_method1(ilk_pipe_pixel_rate(cstate), bpp, mem_value); 1788 + method1 = ilk_wm_method1(ilk_pipe_pixel_rate(cstate), cpp, mem_value); 1786 1789 method2 = ilk_wm_method2(ilk_pipe_pixel_rate(cstate), 1787 1790 cstate->base.adjusted_mode.crtc_htotal, 1788 1791 drm_rect_width(&pstate->dst), 1789 - bpp, 1790 - mem_value); 1792 + cpp, mem_value); 1791 1793 return min(method1, method2); 1792 1794 } 1793 1795 ··· 1799 1801 const struct intel_plane_state *pstate, 1800 1802 uint32_t mem_value) 1801 1803 { 1802 - int bpp = pstate->base.fb ? pstate->base.fb->bits_per_pixel / 8 : 0; 1804 + /* 1805 + * We treat the cursor plane as always-on for the purposes of watermark 1806 + * calculation. Until we have two-stage watermark programming merged, 1807 + * this is necessary to avoid flickering. 1808 + */ 1809 + int cpp = 4; 1810 + int width = pstate->visible ? pstate->base.crtc_w : 64; 1803 1811 1804 - if (!cstate->base.active || !pstate->visible) 1812 + if (!cstate->base.active) 1805 1813 return 0; 1806 1814 1807 1815 return ilk_wm_method2(ilk_pipe_pixel_rate(cstate), 1808 1816 cstate->base.adjusted_mode.crtc_htotal, 1809 - drm_rect_width(&pstate->dst), 1810 - bpp, 1811 - mem_value); 1817 + width, cpp, mem_value); 1812 1818 } 1813 1819 1814 1820 /* Only for WM_LP. */ ··· 1820 1818 const struct intel_plane_state *pstate, 1821 1819 uint32_t pri_val) 1822 1820 { 1823 - int bpp = pstate->base.fb ? pstate->base.fb->bits_per_pixel / 8 : 0; 1821 + int cpp = pstate->base.fb ? 1822 + drm_format_plane_cpp(pstate->base.fb->pixel_format, 0) : 0; 1824 1823 1825 1824 if (!cstate->base.active || !pstate->visible) 1826 1825 return 0; 1827 1826 1828 - return ilk_wm_fbc(pri_val, drm_rect_width(&pstate->dst), bpp); 1827 + return ilk_wm_fbc(pri_val, drm_rect_width(&pstate->dst), cpp); 1829 1828 } 1830 1829 1831 1830 static unsigned int ilk_display_fifo_size(const struct drm_device *dev) ··· 3045 3042 3046 3043 /* 3047 3044 * The max latency should be 257 (max the punit can code is 255 and we add 2us 3048 - * for the read latency) and bytes_per_pixel should always be <= 8, so that 3045 + * for the read latency) and cpp should always be <= 8, so that 3049 3046 * should allow pixel_rate up to ~2 GHz which seems sufficient since max 3050 3047 * 2xcdclk is 1350 MHz and the pixel rate should never exceed that. 3051 3048 */ 3052 - static uint32_t skl_wm_method1(uint32_t pixel_rate, uint8_t bytes_per_pixel, 3053 - uint32_t latency) 3049 + static uint32_t skl_wm_method1(uint32_t pixel_rate, uint8_t cpp, uint32_t latency) 3054 3050 { 3055 3051 uint32_t wm_intermediate_val, ret; 3056 3052 3057 3053 if (latency == 0) 3058 3054 return UINT_MAX; 3059 3055 3060 - wm_intermediate_val = latency * pixel_rate * bytes_per_pixel / 512; 3056 + wm_intermediate_val = latency * pixel_rate * cpp / 512; 3061 3057 ret = DIV_ROUND_UP(wm_intermediate_val, 1000); 3062 3058 3063 3059 return ret; 3064 3060 } 3065 3061 3066 3062 static uint32_t skl_wm_method2(uint32_t pixel_rate, uint32_t pipe_htotal, 3067 - uint32_t horiz_pixels, uint8_t bytes_per_pixel, 3063 + uint32_t horiz_pixels, uint8_t cpp, 3068 3064 uint64_t tiling, uint32_t latency) 3069 3065 { 3070 3066 uint32_t ret; ··· 3073 3071 if (latency == 0) 3074 3072 return UINT_MAX; 3075 3073 3076 - plane_bytes_per_line = horiz_pixels * bytes_per_pixel; 3074 + plane_bytes_per_line = horiz_pixels * cpp; 3077 3075 3078 3076 if (tiling == I915_FORMAT_MOD_Y_TILED || 3079 3077 tiling == I915_FORMAT_MOD_Yf_TILED) { ··· 3123 3121 uint32_t plane_bytes_per_line, plane_blocks_per_line; 3124 3122 uint32_t res_blocks, res_lines; 3125 3123 uint32_t selected_result; 3126 - uint8_t bytes_per_pixel; 3124 + uint8_t cpp; 3127 3125 3128 3126 if (latency == 0 || !cstate->base.active || !fb) 3129 3127 return false; 3130 3128 3131 - bytes_per_pixel = drm_format_plane_cpp(fb->pixel_format, 0); 3129 + cpp = drm_format_plane_cpp(fb->pixel_format, 0); 3132 3130 method1 = skl_wm_method1(skl_pipe_pixel_rate(cstate), 3133 - bytes_per_pixel, 3134 - latency); 3131 + cpp, latency); 3135 3132 method2 = skl_wm_method2(skl_pipe_pixel_rate(cstate), 3136 3133 cstate->base.adjusted_mode.crtc_htotal, 3137 3134 cstate->pipe_src_w, 3138 - bytes_per_pixel, 3139 - fb->modifier[0], 3135 + cpp, fb->modifier[0], 3140 3136 latency); 3141 3137 3142 - plane_bytes_per_line = cstate->pipe_src_w * bytes_per_pixel; 3138 + plane_bytes_per_line = cstate->pipe_src_w * cpp; 3143 3139 plane_blocks_per_line = DIV_ROUND_UP(plane_bytes_per_line, 512); 3144 3140 3145 3141 if (fb->modifier[0] == I915_FORMAT_MOD_Y_TILED || ··· 3145 3145 uint32_t min_scanlines = 4; 3146 3146 uint32_t y_tile_minimum; 3147 3147 if (intel_rotation_90_or_270(plane->state->rotation)) { 3148 - int bpp = (fb->pixel_format == DRM_FORMAT_NV12) ? 3148 + int cpp = (fb->pixel_format == DRM_FORMAT_NV12) ? 3149 3149 drm_format_plane_cpp(fb->pixel_format, 1) : 3150 3150 drm_format_plane_cpp(fb->pixel_format, 0); 3151 3151 3152 - switch (bpp) { 3152 + switch (cpp) { 3153 3153 case 1: 3154 3154 min_scanlines = 16; 3155 3155 break; ··· 4562 4562 onoff(mode & GEN6_RC_CTL_RC6_ENABLE)); 4563 4563 } 4564 4564 4565 - static int sanitize_rc6_option(const struct drm_device *dev, int enable_rc6) 4565 + static bool bxt_check_bios_rc6_setup(const struct drm_device *dev) 4566 + { 4567 + struct drm_i915_private *dev_priv = dev->dev_private; 4568 + bool enable_rc6 = true; 4569 + unsigned long rc6_ctx_base; 4570 + 4571 + if (!(I915_READ(RC6_LOCATION) & RC6_CTX_IN_DRAM)) { 4572 + DRM_DEBUG_KMS("RC6 Base location not set properly.\n"); 4573 + enable_rc6 = false; 4574 + } 4575 + 4576 + /* 4577 + * The exact context size is not known for BXT, so assume a page size 4578 + * for this check. 4579 + */ 4580 + rc6_ctx_base = I915_READ(RC6_CTX_BASE) & RC6_CTX_BASE_MASK; 4581 + if (!((rc6_ctx_base >= dev_priv->gtt.stolen_reserved_base) && 4582 + (rc6_ctx_base + PAGE_SIZE <= dev_priv->gtt.stolen_reserved_base + 4583 + dev_priv->gtt.stolen_reserved_size))) { 4584 + DRM_DEBUG_KMS("RC6 Base address not as expected.\n"); 4585 + enable_rc6 = false; 4586 + } 4587 + 4588 + if (!(((I915_READ(PWRCTX_MAXCNT_RCSUNIT) & IDLE_TIME_MASK) > 1) && 4589 + ((I915_READ(PWRCTX_MAXCNT_VCSUNIT0) & IDLE_TIME_MASK) > 1) && 4590 + ((I915_READ(PWRCTX_MAXCNT_BCSUNIT) & IDLE_TIME_MASK) > 1) && 4591 + ((I915_READ(PWRCTX_MAXCNT_VECSUNIT) & IDLE_TIME_MASK) > 1))) { 4592 + DRM_DEBUG_KMS("Engine Idle wait time not set properly.\n"); 4593 + enable_rc6 = false; 4594 + } 4595 + 4596 + if (!(I915_READ(GEN6_RC_CONTROL) & (GEN6_RC_CTL_RC6_ENABLE | 4597 + GEN6_RC_CTL_HW_ENABLE)) && 4598 + ((I915_READ(GEN6_RC_CONTROL) & GEN6_RC_CTL_HW_ENABLE) || 4599 + !(I915_READ(GEN6_RC_STATE) & RC6_STATE))) { 4600 + DRM_DEBUG_KMS("HW/SW RC6 is not enabled by BIOS.\n"); 4601 + enable_rc6 = false; 4602 + } 4603 + 4604 + return enable_rc6; 4605 + } 4606 + 4607 + int sanitize_rc6_option(const struct drm_device *dev, int enable_rc6) 4566 4608 { 4567 4609 /* No RC6 before Ironlake and code is gone for ilk. */ 4568 4610 if (INTEL_INFO(dev)->gen < 6) 4569 4611 return 0; 4612 + 4613 + if (!enable_rc6) 4614 + return 0; 4615 + 4616 + if (IS_BROXTON(dev) && !bxt_check_bios_rc6_setup(dev)) { 4617 + DRM_INFO("RC6 disabled by BIOS\n"); 4618 + return 0; 4619 + } 4570 4620 4571 4621 /* Respect the kernel parameter if it is set */ 4572 4622 if (enable_rc6 >= 0) { ··· 6107 6057 { 6108 6058 struct drm_i915_private *dev_priv = dev->dev_private; 6109 6059 6110 - i915.enable_rc6 = sanitize_rc6_option(dev, i915.enable_rc6); 6111 6060 /* 6112 6061 * RPM depends on RC6 to save restore the GT HW context, so make RC6 a 6113 6062 * requirement. ··· 7238 7189 { 7239 7190 int div, czclk_freq = DIV_ROUND_CLOSEST(dev_priv->czclk_freq, 1000); 7240 7191 7241 - div = vlv_gpu_freq_div(czclk_freq) / 2; 7192 + div = vlv_gpu_freq_div(czclk_freq); 7242 7193 if (div < 0) 7243 7194 return div; 7195 + div /= 2; 7244 7196 7245 7197 return DIV_ROUND_CLOSEST(czclk_freq * val, 2 * div) / 2; 7246 7198 } ··· 7250 7200 { 7251 7201 int mul, czclk_freq = DIV_ROUND_CLOSEST(dev_priv->czclk_freq, 1000); 7252 7202 7253 - mul = vlv_gpu_freq_div(czclk_freq) / 2; 7203 + mul = vlv_gpu_freq_div(czclk_freq); 7254 7204 if (mul < 0) 7255 7205 return mul; 7206 + mul /= 2; 7256 7207 7257 7208 /* CHV needs even values */ 7258 7209 return DIV_ROUND_CLOSEST(val * 2 * mul, czclk_freq) * 2;
+45 -9
drivers/gpu/drm/i915/intel_psr.c
··· 225 225 (aux_clock_divider << DP_AUX_CH_CTL_BIT_CLOCK_2X_SHIFT)); 226 226 } 227 227 228 - drm_dp_dpcd_writeb(&intel_dp->aux, DP_PSR_EN_CFG, DP_PSR_ENABLE); 228 + if (dev_priv->psr.link_standby) 229 + drm_dp_dpcd_writeb(&intel_dp->aux, DP_PSR_EN_CFG, 230 + DP_PSR_ENABLE | DP_PSR_MAIN_LINK_ACTIVE); 231 + else 232 + drm_dp_dpcd_writeb(&intel_dp->aux, DP_PSR_EN_CFG, 233 + DP_PSR_ENABLE); 229 234 } 230 235 231 236 static void vlv_psr_enable_source(struct intel_dp *intel_dp) ··· 285 280 if (IS_HASWELL(dev)) 286 281 val |= EDP_PSR_MIN_LINK_ENTRY_TIME_8_LINES; 287 282 283 + if (dev_priv->psr.link_standby) 284 + val |= EDP_PSR_LINK_STANDBY; 285 + 288 286 I915_WRITE(EDP_PSR_CTL, val | 289 287 max_sleep_time << EDP_PSR_MAX_SLEEP_TIME_SHIFT | 290 288 idle_frames << EDP_PSR_IDLE_FRAME_SHIFT | ··· 312 304 313 305 dev_priv->psr.source_ok = false; 314 306 315 - if (IS_HASWELL(dev) && dig_port->port != PORT_A) { 316 - DRM_DEBUG_KMS("HSW ties PSR to DDI A (eDP)\n"); 307 + /* 308 + * HSW spec explicitly says PSR is tied to port A. 309 + * BDW+ platforms with DDI implementation of PSR have different 310 + * PSR registers per transcoder and we only implement transcoder EDP 311 + * ones. Since by Display design transcoder EDP is tied to port A 312 + * we can safely escape based on the port A. 313 + */ 314 + if (HAS_DDI(dev) && dig_port->port != PORT_A) { 315 + DRM_DEBUG_KMS("PSR condition failed: Port not supported\n"); 317 316 return false; 318 317 } 319 318 320 319 if (!i915.enable_psr) { 321 320 DRM_DEBUG_KMS("PSR disable by flag\n"); 321 + return false; 322 + } 323 + 324 + if ((IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev)) && 325 + !dev_priv->psr.link_standby) { 326 + DRM_ERROR("PSR condition failed: Link off requested but not supported on this platform\n"); 322 327 return false; 323 328 } 324 329 ··· 345 324 if (IS_HASWELL(dev) && 346 325 intel_crtc->config->base.adjusted_mode.flags & DRM_MODE_FLAG_INTERLACE) { 347 326 DRM_DEBUG_KMS("PSR condition failed: Interlaced is Enabled\n"); 348 - return false; 349 - } 350 - 351 - if (!IS_VALLEYVIEW(dev) && !IS_CHERRYVIEW(dev) && 352 - ((dev_priv->vbt.psr.full_link) || (dig_port->port != PORT_A))) { 353 - DRM_DEBUG_KMS("PSR condition failed: Link Standby requested/needed but not supported on this platform\n"); 354 327 return false; 355 328 } 356 329 ··· 777 762 778 763 dev_priv->psr_mmio_base = IS_HASWELL(dev_priv) ? 779 764 HSW_EDP_PSR_BASE : BDW_EDP_PSR_BASE; 765 + 766 + /* Set link_standby x link_off defaults */ 767 + if (IS_HASWELL(dev) || IS_BROADWELL(dev)) 768 + /* HSW and BDW require workarounds that we don't implement. */ 769 + dev_priv->psr.link_standby = false; 770 + else if (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev)) 771 + /* On VLV and CHV only standby mode is supported. */ 772 + dev_priv->psr.link_standby = true; 773 + else 774 + /* For new platforms let's respect VBT back again */ 775 + dev_priv->psr.link_standby = dev_priv->vbt.psr.full_link; 776 + 777 + /* Override link_standby x link_off defaults */ 778 + if (i915.enable_psr == 2 && !dev_priv->psr.link_standby) { 779 + DRM_DEBUG_KMS("PSR: Forcing link standby\n"); 780 + dev_priv->psr.link_standby = true; 781 + } 782 + if (i915.enable_psr == 3 && dev_priv->psr.link_standby) { 783 + DRM_DEBUG_KMS("PSR: Forcing main link off\n"); 784 + dev_priv->psr.link_standby = false; 785 + } 780 786 781 787 INIT_DELAYED_WORK(&dev_priv->psr.work, intel_psr_work); 782 788 mutex_init(&dev_priv->psr.lock);
+64
drivers/gpu/drm/i915/intel_ringbuffer.c
··· 789 789 790 790 #define WA_WRITE(addr, val) WA_REG(addr, 0xffffffff, val) 791 791 792 + static int wa_ring_whitelist_reg(struct intel_engine_cs *ring, i915_reg_t reg) 793 + { 794 + struct drm_i915_private *dev_priv = ring->dev->dev_private; 795 + struct i915_workarounds *wa = &dev_priv->workarounds; 796 + const uint32_t index = wa->hw_whitelist_count[ring->id]; 797 + 798 + if (WARN_ON(index >= RING_MAX_NONPRIV_SLOTS)) 799 + return -EINVAL; 800 + 801 + WA_WRITE(RING_FORCE_TO_NONPRIV(ring->mmio_base, index), 802 + i915_mmio_reg_offset(reg)); 803 + wa->hw_whitelist_count[ring->id]++; 804 + 805 + return 0; 806 + } 807 + 792 808 static int gen8_init_workarounds(struct intel_engine_cs *ring) 793 809 { 794 810 struct drm_device *dev = ring->dev; ··· 910 894 struct drm_device *dev = ring->dev; 911 895 struct drm_i915_private *dev_priv = dev->dev_private; 912 896 uint32_t tmp; 897 + int ret; 913 898 914 899 /* WaEnableLbsSlaRetryTimerDecrement:skl */ 915 900 I915_WRITE(BDW_SCRATCH1, I915_READ(BDW_SCRATCH1) | ··· 981 964 /* WaDisableSTUnitPowerOptimization:skl,bxt */ 982 965 WA_SET_BIT_MASKED(HALF_SLICE_CHICKEN2, GEN8_ST_PO_DISABLE); 983 966 967 + /* WaOCLCoherentLineFlush:skl,bxt */ 968 + I915_WRITE(GEN8_L3SQCREG4, (I915_READ(GEN8_L3SQCREG4) | 969 + GEN8_LQSC_FLUSH_COHERENT_LINES)); 970 + 971 + /* WaEnablePreemptionGranularityControlByUMD:skl,bxt */ 972 + ret= wa_ring_whitelist_reg(ring, GEN8_CS_CHICKEN1); 973 + if (ret) 974 + return ret; 975 + 976 + /* WaAllowUMDToModifyHDCChicken1:skl,bxt */ 977 + ret = wa_ring_whitelist_reg(ring, GEN8_HDC_CHICKEN1); 978 + if (ret) 979 + return ret; 980 + 984 981 return 0; 985 982 } 986 983 ··· 1050 1019 if (ret) 1051 1020 return ret; 1052 1021 1022 + /* 1023 + * Actual WA is to disable percontext preemption granularity control 1024 + * until D0 which is the default case so this is equivalent to 1025 + * !WaDisablePerCtxtPreemptionGranularityControl:skl 1026 + */ 1027 + if (IS_SKL_REVID(dev, SKL_REVID_E0, REVID_FOREVER)) { 1028 + I915_WRITE(GEN7_FF_SLICE_CS_CHICKEN1, 1029 + _MASKED_BIT_ENABLE(GEN9_FFSC_PERCTX_PREEMPT_CTRL)); 1030 + } 1031 + 1053 1032 if (IS_SKL_REVID(dev, 0, SKL_REVID_D0)) { 1054 1033 /* WaDisableChickenBitTSGBarrierAckForFFSliceCS:skl */ 1055 1034 I915_WRITE(FF_SLICE_CS_CHICKEN2, ··· 1112 1071 GEN7_HALF_SLICE_CHICKEN1, 1113 1072 GEN7_SBE_SS_CACHE_DISPATCH_PORT_SHARING_DISABLE); 1114 1073 1074 + /* WaDisableLSQCROPERFforOCL:skl */ 1075 + ret = wa_ring_whitelist_reg(ring, GEN8_L3SQCREG4); 1076 + if (ret) 1077 + return ret; 1078 + 1115 1079 return skl_tune_iz_hashing(ring); 1116 1080 } 1117 1081 ··· 1152 1106 GEN7_SBE_SS_CACHE_DISPATCH_PORT_SHARING_DISABLE); 1153 1107 } 1154 1108 1109 + /* WaDisableObjectLevelPreemptionForTrifanOrPolygon:bxt */ 1110 + /* WaDisableObjectLevelPreemptionForInstancedDraw:bxt */ 1111 + /* WaDisableObjectLevelPreemtionForInstanceId:bxt */ 1112 + /* WaDisableLSQCROPERFforOCL:bxt */ 1113 + if (IS_BXT_REVID(dev, 0, BXT_REVID_A1)) { 1114 + ret = wa_ring_whitelist_reg(ring, GEN9_CS_DEBUG_MODE1); 1115 + if (ret) 1116 + return ret; 1117 + 1118 + ret = wa_ring_whitelist_reg(ring, GEN8_L3SQCREG4); 1119 + if (ret) 1120 + return ret; 1121 + } 1122 + 1155 1123 return 0; 1156 1124 } 1157 1125 ··· 1177 1117 WARN_ON(ring->id != RCS); 1178 1118 1179 1119 dev_priv->workarounds.count = 0; 1120 + dev_priv->workarounds.hw_whitelist_count[RCS] = 0; 1180 1121 1181 1122 if (IS_BROADWELL(dev)) 1182 1123 return bdw_init_workarounds(ring); ··· 2118 2057 i915_gem_object_ggtt_unpin(obj); 2119 2058 return ret; 2120 2059 } 2060 + 2061 + /* Access through the GTT requires the device to be awake. */ 2062 + assert_rpm_wakelock_held(dev_priv); 2121 2063 2122 2064 ringbuf->virtual_start = ioremap_wc(dev_priv->gtt.mappable_base + 2123 2065 i915_gem_obj_ggtt_offset(obj), ringbuf->size);
+1
drivers/gpu/drm/i915/intel_ringbuffer.h
··· 158 158 #define I915_NUM_RINGS 5 159 159 #define _VCS(n) (VCS + (n)) 160 160 unsigned int exec_id; 161 + unsigned int guc_id; 161 162 u32 mmio_base; 162 163 struct drm_device *dev; 163 164 struct intel_ringbuffer *buffer;
+4
drivers/gpu/drm/i915/intel_sdvo.c
··· 1527 1527 struct drm_display_mode *mode) 1528 1528 { 1529 1529 struct intel_sdvo *intel_sdvo = intel_attached_sdvo(connector); 1530 + int max_dotclk = to_i915(connector->dev)->max_dotclk_freq; 1530 1531 1531 1532 if (mode->flags & DRM_MODE_FLAG_DBLSCAN) 1532 1533 return MODE_NO_DBLESCAN; ··· 1536 1535 return MODE_CLOCK_LOW; 1537 1536 1538 1537 if (intel_sdvo->pixel_clock_max < mode->clock) 1538 + return MODE_CLOCK_HIGH; 1539 + 1540 + if (mode->clock > max_dotclk) 1539 1541 return MODE_CLOCK_HIGH; 1540 1542 1541 1543 if (intel_sdvo->is_lvds) {
+5 -18
drivers/gpu/drm/i915/intel_sideband.c
··· 129 129 return val; 130 130 } 131 131 132 - u32 vlv_gpio_nc_read(struct drm_i915_private *dev_priv, u32 reg) 132 + u32 vlv_iosf_sb_read(struct drm_i915_private *dev_priv, u8 port, u32 reg) 133 133 { 134 134 u32 val = 0; 135 - vlv_sideband_rw(dev_priv, PCI_DEVFN(0, 0), IOSF_PORT_GPIO_NC, 135 + vlv_sideband_rw(dev_priv, PCI_DEVFN(0, 0), port, 136 136 SB_CRRDDA_NP, reg, &val); 137 137 return val; 138 138 } 139 139 140 - void vlv_gpio_nc_write(struct drm_i915_private *dev_priv, u32 reg, u32 val) 140 + void vlv_iosf_sb_write(struct drm_i915_private *dev_priv, 141 + u8 port, u32 reg, u32 val) 141 142 { 142 - vlv_sideband_rw(dev_priv, PCI_DEVFN(0, 0), IOSF_PORT_GPIO_NC, 143 + vlv_sideband_rw(dev_priv, PCI_DEVFN(0, 0), port, 143 144 SB_CRWRDA_NP, reg, &val); 144 145 } 145 146 ··· 169 168 void vlv_ccu_write(struct drm_i915_private *dev_priv, u32 reg, u32 val) 170 169 { 171 170 vlv_sideband_rw(dev_priv, PCI_DEVFN(0, 0), IOSF_PORT_CCU, 172 - SB_CRWRDA_NP, reg, &val); 173 - } 174 - 175 - u32 vlv_gps_core_read(struct drm_i915_private *dev_priv, u32 reg) 176 - { 177 - u32 val = 0; 178 - vlv_sideband_rw(dev_priv, PCI_DEVFN(0, 0), IOSF_PORT_GPS_CORE, 179 - SB_CRRDDA_NP, reg, &val); 180 - return val; 181 - } 182 - 183 - void vlv_gps_core_write(struct drm_i915_private *dev_priv, u32 reg, u32 val) 184 - { 185 - vlv_sideband_rw(dev_priv, PCI_DEVFN(0, 0), IOSF_PORT_GPS_CORE, 186 171 SB_CRWRDA_NP, reg, &val); 187 172 } 188 173
+17 -23
drivers/gpu/drm/i915/intel_sprite.c
··· 350 350 int pipe = intel_plane->pipe; 351 351 int plane = intel_plane->plane; 352 352 u32 sprctl; 353 - unsigned long sprsurf_offset, linear_offset; 354 - int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); 353 + u32 sprsurf_offset, linear_offset; 354 + int cpp = drm_format_plane_cpp(fb->pixel_format, 0); 355 355 const struct drm_intel_sprite_colorkey *key = &plane_state->ckey; 356 356 int crtc_x = plane_state->dst.x1; 357 357 int crtc_y = plane_state->dst.y1; ··· 422 422 crtc_w--; 423 423 crtc_h--; 424 424 425 - linear_offset = y * fb->pitches[0] + x * pixel_size; 425 + linear_offset = y * fb->pitches[0] + x * cpp; 426 426 sprsurf_offset = intel_compute_tile_offset(dev_priv, &x, &y, 427 - fb->modifier[0], 428 - pixel_size, 427 + fb->modifier[0], cpp, 429 428 fb->pitches[0]); 430 429 linear_offset -= sprsurf_offset; 431 430 ··· 433 434 434 435 x += src_w; 435 436 y += src_h; 436 - linear_offset += src_h * fb->pitches[0] + src_w * pixel_size; 437 + linear_offset += src_h * fb->pitches[0] + src_w * cpp; 437 438 } 438 439 439 440 if (key->flags) { ··· 492 493 struct drm_i915_gem_object *obj = intel_fb_obj(fb); 493 494 enum pipe pipe = intel_plane->pipe; 494 495 u32 sprctl, sprscale = 0; 495 - unsigned long sprsurf_offset, linear_offset; 496 - int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); 496 + u32 sprsurf_offset, linear_offset; 497 + int cpp = drm_format_plane_cpp(fb->pixel_format, 0); 497 498 const struct drm_intel_sprite_colorkey *key = &plane_state->ckey; 498 499 int crtc_x = plane_state->dst.x1; 499 500 int crtc_y = plane_state->dst.y1; ··· 555 556 if (crtc_w != src_w || crtc_h != src_h) 556 557 sprscale = SPRITE_SCALE_ENABLE | (src_w << 16) | src_h; 557 558 558 - linear_offset = y * fb->pitches[0] + x * pixel_size; 559 + linear_offset = y * fb->pitches[0] + x * cpp; 559 560 sprsurf_offset = intel_compute_tile_offset(dev_priv, &x, &y, 560 - fb->modifier[0], 561 - pixel_size, 561 + fb->modifier[0], cpp, 562 562 fb->pitches[0]); 563 563 linear_offset -= sprsurf_offset; 564 564 ··· 568 570 if (!IS_HASWELL(dev) && !IS_BROADWELL(dev)) { 569 571 x += src_w; 570 572 y += src_h; 571 - linear_offset += src_h * fb->pitches[0] + 572 - src_w * pixel_size; 573 + linear_offset += src_h * fb->pitches[0] + src_w * cpp; 573 574 } 574 575 } 575 576 ··· 632 635 struct drm_framebuffer *fb = plane_state->base.fb; 633 636 struct drm_i915_gem_object *obj = intel_fb_obj(fb); 634 637 int pipe = intel_plane->pipe; 635 - unsigned long dvssurf_offset, linear_offset; 636 638 u32 dvscntr, dvsscale; 637 - int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); 639 + u32 dvssurf_offset, linear_offset; 640 + int cpp = drm_format_plane_cpp(fb->pixel_format, 0); 638 641 const struct drm_intel_sprite_colorkey *key = &plane_state->ckey; 639 642 int crtc_x = plane_state->dst.x1; 640 643 int crtc_y = plane_state->dst.y1; ··· 692 695 if (crtc_w != src_w || crtc_h != src_h) 693 696 dvsscale = DVS_SCALE_ENABLE | (src_w << 16) | src_h; 694 697 695 - linear_offset = y * fb->pitches[0] + x * pixel_size; 698 + linear_offset = y * fb->pitches[0] + x * cpp; 696 699 dvssurf_offset = intel_compute_tile_offset(dev_priv, &x, &y, 697 - fb->modifier[0], 698 - pixel_size, 700 + fb->modifier[0], cpp, 699 701 fb->pitches[0]); 700 702 linear_offset -= dvssurf_offset; 701 703 ··· 703 707 704 708 x += src_w; 705 709 y += src_h; 706 - linear_offset += src_h * fb->pitches[0] + src_w * pixel_size; 710 + linear_offset += src_h * fb->pitches[0] + src_w * cpp; 707 711 } 708 712 709 713 if (key->flags) { ··· 768 772 int hscale, vscale; 769 773 int max_scale, min_scale; 770 774 bool can_scale; 771 - int pixel_size; 772 775 773 776 if (!fb) { 774 777 state->visible = false; ··· 889 894 /* Check size restrictions when scaling */ 890 895 if (state->visible && (src_w != crtc_w || src_h != crtc_h)) { 891 896 unsigned int width_bytes; 897 + int cpp = drm_format_plane_cpp(fb->pixel_format, 0); 892 898 893 899 WARN_ON(!can_scale); 894 900 ··· 901 905 if (src_w < 3 || src_h < 3) 902 906 state->visible = false; 903 907 904 - pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); 905 - width_bytes = ((src_x * pixel_size) & 63) + 906 - src_w * pixel_size; 908 + width_bytes = ((src_x * cpp) & 63) + src_w * cpp; 907 909 908 910 if (INTEL_INFO(dev)->gen < 9 && (src_w > 2048 || src_h > 2048 || 909 911 width_bytes > 4096 || fb->pitches[0] > 4096)) {
+5
drivers/gpu/drm/i915/intel_tv.c
··· 897 897 { 898 898 struct intel_tv *intel_tv = intel_attached_tv(connector); 899 899 const struct tv_mode *tv_mode = intel_tv_mode_find(intel_tv); 900 + int max_dotclk = to_i915(connector->dev)->max_dotclk_freq; 901 + 902 + if (mode->clock > max_dotclk) 903 + return MODE_CLOCK_HIGH; 900 904 901 905 /* Ensure TV refresh is close to desired refresh */ 902 906 if (tv_mode && abs(tv_mode->refresh - drm_mode_vrefresh(mode) * 1000) ··· 1424 1420 if (!mode_ptr) 1425 1421 continue; 1426 1422 strncpy(mode_ptr->name, input->name, DRM_DISPLAY_MODE_LEN); 1423 + mode_ptr->name[DRM_DISPLAY_MODE_LEN - 1] = '\0'; 1427 1424 1428 1425 mode_ptr->hdisplay = hactive_s; 1429 1426 mode_ptr->hsync_start = hactive_s + 1;
+2
drivers/gpu/drm/i915/intel_uncore.c
··· 400 400 401 401 void intel_uncore_sanitize(struct drm_device *dev) 402 402 { 403 + i915.enable_rc6 = sanitize_rc6_option(dev, i915.enable_rc6); 404 + 403 405 /* BIOS often leaves RC6 enabled, but disable it for hw init */ 404 406 intel_disable_gt_powersave(dev); 405 407 }
+5 -1
include/drm/i915_pciids.h
··· 277 277 INTEL_VGA_DEVICE(0x191D, info) /* WKS GT2 */ 278 278 279 279 #define INTEL_SKL_GT3_IDS(info) \ 280 + INTEL_VGA_DEVICE(0x1923, info), /* ULT GT3 */ \ 280 281 INTEL_VGA_DEVICE(0x1926, info), /* ULT GT3 */ \ 282 + INTEL_VGA_DEVICE(0x1927, info), /* ULT GT3 */ \ 281 283 INTEL_VGA_DEVICE(0x192B, info), /* Halo GT3 */ \ 282 284 INTEL_VGA_DEVICE(0x192A, info) /* SRV GT3 */ 283 285 ··· 298 296 #define INTEL_BXT_IDS(info) \ 299 297 INTEL_VGA_DEVICE(0x0A84, info), \ 300 298 INTEL_VGA_DEVICE(0x1A84, info), \ 301 - INTEL_VGA_DEVICE(0x5A84, info) 299 + INTEL_VGA_DEVICE(0x1A85, info), \ 300 + INTEL_VGA_DEVICE(0x5A84, info), /* APL HD Graphics 505 */ \ 301 + INTEL_VGA_DEVICE(0x5A85, info) /* APL HD Graphics 500 */ 302 302 303 303 #define INTEL_KBL_GT1_IDS(info) \ 304 304 INTEL_VGA_DEVICE(0x5913, info), /* ULT GT1.5 */ \
+6 -4
include/uapi/drm/i915_drm.h
··· 772 772 #define I915_EXEC_HANDLE_LUT (1<<12) 773 773 774 774 /** Used for switching BSD rings on the platforms with two BSD rings */ 775 - #define I915_EXEC_BSD_MASK (3<<13) 776 - #define I915_EXEC_BSD_DEFAULT (0<<13) /* default ping-pong mode */ 777 - #define I915_EXEC_BSD_RING1 (1<<13) 778 - #define I915_EXEC_BSD_RING2 (2<<13) 775 + #define I915_EXEC_BSD_SHIFT (13) 776 + #define I915_EXEC_BSD_MASK (3 << I915_EXEC_BSD_SHIFT) 777 + /* default ping-pong mode */ 778 + #define I915_EXEC_BSD_DEFAULT (0 << I915_EXEC_BSD_SHIFT) 779 + #define I915_EXEC_BSD_RING1 (1 << I915_EXEC_BSD_SHIFT) 780 + #define I915_EXEC_BSD_RING2 (2 << I915_EXEC_BSD_SHIFT) 779 781 780 782 /** Tell the kernel that the batchbuffer is processed by 781 783 * the resource streamer.