All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] ASoC: SOF: AMD updates
@ 2022-04-21 16:58 Pierre-Louis Bossart
  2022-04-21 16:58 ` [PATCH v2 1/2] ASoC: SOF: amd: Add psp_mbox_ready() and psp_send_cmd() callback Pierre-Louis Bossart
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Pierre-Louis Bossart @ 2022-04-21 16:58 UTC (permalink / raw)
  To: alsa-devel; +Cc: tiwai, broonie, Pierre-Louis Bossart

these patches were originally submitted in the "ASoC: SOF:
AMD/Mediatek updates" series, but there was a bisect
issue on the first patch.

sound/soc/sof/amd/acp.c:176:29: error: unused variable ‘sdev’
[-Werror=unused-variable]

resubmitting as v2 with each patch compiling without warning.

Ajit Kumar Pandey (2):
  ASoC: SOF: amd: Add psp_mbox_ready() and psp_send_cmd() callback
  ASoC: SOF: amd: Use dedicated MBOX for ACP and PSP communication

 sound/soc/sof/amd/acp.c | 66 ++++++++++++++++++++++++++++++++++++-----
 sound/soc/sof/amd/acp.h |  6 ++--
 2 files changed, 63 insertions(+), 9 deletions(-)

-- 
2.30.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/2] ASoC: SOF: amd: Add psp_mbox_ready() and psp_send_cmd() callback
  2022-04-21 16:58 [PATCH v2 0/2] ASoC: SOF: AMD updates Pierre-Louis Bossart
@ 2022-04-21 16:58 ` Pierre-Louis Bossart
  2022-04-21 16:58 ` [PATCH v2 2/2] ASoC: SOF: amd: Use dedicated MBOX for ACP and PSP communication Pierre-Louis Bossart
  2022-04-21 18:38 ` [PATCH v2 0/2] ASoC: SOF: AMD updates Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Pierre-Louis Bossart @ 2022-04-21 16:58 UTC (permalink / raw)
  To: alsa-devel
  Cc: tiwai, broonie, Ranjani Sridharan, Ajit Kumar Pandey,
	Pierre-Louis Bossart

From: Ajit Kumar Pandey <AjitKumar.Pandey@amd.com>

We need to ensure if PSP is mbox ready before and after sending cmd
to PSP over SMN interface. Add method to check MBOX_READY bit of PSP
with some delay over ACP_PSP_TIMEOUT_COUNTER. Replace psp_fw_validate
with new method psp_send_cmd() to send command via psp mailbox.

Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Ajit Kumar Pandey <AjitKumar.Pandey@amd.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/soc/sof/amd/acp.c | 46 +++++++++++++++++++++++++++++++++++------
 1 file changed, 40 insertions(+), 6 deletions(-)

diff --git a/sound/soc/sof/amd/acp.c b/sound/soc/sof/amd/acp.c
index 71d71c152342a..8e88ae597fb88 100644
--- a/sound/soc/sof/amd/acp.c
+++ b/sound/soc/sof/amd/acp.c
@@ -138,14 +138,18 @@ int configure_and_run_dma(struct acp_dev_data *adata, unsigned int src_addr,
 	return ret;
 }
 
