Lines Matching +full:0 +full:xe

64 	struct xe_device *xe = to_xe_device(dev);  in xe_file_open()  local
82 xef->xe = xe; in xe_file_open()
100 return 0; in xe_file_open()
118 * xe_file_get() - Take a reference to the xe file object
119 * @xef: Pointer to the xe file
121 * Anyone with a pointer to xef must take a reference to the xe file
124 * Return: xe file pointer
133 * xe_file_put() - Drop a reference to the xe file object
134 * @xef: Pointer to the xe file
145 struct xe_device *xe = to_xe_device(dev); in xe_file_close() local
151 xe_pm_runtime_get(xe); in xe_file_close()
170 xe_pm_runtime_put(xe); in xe_file_close()
196 struct xe_device *xe = to_xe_device(file_priv->minor->dev); in xe_drm_ioctl() local
199 if (xe_device_wedged(xe)) in xe_drm_ioctl()
202 ret = xe_pm_runtime_get_ioctl(xe); in xe_drm_ioctl()
203 if (ret >= 0) in xe_drm_ioctl()
205 xe_pm_runtime_put(xe); in xe_drm_ioctl()
214 struct xe_device *xe = to_xe_device(file_priv->minor->dev); in xe_drm_compat_ioctl() local
217 if (xe_device_wedged(xe)) in xe_drm_compat_ioctl()
220 ret = xe_pm_runtime_get_ioctl(xe); in xe_drm_compat_ioctl()
221 if (ret >= 0) in xe_drm_compat_ioctl()
223 xe_pm_runtime_put(xe); in xe_drm_compat_ioctl()
279 struct xe_device *xe = to_xe_device(dev); in xe_device_destroy() local
281 if (xe->preempt_fence_wq) in xe_device_destroy()
282 destroy_workqueue(xe->preempt_fence_wq); in xe_device_destroy()
284 if (xe->ordered_wq) in xe_device_destroy()
285 destroy_workqueue(xe->ordered_wq); in xe_device_destroy()
287 if (xe->unordered_wq) in xe_device_destroy()
288 destroy_workqueue(xe->unordered_wq); in xe_device_destroy()
290 if (xe->destroy_wq) in xe_device_destroy()
291 destroy_workqueue(xe->destroy_wq); in xe_device_destroy()
293 ttm_device_fini(&xe->ttm); in xe_device_destroy()
299 struct xe_device *xe; in xe_device_create() local
308 xe = devm_drm_dev_alloc(&pdev->dev, &driver, struct xe_device, drm); in xe_device_create()
309 if (IS_ERR(xe)) in xe_device_create()
310 return xe; in xe_device_create()
312 err = ttm_device_init(&xe->ttm, &xe_ttm_funcs, xe->drm.dev, in xe_device_create()
313 xe->drm.anon_inode->i_mapping, in xe_device_create()
314 xe->drm.vma_offset_manager, false, false); in xe_device_create()
318 err = drmm_add_action_or_reset(&xe->drm, xe_device_destroy, NULL); in xe_device_create()
322 xe->info.devid = pdev->device; in xe_device_create()
323 xe->info.revid = pdev->revision; in xe_device_create()
324 xe->info.force_execlist = xe_modparam.force_execlist; in xe_device_create()
326 spin_lock_init(&xe->irq.lock); in xe_device_create()
328 init_waitqueue_head(&xe->ufence_wq); in xe_device_create()
330 init_rwsem(&xe->usm.lock); in xe_device_create()
332 xa_init_flags(&xe->usm.asid_to_vm, XA_FLAGS_ALLOC); in xe_device_create()
339 err = xa_alloc_cyclic(&xe->usm.asid_to_vm, &asid, NULL, in xe_device_create()
341 &xe->usm.next_asid, GFP_KERNEL); in xe_device_create()
342 drm_WARN_ON(&xe->drm, err); in xe_device_create()
343 if (err >= 0) in xe_device_create()
344 xa_erase(&xe->usm.asid_to_vm, asid); in xe_device_create()
347 spin_lock_init(&xe->pinned.lock); in xe_device_create()
348 INIT_LIST_HEAD(&xe->pinned.kernel_bo_present); in xe_device_create()
349 INIT_LIST_HEAD(&xe->pinned.external_vram); in xe_device_create()
350 INIT_LIST_HEAD(&xe->pinned.evicted); in xe_device_create()
352 xe->preempt_fence_wq = alloc_ordered_workqueue("xe-preempt-fence-wq", 0); in xe_device_create()
353 xe->ordered_wq = alloc_ordered_workqueue("xe-ordered-wq", 0); in xe_device_create()
354 xe->unordered_wq = alloc_workqueue("xe-unordered-wq", 0, 0); in xe_device_create()
355 xe->destroy_wq = alloc_workqueue("xe-destroy-wq", 0, 0); in xe_device_create()
356 if (!xe->ordered_wq || !xe->unordered_wq || in xe_device_create()
357 !xe->preempt_fence_wq || !xe->destroy_wq) { in xe_device_create()
362 drm_err(&xe->drm, "Failed to allocate xe workqueues\n"); in xe_device_create()
367 err = xe_display_create(xe); in xe_device_create()
371 return xe; in xe_device_create()
390 static void xe_driver_flr(struct xe_device *xe) in xe_driver_flr() argument
393 struct xe_gt *gt = xe_root_mmio_gt(xe); in xe_driver_flr()
397 drm_info_once(&xe->drm, "BIOS Disabled Driver-FLR\n"); in xe_driver_flr()
401 drm_dbg(&xe->drm, "Triggering Driver-FLR\n"); in xe_driver_flr()
412 ret = xe_mmio_wait32(gt, GU_CNTL, DRIVERFLR, 0, flr_timeout, NULL, false); in xe_driver_flr()
414 drm_err(&xe->drm, "Driver-FLR-prepare wait for ready failed! %d\n", ret); in xe_driver_flr()
420 xe_mmio_rmw32(gt, GU_CNTL, 0, DRIVERFLR); in xe_driver_flr()
423 ret = xe_mmio_wait32(gt, GU_CNTL, DRIVERFLR, 0, flr_timeout, NULL, false); in xe_driver_flr()
425 drm_err(&xe->drm, "Driver-FLR-teardown wait completion failed! %d\n", ret); in xe_driver_flr()
433 drm_err(&xe->drm, "Driver-FLR-reinit wait completion failed! %d\n", ret); in xe_driver_flr()
443 struct xe_device *xe = arg; in xe_driver_flr_fini() local
445 if (xe->needs_flr_on_fini) in xe_driver_flr_fini()
446 xe_driver_flr(xe); in xe_driver_flr_fini()
451 struct xe_device *xe = arg; in xe_device_sanitize() local
455 for_each_gt(gt, xe, id) in xe_device_sanitize()
459 static int xe_set_dma_info(struct xe_device *xe) in xe_set_dma_info() argument
461 unsigned int mask_size = xe->info.dma_mask_size; in xe_set_dma_info()
464 dma_set_max_seg_size(xe->drm.dev, xe_sg_segment_size(xe->drm.dev)); in xe_set_dma_info()
466 err = dma_set_mask(xe->drm.dev, DMA_BIT_MASK(mask_size)); in xe_set_dma_info()
470 err = dma_set_coherent_mask(xe->drm.dev, DMA_BIT_MASK(mask_size)); in xe_set_dma_info()
474 return 0; in xe_set_dma_info()
477 drm_err(&xe->drm, "Can't set DMA mask/consistent mask (%d)\n", err); in xe_set_dma_info()
488 static int wait_for_lmem_ready(struct xe_device *xe) in wait_for_lmem_ready() argument
490 struct xe_gt *gt = xe_root_mmio_gt(xe); in wait_for_lmem_ready()
493 if (!IS_DGFX(xe)) in wait_for_lmem_ready()
494 return 0; in wait_for_lmem_ready()
496 if (IS_SRIOV_VF(xe)) in wait_for_lmem_ready()
497 return 0; in wait_for_lmem_ready()
500 return 0; in wait_for_lmem_ready()
502 drm_dbg(&xe->drm, "Waiting for lmem initialization\n"); in wait_for_lmem_ready()
522 drm_dbg(&xe->drm, "lmem not initialized by firmware\n"); in wait_for_lmem_ready()
530 drm_dbg(&xe->drm, "lmem ready after %ums", in wait_for_lmem_ready()
533 return 0; in wait_for_lmem_ready()
536 static void update_device_info(struct xe_device *xe) in update_device_info() argument
539 if (IS_SRIOV_VF(xe)) { in update_device_info()
540 xe->info.probe_display = 0; in update_device_info()
541 xe->info.has_heci_gscfi = 0; in update_device_info()
542 xe->info.skip_guc_pc = 1; in update_device_info()
543 xe->info.skip_pcode = 1; in update_device_info()
549 * @xe: xe device instance
555 * Return: 0 on success, error code on failure
557 int xe_device_probe_early(struct xe_device *xe) in xe_device_probe_early() argument
561 err = xe_mmio_init(xe); in xe_device_probe_early()
565 xe_sriov_probe_early(xe); in xe_device_probe_early()
567 update_device_info(xe); in xe_device_probe_early()
569 err = xe_pcode_probe_early(xe); in xe_device_probe_early()
573 err = wait_for_lmem_ready(xe); in xe_device_probe_early()
577 xe->wedged.mode = xe_modparam.wedged_mode; in xe_device_probe_early()
579 return 0; in xe_device_probe_early()
582 static int xe_device_set_has_flat_ccs(struct xe_device *xe) in xe_device_set_has_flat_ccs() argument
587 if (GRAPHICS_VER(xe) < 20 || !xe->info.has_flat_ccs) in xe_device_set_has_flat_ccs()
588 return 0; in xe_device_set_has_flat_ccs()
590 struct xe_gt *gt = xe_root_mmio_gt(xe); in xe_device_set_has_flat_ccs()
597 xe->info.has_flat_ccs = (reg & XE2_FLAT_CCS_ENABLE); in xe_device_set_has_flat_ccs()
599 if (!xe->info.has_flat_ccs) in xe_device_set_has_flat_ccs()
600 drm_dbg(&xe->drm, in xe_device_set_has_flat_ccs()
606 int xe_device_probe(struct xe_device *xe) in xe_device_probe() argument
614 xe_pat_init_early(xe); in xe_device_probe()
616 err = xe_sriov_init(xe); in xe_device_probe()
620 xe->info.mem_region_mask = 1; in xe_device_probe()
621 err = xe_display_init_nommio(xe); in xe_device_probe()
625 err = xe_set_dma_info(xe); in xe_device_probe()
629 err = xe_mmio_probe_tiles(xe); in xe_device_probe()
633 xe_ttm_sys_mgr_init(xe); in xe_device_probe()
635 for_each_gt(gt, xe, id) { in xe_device_probe()
641 for_each_tile(tile, xe, id) { in xe_device_probe()
642 if (IS_SRIOV_VF(xe)) { in xe_device_probe()
654 if (IS_SRIOV_VF(xe)) { in xe_device_probe()
661 for_each_gt(gt, xe, id) { in xe_device_probe()
667 err = xe_devcoredump_init(xe); in xe_device_probe()
670 err = devm_add_action_or_reset(xe->drm.dev, xe_driver_flr_fini, xe); in xe_device_probe()
674 err = xe_display_init_noirq(xe); in xe_device_probe()
678 err = xe_irq_install(xe); in xe_device_probe()
682 err = xe_device_set_has_flat_ccs(xe); in xe_device_probe()
686 err = xe_vram_probe(xe); in xe_device_probe()
690 for_each_tile(tile, xe, id) { in xe_device_probe()
697 xe_ttm_stolen_mgr_init(xe); in xe_device_probe()
705 err = xe_display_init_noaccel(xe); in xe_device_probe()
709 for_each_gt(gt, xe, id) { in xe_device_probe()
717 xe_heci_gsc_init(xe); in xe_device_probe()
719 err = xe_oa_init(xe); in xe_device_probe()
723 err = xe_display_init(xe); in xe_device_probe()
727 err = drm_dev_register(&xe->drm, 0); in xe_device_probe()
731 xe_display_register(xe); in xe_device_probe()
733 xe_oa_register(xe); in xe_device_probe()
735 xe_debugfs_register(xe); in xe_device_probe()
737 xe_hwmon_register(xe); in xe_device_probe()
739 for_each_gt(gt, xe, id) in xe_device_probe()
742 return devm_add_action_or_reset(xe->drm.dev, xe_device_sanitize, xe); in xe_device_probe()
745 xe_display_driver_remove(xe); in xe_device_probe()
748 xe_oa_fini(xe); in xe_device_probe()
751 for_each_gt(gt, xe, id) { in xe_device_probe()
759 xe_display_fini(xe); in xe_device_probe()
763 static void xe_device_remove_display(struct xe_device *xe) in xe_device_remove_display() argument
765 xe_display_unregister(xe); in xe_device_remove_display()
767 drm_dev_unplug(&xe->drm); in xe_device_remove_display()
768 xe_display_driver_remove(xe); in xe_device_remove_display()
771 void xe_device_remove(struct xe_device *xe) in xe_device_remove() argument
776 xe_oa_unregister(xe); in xe_device_remove()
778 xe_device_remove_display(xe); in xe_device_remove()
780 xe_display_fini(xe); in xe_device_remove()
782 xe_oa_fini(xe); in xe_device_remove()
784 xe_heci_gsc_fini(xe); in xe_device_remove()
786 for_each_gt(gt, xe, id) in xe_device_remove()
790 void xe_device_shutdown(struct xe_device *xe) in xe_device_shutdown() argument
796 * @xe: the &xe_device
803 void xe_device_wmb(struct xe_device *xe) in xe_device_wmb() argument
805 struct xe_gt *gt = xe_root_mmio_gt(xe); in xe_device_wmb()
808 if (IS_DGFX(xe)) in xe_device_wmb()
809 xe_mmio_write32(gt, VF_CAP_REG, 0); in xe_device_wmb()
814 * @xe: The device
830 void xe_device_td_flush(struct xe_device *xe) in xe_device_td_flush() argument
835 if (!IS_DGFX(xe) || GRAPHICS_VER(xe) < 20) in xe_device_td_flush()
838 if (XE_WA(xe_root_mmio_gt(xe), 16023588340)) { in xe_device_td_flush()
839 xe_device_l2_flush(xe); in xe_device_td_flush()
843 for_each_gt(gt, xe, id) { in xe_device_td_flush()
858 if (xe_mmio_wait32(gt, XE2_TDF_CTRL, TRANSIENT_FLUSH_REQUEST, 0, in xe_device_td_flush()
866 void xe_device_l2_flush(struct xe_device *xe) in xe_device_l2_flush() argument
871 gt = xe_root_mmio_gt(xe); in xe_device_l2_flush()
881 xe_mmio_write32(gt, XE2_GLOBAL_INVAL, 0x1); in xe_device_l2_flush()
883 if (xe_mmio_wait32(gt, XE2_GLOBAL_INVAL, 0x1, 0x0, 500, NULL, true)) in xe_device_l2_flush()
890 u32 xe_device_ccs_bytes(struct xe_device *xe, u64 size) in xe_device_ccs_bytes() argument
892 return xe_device_has_flat_ccs(xe) ? in xe_device_ccs_bytes()
893 DIV_ROUND_UP_ULL(size, NUM_BYTES_PER_CCS_BYTE(xe)) : 0; in xe_device_ccs_bytes()
898 * @xe: xe device instance
902 * that the device is going to remain awake. Xe PM runtime get and put
907 void xe_device_assert_mem_access(struct xe_device *xe) in xe_device_assert_mem_access() argument
909 xe_assert(xe, !xe_pm_runtime_suspended(xe)); in xe_device_assert_mem_access()
912 void xe_device_snapshot_print(struct xe_device *xe, struct drm_printer *p) in xe_device_snapshot_print() argument
917 drm_printf(p, "PCI ID: 0x%04x\n", xe->info.devid); in xe_device_snapshot_print()
918 drm_printf(p, "PCI revision: 0x%02x\n", xe->info.revid); in xe_device_snapshot_print()
920 for_each_gt(gt, xe, id) { in xe_device_snapshot_print()
932 u64 xe_device_canonicalize_addr(struct xe_device *xe, u64 address) in xe_device_canonicalize_addr() argument
934 return sign_extend64(address, xe->info.va_bits - 1); in xe_device_canonicalize_addr()
937 u64 xe_device_uncanonicalize_addr(struct xe_device *xe, u64 address) in xe_device_uncanonicalize_addr() argument
939 return address & GENMASK_ULL(xe->info.va_bits - 1, 0); in xe_device_uncanonicalize_addr()
944 struct xe_device *xe = arg; in xe_device_wedged_fini() local
946 xe_pm_runtime_put(xe); in xe_device_wedged_fini()
951 * @xe: xe device instance
958 * If xe.wedged module parameter is set to 2, this function will be called
963 void xe_device_declare_wedged(struct xe_device *xe) in xe_device_declare_wedged() argument
968 if (xe->wedged.mode == 0) { in xe_device_declare_wedged()
969 drm_dbg(&xe->drm, "Wedged mode is forcibly disabled\n"); in xe_device_declare_wedged()
973 xe_pm_runtime_get_noresume(xe); in xe_device_declare_wedged()
975 if (drmm_add_action_or_reset(&xe->drm, xe_device_wedged_fini, xe)) { in xe_device_declare_wedged()
976 …drm_err(&xe->drm, "Failed to register xe_device_wedged_fini clean-up. Although device is wedged.\n… in xe_device_declare_wedged()
980 if (!atomic_xchg(&xe->wedged.flag, 1)) { in xe_device_declare_wedged()
981 xe->needs_flr_on_fini = true; in xe_device_declare_wedged()
982 drm_err(&xe->drm, in xe_device_declare_wedged()
983 "CRITICAL: Xe has declared device %s as wedged.\n" in xe_device_declare_wedged()
985 "Please file a _new_ bug report at https://gitlab.freedesktop.org/drm/xe/kernel/issues/new\n", in xe_device_declare_wedged()
986 dev_name(xe->drm.dev)); in xe_device_declare_wedged()
989 for_each_gt(gt, xe, id) in xe_device_declare_wedged()