int qxl_gem_object_create(struct qxl_device *qdev, int size, int alignment, int initial_domain, bool discardable, bool kernel, struct qxl_surface *surf, struct drm_gem_object **obj) { struct qxl_bo *qbo; int r; *obj = NULL; /* At least align on page size */ if (alignment < PAGE_SIZE) alignment = PAGE_SIZE; r = qxl_bo_create(qdev, size, kernel, false, initial_domain, surf, &qbo); if (r) { if (r != -ERESTARTSYS) DRM_ERROR( "Failed to allocate GEM object (%d, %d, %u, %d)\n", size, initial_domain, alignment, r); return r; } *obj = &qbo->gem_base; mutex_lock(&qdev->gem.mutex); list_add_tail(&qbo->list, &qdev->gem.objects); mutex_unlock(&qdev->gem.mutex); return 0; }
int qxl_alloc_bo_reserved(struct qxl_device *qdev, unsigned long size, struct qxl_bo **_bo) { struct qxl_bo *bo; int ret; ret = qxl_bo_create(qdev, size, false /* not kernel - device */, QXL_GEM_DOMAIN_VRAM, NULL, &bo); if (ret) { DRM_ERROR("failed to allocate VRAM BO\n"); return ret; } ret = qxl_bo_reserve(bo, false); if (unlikely(ret != 0)) goto out_unref; *_bo = bo; return 0; out_unref: qxl_bo_unref(&bo); return 0; }