Skip to content

Commit

Permalink
tests/kernel/smp: Misc synchronization fixups
Browse files Browse the repository at this point in the history
A few mistakes in recent changes to this test:

There was a "LOCK_NO" (i.e. no locking!) case being exercised in
test_inc_concurrency, where three threads would race against each
other incrementing and decrementing a single count without
synchronization.  And... it failed on cAVS.  Because there was no
synchronization.  Just remove.

The LOCK_IRQ (irq_un/lock()) case of the same test was was casting
taking a pointer to an integer (that stored the irq_lock() result) and
casting the pointer value to an integer instead of dereferencing it.

Also the workq test had a work item on the stack, which is forbidden
when KERNEL_COHERENCE=y

Fixes zephyrproject-rtos#34152

Signed-off-by: Andy Ross <[email protected]>
  • Loading branch information
Andy Ross committed May 13, 2021
1 parent 253350c commit fe86d07
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions tests/kernel/smp/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ static void workq_handler(struct k_work *work)
*/
void test_workq_on_smp(void)
{
struct k_work work;
static struct k_work work;

k_work_init(&work, workq_handler);

Expand Down Expand Up @@ -858,7 +858,6 @@ void test_smp_release_global_lock_irq(void)
#define LOOP_COUNT 20000

enum sync_t {
LOCK_NO,
LOCK_IRQ,
LOCK_SEM,
LOCK_MUTEX
Expand All @@ -877,14 +876,12 @@ static void sync_lock_dummy(void *k)

static void sync_lock_irq(void *k)
{
*((int *)k) = irq_lock();
*((unsigned int *)k) = irq_lock();
}

static void sync_unlock_irq(void *k)
{
int key = POINTER_TO_INT(k);

irq_unlock(key);
irq_unlock(*(unsigned int *)k);
}

static void sync_lock_sem(void *k)
Expand Down Expand Up @@ -1006,10 +1003,6 @@ static int run_concurrency(int type, void *func)
*/
void test_inc_concurrency(void)
{
/* increasing global var without lock */
zassert_false(run_concurrency(LOCK_NO, inc_global_cnt),
"total count %d is wrong", global_cnt);

/* increasing global var with irq lock */
zassert_true(run_concurrency(LOCK_IRQ, inc_global_cnt),
"total count %d is wrong(i)", global_cnt);
Expand Down

0 comments on commit fe86d07

Please sign in to comment.