Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add Probe functionality support for amd platforms.

Merge series from V sujith kumar Reddy <vsujithkumar.reddy@amd.corp-partner.google.com>:

The Patch series consists of probe functionality support for amd
platforms.

+200
+8
sound/soc/sof/amd/Kconfig
··· 21 21 select SND_SOC_SOF_PCI_DEV 22 22 select SND_AMD_ACP_CONFIG 23 23 select SND_SOC_SOF_XTENSA 24 + select SND_SOC_SOF_ACP_PROBES 24 25 select SND_SOC_ACPI if ACPI 25 26 help 26 27 This option is not user-selectable but automatically handled by ··· 42 41 Select this option for SOF support on AMD Rembrandt platform 43 42 Say Y if you want to enable SOF on Rembrandt. 44 43 If unsure select "N". 44 + 45 + config SND_SOC_SOF_ACP_PROBES 46 + tristate 47 + select SND_SOC_SOF_DEBUG_PROBES 48 + help 49 + This option is not user-selectable but automatically handled by 50 + 'select' statements at a higher level 45 51 46 52 endif
+1
sound/soc/sof/amd/Makefile
··· 5 5 # Copyright(c) 2021 Advanced Micro Devices, Inc. All rights reserved. 6 6 7 7 snd-sof-amd-acp-objs := acp.o acp-loader.o acp-ipc.o acp-pcm.o acp-stream.o acp-trace.o acp-common.o 8 + snd-sof-amd-acp-$(CONFIG_SND_SOC_SOF_ACP_PROBES) = acp-probes.o 8 9 snd-sof-amd-renoir-objs := pci-rn.o renoir.o 9 10 snd-sof-amd-rembrandt-objs := pci-rmb.o rembrandt.o 10 11
+4
sound/soc/sof/amd/acp-common.c
··· 196 196 .dbg_dump = amd_sof_dump, 197 197 .debugfs_add_region_item = snd_sof_debugfs_add_region_item_iomem, 198 198 .dsp_arch_ops = &sof_xtensa_arch_ops, 199 + 200 + /* probe client device registation */ 201 + .register_ipc_clients = acp_probes_register, 202 + .unregister_ipc_clients = acp_probes_unregister, 199 203 }; 200 204 EXPORT_SYMBOL_NS(sof_acp_common_ops, SND_SOC_SOF_AMD_COMMON); 201 205
+26
sound/soc/sof/amd/acp-ipc.c
··· 155 155 irqreturn_t acp_sof_ipc_irq_thread(int irq, void *context) 156 156 { 157 157 struct snd_sof_dev *sdev = context; 158 + const struct sof_amd_acp_desc *desc = get_chip_info(sdev->pdata); 159 + struct acp_dev_data *adata = sdev->pdata->hw_pdata; 158 160 unsigned int dsp_msg_write = sdev->debug_box.offset + 159 161 offsetof(struct scratch_ipc_conf, sof_dsp_msg_write); 160 162 unsigned int dsp_ack_write = sdev->debug_box.offset + ··· 200 198 if ((status & SOF_IPC_PANIC_MAGIC_MASK) == SOF_IPC_PANIC_MAGIC) { 201 199 snd_sof_dsp_panic(sdev, sdev->dsp_oops_offset, true); 202 200 return IRQ_HANDLED; 201 + } 202 + 203 + if (desc->probe_reg_offset) { 204 + u32 val; 205 + u32 posn; 206 + 207 + /* Probe register consists of two parts 208 + * (0-30) bit has cumulative position value 209 + * 31 bit is a synchronization flag between DSP and CPU 210 + * for the position update 211 + */ 212 + val = snd_sof_dsp_read(sdev, ACP_DSP_BAR, desc->probe_reg_offset); 213 + if (val & PROBE_STATUS_BIT) { 214 + posn = val & ~PROBE_STATUS_BIT; 215 + if (adata->probe_stream) { 216 + /* Probe related posn value is of 31 bits limited to 2GB 217 + * once wrapped DSP won't send posn interrupt. 218 + */ 219 + adata->probe_stream->cstream_posn = posn; 220 + snd_compr_fragment_elapsed(adata->probe_stream->cstream); 221 + snd_sof_dsp_write(sdev, ACP_DSP_BAR, desc->probe_reg_offset, posn); 222 + ipc_irq = true; 223 + } 224 + } 203 225 } 204 226 205 227 if (!ipc_irq)
+147
sound/soc/sof/amd/acp-probes.c
··· 1 + // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) 2 + // 3 + // This file is provided under a dual BSD/GPLv2 license. When using or 4 + // redistributing this file, you may do so under either license. 5 + // 6 + // Copyright(c) 2023 Advanced Micro Devices, Inc. 7 + // 8 + // Authors: V Sujith Kumar Reddy <Vsujithkumar.Reddy@amd.com> 9 + 10 + /* 11 + * Probe interface for generic AMD audio ACP DSP block 12 + */ 13 + 14 + #include <linux/module.h> 15 + #include <sound/soc.h> 16 + #include "../sof-priv.h" 17 + #include "../sof-client-probes.h" 18 + #include "../sof-client.h" 19 + #include "../ops.h" 20 + #include "acp.h" 21 + #include "acp-dsp-offset.h" 22 + 23 + static int acp_probes_compr_startup(struct sof_client_dev *cdev, 24 + struct snd_compr_stream *cstream, 25 + struct snd_soc_dai *dai, u32 *stream_id) 26 + { 27 + struct snd_sof_dev *sdev = sof_client_dev_to_sof_dev(cdev); 28 + struct acp_dsp_stream *stream; 29 + struct acp_dev_data *adata; 30 + 31 + adata = sdev->pdata->hw_pdata; 32 + stream = acp_dsp_stream_get(sdev, 0); 33 + if (!stream) 34 + return -ENODEV; 35 + 36 + stream->cstream = cstream; 37 + cstream->runtime->private_data = stream; 38 + 39 + adata->probe_stream = stream; 40 + *stream_id = stream->stream_tag; 41 + 42 + return 0; 43 + } 44 + 45 + static int acp_probes_compr_shutdown(struct sof_client_dev *cdev, 46 + struct snd_compr_stream *cstream, 47 + struct snd_soc_dai *dai) 48 + { 49 + struct snd_sof_dev *sdev = sof_client_dev_to_sof_dev(cdev); 50 + struct acp_dsp_stream *stream = cstream->runtime->private_data; 51 + struct acp_dev_data *adata; 52 + int ret; 53 + 54 + ret = acp_dsp_stream_put(sdev, stream); 55 + if (ret < 0) { 56 + dev_err(sdev->dev, "Failed to release probe compress stream\n"); 57 + return ret; 58 + } 59 + 60 + adata = sdev->pdata->hw_pdata; 61 + stream->cstream = NULL; 62 + cstream->runtime->private_data = NULL; 63 + adata->probe_stream = NULL; 64 + 65 + return 0; 66 + } 67 + 68 + static int acp_probes_compr_set_params(struct sof_client_dev *cdev, 69 + struct snd_compr_stream *cstream, 70 + struct snd_compr_params *params, 71 + struct snd_soc_dai *dai) 72 + { 73 + struct snd_sof_dev *sdev = sof_client_dev_to_sof_dev(cdev); 74 + struct acp_dsp_stream *stream = cstream->runtime->private_data; 75 + unsigned int buf_offset, index; 76 + u32 size; 77 + int ret; 78 + 79 + stream->dmab = cstream->runtime->dma_buffer_p; 80 + stream->num_pages = PFN_UP(cstream->runtime->dma_bytes); 81 + size = cstream->runtime->buffer_size; 82 + 83 + ret = acp_dsp_stream_config(sdev, stream); 84 + if (ret < 0) { 85 + acp_dsp_stream_put(sdev, stream); 86 + return ret; 87 + } 88 + 89 + /* write buffer size of stream in scratch memory */ 90 + 91 + buf_offset = sdev->debug_box.offset + 92 + offsetof(struct scratch_reg_conf, buf_size); 93 + index = stream->stream_tag - 1; 94 + buf_offset = buf_offset + index * 4; 95 + 96 + snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_SCRATCH_REG_0 + buf_offset, size); 97 + 98 + return 0; 99 + } 100 + 101 + static int acp_probes_compr_trigger(struct sof_client_dev *cdev, 102 + struct snd_compr_stream *cstream, 103 + int cmd, struct snd_soc_dai *dai) 104 + { 105 + /* Nothing to do here, as it is a mandatory callback just defined */ 106 + return 0; 107 + } 108 + 109 + static int acp_probes_compr_pointer(struct sof_client_dev *cdev, 110 + struct snd_compr_stream *cstream, 111 + struct snd_compr_tstamp *tstamp, 112 + struct snd_soc_dai *dai) 113 + { 114 + struct acp_dsp_stream *stream = cstream->runtime->private_data; 115 + struct snd_soc_pcm_stream *pstream; 116 + 117 + pstream = &dai->driver->capture; 118 + tstamp->copied_total = stream->cstream_posn; 119 + tstamp->sampling_rate = snd_pcm_rate_bit_to_rate(pstream->rates); 120 + 121 + return 0; 122 + } 123 + 124 + /* SOF client implementation */ 125 + static const struct sof_probes_host_ops acp_probes_ops = { 126 + .startup = acp_probes_compr_startup, 127 + .shutdown = acp_probes_compr_shutdown, 128 + .set_params = acp_probes_compr_set_params, 129 + .trigger = acp_probes_compr_trigger, 130 + .pointer = acp_probes_compr_pointer, 131 + }; 132 + 133 + int acp_probes_register(struct snd_sof_dev *sdev) 134 + { 135 + return sof_client_dev_register(sdev, "acp-probes", 0, &acp_probes_ops, 136 + sizeof(acp_probes_ops)); 137 + } 138 + EXPORT_SYMBOL_NS(acp_probes_register, SND_SOC_SOF_AMD_COMMON); 139 + 140 + void acp_probes_unregister(struct snd_sof_dev *sdev) 141 + { 142 + sof_client_dev_unregister(sdev, "acp-probes", 0); 143 + } 144 + EXPORT_SYMBOL_NS(acp_probes_unregister, SND_SOC_SOF_AMD_COMMON); 145 + 146 + MODULE_IMPORT_NS(SND_SOC_SOF_CLIENT); 147 +
+9
sound/soc/sof/amd/acp.h
··· 77 77 #define AMD_STACK_DUMP_SIZE 32 78 78 79 79 #define SRAM1_SIZE 0x13A000 80 + #define PROBE_STATUS_BIT BIT(31) 80 81 81 82 enum clock_source { 82 83 ACP_CLOCK_96M = 0, ··· 157 156 int active; 158 157 unsigned int reg_offset; 159 158 size_t posn_offset; 159 + struct snd_compr_stream *cstream; 160 + u64 cstream_posn; 160 161 }; 161 162 162 163 struct sof_amd_acp_desc { ··· 171 168 u32 hw_semaphore_offset; 172 169 u32 acp_clkmux_sel; 173 170 u32 fusion_dsp_offset; 171 + u32 probe_reg_offset; 174 172 }; 175 173 176 174 /* Common device data struct for ACP devices */ ··· 190 186 struct acp_dsp_stream stream_buf[ACP_MAX_STREAM]; 191 187 struct acp_dsp_stream *dtrace_stream; 192 188 struct pci_dev *smn_dev; 189 + struct acp_dsp_stream *probe_stream; 193 190 }; 194 191 195 192 void memcpy_to_scratch(struct snd_sof_dev *sdev, u32 offset, unsigned int *src, size_t bytes); ··· 278 273 279 274 return desc->chip_info; 280 275 } 276 + 277 + int acp_probes_register(struct snd_sof_dev *sdev); 278 + void acp_probes_unregister(struct snd_sof_dev *sdev); 279 + 281 280 #endif
+2
sound/soc/sof/amd/pci-rmb.c
··· 25 25 26 26 #define ACP6x_REG_START 0x1240000 27 27 #define ACP6x_REG_END 0x125C000 28 + #define ACP6X_FUTURE_REG_ACLK_0 0x1854 28 29 29 30 static const struct sof_amd_acp_desc rembrandt_chip_info = { 30 31 .rev = 6, ··· 37 36 .hw_semaphore_offset = ACP6X_AXI2DAGB_SEM_0, 38 37 .acp_clkmux_sel = ACP6X_CLKMUX_SEL, 39 38 .fusion_dsp_offset = ACP6X_DSP_FUSION_RUNSTALL, 39 + .probe_reg_offset = ACP6X_FUTURE_REG_ACLK_0, 40 40 }; 41 41 42 42 static const struct sof_dev_desc rembrandt_desc = {
+2
sound/soc/sof/amd/pci-rn.c
··· 25 25 26 26 #define ACP3x_REG_START 0x1240000 27 27 #define ACP3x_REG_END 0x125C000 28 + #define ACP3X_FUTURE_REG_ACLK_0 0x1860 28 29 29 30 static const struct sof_amd_acp_desc renoir_chip_info = { 30 31 .rev = 3, ··· 36 35 .sram_pte_offset = ACP3X_SRAM_PTE_OFFSET, 37 36 .hw_semaphore_offset = ACP3X_AXI2DAGB_SEM_0, 38 37 .acp_clkmux_sel = ACP3X_CLKMUX_SEL, 38 + .probe_reg_offset = ACP3X_FUTURE_REG_ACLK_0, 39 39 }; 40 40 41 41 static const struct sof_dev_desc renoir_desc = {
+1
sound/soc/sof/sof-client-probes.c
··· 523 523 524 524 static const struct auxiliary_device_id sof_probes_client_id_table[] = { 525 525 { .name = "snd_sof.hda-probes", }, 526 + { .name = "snd_sof.acp-probes", }, 526 527 {}, 527 528 }; 528 529 MODULE_DEVICE_TABLE(auxiliary, sof_probes_client_id_table);