Skip to content

Commit d597225

Browse files
committed
ASoC: SOF: apply IPC changes to byt
(1) Set DONE bit in cmd_done function which processes msgs, rather than doing it in IRQ function. But if a msg is not in the rx list, it can only be done at IRQ function (2) Check DONE bit in byt_is_ready function Signed-off-by: Rander Wang <[email protected]>
1 parent 0621640 commit d597225

File tree

1 file changed

+33
-21
lines changed

1 file changed

+33
-21
lines changed

sound/soc/sof/intel/byt.c

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ static const struct snd_sof_debugfs_map cht_debugfs[] = {
9595
{"shim", BYT_DSP_BAR, SHIM_OFFSET, SHIM_SIZE},
9696
};
9797

98+
static int byt_cmd_done(struct snd_sof_dev *sdev, int dir);
99+
98100
/*
99101
* Register IO
100102
*/
@@ -376,16 +378,15 @@ static irqreturn_t byt_irq_thread(int irq, void *context)
376378

377379
/* reply message from DSP */
378380
if (ipcx & SHIM_BYT_IPCX_DONE) {
379-
/* Handle Immediate reply from DSP Core */
380-
snd_sof_ipc_reply(sdev, ipcx);
381-
382-
/* clear DONE bit - tell DSP we have completed */
383-
snd_sof_dsp_update_bits64_unlocked(sdev, BYT_DSP_BAR, SHIM_IPCX,
384-
SHIM_BYT_IPCX_DONE, 0);
385-
386-
/* unmask Done interrupt */
387-
snd_sof_dsp_update_bits64_unlocked(sdev, BYT_DSP_BAR, SHIM_IMRX,
388-
SHIM_IMRX_DONE, 0);
381+
/*
382+
* handle immediate reply from DSP core. If the msg is
383+
* found, set done bit in cmd_done which is called at the
384+
* end of message processing function, else set it here
385+
* because the done bit can't be set in cmd_done function
386+
* which is triggered by msg
387+
*/
388+
if (snd_sof_ipc_reply(sdev, ipcx))
389+
byt_cmd_done(sdev, SOF_IPC_DSP_REPLY);
389390
}
390391

391392
/* new message from DSP */
@@ -405,10 +406,11 @@ static irqreturn_t byt_irq_thread(int irq, void *context)
405406

406407
static int byt_is_ready(struct snd_sof_dev *sdev)
407408
{
408-
u64 imrx;
409+
u64 imrx, ipcx;
409410

410411
imrx = snd_sof_dsp_read64(sdev, BYT_DSP_BAR, SHIM_IMRX);
411-
if (imrx & SHIM_IMRX_DONE)
412+
ipcx = snd_sof_dsp_read64(sdev, BYT_DSP_BAR, SHIM_IPCX);
413+
if ((imrx & SHIM_IMRX_DONE) || (ipcx & SHIM_BYT_IPCX_DONE))
412414
return 0;
413415

414416
return 1;
@@ -458,17 +460,27 @@ static int byt_get_reply(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg)
458460
return ret;
459461
}
460462

461-
static int byt_cmd_done(struct snd_sof_dev *sdev)
463+
static int byt_cmd_done(struct snd_sof_dev *sdev, int dir)
462464
{
463-
/* clear BUSY bit and set DONE bit - accept new messages */
464-
snd_sof_dsp_update_bits64_unlocked(sdev, BYT_DSP_BAR, SHIM_IPCD,
465-
SHIM_BYT_IPCD_BUSY |
466-
SHIM_BYT_IPCD_DONE,
467-
SHIM_BYT_IPCD_DONE);
465+
if (dir == SOF_IPC_HOST_REPLY) {
466+
/* clear BUSY bit and set DONE bit - accept new messages */
467+
snd_sof_dsp_update_bits64_unlocked(sdev, BYT_DSP_BAR, SHIM_IPCD,
468+
SHIM_BYT_IPCD_BUSY |
469+
SHIM_BYT_IPCD_DONE,
470+
SHIM_BYT_IPCD_DONE);
468471

469-
/* unmask busy interrupt */
470-
snd_sof_dsp_update_bits64_unlocked(sdev, BYT_DSP_BAR, SHIM_IMRX,
471-
SHIM_IMRX_BUSY, 0);
472+
/* unmask busy interrupt */
473+
snd_sof_dsp_update_bits64_unlocked(sdev, BYT_DSP_BAR, SHIM_IMRX,
474+
SHIM_IMRX_BUSY, 0);
475+
} else {
476+
/* clear DONE bit - tell DSP we have completed */
477+
snd_sof_dsp_update_bits64_unlocked(sdev, BYT_DSP_BAR, SHIM_IPCX,
478+
SHIM_BYT_IPCX_DONE, 0);
479+
480+
/* unmask Done interrupt */
481+
snd_sof_dsp_update_bits64_unlocked(sdev, BYT_DSP_BAR, SHIM_IMRX,
482+
SHIM_IMRX_DONE, 0);
483+
}
472484

473485
return 0;
474486
}

0 commit comments

Comments
 (0)