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

Commit 094a2b6e authored by Manoj Prabhu B's avatar Manoj Prabhu B Committed by Gerrit - the friendly Code Review server
Browse files

memshare: Conditional free the clients allotted memory



The patch adds an additional check to not free the clients memory
if the client has a designated property of allocate-on-request.

Change-Id: Iecf5886034ccd052ab82fff18cc66f1868604284
Signed-off-by: default avatarManoj Prabhu B <bmanoj@codeaurora.org>
parent e46bc1b0
Loading
Loading
Loading
Loading
+11 −8
Original line number Diff line number Diff line
/* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2013-2018, 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
@@ -375,6 +375,7 @@ static int modem_notifier_cb(struct notifier_block *this, unsigned long code,
				if (memblock[i].peripheral ==
					DHMS_MEM_PROC_MPSS_V01 &&
					!memblock[i].guarantee &&
					!memblock[i].client_request &&
					memblock[i].alloted) {
					pr_debug("memshare: Freeing memory for client id: %d\n",
						memblock[i].client_id);
@@ -630,12 +631,10 @@ static int handle_free_generic_req(void *req_h, void *req, void *conn_h)
					__func__);
		flag = 1;
	} else if (!memblock[client_id].guarantee &&
				memblock[client_id].client_request &&
					memblock[client_id].alloted) {
		pr_debug("In %s: pblk->virtual_addr :%lx, pblk->phy_addr: %lx\n,size: %d",
				__func__,
				(unsigned long int)
				memblock[client_id].virtual_addr,
				(unsigned long int)memblock[client_id].phy_addr,
		pr_debug("memshare: %s: client_id:%d, size: %d",
				__func__, client_id,
				memblock[client_id].size);
		dma_free_attrs(memsh_drv->dev, memblock[client_id].size,
			memblock[client_id].virtual_addr,
@@ -643,8 +642,8 @@ static int handle_free_generic_req(void *req_h, void *req, void *conn_h)
			&attrs);
		free_client(client_id);
	} else {
		pr_err("In %s, Request came for a guaranteed client cannot free up the memory\n",
						__func__);
		pr_err("In %s, Request came for a guaranteed client(client_id: %d) cannot free up the memory\n",
						__func__, client_id);
	}

	if (flag) {
@@ -947,6 +946,10 @@ static int memshare_child_probe(struct platform_device *pdev)
							pdev->dev.of_node,
							"qcom,allocate-boot-time");

	memblock[num_clients].client_request = of_property_read_bool(
							pdev->dev.of_node,
							"qcom,allocate-on-request");

	rc = of_property_read_string(pdev->dev.of_node, "label",
						&name);
	if (rc) {
+3 −1
Original line number Diff line number Diff line
/* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2013-2018, 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
@@ -39,6 +39,8 @@ struct mem_blocks {
	uint32_t guarantee;
	/* Memory alloted or not */
	uint32_t alloted;
	/* Allocation on request from a client*/
	uint32_t client_request;
	/* Size required for client */
	uint32_t size;
	/*