Lines Matching defs:xe

52 	struct xe_device *xe = to_xe_device(dev);
69 xef->xe = xe;
77 spin_lock(&xe->clients.lock);
78 xe->clients.count++;
79 spin_unlock(&xe->clients.lock);
87 struct xe_device *xe = to_xe_device(dev);
108 spin_lock(&xe->clients.lock);
109 xe->clients.count--;
110 spin_unlock(&xe->clients.lock);
138 struct xe_device *xe = to_xe_device(file_priv->minor->dev);
141 ret = xe_pm_runtime_get_ioctl(xe);
144 xe_pm_runtime_put(xe);
153 struct xe_device *xe = to_xe_device(file_priv->minor->dev);
156 ret = xe_pm_runtime_get_ioctl(xe);
159 xe_pm_runtime_put(xe);
185 struct xe_device *xe = to_xe_device(dev);
187 pci_set_drvdata(to_pci_dev(xe->drm.dev), NULL);
223 struct xe_device *xe = to_xe_device(dev);
225 if (xe->preempt_fence_wq)
226 destroy_workqueue(xe->preempt_fence_wq);
228 if (xe->ordered_wq)
229 destroy_workqueue(xe->ordered_wq);
231 if (xe->unordered_wq)
232 destroy_workqueue(xe->unordered_wq);
234 ttm_device_fini(&xe->ttm);
240 struct xe_device *xe;
249 xe = devm_drm_dev_alloc(&pdev->dev, &driver, struct xe_device, drm);
250 if (IS_ERR(xe))
251 return xe;
253 err = ttm_device_init(&xe->ttm, &xe_ttm_funcs, xe->drm.dev,
254 xe->drm.anon_inode->i_mapping,
255 xe->drm.vma_offset_manager, false, false);
259 err = drmm_add_action_or_reset(&xe->drm, xe_device_destroy, NULL);
263 xe->info.devid = pdev->device;
264 xe->info.revid = pdev->revision;
265 xe->info.force_execlist = xe_modparam.force_execlist;
267 spin_lock_init(&xe->irq.lock);
268 spin_lock_init(&xe->clients.lock);
270 init_waitqueue_head(&xe->ufence_wq);
272 drmm_mutex_init(&xe->drm, &xe->usm.lock);
273 xa_init_flags(&xe->usm.asid_to_vm, XA_FLAGS_ALLOC);
280 err = xa_alloc_cyclic(&xe->usm.asid_to_vm, &asid, NULL,
282 &xe->usm.next_asid, GFP_KERNEL);
283 drm_WARN_ON(&xe->drm, err);
285 xa_erase(&xe->usm.asid_to_vm, asid);
288 spin_lock_init(&xe->pinned.lock);
289 INIT_LIST_HEAD(&xe->pinned.kernel_bo_present);
290 INIT_LIST_HEAD(&xe->pinned.external_vram);
291 INIT_LIST_HEAD(&xe->pinned.evicted);
293 xe->preempt_fence_wq = alloc_ordered_workqueue("xe-preempt-fence-wq", 0);
294 xe->ordered_wq = alloc_ordered_workqueue("xe-ordered-wq", 0);
295 xe->unordered_wq = alloc_workqueue("xe-unordered-wq", 0, 0);
296 if (!xe->ordered_wq || !xe->unordered_wq ||
297 !xe->preempt_fence_wq) {
302 drm_err(&xe->drm, "Failed to allocate xe workqueues\n");
307 err = xe_display_create(xe);
311 return xe;
330 static void xe_driver_flr(struct xe_device *xe)
333 struct xe_gt *gt = xe_root_mmio_gt(xe);
337 drm_info_once(&xe->drm, "BIOS Disabled Driver-FLR\n");
341 drm_dbg(&xe->drm, "Triggering Driver-FLR\n");
354 drm_err(&xe->drm, "Driver-FLR-prepare wait for ready failed! %d\n", ret);
365 drm_err(&xe->drm, "Driver-FLR-teardown wait completion failed! %d\n", ret);
373 drm_err(&xe->drm, "Driver-FLR-reinit wait completion failed! %d\n", ret);
383 struct xe_device *xe = arg;
385 if (xe->needs_flr_on_fini)
386 xe_driver_flr(xe);
391 struct xe_device *xe = arg;
395 for_each_gt(gt, xe, id)
399 static int xe_set_dma_info(struct xe_device *xe)
401 unsigned int mask_size = xe->info.dma_mask_size;
404 dma_set_max_seg_size(xe->drm.dev, xe_sg_segment_size(xe->drm.dev));
406 err = dma_set_mask(xe->drm.dev, DMA_BIT_MASK(mask_size));
410 err = dma_set_coherent_mask(xe->drm.dev, DMA_BIT_MASK(mask_size));
417 drm_err(&xe->drm, "Can't set DMA mask/consistent mask (%d)\n", err);
428 static int wait_for_lmem_ready(struct xe_device *xe)
430 struct xe_gt *gt = xe_root_mmio_gt(xe);
433 if (!IS_DGFX(xe))
436 if (IS_SRIOV_VF(xe))
442 drm_dbg(&xe->drm, "Waiting for lmem initialization\n");
462 drm_dbg(&xe->drm, "lmem not initialized by firmware\n");
470 drm_dbg(&xe->drm, "lmem ready after %ums",
478 * @xe: xe device instance
486 int xe_device_probe_early(struct xe_device *xe)
490 err = xe_mmio_init(xe);
494 xe_sriov_probe_early(xe);
496 err = xe_pcode_probe_early(xe);
500 err = wait_for_lmem_ready(xe);
507 static int xe_device_set_has_flat_ccs(struct xe_device *xe)
512 if (GRAPHICS_VER(xe) < 20 || !xe->info.has_flat_ccs)
515 struct xe_gt *gt = xe_root_mmio_gt(xe);
522 xe->info.has_flat_ccs = (reg & XE2_FLAT_CCS_ENABLE);
524 if (!xe->info.has_flat_ccs)
525 drm_dbg(&xe->drm,
531 int xe_device_probe(struct xe_device *xe)
539 xe_pat_init_early(xe);
541 err = xe_sriov_init(xe);
545 xe->info.mem_region_mask = 1;
546 err = xe_display_init_nommio(xe);
550 err = xe_set_dma_info(xe);
554 xe_mmio_probe_tiles(xe);
556 xe_ttm_sys_mgr_init(xe);
558 for_each_gt(gt, xe, id)
561 for_each_tile(tile, xe, id) {
565 if (IS_SRIOV_VF(xe)) {
572 for_each_gt(gt, xe, id) {
578 err = xe_devcoredump_init(xe);
581 err = drmm_add_action_or_reset(&xe->drm, xe_driver_flr_fini, xe);
585 for_each_gt(gt, xe, id)
588 err = xe_display_init_noirq(xe);
592 err = xe_irq_install(xe);
596 for_each_gt(gt, xe, id) {
602 err = xe_device_set_has_flat_ccs(xe);
606 err = xe_mmio_probe_vram(xe);
610 for_each_tile(tile, xe, id) {
617 xe_ttm_stolen_mgr_init(xe);
625 err = xe_display_init_noaccel(xe);
629 for_each_gt(gt, xe, id) {
637 xe_heci_gsc_init(xe);
639 err = xe_display_init(xe);
643 err = drm_dev_register(&xe->drm, 0);
647 xe_display_register(xe);
649 xe_debugfs_register(xe);
651 xe_hwmon_register(xe);
653 return drmm_add_action_or_reset(&xe->drm, xe_device_sanitize, xe);
656 xe_display_driver_remove(xe);
659 for_each_gt(gt, xe, id) {
667 xe_irq_shutdown(xe);
669 xe_display_fini(xe);
673 static void xe_device_remove_display(struct xe_device *xe)
675 xe_display_unregister(xe);
677 drm_dev_unplug(&xe->drm);
678 xe_display_driver_remove(xe);
681 void xe_device_remove(struct xe_device *xe)
686 xe_device_remove_display(xe);
688 xe_display_fini(xe);
690 xe_heci_gsc_fini(xe);
692 for_each_gt(gt, xe, id)
695 xe_irq_shutdown(xe);
698 void xe_device_shutdown(struct xe_device *xe)
702 void xe_device_wmb(struct xe_device *xe)
704 struct xe_gt *gt = xe_root_mmio_gt(xe);
707 if (IS_DGFX(xe))
711 u32 xe_device_ccs_bytes(struct xe_device *xe, u64 size)
713 return xe_device_has_flat_ccs(xe) ?
714 DIV_ROUND_UP_ULL(size, NUM_BYTES_PER_CCS_BYTE(xe)) : 0;
719 * @xe: xe device instance
728 void xe_device_assert_mem_access(struct xe_device *xe)
730 xe_assert(xe, !xe_pm_runtime_suspended(xe));
733 void xe_device_snapshot_print(struct xe_device *xe, struct drm_printer *p)
738 drm_printf(p, "PCI ID: 0x%04x\n", xe->info.devid);
739 drm_printf(p, "PCI revision: 0x%02x\n", xe->info.revid);
741 for_each_gt(gt, xe, id) {
753 u64 xe_device_canonicalize_addr(struct xe_device *xe, u64 address)
755 return sign_extend64(address, xe->info.va_bits - 1);
758 u64 xe_device_uncanonicalize_addr(struct xe_device *xe, u64 address)
760 return address & GENMASK_ULL(xe->info.va_bits - 1, 0);