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

Commit e4433fd3 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: ocmem: Serialize allocation requests only when necessary"

parents a393d67e 95aa1e95
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;
}