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

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

Merge "memshare: Perform Hypervisor mapping for boot-time allotted memory"

parents b21f2ab9 5de9d8e1
Loading
Loading
Loading
Loading
+16 −7
Original line number Original line Diff line number Diff line
@@ -495,6 +495,7 @@ static int handle_alloc_generic_req(void *req_h, void *req, void *conn_h)
	struct mem_alloc_generic_resp_msg_v01 *alloc_resp;
	struct mem_alloc_generic_resp_msg_v01 *alloc_resp;
	int rc, resp = 0;
	int rc, resp = 0;
	int client_id;
	int client_id;
	uint32_t size = 0;


	mutex_lock(&memsh_drv->mem_share);
	mutex_lock(&memsh_drv->mem_share);
	alloc_req = (struct mem_alloc_generic_req_msg_v01 *)req;
	alloc_req = (struct mem_alloc_generic_req_msg_v01 *)req;
@@ -521,12 +522,12 @@ static int handle_alloc_generic_req(void *req_h, void *req, void *conn_h)
		return -EINVAL;
		return -EINVAL;
	}
	}


	memblock[client_id].free_memory += 1;
	pr_debug("memshare: %s, free memory count for client id: %d = %d",
		__func__, memblock[client_id].client_id,
			memblock[client_id].free_memory);
	if (!memblock[client_id].allotted) {
	if (!memblock[client_id].allotted) {
		rc = memshare_alloc(memsh_drv->dev, alloc_req->num_bytes,
		if (alloc_req->client_id == 1 && alloc_req->num_bytes > 0)
			size = alloc_req->num_bytes + MEMSHARE_GUARD_BYTES;
		else
			size = alloc_req->num_bytes;
		rc = memshare_alloc(memsh_drv->dev, size,
					&memblock[client_id]);
					&memblock[client_id]);
		if (rc) {
		if (rc) {
			pr_err("memshare: %s,Unable to allocate memory for requested client\n",
			pr_err("memshare: %s,Unable to allocate memory for requested client\n",
@@ -534,11 +535,16 @@ static int handle_alloc_generic_req(void *req_h, void *req, void *conn_h)
			resp = 1;
			resp = 1;
		}
		}
		if (!resp) {
		if (!resp) {
			memblock[client_id].free_memory += 1;
			memblock[client_id].allotted = 1;
			memblock[client_id].allotted = 1;
			memblock[client_id].size = alloc_req->num_bytes;
			memblock[client_id].size = alloc_req->num_bytes;
			memblock[client_id].peripheral = alloc_req->proc_id;
			memblock[client_id].peripheral = alloc_req->proc_id;
		}
		}
	}
	}
	pr_debug("memshare: In %s, free memory count for client id: %d = %d",
		__func__, memblock[client_id].client_id,
		memblock[client_id].free_memory);

	memblock[client_id].sequence_id = alloc_req->sequence_id;
	memblock[client_id].sequence_id = alloc_req->sequence_id;


	fill_alloc_response(alloc_resp, client_id, &resp);
	fill_alloc_response(alloc_resp, client_id, &resp);
@@ -941,9 +947,11 @@ static int memshare_child_probe(struct platform_device *pdev)
  /*
  /*
   *	Memshare allocation for guaranteed clients
   *	Memshare allocation for guaranteed clients
   */
   */
	if (memblock[num_clients].guarantee) {
	if (memblock[num_clients].guarantee && size > 0) {
		if (client_id == 1)
			size += MEMSHARE_GUARD_BYTES;
		rc = memshare_alloc(memsh_child->dev,
		rc = memshare_alloc(memsh_child->dev,
				memblock[num_clients].size,
				size,
				&memblock[num_clients]);
				&memblock[num_clients]);
		if (rc) {
		if (rc) {
			pr_err("memshare: %s, Unable to allocate memory for guaranteed clients, rc: %d\n",
			pr_err("memshare: %s, Unable to allocate memory for guaranteed clients, rc: %d\n",
@@ -951,6 +959,7 @@ static int memshare_child_probe(struct platform_device *pdev)
			return rc;
			return rc;
		}
		}
		memblock[num_clients].allotted = 1;
		memblock[num_clients].allotted = 1;
		shared_hyp_mapping(num_clients);
	}
	}


	/*
	/*
+1 −0
Original line number Original line Diff line number Diff line
@@ -24,6 +24,7 @@
#define GPS	0
#define GPS	0
#define CHECK	0
#define CHECK	0
#define FREE	1
#define FREE	1
#define MEMSHARE_GUARD_BYTES	(4*1024)


struct mem_blocks {
struct mem_blocks {
	/* Client Id information */
	/* Client Id information */