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

Commit 68d1f386 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "soc: qcom: smem: use remote spinlock try lock"

parents a55a270d b777c724
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);