Skip to content

Commit bcaad35

Browse files
committed
ASoC: SOF: clients: Add API to manage the module refcount of SOF core
The SOF core module (the device driver of the DSP) needs to be protected against removal when a client is active and needs the core to be present during it's active operation. sof_client_core_moduleget/put can be use by client drivers to manage the refcount on the core's module to prevent such a case. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent 9e32894 commit bcaad35

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

sound/soc/sof/sof-client.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,26 @@ const struct sof_ipc_fw_version *sof_client_get_fw_version(struct sof_client_dev
231231
}
232232
EXPORT_SYMBOL_NS_GPL(sof_client_get_fw_version, SND_SOC_SOF_CLIENT);
233233

234+
/* module refcount management of SOF core */
235+
int sof_client_core_module_get(struct sof_client_dev *cdev)
236+
{
237+
struct snd_sof_dev *sdev = sof_client_dev_to_sof_dev(cdev);
238+
239+
if (!try_module_get(sdev->dev->driver->owner))
240+
return -ENODEV;
241+
242+
return 0;
243+
}
244+
EXPORT_SYMBOL_NS_GPL(sof_client_core_module_get, SND_SOC_SOF_CLIENT);
245+
246+
void sof_client_core_module_put(struct sof_client_dev *cdev)
247+
{
248+
struct snd_sof_dev *sdev = sof_client_dev_to_sof_dev(cdev);
249+
250+
module_put(sdev->dev->driver->owner);
251+
}
252+
EXPORT_SYMBOL_NS_GPL(sof_client_core_module_put, SND_SOC_SOF_CLIENT);
253+
234254
/* IPC event handling */
235255
void sof_client_ipc_rx_dispatcher(struct snd_sof_dev *sdev, void *full_msg)
236256
{

sound/soc/sof/sof-client.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ struct dentry *sof_client_get_debugfs_root(struct sof_client_dev *cdev);
4242
struct device *sof_client_get_dma_dev(struct sof_client_dev *cdev);
4343
const struct sof_ipc_fw_version *sof_client_get_fw_version(struct sof_client_dev *cdev);
4444

45+
/* module refcount management of SOF core */
46+
int sof_client_core_module_get(struct sof_client_dev *cdev);
47+
void sof_client_core_module_put(struct sof_client_dev *cdev);
48+
4549
/* IPC notification */
4650
typedef void (*sof_client_event_callback)(struct sof_client_dev *cdev,
4751
void *full_msg);

0 commit comments

Comments
 (0)