fix(spm-mm): prevent excessive racing

The current code does the following:

sp_state_wait_switch:
	lock()
	if (status == 0)
		status = 1
	unlock()

[critical section]

sp_state_set:
	lock()
	status = 0
	unlock()

One core will obtain the status for itself and then all other cores will
get the lock, see the status is not available, release the lock, and try
again. However, when there are many cores this causes a lot of lock
contention and the original core is racing to obtain the lock to release
the status. This starves the holder of the lock, resulting in an
apparent deadlock, although given enough time it will pass.

Hold the lock throughout to prevent this.

Also make the functions static as they are never exported and drop
sp_state_try_switch() as its unused and would not work anymore.

Signed-off-by: Boyan Karatotev <boyan.karatotev@arm.com>
Change-Id: Ifa8be75086f2e5b2f8a7c6f266a01dd4deb133e4
(cherry picked from commit 940ae6cfc92cf43d7a72622997ffe5be872b68d5)
1 file changed