* [PATCH 00/12] ASoC: qcom: q6dsp: few cleanups
@ 2025-10-17 8:52 Srinivas Kandagatla
2025-10-17 8:52 ` [PATCH 01/12] ASoC: qdsp6: q6asm: do not sleep while atomic Srinivas Kandagatla
` (12 more replies)
0 siblings, 13 replies; 16+ messages in thread
From: Srinivas Kandagatla @ 2025-10-17 8:52 UTC (permalink / raw)
To: broonie
Cc: perex, tiwai, srini, alexey.klimov, linux-sound, linux-kernel,
linux-arm-msm, Srinivas Kandagatla
This patchset does 3 things.
- simplify code via __free(kfree) mechanism.
- use spinlock guards
- few cleanups discovered during doing above 2.
No functional changes
Thanks,
--sirni
Srinivas Kandagatla (12):
ASoC: qdsp6: q6asm: do not sleep while atomic
ASoc: qcom: audioreach: remove unused variables
ASoc: qcom: audioreach: Use automatic cleanup of kfree()
ASoc: qcom: q6adm: Use automatic cleanup of kfree()
ASoc: qcom: q6afe: Use automatic cleanup of kfree()
ASoc: qcom: q6apm: Use automatic cleanup of kfree()
ASoc: qcom: q6prm: Use automatic cleanup of kfree()
ASoc: qcom: q6asm: Use automatic cleanup of kfree()
ASoC: qcom: q6afe: Use guard() for spin locks
ASoC: qcom: q6apm-dai: Use guard() for spin locks
ASoC: qcom: q6asm-dai: Use guard() for spin locks
ASoC: qcom: q6asm: Use guard() for spin locks
sound/soc/qcom/qdsp6/audioreach.c | 234 +++++++++---------------------
sound/soc/qcom/qdsp6/q6adm.c | 33 ++---
sound/soc/qcom/qdsp6/q6afe.c | 49 ++-----
sound/soc/qcom/qdsp6/q6apm-dai.c | 23 +--
sound/soc/qcom/qdsp6/q6apm.c | 57 +++-----
sound/soc/qcom/qdsp6/q6asm-dai.c | 23 +--
sound/soc/qcom/qdsp6/q6asm.c | 189 ++++++------------------
sound/soc/qcom/qdsp6/q6prm.c | 27 +---
8 files changed, 170 insertions(+), 465 deletions(-)
--
2.51.0
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 01/12] ASoC: qdsp6: q6asm: do not sleep while atomic
2025-10-17 8:52 [PATCH 00/12] ASoC: qcom: q6dsp: few cleanups Srinivas Kandagatla
@ 2025-10-17 8:52 ` Srinivas Kandagatla
2025-10-17 8:52 ` [PATCH 02/12] ASoc: qcom: audioreach: remove unused variables Srinivas Kandagatla
` (11 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: Srinivas Kandagatla @ 2025-10-17 8:52 UTC (permalink / raw)
To: broonie
Cc: perex, tiwai, srini, alexey.klimov, linux-sound, linux-kernel,
linux-arm-msm, Srinivas Kandagatla, Stable
For some reason we ended up kfree between spinlock lock and unlock,
which can sleep.
move the kfree out of spinlock section.
Fixes: a2a5d30218fd ("ASoC: qdsp6: q6asm: Add support to memory map and unmap")
Cc: Stable@vger.kernel.org
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
---
sound/soc/qcom/qdsp6/q6asm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/qcom/qdsp6/q6asm.c b/sound/soc/qcom/qdsp6/q6asm.c
index 06a802f9dba5..67e9ca18883c 100644
--- a/sound/soc/qcom/qdsp6/q6asm.c
+++ b/sound/soc/qcom/qdsp6/q6asm.c
@@ -377,9 +377,9 @@ static void q6asm_audio_client_free_buf(struct audio_client *ac,
spin_lock_irqsave(&ac->lock, flags);
port->num_periods = 0;
+ spin_unlock_irqrestore(&ac->lock, flags);
kfree(port->buf);
port->buf = NULL;
- spin_unlock_irqrestore(&ac->lock, flags);
}
/**
--
2.51.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 02/12] ASoc: qcom: audioreach: remove unused variables
2025-10-17 8:52 [PATCH 00/12] ASoC: qcom: q6dsp: few cleanups Srinivas Kandagatla
2025-10-17 8:52 ` [PATCH 01/12] ASoC: qdsp6: q6asm: do not sleep while atomic Srinivas Kandagatla
@ 2025-10-17 8:52 ` Srinivas Kandagatla
2025-10-17 8:52 ` [PATCH 03/12] ASoc: qcom: audioreach: Use automatic cleanup of kfree() Srinivas Kandagatla
` (10 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: Srinivas Kandagatla @ 2025-10-17 8:52 UTC (permalink / raw)
To: broonie
Cc: perex, tiwai, srini, alexey.klimov, linux-sound, linux-kernel,
linux-arm-msm, Srinivas Kandagatla
remove unused variables in some of the audioreach functions.
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
---
sound/soc/qcom/qdsp6/audioreach.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audioreach.c
index 2365424a9b42..0456d4689034 100644
--- a/sound/soc/qcom/qdsp6/audioreach.c
+++ b/sound/soc/qcom/qdsp6/audioreach.c
@@ -612,7 +612,7 @@ static int audioreach_display_port_set_media_format(struct q6apm_graph *graph,
struct apm_module_frame_size_factor_cfg *fs_cfg;
struct apm_module_param_data *param_data;
struct apm_module_hw_ep_mf_cfg *hw_cfg;
- int ic_sz, ep_sz, fs_sz, dl_sz;
+ int ic_sz, ep_sz, fs_sz;
int rc, payload_size;
struct gpr_pkt *pkt;
void *p;
@@ -620,9 +620,8 @@ static int audioreach_display_port_set_media_format(struct q6apm_graph *graph,
ic_sz = APM_DP_INTF_CFG_PSIZE;
ep_sz = APM_HW_EP_CFG_PSIZE;
fs_sz = APM_FS_CFG_PSIZE;
- dl_sz = 0;
- payload_size = ic_sz + ep_sz + fs_sz + dl_sz;
+ payload_size = ic_sz + ep_sz + fs_sz;
pkt = audioreach_alloc_apm_cmd_pkt(payload_size, APM_CMD_SET_CFG, 0);
if (IS_ERR(pkt))
@@ -680,7 +679,7 @@ static int audioreach_codec_dma_set_media_format(struct q6apm_graph *graph,
struct apm_module_hw_ep_power_mode_cfg *pm_cfg;
struct apm_module_param_data *param_data;
struct apm_module_hw_ep_mf_cfg *hw_cfg;
- int ic_sz, ep_sz, fs_sz, pm_sz, dl_sz;
+ int ic_sz, ep_sz, fs_sz, pm_sz;
int rc, payload_size;
struct gpr_pkt *pkt;
void *p;
@@ -689,9 +688,8 @@ static int audioreach_codec_dma_set_media_format(struct q6apm_graph *graph,
ep_sz = APM_HW_EP_CFG_PSIZE;
fs_sz = APM_FS_CFG_PSIZE;
pm_sz = APM_HW_EP_PMODE_CFG_PSIZE;
- dl_sz = 0;
- payload_size = ic_sz + ep_sz + fs_sz + pm_sz + dl_sz;
+ payload_size = ic_sz + ep_sz + fs_sz + pm_sz;
pkt = audioreach_alloc_apm_cmd_pkt(payload_size, APM_CMD_SET_CFG, 0);
if (IS_ERR(pkt))
--
2.51.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 03/12] ASoc: qcom: audioreach: Use automatic cleanup of kfree()
2025-10-17 8:52 [PATCH 00/12] ASoC: qcom: q6dsp: few cleanups Srinivas Kandagatla
2025-10-17 8:52 ` [PATCH 01/12] ASoC: qdsp6: q6asm: do not sleep while atomic Srinivas Kandagatla
2025-10-17 8:52 ` [PATCH 02/12] ASoc: qcom: audioreach: remove unused variables Srinivas Kandagatla
@ 2025-10-17 8:52 ` Srinivas Kandagatla
2025-10-17 8:52 ` [PATCH 04/12] ASoc: qcom: q6adm: " Srinivas Kandagatla
` (9 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: Srinivas Kandagatla @ 2025-10-17 8:52 UTC (permalink / raw)
To: broonie
Cc: perex, tiwai, srini, alexey.klimov, linux-sound, linux-kernel,
linux-arm-msm, Srinivas Kandagatla
Its common pattern in q6dsp code to allocate temporary buffer
to send gpr/apr packets and free at the function exit.
Now this can be simplified via __free(kfree) mechanism.
No functional changes.
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
---
sound/soc/qcom/qdsp6/audioreach.c | 232 +++++++++---------------------
1 file changed, 66 insertions(+), 166 deletions(-)
diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audioreach.c
index 0456d4689034..7f2c607fb27a 100644
--- a/sound/soc/qcom/qdsp6/audioreach.c
+++ b/sound/soc/qcom/qdsp6/audioreach.c
@@ -612,18 +612,12 @@ static int audioreach_display_port_set_media_format(struct q6apm_graph *graph,
struct apm_module_frame_size_factor_cfg *fs_cfg;
struct apm_module_param_data *param_data;
struct apm_module_hw_ep_mf_cfg *hw_cfg;
- int ic_sz, ep_sz, fs_sz;
- int rc, payload_size;
- struct gpr_pkt *pkt;
+ int ic_sz = APM_DP_INTF_CFG_PSIZE;
+ int ep_sz = APM_HW_EP_CFG_PSIZE;
+ int fs_sz = APM_FS_CFG_PSIZE;
+ int size = ic_sz + ep_sz + fs_sz;
void *p;
-
- ic_sz = APM_DP_INTF_CFG_PSIZE;
- ep_sz = APM_HW_EP_CFG_PSIZE;
- fs_sz = APM_FS_CFG_PSIZE;
-
- payload_size = ic_sz + ep_sz + fs_sz;
-
- pkt = audioreach_alloc_apm_cmd_pkt(payload_size, APM_CMD_SET_CFG, 0);
+ struct gpr_pkt *pkt __free(kfree) = audioreach_alloc_apm_cmd_pkt(size, APM_CMD_SET_CFG, 0);
if (IS_ERR(pkt))
return PTR_ERR(pkt);
@@ -662,11 +656,7 @@ static int audioreach_display_port_set_media_format(struct q6apm_graph *graph,
intf_cfg->cfg.mst_idx = 0;
intf_cfg->cfg.dptx_idx = cfg->dp_idx;
- rc = q6apm_send_cmd_sync(graph->apm, pkt, 0);
-
- kfree(pkt);
-
- return rc;
+ return q6apm_send_cmd_sync(graph->apm, pkt, 0);
}
/* LPASS Codec DMA port Module Media Format Setup */
@@ -679,19 +669,13 @@ static int audioreach_codec_dma_set_media_format(struct q6apm_graph *graph,
struct apm_module_hw_ep_power_mode_cfg *pm_cfg;
struct apm_module_param_data *param_data;
struct apm_module_hw_ep_mf_cfg *hw_cfg;
- int ic_sz, ep_sz, fs_sz, pm_sz;
- int rc, payload_size;
- struct gpr_pkt *pkt;
+ int ic_sz = APM_CDMA_INTF_CFG_PSIZE;
+ int ep_sz = APM_HW_EP_CFG_PSIZE;
+ int fs_sz = APM_FS_CFG_PSIZE;
+ int pm_sz = APM_HW_EP_PMODE_CFG_PSIZE;
+ int size = ic_sz + ep_sz + fs_sz + pm_sz;
void *p;
-
- ic_sz = APM_CDMA_INTF_CFG_PSIZE;
- ep_sz = APM_HW_EP_CFG_PSIZE;
- fs_sz = APM_FS_CFG_PSIZE;
- pm_sz = APM_HW_EP_PMODE_CFG_PSIZE;
-
- payload_size = ic_sz + ep_sz + fs_sz + pm_sz;
-
- pkt = audioreach_alloc_apm_cmd_pkt(payload_size, APM_CMD_SET_CFG, 0);
+ struct gpr_pkt *pkt __free(kfree) = audioreach_alloc_apm_cmd_pkt(size, APM_CMD_SET_CFG, 0);
if (IS_ERR(pkt))
return PTR_ERR(pkt);
@@ -739,24 +723,17 @@ static int audioreach_codec_dma_set_media_format(struct q6apm_graph *graph,
param_data->param_size = pm_sz - APM_MODULE_PARAM_DATA_SIZE;
pm_cfg->power_mode.power_mode = 0;
- rc = q6apm_send_cmd_sync(graph->apm, pkt, 0);
-
- kfree(pkt);
-
- return rc;
+ return q6apm_send_cmd_sync(graph->apm, pkt, 0);
}
int audioreach_send_u32_param(struct q6apm_graph *graph, struct audioreach_module *module,
uint32_t param_id, uint32_t param_val)
{
struct apm_module_param_data *param_data;
- struct gpr_pkt *pkt;
+ struct gpr_pkt *pkt __free(kfree) = NULL;
uint32_t *param;
- int rc, payload_size;
- void *p;
-
- payload_size = sizeof(uint32_t) + APM_MODULE_PARAM_DATA_SIZE;
- p = audioreach_alloc_apm_cmd_pkt(payload_size, APM_CMD_SET_CFG, 0);
+ int payload_size = sizeof(uint32_t) + APM_MODULE_PARAM_DATA_SIZE;
+ void *p = audioreach_alloc_apm_cmd_pkt(payload_size, APM_CMD_SET_CFG, 0);
if (IS_ERR(p))
return -ENOMEM;
@@ -773,11 +750,7 @@ int audioreach_send_u32_param(struct q6apm_graph *graph, struct audioreach_modul
param = p;
*param = param_val;
- rc = q6apm_send_cmd_sync(graph->apm, pkt, 0);
-
- kfree(pkt);
-
- return rc;
+ return q6apm_send_cmd_sync(graph->apm, pkt, 0);
}
EXPORT_SYMBOL_GPL(audioreach_send_u32_param);
@@ -813,24 +786,17 @@ static int audioreach_set_module_config(struct q6apm_graph *graph,
struct audioreach_module *module,
struct audioreach_module_config *cfg)
{
- int payload_size = le32_to_cpu(module->data->size);
- struct gpr_pkt *pkt;
- int rc;
+ int size = le32_to_cpu(module->data->size);
void *p;
-
- pkt = audioreach_alloc_apm_cmd_pkt(payload_size, APM_CMD_SET_CFG, 0);
+ struct gpr_pkt *pkt __free(kfree) = audioreach_alloc_apm_cmd_pkt(size, APM_CMD_SET_CFG, 0);
if (IS_ERR(pkt))
return PTR_ERR(pkt);
p = (void *)pkt + GPR_HDR_SIZE + APM_CMD_HDR_SIZE;
- memcpy(p, module->data->data, payload_size);
-
- rc = q6apm_send_cmd_sync(graph->apm, pkt, 0);
+ memcpy(p, module->data->data, size);
- kfree(pkt);
-
- return rc;
+ return q6apm_send_cmd_sync(graph->apm, pkt, 0);
}
static int audioreach_mfc_set_media_format(struct q6apm_graph *graph,
@@ -840,15 +806,11 @@ static int audioreach_mfc_set_media_format(struct q6apm_graph *graph,
struct apm_module_param_data *param_data;
struct param_id_mfc_media_format *media_format;
uint32_t num_channels = cfg->num_channels;
- int payload_size;
- struct gpr_pkt *pkt;
- int rc, i;
+ int payload_size = APM_MFC_CFG_PSIZE(media_format, num_channels) +
+ APM_MODULE_PARAM_DATA_SIZE;
+ int i;
void *p;
-
- payload_size = APM_MFC_CFG_PSIZE(media_format, num_channels) +
- APM_MODULE_PARAM_DATA_SIZE;
-
- pkt = audioreach_alloc_apm_cmd_pkt(payload_size, APM_CMD_SET_CFG, 0);
+ struct gpr_pkt *pkt __free(kfree) = audioreach_alloc_apm_cmd_pkt(payload_size, APM_CMD_SET_CFG, 0);
if (IS_ERR(pkt))
return PTR_ERR(pkt);
@@ -868,11 +830,7 @@ static int audioreach_mfc_set_media_format(struct q6apm_graph *graph,
for (i = 0; i < num_channels; i++)
media_format->channel_mapping[i] = cfg->channel_map[i];
- rc = q6apm_send_cmd_sync(graph->apm, pkt, 0);
-
- kfree(pkt);
-
- return rc;
+ return q6apm_send_cmd_sync(graph->apm, pkt, 0);
}
static int audioreach_set_compr_media_format(struct media_format *media_fmt_hdr,
@@ -960,31 +918,24 @@ static int audioreach_set_compr_media_format(struct media_format *media_fmt_hdr,
int audioreach_compr_set_param(struct q6apm_graph *graph, struct audioreach_module_config *mcfg)
{
struct media_format *header;
- struct gpr_pkt *pkt;
- int iid, payload_size, rc;
+ int rc;
void *p;
-
- payload_size = sizeof(struct apm_sh_module_media_fmt_cmd);
-
- iid = q6apm_graph_get_rx_shmem_module_iid(graph);
- pkt = audioreach_alloc_cmd_pkt(payload_size, DATA_CMD_WR_SH_MEM_EP_MEDIA_FORMAT,
- 0, graph->port->id, iid);
-
+ int iid = q6apm_graph_get_rx_shmem_module_iid(graph);
+ int payload_size = sizeof(struct apm_sh_module_media_fmt_cmd);
+ struct gpr_pkt *pkt __free(kfree) = audioreach_alloc_cmd_pkt(payload_size,
+ DATA_CMD_WR_SH_MEM_EP_MEDIA_FORMAT,
+ 0, graph->port->id, iid);
if (IS_ERR(pkt))
return -ENOMEM;
+
p = (void *)pkt + GPR_HDR_SIZE;
header = p;
rc = audioreach_set_compr_media_format(header, p, mcfg);
- if (rc) {
- kfree(pkt);
+ if (rc)
return rc;
- }
-
- rc = gpr_send_port_pkt(graph->port, pkt);
- kfree(pkt);
- return rc;
+ return gpr_send_port_pkt(graph->port, pkt);
}
EXPORT_SYMBOL_GPL(audioreach_compr_set_param);
@@ -996,18 +947,12 @@ static int audioreach_i2s_set_media_format(struct q6apm_graph *graph,
struct apm_module_param_data *param_data;
struct apm_i2s_module_intf_cfg *intf_cfg;
struct apm_module_hw_ep_mf_cfg *hw_cfg;
- int ic_sz, ep_sz, fs_sz;
- int rc, payload_size;
- struct gpr_pkt *pkt;
+ int ic_sz = APM_I2S_INTF_CFG_PSIZE;
+ int ep_sz = APM_HW_EP_CFG_PSIZE;
+ int fs_sz = APM_FS_CFG_PSIZE;
+ int size = ic_sz + ep_sz + fs_sz;
void *p;
-
- ic_sz = APM_I2S_INTF_CFG_PSIZE;
- ep_sz = APM_HW_EP_CFG_PSIZE;
- fs_sz = APM_FS_CFG_PSIZE;
-
- payload_size = ic_sz + ep_sz + fs_sz;
-
- pkt = audioreach_alloc_apm_cmd_pkt(payload_size, APM_CMD_SET_CFG, 0);
+ struct gpr_pkt *pkt __free(kfree) = audioreach_alloc_apm_cmd_pkt(size, APM_CMD_SET_CFG, 0);
if (IS_ERR(pkt))
return PTR_ERR(pkt);
@@ -1058,11 +1003,7 @@ static int audioreach_i2s_set_media_format(struct q6apm_graph *graph,
param_data->param_size = fs_sz - APM_MODULE_PARAM_DATA_SIZE;
fs_cfg->frame_size_factor = 1;
- rc = q6apm_send_cmd_sync(graph->apm, pkt, 0);
-
- kfree(pkt);
-
- return rc;
+ return q6apm_send_cmd_sync(graph->apm, pkt, 0);
}
static int audioreach_logging_set_media_format(struct q6apm_graph *graph,
@@ -1070,12 +1011,9 @@ static int audioreach_logging_set_media_format(struct q6apm_graph *graph,
{
struct apm_module_param_data *param_data;
struct data_logging_config *cfg;
- int rc, payload_size;
- struct gpr_pkt *pkt;
+ int size = sizeof(*cfg) + APM_MODULE_PARAM_DATA_SIZE;
void *p;
-
- payload_size = sizeof(*cfg) + APM_MODULE_PARAM_DATA_SIZE;
- pkt = audioreach_alloc_apm_cmd_pkt(payload_size, APM_CMD_SET_CFG, 0);
+ struct gpr_pkt *pkt __free(kfree) = audioreach_alloc_apm_cmd_pkt(size, APM_CMD_SET_CFG, 0);
if (IS_ERR(pkt))
return PTR_ERR(pkt);
@@ -1085,7 +1023,7 @@ static int audioreach_logging_set_media_format(struct q6apm_graph *graph,
param_data->module_instance_id = module->instance_id;
param_data->error_code = 0;
param_data->param_id = PARAM_ID_DATA_LOGGING_CONFIG;
- param_data->param_size = payload_size - APM_MODULE_PARAM_DATA_SIZE;
+ param_data->param_size = size - APM_MODULE_PARAM_DATA_SIZE;
p = p + APM_MODULE_PARAM_DATA_SIZE;
cfg = p;
@@ -1093,11 +1031,7 @@ static int audioreach_logging_set_media_format(struct q6apm_graph *graph,
cfg->log_tap_point_id = module->log_tap_point_id;
cfg->mode = module->log_mode;
- rc = q6apm_send_cmd_sync(graph->apm, pkt, 0);
-
- kfree(pkt);
-
- return rc;
+ return q6apm_send_cmd_sync(graph->apm, pkt, 0);
}
static int audioreach_pcm_set_media_format(struct q6apm_graph *graph,
@@ -1108,8 +1042,8 @@ static int audioreach_pcm_set_media_format(struct q6apm_graph *graph,
uint32_t num_channels = mcfg->num_channels;
struct apm_pcm_module_media_fmt_cmd *cfg;
struct apm_module_param_data *param_data;
- int rc, payload_size;
- struct gpr_pkt *pkt;
+ int payload_size;
+ struct gpr_pkt *pkt __free(kfree) = NULL;
if (num_channels > 4) {
dev_err(graph->dev, "Error: Invalid channels (%d)!\n", num_channels);
@@ -1144,11 +1078,7 @@ static int audioreach_pcm_set_media_format(struct q6apm_graph *graph,
media_cfg->bits_per_sample = mcfg->bit_width;
memcpy(media_cfg->channel_mapping, mcfg->channel_map, mcfg->num_channels);
- rc = q6apm_send_cmd_sync(graph->apm, pkt, 0);
-
- kfree(pkt);
-
- return rc;
+ return q6apm_send_cmd_sync(graph->apm, pkt, 0);
}
static int audioreach_shmem_set_media_format(struct q6apm_graph *graph,
@@ -1160,7 +1090,7 @@ static int audioreach_shmem_set_media_format(struct q6apm_graph *graph,
struct payload_media_fmt_pcm *cfg;
struct media_format *header;
int rc, payload_size;
- struct gpr_pkt *pkt;
+ struct gpr_pkt *pkt __free(kfree) = NULL;
void *p;
if (num_channels > 4) {
@@ -1202,29 +1132,20 @@ static int audioreach_shmem_set_media_format(struct q6apm_graph *graph,
memcpy(cfg->channel_mapping, mcfg->channel_map, mcfg->num_channels);
} else {
rc = audioreach_set_compr_media_format(header, p, mcfg);
- if (rc) {
- kfree(pkt);
+ if (rc)
return rc;
- }
}
- rc = audioreach_graph_send_cmd_sync(graph, pkt, 0);
-
- kfree(pkt);
-
- return rc;
+ return audioreach_graph_send_cmd_sync(graph, pkt, 0);
}
int audioreach_gain_set_vol_ctrl(struct q6apm *apm, struct audioreach_module *module, int vol)
{
struct param_id_vol_ctrl_master_gain *cfg;
struct apm_module_param_data *param_data;
- int rc, payload_size;
- struct gpr_pkt *pkt;
+ int size = sizeof(*cfg) + APM_MODULE_PARAM_DATA_SIZE;
void *p;
-
- payload_size = sizeof(*cfg) + APM_MODULE_PARAM_DATA_SIZE;
- pkt = audioreach_alloc_apm_cmd_pkt(payload_size, APM_CMD_SET_CFG, 0);
+ struct gpr_pkt *pkt __free(kfree) = audioreach_alloc_apm_cmd_pkt(size, APM_CMD_SET_CFG, 0);
if (IS_ERR(pkt))
return PTR_ERR(pkt);
@@ -1234,16 +1155,12 @@ int audioreach_gain_set_vol_ctrl(struct q6apm *apm, struct audioreach_module *mo
param_data->module_instance_id = module->instance_id;
param_data->error_code = 0;
param_data->param_id = PARAM_ID_VOL_CTRL_MASTER_GAIN;
- param_data->param_size = payload_size - APM_MODULE_PARAM_DATA_SIZE;
+ param_data->param_size = size - APM_MODULE_PARAM_DATA_SIZE;
p = p + APM_MODULE_PARAM_DATA_SIZE;
cfg = p;
cfg->master_gain = vol;
- rc = q6apm_send_cmd_sync(apm, pkt, 0);
-
- kfree(pkt);
-
- return rc;
+ return q6apm_send_cmd_sync(apm, pkt, 0);
}
EXPORT_SYMBOL_GPL(audioreach_gain_set_vol_ctrl);
@@ -1251,11 +1168,8 @@ static int audioreach_gain_set(struct q6apm_graph *graph, struct audioreach_modu
{
struct apm_module_param_data *param_data;
struct apm_gain_module_cfg *cfg;
- int rc, payload_size;
- struct gpr_pkt *pkt;
-
- payload_size = APM_GAIN_CFG_PSIZE;
- pkt = audioreach_alloc_apm_cmd_pkt(payload_size, APM_CMD_SET_CFG, 0);
+ int size = APM_GAIN_CFG_PSIZE;
+ struct gpr_pkt *pkt __free(kfree) = audioreach_alloc_apm_cmd_pkt(size, APM_CMD_SET_CFG, 0);
if (IS_ERR(pkt))
return PTR_ERR(pkt);
@@ -1265,15 +1179,11 @@ static int audioreach_gain_set(struct q6apm_graph *graph, struct audioreach_modu
param_data->module_instance_id = module->instance_id;
param_data->error_code = 0;
param_data->param_id = APM_PARAM_ID_GAIN;
- param_data->param_size = payload_size - APM_MODULE_PARAM_DATA_SIZE;
+ param_data->param_size = size - APM_MODULE_PARAM_DATA_SIZE;
cfg->gain_cfg.gain = module->gain;
- rc = q6apm_send_cmd_sync(graph->apm, pkt, 0);
-
- kfree(pkt);
-
- return rc;
+ return q6apm_send_cmd_sync(graph->apm, pkt, 0);
}
int audioreach_set_media_format(struct q6apm_graph *graph, struct audioreach_module *module,
@@ -1358,9 +1268,9 @@ int audioreach_map_memory_regions(struct q6apm_graph *graph, unsigned int dir, s
struct apm_cmd_shared_mem_map_regions *cmd;
uint32_t num_regions, buf_sz, payload_size;
struct audioreach_graph_data *data;
- struct gpr_pkt *pkt;
+ struct gpr_pkt *pkt __free(kfree) = NULL;
void *p;
- int rc, i;
+ int i;
if (dir == SNDRV_PCM_STREAM_PLAYBACK)
data = &graph->rx_data;
@@ -1407,23 +1317,16 @@ int audioreach_map_memory_regions(struct q6apm_graph *graph, unsigned int dir, s
}
mutex_unlock(&graph->lock);
- rc = audioreach_graph_send_cmd_sync(graph, pkt, APM_CMD_RSP_SHARED_MEM_MAP_REGIONS);
-
- kfree(pkt);
-
- return rc;
+ return audioreach_graph_send_cmd_sync(graph, pkt, APM_CMD_RSP_SHARED_MEM_MAP_REGIONS);
}
EXPORT_SYMBOL_GPL(audioreach_map_memory_regions);
int audioreach_shared_memory_send_eos(struct q6apm_graph *graph)
{
struct data_cmd_wr_sh_mem_ep_eos *eos;
- struct gpr_pkt *pkt;
- int rc = 0, iid;
-
- iid = q6apm_graph_get_rx_shmem_module_iid(graph);
- pkt = audioreach_alloc_cmd_pkt(sizeof(*eos), DATA_CMD_WR_SH_MEM_EP_EOS, 0,
- graph->port->id, iid);
+ int iid = q6apm_graph_get_rx_shmem_module_iid(graph);
+ struct gpr_pkt *pkt __free(kfree) = audioreach_alloc_cmd_pkt(sizeof(*eos),
+ DATA_CMD_WR_SH_MEM_EP_EOS, 0, graph->port->id, iid);
if (IS_ERR(pkt))
return PTR_ERR(pkt);
@@ -1431,9 +1334,6 @@ int audioreach_shared_memory_send_eos(struct q6apm_graph *graph)
eos->policy = WR_SH_MEM_EP_EOS_POLICY_LAST;
- rc = gpr_send_port_pkt(graph->port, pkt);
- kfree(pkt);
-
- return rc;
+ return gpr_send_port_pkt(graph->port, pkt);
}
EXPORT_SYMBOL_GPL(audioreach_shared_memory_send_eos);
--
2.51.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 04/12] ASoc: qcom: q6adm: Use automatic cleanup of kfree()
2025-10-17 8:52 [PATCH 00/12] ASoC: qcom: q6dsp: few cleanups Srinivas Kandagatla
` (2 preceding siblings ...)
2025-10-17 8:52 ` [PATCH 03/12] ASoc: qcom: audioreach: Use automatic cleanup of kfree() Srinivas Kandagatla
@ 2025-10-17 8:52 ` Srinivas Kandagatla
2025-10-17 8:53 ` [PATCH 05/12] ASoc: qcom: q6afe: " Srinivas Kandagatla
` (8 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: Srinivas Kandagatla @ 2025-10-17 8:52 UTC (permalink / raw)
To: broonie
Cc: perex, tiwai, srini, alexey.klimov, linux-sound, linux-kernel,
linux-arm-msm, Srinivas Kandagatla
Its common pattern in q6dsp code to allocate temporary buffer
to send gpr/apr packets and free at the function exit.
Now this can be simplified via __free(kfree) mechanism.
No functional changes.
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
---
sound/soc/qcom/qdsp6/q6adm.c | 33 +++++++++------------------------
1 file changed, 9 insertions(+), 24 deletions(-)
diff --git a/sound/soc/qcom/qdsp6/q6adm.c b/sound/soc/qcom/qdsp6/q6adm.c
index 1530e98df165..6477c7875c12 100644
--- a/sound/soc/qcom/qdsp6/q6adm.c
+++ b/sound/soc/qcom/qdsp6/q6adm.c
@@ -325,11 +325,8 @@ static int q6adm_device_open(struct q6adm *adm, struct q6copp *copp,
struct q6adm_cmd_device_open_v5 *open;
int afe_port = q6afe_get_port_id(port_id);
struct apr_pkt *pkt;
- void *p;
- int ret, pkt_size;
-
- pkt_size = APR_HDR_SIZE + sizeof(*open);
- p = kzalloc(pkt_size, GFP_KERNEL);
+ int ret, pkt_size = APR_HDR_SIZE + sizeof(*open);
+ void *p __free(kfree) = kzalloc(pkt_size, GFP_KERNEL);
if (!p)
return -ENOMEM;
@@ -354,14 +351,9 @@ static int q6adm_device_open(struct q6adm *adm, struct q6copp *copp,
ret = q6dsp_map_channels(&open->dev_channel_mapping[0],
channel_mode);
if (ret)
- goto err;
-
- ret = q6adm_apr_send_copp_pkt(adm, copp, pkt,
- ADM_CMDRSP_DEVICE_OPEN_V5);
+ return ret;
-err:
- kfree(pkt);
- return ret;
+ return q6adm_apr_send_copp_pkt(adm, copp, pkt, ADM_CMDRSP_DEVICE_OPEN_V5);
}
/**
@@ -464,15 +456,12 @@ int q6adm_matrix_map(struct device *dev, int path,
struct q6adm_session_map_node_v5 *node;
struct apr_pkt *pkt;
uint16_t *copps_list;
- int pkt_size, ret, i, copp_idx;
- void *matrix_map;
- struct q6copp *copp;
-
+ int ret, i, copp_idx;
/* Assumes port_ids have already been validated during adm_open */
- pkt_size = (APR_HDR_SIZE + sizeof(*route) + sizeof(*node) +
+ struct q6copp *copp;
+ int pkt_size = (APR_HDR_SIZE + sizeof(*route) + sizeof(*node) +
(sizeof(uint32_t) * payload_map.num_copps));
-
- matrix_map = kzalloc(pkt_size, GFP_KERNEL);
+ void *matrix_map __free(kfree) = kzalloc(pkt_size, GFP_KERNEL);
if (!matrix_map)
return -ENOMEM;
@@ -510,16 +499,13 @@ int q6adm_matrix_map(struct device *dev, int path,
if (port_idx < 0) {
dev_err(dev, "Invalid port_id %d\n",
payload_map.port_id[i]);
- kfree(pkt);
return -EINVAL;
}
copp_idx = payload_map.copp_idx[i];
copp = q6adm_find_copp(adm, port_idx, copp_idx);
- if (!copp) {
- kfree(pkt);
+ if (!copp)
return -EINVAL;
- }
copps_list[i] = copp->id;
kref_put(&copp->refcount, q6adm_free_copp);
@@ -552,7 +538,6 @@ int q6adm_matrix_map(struct device *dev, int path,
fail_cmd:
mutex_unlock(&adm->lock);
- kfree(pkt);
return ret;
}
EXPORT_SYMBOL_GPL(q6adm_matrix_map);
--
2.51.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 05/12] ASoc: qcom: q6afe: Use automatic cleanup of kfree()
2025-10-17 8:52 [PATCH 00/12] ASoC: qcom: q6dsp: few cleanups Srinivas Kandagatla
` (3 preceding siblings ...)
2025-10-17 8:52 ` [PATCH 04/12] ASoc: qcom: q6adm: " Srinivas Kandagatla
@ 2025-10-17 8:53 ` Srinivas Kandagatla
2025-10-17 8:53 ` [PATCH 06/12] ASoc: qcom: q6apm: " Srinivas Kandagatla
` (7 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: Srinivas Kandagatla @ 2025-10-17 8:53 UTC (permalink / raw)
To: broonie
Cc: perex, tiwai, srini, alexey.klimov, linux-sound, linux-kernel,
linux-arm-msm, Srinivas Kandagatla
Its common pattern in q6dsp code to allocate temporary buffer
to send gpr/apr packets and free at the function exit.
Now this can be simplified via __free(kfree) mechanism.
No functional changes.
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
---
sound/soc/qcom/qdsp6/q6afe.c | 41 +++++++++++-------------------------
1 file changed, 12 insertions(+), 29 deletions(-)
diff --git a/sound/soc/qcom/qdsp6/q6afe.c b/sound/soc/qcom/qdsp6/q6afe.c
index 7b59d514b432..56f85f1c2425 100644
--- a/sound/soc/qcom/qdsp6/q6afe.c
+++ b/sound/soc/qcom/qdsp6/q6afe.c
@@ -1077,11 +1077,9 @@ static int q6afe_set_param(struct q6afe *afe, struct q6afe_port *port,
struct afe_svc_cmd_set_param *param;
struct afe_port_param_data_v2 *pdata;
struct apr_pkt *pkt;
- int ret, pkt_size;
- void *p, *pl;
-
- pkt_size = APR_HDR_SIZE + sizeof(*param) + sizeof(*pdata) + psize;
- p = kzalloc(pkt_size, GFP_KERNEL);
+ int ret, pkt_size = APR_HDR_SIZE + sizeof(*param) + sizeof(*pdata) + psize;
+ void *pl;
+ void *p __free(kfree) = kzalloc(pkt_size, GFP_KERNEL);
if (!p)
return -ENOMEM;
@@ -1112,7 +1110,6 @@ static int q6afe_set_param(struct q6afe *afe, struct q6afe_port *port,
if (ret)
dev_err(afe->dev, "AFE set params failed %d\n", ret);
- kfree(pkt);
return ret;
}
@@ -1131,11 +1128,9 @@ static int q6afe_port_set_param_v2(struct q6afe_port *port, void *data,
struct q6afe *afe = port->afe;
struct apr_pkt *pkt;
u16 port_id = port->id;
- int ret, pkt_size;
- void *p, *pl;
-
- pkt_size = APR_HDR_SIZE + sizeof(*param) + sizeof(*pdata) + psize;
- p = kzalloc(pkt_size, GFP_KERNEL);
+ int ret, pkt_size = APR_HDR_SIZE + sizeof(*param) + sizeof(*pdata) + psize;
+ void *pl;
+ void *p __free(kfree) = kzalloc(pkt_size, GFP_KERNEL);
if (!p)
return -ENOMEM;
@@ -1168,7 +1163,6 @@ static int q6afe_port_set_param_v2(struct q6afe_port *port, void *data,
dev_err(afe->dev, "AFE enable for port 0x%x failed %d\n",
port_id, ret);
- kfree(pkt);
return ret;
}
@@ -1285,7 +1279,7 @@ int q6afe_port_stop(struct q6afe_port *port)
int port_id = port->id;
int ret = 0;
int index, pkt_size;
- void *p;
+ void *p __free(kfree) = NULL;
index = port->token;
if (index < 0 || index >= AFE_PORT_MAX) {
@@ -1316,7 +1310,6 @@ int q6afe_port_stop(struct q6afe_port *port)
if (ret)
dev_err(afe->dev, "AFE close failed %d\n", ret);
- kfree(pkt);
return ret;
}
EXPORT_SYMBOL_GPL(q6afe_port_stop);
@@ -1676,7 +1669,7 @@ int q6afe_port_start(struct q6afe_port *port)
int ret, param_id = port->cfg_type;
struct apr_pkt *pkt;
int pkt_size;
- void *p;
+ void *p __free(kfree) = NULL;
ret = q6afe_port_set_param_v2(port, &port->port_cfg, param_id,
AFE_MODULE_AUDIO_DEV_INTERFACE,
@@ -1722,7 +1715,6 @@ int q6afe_port_start(struct q6afe_port *port)
dev_err(afe->dev, "AFE enable for port 0x%x failed %d\n",
port_id, ret);
- kfree(pkt);
return ret;
}
EXPORT_SYMBOL_GPL(q6afe_port_start);
@@ -1845,11 +1837,8 @@ int q6afe_unvote_lpass_core_hw(struct device *dev, uint32_t hw_block_id,
struct afe_cmd_remote_lpass_core_hw_devote_request *vote_cfg;
struct apr_pkt *pkt;
int ret = 0;
- int pkt_size;
- void *p;
-
- pkt_size = APR_HDR_SIZE + sizeof(*vote_cfg);
- p = kzalloc(pkt_size, GFP_KERNEL);
+ int pkt_size = APR_HDR_SIZE + sizeof(*vote_cfg);
+ void *p __free(kfree) = kzalloc(pkt_size, GFP_KERNEL);
if (!p)
return -ENOMEM;
@@ -1871,7 +1860,6 @@ int q6afe_unvote_lpass_core_hw(struct device *dev, uint32_t hw_block_id,
if (ret < 0)
dev_err(afe->dev, "AFE failed to unvote (%d)\n", hw_block_id);
- kfree(pkt);
return ret;
}
EXPORT_SYMBOL(q6afe_unvote_lpass_core_hw);
@@ -1883,11 +1871,8 @@ int q6afe_vote_lpass_core_hw(struct device *dev, uint32_t hw_block_id,
struct afe_cmd_remote_lpass_core_hw_vote_request *vote_cfg;
struct apr_pkt *pkt;
int ret = 0;
- int pkt_size;
- void *p;
-
- pkt_size = APR_HDR_SIZE + sizeof(*vote_cfg);
- p = kzalloc(pkt_size, GFP_KERNEL);
+ int pkt_size = APR_HDR_SIZE + sizeof(*vote_cfg);
+ void *p __free(kfree) = kzalloc(pkt_size, GFP_KERNEL);
if (!p)
return -ENOMEM;
@@ -1911,8 +1896,6 @@ int q6afe_vote_lpass_core_hw(struct device *dev, uint32_t hw_block_id,
if (ret)
dev_err(afe->dev, "AFE failed to vote (%d)\n", hw_block_id);
-
- kfree(pkt);
return ret;
}
EXPORT_SYMBOL(q6afe_vote_lpass_core_hw);
--
2.51.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 06/12] ASoc: qcom: q6apm: Use automatic cleanup of kfree()
2025-10-17 8:52 [PATCH 00/12] ASoC: qcom: q6dsp: few cleanups Srinivas Kandagatla
` (4 preceding siblings ...)
2025-10-17 8:53 ` [PATCH 05/12] ASoc: qcom: q6afe: " Srinivas Kandagatla
@ 2025-10-17 8:53 ` Srinivas Kandagatla
2025-10-17 8:53 ` [PATCH 07/12] ASoc: qcom: q6prm: " Srinivas Kandagatla
` (6 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: Srinivas Kandagatla @ 2025-10-17 8:53 UTC (permalink / raw)
To: broonie
Cc: perex, tiwai, srini, alexey.klimov, linux-sound, linux-kernel,
linux-arm-msm, Srinivas Kandagatla
Its common pattern in q6dsp code to allocate temporary buffer
to send gpr/apr packets and free at the function exit.
Now this can be simplified via __free(kfree) mechanism.
No functional changes.
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
---
sound/soc/qcom/qdsp6/q6apm.c | 57 +++++++++++-------------------------
1 file changed, 17 insertions(+), 40 deletions(-)
diff --git a/sound/soc/qcom/qdsp6/q6apm.c b/sound/soc/qcom/qdsp6/q6apm.c
index 0e667a7eb546..7a7d7195d990 100644
--- a/sound/soc/qcom/qdsp6/q6apm.c
+++ b/sound/soc/qcom/qdsp6/q6apm.c
@@ -99,12 +99,8 @@ static int audioreach_graph_mgmt_cmd(struct audioreach_graph *graph, uint32_t op
struct apm_graph_mgmt_cmd *mgmt_cmd;
struct audioreach_sub_graph *sg;
struct q6apm *apm = graph->apm;
- int i = 0, rc, payload_size;
- struct gpr_pkt *pkt;
-
- payload_size = APM_GRAPH_MGMT_PSIZE(mgmt_cmd, num_sub_graphs);
-
- pkt = audioreach_alloc_apm_cmd_pkt(payload_size, opcode, 0);
+ int i = 0, payload_size = APM_GRAPH_MGMT_PSIZE(mgmt_cmd, num_sub_graphs);
+ struct gpr_pkt *pkt __free(kfree) = audioreach_alloc_apm_cmd_pkt(payload_size, opcode, 0);
if (IS_ERR(pkt))
return PTR_ERR(pkt);
@@ -120,11 +116,7 @@ static int audioreach_graph_mgmt_cmd(struct audioreach_graph *graph, uint32_t op
list_for_each_entry(sg, &info->sg_list, node)
mgmt_cmd->sub_graph_id_list[i++] = sg->sub_graph_id;
- rc = q6apm_send_cmd_sync(apm, pkt, 0);
-
- kfree(pkt);
-
- return rc;
+ return q6apm_send_cmd_sync(apm, pkt, 0);
}
static void q6apm_put_audioreach_graph(struct kref *ref)
@@ -148,16 +140,13 @@ static void q6apm_put_audioreach_graph(struct kref *ref)
static int q6apm_get_apm_state(struct q6apm *apm)
{
- struct gpr_pkt *pkt;
-
- pkt = audioreach_alloc_apm_cmd_pkt(0, APM_CMD_GET_SPF_STATE, 0);
+ struct gpr_pkt *pkt __free(kfree) = audioreach_alloc_apm_cmd_pkt(0,
+ APM_CMD_GET_SPF_STATE, 0);
if (IS_ERR(pkt))
return PTR_ERR(pkt);
q6apm_send_cmd_sync(apm, pkt, APM_CMD_RSP_GET_SPF_STATE);
- kfree(pkt);
-
return apm->state;
}
@@ -270,7 +259,7 @@ int q6apm_unmap_memory_regions(struct q6apm_graph *graph, unsigned int dir)
{
struct apm_cmd_shared_mem_unmap_regions *cmd;
struct audioreach_graph_data *data;
- struct gpr_pkt *pkt;
+ struct gpr_pkt *pkt __free(kfree) = NULL;
int rc;
if (dir == SNDRV_PCM_STREAM_PLAYBACK)
@@ -290,7 +279,6 @@ int q6apm_unmap_memory_regions(struct q6apm_graph *graph, unsigned int dir)
cmd->mem_map_handle = data->mem_map_handle;
rc = audioreach_graph_send_cmd_sync(graph, pkt, APM_CMD_SHARED_MEM_UNMAP_REGIONS);
- kfree(pkt);
audioreach_graph_free_buf(graph);
@@ -420,13 +408,11 @@ int q6apm_write_async(struct q6apm_graph *graph, uint32_t len, uint32_t msw_ts,
{
struct apm_data_cmd_wr_sh_mem_ep_data_buffer_v2 *write_buffer;
struct audio_buffer *ab;
- struct gpr_pkt *pkt;
- int rc, iid;
-
- iid = q6apm_graph_get_rx_shmem_module_iid(graph);
- pkt = audioreach_alloc_pkt(sizeof(*write_buffer), DATA_CMD_WR_SH_MEM_EP_DATA_BUFFER_V2,
- graph->rx_data.dsp_buf | (len << APM_WRITE_TOKEN_LEN_SHIFT),
- graph->port->id, iid);
+ int iid = q6apm_graph_get_rx_shmem_module_iid(graph);
+ struct gpr_pkt *pkt __free(kfree) = audioreach_alloc_pkt(sizeof(*write_buffer),
+ DATA_CMD_WR_SH_MEM_EP_DATA_BUFFER_V2,
+ graph->rx_data.dsp_buf | (len << APM_WRITE_TOKEN_LEN_SHIFT),
+ graph->port->id, iid);
if (IS_ERR(pkt))
return PTR_ERR(pkt);
@@ -450,11 +436,7 @@ int q6apm_write_async(struct q6apm_graph *graph, uint32_t len, uint32_t msw_ts,
mutex_unlock(&graph->lock);
- rc = gpr_send_port_pkt(graph->port, pkt);
-
- kfree(pkt);
-
- return rc;
+ return gpr_send_port_pkt(graph->port, pkt);
}
EXPORT_SYMBOL_GPL(q6apm_write_async);
@@ -463,12 +445,10 @@ int q6apm_read(struct q6apm_graph *graph)
struct data_cmd_rd_sh_mem_ep_data_buffer_v2 *read_buffer;
struct audioreach_graph_data *port;
struct audio_buffer *ab;
- struct gpr_pkt *pkt;
- int rc, iid;
-
- iid = q6apm_graph_get_tx_shmem_module_iid(graph);
- pkt = audioreach_alloc_pkt(sizeof(*read_buffer), DATA_CMD_RD_SH_MEM_EP_DATA_BUFFER_V2,
- graph->tx_data.dsp_buf, graph->port->id, iid);
+ int iid = q6apm_graph_get_tx_shmem_module_iid(graph);
+ struct gpr_pkt *pkt __free(kfree) = audioreach_alloc_pkt(sizeof(*read_buffer),
+ DATA_CMD_RD_SH_MEM_EP_DATA_BUFFER_V2,
+ graph->tx_data.dsp_buf, graph->port->id, iid);
if (IS_ERR(pkt))
return PTR_ERR(pkt);
@@ -490,10 +470,7 @@ int q6apm_read(struct q6apm_graph *graph)
mutex_unlock(&graph->lock);
- rc = gpr_send_port_pkt(graph->port, pkt);
- kfree(pkt);
-
- return rc;
+ return gpr_send_port_pkt(graph->port, pkt);
}
EXPORT_SYMBOL_GPL(q6apm_read);
--
2.51.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 07/12] ASoc: qcom: q6prm: Use automatic cleanup of kfree()
2025-10-17 8:52 [PATCH 00/12] ASoC: qcom: q6dsp: few cleanups Srinivas Kandagatla
` (5 preceding siblings ...)
2025-10-17 8:53 ` [PATCH 06/12] ASoc: qcom: q6apm: " Srinivas Kandagatla
@ 2025-10-17 8:53 ` Srinivas Kandagatla
2025-10-17 8:53 ` [PATCH 08/12] ASoc: qcom: q6asm: " Srinivas Kandagatla
` (5 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: Srinivas Kandagatla @ 2025-10-17 8:53 UTC (permalink / raw)
To: broonie
Cc: perex, tiwai, srini, alexey.klimov, linux-sound, linux-kernel,
linux-arm-msm, Srinivas Kandagatla
Its common pattern in q6dsp code to allocate temporary buffer
to send gpr/apr packets and free at the function exit.
Now this can be simplified via __free(kfree) mechanism.
No functional changes.
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
---
sound/soc/qcom/qdsp6/q6prm.c | 27 ++++++---------------------
1 file changed, 6 insertions(+), 21 deletions(-)
diff --git a/sound/soc/qcom/qdsp6/q6prm.c b/sound/soc/qcom/qdsp6/q6prm.c
index 81554d202658..0b8fad0bc832 100644
--- a/sound/soc/qcom/qdsp6/q6prm.c
+++ b/sound/soc/qcom/qdsp6/q6prm.c
@@ -62,8 +62,7 @@ static int q6prm_set_hw_core_req(struct device *dev, uint32_t hw_block_id, bool
struct prm_cmd_request_hw_core *req;
gpr_device_t *gdev = prm->gdev;
uint32_t opcode, rsp_opcode;
- struct gpr_pkt *pkt;
- int rc;
+ struct gpr_pkt *pkt __free(kfree) = NULL;
if (enable) {
opcode = PRM_CMD_REQUEST_HW_RSC;
@@ -88,11 +87,7 @@ static int q6prm_set_hw_core_req(struct device *dev, uint32_t hw_block_id, bool
req->hw_clk_id = hw_block_id;
- rc = q6prm_send_cmd_sync(prm, pkt, rsp_opcode);
-
- kfree(pkt);
-
- return rc;
+ return q6prm_send_cmd_sync(prm, pkt, rsp_opcode);
}
int q6prm_vote_lpass_core_hw(struct device *dev, uint32_t hw_block_id,
@@ -116,8 +111,7 @@ static int q6prm_request_lpass_clock(struct device *dev, int clk_id, int clk_att
struct apm_module_param_data *param_data;
struct prm_cmd_request_rsc *req;
gpr_device_t *gdev = prm->gdev;
- struct gpr_pkt *pkt;
- int rc;
+ struct gpr_pkt *pkt __free(kfree) = NULL;
pkt = audioreach_alloc_cmd_pkt(sizeof(*req), PRM_CMD_REQUEST_HW_RSC, 0, gdev->svc.id,
GPR_PRM_MODULE_IID);
@@ -139,11 +133,7 @@ static int q6prm_request_lpass_clock(struct device *dev, int clk_id, int clk_att
req->clock_id.clock_attri = clk_attr;
req->clock_id.clock_root = clk_root;
- rc = q6prm_send_cmd_sync(prm, pkt, PRM_CMD_RSP_REQUEST_HW_RSC);
-
- kfree(pkt);
-
- return rc;
+ return q6prm_send_cmd_sync(prm, pkt, PRM_CMD_RSP_REQUEST_HW_RSC);
}
static int q6prm_release_lpass_clock(struct device *dev, int clk_id, int clk_attr, int clk_root,
@@ -153,8 +143,7 @@ static int q6prm_release_lpass_clock(struct device *dev, int clk_id, int clk_att
struct apm_module_param_data *param_data;
struct prm_cmd_release_rsc *rel;
gpr_device_t *gdev = prm->gdev;
- struct gpr_pkt *pkt;
- int rc;
+ struct gpr_pkt *pkt __free(kfree) = NULL;
pkt = audioreach_alloc_cmd_pkt(sizeof(*rel), PRM_CMD_RELEASE_HW_RSC, 0, gdev->svc.id,
GPR_PRM_MODULE_IID);
@@ -173,11 +162,7 @@ static int q6prm_release_lpass_clock(struct device *dev, int clk_id, int clk_att
rel->num_clk_id = 1;
rel->clock_id.clock_id = clk_id;
- rc = q6prm_send_cmd_sync(prm, pkt, PRM_CMD_RSP_RELEASE_HW_RSC);
-
- kfree(pkt);
-
- return rc;
+ return q6prm_send_cmd_sync(prm, pkt, PRM_CMD_RSP_RELEASE_HW_RSC);
}
int q6prm_set_lpass_clock(struct device *dev, int clk_id, int clk_attr, int clk_root,
--
2.51.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 08/12] ASoc: qcom: q6asm: Use automatic cleanup of kfree()
2025-10-17 8:52 [PATCH 00/12] ASoC: qcom: q6dsp: few cleanups Srinivas Kandagatla
` (6 preceding siblings ...)
2025-10-17 8:53 ` [PATCH 07/12] ASoc: qcom: q6prm: " Srinivas Kandagatla
@ 2025-10-17 8:53 ` Srinivas Kandagatla
2025-10-17 8:53 ` [PATCH 09/12] ASoC: qcom: q6afe: Use guard() for spin locks Srinivas Kandagatla
` (4 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: Srinivas Kandagatla @ 2025-10-17 8:53 UTC (permalink / raw)
To: broonie
Cc: perex, tiwai, srini, alexey.klimov, linux-sound, linux-kernel,
linux-arm-msm, Srinivas Kandagatla
Its common pattern in q6dsp code to allocate temporary buffer
to send gpr/apr packets and free at the function exit.
Now this can be simplified via __free(kfree) mechanism.
No functional changes.
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
---
sound/soc/qcom/qdsp6/q6asm.c | 166 +++++++++--------------------------
1 file changed, 42 insertions(+), 124 deletions(-)
diff --git a/sound/soc/qcom/qdsp6/q6asm.c b/sound/soc/qcom/qdsp6/q6asm.c
index 67e9ca18883c..366fe8a8387f 100644
--- a/sound/soc/qcom/qdsp6/q6asm.c
+++ b/sound/soc/qcom/qdsp6/q6asm.c
@@ -333,7 +333,7 @@ static int __q6asm_memory_unmap(struct audio_client *ac,
struct q6asm *a = dev_get_drvdata(ac->dev->parent);
struct apr_pkt *pkt;
int rc, pkt_size;
- void *p;
+ void *p __free(kfree) = NULL;
if (ac->port[dir].mem_map_handle == 0) {
dev_err(ac->dev, "invalid mem handle\n");
@@ -358,14 +358,11 @@ static int __q6asm_memory_unmap(struct audio_client *ac,
mem_unmap->mem_map_handle = ac->port[dir].mem_map_handle;
rc = q6asm_apr_send_session_pkt(a, ac, pkt, 0);
- if (rc < 0) {
- kfree(pkt);
+ if (rc < 0)
return rc;
- }
ac->port[dir].mem_map_handle = 0;
- kfree(pkt);
return 0;
}
@@ -429,10 +426,10 @@ static int __q6asm_memory_map_regions(struct audio_client *ac, int dir,
struct audio_port_data *port = NULL;
struct audio_buffer *ab = NULL;
struct apr_pkt *pkt;
- void *p;
+ void *p __free(kfree) = NULL;
unsigned long flags;
uint32_t num_regions, buf_sz;
- int rc, i, pkt_size;
+ int i, pkt_size;
if (is_contiguous) {
num_regions = 1;
@@ -479,12 +476,7 @@ static int __q6asm_memory_map_regions(struct audio_client *ac, int dir,
}
spin_unlock_irqrestore(&ac->lock, flags);
- rc = q6asm_apr_send_session_pkt(a, ac, pkt,
- ASM_CMDRSP_SHARED_MEM_MAP_REGIONS);
-
- kfree(pkt);
-
- return rc;
+ return q6asm_apr_send_session_pkt(a, ac, pkt, ASM_CMDRSP_SHARED_MEM_MAP_REGIONS);
}
/**
@@ -930,12 +922,8 @@ int q6asm_open_write(struct audio_client *ac, uint32_t stream_id,
{
struct asm_stream_cmd_open_write_v3 *open;
struct apr_pkt *pkt;
- void *p;
- int rc, pkt_size;
-
- pkt_size = APR_HDR_SIZE + sizeof(*open);
-
- p = kzalloc(pkt_size, GFP_KERNEL);
+ int rc, pkt_size = APR_HDR_SIZE + sizeof(*open);
+ void *p __free(kfree) = kzalloc(pkt_size, GFP_KERNEL);
if (!p)
return -ENOMEM;
@@ -1001,7 +989,6 @@ int q6asm_open_write(struct audio_client *ac, uint32_t stream_id,
ac->io_mode |= ASM_TUN_WRITE_IO_MODE;
err:
- kfree(pkt);
return rc;
}
EXPORT_SYMBOL_GPL(q6asm_open_write);
@@ -1012,11 +999,8 @@ static int __q6asm_run(struct audio_client *ac, uint32_t stream_id,
{
struct asm_session_cmd_run_v2 *run;
struct apr_pkt *pkt;
- int pkt_size, rc;
- void *p;
-
- pkt_size = APR_HDR_SIZE + sizeof(*run);
- p = kzalloc(pkt_size, GFP_ATOMIC);
+ int rc, pkt_size = APR_HDR_SIZE + sizeof(*run);
+ void *p __free(kfree) = kzalloc(pkt_size, GFP_ATOMIC);
if (!p)
return -ENOMEM;
@@ -1037,7 +1021,6 @@ static int __q6asm_run(struct audio_client *ac, uint32_t stream_id,
rc = 0;
}
- kfree(pkt);
return rc;
}
@@ -1098,11 +1081,8 @@ int q6asm_media_format_block_multi_ch_pcm(struct audio_client *ac,
struct asm_multi_channel_pcm_fmt_blk_v2 *fmt;
struct apr_pkt *pkt;
u8 *channel_mapping;
- void *p;
- int rc, pkt_size;
-
- pkt_size = APR_HDR_SIZE + sizeof(*fmt);
- p = kzalloc(pkt_size, GFP_KERNEL);
+ int pkt_size = APR_HDR_SIZE + sizeof(*fmt);
+ void *p __free(kfree) = kzalloc(pkt_size, GFP_KERNEL);
if (!p)
return -ENOMEM;
@@ -1125,16 +1105,11 @@ int q6asm_media_format_block_multi_ch_pcm(struct audio_client *ac,
} else {
if (q6dsp_map_channels(channel_mapping, channels)) {
dev_err(ac->dev, " map channels failed %d\n", channels);
- rc = -EINVAL;
- goto err;
+ return -EINVAL;
}
}
- rc = q6asm_ac_send_cmd_sync(ac, pkt);
-
-err:
- kfree(pkt);
- return rc;
+ return q6asm_ac_send_cmd_sync(ac, pkt);
}
EXPORT_SYMBOL_GPL(q6asm_media_format_block_multi_ch_pcm);
@@ -1144,11 +1119,8 @@ int q6asm_stream_media_format_block_flac(struct audio_client *ac,
{
struct asm_flac_fmt_blk_v2 *fmt;
struct apr_pkt *pkt;
- void *p;
- int rc, pkt_size;
-
- pkt_size = APR_HDR_SIZE + sizeof(*fmt);
- p = kzalloc(pkt_size, GFP_KERNEL);
+ int pkt_size = APR_HDR_SIZE + sizeof(*fmt);
+ void *p __free(kfree) = kzalloc(pkt_size, GFP_KERNEL);
if (!p)
return -ENOMEM;
@@ -1168,10 +1140,7 @@ int q6asm_stream_media_format_block_flac(struct audio_client *ac,
fmt->max_frame_size = cfg->max_frame_size;
fmt->sample_size = cfg->sample_size;
- rc = q6asm_ac_send_cmd_sync(ac, pkt);
- kfree(pkt);
-
- return rc;
+ return q6asm_ac_send_cmd_sync(ac, pkt);
}
EXPORT_SYMBOL_GPL(q6asm_stream_media_format_block_flac);
@@ -1181,11 +1150,8 @@ int q6asm_stream_media_format_block_wma_v9(struct audio_client *ac,
{
struct asm_wmastdv9_fmt_blk_v2 *fmt;
struct apr_pkt *pkt;
- void *p;
- int rc, pkt_size;
-
- pkt_size = APR_HDR_SIZE + sizeof(*fmt);
- p = kzalloc(pkt_size, GFP_KERNEL);
+ int pkt_size = APR_HDR_SIZE + sizeof(*fmt);
+ void *p __free(kfree) = kzalloc(pkt_size, GFP_KERNEL);
if (!p)
return -ENOMEM;
@@ -1206,10 +1172,7 @@ int q6asm_stream_media_format_block_wma_v9(struct audio_client *ac,
fmt->enc_options = cfg->enc_options;
fmt->reserved = 0;
- rc = q6asm_ac_send_cmd_sync(ac, pkt);
- kfree(pkt);
-
- return rc;
+ return q6asm_ac_send_cmd_sync(ac, pkt);
}
EXPORT_SYMBOL_GPL(q6asm_stream_media_format_block_wma_v9);
@@ -1219,11 +1182,8 @@ int q6asm_stream_media_format_block_wma_v10(struct audio_client *ac,
{
struct asm_wmaprov10_fmt_blk_v2 *fmt;
struct apr_pkt *pkt;
- void *p;
- int rc, pkt_size;
-
- pkt_size = APR_HDR_SIZE + sizeof(*fmt);
- p = kzalloc(pkt_size, GFP_KERNEL);
+ int pkt_size = APR_HDR_SIZE + sizeof(*fmt);
+ void *p __free(kfree) = kzalloc(pkt_size, GFP_KERNEL);
if (!p)
return -ENOMEM;
@@ -1245,10 +1205,7 @@ int q6asm_stream_media_format_block_wma_v10(struct audio_client *ac,
fmt->advanced_enc_options1 = cfg->adv_enc_options;
fmt->advanced_enc_options2 = cfg->adv_enc_options2;
- rc = q6asm_ac_send_cmd_sync(ac, pkt);
- kfree(pkt);
-
- return rc;
+ return q6asm_ac_send_cmd_sync(ac, pkt);
}
EXPORT_SYMBOL_GPL(q6asm_stream_media_format_block_wma_v10);
@@ -1258,11 +1215,8 @@ int q6asm_stream_media_format_block_alac(struct audio_client *ac,
{
struct asm_alac_fmt_blk_v2 *fmt;
struct apr_pkt *pkt;
- void *p;
- int rc, pkt_size;
-
- pkt_size = APR_HDR_SIZE + sizeof(*fmt);
- p = kzalloc(pkt_size, GFP_KERNEL);
+ int pkt_size = APR_HDR_SIZE + sizeof(*fmt);
+ void *p __free(kfree) = kzalloc(pkt_size, GFP_KERNEL);
if (!p)
return -ENOMEM;
@@ -1287,10 +1241,7 @@ int q6asm_stream_media_format_block_alac(struct audio_client *ac,
fmt->mb = cfg->mb;
fmt->kb = cfg->kb;
- rc = q6asm_ac_send_cmd_sync(ac, pkt);
- kfree(pkt);
-
- return rc;
+ return q6asm_ac_send_cmd_sync(ac, pkt);
}
EXPORT_SYMBOL_GPL(q6asm_stream_media_format_block_alac);
@@ -1300,11 +1251,8 @@ int q6asm_stream_media_format_block_ape(struct audio_client *ac,
{
struct asm_ape_fmt_blk_v2 *fmt;
struct apr_pkt *pkt;
- void *p;
- int rc, pkt_size;
-
- pkt_size = APR_HDR_SIZE + sizeof(*fmt);
- p = kzalloc(pkt_size, GFP_KERNEL);
+ int pkt_size = APR_HDR_SIZE + sizeof(*fmt);
+ void *p __free(kfree) = kzalloc(pkt_size, GFP_KERNEL);
if (!p)
return -ENOMEM;
@@ -1327,10 +1275,7 @@ int q6asm_stream_media_format_block_ape(struct audio_client *ac,
fmt->sample_rate = cfg->sample_rate;
fmt->seek_table_present = cfg->seek_table_present;
- rc = q6asm_ac_send_cmd_sync(ac, pkt);
- kfree(pkt);
-
- return rc;
+ return q6asm_ac_send_cmd_sync(ac, pkt);
}
EXPORT_SYMBOL_GPL(q6asm_stream_media_format_block_ape);
@@ -1340,11 +1285,8 @@ static int q6asm_stream_remove_silence(struct audio_client *ac, uint32_t stream_
{
uint32_t *samples;
struct apr_pkt *pkt;
- void *p;
- int rc, pkt_size;
-
- pkt_size = APR_HDR_SIZE + sizeof(uint32_t);
- p = kzalloc(pkt_size, GFP_ATOMIC);
+ int rc, pkt_size = APR_HDR_SIZE + sizeof(uint32_t);
+ void *p __free(kfree) = kzalloc(pkt_size, GFP_ATOMIC);
if (!p)
return -ENOMEM;
@@ -1359,8 +1301,6 @@ static int q6asm_stream_remove_silence(struct audio_client *ac, uint32_t stream_
if (rc == pkt_size)
rc = 0;
- kfree(pkt);
-
return rc;
}
@@ -1403,11 +1343,8 @@ int q6asm_enc_cfg_blk_pcm_format_support(struct audio_client *ac,
struct apr_pkt *pkt;
u8 *channel_mapping;
u32 frames_per_buf = 0;
- int pkt_size, rc;
- void *p;
-
- pkt_size = APR_HDR_SIZE + sizeof(*enc_cfg);
- p = kzalloc(pkt_size, GFP_KERNEL);
+ int pkt_size = APR_HDR_SIZE + sizeof(*enc_cfg);
+ void *p __free(kfree) = kzalloc(pkt_size, GFP_KERNEL);
if (!p)
return -ENOMEM;
@@ -1428,15 +1365,10 @@ int q6asm_enc_cfg_blk_pcm_format_support(struct audio_client *ac,
enc_cfg->is_signed = 1;
channel_mapping = enc_cfg->channel_mapping;
- if (q6dsp_map_channels(channel_mapping, channels)) {
- rc = -EINVAL;
- goto err;
- }
+ if (q6dsp_map_channels(channel_mapping, channels))
+ return -EINVAL;
- rc = q6asm_ac_send_cmd_sync(ac, pkt);
-err:
- kfree(pkt);
- return rc;
+ return q6asm_ac_send_cmd_sync(ac, pkt);
}
EXPORT_SYMBOL_GPL(q6asm_enc_cfg_blk_pcm_format_support);
@@ -1456,12 +1388,9 @@ int q6asm_read(struct audio_client *ac, uint32_t stream_id)
struct audio_buffer *ab;
struct apr_pkt *pkt;
unsigned long flags;
- int pkt_size;
+ int pkt_size = APR_HDR_SIZE + sizeof(*read);
int rc = 0;
- void *p;
-
- pkt_size = APR_HDR_SIZE + sizeof(*read);
- p = kzalloc(pkt_size, GFP_ATOMIC);
+ void *p __free(kfree) = kzalloc(pkt_size, GFP_ATOMIC);
if (!p)
return -ENOMEM;
@@ -1493,7 +1422,6 @@ int q6asm_read(struct audio_client *ac, uint32_t stream_id)
else
pr_err("read op[0x%x]rc[%d]\n", pkt->hdr.opcode, rc);
- kfree(pkt);
return rc;
}
EXPORT_SYMBOL_GPL(q6asm_read);
@@ -1503,11 +1431,8 @@ static int __q6asm_open_read(struct audio_client *ac, uint32_t stream_id,
{
struct asm_stream_cmd_open_read_v3 *open;
struct apr_pkt *pkt;
- int pkt_size, rc;
- void *p;
-
- pkt_size = APR_HDR_SIZE + sizeof(*open);
- p = kzalloc(pkt_size, GFP_KERNEL);
+ int pkt_size = APR_HDR_SIZE + sizeof(*open);
+ void *p __free(kfree) = kzalloc(pkt_size, GFP_KERNEL);
if (!p)
return -ENOMEM;
@@ -1535,10 +1460,7 @@ static int __q6asm_open_read(struct audio_client *ac, uint32_t stream_id,
pr_err("Invalid format[%d]\n", format);
}
- rc = q6asm_ac_send_cmd_sync(ac, pkt);
-
- kfree(pkt);
- return rc;
+ return q6asm_ac_send_cmd_sync(ac, pkt);
}
/**
@@ -1578,12 +1500,9 @@ int q6asm_write_async(struct audio_client *ac, uint32_t stream_id, uint32_t len,
struct audio_buffer *ab;
unsigned long flags;
struct apr_pkt *pkt;
- int pkt_size;
+ int pkt_size = APR_HDR_SIZE + sizeof(*write);
int rc = 0;
- void *p;
-
- pkt_size = APR_HDR_SIZE + sizeof(*write);
- p = kzalloc(pkt_size, GFP_ATOMIC);
+ void *p __free(kfree) = kzalloc(pkt_size, GFP_ATOMIC);
if (!p)
return -ENOMEM;
@@ -1618,7 +1537,6 @@ int q6asm_write_async(struct audio_client *ac, uint32_t stream_id, uint32_t len,
if (rc == pkt_size)
rc = 0;
- kfree(pkt);
return rc;
}
EXPORT_SYMBOL_GPL(q6asm_write_async);
--
2.51.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 09/12] ASoC: qcom: q6afe: Use guard() for spin locks
2025-10-17 8:52 [PATCH 00/12] ASoC: qcom: q6dsp: few cleanups Srinivas Kandagatla
` (7 preceding siblings ...)
2025-10-17 8:53 ` [PATCH 08/12] ASoc: qcom: q6asm: " Srinivas Kandagatla
@ 2025-10-17 8:53 ` Srinivas Kandagatla
2025-10-17 8:53 ` [PATCH 10/12] ASoC: qcom: q6apm-dai: " Srinivas Kandagatla
` (3 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: Srinivas Kandagatla @ 2025-10-17 8:53 UTC (permalink / raw)
To: broonie
Cc: perex, tiwai, srini, alexey.klimov, linux-sound, linux-kernel,
linux-arm-msm, Srinivas Kandagatla
Clean up the code using guard() for spin locks.
No functional changes, just cleanup.
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
---
sound/soc/qcom/qdsp6/q6afe.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/sound/soc/qcom/qdsp6/q6afe.c b/sound/soc/qcom/qdsp6/q6afe.c
index 56f85f1c2425..980851a12976 100644
--- a/sound/soc/qcom/qdsp6/q6afe.c
+++ b/sound/soc/qcom/qdsp6/q6afe.c
@@ -946,9 +946,8 @@ static struct q6afe_port *q6afe_find_port(struct q6afe *afe, int token)
{
struct q6afe_port *p;
struct q6afe_port *ret = NULL;
- unsigned long flags;
- spin_lock_irqsave(&afe->port_list_lock, flags);
+ guard(spinlock)(&afe->port_list_lock);
list_for_each_entry(p, &afe->port_list, node)
if (p->token == token) {
ret = p;
@@ -956,7 +955,6 @@ static struct q6afe_port *q6afe_find_port(struct q6afe *afe, int token)
break;
}
- spin_unlock_irqrestore(&afe->port_list_lock, flags);
return ret;
}
@@ -1733,7 +1731,6 @@ struct q6afe_port *q6afe_port_get_from_id(struct device *dev, int id)
int port_id;
struct q6afe *afe = dev_get_drvdata(dev->parent);
struct q6afe_port *port;
- unsigned long flags;
int cfg_type;
if (id < 0 || id >= AFE_PORT_MAX) {
@@ -1810,9 +1807,8 @@ struct q6afe_port *q6afe_port_get_from_id(struct device *dev, int id)
port->cfg_type = cfg_type;
kref_init(&port->refcount);
- spin_lock_irqsave(&afe->port_list_lock, flags);
+ guard(spinlock)(&afe->port_list_lock);
list_add_tail(&port->node, &afe->port_list);
- spin_unlock_irqrestore(&afe->port_list_lock, flags);
return port;
--
2.51.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 10/12] ASoC: qcom: q6apm-dai: Use guard() for spin locks
2025-10-17 8:52 [PATCH 00/12] ASoC: qcom: q6dsp: few cleanups Srinivas Kandagatla
` (8 preceding siblings ...)
2025-10-17 8:53 ` [PATCH 09/12] ASoC: qcom: q6afe: Use guard() for spin locks Srinivas Kandagatla
@ 2025-10-17 8:53 ` Srinivas Kandagatla
2025-10-17 8:53 ` [PATCH 11/12] ASoC: qcom: q6asm-dai: " Srinivas Kandagatla
` (2 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: Srinivas Kandagatla @ 2025-10-17 8:53 UTC (permalink / raw)
To: broonie
Cc: perex, tiwai, srini, alexey.klimov, linux-sound, linux-kernel,
linux-arm-msm, Srinivas Kandagatla
Clean up the code using guard() for spin locks.
No functional changes, just cleanup.
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
---
sound/soc/qcom/qdsp6/q6apm-dai.c | 23 +++++------------------
1 file changed, 5 insertions(+), 18 deletions(-)
diff --git a/sound/soc/qcom/qdsp6/q6apm-dai.c b/sound/soc/qcom/qdsp6/q6apm-dai.c
index 4ecaff45c518..865fb0b3bc06 100644
--- a/sound/soc/qcom/qdsp6/q6apm-dai.c
+++ b/sound/soc/qcom/qdsp6/q6apm-dai.c
@@ -149,33 +149,28 @@ static void event_handler_compr(uint32_t opcode, uint32_t token,
{
struct q6apm_dai_rtd *prtd = priv;
struct snd_compr_stream *substream = prtd->cstream;
- unsigned long flags;
uint32_t wflags = 0;
uint64_t avail;
uint32_t bytes_written, bytes_to_write;
bool is_last_buffer = false;
+ guard(spinlock_irqsave)(&prtd->lock);
switch (opcode) {
case APM_CLIENT_EVENT_CMD_EOS_DONE:
- spin_lock_irqsave(&prtd->lock, flags);
if (prtd->notify_on_drain) {
snd_compr_drain_notify(prtd->cstream);
prtd->notify_on_drain = false;
} else {
prtd->state = Q6APM_STREAM_STOPPED;
}
- spin_unlock_irqrestore(&prtd->lock, flags);
break;
case APM_CLIENT_EVENT_DATA_WRITE_DONE:
- spin_lock_irqsave(&prtd->lock, flags);
bytes_written = token >> APM_WRITE_TOKEN_LEN_SHIFT;
prtd->copied_total += bytes_written;
snd_compr_fragment_elapsed(substream);
- if (prtd->state != Q6APM_STREAM_RUNNING) {
- spin_unlock_irqrestore(&prtd->lock, flags);
+ if (prtd->state != Q6APM_STREAM_RUNNING)
break;
- }
avail = prtd->bytes_received - prtd->bytes_sent;
@@ -200,7 +195,6 @@ static void event_handler_compr(uint32_t opcode, uint32_t token,
audioreach_shared_memory_send_eos(prtd->graph);
}
- spin_unlock_irqrestore(&prtd->lock, flags);
break;
default:
break;
@@ -581,14 +575,12 @@ static int q6apm_dai_compr_pointer(struct snd_soc_component *component,
{
struct snd_compr_runtime *runtime = stream->runtime;
struct q6apm_dai_rtd *prtd = runtime->private_data;
- unsigned long flags;
uint64_t temp_copied_total;
- spin_lock_irqsave(&prtd->lock, flags);
+ guard(spinlock_irqsave)(&prtd->lock);
tstamp->copied_total = prtd->copied_total;
temp_copied_total = tstamp->copied_total;
tstamp->byte_offset = do_div(temp_copied_total, prtd->pcm_size);
- spin_unlock_irqrestore(&prtd->lock, flags);
return 0;
}
@@ -631,11 +623,9 @@ static int q6apm_dai_compr_ack(struct snd_soc_component *component, struct snd_c
{
struct snd_compr_runtime *runtime = stream->runtime;
struct q6apm_dai_rtd *prtd = runtime->private_data;
- unsigned long flags;
- spin_lock_irqsave(&prtd->lock, flags);
+ guard(spinlock_irqsave)(&prtd->lock);
prtd->bytes_received += count;
- spin_unlock_irqrestore(&prtd->lock, flags);
return count;
}
@@ -760,7 +750,6 @@ static int q6apm_compr_copy(struct snd_soc_component *component,
struct snd_compr_runtime *runtime = stream->runtime;
struct q6apm_dai_rtd *prtd = runtime->private_data;
void *dstn;
- unsigned long flags;
size_t copy;
u32 wflags = 0;
u32 app_pointer;
@@ -795,7 +784,7 @@ static int q6apm_compr_copy(struct snd_soc_component *component,
return -EFAULT;
}
- spin_lock_irqsave(&prtd->lock, flags);
+ guard(spinlock_irqsave)(&prtd->lock);
bytes_in_flight = prtd->bytes_received - prtd->copied_total;
if (prtd->next_track) {
@@ -818,8 +807,6 @@ static int q6apm_compr_copy(struct snd_soc_component *component,
prtd->bytes_sent += bytes_to_write;
}
- spin_unlock_irqrestore(&prtd->lock, flags);
-
return count;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 11/12] ASoC: qcom: q6asm-dai: Use guard() for spin locks
2025-10-17 8:52 [PATCH 00/12] ASoC: qcom: q6dsp: few cleanups Srinivas Kandagatla
` (9 preceding siblings ...)
2025-10-17 8:53 ` [PATCH 10/12] ASoC: qcom: q6apm-dai: " Srinivas Kandagatla
@ 2025-10-17 8:53 ` Srinivas Kandagatla
2025-10-17 8:53 ` [PATCH 12/12] ASoC: qcom: q6asm: " Srinivas Kandagatla
2025-10-21 11:37 ` (subset) [PATCH 00/12] ASoC: qcom: q6dsp: few cleanups Mark Brown
12 siblings, 0 replies; 16+ messages in thread
From: Srinivas Kandagatla @ 2025-10-17 8:53 UTC (permalink / raw)
To: broonie
Cc: perex, tiwai, srini, alexey.klimov, linux-sound, linux-kernel,
linux-arm-msm, Srinivas Kandagatla
Clean up the code using guard() for spin locks.
No functional changes, just cleanup.
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
---
sound/soc/qcom/qdsp6/q6asm-dai.c | 23 +++++------------------
1 file changed, 5 insertions(+), 18 deletions(-)
diff --git a/sound/soc/qcom/qdsp6/q6asm-dai.c b/sound/soc/qcom/qdsp6/q6asm-dai.c
index b616ce316d2f..665a5d1ec4cf 100644
--- a/sound/soc/qcom/qdsp6/q6asm-dai.c
+++ b/sound/soc/qcom/qdsp6/q6asm-dai.c
@@ -493,15 +493,15 @@ static void compress_event_handler(uint32_t opcode, uint32_t token,
{
struct q6asm_dai_rtd *prtd = priv;
struct snd_compr_stream *substream = prtd->cstream;
- unsigned long flags;
u32 wflags = 0;
uint64_t avail;
uint32_t bytes_written, bytes_to_write;
bool is_last_buffer = false;
+ guard(spinlock_irqsave)(&prtd->lock);
+
switch (opcode) {
case ASM_CLIENT_EVENT_CMD_RUN_DONE:
- spin_lock_irqsave(&prtd->lock, flags);
if (!prtd->bytes_sent) {
q6asm_stream_remove_initial_silence(prtd->audio_client,
prtd->stream_id,
@@ -512,11 +512,9 @@ static void compress_event_handler(uint32_t opcode, uint32_t token,
prtd->bytes_sent += prtd->pcm_count;
}
- spin_unlock_irqrestore(&prtd->lock, flags);
break;
case ASM_CLIENT_EVENT_CMD_EOS_DONE:
- spin_lock_irqsave(&prtd->lock, flags);
if (prtd->notify_on_drain) {
if (substream->partial_drain) {
/*
@@ -539,20 +537,16 @@ static void compress_event_handler(uint32_t opcode, uint32_t token,
} else {
prtd->state = Q6ASM_STREAM_STOPPED;
}
- spin_unlock_irqrestore(&prtd->lock, flags);
break;
case ASM_CLIENT_EVENT_DATA_WRITE_DONE:
- spin_lock_irqsave(&prtd->lock, flags);
bytes_written = token >> ASM_WRITE_TOKEN_LEN_SHIFT;
prtd->copied_total += bytes_written;
snd_compr_fragment_elapsed(substream);
- if (prtd->state != Q6ASM_STREAM_RUNNING) {
- spin_unlock_irqrestore(&prtd->lock, flags);
+ if (prtd->state != Q6ASM_STREAM_RUNNING)
break;
- }
avail = prtd->bytes_received - prtd->bytes_sent;
if (avail > prtd->pcm_count) {
@@ -581,7 +575,6 @@ static void compress_event_handler(uint32_t opcode, uint32_t token,
q6asm_cmd_nowait(prtd->audio_client,
prtd->stream_id, CMD_EOS);
- spin_unlock_irqrestore(&prtd->lock, flags);
break;
default:
@@ -1031,17 +1024,14 @@ static int q6asm_dai_compr_pointer(struct snd_soc_component *component,
{
struct snd_compr_runtime *runtime = stream->runtime;
struct q6asm_dai_rtd *prtd = runtime->private_data;
- unsigned long flags;
uint64_t temp_copied_total;
- spin_lock_irqsave(&prtd->lock, flags);
+ guard(spinlock_irqsave)(&prtd->lock);
tstamp->copied_total = prtd->copied_total;
temp_copied_total = tstamp->copied_total;
tstamp->byte_offset = do_div(temp_copied_total, prtd->pcm_size);
- spin_unlock_irqrestore(&prtd->lock, flags);
-
return 0;
}
@@ -1051,7 +1041,6 @@ static int q6asm_compr_copy(struct snd_soc_component *component,
{
struct snd_compr_runtime *runtime = stream->runtime;
struct q6asm_dai_rtd *prtd = runtime->private_data;
- unsigned long flags;
u32 wflags = 0;
uint64_t avail, bytes_in_flight = 0;
void *dstn;
@@ -1087,7 +1076,7 @@ static int q6asm_compr_copy(struct snd_soc_component *component,
return -EFAULT;
}
- spin_lock_irqsave(&prtd->lock, flags);
+ guard(spinlock_irqsave)(&prtd->lock);
bytes_in_flight = prtd->bytes_received - prtd->copied_total;
@@ -1113,8 +1102,6 @@ static int q6asm_compr_copy(struct snd_soc_component *component,
prtd->bytes_sent += bytes_to_write;
}
- spin_unlock_irqrestore(&prtd->lock, flags);
-
return count;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 12/12] ASoC: qcom: q6asm: Use guard() for spin locks
2025-10-17 8:52 [PATCH 00/12] ASoC: qcom: q6dsp: few cleanups Srinivas Kandagatla
` (10 preceding siblings ...)
2025-10-17 8:53 ` [PATCH 11/12] ASoC: qcom: q6asm-dai: " Srinivas Kandagatla
@ 2025-10-17 8:53 ` Srinivas Kandagatla
2025-10-19 4:18 ` kernel test robot
2025-10-21 11:37 ` (subset) [PATCH 00/12] ASoC: qcom: q6dsp: few cleanups Mark Brown
12 siblings, 1 reply; 16+ messages in thread
From: Srinivas Kandagatla @ 2025-10-17 8:53 UTC (permalink / raw)
To: broonie
Cc: perex, tiwai, srini, alexey.klimov, linux-sound, linux-kernel,
linux-arm-msm, Srinivas Kandagatla
Clean up the code using guard() for spin locks.
No functional changes, just cleanup.
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
---
sound/soc/qcom/qdsp6/q6asm.c | 21 +++++----------------
1 file changed, 5 insertions(+), 16 deletions(-)
diff --git a/sound/soc/qcom/qdsp6/q6asm.c b/sound/soc/qcom/qdsp6/q6asm.c
index 366fe8a8387f..7c9d1494e8b9 100644
--- a/sound/soc/qcom/qdsp6/q6asm.c
+++ b/sound/soc/qcom/qdsp6/q6asm.c
@@ -569,9 +569,8 @@ static struct audio_client *q6asm_get_audio_client(struct q6asm *a,
int session_id)
{
struct audio_client *ac = NULL;
- unsigned long flags;
- spin_lock_irqsave(&a->slock, flags);
+ guard(spinlock_irqsave)(&a->slock);
if ((session_id <= 0) || (session_id > MAX_SESSIONS)) {
dev_err(a->dev, "invalid session: %d\n", session_id);
goto err;
@@ -586,7 +585,6 @@ static struct audio_client *q6asm_get_audio_client(struct q6asm *a,
ac = a->session[session_id];
kref_get(&ac->refcount);
err:
- spin_unlock_irqrestore(&a->slock, flags);
return ac;
}
@@ -666,15 +664,13 @@ static int32_t q6asm_stream_callback(struct apr_device *adev,
client_event = ASM_CLIENT_EVENT_DATA_WRITE_DONE;
if (ac->io_mode & ASM_SYNC_IO_MODE) {
phys_addr_t phys;
- unsigned long flags;
int token = hdr->token & ASM_WRITE_TOKEN_MASK;
- spin_lock_irqsave(&ac->lock, flags);
+ guard(spinlock_irqsave)(&ac->lock);
port = &ac->port[SNDRV_PCM_STREAM_PLAYBACK];
if (!port->buf) {
- spin_unlock_irqrestore(&ac->lock, flags);
ret = 0;
goto done;
}
@@ -685,24 +681,21 @@ static int32_t q6asm_stream_callback(struct apr_device *adev,
upper_32_bits(phys) != result->status) {
dev_err(ac->dev, "Expected addr %pa\n",
&port->buf[token].phys);
- spin_unlock_irqrestore(&ac->lock, flags);
ret = -EINVAL;
goto done;
}
- spin_unlock_irqrestore(&ac->lock, flags);
+ atomic_set(&port->hw_ptr, token + 1);
}
break;
case ASM_DATA_EVENT_READ_DONE_V2:
client_event = ASM_CLIENT_EVENT_DATA_READ_DONE;
if (ac->io_mode & ASM_SYNC_IO_MODE) {
struct asm_data_cmd_read_v2_done *done = data->payload;
- unsigned long flags;
phys_addr_t phys;
- spin_lock_irqsave(&ac->lock, flags);
+ guard(spinlock_irqsave)(&ac->lock);
port = &ac->port[SNDRV_PCM_STREAM_CAPTURE];
if (!port->buf) {
- spin_unlock_irqrestore(&ac->lock, flags);
ret = 0;
goto done;
}
@@ -715,11 +708,9 @@ static int32_t q6asm_stream_callback(struct apr_device *adev,
&port->buf[hdr->token].phys,
done->buf_addr_lsw,
done->buf_addr_msw);
- spin_unlock_irqrestore(&ac->lock, flags);
ret = -EINVAL;
goto done;
}
- spin_unlock_irqrestore(&ac->lock, flags);
}
break;
@@ -1544,14 +1535,12 @@ EXPORT_SYMBOL_GPL(q6asm_write_async);
static void q6asm_reset_buf_state(struct audio_client *ac)
{
struct audio_port_data *port;
- unsigned long flags;
- spin_lock_irqsave(&ac->lock, flags);
+ guard(spinlock_irqsave)(&ac->lock);
port = &ac->port[SNDRV_PCM_STREAM_PLAYBACK];
port->dsp_buf = 0;
port = &ac->port[SNDRV_PCM_STREAM_CAPTURE];
port->dsp_buf = 0;
- spin_unlock_irqrestore(&ac->lock, flags);
}
static int __q6asm_cmd(struct audio_client *ac, uint32_t stream_id, int cmd,
--
2.51.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 12/12] ASoC: qcom: q6asm: Use guard() for spin locks
2025-10-17 8:53 ` [PATCH 12/12] ASoC: qcom: q6asm: " Srinivas Kandagatla
@ 2025-10-19 4:18 ` kernel test robot
2025-10-20 10:29 ` Srinivas Kandagatla
0 siblings, 1 reply; 16+ messages in thread
From: kernel test robot @ 2025-10-19 4:18 UTC (permalink / raw)
To: Srinivas Kandagatla, broonie
Cc: oe-kbuild-all, perex, tiwai, srini, alexey.klimov, linux-sound,
linux-kernel, linux-arm-msm, Srinivas Kandagatla
Hi Srinivas,
kernel test robot noticed the following build errors:
[auto build test ERROR on broonie-sound/for-next]
[also build test ERROR on linus/master v6.18-rc1 next-20251017]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Srinivas-Kandagatla/ASoC-qdsp6-q6asm-do-not-sleep-while-atomic/20251017-170114
base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
patch link: https://lore.kernel.org/r/20251017085307.4325-13-srinivas.kandagatla%40oss.qualcomm.com
patch subject: [PATCH 12/12] ASoC: qcom: q6asm: Use guard() for spin locks
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20251019/202510191117.BTexj8De-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 15.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251019/202510191117.BTexj8De-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202510191117.BTexj8De-lkp@intel.com/
All errors (new ones prefixed by >>):
sound/soc/qcom/qdsp6/q6asm.c: In function 'q6asm_stream_callback':
>> sound/soc/qcom/qdsp6/q6asm.c:687:41: error: 'struct audio_port_data' has no member named 'hw_ptr'
687 | atomic_set(&port->hw_ptr, token + 1);
| ^~
vim +687 sound/soc/qcom/qdsp6/q6asm.c
590
591 static int32_t q6asm_stream_callback(struct apr_device *adev,
592 struct apr_resp_pkt *data,
593 int session_id)
594 {
595 struct q6asm *q6asm = dev_get_drvdata(&adev->dev);
596 struct aprv2_ibasic_rsp_result_t *result;
597 struct apr_hdr *hdr = &data->hdr;
598 struct audio_port_data *port;
599 struct audio_client *ac;
600 uint32_t client_event = 0;
601 int ret = 0;
602
603 ac = q6asm_get_audio_client(q6asm, session_id);
604 if (!ac)/* Audio client might already be freed by now */
605 return 0;
606
607 result = data->payload;
608
609 switch (hdr->opcode) {
610 case APR_BASIC_RSP_RESULT:
611 switch (result->opcode) {
612 case ASM_SESSION_CMD_PAUSE:
613 client_event = ASM_CLIENT_EVENT_CMD_PAUSE_DONE;
614 break;
615 case ASM_SESSION_CMD_SUSPEND:
616 client_event = ASM_CLIENT_EVENT_CMD_SUSPEND_DONE;
617 break;
618 case ASM_STREAM_CMD_FLUSH:
619 client_event = ASM_CLIENT_EVENT_CMD_FLUSH_DONE;
620 break;
621 case ASM_SESSION_CMD_RUN_V2:
622 client_event = ASM_CLIENT_EVENT_CMD_RUN_DONE;
623 break;
624 case ASM_STREAM_CMD_CLOSE:
625 client_event = ASM_CLIENT_EVENT_CMD_CLOSE_DONE;
626 break;
627 case ASM_STREAM_CMD_FLUSH_READBUFS:
628 client_event = ASM_CLIENT_EVENT_CMD_OUT_FLUSH_DONE;
629 break;
630 case ASM_STREAM_CMD_OPEN_WRITE_V3:
631 case ASM_STREAM_CMD_OPEN_READ_V3:
632 case ASM_STREAM_CMD_OPEN_READWRITE_V2:
633 case ASM_STREAM_CMD_SET_ENCDEC_PARAM:
634 case ASM_DATA_CMD_MEDIA_FMT_UPDATE_V2:
635 case ASM_DATA_CMD_REMOVE_INITIAL_SILENCE:
636 case ASM_DATA_CMD_REMOVE_TRAILING_SILENCE:
637 if (result->status != 0) {
638 dev_err(ac->dev,
639 "cmd = 0x%x returned error = 0x%x\n",
640 result->opcode, result->status);
641 ac->result = *result;
642 wake_up(&ac->cmd_wait);
643 ret = 0;
644 goto done;
645 }
646 break;
647 default:
648 dev_err(ac->dev, "command[0x%x] not expecting rsp\n",
649 result->opcode);
650 break;
651 }
652
653 ac->result = *result;
654 wake_up(&ac->cmd_wait);
655
656 if (ac->cb)
657 ac->cb(client_event, hdr->token,
658 data->payload, ac->priv);
659
660 ret = 0;
661 goto done;
662
663 case ASM_DATA_EVENT_WRITE_DONE_V2:
664 client_event = ASM_CLIENT_EVENT_DATA_WRITE_DONE;
665 if (ac->io_mode & ASM_SYNC_IO_MODE) {
666 phys_addr_t phys;
667 int token = hdr->token & ASM_WRITE_TOKEN_MASK;
668
669 guard(spinlock_irqsave)(&ac->lock);
670
671 port = &ac->port[SNDRV_PCM_STREAM_PLAYBACK];
672
673 if (!port->buf) {
674 ret = 0;
675 goto done;
676 }
677
678 phys = port->buf[token].phys;
679
680 if (lower_32_bits(phys) != result->opcode ||
681 upper_32_bits(phys) != result->status) {
682 dev_err(ac->dev, "Expected addr %pa\n",
683 &port->buf[token].phys);
684 ret = -EINVAL;
685 goto done;
686 }
> 687 atomic_set(&port->hw_ptr, token + 1);
688 }
689 break;
690 case ASM_DATA_EVENT_READ_DONE_V2:
691 client_event = ASM_CLIENT_EVENT_DATA_READ_DONE;
692 if (ac->io_mode & ASM_SYNC_IO_MODE) {
693 struct asm_data_cmd_read_v2_done *done = data->payload;
694 phys_addr_t phys;
695
696 guard(spinlock_irqsave)(&ac->lock);
697 port = &ac->port[SNDRV_PCM_STREAM_CAPTURE];
698 if (!port->buf) {
699 ret = 0;
700 goto done;
701 }
702
703 phys = port->buf[hdr->token].phys;
704
705 if (upper_32_bits(phys) != done->buf_addr_msw ||
706 lower_32_bits(phys) != done->buf_addr_lsw) {
707 dev_err(ac->dev, "Expected addr %pa %08x-%08x\n",
708 &port->buf[hdr->token].phys,
709 done->buf_addr_lsw,
710 done->buf_addr_msw);
711 ret = -EINVAL;
712 goto done;
713 }
714 }
715
716 break;
717 case ASM_DATA_EVENT_RENDERED_EOS:
718 client_event = ASM_CLIENT_EVENT_CMD_EOS_DONE;
719 break;
720 }
721
722 if (ac->cb)
723 ac->cb(client_event, hdr->token, data->payload, ac->priv);
724
725 done:
726 kref_put(&ac->refcount, q6asm_audio_client_release);
727 return ret;
728 }
729
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 12/12] ASoC: qcom: q6asm: Use guard() for spin locks
2025-10-19 4:18 ` kernel test robot
@ 2025-10-20 10:29 ` Srinivas Kandagatla
0 siblings, 0 replies; 16+ messages in thread
From: Srinivas Kandagatla @ 2025-10-20 10:29 UTC (permalink / raw)
To: kernel test robot, Srinivas Kandagatla, broonie
Cc: oe-kbuild-all, perex, tiwai, srini, alexey.klimov, linux-sound,
linux-kernel, linux-arm-msm
On 10/19/25 5:18 AM, kernel test robot wrote:
> Hi Srinivas,
>
> kernel test robot noticed the following build errors:
>
> [auto build test ERROR on broonie-sound/for-next]
> [also build test ERROR on linus/master v6.18-rc1 next-20251017]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
>
> url: https://github.com/intel-lab-lkp/linux/commits/Srinivas-Kandagatla/ASoC-qdsp6-q6asm-do-not-sleep-while-atomic/20251017-170114
> base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
> patch link: https://lore.kernel.org/r/20251017085307.4325-13-srinivas.kandagatla%40oss.qualcomm.com
> patch subject: [PATCH 12/12] ASoC: qcom: q6asm: Use guard() for spin locks
> config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20251019/202510191117.BTexj8De-lkp@intel.com/config)
> compiler: m68k-linux-gcc (GCC) 15.1.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251019/202510191117.BTexj8De-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202510191117.BTexj8De-lkp@intel.com/
>
> All errors (new ones prefixed by >>):
>
> sound/soc/qcom/qdsp6/q6asm.c: In function 'q6asm_stream_callback':
>>> sound/soc/qcom/qdsp6/q6asm.c:687:41: error: 'struct audio_port_data' has no member named 'hw_ptr'
> 687 | atomic_set(&port->hw_ptr, token + 1);
> | ^~
>
>
> vim +687 sound/soc/qcom/qdsp6/q6asm.c
>
> 590
> 591 static int32_t q6asm_stream_callback(struct apr_device *adev,
> 592 struct apr_resp_pkt *data,
> 593 int session_id)
> 594 {
> 595 struct q6asm *q6asm = dev_get_drvdata(&adev->dev);
> 596 struct aprv2_ibasic_rsp_result_t *result;
> 597 struct apr_hdr *hdr = &data->hdr;
> 598 struct audio_port_data *port;
> 599 struct audio_client *ac;
> 600 uint32_t client_event = 0;
> 601 int ret = 0;
> 602
> 603 ac = q6asm_get_audio_client(q6asm, session_id);
> 604 if (!ac)/* Audio client might already be freed by now */
> 605 return 0;
> 606
> 607 result = data->payload;
> 608
> 609 switch (hdr->opcode) {
> 610 case APR_BASIC_RSP_RESULT:
> 611 switch (result->opcode) {
> 612 case ASM_SESSION_CMD_PAUSE:
> 613 client_event = ASM_CLIENT_EVENT_CMD_PAUSE_DONE;
> 614 break;
> 615 case ASM_SESSION_CMD_SUSPEND:
> 616 client_event = ASM_CLIENT_EVENT_CMD_SUSPEND_DONE;
> 617 break;
> 618 case ASM_STREAM_CMD_FLUSH:
> 619 client_event = ASM_CLIENT_EVENT_CMD_FLUSH_DONE;
> 620 break;
> 621 case ASM_SESSION_CMD_RUN_V2:
> 622 client_event = ASM_CLIENT_EVENT_CMD_RUN_DONE;
> 623 break;
> 624 case ASM_STREAM_CMD_CLOSE:
> 625 client_event = ASM_CLIENT_EVENT_CMD_CLOSE_DONE;
> 626 break;
> 627 case ASM_STREAM_CMD_FLUSH_READBUFS:
> 628 client_event = ASM_CLIENT_EVENT_CMD_OUT_FLUSH_DONE;
> 629 break;
> 630 case ASM_STREAM_CMD_OPEN_WRITE_V3:
> 631 case ASM_STREAM_CMD_OPEN_READ_V3:
> 632 case ASM_STREAM_CMD_OPEN_READWRITE_V2:
> 633 case ASM_STREAM_CMD_SET_ENCDEC_PARAM:
> 634 case ASM_DATA_CMD_MEDIA_FMT_UPDATE_V2:
> 635 case ASM_DATA_CMD_REMOVE_INITIAL_SILENCE:
> 636 case ASM_DATA_CMD_REMOVE_TRAILING_SILENCE:
> 637 if (result->status != 0) {
> 638 dev_err(ac->dev,
> 639 "cmd = 0x%x returned error = 0x%x\n",
> 640 result->opcode, result->status);
> 641 ac->result = *result;
> 642 wake_up(&ac->cmd_wait);
> 643 ret = 0;
> 644 goto done;
> 645 }
> 646 break;
> 647 default:
> 648 dev_err(ac->dev, "command[0x%x] not expecting rsp\n",
> 649 result->opcode);
> 650 break;
> 651 }
> 652
> 653 ac->result = *result;
> 654 wake_up(&ac->cmd_wait);
> 655
> 656 if (ac->cb)
> 657 ac->cb(client_event, hdr->token,
> 658 data->payload, ac->priv);
> 659
> 660 ret = 0;
> 661 goto done;
> 662
> 663 case ASM_DATA_EVENT_WRITE_DONE_V2:
> 664 client_event = ASM_CLIENT_EVENT_DATA_WRITE_DONE;
> 665 if (ac->io_mode & ASM_SYNC_IO_MODE) {
> 666 phys_addr_t phys;
> 667 int token = hdr->token & ASM_WRITE_TOKEN_MASK;
> 668
> 669 guard(spinlock_irqsave)(&ac->lock);
> 670
> 671 port = &ac->port[SNDRV_PCM_STREAM_PLAYBACK];
> 672
> 673 if (!port->buf) {
> 674 ret = 0;
> 675 goto done;
> 676 }
> 677
> 678 phys = port->buf[token].phys;
> 679
> 680 if (lower_32_bits(phys) != result->opcode ||
> 681 upper_32_bits(phys) != result->status) {
> 682 dev_err(ac->dev, "Expected addr %pa\n",
> 683 &port->buf[token].phys);
> 684 ret = -EINVAL;
> 685 goto done;
> 686 }
> > 687 atomic_set(&port->hw_ptr, token + 1);
Ah.. looks like left over from adsp patches
will remove this and send a v2.
--srini> 688 }
> 689 break;
> 690 case ASM_DATA_EVENT_READ_DONE_V2:
> 691 client_event = ASM_CLIENT_EVENT_DATA_READ_DONE;
> 692 if (ac->io_mode & ASM_SYNC_IO_MODE) {
> 693 struct asm_data_cmd_read_v2_done *done = data->payload;
> 694 phys_addr_t phys;
> 695
> 696 guard(spinlock_irqsave)(&ac->lock);
> 697 port = &ac->port[SNDRV_PCM_STREAM_CAPTURE];
> 698 if (!port->buf) {
> 699 ret = 0;
> 700 goto done;
> 701 }
> 702
> 703 phys = port->buf[hdr->token].phys;
> 704
> 705 if (upper_32_bits(phys) != done->buf_addr_msw ||
> 706 lower_32_bits(phys) != done->buf_addr_lsw) {
> 707 dev_err(ac->dev, "Expected addr %pa %08x-%08x\n",
> 708 &port->buf[hdr->token].phys,
> 709 done->buf_addr_lsw,
> 710 done->buf_addr_msw);
> 711 ret = -EINVAL;
> 712 goto done;
> 713 }
> 714 }
> 715
> 716 break;
> 717 case ASM_DATA_EVENT_RENDERED_EOS:
> 718 client_event = ASM_CLIENT_EVENT_CMD_EOS_DONE;
> 719 break;
> 720 }
> 721
> 722 if (ac->cb)
> 723 ac->cb(client_event, hdr->token, data->payload, ac->priv);
> 724
> 725 done:
> 726 kref_put(&ac->refcount, q6asm_audio_client_release);
> 727 return ret;
> 728 }
> 729
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: (subset) [PATCH 00/12] ASoC: qcom: q6dsp: few cleanups
2025-10-17 8:52 [PATCH 00/12] ASoC: qcom: q6dsp: few cleanups Srinivas Kandagatla
` (11 preceding siblings ...)
2025-10-17 8:53 ` [PATCH 12/12] ASoC: qcom: q6asm: " Srinivas Kandagatla
@ 2025-10-21 11:37 ` Mark Brown
12 siblings, 0 replies; 16+ messages in thread
From: Mark Brown @ 2025-10-21 11:37 UTC (permalink / raw)
To: Srinivas Kandagatla
Cc: perex, tiwai, srini, alexey.klimov, linux-sound, linux-kernel,
linux-arm-msm
On Fri, 17 Oct 2025 09:52:55 +0100, Srinivas Kandagatla wrote:
> This patchset does 3 things.
> - simplify code via __free(kfree) mechanism.
> - use spinlock guards
> - few cleanups discovered during doing above 2.
>
> No functional changes
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[01/12] ASoC: qdsp6: q6asm: do not sleep while atomic
commit: fdbb53d318aa94a094434e5f226617f0eb1e8f22
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
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2025-10-21 11:37 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-17 8:52 [PATCH 00/12] ASoC: qcom: q6dsp: few cleanups Srinivas Kandagatla
2025-10-17 8:52 ` [PATCH 01/12] ASoC: qdsp6: q6asm: do not sleep while atomic Srinivas Kandagatla
2025-10-17 8:52 ` [PATCH 02/12] ASoc: qcom: audioreach: remove unused variables Srinivas Kandagatla
2025-10-17 8:52 ` [PATCH 03/12] ASoc: qcom: audioreach: Use automatic cleanup of kfree() Srinivas Kandagatla
2025-10-17 8:52 ` [PATCH 04/12] ASoc: qcom: q6adm: " Srinivas Kandagatla
2025-10-17 8:53 ` [PATCH 05/12] ASoc: qcom: q6afe: " Srinivas Kandagatla
2025-10-17 8:53 ` [PATCH 06/12] ASoc: qcom: q6apm: " Srinivas Kandagatla
2025-10-17 8:53 ` [PATCH 07/12] ASoc: qcom: q6prm: " Srinivas Kandagatla
2025-10-17 8:53 ` [PATCH 08/12] ASoc: qcom: q6asm: " Srinivas Kandagatla
2025-10-17 8:53 ` [PATCH 09/12] ASoC: qcom: q6afe: Use guard() for spin locks Srinivas Kandagatla
2025-10-17 8:53 ` [PATCH 10/12] ASoC: qcom: q6apm-dai: " Srinivas Kandagatla
2025-10-17 8:53 ` [PATCH 11/12] ASoC: qcom: q6asm-dai: " Srinivas Kandagatla
2025-10-17 8:53 ` [PATCH 12/12] ASoC: qcom: q6asm: " Srinivas Kandagatla
2025-10-19 4:18 ` kernel test robot
2025-10-20 10:29 ` Srinivas Kandagatla
2025-10-21 11:37 ` (subset) [PATCH 00/12] ASoC: qcom: q6dsp: few cleanups Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox