Skip to content

Commit 2b077e9

Browse files
ASoC: SOF: amd: add post-firmware-run delay for ACP7x
Add sof_acp7x_post_fw_run_delay() to introduce a small delay after firmware boot completion on resume to avoid DSP entering an unrecoverable state. Register it as post_fw_run callback only when the ACPI property acp-sof-post_fw_run_delay is set, following the same pattern used by the Vangogh platform. Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
1 parent 3c862a6 commit 2b077e9

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

sound/soc/sof/amd/acp7x.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* Hardware interface for Audio DSP on ACP7.B/7.F platforms
1212
*/
1313

14+
#include <linux/acpi.h>
1415
#include <linux/module.h>
1516
#include <linux/platform_device.h>
1617
#include <linux/pci.h>
@@ -127,11 +128,29 @@ static struct snd_soc_dai_driver acp7x_sof_dai[] = {
127128
},
128129
};
129130

131+
static int sof_acp7x_post_fw_run_delay(struct snd_sof_dev *sdev)
132+
{
133+
/*
134+
* Resuming from suspend in some cases may cause the DSP firmware
135+
* to enter an unrecoverable faulty state. Delaying a bit any host
136+
* to DSP transmission right after firmware boot completion seems
137+
* to resolve the issue.
138+
*/
139+
if (!sdev->first_boot)
140+
usleep_range(100, 150);
141+
142+
return 0;
143+
}
144+
130145
struct snd_sof_dsp_ops sof_acp7x_ops;
131146
EXPORT_SYMBOL_NS(sof_acp7x_ops, "SND_SOC_SOF_AMD_COMMON");
132147

133148
int sof_acp7x_ops_init(struct snd_sof_dev *sdev)
134149
{
150+
struct acpi_device *adev = ACPI_COMPANION(&to_pci_dev(sdev->dev)->dev);
151+
const union acpi_object *obj;
152+
int acp_sof_post_fw_run_delay = 0;
153+
135154
/* common defaults */
136155
memcpy(&sof_acp7x_ops, &sof_acp_common_ops, sizeof(struct snd_sof_dsp_ops));
137156

@@ -140,5 +159,14 @@ int sof_acp7x_ops_init(struct snd_sof_dev *sdev)
140159
sof_acp7x_ops.probe = amd_sof_acp7x_probe;
141160
sof_acp7x_ops.remove = amd_sof_acp7x_remove;
142161

162+
if (adev) {
163+
if (!acpi_dev_get_property(adev, "acp-sof-post_fw_run_delay",
164+
ACPI_TYPE_INTEGER, &obj))
165+
acp_sof_post_fw_run_delay = obj->integer.value;
166+
}
167+
168+
if (acp_sof_post_fw_run_delay)
169+
sof_acp7x_ops.post_fw_run = sof_acp7x_post_fw_run_delay;
170+
143171
return 0;
144172
}

0 commit comments

Comments
 (0)