Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/drivers/intel/cavs/dmic.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,16 @@ static enum task_state dmic_work(void *data)
int32_t gval;
uint32_t val;
int i;
int ret;

tracev_dmic("dmic_work()");
spin_lock(dai->lock);

spin_try_lock(dai->lock, ret);
if (!ret) {
tracev_dmic("dmic_work(): spin_try_lock(dai->lock, ret)"
"failed: RESCHEDULE");
return SOF_TASK_STATE_RESCHEDULE;
}

/* Increment gain with logarithmic step.
* Gain is Q2.30 and gain modifier is Q12.20.
Expand Down Expand Up @@ -1396,6 +1403,7 @@ static void dmic_stop(struct dai *dai)

dmic_active_fifos--;

schedule_task_cancel(&dmic->dmicwork);
out:
spin_unlock(dai->lock);
}
Expand Down
4 changes: 2 additions & 2 deletions src/include/sof/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,10 @@ extern uint32_t lock_dbg_user[DBG_LOCK_USERS];
arch_spin_lock(lock); \
} while (0)

#define spin_try_lock(lock) \
#define spin_try_lock(lock, ret) \
do { \
spin_lock_dbg(); \
arch_try_lock(lock); \
ret = arch_try_lock(lock); \

@paulstelian97 paulstelian97 Nov 8, 2019 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't a better approach be to use a block expression? (GNU extension). As in,

#define spin_try_lock(lock) ({ \
              spin_lock_dbg();  \
              arch_try_lock(lock); \
})

(with the proper alignment)? That would also be of lower impact to the remainder of the code.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency I think that we can change it for every spin_lock*() macro in another PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, we could make this an incremental update in another PR.

} while (0)

#define spin_unlock(lock) \
Expand Down