int nvhost_job_pin(struct nvhost_job *job)
{
	int err = 0;

	/* pin mem handles and patch physical addresses */
	job->num_unpins = nvmap_pin_array(job->nvmap,
				nvmap_ref_to_handle(job->gather_mem),
				job->pinarray, job->num_pins,
				job->unpins);
	if (job->num_unpins < 0)
		err = job->num_unpins;

	return err;
}
Beispiel #2
0
int nvhost_nvmap_pin_array_ids(struct mem_mgr *mgr,
		u32 *ids,
		u32 id_type_mask,
		u32 id_type,
		u32 count,
		struct nvhost_job_unpin *unpin_data,
		dma_addr_t *phys_addr)
{
	int i;
	int result = 0;
	struct nvmap_handle **unique_handles;
	struct nvmap_handle_ref **unique_handle_refs;
	void *ptrs = kmalloc(sizeof(void *) * count * 2,
			GFP_KERNEL);

	if (!ptrs)
		return -ENOMEM;

	unique_handles = (struct nvmap_handle **) ptrs;
	unique_handle_refs = (struct nvmap_handle_ref **)
			&unique_handles[count];

	result = nvmap_pin_array((struct nvmap_client *)mgr,
		    (long unsigned *)ids, id_type_mask, id_type, count,
		    unique_handles,
		    unique_handle_refs);

	if (result < 0)
		goto fail;

	WARN_ON(result > count);

	for (i = 0; i < result; i++)
		unpin_data[i].h = (struct mem_handle *)unique_handle_refs[i];

	for (i = 0; i < count; i++) {
		if ((ids[i] & id_type_mask) == id_type)
			phys_addr[i] = (dma_addr_t)nvmap_get_addr_from_user_id(
								ids[i]);
	}

fail:
	kfree(ptrs);
	return result;
}