示例#1
0
int gk20a_as_dev_open(struct inode *inode, struct file *filp)
{
	struct gk20a_as_share *as_share;
	struct gk20a *g;
	int err;

	gk20a_dbg_fn("");

	g = container_of(inode->i_cdev, struct gk20a, as.cdev);

	err = gk20a_get_client(g);
	if (err) {
		gk20a_dbg_fn("fail to get channel!");
		return err;
	}

	err = gk20a_as_alloc_share(&g->as, &as_share);
	if (err) {
		gk20a_dbg_fn("failed to alloc share");
		gk20a_put_client(g);
		return err;
	}

	filp->private_data = as_share;
	return 0;
}
示例#2
0
static int gk20a_ctrl_alloc_as(
		struct gk20a *g,
		struct nvgpu_alloc_as_args *args)
{
	struct platform_device *dev = g->dev;
	struct gk20a_as_share *as_share;
	int err;
	int fd;
	struct file *file;
	char *name;

	err = get_unused_fd_flags(O_RDWR);
	if (err < 0)
		return err;
	fd = err;

	name = kasprintf(GFP_KERNEL, "nvhost-%s-fd%d",
			dev_name(&dev->dev), fd);

	file = anon_inode_getfile(name, g->as.cdev.ops, NULL, O_RDWR);
	kfree(name);
	if (IS_ERR(file)) {
		err = PTR_ERR(file);
		goto clean_up;
	}
	fd_install(fd, file);

	err = gk20a_as_alloc_share(&g->as, args->big_page_size, &as_share);
	if (err)
		goto clean_up;

	file->private_data = as_share;

	args->as_fd = fd;
	return 0;

clean_up:
	put_unused_fd(fd);
	return err;
}