예제 #1
0
파일: gem.c 프로젝트: 303750856/linux-3.1
void psb_gem_free_object(struct drm_gem_object *obj)
{
	struct gtt_range *gtt = container_of(obj, struct gtt_range, gem);
	drm_gem_object_release_wrap(obj);
	/* This must occur last as it frees up the memory of the GEM object */
	psb_gtt_free_range(obj->dev, gtt);
}
예제 #2
0
파일: gem.c 프로젝트: 03199618/linux
void psb_gem_free_object(struct drm_gem_object *obj)
{
	struct gtt_range *gtt = container_of(obj, struct gtt_range, gem);

	/* Remove the list map if one is present */
	drm_gem_free_mmap_offset(obj);
	drm_gem_object_release(obj);

	/* This must occur last as it frees up the memory of the GEM object */
	psb_gtt_free_range(obj->dev, gtt);
}
예제 #3
0
파일: gem.c 프로젝트: wx1183618058/m463
/**
 *	psb_gem_create		-	create a mappable object
 *	@file: the DRM file of the client
 *	@dev: our device
 *	@size: the size requested
 *	@handlep: returned handle (opaque number)
 *
 *	Create a GEM object, fill in the boilerplate and attach a handle to
 *	it so that userspace can speak about it. This does the core work
 *	for the various methods that do/will create GEM objects for things
 */
static int psb_gem_create(struct drm_file *file,
                          struct drm_device *dev, uint64_t size, uint32_t *handlep)
{
    struct gtt_range *r;
    int ret;
    u32 handle;

    size = roundup(size, PAGE_SIZE);

    /* Allocate our object - for now a direct gtt range which is not
       stolen memory backed */
    r = psb_gtt_alloc_range(dev, size, "gem", 0);
    if (r == NULL) {
        dev_err(dev->dev, "no memory for %lld byte GEM object\n", size);
        return -ENOSPC;
    }
    /* Initialize the extra goodies GEM needs to do all the hard work */
    if (drm_gem_object_init(dev, &r->gem, size) != 0) {
        psb_gtt_free_range(dev, r);
        /* GEM doesn't give an error code so use -ENOMEM */
        dev_err(dev->dev, "GEM init failed for %lld\n", size);
        return -ENOMEM;
    }
    /* Limit the object to 32bit mappings */
    mapping_set_gfp_mask(r->gem.filp->f_mapping, GFP_KERNEL | __GFP_DMA32);
    /* Give the object a handle so we can carry it more easily */
    ret = drm_gem_handle_create(file, &r->gem, &handle);
    if (ret) {
        dev_err(dev->dev, "GEM handle failed for %p, %lld\n",
                &r->gem, size);
        drm_gem_object_release(&r->gem);
        psb_gtt_free_range(dev, r);
        return ret;
    }
    /* We have the initial and handle reference but need only one now */
    drm_gem_object_unreference(&r->gem);
    *handlep = handle;
    return 0;
}
예제 #4
0
파일: gem.c 프로젝트: 303750856/linux-3.1
static int psb_gem_create_stolen(struct drm_file *file, struct drm_device *dev,
						int size, u32 *handle)
{
	struct gtt_range *gtt = psb_gtt_alloc_range(dev, size, "gem", 1);
	if (gtt == NULL)
		return -ENOMEM;
	if (drm_gem_private_object_init(dev, &gtt->gem, size) != 0)
		goto free_gtt;
	if (drm_gem_handle_create(file, &gtt->gem, handle) == 0)
		return 0;
free_gtt:
	psb_gtt_free_range(dev, gtt);
	return -ENOMEM;
}