ASoC: SOF: AMD/Mediatek updates
Subsystems (4)
cover ASoC: SOF: AMD/Mediatek updates
Hardware/IPC updates for AMD and shutdown support for Mediatek.
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
YC Hung (2):
ASoC: SOF: OF: Add shutdown callback for SOF OF device
ASoC: SOF: mediatek: mt8195 add shutdown callback
sound/soc/sof/amd/acp.c | 66 +++++++++++++++++++++++--- sound/soc/sof/amd/acp.h | 6 ++- sound/soc/sof/mediatek/mt8195/mt8195.c | 7 +++ sound/soc/sof/sof-of-dev.c | 6 +++ sound/soc/sof/sof-of-dev.h | 1 + 5 files changed, 77 insertions(+), 9 deletions(-)
Signature · 1 line
2.30.2
PATCH 1/4 ASoC: SOF: OF: Add shutdown callback for SOF OF device
From: YC Hung <[email protected]>
Add shutdown callback function for SOF OF device and call snd_sof_device_shutdown in sof_of_shutdown callback for DSP shutdown sequence.
--- sound/soc/sof/sof-of-dev.c | 6 ++++++ sound/soc/sof/sof-of-dev.h | 1 + 2 files changed, 7 insertions(+)
sound/soc/sof/sof-of-dev.c +6 -0
@@ -95,4 +95,10 @@ int sof_of_remove(struct platform_device *pdev) }EXPORT_SYMBOL (sof_of_remove); +void sof_of_shutdown (struct platform_device *pdev) +{ +snd_sof_device_shutdown (&pdev->dev); +} +EXPORT_SYMBOL (sof_of_shutdown); +MODULE_LICENSE ("Dual BSD/GPL" );
sound/soc/sof/sof-of-dev.h +1 -0
@@ -13,5 +13,6 @@ extern const struct dev_pm_ops sof_of_pm;int sof_of_probe (struct platform_device *pdev);int sof_of_remove (struct platform_device *pdev); +void sof_of_shutdown (struct platform_device *pdev);#endif
Signature · 1 line
2.30.2
PATCH 2/4 ASoC: SOF: mediatek: mt8195 add shutdown callback
In reply to Pierre-Louis BossartFrom: YC Hung <[email protected]>
Add mt8195 shutdown callback function implementation to ensure that shutdown flow is called to shutdown dsp core, disable adsp clock, and power off dsp sram correctly during reboot flow.
--- sound/soc/sof/mediatek/mt8195/mt8195.c | 7 +++++++ 1 file changed, 7 insertions(+)
sound/soc/sof/mediatek/mt8195/mt8195.c +7 -0
@@ -302,6 +302,11 @@ static int mt8195_dsp_probe(struct snd_sof_dev *sdev)return ret; } +static int mt8195_dsp_shutdown (struct snd_sof_dev *sdev) +{ +return snd_sof_suspend (sdev->dev); +} +static int mt8195_dsp_remove (struct snd_sof_dev *sdev) { struct platform_device *pdev = container_of(sdev->dev, struct platform_device, dev);
@@ -392,6 +397,7 @@ static const struct snd_sof_dsp_ops sof_mt8195_ops = {/* probe and remove */ .probe = mt8195_dsp_probe, .remove = mt8195_dsp_remove, + .shutdown = mt8195_dsp_shutdown,/* DSP core boot */ .run = mt8195_run,
@@ -451,6 +457,7 @@ MODULE_DEVICE_TABLE(of, sof_of_mt8195_ids);static struct platform_driver snd_sof_of_mt8195_driver = { .probe = sof_of_probe, .remove = sof_of_remove, + .shutdown = sof_of_shutdown, .driver = { .name ="sof-audio-of-mt8195" , .pm = &sof_of_pm,
Signature · 1 line
2.30.2
PATCH 3/4 ASoC: SOF: amd: Add psp_mbox_ready() and psp_send_cmd() callback
In reply to Pierre-Louis BossartFrom: Ajit Kumar Pandey <[email protected]>
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.
--- sound/soc/sof/amd/acp.c | 47 +++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-)
sound/soc/sof/amd/acp.c +41 -6
@@ -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,39 @@ 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) +{ +struct snd_sof_dev *sdev = adata->dev; +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 +231,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;
Signature · 1 line
2.30.2
Mark Brown
maintainerRe: [PATCH 3/4] ASoC: SOF: amd: Add psp_mbox_ready() and psp_send_cmd() callback
Quoted 6 lines · Pierre-Louis Bossart
From: Ajit Kumar Pandey <[email protected]>
We need to ensure if PSP is mbox ready before and after sending cmd to PSP over SMN interface. Add method to check
MBOX_READYbit of PSP with some delay overACP_PSP_TIMEOUT_COUNTER. Replacepsp_fw_validatewith new methodpsp_send_cmd()to send command via psp mailbox.
This breaks an x86 allmodconfig build with GCC 11:
/build/stage/linux/sound/soc/sof/amd/acp.c: In function ‘psp_send_cmd’:
/build/stage/linux/sound/soc/sof/amd/acp.c:176:29: error: unused variable ‘sdev’ [-Werror=unused-variable]
176 | struct snd_sof_dev *sdev = adata->dev;
| ^~~~
cc1: all warnings being treated as errors
make[5]: *** [/build/stage/linux/scripts/Makefile.build:288: sound/soc/sof/amd/acp.o] Error 1 make[5]: Target '__build' not remade because of errors.
make[4]: *** [/build/stage/linux/scripts/Makefile.build:550: sound/soc/sof/amd] Error 2 make[4]: Target '__build' not remade because of errors.
make[3]: *** [/build/stage/linux/scripts/Makefile.build:550: sound/soc/sof] Error 2 make[3]: Target '__build' not remade because of errors.
make[2]: *** [/build/stage/linux/scripts/Makefile.build:550: sound/soc] Error 2
PATCH 4/4 ASoC: SOF: amd: Use dedicated MBOX for ACP and PSP communication
In reply to Pierre-Louis BossartFrom: Ajit Kumar Pandey <[email protected]>
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.
--- sound/soc/sof/amd/acp.c | 23 ++++++++++++++++++++--- sound/soc/sof/amd/acp.h | 6 ++++-- 2 files changed, 24 insertions(+), 5 deletions(-)
sound/soc/sof/amd/acp.c +20 -3
@@ -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 ; }
@@ -174,17 +174,34 @@ static int psp_mbox_ready(struct acp_dev_data *adata, bool ack)static int psp_send_cmd (struct acp_dev_data *adata,int cmd) {struct snd_sof_dev *sdev = adata->dev; -int ret; +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 );
sound/soc/sof/amd/acp.h +4 -2
@@ -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
Signature · 1 line
2.30.2
Mark Brown
maintainerQuoted 11 lines · Pierre-Louis Bossart
Hardware/IPC updates for AMD and shutdown support for Mediatek.
Ajit Kumar Pandey (2):
ASoC: SOF: amd: Addpsp_mbox_ready()andpsp_send_cmd()callback
ASoC: SOF: amd: Use dedicated MBOX for ACP and PSP communicationYC Hung (2):
ASoC: SOF: OF: Add shutdown callback for SOF OF device
ASoC: SOF: mediatek: mt8195 add shutdown callback[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/4] ASoC: SOF: OF: Add shutdown callback for SOF OF device
commit: fe70300c70baa82fd3024af9a1d2838610a35005
[2/4] ASoC: SOF: mediatek: mt8195 add shutdown callback
commit: 5cfe477f6a3f9a4d9b2906d442964f2115b0403f[3/4] ASoC: SOF: amd: Add psp_mbox_ready() and psp_send_cmd() callback
(no commit info)
[4/4] ASoC: SOF: amd: Use dedicated MBOX for ACP and PSP communication
(no commit info)
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