Example #1
0
struct ocmem_buf *ocmem_allocate_nb(int client_id, unsigned long size)
{
	bool can_block = true;
	bool can_wait = false;

	if (!check_id(client_id)) {
		pr_err("ocmem: Invalid client id: %d\n", client_id);
		return NULL;
	}

	/* Asynchronous API requires notifier registration */
	if (!check_notifier(client_id)) {
		pr_err("ocmem: No notifier registered for client %d\n",
				client_id);
		return NULL;
	}

	if (size < OCMEM_MIN_ALLOC) {
		pr_err("ocmem: requested size %lx must be at least %x\n",
				size, OCMEM_MIN_ALLOC);
		return NULL;
	}

	if (!IS_ALIGNED(size, OCMEM_MIN_ALIGN)) {
		pr_err("ocmem: Invalid alignment, args must be %x aligned\n",
				OCMEM_MIN_ALIGN);
		return NULL;
	}

	return __ocmem_allocate_range(client_id, 0, size, size,
						can_block, can_wait);

}
Example #2
0
int ocmem_map(int client_id, struct ocmem_buf *buffer,
			struct ocmem_map_list *list)
{
	int ret = 0;
	struct ocmem_handle *handle = NULL;

	if (!check_id(client_id)) {
		pr_err("ocmem: Invalid client id: %d\n", client_id);
		return -EINVAL;
	}

	if (!zone_active(client_id)) {
		pr_err("ocmem: Client id: %s (id: %d) not allowed to use OCMEM\n",
					get_name(client_id), client_id);
		return -EINVAL;
	}

	/* Asynchronous API requires notifier registration */
	if (!check_notifier(client_id)) {
		pr_err("ocmem: No notifier registered for client %d\n",
				client_id);
		return -EINVAL;
	}

	if (!buffer) {
		pr_err("ocmem: Invalid buffer\n");
		return -EINVAL;
	}

	if (pre_validate_chunk_list(list) != 0)
		return -EINVAL;

	handle = buffer_to_handle(buffer);

	if (!handle)
		return -EINVAL;

	mutex_lock(&handle->handle_mutex);
	ret = process_xfer(client_id, handle, list, TO_OCMEM);
	mutex_unlock(&handle->handle_mutex);
	return ret;
}
Example #3
0
struct ocmem_buf *ocmem_allocate_range(int client_id, unsigned long min,
		unsigned long goal, unsigned long step)
{
	bool can_block = true;
	bool can_wait = false;

	if (!check_id(client_id)) {
		pr_err("ocmem: Invalid client id: %d\n", client_id);
		return NULL;
	}

	if (!zone_active(client_id)) {
		pr_err("ocmem: Client %s (id: %d) not allowed to use OCMEM\n",
					get_name(client_id), client_id);
		return NULL;
	}

	/* Asynchronous API requires notifier registration */
	if (!check_notifier(client_id)) {
		pr_err("ocmem: No notifier registered for client %d\n",
				client_id);
		return NULL;
	}

	if (min < OCMEM_MIN_ALLOC) {
		pr_err("ocmem: requested min size %lx must be at least %x\n",
				min, OCMEM_MIN_ALLOC);
		return NULL;
	}

	if (!IS_ALIGNED(min | goal | step, OCMEM_MIN_ALIGN)) {
		pr_err("ocmem: Invalid alignment, args must be %x aligned\n",
				OCMEM_MIN_ALIGN);
		return NULL;
	}

	return __ocmem_allocate_range(client_id, min, goal,
				step, can_block, can_wait);
}