i915_vma_create(struct drm_i915_gem_object *obj,
struct i915_address_space *vm,
const struct i915_ggtt_view *view);
+void i915_vma_unpin_and_release(struct i915_vma **p_vma);
static inline bool i915_vma_is_ggtt(const struct i915_vma *vma)
{
return vma;
}
-/**
- * guc_release_vma() - Release gem object allocated for GuC usage
- * @vma: gem obj to be released
- */
-static void guc_release_vma(struct i915_vma *vma)
-{
- if (!vma)
- return;
-
- i915_vma_unpin(vma);
- i915_vma_put(vma);
-}
-
static void
guc_client_free(struct drm_i915_private *dev_priv,
struct i915_guc_client *client)
kunmap(kmap_to_page(client->client_base));
}
- guc_release_vma(client->vma);
+ i915_vma_unpin_and_release(&client->vma);
if (client->ctx_index != GUC_INVALID_CTX_ID) {
guc_fini_ctx_desc(guc, client);
{
struct intel_guc *guc = &dev_priv->guc;
- guc_release_vma(fetch_and_zero(&guc->ads_vma));
- guc_release_vma(fetch_and_zero(&guc->log_vma));
+ i915_vma_unpin_and_release(&guc->ads_vma);
+ i915_vma_unpin_and_release(&guc->log_vma);
if (guc->ctx_pool_vma)
ida_destroy(&guc->ctx_ids);
- guc_release_vma(fetch_and_zero(&guc->ctx_pool_vma));
+ i915_vma_unpin_and_release(&guc->ctx_pool_vma);
}
/**
static void lrc_destroy_wa_ctx_obj(struct intel_engine_cs *engine)
{
- struct i915_vma *vma;
-
- vma = fetch_and_zero(&engine->wa_ctx.vma);
- if (!vma)
- return;
-
- i915_vma_unpin(vma);
- i915_vma_put(vma);
+ i915_vma_unpin_and_release(&engine->wa_ctx.vma);
}
static int intel_init_workaround_bb(struct intel_engine_cs *engine)
static void render_ring_cleanup(struct intel_engine_cs *engine)
{
struct drm_i915_private *dev_priv = engine->i915;
- struct i915_vma *vma;
-
- vma = fetch_and_zero(&dev_priv->semaphore);
- if (!vma)
- return;
- i915_vma_unpin(vma);
- i915_vma_put(vma);
+ i915_vma_unpin_and_release(&dev_priv->semaphore);
}
static int gen8_rcs_signal(struct drm_i915_gem_request *req)