ASoC: Intel: Skylake: large_config_get overhaul
Subsystems (3)
Cezary Rojewski
maintainerv5 cover ASoC: Intel: Skylake: large_config_get overhaul
LARGE_CONFIG_GET is among the most crucial IPCs. Host is expected to send single request first to obtain total payload size from received header's data_off_size. From then on, it loops for each frame exceeding inbox size until entire payload is read. If entire payload is contained within the very first frame, no looping is performed.
LARGE_CONFIG_GET is a flexible IPC, it not only receives payload but may carry one with them to provide list of params DSP module should return info for. This behavior is usually reserved for vendors and IPC handler should not touch that content. To achieve that, simply pass provided payload and bytes to sst_ipc_tx_message_wait as a part of request.
In current state, LARGE_CONFIG_GET message handler does nothing of that, in consequence making it dysfunctional. Overhaul said handler allowing rightful king of IPCs to return back on his throne - kingdom he shares with his twin brother: LARGE_CONFIG_SET.
The looping has not been added in this update as payloads of such size do not exist in practice. Will need to create custom module specifically for that very case and test against it before that feature can be added.
Changes since v4:
- Addressed Pierre's review: updated function's declaration and dropped unrelated log changes
Changes since v3:
- Split "large_config_get overhaul" patch into two segments as suggested by Pierre: first remove looping, then adjust function's behavior
Changes since v2:
- None, just for-next rebase
Changes since v1:
- None, just for-next rebase
Cezary Rojewski (2):
ASoC: Intel: Skylake: Limit large_config_get to single frame
ASoC: Intel: Skylake: large_config_get overhaul
sound/soc/intel/skylake/skl-messages.c | 3 +- sound/soc/intel/skylake/skl-sst-ipc.c | 54 +++++++++++--------------- sound/soc/intel/skylake/skl-sst-ipc.h | 3 +- 3 files changed, 27 insertions(+), 33 deletions(-)
Signature · 1 line
2.17.1
Cezary Rojewski
maintainerPATCH v5 1/2 ASoC: Intel: Skylake: Limit large_config_get to single frame
Reply for the very first LARGE_CONFIG_GET request contains total size of payload to be retrieved by host.
Quoted 1 line
From then on, each subsequent reply carries buffer offset instead. As
looping is not covered by any real-life example, remove it and cleanup the function for followup overhaul.
--- sound/soc/intel/skylake/skl-sst-ipc.c | 37 +++++---------------------- 1 file changed, 7 insertions(+), 30 deletions(-)
sound/soc/intel/skylake/skl-sst-ipc.c +7 -30
@@ -973,8 +973,7 @@ int skl_ipc_get_large_config(struct sst_generic_ipc *ipc, {struct skl_ipc_header header = {0 };struct sst_ipc_message request = {0 }, reply = {0 }; -int ret =0 ; -size_t sz_remaining, rx_size, data_offset; +int ret; header.primary =IPC_MSG_TARGET (IPC_MOD_MSG ); header.primary |=IPC_MSG_DIR (IPC_MSG_REQUEST );
@@ -987,34 +986,12 @@ int skl_ipc_get_large_config(struct sst_generic_ipc *ipc, header.extension |=IPC_FINAL_BLOCK (1 ); header.extension |=IPC_INITIAL_BLOCK (1 ); - sz_remaining = msg->param_data_size; - data_offset =0 ; - -while (sz_remaining !=0 ) { - rx_size = sz_remaining >SKL_ADSP_W1_SZ - ?SKL_ADSP_W1_SZ : sz_remaining; -if (rx_size == sz_remaining) - header.extension |=IPC_FINAL_BLOCK (1 ); - - request.header = *(u64 *)(&header); - reply.data = ((char *)param) + data_offset; - reply.size = msg->param_data_size; - ret =sst_ipc_tx_message_wait (ipc, request, &reply); -if (ret <0 ) { -dev_err (ipc->dev, -"ipc: get large config fail, err: %d\n" , ret); -return ret; - } - sz_remaining -= rx_size; - data_offset = msg->param_data_size - sz_remaining; - -/* clear the fields */ - header.extension &=IPC_INITIAL_BLOCK_CLEAR ; - header.extension &=IPC_DATA_OFFSET_SZ_CLEAR ; -/* fill the fields */ - header.extension |=IPC_INITIAL_BLOCK (1 ); - header.extension |=IPC_DATA_OFFSET_SZ (data_offset); - } + request.header = *(u64 *)(&header); + reply.data = param; + reply.size = msg->param_data_size; + ret =sst_ipc_tx_message_wait (ipc, request, &reply); +if (ret <0 ) +dev_err (ipc->dev,"ipc: get large config fail, err: %d\n" , ret);return ret; }
Signature · 1 line
2.17.1
Mark Brown
maintainerApplied "ASoC: Intel: Skylake: Limit large_config_get to single frame" to the asoc tree
The patch
ASoC: Intel: Skylake: Limit large_config_get to single frame
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.4
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
63e45324c284d240562a5b435afc4b23ae7d923cMon Sep 17 00:00:00 2001
From: Cezary Rojewski <[email protected]>
Date: Thu, 8 Aug 2019 20:15:48 +0200
Subject: [PATCH] ASoC: Intel: Skylake: Limit large_config_get to single frame
Reply for the very first LARGE_CONFIG_GET request contains total size of payload to be retrieved by host.
Quoted 1 line
From then on, each subsequent reply carries buffer offset instead. As
looping is not covered by any real-life example, remove it and cleanup the function for followup overhaul.
--- sound/soc/intel/skylake/skl-sst-ipc.c | 37 +++++---------------------- 1 file changed, 7 insertions(+), 30 deletions(-)
sound/soc/intel/skylake/skl-sst-ipc.c +7 -30
@@ -973,8 +973,7 @@ int skl_ipc_get_large_config(struct sst_generic_ipc *ipc, {struct skl_ipc_header header = {0 };struct sst_ipc_message request = {0 }, reply = {0 }; -int ret =0 ; -size_t sz_remaining, rx_size, data_offset; +int ret; header.primary =IPC_MSG_TARGET (IPC_MOD_MSG ); header.primary |=IPC_MSG_DIR (IPC_MSG_REQUEST );
@@ -987,34 +986,12 @@ int skl_ipc_get_large_config(struct sst_generic_ipc *ipc, header.extension |=IPC_FINAL_BLOCK (1 ); header.extension |=IPC_INITIAL_BLOCK (1 ); - sz_remaining = msg->param_data_size; - data_offset =0 ; - -while (sz_remaining !=0 ) { - rx_size = sz_remaining >SKL_ADSP_W1_SZ - ?SKL_ADSP_W1_SZ : sz_remaining; -if (rx_size == sz_remaining) - header.extension |=IPC_FINAL_BLOCK (1 ); - - request.header = *(u64 *)(&header); - reply.data = ((char *)param) + data_offset; - reply.size = msg->param_data_size; - ret =sst_ipc_tx_message_wait (ipc, request, &reply); -if (ret <0 ) { -dev_err (ipc->dev, -"ipc: get large config fail, err: %d\n" , ret); -return ret; - } - sz_remaining -= rx_size; - data_offset = msg->param_data_size - sz_remaining; - -/* clear the fields */ - header.extension &=IPC_INITIAL_BLOCK_CLEAR ; - header.extension &=IPC_DATA_OFFSET_SZ_CLEAR ; -/* fill the fields */ - header.extension |=IPC_INITIAL_BLOCK (1 ); - header.extension |=IPC_DATA_OFFSET_SZ (data_offset); - } + request.header = *(u64 *)(&header); + reply.data = param; + reply.size = msg->param_data_size; + ret =sst_ipc_tx_message_wait (ipc, request, &reply); +if (ret <0 ) +dev_err (ipc->dev,"ipc: get large config fail, err: %d\n" , ret);return ret; }
Signature · 1 line
2.20.1
Cezary Rojewski
maintainerPATCH v5 2/2 ASoC: Intel: Skylake: large_config_get overhaul
In reply to Cezary RojewskiLARGE_CONFIG_GET is mainly used to retrieve requested module parameters but it may also carry TX payload with them. Update its implementation to account for both TX and RX data.
First reply.header carries total payload size within data_off_sizefield. Make use of reply.header to realloc returned buffer with correct size.
Failure of IPC request is permissive - error-payload may be returned, an informative data why GET for given param failed - and thus function should not collapse before entire processing is finished. Caller is responsible for checking returned payload and bytes parameters.
--- sound/soc/intel/skylake/skl-messages.c | 3 ++- sound/soc/intel/skylake/skl-sst-ipc.c | 25 ++++++++++++++++++++----- sound/soc/intel/skylake/skl-sst-ipc.h | 3 ++- 3 files changed, 24 insertions(+), 7 deletions(-)
sound/soc/intel/skylake/skl-messages.c +2 -1
@@ -1379,11 +1379,12 @@ int skl_get_module_params(struct skl_dev *skl, u32 *params, int size, u32 param_id, struct skl_module_cfg *mcfg) { struct skl_ipc_large_config_msg msg; +size_t bytes = size; msg.module_id = mcfg->id.module_id; msg.instance_id = mcfg->id.pvt_id; msg.param_data_size = size; msg.large_param_id = param_id; -return skl_ipc_get_large_config (&skl->ipc, &msg, params); +return skl_ipc_get_large_config (&skl->ipc, &msg, ¶ms, &bytes); }
sound/soc/intel/skylake/skl-sst-ipc.c +20 -5
@@ -969,12 +969,18 @@ int skl_ipc_set_large_config(struct sst_generic_ipc *ipc,EXPORT_SYMBOL_GPL (skl_ipc_set_large_config);int skl_ipc_get_large_config (struct sst_generic_ipc *ipc, -struct skl_ipc_large_config_msg *msg,u32 *param) +struct skl_ipc_large_config_msg *msg, +u32 **payload,size_t *bytes) {struct skl_ipc_header header = {0 }; -struct sst_ipc_message request = {0 }, reply = {0 }; +struct sst_ipc_message request, reply = {0 }; +unsigned int *buf;int ret; + reply.data =kzalloc (SKL_ADSP_W1_SZ ,GFP_KERNEL ); +if (!reply.data) +return -ENOMEM ; + header.primary =IPC_MSG_TARGET (IPC_MOD_MSG ); header.primary |=IPC_MSG_DIR (IPC_MSG_REQUEST ); header.primary |=IPC_GLB_TYPE (IPC_MOD_LARGE_CONFIG_GET );
@@ -986,13 +992,22 @@ int skl_ipc_get_large_config(struct sst_generic_ipc *ipc, header.extension |=IPC_FINAL_BLOCK (1 ); header.extension |=IPC_INITIAL_BLOCK (1 ); - request.header = *(u64 *)(&header); - reply.data = param; - reply.size = msg->param_data_size; + request.header = *(u64 *)&header; + request.data = *payload; + request.size = *bytes; + reply.size =SKL_ADSP_W1_SZ ; + ret =sst_ipc_tx_message_wait (ipc, request, &reply);if (ret <0 )dev_err (ipc->dev,"ipc: get large config fail, err: %d\n" , ret); + reply.size = (reply.header >>32 ) &IPC_DATA_OFFSET_SZ_MASK ; + buf =krealloc (reply.data, reply.size,GFP_KERNEL ); +if (!buf) +return -ENOMEM ; + *payload = buf; + *bytes = reply.size; +return ret; }EXPORT_SYMBOL_GPL (skl_ipc_get_large_config);
sound/soc/intel/skylake/skl-sst-ipc.h +2 -1
@@ -139,7 +139,8 @@ int skl_ipc_set_large_config(struct sst_generic_ipc *ipc, struct skl_ipc_large_config_msg *msg, u32 *param);int skl_ipc_get_large_config (struct sst_generic_ipc *ipc, -struct skl_ipc_large_config_msg *msg,u32 *param); +struct skl_ipc_large_config_msg *msg, +u32 **payload,size_t *bytes);int skl_sst_ipc_load_library (struct sst_generic_ipc *ipc,u8 dma_id,u8 table_id,bool wait);
Signature · 1 line
2.17.1
Mark Brown
maintainerApplied "ASoC: Intel: Skylake: large_config_get overhaul" to the asoc tree
The patch
ASoC: Intel: Skylake: large_config_get overhaul
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.4
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
36004c42c761a6d95b867a4fbb9a955034e53351Mon Sep 17 00:00:00 2001
From: Cezary Rojewski <[email protected]>
Date: Thu, 8 Aug 2019 20:15:49 +0200
Subject: [PATCH] ASoC: Intel: Skylake: large_config_get overhaul
LARGE_CONFIG_GET is mainly used to retrieve requested module parameters but it may also carry TX payload with them. Update its implementation to account for both TX and RX data.
First reply.header carries total payload size within data_off_sizefield. Make use of reply.header to realloc returned buffer with correct size.
Failure of IPC request is permissive - error-payload may be returned, an informative data why GET for given param failed - and thus function should not collapse before entire processing is finished. Caller is responsible for checking returned payload and bytes parameters.
--- sound/soc/intel/skylake/skl-messages.c | 3 ++- sound/soc/intel/skylake/skl-sst-ipc.c | 25 ++++++++++++++++++++----- sound/soc/intel/skylake/skl-sst-ipc.h | 3 ++- 3 files changed, 24 insertions(+), 7 deletions(-)
sound/soc/intel/skylake/skl-messages.c +2 -1
@@ -1379,11 +1379,12 @@ int skl_get_module_params(struct skl_dev *skl, u32 *params, int size, u32 param_id, struct skl_module_cfg *mcfg) { struct skl_ipc_large_config_msg msg; +size_t bytes = size; msg.module_id = mcfg->id.module_id; msg.instance_id = mcfg->id.pvt_id; msg.param_data_size = size; msg.large_param_id = param_id; -return skl_ipc_get_large_config (&skl->ipc, &msg, params); +return skl_ipc_get_large_config (&skl->ipc, &msg, ¶ms, &bytes); }
sound/soc/intel/skylake/skl-sst-ipc.c +20 -5
@@ -969,12 +969,18 @@ int skl_ipc_set_large_config(struct sst_generic_ipc *ipc,EXPORT_SYMBOL_GPL (skl_ipc_set_large_config);int skl_ipc_get_large_config (struct sst_generic_ipc *ipc, -struct skl_ipc_large_config_msg *msg,u32 *param) +struct skl_ipc_large_config_msg *msg, +u32 **payload,size_t *bytes) {struct skl_ipc_header header = {0 }; -struct sst_ipc_message request = {0 }, reply = {0 }; +struct sst_ipc_message request, reply = {0 }; +unsigned int *buf;int ret; + reply.data =kzalloc (SKL_ADSP_W1_SZ ,GFP_KERNEL ); +if (!reply.data) +return -ENOMEM ; + header.primary =IPC_MSG_TARGET (IPC_MOD_MSG ); header.primary |=IPC_MSG_DIR (IPC_MSG_REQUEST ); header.primary |=IPC_GLB_TYPE (IPC_MOD_LARGE_CONFIG_GET );
@@ -986,13 +992,22 @@ int skl_ipc_get_large_config(struct sst_generic_ipc *ipc, header.extension |=IPC_FINAL_BLOCK (1 ); header.extension |=IPC_INITIAL_BLOCK (1 ); - request.header = *(u64 *)(&header); - reply.data = param; - reply.size = msg->param_data_size; + request.header = *(u64 *)&header; + request.data = *payload; + request.size = *bytes; + reply.size =SKL_ADSP_W1_SZ ; + ret =sst_ipc_tx_message_wait (ipc, request, &reply);if (ret <0 )dev_err (ipc->dev,"ipc: get large config fail, err: %d\n" , ret); + reply.size = (reply.header >>32 ) &IPC_DATA_OFFSET_SZ_MASK ; + buf =krealloc (reply.data, reply.size,GFP_KERNEL ); +if (!buf) +return -ENOMEM ; + *payload = buf; + *bytes = reply.size; +return ret; }EXPORT_SYMBOL_GPL (skl_ipc_get_large_config);
sound/soc/intel/skylake/skl-sst-ipc.h +2 -1
@@ -139,7 +139,8 @@ int skl_ipc_set_large_config(struct sst_generic_ipc *ipc, struct skl_ipc_large_config_msg *msg, u32 *param);int skl_ipc_get_large_config (struct sst_generic_ipc *ipc, -struct skl_ipc_large_config_msg *msg,u32 *param); +struct skl_ipc_large_config_msg *msg, +u32 **payload,size_t *bytes);int skl_sst_ipc_load_library (struct sst_generic_ipc *ipc,u8 dma_id,u8 table_id,bool wait);
Signature · 1 line
2.20.1
Quoted 12 lines · Cezary Rojewski
LARGE_CONFIG_GETis among the most crucial IPCs. Host is expected to send single request first to obtain total payload size from received header'sdata_off_size. From then on, it loops for each frame exceeding inbox size until entire payload is read. If entire payload is contained within the very first frame, no looping is performed.
LARGE_CONFIG_GETis a flexible IPC, it not only receives payload but may carry one with them to provide list of params DSP module should return info for. This behavior is usually reserved for vendors and IPC handler should not touch that content. To achieve that, simply pass provided payload and bytes tosst_ipc_tx_message_waitas a part of request.
Quoted 8 lines
In current state,
LARGE_CONFIG_GETmessage handler does nothing of that, in consequence making it dysfunctional. Overhaul said handler allowing rightful king of IPCs to return back on his throne - kingdom he shares with his twin brother:LARGE_CONFIG_SET.The looping has not been added in this update as payloads of such size do not exist in practice. Will need to create custom module specifically for that very case and test against it before that feature can be added.
Thanks Cezary.
For the series:
Quoted 24 lines
Changes since v4:
- Addressed Pierre's review: updated function's declaration and dropped unrelated log changesChanges since v3:
- Split "large_config_getoverhaul" patch into two segments as suggested by Pierre: first remove looping, then adjust function's behaviorChanges since v2:
- None, just for-next rebaseChanges since v1:
- None, just for-next rebaseCezary Rojewski (2):
ASoC: Intel: Skylake: Limitlarge_config_getto single frame
ASoC: Intel: Skylake:large_config_getoverhaulsound/soc/intel/skylake/skl-messages.c | 3 +- sound/soc/intel/skylake/skl-sst-ipc.c | 54 +++++++++++--------------- sound/soc/intel/skylake/skl-sst-ipc.h | 3 +- 3 files changed, 27 insertions(+), 33 deletions(-)