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

Commit 3c0655f1 authored by Chris Lew's avatar Chris Lew Committed by Gerrit - the friendly Code Review server
Browse files

rpmsg: glink: spi: Update intent before sending cmd



There is a race between updating the intent offset and writing the data
cmd onto the spi bus. If the remote side reads the data cmd and
responds with a rx_done cmd, the intent for that data cmd will be freed
before the offset is updated in glink_spi_send_data.

Move the offset update above the cmd write so all local state updates
are finished before the remote receives any cmds.

Change-Id: I453b7c464a33743fbcb9efee56505b872f2ab804
Signed-off-by: default avatarChris Lew <clew@codeaurora.org>
parent 1e465bc9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1212,8 +1212,8 @@ static int glink_spi_send_data(struct glink_channel *channel,
		mutex_lock(&glink->tx_lock);
	}
	glink_spi_write(glink, data, intent->addr + intent->offset, chunk_size);
	glink_spi_tx_write(glink, &req, sizeof(req), NULL, 0);
	intent->offset += chunk_size;
	glink_spi_tx_write(glink, &req, sizeof(req), NULL, 0);

	mutex_unlock(&glink->tx_lock);
	return 0;