Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 95aa1e95 authored by Naveen Ramaraj's avatar Naveen Ramaraj Committed by Neeti Desai
Browse files

msm: ocmem: Serialize allocation requests only when necessary



Certain clients of ocmem always have exclusive regions set aside in
the OCMEM memory map. Allocation requests for such clients do not
have to wait for any pending evictions in progress to be completed
nor will trigger any new evictions and can be safely scheduled right
away.

CRs-Fixed: 599002
Change-Id: I54369bca9d26378a9aa70db83d35ab94866a3ff1
Signed-off-by: default avatarNaveen Ramaraj <nramaraj@codeaurora.org>
Signed-off-by: default avatarNeeti Desai <neetid@codeaurora.org>
parent 7198e5fb
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -2095,7 +2095,6 @@ static int do_allocate(struct ocmem_req *req, bool can_block, bool can_wait)

	down_write(&req->rw_sem);

	mutex_lock(&allocation_mutex);
retry_allocate:

	/* Take the scheduler mutex */
@@ -2105,12 +2104,14 @@ retry_allocate:

	if (rc == OP_EVICT) {

		mutex_lock(&allocation_mutex);
		ret = run_evict(req);

		if (ret == 0) {
			rc = sched_restore(req);
			if (rc < 0) {
				pr_err("Failed to restore for req %p\n", req);
				mutex_unlock(&allocation_mutex);
				goto err_allocate_fail;
			}
			req->edata = NULL;
@@ -2118,14 +2119,14 @@ retry_allocate:
			pr_debug("Attempting to re-allocate req %p\n", req);
			req->req_start = 0x0;
			req->req_end = 0x0;
			mutex_unlock(&allocation_mutex);
			goto retry_allocate;
		} else {
			mutex_unlock(&allocation_mutex);
			goto err_allocate_fail;
		}
	}

	mutex_unlock(&allocation_mutex);

	if (rc == OP_FAIL) {
		inc_ocmem_stat(zone_of(req), NR_ALLOCATION_FAILS);
		goto err_allocate_fail;
@@ -2150,7 +2151,6 @@ retry_allocate:
	up_write(&req->rw_sem);
	return 0;
err_allocate_fail:
	mutex_unlock(&allocation_mutex);
	up_write(&req->rw_sem);
	return -EINVAL;
}