From dc4e87b372d24bd31167592e9e0c57e773289ca6 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Wed, 23 Jan 2019 14:54:10 +0800 Subject: [PATCH 1/2] ASoC: SOF: IPC: fix message finding logic in sof_ipc_reply_find_msg We should find message from reply_list with the whole message header(32 bits), not only the lowest 16 bits message id, otherwise, the searching will always return either with the 1st message in the list(as all our messages now are with 0x0 lowest 16 bits), or with no matched and show error logs always to be "error: rx list empty but received 0x0". Signed-off-by: Keyon Jie --- sound/soc/sof/ipc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sound/soc/sof/ipc.c b/sound/soc/sof/ipc.c index b52fee9c6c482c..333d5284e6eb88 100644 --- a/sound/soc/sof/ipc.c +++ b/sound/soc/sof/ipc.c @@ -312,10 +312,8 @@ static struct snd_sof_ipc_msg *sof_ipc_reply_find_msg(struct snd_sof_ipc *ipc, struct snd_sof_dev *sdev = ipc->sdev; struct snd_sof_ipc_msg *msg; - header = SOF_IPC_MESSAGE_ID(header); - list_for_each_entry(msg, &ipc->reply_list, list) { - if (SOF_IPC_MESSAGE_ID(msg->header) == header) + if (msg->header == header) return msg; } From fce5b82a1158ed2b60ddef8b5c85c496540f4de1 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Wed, 23 Jan 2019 16:41:39 +0800 Subject: [PATCH 2/2] ASoC: SOF: IPC: add a msg_mask for ipc_reply message check As some of the highest IPC register bits are occupied for busy/done interrupts, we can't use them for IPC message payload. This is only an simple fix for this ipc message matching check but not perfect, we may need to switch to use host_box to get the whole message for checking in future, which need changes together in FW side. Signed-off-by: Keyon Jie --- sound/soc/sof/intel/bdw.c | 2 +- sound/soc/sof/intel/byt.c | 2 +- sound/soc/sof/intel/cnl.c | 2 +- sound/soc/sof/intel/hda-ipc.c | 3 ++- sound/soc/sof/intel/hsw.c | 2 +- sound/soc/sof/ipc.c | 8 ++++---- sound/soc/sof/sof-priv.h | 2 +- 7 files changed, 11 insertions(+), 10 deletions(-) diff --git a/sound/soc/sof/intel/bdw.c b/sound/soc/sof/intel/bdw.c index f6eb51605f7a6d..a83eb7f11b4aa7 100644 --- a/sound/soc/sof/intel/bdw.c +++ b/sound/soc/sof/intel/bdw.c @@ -280,7 +280,7 @@ static irqreturn_t bdw_irq_thread(int irq, void *context) * because the done bit can't be set in cmd_done function * which is triggered by msg */ - if (snd_sof_ipc_reply(sdev, ipcx)) + if (snd_sof_ipc_reply(sdev, ipcx, U32_MAX)) bdw_cmd_done(sdev, SOF_IPC_DSP_REPLY); } diff --git a/sound/soc/sof/intel/byt.c b/sound/soc/sof/intel/byt.c index a6a2dfecf820ce..ef434c7ddc23dd 100644 --- a/sound/soc/sof/intel/byt.c +++ b/sound/soc/sof/intel/byt.c @@ -306,7 +306,7 @@ static irqreturn_t byt_irq_thread(int irq, void *context) * because the done bit can't be set in cmd_done function * which is triggered by msg */ - if (snd_sof_ipc_reply(sdev, ipcx)) + if (snd_sof_ipc_reply(sdev, ipcx, U32_MAX)) byt_cmd_done(sdev, SOF_IPC_DSP_REPLY); } diff --git a/sound/soc/sof/intel/cnl.c b/sound/soc/sof/intel/cnl.c index bcc9820d57968c..ae0b9e77f3c60f 100644 --- a/sound/soc/sof/intel/cnl.c +++ b/sound/soc/sof/intel/cnl.c @@ -63,7 +63,7 @@ static irqreturn_t cnl_ipc_irq_thread(int irq, void *context) * because the done bit can't be set in cmd_done function * which is triggered by msg */ - if (snd_sof_ipc_reply(sdev, msg)) + if (snd_sof_ipc_reply(sdev, msg, CNL_DSP_REG_HIPCIDA_MSG_MASK)) cnl_ipc_cmd_done(sdev, SOF_IPC_DSP_REPLY); ret = IRQ_HANDLED; diff --git a/sound/soc/sof/intel/hda-ipc.c b/sound/soc/sof/intel/hda-ipc.c index 9ddfa9e1f96868..91ad06468ba312 100644 --- a/sound/soc/sof/intel/hda-ipc.c +++ b/sound/soc/sof/intel/hda-ipc.c @@ -152,7 +152,8 @@ irqreturn_t hda_dsp_ipc_irq_thread(int irq, void *context) /* handle immediate reply from DSP core - ignore ROM messages */ if (msg != 0x1004000) - reply = snd_sof_ipc_reply(sdev, msg); + reply = snd_sof_ipc_reply(sdev, msg, + HDA_DSP_REG_HIPCI_MSG_MASK); /* * handle immediate reply from DSP core. If the msg is diff --git a/sound/soc/sof/intel/hsw.c b/sound/soc/sof/intel/hsw.c index d1c3ed9b0247d7..a091cb767e66e5 100644 --- a/sound/soc/sof/intel/hsw.c +++ b/sound/soc/sof/intel/hsw.c @@ -281,7 +281,7 @@ static irqreturn_t hsw_irq_thread(int irq, void *context) * because the done bit can't be set in cmd_done function * which is triggered by msg */ - if (snd_sof_ipc_reply(sdev, ipcx)) + if (snd_sof_ipc_reply(sdev, ipcx, U32_MAX)) hsw_cmd_done(sdev, SOF_IPC_DSP_REPLY); } diff --git a/sound/soc/sof/ipc.c b/sound/soc/sof/ipc.c index 333d5284e6eb88..7cc459b0db4810 100644 --- a/sound/soc/sof/ipc.c +++ b/sound/soc/sof/ipc.c @@ -307,13 +307,13 @@ static void ipc_tx_next_msg(struct work_struct *work) /* find original TX message from DSP reply */ static struct snd_sof_ipc_msg *sof_ipc_reply_find_msg(struct snd_sof_ipc *ipc, - u32 header) + u32 header, u32 mask) { struct snd_sof_dev *sdev = ipc->sdev; struct snd_sof_ipc_msg *msg; list_for_each_entry(msg, &ipc->reply_list, list) { - if (msg->header == header) + if ((msg->header & mask) == header) return msg; } @@ -354,11 +354,11 @@ void sof_ipc_drop_all(struct snd_sof_ipc *ipc) EXPORT_SYMBOL(sof_ipc_drop_all); /* handle reply message from DSP */ -int snd_sof_ipc_reply(struct snd_sof_dev *sdev, u32 msg_id) +int snd_sof_ipc_reply(struct snd_sof_dev *sdev, u32 msg_id, u32 msg_mask) { struct snd_sof_ipc_msg *msg; - msg = sof_ipc_reply_find_msg(sdev->ipc, msg_id); + msg = sof_ipc_reply_find_msg(sdev->ipc, msg_id, msg_mask); if (!msg) { dev_err(sdev->dev, "error: can't find message header 0x%x", msg_id); diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h index d704cc5c0969ab..9c254bd690397a 100644 --- a/sound/soc/sof/sof-priv.h +++ b/sound/soc/sof/sof-priv.h @@ -416,7 +416,7 @@ int snd_sof_fw_parse_ext_data(struct snd_sof_dev *sdev, u32 offset); */ struct snd_sof_ipc *snd_sof_ipc_init(struct snd_sof_dev *sdev); void snd_sof_ipc_free(struct snd_sof_dev *sdev); -int snd_sof_ipc_reply(struct snd_sof_dev *sdev, u32 msg_id); +int snd_sof_ipc_reply(struct snd_sof_dev *sdev, u32 msg_id, u32 msg_mask); void snd_sof_ipc_msgs_rx(struct snd_sof_dev *sdev); void snd_sof_ipc_msgs_tx(struct snd_sof_dev *sdev); int snd_sof_ipc_stream_pcm_params(struct snd_sof_dev *sdev,