tests/kernel/smp: Misc synchronization fixups

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 #34152

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
Andy Ross 2021-05-12 15:10:03 -07:00 committed by Anas Nashif
commit 6941c8fda9

View file

@ -698,7 +698,7 @@ static void workq_handler(struct k_work *work)
*/ */
void test_workq_on_smp(void) void test_workq_on_smp(void)
{ {
struct k_work work; static struct k_work work;
k_work_init(&work, workq_handler); k_work_init(&work, workq_handler);
@ -858,7 +858,6 @@ void test_smp_release_global_lock_irq(void)
#define LOOP_COUNT 20000 #define LOOP_COUNT 20000
enum sync_t { enum sync_t {
LOCK_NO,
LOCK_IRQ, LOCK_IRQ,
LOCK_SEM, LOCK_SEM,
LOCK_MUTEX LOCK_MUTEX
@ -877,14 +876,12 @@ static void sync_lock_dummy(void *k)
static void sync_lock_irq(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) static void sync_unlock_irq(void *k)
{ {
int key = POINTER_TO_INT(k); irq_unlock(*(unsigned int *)k);
irq_unlock(key);
} }
static void sync_lock_sem(void *k) static void sync_lock_sem(void *k)
@ -1006,10 +1003,6 @@ static int run_concurrency(int type, void *func)
*/ */
void test_inc_concurrency(void) 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 */ /* increasing global var with irq lock */
zassert_true(run_concurrency(LOCK_IRQ, inc_global_cnt), zassert_true(run_concurrency(LOCK_IRQ, inc_global_cnt),
"total count %d is wrong(i)", global_cnt); "total count %d is wrong(i)", global_cnt);