OSDN Git Service

memshare: Update the free memory count after allocation
authorManoj Prabhu B <bmanoj@codeaurora.org>
Wed, 10 May 2017 05:31:37 +0000 (11:01 +0530)
committerManoj Prabhu B <bmanoj@codeaurora.org>
Fri, 12 May 2017 05:12:41 +0000 (10:42 +0530)
The patch updates the client's free memory
count variable after the successful allocation.

CRs-Fixed: 2046258
Change-Id: Ibae317596557e23d2b2278daf433bd293a8bd0be
Signed-off-by: Manoj Prabhu B <bmanoj@codeaurora.org>
drivers/soc/qcom/memshare/msm_memshare.c

index c111145..7406dba 100644 (file)
@@ -524,10 +524,6 @@ static int handle_alloc_generic_req(void *req_h, void *req, void *conn_h)
                return -EINVAL;
        }
 
-       memblock[client_id].free_memory += 1;
-       pr_debug("memshare: In %s, free memory count for client id: %d = %d",
-               __func__, memblock[client_id].client_id,
-                       memblock[client_id].free_memory);
        if (!memblock[client_id].alloted) {
                if (alloc_req->client_id == 1 && alloc_req->num_bytes > 0)
                        size = alloc_req->num_bytes + MEMSHARE_GUARD_BYTES;
@@ -541,11 +537,16 @@ static int handle_alloc_generic_req(void *req_h, void *req, void *conn_h)
                        resp = 1;
                }
                if (!resp) {
+                       memblock[client_id].free_memory += 1;
                        memblock[client_id].alloted = 1;
                        memblock[client_id].size = alloc_req->num_bytes;
                        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;
 
        fill_alloc_response(alloc_resp, client_id, &resp);