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

Commit 077edede authored by Maulik Shah's avatar Maulik Shah
Browse files

soc: qcom: rpmh: Correct rpm_msg pointer offset and add list_del



rpm_msgs address is calculated from memory allocated during write_batch.
Correct the offset from where rpm_msgs actually starts and assign req
pointer to point to correct address.

Also add list_del before freeing memory in invalidate_batch.

Change-Id: Idca43fe73bd238e90911158b08b3889c001e1123
Signed-off-by: default avatarMaulik Shah <mkshah@codeaurora.org>
parent 800b8a60
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@ struct cache_req {
struct batch_cache_req {
	struct list_head list;
	int count;
	struct rpmh_request rpm_msgs[];
	struct rpmh_request *rpm_msgs;
};

static struct rpmh_ctrlr *get_rpmh_ctrlr(const struct device *dev)
@@ -383,8 +383,10 @@ static void invalidate_batch(struct rpmh_ctrlr *ctrlr)
	unsigned long flags;

	spin_lock_irqsave(&ctrlr->cache_lock, flags);
	list_for_each_entry_safe(req, tmp, &ctrlr->batch_cache, list)
	list_for_each_entry_safe(req, tmp, &ctrlr->batch_cache, list) {
		list_del(&req->list);
		kfree(req);
	}
	INIT_LIST_HEAD(&ctrlr->batch_cache);
	spin_unlock_irqrestore(&ctrlr->cache_lock, flags);
}
@@ -440,10 +442,11 @@ int rpmh_write_batch(const struct device *dev, enum rpmh_state state,
		return -ENOMEM;

	req = ptr;
	rpm_msgs = ptr + sizeof(*req);
	compls = ptr + sizeof(*req) + count * sizeof(*rpm_msgs);

	req->count = count;
	rpm_msgs = req->rpm_msgs;
	req->rpm_msgs = rpm_msgs;

	for (i = 0; i < count; i++) {
		__fill_rpmh_msg(rpm_msgs + i, state, cmd, n[i]);