Skip to content
Closed
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: 6 additions & 4 deletions src/audio/component.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,23 @@ DECLARE_TR_CTX(comp_tr, SOF_UUID(comp_uuid), LOG_LEVEL_INFO);
int comp_register(struct comp_driver_info *drv)
{
struct comp_driver_list *drivers = comp_drivers_get();
k_spinlock_key_t key;

spin_lock(&drivers->lock);
key = k_spin_lock(&drivers->lock);
list_item_prepend(&drv->list, &drivers->list);
spin_unlock(&drivers->lock);
k_spin_unlock(&drivers->lock, key);

return 0;
}

void comp_unregister(struct comp_driver_info *drv)
{
struct comp_driver_list *drivers = comp_drivers_get();
k_spinlock_key_t key;

spin_lock(&drivers->lock);
key = k_spin_lock(&drivers->lock);
list_item_del(&drv->list);
spin_unlock(&drivers->lock);
k_spin_unlock(&drivers->lock, key);
}

/* NOTE: Keep the component state diagram up to date:
Expand Down
12 changes: 6 additions & 6 deletions src/audio/kpb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ static void kpb_init_draining(struct comp_dev *dev, struct kpb_client *cli)
(KPB_SAMPLE_CONTAINER_SIZE(sample_width) / 8) *
kpb->config.channels;
size_t period_bytes_limit;
uint32_t flags;
k_spinlock_key_t key;

comp_info(dev, "kpb_init_draining(): requested draining of %d [ms] from history buffer",
cli->drain_req);
Expand All @@ -1045,7 +1045,7 @@ static void kpb_init_draining(struct comp_dev *dev, struct kpb_client *cli)
* in the history buffer. All we have to do now is to calculate
* read pointer from which we will start draining.
*/
spin_lock_irq(&kpb->lock, flags);
key = k_spin_lock_irq(&kpb->lock);

kpb_change_state(kpb, KPB_STATE_INIT_DRAINING);

Expand Down Expand Up @@ -1103,7 +1103,7 @@ static void kpb_init_draining(struct comp_dev *dev, struct kpb_client *cli)

} while (buff != first_buff);

spin_unlock_irq(&kpb->lock, flags);
k_spin_unlock_irq(&kpb->lock, key);

/* Should we drain in synchronized mode (sync_draining_mode)?
* Note! We have already verified host params during
Expand Down Expand Up @@ -1190,7 +1190,7 @@ static enum task_state kpb_draining_task(void *arg)
struct comp_data *kpb = comp_get_drvdata(draining_data->dev);
bool sync_mode_on = draining_data->sync_mode_on;
bool pm_is_active;
uint32_t flags;
k_spinlock_key_t key;

comp_cl_info(&comp_kpb, "kpb_draining_task(), start.");

Expand Down Expand Up @@ -1280,7 +1280,7 @@ static enum task_state kpb_draining_task(void *arg)
*/
comp_cl_info(&comp_kpb, "kpb: update drain_req by %d",
*rt_stream_update);
spin_lock_irq(&kpb->lock, flags);
key = k_spin_lock_irq(&kpb->lock);
drain_req += *rt_stream_update;
*rt_stream_update = 0;
if (!drain_req && kpb->state == KPB_STATE_DRAINING) {
Expand All @@ -1292,7 +1292,7 @@ static enum task_state kpb_draining_task(void *arg)
*/
kpb_change_state(kpb, KPB_STATE_HOST_COPY);
}
spin_unlock_irq(&kpb->lock, flags);
k_spin_unlock_irq(&kpb->lock, key);
}
}

Expand Down
11 changes: 6 additions & 5 deletions src/audio/pipeline/pipeline-graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ static inline int pipeline_posn_offset_get(uint32_t *posn_offset)
struct pipeline_posn *pipeline_posn = pipeline_posn_get();
int ret = -EINVAL;
uint32_t i;
k_spinlock_key_t key;

spin_lock(&pipeline_posn->lock);
key = k_spin_lock(&pipeline_posn->lock);

for (i = 0; i < PPL_POSN_OFFSETS; ++i) {
if (!pipeline_posn->posn_offset[i]) {
Expand All @@ -73,7 +74,7 @@ static inline int pipeline_posn_offset_get(uint32_t *posn_offset)
}


spin_unlock(&pipeline_posn->lock);
k_spin_unlock(&pipeline_posn->lock, key);

return ret;
}
Expand All @@ -86,13 +87,13 @@ static inline void pipeline_posn_offset_put(uint32_t posn_offset)
{
struct pipeline_posn *pipeline_posn = pipeline_posn_get();
int i = posn_offset / sizeof(struct sof_ipc_stream_posn);
k_spinlock_key_t key;

spin_lock(&pipeline_posn->lock);
key = k_spin_lock(&pipeline_posn->lock);

pipeline_posn->posn_offset[i] = false;


spin_unlock(&pipeline_posn->lock);
k_spin_unlock(&pipeline_posn->lock, key);
}

