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

Commit b777c724 authored by Arun Kumar Neelakantam's avatar Arun Kumar Neelakantam
Browse files

soc: qcom: smem: use remote spinlock try lock



If a remote subsystem resets while holding the remote spinlock and APPs
is trying to acquire the same remote spinlock, then SSR does not get
handled and the system eventually crashes due to a deadlock.

Use remote_spinlock_trylock_irqsave() instead of remote_spinlock_irqsave()
which allows the CPU to handle the pending interrupts if remote spinlock
is not available.

CRs-Fixed: 932028
Change-Id: I88716abf5bfd9a85495733cffe6df9e8e827c1b5
Signed-off-by: default avatarArun Kumar Neelakantam <aneela@codeaurora.org>
parent 049b7256
Loading
Loading
Loading
Loading
+16 −5
Original line number Diff line number Diff line
@@ -306,6 +306,7 @@ static void *__smem_get_entry_nonsecure(unsigned id, unsigned *size,
	int use_spinlocks = spinlocks_initialized && use_rspinlock;
	void *ret = 0;
	unsigned long flags = 0;
	int rc;

	if (!skip_init_check && !smem_initialized_check())
		return ret;
@@ -313,8 +314,12 @@ static void *__smem_get_entry_nonsecure(unsigned id, unsigned *size,
	if (id >= SMEM_NUM_ITEMS)
		return ret;

	if (use_spinlocks)
		remote_spin_lock_irqsave(&remote_spinlock, flags);
	if (use_spinlocks) {
		do {
			rc = remote_spin_trylock_irqsave(&remote_spinlock,
				flags);
		} while (!rc);
	}
	/* toc is in device memory and cannot be speculatively accessed */
	if (toc[id].allocated) {
		phys_addr_t phys_base;
@@ -394,8 +399,12 @@ static void *__smem_get_entry_secure(unsigned id,
			return NULL;
		}
	}
	if (use_rspinlock)
		remote_spin_lock_irqsave(&remote_spinlock, lflags);
	if (use_rspinlock) {
		do {
			rc = remote_spin_trylock_irqsave(&remote_spinlock,
				lflags);
		} while (!rc);
	}
	if (hdr->identifier != SMEM_PART_HDR_IDENTIFIER) {
		LOG_ERR(
			"%s: SMEM corruption detected.  Partition %d to %d at %p\n",
@@ -729,7 +738,9 @@ void *smem_alloc(unsigned id, unsigned size_in, unsigned to_proc,
	}

	a_size_in = ALIGN(size_in, 8);
	remote_spin_lock_irqsave(&remote_spinlock, lflags);
	do {
		rc = remote_spin_trylock_irqsave(&remote_spinlock, lflags);
	} while (!rc);

	ret = __smem_get_entry_secure(id, &size_out, to_proc, flags, true,
									false);