Lines Matching refs:guc

42 void intel_guc_notify(struct intel_guc *guc)  in intel_guc_notify()  argument
44 struct intel_gt *gt = guc_to_gt(guc); in intel_guc_notify()
52 intel_uncore_write(gt->uncore, guc->notify_reg, GUC_SEND_TRIGGER); in intel_guc_notify()
55 static inline i915_reg_t guc_send_reg(struct intel_guc *guc, u32 i) in guc_send_reg() argument
57 GEM_BUG_ON(!guc->send_regs.base); in guc_send_reg()
58 GEM_BUG_ON(!guc->send_regs.count); in guc_send_reg()
59 GEM_BUG_ON(i >= guc->send_regs.count); in guc_send_reg()
61 return _MMIO(guc->send_regs.base + 4 * i); in guc_send_reg()
64 void intel_guc_init_send_regs(struct intel_guc *guc) in intel_guc_init_send_regs() argument
66 struct intel_gt *gt = guc_to_gt(guc); in intel_guc_init_send_regs()
70 GEM_BUG_ON(!guc->send_regs.base); in intel_guc_init_send_regs()
71 GEM_BUG_ON(!guc->send_regs.count); in intel_guc_init_send_regs()
73 for (i = 0; i < guc->send_regs.count; i++) { in intel_guc_init_send_regs()
75 guc_send_reg(guc, i), in intel_guc_init_send_regs()
78 guc->send_regs.fw_domains = fw_domains; in intel_guc_init_send_regs()
81 static void gen9_reset_guc_interrupts(struct intel_guc *guc) in gen9_reset_guc_interrupts() argument
83 struct intel_gt *gt = guc_to_gt(guc); in gen9_reset_guc_interrupts()
92 static void gen9_enable_guc_interrupts(struct intel_guc *guc) in gen9_enable_guc_interrupts() argument
94 struct intel_gt *gt = guc_to_gt(guc); in gen9_enable_guc_interrupts()
99 guc_WARN_ON_ONCE(guc, intel_uncore_read(gt->uncore, GEN8_GT_IIR(2)) & in gen9_enable_guc_interrupts()
104 guc->interrupts.enabled = true; in gen9_enable_guc_interrupts()
107 static void gen9_disable_guc_interrupts(struct intel_guc *guc) in gen9_disable_guc_interrupts() argument
109 struct intel_gt *gt = guc_to_gt(guc); in gen9_disable_guc_interrupts()
112 guc->interrupts.enabled = false; in gen9_disable_guc_interrupts()
121 gen9_reset_guc_interrupts(guc); in gen9_disable_guc_interrupts()
132 static void gen11_reset_guc_interrupts(struct intel_guc *guc) in gen11_reset_guc_interrupts() argument
134 struct intel_gt *gt = guc_to_gt(guc); in gen11_reset_guc_interrupts()
141 static void gen11_enable_guc_interrupts(struct intel_guc *guc) in gen11_enable_guc_interrupts() argument
143 struct intel_gt *gt = guc_to_gt(guc); in gen11_enable_guc_interrupts()
149 guc->interrupts.enabled = true; in gen11_enable_guc_interrupts()
152 static void gen11_disable_guc_interrupts(struct intel_guc *guc) in gen11_disable_guc_interrupts() argument
154 struct intel_gt *gt = guc_to_gt(guc); in gen11_disable_guc_interrupts()
156 guc->interrupts.enabled = false; in gen11_disable_guc_interrupts()
159 gen11_reset_guc_interrupts(guc); in gen11_disable_guc_interrupts()
164 struct intel_guc *guc = container_of(w, struct intel_guc, dead_guc_worker); in guc_dead_worker_func() local
165 struct intel_gt *gt = guc_to_gt(guc); in guc_dead_worker_func()
166 unsigned long last = guc->last_dead_guc_jiffies; in guc_dead_worker_func()
173 guc->last_dead_guc_jiffies = jiffies; in guc_dead_worker_func()
177 void intel_guc_init_early(struct intel_guc *guc) in intel_guc_init_early() argument
179 struct intel_gt *gt = guc_to_gt(guc); in intel_guc_init_early()
182 intel_uc_fw_init_early(&guc->fw, INTEL_UC_FW_TYPE_GUC, true); in intel_guc_init_early()
183 intel_guc_ct_init_early(&guc->ct); in intel_guc_init_early()
184 intel_guc_log_init_early(&guc->log); in intel_guc_init_early()
185 intel_guc_submission_init_early(guc); in intel_guc_init_early()
186 intel_guc_slpc_init_early(&guc->slpc); in intel_guc_init_early()
187 intel_guc_rc_init_early(guc); in intel_guc_init_early()
189 INIT_WORK(&guc->dead_guc_worker, guc_dead_worker_func); in intel_guc_init_early()
191 mutex_init(&guc->send_mutex); in intel_guc_init_early()
192 spin_lock_init(&guc->irq_lock); in intel_guc_init_early()
194 guc->interrupts.reset = gen11_reset_guc_interrupts; in intel_guc_init_early()
195 guc->interrupts.enable = gen11_enable_guc_interrupts; in intel_guc_init_early()
196 guc->interrupts.disable = gen11_disable_guc_interrupts; in intel_guc_init_early()
198 guc->notify_reg = MEDIA_GUC_HOST_INTERRUPT; in intel_guc_init_early()
199 guc->send_regs.base = i915_mmio_reg_offset(MEDIA_SOFT_SCRATCH(0)); in intel_guc_init_early()
201 guc->notify_reg = GEN11_GUC_HOST_INTERRUPT; in intel_guc_init_early()
202 guc->send_regs.base = i915_mmio_reg_offset(GEN11_SOFT_SCRATCH(0)); in intel_guc_init_early()
205 guc->send_regs.count = GEN11_SOFT_SCRATCH_COUNT; in intel_guc_init_early()
208 guc->notify_reg = GUC_SEND_INTERRUPT; in intel_guc_init_early()
209 guc->interrupts.reset = gen9_reset_guc_interrupts; in intel_guc_init_early()
210 guc->interrupts.enable = gen9_enable_guc_interrupts; in intel_guc_init_early()
211 guc->interrupts.disable = gen9_disable_guc_interrupts; in intel_guc_init_early()
212 guc->send_regs.base = i915_mmio_reg_offset(SOFT_SCRATCH(0)); in intel_guc_init_early()
213 guc->send_regs.count = GUC_MAX_MMIO_MSG_LEN; in intel_guc_init_early()
217 intel_guc_enable_msg(guc, INTEL_GUC_RECV_MSG_EXCEPTION | in intel_guc_init_early()
221 void intel_guc_init_late(struct intel_guc *guc) in intel_guc_init_late() argument
223 intel_guc_ads_init_late(guc); in intel_guc_init_late()
226 static u32 guc_ctl_debug_flags(struct intel_guc *guc) in guc_ctl_debug_flags() argument
228 u32 level = intel_guc_log_get_level(&guc->log); in guc_ctl_debug_flags()
240 static u32 guc_ctl_feature_flags(struct intel_guc *guc) in guc_ctl_feature_flags() argument
244 if (!intel_guc_submission_is_used(guc)) in guc_ctl_feature_flags()
247 if (intel_guc_slpc_is_used(guc)) in guc_ctl_feature_flags()
253 static u32 guc_ctl_log_params_flags(struct intel_guc *guc) in guc_ctl_log_params_flags() argument
255 struct intel_guc_log *log = &guc->log; in guc_ctl_log_params_flags()
260 offset = intel_guc_ggtt_offset(guc, log->vma) >> PAGE_SHIFT; in guc_ctl_log_params_flags()
274 static u32 guc_ctl_ads_flags(struct intel_guc *guc) in guc_ctl_ads_flags() argument
276 u32 ads = intel_guc_ggtt_offset(guc, guc->ads_vma) >> PAGE_SHIFT; in guc_ctl_ads_flags()
282 static u32 guc_ctl_wa_flags(struct intel_guc *guc) in guc_ctl_wa_flags() argument
284 struct intel_gt *gt = guc_to_gt(guc); in guc_ctl_wa_flags()
327 if (GUC_FIRMWARE_VER(guc) >= MAKE_GUC_VER(70, 7, 0)) in guc_ctl_wa_flags()
333 static u32 guc_ctl_devid(struct intel_guc *guc) in guc_ctl_devid() argument
335 struct drm_i915_private *i915 = guc_to_i915(guc); in guc_ctl_devid()
345 static void guc_init_params(struct intel_guc *guc) in guc_init_params() argument
347 u32 *params = guc->params; in guc_init_params()
350 BUILD_BUG_ON(sizeof(guc->params) != GUC_CTL_MAX_DWORDS * sizeof(u32)); in guc_init_params()
352 params[GUC_CTL_LOG_PARAMS] = guc_ctl_log_params_flags(guc); in guc_init_params()
353 params[GUC_CTL_FEATURE] = guc_ctl_feature_flags(guc); in guc_init_params()
354 params[GUC_CTL_DEBUG] = guc_ctl_debug_flags(guc); in guc_init_params()
355 params[GUC_CTL_ADS] = guc_ctl_ads_flags(guc); in guc_init_params()
356 params[GUC_CTL_WA] = guc_ctl_wa_flags(guc); in guc_init_params()
357 params[GUC_CTL_DEVID] = guc_ctl_devid(guc); in guc_init_params()
360 guc_dbg(guc, "param[%2d] = %#x\n", i, params[i]); in guc_init_params()
368 void intel_guc_write_params(struct intel_guc *guc) in intel_guc_write_params() argument
370 struct intel_uncore *uncore = guc_to_gt(guc)->uncore; in intel_guc_write_params()
383 intel_uncore_write(uncore, SOFT_SCRATCH(1 + i), guc->params[i]); in intel_guc_write_params()
388 void intel_guc_dump_time_info(struct intel_guc *guc, struct drm_printer *p) in intel_guc_dump_time_info() argument
390 struct intel_gt *gt = guc_to_gt(guc); in intel_guc_dump_time_info()
405 int intel_guc_init(struct intel_guc *guc) in intel_guc_init() argument
409 ret = intel_uc_fw_init(&guc->fw); in intel_guc_init()
413 ret = intel_guc_log_create(&guc->log); in intel_guc_init()
417 ret = intel_guc_capture_init(guc); in intel_guc_init()
421 ret = intel_guc_ads_create(guc); in intel_guc_init()
425 GEM_BUG_ON(!guc->ads_vma); in intel_guc_init()
427 ret = intel_guc_ct_init(&guc->ct); in intel_guc_init()
431 if (intel_guc_submission_is_used(guc)) { in intel_guc_init()
436 ret = intel_guc_submission_init(guc); in intel_guc_init()
441 if (intel_guc_slpc_is_used(guc)) { in intel_guc_init()
442 ret = intel_guc_slpc_init(&guc->slpc); in intel_guc_init()
448 guc_init_params(guc); in intel_guc_init()
450 intel_uc_fw_change_status(&guc->fw, INTEL_UC_FIRMWARE_LOADABLE); in intel_guc_init()
455 intel_guc_submission_fini(guc); in intel_guc_init()
457 intel_guc_ct_fini(&guc->ct); in intel_guc_init()
459 intel_guc_ads_destroy(guc); in intel_guc_init()
461 intel_guc_capture_destroy(guc); in intel_guc_init()
463 intel_guc_log_destroy(&guc->log); in intel_guc_init()
465 intel_uc_fw_fini(&guc->fw); in intel_guc_init()
467 intel_uc_fw_change_status(&guc->fw, INTEL_UC_FIRMWARE_INIT_FAIL); in intel_guc_init()
468 guc_probe_error(guc, "failed with %pe\n", ERR_PTR(ret)); in intel_guc_init()
472 void intel_guc_fini(struct intel_guc *guc) in intel_guc_fini() argument
474 if (!intel_uc_fw_is_loadable(&guc->fw)) in intel_guc_fini()
477 flush_work(&guc->dead_guc_worker); in intel_guc_fini()
479 if (intel_guc_slpc_is_used(guc)) in intel_guc_fini()
480 intel_guc_slpc_fini(&guc->slpc); in intel_guc_fini()
482 if (intel_guc_submission_is_used(guc)) in intel_guc_fini()
483 intel_guc_submission_fini(guc); in intel_guc_fini()
485 intel_guc_ct_fini(&guc->ct); in intel_guc_fini()
487 intel_guc_ads_destroy(guc); in intel_guc_fini()
488 intel_guc_capture_destroy(guc); in intel_guc_fini()
489 intel_guc_log_destroy(&guc->log); in intel_guc_fini()
490 intel_uc_fw_fini(&guc->fw); in intel_guc_fini()
496 int intel_guc_send_mmio(struct intel_guc *guc, const u32 *request, u32 len, in intel_guc_send_mmio() argument
499 struct intel_uncore *uncore = guc_to_gt(guc)->uncore; in intel_guc_send_mmio()
505 GEM_BUG_ON(len > guc->send_regs.count); in intel_guc_send_mmio()
510 mutex_lock(&guc->send_mutex); in intel_guc_send_mmio()
511 intel_uncore_forcewake_get(uncore, guc->send_regs.fw_domains); in intel_guc_send_mmio()
515 intel_uncore_write(uncore, guc_send_reg(guc, i), request[i]); in intel_guc_send_mmio()
517 intel_uncore_posting_read(uncore, guc_send_reg(guc, i - 1)); in intel_guc_send_mmio()
519 intel_guc_notify(guc); in intel_guc_send_mmio()
526 guc_send_reg(guc, 0), in intel_guc_send_mmio()
533 guc_err(guc, "mmio request %#x: no reply %x\n", in intel_guc_send_mmio()
539 #define done ({ header = intel_uncore_read(uncore, guc_send_reg(guc, 0)); \ in intel_guc_send_mmio()
555 guc_dbg(guc, "mmio request %#x: retrying, reason %u\n", in intel_guc_send_mmio()
564 guc_err(guc, "mmio request %#x: failure %x/%u\n", in intel_guc_send_mmio()
572 guc_err(guc, "mmio request %#x: unexpected reply %#x\n", in intel_guc_send_mmio()
579 int count = min(response_buf_size, guc->send_regs.count); in intel_guc_send_mmio()
587 guc_send_reg(guc, i)); in intel_guc_send_mmio()
597 intel_uncore_forcewake_put(uncore, guc->send_regs.fw_domains); in intel_guc_send_mmio()
598 mutex_unlock(&guc->send_mutex); in intel_guc_send_mmio()
603 int intel_guc_crash_process_msg(struct intel_guc *guc, u32 action) in intel_guc_crash_process_msg() argument
606 guc_err(guc, "Crash dump notification\n"); in intel_guc_crash_process_msg()
608 guc_err(guc, "Exception notification\n"); in intel_guc_crash_process_msg()
610 guc_err(guc, "Unknown crash notification: 0x%04X\n", action); in intel_guc_crash_process_msg()
612 queue_work(system_unbound_wq, &guc->dead_guc_worker); in intel_guc_crash_process_msg()
617 int intel_guc_to_host_process_recv_msg(struct intel_guc *guc, in intel_guc_to_host_process_recv_msg() argument
626 msg = payload[0] & guc->msg_enabled_mask; in intel_guc_to_host_process_recv_msg()
629 guc_err(guc, "Received early crash dump notification!\n"); in intel_guc_to_host_process_recv_msg()
631 guc_err(guc, "Received early exception notification!\n"); in intel_guc_to_host_process_recv_msg()
634 queue_work(system_unbound_wq, &guc->dead_guc_worker); in intel_guc_to_host_process_recv_msg()
650 int intel_guc_auth_huc(struct intel_guc *guc, u32 rsa_offset) in intel_guc_auth_huc() argument
657 return intel_guc_send(guc, action, ARRAY_SIZE(action)); in intel_guc_auth_huc()
664 int intel_guc_suspend(struct intel_guc *guc) in intel_guc_suspend() argument
671 if (!intel_guc_is_ready(guc)) in intel_guc_suspend()
674 if (intel_guc_submission_is_used(guc)) { in intel_guc_suspend()
675 flush_work(&guc->dead_guc_worker); in intel_guc_suspend()
688 ret = intel_guc_send_mmio(guc, action, ARRAY_SIZE(action), NULL, 0); in intel_guc_suspend()
690 guc_err(guc, "suspend: RESET_CLIENT action failed with %pe\n", in intel_guc_suspend()
695 intel_guc_sanitize(guc); in intel_guc_suspend()
704 int intel_guc_resume(struct intel_guc *guc) in intel_guc_resume() argument
762 struct i915_vma *intel_guc_allocate_vma(struct intel_guc *guc, u32 size) in intel_guc_allocate_vma() argument
764 struct intel_gt *gt = guc_to_gt(guc); in intel_guc_allocate_vma()
819 int intel_guc_allocate_and_map_vma(struct intel_guc *guc, u32 size, in intel_guc_allocate_and_map_vma() argument
825 vma = intel_guc_allocate_vma(guc, size); in intel_guc_allocate_and_map_vma()
830 intel_gt_coherent_map_type(guc_to_gt(guc), in intel_guc_allocate_and_map_vma()
843 static int __guc_action_self_cfg(struct intel_guc *guc, u16 key, u16 len, u64 value) in __guc_action_self_cfg() argument
860 ret = intel_guc_send_mmio(guc, request, ARRAY_SIZE(request), NULL, 0); in __guc_action_self_cfg()
872 static int __guc_self_cfg(struct intel_guc *guc, u16 key, u16 len, u64 value) in __guc_self_cfg() argument
874 int err = __guc_action_self_cfg(guc, key, len, value); in __guc_self_cfg()
877 guc_probe_error(guc, "Unsuccessful self-config (%pe) key %#hx value %#llx\n", in __guc_self_cfg()
882 int intel_guc_self_cfg32(struct intel_guc *guc, u16 key, u32 value) in intel_guc_self_cfg32() argument
884 return __guc_self_cfg(guc, key, 1, value); in intel_guc_self_cfg32()
887 int intel_guc_self_cfg64(struct intel_guc *guc, u16 key, u64 value) in intel_guc_self_cfg64() argument
889 return __guc_self_cfg(guc, key, 2, value); in intel_guc_self_cfg64()
899 void intel_guc_load_status(struct intel_guc *guc, struct drm_printer *p) in intel_guc_load_status() argument
901 struct intel_gt *gt = guc_to_gt(guc); in intel_guc_load_status()
905 if (!intel_guc_is_supported(guc)) { in intel_guc_load_status()
910 if (!intel_guc_is_wanted(guc)) { in intel_guc_load_status()
915 intel_uc_fw_dump(&guc->fw, p); in intel_guc_load_status()
936 void intel_guc_write_barrier(struct intel_guc *guc) in intel_guc_write_barrier() argument
938 struct intel_gt *gt = guc_to_gt(guc); in intel_guc_write_barrier()
940 if (i915_gem_object_is_lmem(guc->ct.vma->obj)) { in intel_guc_write_barrier()
945 GEM_BUG_ON(guc->send_regs.fw_domains); in intel_guc_write_barrier()