intel_guc.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. /*
  2. * Copyright © 2014-2017 Intel Corporation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice (including the next
  12. * paragraph) shall be included in all copies or substantial portions of the
  13. * Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  21. * IN THE SOFTWARE.
  22. *
  23. */
  24. #include "intel_guc.h"
  25. #include "intel_guc_ads.h"
  26. #include "intel_guc_submission.h"
  27. #include "i915_drv.h"
  28. static void gen8_guc_raise_irq(struct intel_guc *guc)
  29. {
  30. struct drm_i915_private *dev_priv = guc_to_i915(guc);
  31. I915_WRITE(GUC_SEND_INTERRUPT, GUC_SEND_TRIGGER);
  32. }
  33. static inline i915_reg_t guc_send_reg(struct intel_guc *guc, u32 i)
  34. {
  35. GEM_BUG_ON(!guc->send_regs.base);
  36. GEM_BUG_ON(!guc->send_regs.count);
  37. GEM_BUG_ON(i >= guc->send_regs.count);
  38. return _MMIO(guc->send_regs.base + 4 * i);
  39. }
  40. void intel_guc_init_send_regs(struct intel_guc *guc)
  41. {
  42. struct drm_i915_private *dev_priv = guc_to_i915(guc);
  43. enum forcewake_domains fw_domains = 0;
  44. unsigned int i;
  45. guc->send_regs.base = i915_mmio_reg_offset(SOFT_SCRATCH(0));
  46. guc->send_regs.count = SOFT_SCRATCH_COUNT - 1;
  47. for (i = 0; i < guc->send_regs.count; i++) {
  48. fw_domains |= intel_uncore_forcewake_for_reg(dev_priv,
  49. guc_send_reg(guc, i),
  50. FW_REG_READ | FW_REG_WRITE);
  51. }
  52. guc->send_regs.fw_domains = fw_domains;
  53. }
  54. void intel_guc_init_early(struct intel_guc *guc)
  55. {
  56. intel_guc_fw_init_early(guc);
  57. intel_guc_ct_init_early(&guc->ct);
  58. intel_guc_log_init_early(&guc->log);
  59. mutex_init(&guc->send_mutex);
  60. spin_lock_init(&guc->irq_lock);
  61. guc->send = intel_guc_send_nop;
  62. guc->notify = gen8_guc_raise_irq;
  63. }
  64. int intel_guc_init_wq(struct intel_guc *guc)
  65. {
  66. struct drm_i915_private *dev_priv = guc_to_i915(guc);
  67. /*
  68. * GuC log buffer flush work item has to do register access to
  69. * send the ack to GuC and this work item, if not synced before
  70. * suspend, can potentially get executed after the GFX device is
  71. * suspended.
  72. * By marking the WQ as freezable, we don't have to bother about
  73. * flushing of this work item from the suspend hooks, the pending
  74. * work item if any will be either executed before the suspend
  75. * or scheduled later on resume. This way the handling of work
  76. * item can be kept same between system suspend & rpm suspend.
  77. */
  78. guc->log.relay.flush_wq =
  79. alloc_ordered_workqueue("i915-guc_log",
  80. WQ_HIGHPRI | WQ_FREEZABLE);
  81. if (!guc->log.relay.flush_wq) {
  82. DRM_ERROR("Couldn't allocate workqueue for GuC log\n");
  83. return -ENOMEM;
  84. }
  85. /*
  86. * Even though both sending GuC action, and adding a new workitem to
  87. * GuC workqueue are serialized (each with its own locking), since
  88. * we're using mutliple engines, it's possible that we're going to
  89. * issue a preempt request with two (or more - each for different
  90. * engine) workitems in GuC queue. In this situation, GuC may submit
  91. * all of them, which will make us very confused.
  92. * Our preemption contexts may even already be complete - before we
  93. * even had the chance to sent the preempt action to GuC!. Rather
  94. * than introducing yet another lock, we can just use ordered workqueue
  95. * to make sure we're always sending a single preemption request with a
  96. * single workitem.
  97. */
  98. if (HAS_LOGICAL_RING_PREEMPTION(dev_priv) &&
  99. USES_GUC_SUBMISSION(dev_priv)) {
  100. guc->preempt_wq = alloc_ordered_workqueue("i915-guc_preempt",
  101. WQ_HIGHPRI);
  102. if (!guc->preempt_wq) {
  103. destroy_workqueue(guc->log.relay.flush_wq);
  104. DRM_ERROR("Couldn't allocate workqueue for GuC "
  105. "preemption\n");
  106. return -ENOMEM;
  107. }
  108. }
  109. return 0;
  110. }
  111. void intel_guc_fini_wq(struct intel_guc *guc)
  112. {
  113. struct drm_i915_private *dev_priv = guc_to_i915(guc);
  114. if (HAS_LOGICAL_RING_PREEMPTION(dev_priv) &&
  115. USES_GUC_SUBMISSION(dev_priv))
  116. destroy_workqueue(guc->preempt_wq);
  117. destroy_workqueue(guc->log.relay.flush_wq);
  118. }
  119. static int guc_shared_data_create(struct intel_guc *guc)
  120. {
  121. struct i915_vma *vma;
  122. void *vaddr;
  123. vma = intel_guc_allocate_vma(guc, PAGE_SIZE);
  124. if (IS_ERR(vma))
  125. return PTR_ERR(vma);
  126. vaddr = i915_gem_object_pin_map(vma->obj, I915_MAP_WB);
  127. if (IS_ERR(vaddr)) {
  128. i915_vma_unpin_and_release(&vma);
  129. return PTR_ERR(vaddr);
  130. }
  131. guc->shared_data = vma;
  132. guc->shared_data_vaddr = vaddr;
  133. return 0;
  134. }
  135. static void guc_shared_data_destroy(struct intel_guc *guc)
  136. {
  137. i915_gem_object_unpin_map(guc->shared_data->obj);
  138. i915_vma_unpin_and_release(&guc->shared_data);
  139. }
  140. int intel_guc_init(struct intel_guc *guc)
  141. {
  142. struct drm_i915_private *dev_priv = guc_to_i915(guc);
  143. int ret;
  144. ret = guc_shared_data_create(guc);
  145. if (ret)
  146. return ret;
  147. GEM_BUG_ON(!guc->shared_data);
  148. ret = intel_guc_log_create(&guc->log);
  149. if (ret)
  150. goto err_shared;
  151. ret = intel_guc_ads_create(guc);
  152. if (ret)
  153. goto err_log;
  154. GEM_BUG_ON(!guc->ads_vma);
  155. /* We need to notify the guc whenever we change the GGTT */
  156. i915_ggtt_enable_guc(dev_priv);
  157. return 0;
  158. err_log:
  159. intel_guc_log_destroy(&guc->log);
  160. err_shared:
  161. guc_shared_data_destroy(guc);
  162. return ret;
  163. }
  164. void intel_guc_fini(struct intel_guc *guc)
  165. {
  166. struct drm_i915_private *dev_priv = guc_to_i915(guc);
  167. i915_ggtt_disable_guc(dev_priv);
  168. intel_guc_ads_destroy(guc);
  169. intel_guc_log_destroy(&guc->log);
  170. guc_shared_data_destroy(guc);
  171. }
  172. static u32 get_gt_type(struct drm_i915_private *dev_priv)
  173. {
  174. /* XXX: GT type based on PCI device ID? field seems unused by fw */
  175. return 0;
  176. }
  177. static u32 get_core_family(struct drm_i915_private *dev_priv)
  178. {
  179. u32 gen = INTEL_GEN(dev_priv);
  180. switch (gen) {
  181. case 9:
  182. return GUC_CORE_FAMILY_GEN9;
  183. default:
  184. MISSING_CASE(gen);
  185. return GUC_CORE_FAMILY_UNKNOWN;
  186. }
  187. }
  188. static u32 get_log_control_flags(void)
  189. {
  190. u32 level = i915_modparams.guc_log_level;
  191. u32 flags = 0;
  192. GEM_BUG_ON(level < 0);
  193. if (!GUC_LOG_LEVEL_IS_ENABLED(level))
  194. flags |= GUC_LOG_DEFAULT_DISABLED;
  195. if (!GUC_LOG_LEVEL_IS_VERBOSE(level))
  196. flags |= GUC_LOG_DISABLED;
  197. else
  198. flags |= GUC_LOG_LEVEL_TO_VERBOSITY(level) <<
  199. GUC_LOG_VERBOSITY_SHIFT;
  200. return flags;
  201. }
  202. /*
  203. * Initialise the GuC parameter block before starting the firmware
  204. * transfer. These parameters are read by the firmware on startup
  205. * and cannot be changed thereafter.
  206. */
  207. void intel_guc_init_params(struct intel_guc *guc)
  208. {
  209. struct drm_i915_private *dev_priv = guc_to_i915(guc);
  210. u32 params[GUC_CTL_MAX_DWORDS];
  211. int i;
  212. memset(params, 0, sizeof(params));
  213. params[GUC_CTL_DEVICE_INFO] |=
  214. (get_gt_type(dev_priv) << GUC_CTL_GT_TYPE_SHIFT) |
  215. (get_core_family(dev_priv) << GUC_CTL_CORE_FAMILY_SHIFT);
  216. /*
  217. * GuC ARAT increment is 10 ns. GuC default scheduler quantum is one
  218. * second. This ARAR is calculated by:
  219. * Scheduler-Quantum-in-ns / ARAT-increment-in-ns = 1000000000 / 10
  220. */
  221. params[GUC_CTL_ARAT_HIGH] = 0;
  222. params[GUC_CTL_ARAT_LOW] = 100000000;
  223. params[GUC_CTL_WA] |= GUC_CTL_WA_UK_BY_DRIVER;
  224. params[GUC_CTL_FEATURE] |= GUC_CTL_DISABLE_SCHEDULER |
  225. GUC_CTL_VCS2_ENABLED;
  226. params[GUC_CTL_LOG_PARAMS] = guc->log.flags;
  227. params[GUC_CTL_DEBUG] = get_log_control_flags();
  228. /* If GuC submission is enabled, set up additional parameters here */
  229. if (USES_GUC_SUBMISSION(dev_priv)) {
  230. u32 ads = intel_guc_ggtt_offset(guc,
  231. guc->ads_vma) >> PAGE_SHIFT;
  232. u32 pgs = intel_guc_ggtt_offset(guc, guc->stage_desc_pool);
  233. u32 ctx_in_16 = GUC_MAX_STAGE_DESCRIPTORS / 16;
  234. params[GUC_CTL_DEBUG] |= ads << GUC_ADS_ADDR_SHIFT;
  235. params[GUC_CTL_DEBUG] |= GUC_ADS_ENABLED;
  236. pgs >>= PAGE_SHIFT;
  237. params[GUC_CTL_CTXINFO] = (pgs << GUC_CTL_BASE_ADDR_SHIFT) |
  238. (ctx_in_16 << GUC_CTL_CTXNUM_IN16_SHIFT);
  239. params[GUC_CTL_FEATURE] |= GUC_CTL_KERNEL_SUBMISSIONS;
  240. /* Unmask this bit to enable the GuC's internal scheduler */
  241. params[GUC_CTL_FEATURE] &= ~GUC_CTL_DISABLE_SCHEDULER;
  242. }
  243. /*
  244. * All SOFT_SCRATCH registers are in FORCEWAKE_BLITTER domain and
  245. * they are power context saved so it's ok to release forcewake
  246. * when we are done here and take it again at xfer time.
  247. */
  248. intel_uncore_forcewake_get(dev_priv, FORCEWAKE_BLITTER);
  249. I915_WRITE(SOFT_SCRATCH(0), 0);
  250. for (i = 0; i < GUC_CTL_MAX_DWORDS; i++)
  251. I915_WRITE(SOFT_SCRATCH(1 + i), params[i]);
  252. intel_uncore_forcewake_put(dev_priv, FORCEWAKE_BLITTER);
  253. }
  254. int intel_guc_send_nop(struct intel_guc *guc, const u32 *action, u32 len)
  255. {
  256. WARN(1, "Unexpected send: action=%#x\n", *action);
  257. return -ENODEV;
  258. }
  259. /*
  260. * This function implements the MMIO based host to GuC interface.
  261. */
  262. int intel_guc_send_mmio(struct intel_guc *guc, const u32 *action, u32 len)
  263. {
  264. struct drm_i915_private *dev_priv = guc_to_i915(guc);
  265. u32 status;
  266. int i;
  267. int ret;
  268. GEM_BUG_ON(!len);
  269. GEM_BUG_ON(len > guc->send_regs.count);
  270. /* If CT is available, we expect to use MMIO only during init/fini */
  271. GEM_BUG_ON(HAS_GUC_CT(dev_priv) &&
  272. *action != INTEL_GUC_ACTION_REGISTER_COMMAND_TRANSPORT_BUFFER &&
  273. *action != INTEL_GUC_ACTION_DEREGISTER_COMMAND_TRANSPORT_BUFFER);
  274. mutex_lock(&guc->send_mutex);
  275. intel_uncore_forcewake_get(dev_priv, guc->send_regs.fw_domains);
  276. for (i = 0; i < len; i++)
  277. I915_WRITE(guc_send_reg(guc, i), action[i]);
  278. POSTING_READ(guc_send_reg(guc, i - 1));
  279. intel_guc_notify(guc);
  280. /*
  281. * No GuC command should ever take longer than 10ms.
  282. * Fast commands should still complete in 10us.
  283. */
  284. ret = __intel_wait_for_register_fw(dev_priv,
  285. guc_send_reg(guc, 0),
  286. INTEL_GUC_RECV_MASK,
  287. INTEL_GUC_RECV_MASK,
  288. 10, 10, &status);
  289. if (status != INTEL_GUC_STATUS_SUCCESS) {
  290. /*
  291. * Either the GuC explicitly returned an error (which
  292. * we convert to -EIO here) or no response at all was
  293. * received within the timeout limit (-ETIMEDOUT)
  294. */
  295. if (ret != -ETIMEDOUT)
  296. ret = -EIO;
  297. DRM_DEBUG_DRIVER("INTEL_GUC_SEND: Action 0x%X failed;"
  298. " ret=%d status=0x%08X response=0x%08X\n",
  299. action[0], ret, status,
  300. I915_READ(SOFT_SCRATCH(15)));
  301. }
  302. intel_uncore_forcewake_put(dev_priv, guc->send_regs.fw_domains);
  303. mutex_unlock(&guc->send_mutex);
  304. return ret;
  305. }
  306. void intel_guc_to_host_event_handler(struct intel_guc *guc)
  307. {
  308. struct drm_i915_private *dev_priv = guc_to_i915(guc);
  309. u32 msg, val;
  310. /*
  311. * Sample the log buffer flush related bits & clear them out now
  312. * itself from the message identity register to minimize the
  313. * probability of losing a flush interrupt, when there are back
  314. * to back flush interrupts.
  315. * There can be a new flush interrupt, for different log buffer
  316. * type (like for ISR), whilst Host is handling one (for DPC).
  317. * Since same bit is used in message register for ISR & DPC, it
  318. * could happen that GuC sets the bit for 2nd interrupt but Host
  319. * clears out the bit on handling the 1st interrupt.
  320. */
  321. spin_lock(&guc->irq_lock);
  322. val = I915_READ(SOFT_SCRATCH(15));
  323. msg = val & guc->msg_enabled_mask;
  324. I915_WRITE(SOFT_SCRATCH(15), val & ~msg);
  325. spin_unlock(&guc->irq_lock);
  326. if (msg & (INTEL_GUC_RECV_MSG_FLUSH_LOG_BUFFER |
  327. INTEL_GUC_RECV_MSG_CRASH_DUMP_POSTED))
  328. queue_work(guc->log.relay.flush_wq,
  329. &guc->log.relay.flush_work);
  330. }
  331. int intel_guc_sample_forcewake(struct intel_guc *guc)
  332. {
  333. struct drm_i915_private *dev_priv = guc_to_i915(guc);
  334. u32 action[2];
  335. action[0] = INTEL_GUC_ACTION_SAMPLE_FORCEWAKE;
  336. /* WaRsDisableCoarsePowerGating:skl,cnl */
  337. if (!HAS_RC6(dev_priv) || NEEDS_WaRsDisableCoarsePowerGating(dev_priv))
  338. action[1] = 0;
  339. else
  340. /* bit 0 and 1 are for Render and Media domain separately */
  341. action[1] = GUC_FORCEWAKE_RENDER | GUC_FORCEWAKE_MEDIA;
  342. return intel_guc_send(guc, action, ARRAY_SIZE(action));
  343. }
  344. /**
  345. * intel_guc_auth_huc() - Send action to GuC to authenticate HuC ucode
  346. * @guc: intel_guc structure
  347. * @rsa_offset: rsa offset w.r.t ggtt base of huc vma
  348. *
  349. * Triggers a HuC firmware authentication request to the GuC via intel_guc_send
  350. * INTEL_GUC_ACTION_AUTHENTICATE_HUC interface. This function is invoked by
  351. * intel_huc_auth().
  352. *
  353. * Return: non-zero code on error
  354. */
  355. int intel_guc_auth_huc(struct intel_guc *guc, u32 rsa_offset)
  356. {
  357. u32 action[] = {
  358. INTEL_GUC_ACTION_AUTHENTICATE_HUC,
  359. rsa_offset
  360. };
  361. return intel_guc_send(guc, action, ARRAY_SIZE(action));
  362. }
  363. /**
  364. * intel_guc_suspend() - notify GuC entering suspend state
  365. * @guc: the guc
  366. */
  367. int intel_guc_suspend(struct intel_guc *guc)
  368. {
  369. u32 data[] = {
  370. INTEL_GUC_ACTION_ENTER_S_STATE,
  371. GUC_POWER_D1, /* any value greater than GUC_POWER_D0 */
  372. intel_guc_ggtt_offset(guc, guc->shared_data)
  373. };
  374. return intel_guc_send(guc, data, ARRAY_SIZE(data));
  375. }
  376. /**
  377. * intel_guc_reset_engine() - ask GuC to reset an engine
  378. * @guc: intel_guc structure
  379. * @engine: engine to be reset
  380. */
  381. int intel_guc_reset_engine(struct intel_guc *guc,
  382. struct intel_engine_cs *engine)
  383. {
  384. u32 data[7];
  385. GEM_BUG_ON(!guc->execbuf_client);
  386. data[0] = INTEL_GUC_ACTION_REQUEST_ENGINE_RESET;
  387. data[1] = engine->guc_id;
  388. data[2] = 0;
  389. data[3] = 0;
  390. data[4] = 0;
  391. data[5] = guc->execbuf_client->stage_id;
  392. data[6] = intel_guc_ggtt_offset(guc, guc->shared_data);
  393. return intel_guc_send(guc, data, ARRAY_SIZE(data));
  394. }
  395. /**
  396. * intel_guc_resume() - notify GuC resuming from suspend state
  397. * @guc: the guc
  398. */
  399. int intel_guc_resume(struct intel_guc *guc)
  400. {
  401. u32 data[] = {
  402. INTEL_GUC_ACTION_EXIT_S_STATE,
  403. GUC_POWER_D0,
  404. intel_guc_ggtt_offset(guc, guc->shared_data)
  405. };
  406. return intel_guc_send(guc, data, ARRAY_SIZE(data));
  407. }
  408. /**
  409. * DOC: GuC Address Space
  410. *
  411. * The layout of GuC address space is shown as below:
  412. *
  413. * +==============> +====================+ <== GUC_GGTT_TOP
  414. * ^ | |
  415. * | | |
  416. * | | DRAM |
  417. * | | Memory |
  418. * | | |
  419. * GuC | |
  420. * Address +========> +====================+ <== WOPCM Top
  421. * Space ^ | HW contexts RSVD |
  422. * | | | WOPCM |
  423. * | | +==> +--------------------+ <== GuC WOPCM Top
  424. * | GuC ^ | |
  425. * | GGTT | | |
  426. * | Pin GuC | GuC |
  427. * | Bias WOPCM | WOPCM |
  428. * | | Size | |
  429. * | | | | |
  430. * v v v | |
  431. * +=====+=====+==> +====================+ <== GuC WOPCM Base
  432. * | Non-GuC WOPCM |
  433. * | (HuC/Reserved) |
  434. * +====================+ <== WOPCM Base
  435. *
  436. * The lower part [0, GuC ggtt_pin_bias) is mapped to WOPCM which consists of
  437. * GuC WOPCM and WOPCM reserved for other usage (e.g.RC6 context). The value of
  438. * the GuC ggtt_pin_bias is determined by the actually GuC WOPCM size which is
  439. * set in GUC_WOPCM_SIZE register.
  440. */
  441. /**
  442. * intel_guc_init_ggtt_pin_bias() - Initialize the GuC ggtt_pin_bias value.
  443. * @guc: intel_guc structure.
  444. *
  445. * This function will calculate and initialize the ggtt_pin_bias value based on
  446. * overall WOPCM size and GuC WOPCM size.
  447. */
  448. void intel_guc_init_ggtt_pin_bias(struct intel_guc *guc)
  449. {
  450. struct drm_i915_private *i915 = guc_to_i915(guc);
  451. GEM_BUG_ON(!i915->wopcm.size);
  452. GEM_BUG_ON(i915->wopcm.size < i915->wopcm.guc.base);
  453. guc->ggtt_pin_bias = i915->wopcm.size - i915->wopcm.guc.base;
  454. }
  455. /**
  456. * intel_guc_allocate_vma() - Allocate a GGTT VMA for GuC usage
  457. * @guc: the guc
  458. * @size: size of area to allocate (both virtual space and memory)
  459. *
  460. * This is a wrapper to create an object for use with the GuC. In order to
  461. * use it inside the GuC, an object needs to be pinned lifetime, so we allocate
  462. * both some backing storage and a range inside the Global GTT. We must pin
  463. * it in the GGTT somewhere other than than [0, GUC ggtt_pin_bias) because that
  464. * range is reserved inside GuC.
  465. *
  466. * Return: A i915_vma if successful, otherwise an ERR_PTR.
  467. */
  468. struct i915_vma *intel_guc_allocate_vma(struct intel_guc *guc, u32 size)
  469. {
  470. struct drm_i915_private *dev_priv = guc_to_i915(guc);
  471. struct drm_i915_gem_object *obj;
  472. struct i915_vma *vma;
  473. int ret;
  474. obj = i915_gem_object_create(dev_priv, size);
  475. if (IS_ERR(obj))
  476. return ERR_CAST(obj);
  477. vma = i915_vma_instance(obj, &dev_priv->ggtt.base, NULL);
  478. if (IS_ERR(vma))
  479. goto err;
  480. ret = i915_vma_pin(vma, 0, PAGE_SIZE,
  481. PIN_GLOBAL | PIN_OFFSET_BIAS | guc->ggtt_pin_bias);
  482. if (ret) {
  483. vma = ERR_PTR(ret);
  484. goto err;
  485. }
  486. return vma;
  487. err:
  488. i915_gem_object_put(obj);
  489. return vma;
  490. }