void pipeline_posn_init(struct sof *sof)
Expand Down
16 changes: 8 additions & 8 deletions src/drivers/amd/renoir/acp_bt_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,38 +52,38 @@ static uint64_t prev_rx_pos;
static struct dma_chan_data *acp_dai_bt_dma_channel_get(struct dma *dma,
unsigned int req_chan)
{
uint32_t flags;
k_spinlock_key_t key;
struct dma_chan_data *channel;

spin_lock_irq(&dma->lock, flags);
key = k_spin_lock_irq(&dma->lock);
if (req_chan >= dma->plat_data.channels) {
spin_unlock_irq(&dma->lock, flags);
k_spin_unlock_irq(&dma->lock, key);
tr_err(&acp_bt_dma_tr, "DMA: Channel %d not in range", req_chan);
return NULL;
}
channel = &dma->chan[req_chan];
if (channel->status != COMP_STATE_INIT) {
spin_unlock_irq(&dma->lock, flags);
k_spin_unlock_irq(&dma->lock, key);
tr_err(&acp_bt_dma_tr, "DMA: channel already in use %d", req_chan);
return NULL;
}
atomic_add(&dma->num_channels_busy, 1);
channel->status = COMP_STATE_READY;
spin_unlock_irq(&dma->lock, flags);
k_spin_unlock_irq(&dma->lock, key);

return channel;
}

/* channel must not be running when this is called */
static void acp_dai_bt_dma_channel_put(struct dma_chan_data *channel)
{
uint32_t flags;
k_spinlock_key_t key;

notifier_unregister_all(NULL, channel);
spin_lock_irq(&channel->dma->lock, flags);
key = k_spin_lock_irq(&channel->dma->lock);
channel->status = COMP_STATE_INIT;
atomic_sub(&channel->dma->num_channels_busy, 1);
spin_unlock_irq(&channel->dma->lock, flags);
k_spin_unlock_irq(&channel->dma->lock, key);
}

