Skip to content

Commit

Permalink
ASoC: SOF: debug-dsp-ops: Add op for unloading firmware
Browse files Browse the repository at this point in the history
Unload any existing firmware and set the fw_state to PREPARE in
preparation for a subsequent firmware boot.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
  • Loading branch information
ranj063 authored and plbossart committed Jul 30, 2024
1 parent 98ab12f commit 07f1b50
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion sound/soc/sof/debug-dsp-ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ static int sof_dsp_ops_set_power_state(struct snd_sof_dev *sdev, char *state)
return 0;
}

static void sof_dsp_ops_unload_firmware(struct snd_sof_dev *sdev)
{
/* release the currently loaded firmware */
if (sdev->basefw.fw)
snd_sof_fw_unload(sdev);

sof_set_fw_state(sdev, SOF_FW_BOOT_PREPARE);
}

static int sof_dsp_ops_boot_firmware(struct snd_sof_dev *sdev)
{
const char *fw_filename = NULL;
Expand Down Expand Up @@ -193,6 +202,17 @@ static ssize_t sof_dsp_ops_tester_dfs_write(struct file *file, const char __user
size_t size;
char *string;

if (!strcmp(dentry->d_name.name, "unload_fw")) {
string = kzalloc(count + 1, GFP_KERNEL);
if (!string)
return -ENOMEM;

size = simple_write_to_buffer(string, count, ppos, buffer, count);
kfree(string);
sof_dsp_ops_unload_firmware(sdev);
return size;
}

if (!strcmp(dentry->d_name.name, "boot_fw")) {
int ret;
string = kzalloc(count + 1, GFP_KERNEL);
Expand Down Expand Up @@ -306,5 +326,9 @@ int sof_dbg_dsp_ops_test_init(struct snd_sof_dev *sdev)
if (ret < 0)
return ret;

return sof_dsp_dsp_ops_create_dfse(sdev, "fw_state", dsp_ops_debugfs, 0444);
ret = sof_dsp_dsp_ops_create_dfse(sdev, "fw_state", dsp_ops_debugfs, 0444);
if (ret < 0)
return ret;

return sof_dsp_dsp_ops_create_dfse(sdev, "unload_fw", dsp_ops_debugfs, 0222);
}

0 comments on commit 07f1b50

Please sign in to comment.