示例#1
0
int user_hwctx_set_save(struct user_hwctx *ctx,
                        ulong mem, u32 offset, u32 words, struct nvhost_reloc *reloc)
{
    struct mem_handle *buf;
    struct sg_table *sgt;
    void *page_addr;

    /* First the restore buffer is set, then the save buffer */
    if (!ctx->restore || !ctx->restore_sgt)
        return -EINVAL;

    buf = nvhost_memmgr_get(ctx->hwctx.memmgr,
                            mem, ctx->hwctx.channel->dev);
    if (IS_ERR(buf))
        return PTR_ERR(buf);

    sgt = nvhost_memmgr_pin(ctx->hwctx.memmgr, buf,
                            &ctx->hwctx.channel->dev->dev, mem_flag_none);
    if (IS_ERR(sgt))
        return PTR_ERR(sgt);

    ctx->save_offset = offset;
    ctx->save_size = words;
    ctx->save_buf = buf;
    ctx->save_sgt = sgt;

    /* Patch restore buffer address into save buffer */
    page_addr = nvhost_memmgr_kmap(ctx->save_buf,
                                   reloc->cmdbuf_offset >> PAGE_SHIFT);
    if (!page_addr)
        return -ENOMEM;

    __raw_writel(nvhost_memmgr_dma_addr(ctx->restore_sgt) + offset,
                 page_addr + (reloc->cmdbuf_offset & ~PAGE_MASK));
    nvhost_memmgr_kunmap(ctx->save_buf,
                         reloc->cmdbuf_offset >> PAGE_SHIFT,
                         page_addr);

    return 0;
}
示例#2
0
int user_hwctx_set_restore(struct user_hwctx *ctx,
                           ulong mem, u32 offset, u32 words)
{
    struct mem_handle *buf;
    struct sg_table *sgt;

    buf = nvhost_memmgr_get(ctx->hwctx.memmgr,
                            mem, ctx->hwctx.channel->dev);
    if (IS_ERR(buf))
        return PTR_ERR(buf);

    sgt = nvhost_memmgr_pin(ctx->hwctx.memmgr, buf,
                            &ctx->hwctx.channel->dev->dev, mem_flag_none);
    if (IS_ERR(sgt))
        return PTR_ERR(sgt);

    ctx->restore_offset = offset;
    ctx->restore_size = words;
    ctx->restore = buf;
    ctx->restore_sgt = sgt;

    return 0;
}
示例#3
0
int user_hwctx_set_restore(struct user_hwctx *ctx,
		u32 mem, u32 offset, u32 words)
{
	struct mem_handle *buf;
	struct sg_table *sgt;

	buf = nvhost_memmgr_get(ctx->hwctx.memmgr,
			mem, ctx->hwctx.channel->dev);
	if (IS_ERR_OR_NULL(buf))
		return -ENOMEM;

	sgt = nvhost_memmgr_pin(ctx->hwctx.memmgr, buf,
			&ctx->hwctx.channel->dev->dev);
	if (IS_ERR_OR_NULL(sgt))
		return -ENOMEM;

	ctx->restore_offset = offset;
	ctx->restore_size = words;
	ctx->restore = buf;
	ctx->restore_sgt = sgt;

	return 0;
}