static int acp_dai_bt_dma_start(struct dma_chan_data *channel)
Expand Down
16 changes: 8 additions & 8 deletions src/drivers/amd/renoir/acp_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,24 +174,24 @@ static void dma_reconfig(struct dma_chan_data *channel, uint32_t bytes)
static struct dma_chan_data *acp_dma_channel_get(struct dma *dma,
unsigned int req_chan)
{
uint32_t flags;
k_spinlock_key_t key;
struct dma_chan_data *channel;

spin_lock_irq(&dma->lock, flags);
key = k_spin_lock_irq(&dma->lock);
if (req_chan >= dma->plat_data.channels) {
spin_unlock_irq(&dma->lock, flags);
k_spin_unlock_irq(&dma->lock, key);
tr_err(&acpdma_tr, "DMA: Channel %d not in range", req_chan);
return NULL;
}
channel = &dma->chan[req_chan];
if (channel->status != COMP_STATE_INIT) {
spin_unlock_irq(&dma->lock, flags);
k_spin_unlock_irq(&dma->lock, key);
tr_err(&acpdma_tr, "DMA: channel already in use %d", req_chan);
return NULL;
}
atomic_add(&dma->num_channels_busy, 1);
channel->status = COMP_STATE_READY;
spin_unlock_irq(&dma->lock, flags);
k_spin_unlock_irq(&dma->lock, key);
/* reset read and write pointers */
struct acp_dma_chan_data *acp_dma_chan = dma_chan_get_data(channel);

Expand All @@ -202,12 +202,12 @@ static struct dma_chan_data *acp_dma_channel_get(struct dma *dma,

static void acp_dma_channel_put(struct dma_chan_data *channel)
{
uint32_t flags;
k_spinlock_key_t key;

spin_lock_irq(&channel->dma->lock, flags);
key = k_spin_lock_irq(&channel->dma->lock);
channel->status = COMP_STATE_INIT;
atomic_sub(&channel->dma->num_channels_busy, 1);
spin_unlock_irq(&channel->dma->lock, flags);
k_spin_unlock_irq(&channel->dma->lock, key);
/* reset read and write pointer */
struct acp_dma_chan_data *acp_dma_chan = dma_chan_get_data(channel);

Expand Down
16 changes: 8 additions & 8 deletions src/drivers/amd/renoir/acp_dmic_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,38 +42,38 @@ DECLARE_TR_CTX(acp_dmic_dma_tr, SOF_UUID(acp_dmic_dma_uuid), LOG_LEVEL_INFO);
static struct dma_chan_data *acp_dmic_dma_channel_get(struct dma *dma,
unsigned int req_chan)
{
uint32_t flags;
k_spinlock_key_t key;
struct dma_chan_data *channel;

spin_lock_irq(&dma->lock, flags);
key = k_spin_lock_irq(&dma->lock);
if (req_chan >= dma->plat_data.channels) {
spin_unlock_irq(&dma->lock, flags);
k_spin_unlock_irq(&dma->lock, key);
tr_err(&acp_dmic_dma_tr, "ACP_DMIC: Channel %d out of range",
req_chan);
return NULL;
}
channel = &dma->chan[req_chan];
if (channel->status != COMP_STATE_INIT) {
spin_unlock_irq(&dma->lock, flags);
k_spin_unlock_irq(&dma->lock, key);
tr_err(&acp_dmic_dma_tr, "ACP_DMIC: Cannot reuse channel %d",
req_chan);
return NULL;
}
atomic_add(&dma->num_channels_busy, 1);
channel->status = COMP_STATE_READY;
spin_unlock_irq(&dma->lock, flags);
k_spin_unlock_irq(&dma->lock, key);
return channel;
}

static void acp_dmic_dma_channel_put(struct dma_chan_data *channel)
{
uint32_t flags;
k_spinlock_key_t key;

notifier_unregister_all(NULL, channel);
spin_lock_irq(&channel->dma->lock, flags);
key = k_spin_lock_irq(&channel->dma->lock);
channel->status = COMP_STATE_INIT;
atomic_sub(&channel->dma->num_channels_busy, 1);
spin_unlock_irq(&channel->dma->lock, flags);
k_spin_unlock_irq(&channel->dma->lock, key);
}

static int acp_dmic_dma_start(struct dma_chan_data *channel)
Expand Down
16 changes: 8 additions & 8 deletions src/drivers/amd/renoir/acp_sp_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,37 +48,37 @@ static uint32_t sp_buff_size;
static struct dma_chan_data *acp_dai_sp_dma_channel_get(struct dma *dma,
unsigned int req_chan)
{
uint32_t flags;
k_spinlock_key_t key;
struct dma_chan_data *channel;

spin_lock_irq(&dma->lock, flags);
key = k_spin_lock_irq(&dma->lock);
if (req_chan >= dma->plat_data.channels) {
spin_unlock_irq(&dma->lock, flags);
k_spin_unlock_irq(&dma->lock, key);
tr_err(&acp_sp_tr, "DMA: Channel %d not in range", req_chan);
return NULL;
}
channel = &dma->chan[req_chan];
if (channel->status != COMP_STATE_INIT) {
spin_unlock_irq(&dma->lock, flags);
k_spin_unlock_irq(&dma->lock, key);
tr_err(&acp_sp_tr, "DMA: channel already in use %d", req_chan);
return NULL;
}
atomic_add(&dma->num_channels_busy, 1);
channel->status = COMP_STATE_READY;
spin_unlock_irq(&dma->lock, flags);
k_spin_unlock_irq(&dma->lock, key);
return channel;
}

/* channel must not be running when this is called */
static void acp_dai_sp_dma_channel_put(struct dma_chan_data *channel)
{
uint32_t flags;
k_spinlock_key_t key;

notifier_unregister_all(NULL, channel);
spin_lock_irq(&channel->dma->lock, flags);
key = k_spin_lock_irq(&channel->dma->lock);
channel->status = COMP_STATE_INIT;
atomic_sub(&channel->dma->num_channels_busy, 1);
spin_unlock_irq(&channel->dma->lock, flags);
k_spin_unlock_irq(&channel->dma->lock, key);

}

Expand Down
5 changes: 3 additions & 2 deletions src/drivers/amd/renoir/interrupt.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,14 @@ static inline void acp_handle_irq(struct irq_cascade_desc *cascade,
struct irq_desc *child = NULL;
int bit;
bool handled;
k_spinlock_key_t key;

while (status) {
bit = get_first_irq(status);
handled = false;
status &= ~(1ull << bit);

spin_lock(&cascade->lock);
key = k_spin_lock(&cascade->lock);

list_for_item(clist, &cascade->child[bit].list) {
child = container_of(clist, struct irq_desc, irq_list);
Expand All @@ -115,7 +116,7 @@ static inline void acp_handle_irq(struct irq_cascade_desc *cascade,
}
}

spin_unlock(&cascade->lock);
k_spin_unlock(&cascade->lock, key);

if (!handled) {
tr_err(&acp_irq_tr, "irq_handler(): not handled, bit %d",
Expand Down
Loading