ASoC: SOF: updates for 5.18
Subsystems (3)
cover ASoC: SOF: updates for 5.18
A couple of updates for Intel and AMD hardware, along with minor cleanups
Ajit Kumar Pandey (4):
ASoC: SOF: amd: Flush cache after ATU_BASE_ADDR_GRP register update
ASoC: SOF: amd: Use semaphore register to synchronize ipc's irq
ASoC: SOF: amd: Move group register configuration to acp-loader
ASoC: SOF: amd: Increase ACP_HW_SEM_RETRY_COUNT value
Curtis Malainey (1):
ASoC: SOF: fix 32 signed bit overflow
Gongjun Song (1):
ASoC: SOF: Intel: pci-tgl: add RPL-S support
Peter Ujfalusi (2):
ASoC: SOF: amd: acp-pcm: Take buffer information directly from runtime
ASoC: SOF: amd: Do not set ipc_pcm_params ops as it is optional
Pierre-Louis Bossart (2):
ASoC: SOF: debug: clarify operator precedence
ASoC: SOF: Intel: hda: clarify operator precedence
include/sound/sof/header.h | 2 +- include/uapi/sound/sof/abi.h | 2 +- sound/soc/sof/amd/acp-dsp-offset.h | 1 + sound/soc/sof/amd/acp-ipc.c | 22 ++++++++++++++-------- sound/soc/sof/amd/acp-loader.c | 9 +++++++++ sound/soc/sof/amd/acp-pcm.c | 7 ++++--- sound/soc/sof/amd/acp-stream.c | 3 +++ sound/soc/sof/amd/acp.c | 29 ++++++++++++++--------------- sound/soc/sof/amd/acp.h | 3 +-- sound/soc/sof/amd/renoir.c | 1 - sound/soc/sof/debug.c | 2 +- sound/soc/sof/intel/hda.c | 2 +- sound/soc/sof/intel/pci-tgl.c | 2 ++ 13 files changed, 52 insertions(+), 33 deletions(-)
Signature · 1 line
2.30.2
PATCH 1/10 ASoC: SOF: Intel: pci-tgl: add RPL-S support
From: Gongjun Song <[email protected]>
Add PCI DID for Intel Raptor Lake S.
--- sound/soc/sof/intel/pci-tgl.c | 2 ++ 1 file changed, 2 insertions(+)
sound/soc/sof/intel/pci-tgl.c +2 -0
@@ -110,6 +110,8 @@ static const struct pci_device_id sof_pci_ids[] = { .driver_data = (unsigned long)&ehl_desc}, { PCI_DEVICE(0x8086, 0x7ad0), /* ADL-S */ .driver_data = (unsigned long)&adls_desc}, + { PCI_DEVICE(0x8086, 0x7a50), /* RPL-S */ + .driver_data = (unsigned long)&adls_desc}, { PCI_DEVICE(0x8086, 0x51c8), /* ADL-P */ .driver_data = (unsigned long)&adl_desc}, { PCI_DEVICE(0x8086, 0x51cd), /* ADL-P */
Signature · 1 line
2.30.2
PATCH 2/10 ASoC: SOF: amd: acp-pcm: Take buffer information directly from runtime
In reply to Pierre-Louis BossartFrom: Peter Ujfalusi <[email protected]>
Instead of using the values from ipc_params, take them directly from substream->runtime.
This is in preparation of making the platform hw_params callback to be IPC agnostic.
--- sound/soc/sof/amd/acp-pcm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
sound/soc/sof/amd/acp-pcm.c +4 -3
@@ -19,13 +19,14 @@int acp_pcm_hw_params (struct snd_sof_dev *sdev,struct snd_pcm_substream *substream,struct snd_pcm_hw_params *params,struct sof_ipc_stream_params *ipc_params) { -struct acp_dsp_stream *stream = substream->runtime->private_data; +struct snd_pcm_runtime *runtime = substream->runtime; +struct acp_dsp_stream *stream = runtime->private_data;unsigned int buf_offset, index;u32 size;int ret; - size = ipc_params->buffer.size; - stream->num_pages = ipc_params->buffer.pages; + size = runtime->dma_bytes; + stream->num_pages =PFN_UP (runtime->dma_bytes); stream->dmab = substream->runtime->dma_buffer_p; ret =acp_dsp_stream_config (sdev, stream);
Signature · 1 line
2.30.2
PATCH 3/10 ASoC: SOF: amd: Do not set ipc_pcm_params ops as it is optional
In reply to Pierre-Louis BossartFrom: Peter Ujfalusi <[email protected]>
The ipc_pcm_params() ops implementation for AMD is a NOP and since the callback is marked now as optional, it can be dropped along with the empty function.
--- sound/soc/sof/amd/acp-ipc.c | 8 -------- sound/soc/sof/amd/acp.h | 2 -- sound/soc/sof/amd/renoir.c | 1 - 3 files changed, 11 deletions(-)
sound/soc/sof/amd/acp-ipc.c +0 -8
@@ -170,14 +170,6 @@ int acp_sof_ipc_msg_data(struct snd_sof_dev *sdev, struct snd_pcm_substream *sub }EXPORT_SYMBOL_NS (acp_sof_ipc_msg_data,SND_SOC_SOF_AMD_COMMON ); -int acp_sof_ipc_pcm_params (struct snd_sof_dev *sdev,struct snd_pcm_substream *substream, -const struct sof_ipc_pcm_params_reply *reply) -{ -/* TODO: Implement stream hw params to validate stream offset */ -return 0 ; -} -EXPORT_SYMBOL_NS (acp_sof_ipc_pcm_params,SND_SOC_SOF_AMD_COMMON ); -int acp_sof_ipc_get_mailbox_offset (struct snd_sof_dev *sdev) {return ACP_SCRATCH_MEMORY_ADDRESS ;
sound/soc/sof/amd/acp.h +0 -2
@@ -185,8 +185,6 @@ int acp_sof_ipc_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg);int acp_sof_ipc_get_mailbox_offset (struct snd_sof_dev *sdev);int acp_sof_ipc_get_window_offset (struct snd_sof_dev *sdev,u32 id); -int acp_sof_ipc_pcm_params (struct snd_sof_dev *sdev,struct snd_pcm_substream *substream, -const struct sof_ipc_pcm_params_reply *reply);void acp_mailbox_write (struct snd_sof_dev *sdev,u32 offset,void *message,size_t bytes);void acp_mailbox_read (struct snd_sof_dev *sdev,u32 offset,void *message,size_t bytes);
sound/soc/sof/amd/renoir.c +0 -1
@@ -150,7 +150,6 @@ const struct snd_sof_dsp_ops sof_renoir_ops = {/*IPC */ .send_msg = acp_sof_ipc_send_msg, .ipc_msg_data = acp_sof_ipc_msg_data, - .ipc_pcm_params = acp_sof_ipc_pcm_params, .get_mailbox_offset = acp_sof_ipc_get_mailbox_offset, .irq_thread = acp_sof_ipc_irq_thread, .fw_ready = sof_fw_ready,
Signature · 1 line
2.30.2
PATCH 4/10 ASoC: SOF: amd: Flush cache after ATU_BASE_ADDR_GRP register update
In reply to Pierre-Louis BossartFrom: Ajit Kumar Pandey <[email protected]>
ACP_SRAM_PTE block has cache that needs to be flushed after every PTE updates. This patch updates ACPAXI2AXI_ATU_CTRL register to flush cache after updating PTE with stream physical address.
--- sound/soc/sof/amd/acp-stream.c | 3 +++ 1 file changed, 3 insertions(+)
sound/soc/sof/amd/acp-stream.c +3 -0
@@ -115,6 +115,9 @@ int acp_dsp_stream_config(struct snd_sof_dev *sdev, struct acp_dsp_stream *strea offset +=8 ; } +/* Flush ATU Cache after PTE Update */ +snd_sof_dsp_write (sdev,ACP_DSP_BAR ,ACPAXI2AXI_ATU_CTRL ,ACP_ATU_CACHE_INVALID ); +return 0 ; }
Signature · 1 line
2.30.2
PATCH 5/10 ASoC: SOF: amd: Use semaphore register to synchronize ipc's irq
In reply to Pierre-Louis BossartFrom: Ajit Kumar Pandey <[email protected]>
Add lock and unlock around ipc irq handling code using hw semaphore register that exhibit special property for register read calls. As host and DSP firmware uses few shared registers, there is a possible race condition around those shared registers values. This lock ensure synchronization between Firmware and host ipc interrupts.
--- sound/soc/sof/amd/acp-dsp-offset.h | 1 + sound/soc/sof/amd/acp-ipc.c | 14 ++++++++++++++ sound/soc/sof/amd/acp.c | 15 ++++++++++++++- sound/soc/sof/amd/acp.h | 1 + 4 files changed, 30 insertions(+), 1 deletion(-)
sound/soc/sof/amd/acp-dsp-offset.h +1 -0
@@ -61,6 +61,7 @@#define ACP_DSP_SW_INTR_STAT 0x1818#define ACP_SW_INTR_TRIG 0x181C#define ACP_ERROR_STATUS 0x18C4 +#define ACP_AXI2DAGB_SEM_0 0x1880/* Registers from ACP_SHA block */ #define ACP_SHA_DSP_FW_QUALIFIER 0x1C70
sound/soc/sof/amd/acp-ipc.c +14 -0
@@ -62,12 +62,26 @@ int acp_sof_ipc_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg) {struct acp_dev_data *adata = sdev->pdata->hw_pdata;unsigned int offset = offsetof(struct scratch_ipc_conf , sof_in_box); +unsigned int count =ACP_HW_SEM_RETRY_COUNT ; + +while (snd_sof_dsp_read (sdev,ACP_DSP_BAR ,ACP_AXI2DAGB_SEM_0 )) { +/* Wait until acquired HW Semaphore Lock or timeout*/ + count--; +if (!count) { +dev_err (sdev->dev,"%s: Failed to acquire HW lock\n" , __func__); +return -EINVAL ; + } + };acp_mailbox_write (sdev, offset, msg->msg_data, msg->msg_size);acp_ipc_host_msg_set (sdev);/* Trigger host to dsp interrupt for the msg */ acpbus_trigger_host_to_dsp_swintr (adata); + +/* Unlock or Release HW Semaphore */ +snd_sof_dsp_write (sdev,ACP_DSP_BAR ,ACP_AXI2DAGB_SEM_0 ,0x0 ); +return 0 ; }EXPORT_SYMBOL_NS (acp_sof_ipc_send_msg,SND_SOC_SOF_AMD_COMMON );
sound/soc/sof/amd/acp.c +14 -1
@@ -273,7 +273,7 @@ static int acp_memory_init(struct snd_sof_dev *sdev)static irqreturn_t acp_irq_thread (int irq,void *context) {struct snd_sof_dev *sdev = context; -unsigned int val; +unsigned int val, count =ACP_HW_SEM_RETRY_COUNT ; val =snd_sof_dsp_read (sdev,ACP_DSP_BAR ,ACP_EXTERNAL_INTR_STAT );if (val &ACP_SHA_STAT ) {
@@ -284,9 +284,22 @@ static irqreturn_t acp_irq_thread(int irq, void *context) val =snd_sof_dsp_read (sdev,ACP_DSP_BAR ,ACP_DSP_SW_INTR_STAT );if (val &ACP_DSP_TO_HOST_IRQ ) { +while (snd_sof_dsp_read (sdev,ACP_DSP_BAR ,ACP_AXI2DAGB_SEM_0 )) { +/* Wait until acquired HW Semaphore lock or timeout */ + count--; +if (!count) { +dev_err (sdev->dev,"%s: Failed to acquire HW lock\n" , __func__); +return IRQ_NONE ; + } + }; +sof_ops (sdev)->irq_thread (irq, sdev); val |=ACP_DSP_TO_HOST_IRQ ;snd_sof_dsp_write (sdev,ACP_DSP_BAR ,ACP_DSP_SW_INTR_STAT , val); + +/* Unlock or Release HW Semaphore */ +snd_sof_dsp_write (sdev,ACP_DSP_BAR ,ACP_AXI2DAGB_SEM_0 ,0x0 ); +return IRQ_HANDLED ; }
sound/soc/sof/amd/acp.h +1 -0
@@ -17,6 +17,7 @@#define ACP_DSP_BAR 0 +#define ACP_HW_SEM_RETRY_COUNT 10#define ACP_REG_POLL_INTERVAL 500#define ACP_REG_POLL_TIMEOUT_US 2000#define ACP_DMA_COMPLETE_TIMEOUT_US 5000
Signature · 1 line
2.30.2
PATCH 6/10 ASoC: SOF: amd: Move group register configuration to acp-loader
In reply to Pierre-Louis BossartFrom: Ajit Kumar Pandey <[email protected]>
We are using PTE_GRP1 for DMA operations to load firmware binaries but we are enabling PTE_GRP and flushing ATU cache much before in probe callbacks. This can cause issue if we try to load firmware runtime during system resume as probe callback will not be invoked hence PTE_GRP will not be enabled. Moreover it makes more sense to flush the cache after register configuration.
Move PTE group register configuration to acp-loader within pre_fw_run callback to avoid such issue.
--- sound/soc/sof/amd/acp-loader.c | 9 +++++++++ sound/soc/sof/amd/acp.c | 14 -------------- 2 files changed, 9 insertions(+), 14 deletions(-)
sound/soc/sof/amd/acp-loader.c +9 -0
@@ -127,6 +127,12 @@ static void configure_pte_for_fw_loading(int type, int num_pages, struct acp_devreturn ; } +/* Group Enable */ +snd_sof_dsp_write (sdev,ACP_DSP_BAR ,ACPAXI2AXI_ATU_BASE_ADDR_GRP_1 , +ACP_SRAM_PTE_OFFSET |BIT (31 )); +snd_sof_dsp_write (sdev,ACP_DSP_BAR ,ACPAXI2AXI_ATU_PAGE_SIZE_GRP_1 , +PAGE_SIZE_4K_ENABLE ); +for (page_idx =0 ; page_idx < num_pages; page_idx++) { low =lower_32_bits (addr); high =upper_32_bits (addr);
@@ -136,6 +142,9 @@ static void configure_pte_for_fw_loading(int type, int num_pages, struct acp_dev offset +=8 ; addr +=PAGE_SIZE ; } + +/* Flush ATU Cache after PTE Update */ +snd_sof_dsp_write (sdev,ACP_DSP_BAR ,ACPAXI2AXI_ATU_CTRL ,ACP_ATU_CACHE_INVALID ); }/* pre fw run operations */
sound/soc/sof/amd/acp.c +0 -14
@@ -36,19 +36,6 @@ static int smn_read(struct pci_dev *dev, u32 smn_addr, u32 *data)return 0 ; } -static void configure_acp_groupregisters (struct acp_dev_data *adata) -{ -struct snd_sof_dev *sdev = adata->dev; - -/* Group Enable */ -snd_sof_dsp_write (sdev,ACP_DSP_BAR ,ACPAXI2AXI_ATU_BASE_ADDR_GRP_1 , -ACP_SRAM_PTE_OFFSET |BIT (31 )); -snd_sof_dsp_write (sdev,ACP_DSP_BAR ,ACPAXI2AXI_ATU_PAGE_SIZE_GRP_1 , -PAGE_SIZE_4K_ENABLE ); - -snd_sof_dsp_write (sdev,ACP_DSP_BAR ,ACPAXI2AXI_ATU_CTRL ,ACP_ATU_CACHE_INVALID ); -} -static void init_dma_descriptor (struct acp_dev_data *adata) {struct snd_sof_dev *sdev = adata->dev;
@@ -264,7 +251,6 @@ static int acp_memory_init(struct snd_sof_dev *sdev)snd_sof_dsp_update_bits (sdev,ACP_DSP_BAR ,ACP_DSP_SW_INTR_CNTL ,ACP_DSP_INTR_EN_MASK ,ACP_DSP_INTR_EN_MASK ); -configure_acp_groupregisters (adata);init_dma_descriptor (adata);return 0 ;
Signature · 1 line
2.30.2
PATCH 7/10 ASoC: SOF: amd: Increase ACP_HW_SEM_RETRY_COUNT value
In reply to Pierre-Louis BossartFrom: Ajit Kumar Pandey <[email protected]>
Host is trying to acquire semaphore lock based on HW_SEM_RETRY_COUNT value which is set to 10 by default. So host will loop for 10 times trying to acquire lock before giving error msg "Failed to acquire HW lock". Though this loop count of 10 is good enough with most of the times but we have observed such failure msg in very few cases(~5 %).
Increase ACP_HW_SEM_RETRY_COUNT to avoid such issue and loop for a significant time period before throwing error. We're setting newer loop count to quite higher value of 10K but it's very unlikely that it will loop for this count, since for most of the cases lock will get acquired at much lesser loop iterations.
--- sound/soc/sof/amd/acp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/sof/amd/acp.h +1 -1
@@ -17,7 +17,7 @@#define ACP_DSP_BAR 0 -#define ACP_HW_SEM_RETRY_COUNT 10 +#define ACP_HW_SEM_RETRY_COUNT 10000#define ACP_REG_POLL_INTERVAL 500#define ACP_REG_POLL_TIMEOUT_US 2000#define ACP_DMA_COMPLETE_TIMEOUT_US 5000
Signature · 1 line
2.30.2
PATCH 8/10 ASoC: SOF: fix 32 signed bit overflow
In reply to Pierre-Louis BossartFrom: Curtis Malainey <[email protected]>
Shifting in a signed 32bit container past the signed bit is technically undefined behaviour. Fix by using unsigned types. Found via cppcheck.
--- include/sound/sof/header.h | 2 +- include/uapi/sound/sof/abi.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
include/sound/sof/header.h +1 -1
@@ -31,7 +31,7 @@/* Global Message - Generic */ #define SOF_GLB_TYPE_SHIFT 28 -#define SOF_GLB_TYPE_MASK (0xfL << SOF_GLB_TYPE_SHIFT) +#define SOF_GLB_TYPE_MASK (0xfUL << SOF_GLB_TYPE_SHIFT)#define SOF_GLB_TYPE (x) ((x) << SOF_GLB_TYPE_SHIFT)/* Command Message - Generic */
include/uapi/sound/sof/abi.h +1 -1
@@ -27,7 +27,7 @@/* SOF ABI version major, minor and patch numbers */ #define SOF_ABI_MAJOR 3#define SOF_ABI_MINOR 19 -#define SOF_ABI_PATCH 0 +#define SOF_ABI_PATCH 1/* SOF ABI version number. Format within 32bit word is MMmmmppp */ #define SOF_ABI_MAJOR_SHIFT 24
Signature · 1 line
2.30.2
PATCH 9/10 ASoC: SOF: debug: clarify operator precedence
In reply to Pierre-Louis Bossartcppcheck warning:
sound/soc/sof/debug.c:398:46: style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation]
char *level = flags & SOF_DBG_DUMP_OPTIONAL ? KERN_DEBUG : KERN_ERR;
^--- sound/soc/sof/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/sof/debug.c +1 -1
@@ -395,7 +395,7 @@ static void snd_sof_dbg_print_fw_state(struct snd_sof_dev *sdev, const char *levvoid snd_sof_dsp_dbg_dump (struct snd_sof_dev *sdev,const char *msg,u32 flags) { -char *level = flags &SOF_DBG_DUMP_OPTIONAL ?KERN_DEBUG :KERN_ERR ; +char *level = (flags &SOF_DBG_DUMP_OPTIONAL ) ?KERN_DEBUG :KERN_ERR ;bool print_all =sof_debug_check_flag (SOF_DBG_PRINT_ALL_DUMPS );if (flags &SOF_DBG_DUMP_OPTIONAL && !print_all)
Signature · 1 line
2.30.2
PATCH 10/10 ASoC: SOF: Intel: hda: clarify operator precedence
In reply to Pierre-Louis Bossartcppcheck warning
sound/soc/sof/intel/hda.c:545:46: style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation]
char *level = flags & SOF_DBG_DUMP_OPTIONAL ? KERN_DEBUG : KERN_ERR;
--- sound/soc/sof/intel/hda.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/sof/intel/hda.c +1 -1
@@ -534,7 +534,7 @@ static void hda_dsp_dump_ext_rom_status(struct snd_sof_dev *sdev, const char *levoid hda_dsp_dump (struct snd_sof_dev *sdev,u32 flags) { -char *level = flags &SOF_DBG_DUMP_OPTIONAL ?KERN_DEBUG :KERN_ERR ; +char *level = (flags &SOF_DBG_DUMP_OPTIONAL ) ?KERN_DEBUG :KERN_ERR ;struct sof_ipc_dsp_oops_xtensa xoops;struct sof_ipc_panic_info panic_info;u32 stack[HDA_DSP_STACK_DUMP_SIZE ];
Signature · 1 line
2.30.2
Mark Brown
maintainerQuoted 10 lines · Pierre-Louis Bossart
A couple of updates for Intel and AMD hardware, along with minor cleanups
Ajit Kumar Pandey (4):
ASoC: SOF: amd: Flush cache afterATU_BASE_ADDR_GRPregister update
ASoC: SOF: amd: Use semaphore register to synchronize ipc's irq
ASoC: SOF: amd: Move group register configuration to acp-loader
ASoC: SOF: amd: IncreaseACP_HW_SEM_RETRY_COUNTvalue[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[01/10] ASoC: SOF: Intel: pci-tgl: add RPL-S support
commit: d66c57c5ff8a24859fe7506d290d0b705c2576c0
[02/10] ASoC: SOF: amd: acp-pcm: Take buffer information directly from runtime
commit: edca0623f6d7928b312780d4e885258ca9e562fe
[03/10] ASoC: SOF: amd: Do not set ipc_pcm_params ops as it is optional
commit: 9c2611b2a620f90219f85e4b40bbe3e26ab81e2c
[04/10] ASoC: SOF: amd: Flush cache after ATU_BASE_ADDR_GRP register update
commit: b7485ec850591ad62fde0526bd7fdc56cdc04efd
[05/10] ASoC: SOF: amd: Use semaphore register to synchronize ipc's irq
commit: dc0d4ed26dd2166b47c29d6a9829ac798e62a0fc
[06/10] ASoC: SOF: amd: Move group register configuration to acp-loader
commit: 7cf467ac9cf33f0975095f080a79f6ec6d9be5b6
[07/10] ASoC: SOF: amd: Increase ACP_HW_SEM_RETRY_COUNT value
commit: 8e85cab858562734b9d323f392ba9956bbdc133c
[08/10] ASoC: SOF: fix 32 signed bit overflow
commit: 4aaa06b227f737da5c10feb93a6b203920d5a1e7
[09/10] ASoC: SOF: debug: clarify operator precedence
commit: 9188812539d1d9a13dac690c95ec657259859ba4
[10/10] ASoC: SOF: Intel: hda: clarify operator precedence
commit: 0f33105bb2f77c870542d5bc08cf94b8c4e26f36All 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