-static int psp_fw_validate(struct acp_dev_data *adata)
+/*
+ * psp_mbox_ready- function to poll ready bit of psp mbox
+ * @adata: acp device data
+ * @ack: bool variable to check ready bit status or psp ack
+ */
+
+static int psp_mbox_ready(struct acp_dev_data *adata, bool ack)
 {
 	struct snd_sof_dev *sdev = adata->dev;
 	int timeout;
 	u32 data;
 
-	smn_write(adata->smn_dev, MP0_C2PMSG_26_REG, MBOX_ACP_SHA_DMA_COMMAND);
-
 	for (timeout = ACP_PSP_TIMEOUT_COUNTER; timeout > 0; timeout--) {
 		msleep(20);
 		smn_read(adata->smn_dev, MP0_C2PMSG_26_REG, &data);
@@ -153,8 +157,38 @@ static int psp_fw_validate(struct acp_dev_data *adata)
 			return 0;
 	}
 
-	dev_err(sdev->dev, "FW validation timedout: status %x\n", data & MBOX_STATUS_MASK);
-	return -ETIMEDOUT;
+	dev_err(sdev->dev, "PSP error status %x\n", data & MBOX_STATUS_MASK);
+
+	if (ack)
+		return -ETIMEDOUT;
+
+	return -EBUSY;
+}
+
+/*
+ * psp_send_cmd - function to send psp command over mbox
+ * @adata: acp device data
+ * @cmd: non zero integer value for command type
+ */
+
+static int psp_send_cmd(struct acp_dev_data *adata, int cmd)
+{
+	int ret;
+
+	if (!cmd)
+		return -EINVAL;
+
+	/* Check if PSP is ready for new command */
+	ret = psp_mbox_ready(adata, 0);
+	if (ret)
+		return ret;
+
+	smn_write(adata->smn_dev, MP0_C2PMSG_26_REG, cmd);
+
+	/* Check MBOX ready as PSP ack */
+	ret = psp_mbox_ready(adata, 1);
+
+	return ret;
 }
 
 int configure_and_run_sha_dma(struct acp_dev_data *adata, void *image_addr,
@@ -196,7 +230,7 @@ int configure_and_run_sha_dma(struct acp_dev_data *adata, void *image_addr,
 		return ret;
 	}
 
-	ret = psp_fw_validate(adata);
+	ret = psp_send_cmd(adata, MBOX_ACP_SHA_DMA_COMMAND);
 	if (ret)
 		return ret;
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] ASoC: SOF: amd: Use dedicated MBOX for ACP and PSP communication
  2022-04-21 16:58 [PATCH v2 0/2] ASoC: SOF: AMD updates Pierre-Louis Bossart
  2022-04-21 16:58 ` [PATCH v2 1/2] ASoC: SOF: amd: Add psp_mbox_ready() and psp_send_cmd() callback Pierre-Louis Bossart
@ 2022-04-21 16:58 ` Pierre-Louis Bossart
  2022-04-21 18:38 ` [PATCH v2 0/2] ASoC: SOF: AMD updates Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Pierre-Louis Bossart @ 2022-04-21 16:58 UTC (permalink / raw)
  To: alsa-devel
  Cc: Ajit Kumar Pandey, tiwai, Ranjani Sridharan,
	Pierre-Louis Bossart, broonie, Bard Liao

From: Ajit Kumar Pandey <AjitKumar.Pandey@amd.com>

We are currently using generic PSP Mailbox register for sending SHA
complete command to PSP but observe random arbitration issue during
PSP validation as MP0_C2PMSG_26_REG used by other kernel modules.

Use separate mailbox registers and doorbell mechanism to send SHA_DMA
complete command to PSP. This fixes such validation issues and added
flexibility for sending more ACP commands to PSP in future as new mbox
registers i.e MP0_C2PMSG_114_REG and MP0_C2PMSG_73_REG are dedicated
by PSP for ACP communications.

Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Ajit Kumar Pandey <AjitKumar.Pandey@amd.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/soc/sof/amd/acp.c | 24 +++++++++++++++++++++---
 sound/soc/sof/amd/acp.h |  6 ++++--
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/sound/soc/sof/amd/acp.c b/sound/soc/sof/amd/acp.c
index 8e88ae597fb88..0c272573df979 100644
--- a/sound/soc/sof/amd/acp.c
+++ b/sound/soc/sof/amd/acp.c
@@ -152,7 +152,7 @@ static int psp_mbox_ready(struct acp_dev_data *adata, bool ack)
 
 	for (timeout = ACP_PSP_TIMEOUT_COUNTER; timeout > 0; timeout--) {
 		msleep(20);
-		smn_read(adata->smn_dev, MP0_C2PMSG_26_REG, &data);
+		smn_read(adata->smn_dev, MP0_C2PMSG_114_REG, &data);
 		if (data & MBOX_READY_MASK)
 			return 0;
 	}
@@ -173,17 +173,35 @@ static int psp_mbox_ready(struct acp_dev_data *adata, bool ack)
 
 static int psp_send_cmd(struct acp_dev_data *adata, int cmd)
 {
-	int ret;
+	struct snd_sof_dev *sdev = adata->dev;
+	int ret, timeout;
+	u32 data;
 
 	if (!cmd)
 		return -EINVAL;
 
+	/* Get a non-zero Doorbell value from PSP */
+	for (timeout = ACP_PSP_TIMEOUT_COUNTER; timeout > 0; timeout--) {
+		msleep(MBOX_DELAY);
+		smn_read(adata->smn_dev, MP0_C2PMSG_73_REG, &data);
+		if (data)
+			break;
+	}
+
+	if (!timeout) {
+		dev_err(sdev->dev, "Failed to get Doorbell from MBOX %x\n", MP0_C2PMSG_73_REG);
+		return -EINVAL;
+	}
+
 	/* Check if PSP is ready for new command */
 	ret = psp_mbox_ready(adata, 0);
 	if (ret)
 		return ret;
 
-	smn_write(adata->smn_dev, MP0_C2PMSG_26_REG, cmd);
+	smn_write(adata->smn_dev, MP0_C2PMSG_114_REG, cmd);
+
+	/* Ring the Doorbell for PSP */
+	smn_write(adata->smn_dev, MP0_C2PMSG_73_REG, data);
 
 	/* Check MBOX ready as PSP ack */
 	ret = psp_mbox_ready(adata, 1);
diff --git a/sound/soc/sof/amd/acp.h b/sound/soc/sof/amd/acp.h
index ca69b4969ca22..de526a1bce131 100644
--- a/sound/soc/sof/amd/acp.h
+++ b/sound/soc/sof/amd/acp.h
@@ -57,8 +57,10 @@
 #define ACP_SHA_STAT				0x8000
 #define ACP_PSP_TIMEOUT_COUNTER			5
 #define ACP_EXT_INTR_ERROR_STAT			0x20000000
-#define MP0_C2PMSG_26_REG			0x03810570
-#define MBOX_ACP_SHA_DMA_COMMAND		0x330000
+#define MP0_C2PMSG_114_REG			0x3810AC8
+#define MP0_C2PMSG_73_REG			0x3810A24
+#define MBOX_ACP_SHA_DMA_COMMAND		0x70000
+#define MBOX_DELAY				1000
 #define MBOX_READY_MASK				0x80000000
 #define MBOX_STATUS_MASK			0xFFFF
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 0/2] ASoC: SOF: AMD updates
  2022-04-21 16:58 [PATCH v2 0/2] ASoC: SOF: AMD updates Pierre-Louis Bossart
  2022-04-21 16:58 ` [PATCH v2 1/2] ASoC: SOF: amd: Add psp_mbox_ready() and psp_send_cmd() callback Pierre-Louis Bossart
  2022-04-21 16:58 ` [PATCH v2 2/2] ASoC: SOF: amd: Use dedicated MBOX for ACP and PSP communication Pierre-Louis Bossart
@ 2022-04-21 18:38 ` Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2022-04-21 18:38 UTC (permalink / raw)
  To: alsa-devel, pierre-louis.bossart; +Cc: tiwai

