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

Commit ec7b4193 authored by Kyle Piefer's avatar Kyle Piefer Committed by Gerrit - the friendly Code Review server
Browse files

msm: kgsl: Make the querying of ARC values more robust



Check for an error condition when getting the length of
the cmddb ARC value table. Also use the length of the
table as the condition for looping through the values.
Add a comment to make the code more understandable.

CRs-Fixed: 2085877
Change-Id: Iae377abb8dbd2d12b57ec14084d0a75a06670e1c
Signed-off-by: default avatarKyle Piefer <kpiefer@codeaurora.org>
parent 5bc5bb65
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -505,9 +505,10 @@ static int rpmh_arc_cmds(struct gmu_device *gmu,
	unsigned int len;

	len = cmd_db_get_aux_data_len(res_id);
	if (len == 0)
		return -EINVAL;

	if (len > (MAX_GX_LEVELS << 1)) {
		/* CmdDB VLVL table size in bytes is too large */
		dev_err(&gmu->pdev->dev,
			"gfx cmddb size %d larger than alloc buf %d of %s\n",
			len, (MAX_GX_LEVELS << 1), res_id);
@@ -515,8 +516,16 @@ static int rpmh_arc_cmds(struct gmu_device *gmu,
	}

	cmd_db_get_aux_data(res_id, (uint8_t *)arc->val, len);
	for (arc->num = 1; arc->num <= MAX_GX_LEVELS; arc->num++) {
		if (arc->num == MAX_GX_LEVELS ||

	/*
	 * cmd_db_get_aux_data() gives us a zero-padded table of
	 * size len that contains the arc values. To determine the
	 * number of arc values, we loop through the table and count
	 * them until we get to the end of the buffer or hit the
	 * zero padding.
	 */
	for (arc->num = 1; arc->num <= len; arc->num++) {
		if (arc->num == len ||
				arc->val[arc->num - 1] >= arc->val[arc->num])
			break;
	}