13ea58029SMichal Wajdeczko // SPDX-License-Identifier: MIT
20f261b24SDaniele Ceraolo Spurio /*
33ea58029SMichal Wajdeczko * Copyright © 2014-2019 Intel Corporation
40f261b24SDaniele Ceraolo Spurio */
50f261b24SDaniele Ceraolo Spurio
67acbbc7cSDaniele Ceraolo Spurio #include "gem/i915_gem_lmem.h"
784b1ca2fSDaniele Ceraolo Spurio #include "gt/intel_gt.h"
89fb94522SAndi Shyti #include "gt/intel_gt_irq.h"
99fb94522SAndi Shyti #include "gt/intel_gt_pm_irq.h"
100d6419e9SMatt Roper #include "gt/intel_gt_regs.h"
110f261b24SDaniele Ceraolo Spurio #include "intel_guc.h"
120f261b24SDaniele Ceraolo Spurio #include "intel_guc_ads.h"
1324492514SAlan Previn #include "intel_guc_capture.h"
14ecb89c2cSMichal Wajdeczko #include "intel_guc_print.h"
1524492514SAlan Previn #include "intel_guc_slpc.h"
160f261b24SDaniele Ceraolo Spurio #include "intel_guc_submission.h"
170f261b24SDaniele Ceraolo Spurio #include "i915_drv.h"
1880dfdeb7SJani Nikula #include "i915_irq.h"
19476f62b8SJani Nikula #include "i915_reg.h"
200f261b24SDaniele Ceraolo Spurio
21218151e9SDaniele Ceraolo Spurio /**
22218151e9SDaniele Ceraolo Spurio * DOC: GuC
23218151e9SDaniele Ceraolo Spurio *
24218151e9SDaniele Ceraolo Spurio * The GuC is a microcontroller inside the GT HW, introduced in gen9. The GuC is
25218151e9SDaniele Ceraolo Spurio * designed to offload some of the functionality usually performed by the host
26218151e9SDaniele Ceraolo Spurio * driver; currently the main operations it can take care of are:
27218151e9SDaniele Ceraolo Spurio *
28218151e9SDaniele Ceraolo Spurio * - Authentication of the HuC, which is required to fully enable HuC usage.
29218151e9SDaniele Ceraolo Spurio * - Low latency graphics context scheduling (a.k.a. GuC submission).
30218151e9SDaniele Ceraolo Spurio * - GT Power management.
31218151e9SDaniele Ceraolo Spurio *
32218151e9SDaniele Ceraolo Spurio * The enable_guc module parameter can be used to select which of those
33218151e9SDaniele Ceraolo Spurio * operations to enable within GuC. Note that not all the operations are
34218151e9SDaniele Ceraolo Spurio * supported on all gen9+ platforms.
35218151e9SDaniele Ceraolo Spurio *
36218151e9SDaniele Ceraolo Spurio * Enabling the GuC is not mandatory and therefore the firmware is only loaded
37218151e9SDaniele Ceraolo Spurio * if at least one of the operations is selected. However, not loading the GuC
38218151e9SDaniele Ceraolo Spurio * might result in the loss of some features that do require the GuC (currently
39218151e9SDaniele Ceraolo Spurio * just the HuC, but more are expected to land in the future).
40218151e9SDaniele Ceraolo Spurio */
41218151e9SDaniele Ceraolo Spurio
intel_guc_notify(struct intel_guc * guc)42f20c6b27SDaniele Ceraolo Spurio void intel_guc_notify(struct intel_guc *guc)
430f261b24SDaniele Ceraolo Spurio {
4484b1ca2fSDaniele Ceraolo Spurio struct intel_gt *gt = guc_to_gt(guc);
450f261b24SDaniele Ceraolo Spurio
46f20c6b27SDaniele Ceraolo Spurio /*
47f20c6b27SDaniele Ceraolo Spurio * On Gen11+, the value written to the register is passes as a payload
48f20c6b27SDaniele Ceraolo Spurio * to the FW. However, the FW currently treats all values the same way
49f20c6b27SDaniele Ceraolo Spurio * (H2G interrupt), so we can just write the value that the HW expects
50f20c6b27SDaniele Ceraolo Spurio * on older gens.
51f20c6b27SDaniele Ceraolo Spurio */
52f20c6b27SDaniele Ceraolo Spurio intel_uncore_write(gt->uncore, guc->notify_reg, GUC_SEND_TRIGGER);
530f261b24SDaniele Ceraolo Spurio }
540f261b24SDaniele Ceraolo Spurio
guc_send_reg(struct intel_guc * guc,u32 i)550f261b24SDaniele Ceraolo Spurio static inline i915_reg_t guc_send_reg(struct intel_guc *guc, u32 i)
560f261b24SDaniele Ceraolo Spurio {
570f261b24SDaniele Ceraolo Spurio GEM_BUG_ON(!guc->send_regs.base);
580f261b24SDaniele Ceraolo Spurio GEM_BUG_ON(!guc->send_regs.count);
590f261b24SDaniele Ceraolo Spurio GEM_BUG_ON(i >= guc->send_regs.count);
600f261b24SDaniele Ceraolo Spurio
610f261b24SDaniele Ceraolo Spurio return _MMIO(guc->send_regs.base + 4 * i);
620f261b24SDaniele Ceraolo Spurio }
630f261b24SDaniele Ceraolo Spurio
intel_guc_init_send_regs(struct intel_guc * guc)640f261b24SDaniele Ceraolo Spurio void intel_guc_init_send_regs(struct intel_guc *guc)
650f261b24SDaniele Ceraolo Spurio {
6684b1ca2fSDaniele Ceraolo Spurio struct intel_gt *gt = guc_to_gt(guc);
670f261b24SDaniele Ceraolo Spurio enum forcewake_domains fw_domains = 0;
680f261b24SDaniele Ceraolo Spurio unsigned int i;
690f261b24SDaniele Ceraolo Spurio
70e09be87aSMichal Wajdeczko GEM_BUG_ON(!guc->send_regs.base);
71e09be87aSMichal Wajdeczko GEM_BUG_ON(!guc->send_regs.count);
720f261b24SDaniele Ceraolo Spurio
730f261b24SDaniele Ceraolo Spurio for (i = 0; i < guc->send_regs.count; i++) {
7484b1ca2fSDaniele Ceraolo Spurio fw_domains |= intel_uncore_forcewake_for_reg(gt->uncore,
750f261b24SDaniele Ceraolo Spurio guc_send_reg(guc, i),
760f261b24SDaniele Ceraolo Spurio FW_REG_READ | FW_REG_WRITE);
770f261b24SDaniele Ceraolo Spurio }
780f261b24SDaniele Ceraolo Spurio guc->send_regs.fw_domains = fw_domains;
790f261b24SDaniele Ceraolo Spurio }
800f261b24SDaniele Ceraolo Spurio
gen9_reset_guc_interrupts(struct intel_guc * guc)819fb94522SAndi Shyti static void gen9_reset_guc_interrupts(struct intel_guc *guc)
829fb94522SAndi Shyti {
839fb94522SAndi Shyti struct intel_gt *gt = guc_to_gt(guc);
849fb94522SAndi Shyti
859fb94522SAndi Shyti assert_rpm_wakelock_held(>->i915->runtime_pm);
869fb94522SAndi Shyti
8703d2c54dSMatt Roper spin_lock_irq(gt->irq_lock);
889fb94522SAndi Shyti gen6_gt_pm_reset_iir(gt, gt->pm_guc_events);
8903d2c54dSMatt Roper spin_unlock_irq(gt->irq_lock);
909fb94522SAndi Shyti }
919fb94522SAndi Shyti
gen9_enable_guc_interrupts(struct intel_guc * guc)929fb94522SAndi Shyti static void gen9_enable_guc_interrupts(struct intel_guc *guc)
939fb94522SAndi Shyti {
949fb94522SAndi Shyti struct intel_gt *gt = guc_to_gt(guc);
959fb94522SAndi Shyti
969fb94522SAndi Shyti assert_rpm_wakelock_held(>->i915->runtime_pm);
979fb94522SAndi Shyti
9803d2c54dSMatt Roper spin_lock_irq(gt->irq_lock);
99ecb89c2cSMichal Wajdeczko guc_WARN_ON_ONCE(guc, intel_uncore_read(gt->uncore, GEN8_GT_IIR(2)) &
1009fb94522SAndi Shyti gt->pm_guc_events);
1019fb94522SAndi Shyti gen6_gt_pm_enable_irq(gt, gt->pm_guc_events);
10203d2c54dSMatt Roper spin_unlock_irq(gt->irq_lock);
103a187f13dSDaniele Ceraolo Spurio
104a187f13dSDaniele Ceraolo Spurio guc->interrupts.enabled = true;
1059fb94522SAndi Shyti }
1069fb94522SAndi Shyti
gen9_disable_guc_interrupts(struct intel_guc * guc)1079fb94522SAndi Shyti static void gen9_disable_guc_interrupts(struct intel_guc *guc)
1089fb94522SAndi Shyti {
1099fb94522SAndi Shyti struct intel_gt *gt = guc_to_gt(guc);
1109fb94522SAndi Shyti
1119fb94522SAndi Shyti assert_rpm_wakelock_held(>->i915->runtime_pm);
112a187f13dSDaniele Ceraolo Spurio guc->interrupts.enabled = false;
1139fb94522SAndi Shyti
11403d2c54dSMatt Roper spin_lock_irq(gt->irq_lock);
1159fb94522SAndi Shyti
1169fb94522SAndi Shyti gen6_gt_pm_disable_irq(gt, gt->pm_guc_events);
1179fb94522SAndi Shyti
11803d2c54dSMatt Roper spin_unlock_irq(gt->irq_lock);
1199fb94522SAndi Shyti intel_synchronize_irq(gt->i915);
1209fb94522SAndi Shyti
1219fb94522SAndi Shyti gen9_reset_guc_interrupts(guc);
1229fb94522SAndi Shyti }
1239fb94522SAndi Shyti
__gen11_reset_guc_interrupts(struct intel_gt * gt)124a187f13dSDaniele Ceraolo Spurio static bool __gen11_reset_guc_interrupts(struct intel_gt *gt)
125a187f13dSDaniele Ceraolo Spurio {
126a187f13dSDaniele Ceraolo Spurio u32 irq = gt->type == GT_MEDIA ? MTL_MGUC : GEN11_GUC;
127a187f13dSDaniele Ceraolo Spurio
128a187f13dSDaniele Ceraolo Spurio lockdep_assert_held(gt->irq_lock);
129a187f13dSDaniele Ceraolo Spurio return gen11_gt_reset_one_iir(gt, 0, irq);
130a187f13dSDaniele Ceraolo Spurio }
131a187f13dSDaniele Ceraolo Spurio
gen11_reset_guc_interrupts(struct intel_guc * guc)1329fb94522SAndi Shyti static void gen11_reset_guc_interrupts(struct intel_guc *guc)
1339fb94522SAndi Shyti {
1349fb94522SAndi Shyti struct intel_gt *gt = guc_to_gt(guc);
1359fb94522SAndi Shyti
13603d2c54dSMatt Roper spin_lock_irq(gt->irq_lock);
137a187f13dSDaniele Ceraolo Spurio __gen11_reset_guc_interrupts(gt);
13803d2c54dSMatt Roper spin_unlock_irq(gt->irq_lock);
1399fb94522SAndi Shyti }
1409fb94522SAndi Shyti
gen11_enable_guc_interrupts(struct intel_guc * guc)1419fb94522SAndi Shyti static void gen11_enable_guc_interrupts(struct intel_guc *guc)
1429fb94522SAndi Shyti {
1439fb94522SAndi Shyti struct intel_gt *gt = guc_to_gt(guc);
1449fb94522SAndi Shyti
14503d2c54dSMatt Roper spin_lock_irq(gt->irq_lock);
146a187f13dSDaniele Ceraolo Spurio __gen11_reset_guc_interrupts(gt);
14703d2c54dSMatt Roper spin_unlock_irq(gt->irq_lock);
148a187f13dSDaniele Ceraolo Spurio
149a187f13dSDaniele Ceraolo Spurio guc->interrupts.enabled = true;
1509fb94522SAndi Shyti }
1519fb94522SAndi Shyti
gen11_disable_guc_interrupts(struct intel_guc * guc)1529fb94522SAndi Shyti static void gen11_disable_guc_interrupts(struct intel_guc *guc)
1539fb94522SAndi Shyti {
1549fb94522SAndi Shyti struct intel_gt *gt = guc_to_gt(guc);
1559fb94522SAndi Shyti
156a187f13dSDaniele Ceraolo Spurio guc->interrupts.enabled = false;
1579fb94522SAndi Shyti intel_synchronize_irq(gt->i915);
1589fb94522SAndi Shyti
1599fb94522SAndi Shyti gen11_reset_guc_interrupts(guc);
1609fb94522SAndi Shyti }
1619fb94522SAndi Shyti
intel_guc_init_early(struct intel_guc * guc)1620f261b24SDaniele Ceraolo Spurio void intel_guc_init_early(struct intel_guc *guc)
1630f261b24SDaniele Ceraolo Spurio {
164b910f716SDaniele Ceraolo Spurio struct intel_gt *gt = guc_to_gt(guc);
165b910f716SDaniele Ceraolo Spurio struct drm_i915_private *i915 = gt->i915;
1660f261b24SDaniele Ceraolo Spurio
1673532e75dSDaniele Ceraolo Spurio intel_uc_fw_init_early(&guc->fw, INTEL_UC_FW_TYPE_GUC, true);
1680f261b24SDaniele Ceraolo Spurio intel_guc_ct_init_early(&guc->ct);
1690f261b24SDaniele Ceraolo Spurio intel_guc_log_init_early(&guc->log);
170724df646SMichal Wajdeczko intel_guc_submission_init_early(guc);
171dff0fc49SVinay Belgaumkar intel_guc_slpc_init_early(&guc->slpc);
172216d56c5SVinay Belgaumkar intel_guc_rc_init_early(guc);
1730f261b24SDaniele Ceraolo Spurio
1740f261b24SDaniele Ceraolo Spurio mutex_init(&guc->send_mutex);
1750f261b24SDaniele Ceraolo Spurio spin_lock_init(&guc->irq_lock);
176c816723bSLucas De Marchi if (GRAPHICS_VER(i915) >= 11) {
1770f261b24SDaniele Ceraolo Spurio guc->interrupts.reset = gen11_reset_guc_interrupts;
1780f261b24SDaniele Ceraolo Spurio guc->interrupts.enable = gen11_enable_guc_interrupts;
1790f261b24SDaniele Ceraolo Spurio guc->interrupts.disable = gen11_disable_guc_interrupts;
180b910f716SDaniele Ceraolo Spurio if (gt->type == GT_MEDIA) {
181b910f716SDaniele Ceraolo Spurio guc->notify_reg = MEDIA_GUC_HOST_INTERRUPT;
182b910f716SDaniele Ceraolo Spurio guc->send_regs.base = i915_mmio_reg_offset(MEDIA_SOFT_SCRATCH(0));
183b910f716SDaniele Ceraolo Spurio } else {
184b910f716SDaniele Ceraolo Spurio guc->notify_reg = GEN11_GUC_HOST_INTERRUPT;
185b910f716SDaniele Ceraolo Spurio guc->send_regs.base = i915_mmio_reg_offset(GEN11_SOFT_SCRATCH(0));
186b910f716SDaniele Ceraolo Spurio }
187b910f716SDaniele Ceraolo Spurio
188e09be87aSMichal Wajdeczko guc->send_regs.count = GEN11_SOFT_SCRATCH_COUNT;
189e09be87aSMichal Wajdeczko
1900f261b24SDaniele Ceraolo Spurio } else {
191f20c6b27SDaniele Ceraolo Spurio guc->notify_reg = GUC_SEND_INTERRUPT;
1920f261b24SDaniele Ceraolo Spurio guc->interrupts.reset = gen9_reset_guc_interrupts;
1930f261b24SDaniele Ceraolo Spurio guc->interrupts.enable = gen9_enable_guc_interrupts;
1940f261b24SDaniele Ceraolo Spurio guc->interrupts.disable = gen9_disable_guc_interrupts;
195e09be87aSMichal Wajdeczko guc->send_regs.base = i915_mmio_reg_offset(SOFT_SCRATCH(0));
196e09be87aSMichal Wajdeczko guc->send_regs.count = GUC_MAX_MMIO_MSG_LEN;
197e09be87aSMichal Wajdeczko BUILD_BUG_ON(GUC_MAX_MMIO_MSG_LEN > SOFT_SCRATCH_COUNT);
1980f261b24SDaniele Ceraolo Spurio }
19977b6f79dSJohn Harrison
20077b6f79dSJohn Harrison intel_guc_enable_msg(guc, INTEL_GUC_RECV_MSG_EXCEPTION |
20177b6f79dSJohn Harrison INTEL_GUC_RECV_MSG_CRASH_DUMP_POSTED);
2020f261b24SDaniele Ceraolo Spurio }
2030f261b24SDaniele Ceraolo Spurio
intel_guc_init_late(struct intel_guc * guc)204481d458cSJohn Harrison void intel_guc_init_late(struct intel_guc *guc)
205481d458cSJohn Harrison {
206481d458cSJohn Harrison intel_guc_ads_init_late(guc);
207481d458cSJohn Harrison }
208481d458cSJohn Harrison
guc_ctl_debug_flags(struct intel_guc * guc)2090f261b24SDaniele Ceraolo Spurio static u32 guc_ctl_debug_flags(struct intel_guc *guc)
2100f261b24SDaniele Ceraolo Spurio {
2110f261b24SDaniele Ceraolo Spurio u32 level = intel_guc_log_get_level(&guc->log);
2120f261b24SDaniele Ceraolo Spurio u32 flags = 0;
2130f261b24SDaniele Ceraolo Spurio
2140f261b24SDaniele Ceraolo Spurio if (!GUC_LOG_LEVEL_IS_VERBOSE(level))
2150f261b24SDaniele Ceraolo Spurio flags |= GUC_LOG_DISABLED;
2160f261b24SDaniele Ceraolo Spurio else
2170f261b24SDaniele Ceraolo Spurio flags |= GUC_LOG_LEVEL_TO_VERBOSITY(level) <<
2180f261b24SDaniele Ceraolo Spurio GUC_LOG_VERBOSITY_SHIFT;
2190f261b24SDaniele Ceraolo Spurio
2200f261b24SDaniele Ceraolo Spurio return flags;
2210f261b24SDaniele Ceraolo Spurio }
2220f261b24SDaniele Ceraolo Spurio
guc_ctl_feature_flags(struct intel_guc * guc)2230f261b24SDaniele Ceraolo Spurio static u32 guc_ctl_feature_flags(struct intel_guc *guc)
2240f261b24SDaniele Ceraolo Spurio {
2250f261b24SDaniele Ceraolo Spurio u32 flags = 0;
2260f261b24SDaniele Ceraolo Spurio
227202c98e7SDaniele Ceraolo Spurio if (!intel_guc_submission_is_used(guc))
2280f261b24SDaniele Ceraolo Spurio flags |= GUC_CTL_DISABLE_SCHEDULER;
2290f261b24SDaniele Ceraolo Spurio
2307695d08fSVinay Belgaumkar if (intel_guc_slpc_is_used(guc))
2317695d08fSVinay Belgaumkar flags |= GUC_CTL_ENABLE_SLPC;
2327695d08fSVinay Belgaumkar
2330f261b24SDaniele Ceraolo Spurio return flags;
2340f261b24SDaniele Ceraolo Spurio }
2350f261b24SDaniele Ceraolo Spurio
guc_ctl_log_params_flags(struct intel_guc * guc)2360f261b24SDaniele Ceraolo Spurio static u32 guc_ctl_log_params_flags(struct intel_guc *guc)
2370f261b24SDaniele Ceraolo Spurio {
2388ad0152aSJohn Harrison struct intel_guc_log *log = &guc->log;
2398ad0152aSJohn Harrison u32 offset, flags;
2400f261b24SDaniele Ceraolo Spurio
2418ad0152aSJohn Harrison GEM_BUG_ON(!log->sizes_initialised);
24277b6f79dSJohn Harrison
2438ad0152aSJohn Harrison offset = intel_guc_ggtt_offset(guc, log->vma) >> PAGE_SHIFT;
2440f261b24SDaniele Ceraolo Spurio
2450f261b24SDaniele Ceraolo Spurio flags = GUC_LOG_VALID |
2460f261b24SDaniele Ceraolo Spurio GUC_LOG_NOTIFY_ON_HALF_FULL |
2478ad0152aSJohn Harrison log->sizes[GUC_LOG_SECTIONS_DEBUG].flag |
2488ad0152aSJohn Harrison log->sizes[GUC_LOG_SECTIONS_CAPTURE].flag |
2498ad0152aSJohn Harrison (log->sizes[GUC_LOG_SECTIONS_CRASH].count << GUC_LOG_CRASH_SHIFT) |
2508ad0152aSJohn Harrison (log->sizes[GUC_LOG_SECTIONS_DEBUG].count << GUC_LOG_DEBUG_SHIFT) |
2518ad0152aSJohn Harrison (log->sizes[GUC_LOG_SECTIONS_CAPTURE].count << GUC_LOG_CAPTURE_SHIFT) |
2520f261b24SDaniele Ceraolo Spurio (offset << GUC_LOG_BUF_ADDR_SHIFT);
2530f261b24SDaniele Ceraolo Spurio
2540f261b24SDaniele Ceraolo Spurio return flags;
2550f261b24SDaniele Ceraolo Spurio }
2560f261b24SDaniele Ceraolo Spurio
guc_ctl_ads_flags(struct intel_guc * guc)2570f261b24SDaniele Ceraolo Spurio static u32 guc_ctl_ads_flags(struct intel_guc *guc)
2580f261b24SDaniele Ceraolo Spurio {
2590f261b24SDaniele Ceraolo Spurio u32 ads = intel_guc_ggtt_offset(guc, guc->ads_vma) >> PAGE_SHIFT;
2600f261b24SDaniele Ceraolo Spurio u32 flags = ads << GUC_ADS_ADDR_SHIFT;
2610f261b24SDaniele Ceraolo Spurio
2620f261b24SDaniele Ceraolo Spurio return flags;
2630f261b24SDaniele Ceraolo Spurio }
2640f261b24SDaniele Ceraolo Spurio
guc_ctl_wa_flags(struct intel_guc * guc)26577b6f79dSJohn Harrison static u32 guc_ctl_wa_flags(struct intel_guc *guc)
26677b6f79dSJohn Harrison {
26777b6f79dSJohn Harrison struct intel_gt *gt = guc_to_gt(guc);
26877b6f79dSJohn Harrison u32 flags = 0;
26977b6f79dSJohn Harrison
27077b6f79dSJohn Harrison /* Wa_22012773006:gen11,gen12 < XeHP */
27177b6f79dSJohn Harrison if (GRAPHICS_VER(gt->i915) >= 11 &&
27277b6f79dSJohn Harrison GRAPHICS_VER_FULL(gt->i915) < IP_VER(12, 50))
27377b6f79dSJohn Harrison flags |= GUC_WA_POLLCS;
27477b6f79dSJohn Harrison
27541bb543fSMatt Roper /* Wa_14014475959 */
276*b3749611SMatt Roper if (IS_GFX_GT_IP_STEP(gt, IP_VER(12, 70), STEP_A0, STEP_B0) ||
27741bb543fSMatt Roper IS_DG2(gt->i915))
278717f9badSMatthew Brost flags |= GUC_WA_HOLD_CCS_SWITCHOUT;
279717f9badSMatthew Brost
280c6b41c4dSJohn Harrison /*
2810a9901fdSMatt Roper * Wa_14012197797
2820a9901fdSMatt Roper * Wa_22011391025
283c6b41c4dSJohn Harrison *
284c6b41c4dSJohn Harrison * The same WA bit is used for both and 22011391025 is applicable to
285c6b41c4dSJohn Harrison * all DG2.
286c6b41c4dSJohn Harrison */
287c6b41c4dSJohn Harrison if (IS_DG2(gt->i915))
288c6b41c4dSJohn Harrison flags |= GUC_WA_DUAL_QUEUE;
289c6b41c4dSJohn Harrison
2900667429cSUmesh Nerlige Ramappa /* Wa_22011802037: graphics version 11/12 */
29167f7fba8SMatt Roper if (intel_engine_reset_needs_wa_22011802037(gt))
292dac38381SUmesh Nerlige Ramappa flags |= GUC_WA_PRE_PARSER;
293dac38381SUmesh Nerlige Ramappa
294307f722bSJohn Harrison /*
2950a9901fdSMatt Roper * Wa_22012727170
2960a9901fdSMatt Roper * Wa_22012727685
297307f722bSJohn Harrison */
2980a9901fdSMatt Roper if (IS_DG2_G11(gt->i915))
299307f722bSJohn Harrison flags |= GUC_WA_CONTEXT_ISOLATION;
300307f722bSJohn Harrison
301c5cb0002SMatt Roper /* Wa_16015675438 */
302c5cb0002SMatt Roper if (!RCS_MASK(gt))
303c5cb0002SMatt Roper flags |= GUC_WA_RCS_REGS_IN_CCS_REGS_LIST;
304c5cb0002SMatt Roper
30577b6f79dSJohn Harrison return flags;
30677b6f79dSJohn Harrison }
30777b6f79dSJohn Harrison
guc_ctl_devid(struct intel_guc * guc)30877b6f79dSJohn Harrison static u32 guc_ctl_devid(struct intel_guc *guc)
30977b6f79dSJohn Harrison {
31077b6f79dSJohn Harrison struct drm_i915_private *i915 = guc_to_gt(guc)->i915;
31177b6f79dSJohn Harrison
31277b6f79dSJohn Harrison return (INTEL_DEVID(i915) << 16) | INTEL_REVID(i915);
31377b6f79dSJohn Harrison }
31477b6f79dSJohn Harrison
3150f261b24SDaniele Ceraolo Spurio /*
3160f261b24SDaniele Ceraolo Spurio * Initialise the GuC parameter block before starting the firmware
3170f261b24SDaniele Ceraolo Spurio * transfer. These parameters are read by the firmware on startup
3180f261b24SDaniele Ceraolo Spurio * and cannot be changed thereafter.
3190f261b24SDaniele Ceraolo Spurio */
guc_init_params(struct intel_guc * guc)3202bf8fb39SDaniele Ceraolo Spurio static void guc_init_params(struct intel_guc *guc)
3210f261b24SDaniele Ceraolo Spurio {
3222bf8fb39SDaniele Ceraolo Spurio u32 *params = guc->params;
3230f261b24SDaniele Ceraolo Spurio int i;
3240f261b24SDaniele Ceraolo Spurio
3252bf8fb39SDaniele Ceraolo Spurio BUILD_BUG_ON(sizeof(guc->params) != GUC_CTL_MAX_DWORDS * sizeof(u32));
3260f261b24SDaniele Ceraolo Spurio
3270f261b24SDaniele Ceraolo Spurio params[GUC_CTL_LOG_PARAMS] = guc_ctl_log_params_flags(guc);
3280f261b24SDaniele Ceraolo Spurio params[GUC_CTL_FEATURE] = guc_ctl_feature_flags(guc);
3290f261b24SDaniele Ceraolo Spurio params[GUC_CTL_DEBUG] = guc_ctl_debug_flags(guc);
3300f261b24SDaniele Ceraolo Spurio params[GUC_CTL_ADS] = guc_ctl_ads_flags(guc);
33177b6f79dSJohn Harrison params[GUC_CTL_WA] = guc_ctl_wa_flags(guc);
33277b6f79dSJohn Harrison params[GUC_CTL_DEVID] = guc_ctl_devid(guc);
3330f261b24SDaniele Ceraolo Spurio
3340f261b24SDaniele Ceraolo Spurio for (i = 0; i < GUC_CTL_MAX_DWORDS; i++)
335ecb89c2cSMichal Wajdeczko guc_dbg(guc, "param[%2d] = %#x\n", i, params[i]);
3362bf8fb39SDaniele Ceraolo Spurio }
3372bf8fb39SDaniele Ceraolo Spurio
3382bf8fb39SDaniele Ceraolo Spurio /*
3392bf8fb39SDaniele Ceraolo Spurio * Initialise the GuC parameter block before starting the firmware
3402bf8fb39SDaniele Ceraolo Spurio * transfer. These parameters are read by the firmware on startup
3412bf8fb39SDaniele Ceraolo Spurio * and cannot be changed thereafter.
3422bf8fb39SDaniele Ceraolo Spurio */
intel_guc_write_params(struct intel_guc * guc)3432bf8fb39SDaniele Ceraolo Spurio void intel_guc_write_params(struct intel_guc *guc)
3442bf8fb39SDaniele Ceraolo Spurio {
3452bf8fb39SDaniele Ceraolo Spurio struct intel_uncore *uncore = guc_to_gt(guc)->uncore;
3462bf8fb39SDaniele Ceraolo Spurio int i;
3470f261b24SDaniele Ceraolo Spurio
3480f261b24SDaniele Ceraolo Spurio /*
34955e3c170SMatt Roper * All SOFT_SCRATCH registers are in FORCEWAKE_GT domain and
3500f261b24SDaniele Ceraolo Spurio * they are power context saved so it's ok to release forcewake
3510f261b24SDaniele Ceraolo Spurio * when we are done here and take it again at xfer time.
3520f261b24SDaniele Ceraolo Spurio */
35355e3c170SMatt Roper intel_uncore_forcewake_get(uncore, FORCEWAKE_GT);
3540f261b24SDaniele Ceraolo Spurio
35584b1ca2fSDaniele Ceraolo Spurio intel_uncore_write(uncore, SOFT_SCRATCH(0), 0);
3560f261b24SDaniele Ceraolo Spurio
3570f261b24SDaniele Ceraolo Spurio for (i = 0; i < GUC_CTL_MAX_DWORDS; i++)
3582bf8fb39SDaniele Ceraolo Spurio intel_uncore_write(uncore, SOFT_SCRATCH(1 + i), guc->params[i]);
3590f261b24SDaniele Ceraolo Spurio
36055e3c170SMatt Roper intel_uncore_forcewake_put(uncore, FORCEWAKE_GT);
3610f261b24SDaniele Ceraolo Spurio }
3620f261b24SDaniele Ceraolo Spurio
intel_guc_dump_time_info(struct intel_guc * guc,struct drm_printer * p)363368d179aSJohn Harrison void intel_guc_dump_time_info(struct intel_guc *guc, struct drm_printer *p)
364368d179aSJohn Harrison {
365368d179aSJohn Harrison struct intel_gt *gt = guc_to_gt(guc);
366368d179aSJohn Harrison intel_wakeref_t wakeref;
367368d179aSJohn Harrison u32 stamp = 0;
368368d179aSJohn Harrison u64 ktime;
369368d179aSJohn Harrison
370368d179aSJohn Harrison with_intel_runtime_pm(>->i915->runtime_pm, wakeref)
371368d179aSJohn Harrison stamp = intel_uncore_read(gt->uncore, GUCPMTIMESTAMP);
372368d179aSJohn Harrison ktime = ktime_get_boottime_ns();
373368d179aSJohn Harrison
374368d179aSJohn Harrison drm_printf(p, "Kernel timestamp: 0x%08llX [%llu]\n", ktime, ktime);
375368d179aSJohn Harrison drm_printf(p, "GuC timestamp: 0x%08X [%u]\n", stamp, stamp);
376368d179aSJohn Harrison drm_printf(p, "CS timestamp frequency: %u Hz, %u ns\n",
377368d179aSJohn Harrison gt->clock_frequency, gt->clock_period_ns);
378368d179aSJohn Harrison }
379368d179aSJohn Harrison
intel_guc_init(struct intel_guc * guc)3802bf8fb39SDaniele Ceraolo Spurio int intel_guc_init(struct intel_guc *guc)
3812bf8fb39SDaniele Ceraolo Spurio {
3822bf8fb39SDaniele Ceraolo Spurio int ret;
3832bf8fb39SDaniele Ceraolo Spurio
3842bf8fb39SDaniele Ceraolo Spurio ret = intel_uc_fw_init(&guc->fw);
3852bf8fb39SDaniele Ceraolo Spurio if (ret)
38642f96e5bSDaniele Ceraolo Spurio goto out;
3872bf8fb39SDaniele Ceraolo Spurio
3882bf8fb39SDaniele Ceraolo Spurio ret = intel_guc_log_create(&guc->log);
3892bf8fb39SDaniele Ceraolo Spurio if (ret)
390034982cfSDaniele Ceraolo Spurio goto err_fw;
3912bf8fb39SDaniele Ceraolo Spurio
39224492514SAlan Previn ret = intel_guc_capture_init(guc);
3932bf8fb39SDaniele Ceraolo Spurio if (ret)
3942bf8fb39SDaniele Ceraolo Spurio goto err_log;
39524492514SAlan Previn
39624492514SAlan Previn ret = intel_guc_ads_create(guc);
39724492514SAlan Previn if (ret)
39824492514SAlan Previn goto err_capture;
39924492514SAlan Previn
4002bf8fb39SDaniele Ceraolo Spurio GEM_BUG_ON(!guc->ads_vma);
4012bf8fb39SDaniele Ceraolo Spurio
4022bf8fb39SDaniele Ceraolo Spurio ret = intel_guc_ct_init(&guc->ct);
4032bf8fb39SDaniele Ceraolo Spurio if (ret)
4042bf8fb39SDaniele Ceraolo Spurio goto err_ads;
4052bf8fb39SDaniele Ceraolo Spurio
406202c98e7SDaniele Ceraolo Spurio if (intel_guc_submission_is_used(guc)) {
407edad2547SDaniele Ceraolo Spurio /*
408edad2547SDaniele Ceraolo Spurio * This is stuff we need to have available at fw load time
409edad2547SDaniele Ceraolo Spurio * if we are planning to enable submission later
410edad2547SDaniele Ceraolo Spurio */
411edad2547SDaniele Ceraolo Spurio ret = intel_guc_submission_init(guc);
412edad2547SDaniele Ceraolo Spurio if (ret)
413edad2547SDaniele Ceraolo Spurio goto err_ct;
414edad2547SDaniele Ceraolo Spurio }
415edad2547SDaniele Ceraolo Spurio
416869cd27eSVinay Belgaumkar if (intel_guc_slpc_is_used(guc)) {
417869cd27eSVinay Belgaumkar ret = intel_guc_slpc_init(&guc->slpc);
418869cd27eSVinay Belgaumkar if (ret)
419869cd27eSVinay Belgaumkar goto err_submission;
420869cd27eSVinay Belgaumkar }
421869cd27eSVinay Belgaumkar
4222bf8fb39SDaniele Ceraolo Spurio /* now that everything is perma-pinned, initialize the parameters */
4232bf8fb39SDaniele Ceraolo Spurio guc_init_params(guc);
4242bf8fb39SDaniele Ceraolo Spurio
42542f96e5bSDaniele Ceraolo Spurio intel_uc_fw_change_status(&guc->fw, INTEL_UC_FIRMWARE_LOADABLE);
42642f96e5bSDaniele Ceraolo Spurio
4272bf8fb39SDaniele Ceraolo Spurio return 0;
4282bf8fb39SDaniele Ceraolo Spurio
429869cd27eSVinay Belgaumkar err_submission:
430869cd27eSVinay Belgaumkar intel_guc_submission_fini(guc);
431edad2547SDaniele Ceraolo Spurio err_ct:
432edad2547SDaniele Ceraolo Spurio intel_guc_ct_fini(&guc->ct);
4332bf8fb39SDaniele Ceraolo Spurio err_ads:
4342bf8fb39SDaniele Ceraolo Spurio intel_guc_ads_destroy(guc);
43524492514SAlan Previn err_capture:
43624492514SAlan Previn intel_guc_capture_destroy(guc);
4372bf8fb39SDaniele Ceraolo Spurio err_log:
4382bf8fb39SDaniele Ceraolo Spurio intel_guc_log_destroy(&guc->log);
4392bf8fb39SDaniele Ceraolo Spurio err_fw:
4402bf8fb39SDaniele Ceraolo Spurio intel_uc_fw_fini(&guc->fw);
44142f96e5bSDaniele Ceraolo Spurio out:
442b76c14c8SDaniele Ceraolo Spurio intel_uc_fw_change_status(&guc->fw, INTEL_UC_FIRMWARE_INIT_FAIL);
443ecb89c2cSMichal Wajdeczko guc_probe_error(guc, "failed with %pe\n", ERR_PTR(ret));
4442bf8fb39SDaniele Ceraolo Spurio return ret;
4452bf8fb39SDaniele Ceraolo Spurio }
4462bf8fb39SDaniele Ceraolo Spurio
intel_guc_fini(struct intel_guc * guc)4472bf8fb39SDaniele Ceraolo Spurio void intel_guc_fini(struct intel_guc *guc)
4482bf8fb39SDaniele Ceraolo Spurio {
44942f96e5bSDaniele Ceraolo Spurio if (!intel_uc_fw_is_loadable(&guc->fw))
4500075a20aSMichal Wajdeczko return;
4510075a20aSMichal Wajdeczko
452869cd27eSVinay Belgaumkar if (intel_guc_slpc_is_used(guc))
453869cd27eSVinay Belgaumkar intel_guc_slpc_fini(&guc->slpc);
454869cd27eSVinay Belgaumkar
455202c98e7SDaniele Ceraolo Spurio if (intel_guc_submission_is_used(guc))
456edad2547SDaniele Ceraolo Spurio intel_guc_submission_fini(guc);
457edad2547SDaniele Ceraolo Spurio
4582bf8fb39SDaniele Ceraolo Spurio intel_guc_ct_fini(&guc->ct);
4592bf8fb39SDaniele Ceraolo Spurio
4602bf8fb39SDaniele Ceraolo Spurio intel_guc_ads_destroy(guc);
46124492514SAlan Previn intel_guc_capture_destroy(guc);
4622bf8fb39SDaniele Ceraolo Spurio intel_guc_log_destroy(&guc->log);
4632bf8fb39SDaniele Ceraolo Spurio intel_uc_fw_fini(&guc->fw);
4642bf8fb39SDaniele Ceraolo Spurio }
4652bf8fb39SDaniele Ceraolo Spurio
4660f261b24SDaniele Ceraolo Spurio /*
4670f261b24SDaniele Ceraolo Spurio * This function implements the MMIO based host to GuC interface.
4680f261b24SDaniele Ceraolo Spurio */
intel_guc_send_mmio(struct intel_guc * guc,const u32 * request,u32 len,u32 * response_buf,u32 response_buf_size)469572f2a5cSMichal Wajdeczko int intel_guc_send_mmio(struct intel_guc *guc, const u32 *request, u32 len,
4700f261b24SDaniele Ceraolo Spurio u32 *response_buf, u32 response_buf_size)
4710f261b24SDaniele Ceraolo Spurio {
47284b1ca2fSDaniele Ceraolo Spurio struct intel_uncore *uncore = guc_to_gt(guc)->uncore;
473572f2a5cSMichal Wajdeczko u32 header;
4740f261b24SDaniele Ceraolo Spurio int i;
4750f261b24SDaniele Ceraolo Spurio int ret;
4760f261b24SDaniele Ceraolo Spurio
4770f261b24SDaniele Ceraolo Spurio GEM_BUG_ON(!len);
4780f261b24SDaniele Ceraolo Spurio GEM_BUG_ON(len > guc->send_regs.count);
4790f261b24SDaniele Ceraolo Spurio
480572f2a5cSMichal Wajdeczko GEM_BUG_ON(FIELD_GET(GUC_HXG_MSG_0_ORIGIN, request[0]) != GUC_HXG_ORIGIN_HOST);
481572f2a5cSMichal Wajdeczko GEM_BUG_ON(FIELD_GET(GUC_HXG_MSG_0_TYPE, request[0]) != GUC_HXG_TYPE_REQUEST);
4820f261b24SDaniele Ceraolo Spurio
4830f261b24SDaniele Ceraolo Spurio mutex_lock(&guc->send_mutex);
4840f261b24SDaniele Ceraolo Spurio intel_uncore_forcewake_get(uncore, guc->send_regs.fw_domains);
4850f261b24SDaniele Ceraolo Spurio
486572f2a5cSMichal Wajdeczko retry:
4870f261b24SDaniele Ceraolo Spurio for (i = 0; i < len; i++)
488572f2a5cSMichal Wajdeczko intel_uncore_write(uncore, guc_send_reg(guc, i), request[i]);
4890f261b24SDaniele Ceraolo Spurio
4900f261b24SDaniele Ceraolo Spurio intel_uncore_posting_read(uncore, guc_send_reg(guc, i - 1));
4910f261b24SDaniele Ceraolo Spurio
4920f261b24SDaniele Ceraolo Spurio intel_guc_notify(guc);
4930f261b24SDaniele Ceraolo Spurio
4940f261b24SDaniele Ceraolo Spurio /*
4950f261b24SDaniele Ceraolo Spurio * No GuC command should ever take longer than 10ms.
4960f261b24SDaniele Ceraolo Spurio * Fast commands should still complete in 10us.
4970f261b24SDaniele Ceraolo Spurio */
4980f261b24SDaniele Ceraolo Spurio ret = __intel_wait_for_register_fw(uncore,
4990f261b24SDaniele Ceraolo Spurio guc_send_reg(guc, 0),
500572f2a5cSMichal Wajdeczko GUC_HXG_MSG_0_ORIGIN,
501572f2a5cSMichal Wajdeczko FIELD_PREP(GUC_HXG_MSG_0_ORIGIN,
502572f2a5cSMichal Wajdeczko GUC_HXG_ORIGIN_GUC),
503572f2a5cSMichal Wajdeczko 10, 10, &header);
504572f2a5cSMichal Wajdeczko if (unlikely(ret)) {
505572f2a5cSMichal Wajdeczko timeout:
506ecb89c2cSMichal Wajdeczko guc_err(guc, "mmio request %#x: no reply %x\n",
507572f2a5cSMichal Wajdeczko request[0], header);
508572f2a5cSMichal Wajdeczko goto out;
509572f2a5cSMichal Wajdeczko }
5100f261b24SDaniele Ceraolo Spurio
511572f2a5cSMichal Wajdeczko if (FIELD_GET(GUC_HXG_MSG_0_TYPE, header) == GUC_HXG_TYPE_NO_RESPONSE_BUSY) {
512572f2a5cSMichal Wajdeczko #define done ({ header = intel_uncore_read(uncore, guc_send_reg(guc, 0)); \
513572f2a5cSMichal Wajdeczko FIELD_GET(GUC_HXG_MSG_0_ORIGIN, header) != GUC_HXG_ORIGIN_GUC || \
514572f2a5cSMichal Wajdeczko FIELD_GET(GUC_HXG_MSG_0_TYPE, header) != GUC_HXG_TYPE_NO_RESPONSE_BUSY; })
515572f2a5cSMichal Wajdeczko
516572f2a5cSMichal Wajdeczko ret = wait_for(done, 1000);
517572f2a5cSMichal Wajdeczko if (unlikely(ret))
518572f2a5cSMichal Wajdeczko goto timeout;
519572f2a5cSMichal Wajdeczko if (unlikely(FIELD_GET(GUC_HXG_MSG_0_ORIGIN, header) !=
520572f2a5cSMichal Wajdeczko GUC_HXG_ORIGIN_GUC))
521572f2a5cSMichal Wajdeczko goto proto;
522572f2a5cSMichal Wajdeczko #undef done
523572f2a5cSMichal Wajdeczko }
524572f2a5cSMichal Wajdeczko
525572f2a5cSMichal Wajdeczko if (FIELD_GET(GUC_HXG_MSG_0_TYPE, header) == GUC_HXG_TYPE_NO_RESPONSE_RETRY) {
526572f2a5cSMichal Wajdeczko u32 reason = FIELD_GET(GUC_HXG_RETRY_MSG_0_REASON, header);
527572f2a5cSMichal Wajdeczko
528ecb89c2cSMichal Wajdeczko guc_dbg(guc, "mmio request %#x: retrying, reason %u\n",
529572f2a5cSMichal Wajdeczko request[0], reason);
530572f2a5cSMichal Wajdeczko goto retry;
531572f2a5cSMichal Wajdeczko }
532572f2a5cSMichal Wajdeczko
533572f2a5cSMichal Wajdeczko if (FIELD_GET(GUC_HXG_MSG_0_TYPE, header) == GUC_HXG_TYPE_RESPONSE_FAILURE) {
534572f2a5cSMichal Wajdeczko u32 hint = FIELD_GET(GUC_HXG_FAILURE_MSG_0_HINT, header);
535572f2a5cSMichal Wajdeczko u32 error = FIELD_GET(GUC_HXG_FAILURE_MSG_0_ERROR, header);
536572f2a5cSMichal Wajdeczko
537ecb89c2cSMichal Wajdeczko guc_err(guc, "mmio request %#x: failure %x/%u\n",
538572f2a5cSMichal Wajdeczko request[0], error, hint);
539572f2a5cSMichal Wajdeczko ret = -ENXIO;
540572f2a5cSMichal Wajdeczko goto out;
541572f2a5cSMichal Wajdeczko }
542572f2a5cSMichal Wajdeczko
543572f2a5cSMichal Wajdeczko if (FIELD_GET(GUC_HXG_MSG_0_TYPE, header) != GUC_HXG_TYPE_RESPONSE_SUCCESS) {
544572f2a5cSMichal Wajdeczko proto:
545ecb89c2cSMichal Wajdeczko guc_err(guc, "mmio request %#x: unexpected reply %#x\n",
546572f2a5cSMichal Wajdeczko request[0], header);
547572f2a5cSMichal Wajdeczko ret = -EPROTO;
5480f261b24SDaniele Ceraolo Spurio goto out;
5490f261b24SDaniele Ceraolo Spurio }
5500f261b24SDaniele Ceraolo Spurio
5510f261b24SDaniele Ceraolo Spurio if (response_buf) {
552572f2a5cSMichal Wajdeczko int count = min(response_buf_size, guc->send_regs.count);
5530f261b24SDaniele Ceraolo Spurio
554572f2a5cSMichal Wajdeczko GEM_BUG_ON(!count);
555572f2a5cSMichal Wajdeczko
556572f2a5cSMichal Wajdeczko response_buf[0] = header;
557572f2a5cSMichal Wajdeczko
558572f2a5cSMichal Wajdeczko for (i = 1; i < count; i++)
55984b1ca2fSDaniele Ceraolo Spurio response_buf[i] = intel_uncore_read(uncore,
560572f2a5cSMichal Wajdeczko guc_send_reg(guc, i));
5610f261b24SDaniele Ceraolo Spurio
562572f2a5cSMichal Wajdeczko /* Use number of copied dwords as our return value */
563572f2a5cSMichal Wajdeczko ret = count;
564572f2a5cSMichal Wajdeczko } else {
5650f261b24SDaniele Ceraolo Spurio /* Use data from the GuC response as our return value */
566572f2a5cSMichal Wajdeczko ret = FIELD_GET(GUC_HXG_RESPONSE_MSG_0_DATA0, header);
567572f2a5cSMichal Wajdeczko }
5680f261b24SDaniele Ceraolo Spurio
5690f261b24SDaniele Ceraolo Spurio out:
5700f261b24SDaniele Ceraolo Spurio intel_uncore_forcewake_put(uncore, guc->send_regs.fw_domains);
5710f261b24SDaniele Ceraolo Spurio mutex_unlock(&guc->send_mutex);
5720f261b24SDaniele Ceraolo Spurio
5730f261b24SDaniele Ceraolo Spurio return ret;
5740f261b24SDaniele Ceraolo Spurio }
5750f261b24SDaniele Ceraolo Spurio
intel_guc_to_host_process_recv_msg(struct intel_guc * guc,const u32 * payload,u32 len)5760f261b24SDaniele Ceraolo Spurio int intel_guc_to_host_process_recv_msg(struct intel_guc *guc,
5770f261b24SDaniele Ceraolo Spurio const u32 *payload, u32 len)
5780f261b24SDaniele Ceraolo Spurio {
5790f261b24SDaniele Ceraolo Spurio u32 msg;
5800f261b24SDaniele Ceraolo Spurio
5810f261b24SDaniele Ceraolo Spurio if (unlikely(!len))
5820f261b24SDaniele Ceraolo Spurio return -EPROTO;
5830f261b24SDaniele Ceraolo Spurio
5840f261b24SDaniele Ceraolo Spurio /* Make sure to handle only enabled messages */
5850f261b24SDaniele Ceraolo Spurio msg = payload[0] & guc->msg_enabled_mask;
5860f261b24SDaniele Ceraolo Spurio
58777b6f79dSJohn Harrison if (msg & INTEL_GUC_RECV_MSG_CRASH_DUMP_POSTED)
588ecb89c2cSMichal Wajdeczko guc_err(guc, "Received early crash dump notification!\n");
58977b6f79dSJohn Harrison if (msg & INTEL_GUC_RECV_MSG_EXCEPTION)
590ecb89c2cSMichal Wajdeczko guc_err(guc, "Received early exception notification!\n");
5910f261b24SDaniele Ceraolo Spurio
5920f261b24SDaniele Ceraolo Spurio return 0;
5930f261b24SDaniele Ceraolo Spurio }
5940f261b24SDaniele Ceraolo Spurio
5950f261b24SDaniele Ceraolo Spurio /**
5960f261b24SDaniele Ceraolo Spurio * intel_guc_auth_huc() - Send action to GuC to authenticate HuC ucode
5970f261b24SDaniele Ceraolo Spurio * @guc: intel_guc structure
5980f261b24SDaniele Ceraolo Spurio * @rsa_offset: rsa offset w.r.t ggtt base of huc vma
5990f261b24SDaniele Ceraolo Spurio *
6000f261b24SDaniele Ceraolo Spurio * Triggers a HuC firmware authentication request to the GuC via intel_guc_send
6010f261b24SDaniele Ceraolo Spurio * INTEL_GUC_ACTION_AUTHENTICATE_HUC interface. This function is invoked by
6020f261b24SDaniele Ceraolo Spurio * intel_huc_auth().
6030f261b24SDaniele Ceraolo Spurio *
6040f261b24SDaniele Ceraolo Spurio * Return: non-zero code on error
6050f261b24SDaniele Ceraolo Spurio */
intel_guc_auth_huc(struct intel_guc * guc,u32 rsa_offset)6060f261b24SDaniele Ceraolo Spurio int intel_guc_auth_huc(struct intel_guc *guc, u32 rsa_offset)
6070f261b24SDaniele Ceraolo Spurio {
6080f261b24SDaniele Ceraolo Spurio u32 action[] = {
6090f261b24SDaniele Ceraolo Spurio INTEL_GUC_ACTION_AUTHENTICATE_HUC,
6100f261b24SDaniele Ceraolo Spurio rsa_offset
6110f261b24SDaniele Ceraolo Spurio };
6120f261b24SDaniele Ceraolo Spurio
6130f261b24SDaniele Ceraolo Spurio return intel_guc_send(guc, action, ARRAY_SIZE(action));
6140f261b24SDaniele Ceraolo Spurio }
6150f261b24SDaniele Ceraolo Spurio
6160f261b24SDaniele Ceraolo Spurio /**
6170f261b24SDaniele Ceraolo Spurio * intel_guc_suspend() - notify GuC entering suspend state
6180f261b24SDaniele Ceraolo Spurio * @guc: the guc
6190f261b24SDaniele Ceraolo Spurio */
intel_guc_suspend(struct intel_guc * guc)6200f261b24SDaniele Ceraolo Spurio int intel_guc_suspend(struct intel_guc *guc)
6210f261b24SDaniele Ceraolo Spurio {
6220f261b24SDaniele Ceraolo Spurio int ret;
6230f261b24SDaniele Ceraolo Spurio u32 action[] = {
62477b6f79dSJohn Harrison INTEL_GUC_ACTION_CLIENT_SOFT_RESET,
6250f261b24SDaniele Ceraolo Spurio };
6260f261b24SDaniele Ceraolo Spurio
627cad46a33SMatthew Brost if (!intel_guc_is_ready(guc))
62882e0c5bbSDon Hiatt return 0;
62982e0c5bbSDon Hiatt
630cad46a33SMatthew Brost if (intel_guc_submission_is_used(guc)) {
63182e0c5bbSDon Hiatt /*
632cad46a33SMatthew Brost * This H2G MMIO command tears down the GuC in two steps. First it will
633cad46a33SMatthew Brost * generate a G2H CTB for every active context indicating a reset. In
634cad46a33SMatthew Brost * practice the i915 shouldn't ever get a G2H as suspend should only be
635cad46a33SMatthew Brost * called when the GPU is idle. Next, it tears down the CTBs and this
636cad46a33SMatthew Brost * H2G MMIO command completes.
637cad46a33SMatthew Brost *
638cad46a33SMatthew Brost * Don't abort on a failure code from the GuC. Keep going and do the
639cad46a33SMatthew Brost * clean up in santize() and re-initialisation on resume and hopefully
640cad46a33SMatthew Brost * the error here won't be problematic.
6410f261b24SDaniele Ceraolo Spurio */
642cad46a33SMatthew Brost ret = intel_guc_send_mmio(guc, action, ARRAY_SIZE(action), NULL, 0);
6430f261b24SDaniele Ceraolo Spurio if (ret)
644ecb89c2cSMichal Wajdeczko guc_err(guc, "suspend: RESET_CLIENT action failed with %pe\n",
645ecb89c2cSMichal Wajdeczko ERR_PTR(ret));
6460f261b24SDaniele Ceraolo Spurio }
6470f261b24SDaniele Ceraolo Spurio
648cad46a33SMatthew Brost /* Signal that the GuC isn't running. */
649cad46a33SMatthew Brost intel_guc_sanitize(guc);
650cad46a33SMatthew Brost
6510f261b24SDaniele Ceraolo Spurio return 0;
6520f261b24SDaniele Ceraolo Spurio }
6530f261b24SDaniele Ceraolo Spurio
6540f261b24SDaniele Ceraolo Spurio /**
6550f261b24SDaniele Ceraolo Spurio * intel_guc_resume() - notify GuC resuming from suspend state
6560f261b24SDaniele Ceraolo Spurio * @guc: the guc
6570f261b24SDaniele Ceraolo Spurio */
intel_guc_resume(struct intel_guc * guc)6580f261b24SDaniele Ceraolo Spurio int intel_guc_resume(struct intel_guc *guc)
6590f261b24SDaniele Ceraolo Spurio {
660cad46a33SMatthew Brost /*
661cad46a33SMatthew Brost * NB: This function can still be called even if GuC submission is
662cad46a33SMatthew Brost * disabled, e.g. if GuC is enabled for HuC authentication only. Thus,
663cad46a33SMatthew Brost * if any code is later added here, it must be support doing nothing
664cad46a33SMatthew Brost * if submission is disabled (as per intel_guc_suspend).
665cad46a33SMatthew Brost */
66682e0c5bbSDon Hiatt return 0;
6670f261b24SDaniele Ceraolo Spurio }
6680f261b24SDaniele Ceraolo Spurio
6690f261b24SDaniele Ceraolo Spurio /**
670218151e9SDaniele Ceraolo Spurio * DOC: GuC Memory Management
6710f261b24SDaniele Ceraolo Spurio *
672218151e9SDaniele Ceraolo Spurio * GuC can't allocate any memory for its own usage, so all the allocations must
673218151e9SDaniele Ceraolo Spurio * be handled by the host driver. GuC accesses the memory via the GGTT, with the
674218151e9SDaniele Ceraolo Spurio * exception of the top and bottom parts of the 4GB address space, which are
675218151e9SDaniele Ceraolo Spurio * instead re-mapped by the GuC HW to memory location of the FW itself (WOPCM)
676218151e9SDaniele Ceraolo Spurio * or other parts of the HW. The driver must take care not to place objects that
677218151e9SDaniele Ceraolo Spurio * the GuC is going to access in these reserved ranges. The layout of the GuC
678218151e9SDaniele Ceraolo Spurio * address space is shown below:
6790f261b24SDaniele Ceraolo Spurio *
6800f261b24SDaniele Ceraolo Spurio * ::
6810f261b24SDaniele Ceraolo Spurio *
6820f261b24SDaniele Ceraolo Spurio * +===========> +====================+ <== FFFF_FFFF
6830f261b24SDaniele Ceraolo Spurio * ^ | Reserved |
6840f261b24SDaniele Ceraolo Spurio * | +====================+ <== GUC_GGTT_TOP
6850f261b24SDaniele Ceraolo Spurio * | | |
6860f261b24SDaniele Ceraolo Spurio * | | DRAM |
6870f261b24SDaniele Ceraolo Spurio * GuC | |
6880f261b24SDaniele Ceraolo Spurio * Address +===> +====================+ <== GuC ggtt_pin_bias
6890f261b24SDaniele Ceraolo Spurio * Space ^ | |
6900f261b24SDaniele Ceraolo Spurio * | | | |
6910f261b24SDaniele Ceraolo Spurio * | GuC | GuC |
6920f261b24SDaniele Ceraolo Spurio * | WOPCM | WOPCM |
6930f261b24SDaniele Ceraolo Spurio * | Size | |
6940f261b24SDaniele Ceraolo Spurio * | | | |
6950f261b24SDaniele Ceraolo Spurio * v v | |
6960f261b24SDaniele Ceraolo Spurio * +=======+===> +====================+ <== 0000_0000
6970f261b24SDaniele Ceraolo Spurio *
6980f261b24SDaniele Ceraolo Spurio * The lower part of GuC Address Space [0, ggtt_pin_bias) is mapped to GuC WOPCM
6990f261b24SDaniele Ceraolo Spurio * while upper part of GuC Address Space [ggtt_pin_bias, GUC_GGTT_TOP) is mapped
7000f261b24SDaniele Ceraolo Spurio * to DRAM. The value of the GuC ggtt_pin_bias is the GuC WOPCM size.
7010f261b24SDaniele Ceraolo Spurio */
7020f261b24SDaniele Ceraolo Spurio
7030f261b24SDaniele Ceraolo Spurio /**
7040f261b24SDaniele Ceraolo Spurio * intel_guc_allocate_vma() - Allocate a GGTT VMA for GuC usage
7050f261b24SDaniele Ceraolo Spurio * @guc: the guc
7060f261b24SDaniele Ceraolo Spurio * @size: size of area to allocate (both virtual space and memory)
7070f261b24SDaniele Ceraolo Spurio *
7080f261b24SDaniele Ceraolo Spurio * This is a wrapper to create an object for use with the GuC. In order to
7090f261b24SDaniele Ceraolo Spurio * use it inside the GuC, an object needs to be pinned lifetime, so we allocate
7100f261b24SDaniele Ceraolo Spurio * both some backing storage and a range inside the Global GTT. We must pin
7110f261b24SDaniele Ceraolo Spurio * it in the GGTT somewhere other than than [0, GUC ggtt_pin_bias) because that
7120f261b24SDaniele Ceraolo Spurio * range is reserved inside GuC.
7130f261b24SDaniele Ceraolo Spurio *
7140f261b24SDaniele Ceraolo Spurio * Return: A i915_vma if successful, otherwise an ERR_PTR.
7150f261b24SDaniele Ceraolo Spurio */
intel_guc_allocate_vma(struct intel_guc * guc,u32 size)7160f261b24SDaniele Ceraolo Spurio struct i915_vma *intel_guc_allocate_vma(struct intel_guc *guc, u32 size)
7170f261b24SDaniele Ceraolo Spurio {
71884b1ca2fSDaniele Ceraolo Spurio struct intel_gt *gt = guc_to_gt(guc);
7190f261b24SDaniele Ceraolo Spurio struct drm_i915_gem_object *obj;
7200f261b24SDaniele Ceraolo Spurio struct i915_vma *vma;
7210f261b24SDaniele Ceraolo Spurio u64 flags;
7220f261b24SDaniele Ceraolo Spurio int ret;
7230f261b24SDaniele Ceraolo Spurio
7247acbbc7cSDaniele Ceraolo Spurio if (HAS_LMEM(gt->i915))
7257acbbc7cSDaniele Ceraolo Spurio obj = i915_gem_object_create_lmem(gt->i915, size,
7267acbbc7cSDaniele Ceraolo Spurio I915_BO_ALLOC_CPU_CLEAR |
727a259cc14SThomas Hellström I915_BO_ALLOC_CONTIGUOUS |
728a259cc14SThomas Hellström I915_BO_ALLOC_PM_EARLY);
7297acbbc7cSDaniele Ceraolo Spurio else
73084b1ca2fSDaniele Ceraolo Spurio obj = i915_gem_object_create_shmem(gt->i915, size);
7317acbbc7cSDaniele Ceraolo Spurio
7320f261b24SDaniele Ceraolo Spurio if (IS_ERR(obj))
7330f261b24SDaniele Ceraolo Spurio return ERR_CAST(obj);
7340f261b24SDaniele Ceraolo Spurio
735a161b6dbSFei Yang /*
736f1530f91SJonathan Cavitt * Wa_22016122933: For Media version 13.0, all Media GT shared
737f1530f91SJonathan Cavitt * memory needs to be mapped as WC on CPU side and UC (PAT
738f1530f91SJonathan Cavitt * index 2) on GPU side.
739a161b6dbSFei Yang */
740f1530f91SJonathan Cavitt if (intel_gt_needs_wa_22016122933(gt))
741a161b6dbSFei Yang i915_gem_object_set_cache_coherency(obj, I915_CACHE_NONE);
742a161b6dbSFei Yang
74384b1ca2fSDaniele Ceraolo Spurio vma = i915_vma_instance(obj, >->ggtt->vm, NULL);
7440f261b24SDaniele Ceraolo Spurio if (IS_ERR(vma))
7450f261b24SDaniele Ceraolo Spurio goto err;
7460f261b24SDaniele Ceraolo Spurio
747e3793468SChris Wilson flags = PIN_OFFSET_BIAS | i915_ggtt_pin_bias(vma);
74847b08693SMaarten Lankhorst ret = i915_ggtt_pin(vma, NULL, 0, flags);
7490f261b24SDaniele Ceraolo Spurio if (ret) {
7500f261b24SDaniele Ceraolo Spurio vma = ERR_PTR(ret);
7510f261b24SDaniele Ceraolo Spurio goto err;
7520f261b24SDaniele Ceraolo Spurio }
7530f261b24SDaniele Ceraolo Spurio
7541aff1903SChris Wilson return i915_vma_make_unshrinkable(vma);
7550f261b24SDaniele Ceraolo Spurio
7560f261b24SDaniele Ceraolo Spurio err:
7570f261b24SDaniele Ceraolo Spurio i915_gem_object_put(obj);
7580f261b24SDaniele Ceraolo Spurio return vma;
7590f261b24SDaniele Ceraolo Spurio }
76018c094b3SDaniele Ceraolo Spurio
76118c094b3SDaniele Ceraolo Spurio /**
76218c094b3SDaniele Ceraolo Spurio * intel_guc_allocate_and_map_vma() - Allocate and map VMA for GuC usage
76318c094b3SDaniele Ceraolo Spurio * @guc: the guc
76418c094b3SDaniele Ceraolo Spurio * @size: size of area to allocate (both virtual space and memory)
76518c094b3SDaniele Ceraolo Spurio * @out_vma: return variable for the allocated vma pointer
76618c094b3SDaniele Ceraolo Spurio * @out_vaddr: return variable for the obj mapping
76718c094b3SDaniele Ceraolo Spurio *
76818c094b3SDaniele Ceraolo Spurio * This wrapper calls intel_guc_allocate_vma() and then maps the allocated
76918c094b3SDaniele Ceraolo Spurio * object with I915_MAP_WB.
77018c094b3SDaniele Ceraolo Spurio *
77118c094b3SDaniele Ceraolo Spurio * Return: 0 if successful, a negative errno code otherwise.
77218c094b3SDaniele Ceraolo Spurio */
intel_guc_allocate_and_map_vma(struct intel_guc * guc,u32 size,struct i915_vma ** out_vma,void ** out_vaddr)77318c094b3SDaniele Ceraolo Spurio int intel_guc_allocate_and_map_vma(struct intel_guc *guc, u32 size,
77418c094b3SDaniele Ceraolo Spurio struct i915_vma **out_vma, void **out_vaddr)
77518c094b3SDaniele Ceraolo Spurio {
77618c094b3SDaniele Ceraolo Spurio struct i915_vma *vma;
77718c094b3SDaniele Ceraolo Spurio void *vaddr;
77818c094b3SDaniele Ceraolo Spurio
77918c094b3SDaniele Ceraolo Spurio vma = intel_guc_allocate_vma(guc, size);
78018c094b3SDaniele Ceraolo Spurio if (IS_ERR(vma))
78118c094b3SDaniele Ceraolo Spurio return PTR_ERR(vma);
78218c094b3SDaniele Ceraolo Spurio
783fa85bfd1SVenkata Sandeep Dhanalakota vaddr = i915_gem_object_pin_map_unlocked(vma->obj,
784115cdccaSJonathan Cavitt intel_gt_coherent_map_type(guc_to_gt(guc),
785fa85bfd1SVenkata Sandeep Dhanalakota vma->obj, true));
78618c094b3SDaniele Ceraolo Spurio if (IS_ERR(vaddr)) {
78718c094b3SDaniele Ceraolo Spurio i915_vma_unpin_and_release(&vma, 0);
78818c094b3SDaniele Ceraolo Spurio return PTR_ERR(vaddr);
78918c094b3SDaniele Ceraolo Spurio }
79018c094b3SDaniele Ceraolo Spurio
79118c094b3SDaniele Ceraolo Spurio *out_vma = vma;
79218c094b3SDaniele Ceraolo Spurio *out_vaddr = vaddr;
79318c094b3SDaniele Ceraolo Spurio
79418c094b3SDaniele Ceraolo Spurio return 0;
79518c094b3SDaniele Ceraolo Spurio }
79634904bd6SDaniele Ceraolo Spurio
__guc_action_self_cfg(struct intel_guc * guc,u16 key,u16 len,u64 value)79777b6f79dSJohn Harrison static int __guc_action_self_cfg(struct intel_guc *guc, u16 key, u16 len, u64 value)
79877b6f79dSJohn Harrison {
79977b6f79dSJohn Harrison u32 request[HOST2GUC_SELF_CFG_REQUEST_MSG_LEN] = {
80077b6f79dSJohn Harrison FIELD_PREP(GUC_HXG_MSG_0_ORIGIN, GUC_HXG_ORIGIN_HOST) |
80177b6f79dSJohn Harrison FIELD_PREP(GUC_HXG_MSG_0_TYPE, GUC_HXG_TYPE_REQUEST) |
80277b6f79dSJohn Harrison FIELD_PREP(GUC_HXG_REQUEST_MSG_0_ACTION, GUC_ACTION_HOST2GUC_SELF_CFG),
80377b6f79dSJohn Harrison FIELD_PREP(HOST2GUC_SELF_CFG_REQUEST_MSG_1_KLV_KEY, key) |
80477b6f79dSJohn Harrison FIELD_PREP(HOST2GUC_SELF_CFG_REQUEST_MSG_1_KLV_LEN, len),
80577b6f79dSJohn Harrison FIELD_PREP(HOST2GUC_SELF_CFG_REQUEST_MSG_2_VALUE32, lower_32_bits(value)),
80677b6f79dSJohn Harrison FIELD_PREP(HOST2GUC_SELF_CFG_REQUEST_MSG_3_VALUE64, upper_32_bits(value)),
80777b6f79dSJohn Harrison };
80877b6f79dSJohn Harrison int ret;
80977b6f79dSJohn Harrison
81077b6f79dSJohn Harrison GEM_BUG_ON(len > 2);
81177b6f79dSJohn Harrison GEM_BUG_ON(len == 1 && upper_32_bits(value));
81277b6f79dSJohn Harrison
81377b6f79dSJohn Harrison /* Self config must go over MMIO */
81477b6f79dSJohn Harrison ret = intel_guc_send_mmio(guc, request, ARRAY_SIZE(request), NULL, 0);
81577b6f79dSJohn Harrison
81677b6f79dSJohn Harrison if (unlikely(ret < 0))
81777b6f79dSJohn Harrison return ret;
81877b6f79dSJohn Harrison if (unlikely(ret > 1))
81977b6f79dSJohn Harrison return -EPROTO;
82077b6f79dSJohn Harrison if (unlikely(!ret))
82177b6f79dSJohn Harrison return -ENOKEY;
82277b6f79dSJohn Harrison
82377b6f79dSJohn Harrison return 0;
82477b6f79dSJohn Harrison }
82577b6f79dSJohn Harrison
__guc_self_cfg(struct intel_guc * guc,u16 key,u16 len,u64 value)82677b6f79dSJohn Harrison static int __guc_self_cfg(struct intel_guc *guc, u16 key, u16 len, u64 value)
82777b6f79dSJohn Harrison {
82877b6f79dSJohn Harrison int err = __guc_action_self_cfg(guc, key, len, value);
82977b6f79dSJohn Harrison
83077b6f79dSJohn Harrison if (unlikely(err))
831ecb89c2cSMichal Wajdeczko guc_probe_error(guc, "Unsuccessful self-config (%pe) key %#hx value %#llx\n",
83277b6f79dSJohn Harrison ERR_PTR(err), key, value);
83377b6f79dSJohn Harrison return err;
83477b6f79dSJohn Harrison }
83577b6f79dSJohn Harrison
intel_guc_self_cfg32(struct intel_guc * guc,u16 key,u32 value)83677b6f79dSJohn Harrison int intel_guc_self_cfg32(struct intel_guc *guc, u16 key, u32 value)
83777b6f79dSJohn Harrison {
83877b6f79dSJohn Harrison return __guc_self_cfg(guc, key, 1, value);
83977b6f79dSJohn Harrison }
84077b6f79dSJohn Harrison
intel_guc_self_cfg64(struct intel_guc * guc,u16 key,u64 value)84177b6f79dSJohn Harrison int intel_guc_self_cfg64(struct intel_guc *guc, u16 key, u64 value)
84277b6f79dSJohn Harrison {
84377b6f79dSJohn Harrison return __guc_self_cfg(guc, key, 2, value);
84477b6f79dSJohn Harrison }
84577b6f79dSJohn Harrison
84634904bd6SDaniele Ceraolo Spurio /**
84734904bd6SDaniele Ceraolo Spurio * intel_guc_load_status - dump information about GuC load status
84834904bd6SDaniele Ceraolo Spurio * @guc: the GuC
84934904bd6SDaniele Ceraolo Spurio * @p: the &drm_printer
85034904bd6SDaniele Ceraolo Spurio *
85134904bd6SDaniele Ceraolo Spurio * Pretty printer for GuC load status.
85234904bd6SDaniele Ceraolo Spurio */
intel_guc_load_status(struct intel_guc * guc,struct drm_printer * p)85334904bd6SDaniele Ceraolo Spurio void intel_guc_load_status(struct intel_guc *guc, struct drm_printer *p)
85434904bd6SDaniele Ceraolo Spurio {
85534904bd6SDaniele Ceraolo Spurio struct intel_gt *gt = guc_to_gt(guc);
85634904bd6SDaniele Ceraolo Spurio struct intel_uncore *uncore = gt->uncore;
85734904bd6SDaniele Ceraolo Spurio intel_wakeref_t wakeref;
85834904bd6SDaniele Ceraolo Spurio
85934904bd6SDaniele Ceraolo Spurio if (!intel_guc_is_supported(guc)) {
86034904bd6SDaniele Ceraolo Spurio drm_printf(p, "GuC not supported\n");
86134904bd6SDaniele Ceraolo Spurio return;
86234904bd6SDaniele Ceraolo Spurio }
86334904bd6SDaniele Ceraolo Spurio
86434904bd6SDaniele Ceraolo Spurio if (!intel_guc_is_wanted(guc)) {
86534904bd6SDaniele Ceraolo Spurio drm_printf(p, "GuC disabled\n");
86634904bd6SDaniele Ceraolo Spurio return;
86734904bd6SDaniele Ceraolo Spurio }
86834904bd6SDaniele Ceraolo Spurio
86934904bd6SDaniele Ceraolo Spurio intel_uc_fw_dump(&guc->fw, p);
87034904bd6SDaniele Ceraolo Spurio
87134904bd6SDaniele Ceraolo Spurio with_intel_runtime_pm(uncore->rpm, wakeref) {
87234904bd6SDaniele Ceraolo Spurio u32 status = intel_uncore_read(uncore, GUC_STATUS);
87334904bd6SDaniele Ceraolo Spurio u32 i;
87434904bd6SDaniele Ceraolo Spurio
875cc2e0cf0SJohn Harrison drm_printf(p, "GuC status 0x%08x:\n", status);
87634904bd6SDaniele Ceraolo Spurio drm_printf(p, "\tBootrom status = 0x%x\n",
87734904bd6SDaniele Ceraolo Spurio (status & GS_BOOTROM_MASK) >> GS_BOOTROM_SHIFT);
87834904bd6SDaniele Ceraolo Spurio drm_printf(p, "\tuKernel status = 0x%x\n",
87934904bd6SDaniele Ceraolo Spurio (status & GS_UKERNEL_MASK) >> GS_UKERNEL_SHIFT);
88034904bd6SDaniele Ceraolo Spurio drm_printf(p, "\tMIA Core status = 0x%x\n",
88134904bd6SDaniele Ceraolo Spurio (status & GS_MIA_MASK) >> GS_MIA_SHIFT);
882cc2e0cf0SJohn Harrison drm_puts(p, "Scratch registers:\n");
88334904bd6SDaniele Ceraolo Spurio for (i = 0; i < 16; i++) {
88434904bd6SDaniele Ceraolo Spurio drm_printf(p, "\t%2d: \t0x%x\n",
88534904bd6SDaniele Ceraolo Spurio i, intel_uncore_read(uncore, SOFT_SCRATCH(i)));
88634904bd6SDaniele Ceraolo Spurio }
88734904bd6SDaniele Ceraolo Spurio }
88834904bd6SDaniele Ceraolo Spurio }
8896b540bf6SMatthew Brost
intel_guc_write_barrier(struct intel_guc * guc)8906b540bf6SMatthew Brost void intel_guc_write_barrier(struct intel_guc *guc)
8916b540bf6SMatthew Brost {
8926b540bf6SMatthew Brost struct intel_gt *gt = guc_to_gt(guc);
8936b540bf6SMatthew Brost
8946b540bf6SMatthew Brost if (i915_gem_object_is_lmem(guc->ct.vma->obj)) {
8956b540bf6SMatthew Brost /*
8966b540bf6SMatthew Brost * Ensure intel_uncore_write_fw can be used rather than
8976b540bf6SMatthew Brost * intel_uncore_write.
8986b540bf6SMatthew Brost */
8996b540bf6SMatthew Brost GEM_BUG_ON(guc->send_regs.fw_domains);
9006b540bf6SMatthew Brost
9016b540bf6SMatthew Brost /*
9026b540bf6SMatthew Brost * This register is used by the i915 and GuC for MMIO based
9036b540bf6SMatthew Brost * communication. Once we are in this code CTBs are the only
9046b540bf6SMatthew Brost * method the i915 uses to communicate with the GuC so it is
9056b540bf6SMatthew Brost * safe to write to this register (a value of 0 is NOP for MMIO
9066b540bf6SMatthew Brost * communication). If we ever start mixing CTBs and MMIOs a new
9076b540bf6SMatthew Brost * register will have to be chosen. This function is also used
9086b540bf6SMatthew Brost * to enforce ordering of a work queue item write and an update
9096b540bf6SMatthew Brost * to the process descriptor. When a work queue is being used,
9106b540bf6SMatthew Brost * CTBs are also the only mechanism of communication.
9116b540bf6SMatthew Brost */
9126b540bf6SMatthew Brost intel_uncore_write_fw(gt->uncore, GEN11_SOFT_SCRATCH(0), 0);
9136b540bf6SMatthew Brost } else {
9146b540bf6SMatthew Brost /* wmb() sufficient for a barrier if in smem */
9156b540bf6SMatthew Brost wmb();
9166b540bf6SMatthew Brost }
9176b540bf6SMatthew Brost }
918