On Thu, 21 Apr 2022 11:58:18 -0500, Pierre-Louis Bossart wrote:
> these patches were originally submitted in the "ASoC: SOF:
> AMD/Mediatek updates" series, but there was a bisect
> issue on the first patch.
> 
> sound/soc/sof/amd/acp.c:176:29: error: unused variable ‘sdev’
> [-Werror=unused-variable]
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/2] ASoC: SOF: amd: Add psp_mbox_ready() and psp_send_cmd() callback
      commit: bbdcd3d590cad744db46cb94649833db3575df49
[2/2] ASoC: SOF: amd: Use dedicated MBOX for ACP and PSP communication
      commit: d2be77b382328b46a79635bfd9e959a96bb6ac29

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-04-21 18:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-21 16:58 [PATCH v2 0/2] ASoC: SOF: AMD updates Pierre-Louis Bossart
2022-04-21 16:58 ` [PATCH v2 1/2] ASoC: SOF: amd: Add psp_mbox_ready() and psp_send_cmd() callback Pierre-Louis Bossart
2022-04-21 16:58 ` [PATCH v2 2/2] ASoC: SOF: amd: Use dedicated MBOX for ACP and PSP communication Pierre-Louis Bossart
2022-04-21 18:38 ` [PATCH v2 0/2] ASoC: SOF: AMD updates Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.