summaryrefslogtreecommitdiff
path: root/sound/soc/sof/sof-client-ipc-msg-injector.c
AgeCommit message (Collapse)Author
2022-05-17ASoC: SOF: ipc-msg-injector: Cap the rmaining to count in IPC4 modePeter Ujfalusi
If user space provides smaller buffer than the IPC4 reply then it is possible that we corrupt user space memory since the IPC4 dfs_read function is not using the count directly in copy_to_user() due to the nature of an IPC4 message. Cap the remaining counter to make sure that we are not writing too much to the user space provided buffer. Add a check also to make sure that the buffer is at least the size of the IPC4 header. Fixes: 066c67624d8c: "ASoC: SOF: ipc-msg-injector: Add support for IPC4 messages" Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Link: https://lore.kernel.org/r/20220516092442.17027-1-peter.ujfalusi@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-05-09ASoC: SOF: ipc-msg-injector: Add support for IPC4 messagesPeter Ujfalusi
The IPC message representation of an IPC4 differs from the IPC3 version significantly. The message for IPC4 should be written to the debugfs file in this form: 0-7 IPC4 header (2x u32) 8- additional payload, if any The reply is given back in the same form. The message size limitation is the same as with the IPC3, only messages which can fit to the mailbox can be injected (and received). Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://lore.kernel.org/r/20220506132647.18690-8-peter.ujfalusi@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-05-09ASoC: SOF: ipc-msg-injector: Separate the message sendingPeter Ujfalusi
Move out the code for sending the IPC message into a separate helper function in preparation for support for handling IPC4 communication. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://lore.kernel.org/r/20220506132647.18690-7-peter.ujfalusi@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-05-09ASoC: SOF: ipc-msg-injector: Query the maximum IPC payload sizePeter Ujfalusi
Instead of using the SOF_IPC_MSG_MAX_SIZE as the maximum payload size for and IPC message, use the provided API to query it. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://lore.kernel.org/r/20220506132647.18690-3-peter.ujfalusi@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-04-27ASoC: SOF: sof-client-ipc-msg-injector: use pm_runtime_resume_and_get()Pierre-Louis Bossart
Use pm_runtime_resume_and_get() to replace the pm_runtime_get_sync() and pm_runtime_put_noidle() pattern. No functional changes. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com> Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://lore.kernel.org/r/20220426184106.102636-5-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-03-09ASoC: SOF: ipc-msg-injector: Use devm_kzalloc() for the rx_bufferPeter Ujfalusi
The rx_buffer is cleared before sending an IPC to make sure that when the /sys/kernel/debug/sof/ipc_msg_inject file is read we will have correct information in the buffer (no random or stale data). But if the user reads the file before sending any message the buffer might contain garbage which should not be interpreted. To prevent this, clear the rx_buffer on allocation. Fixes: cac0b0887e53 ("ASoC: SOF: Convert the generic IPC message injector into SOF client") Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/20220309110104.18370-1-peter.ujfalusi@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-02-10ASoC: SOF: Convert the generic IPC message injector into SOF clientPeter Ujfalusi
Move the IPC message injection code out from the debug file as separate SOF client driver. Based on the kernel configuration, the device registration for the new IPC message injector is going to happen in the core. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Link: https://lore.kernel.org/r/20220210150525.30756-9-peter.ujfalusi@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>