]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ASoC: qcom: qdsp6: remove search for module iid in hot path
authorSrinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
Thu, 2 Apr 2026 08:11:17 +0000 (08:11 +0000)
committerMark Brown <broonie@kernel.org>
Thu, 2 Apr 2026 15:33:48 +0000 (16:33 +0100)
Remove searching for Shared Memory module instance id on every
read/write call, this is un-necessary if we can cache the shared
memory module instance id per PCM graph.

Add new member to graph struct to store shared memory module
instance id to avoid searching for this in hot path.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
Link: https://patch.msgid.link/20260402081118.348071-13-srinivas.kandagatla@oss.qualcomm.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/qcom/qdsp6/q6apm-dai.c
sound/soc/qcom/qdsp6/q6apm-lpass-dais.c
sound/soc/qcom/qdsp6/q6apm.c
sound/soc/qcom/qdsp6/q6apm.h

index 292be457764f6fb82f9893875babb702da63a59d..86d6438bd9fd6eb374d12e5436d80a5fe0743315 100644 (file)
@@ -355,7 +355,7 @@ static int q6apm_dai_open(struct snd_soc_component *component,
 
        spin_lock_init(&prtd->lock);
        prtd->substream = substream;
-       prtd->graph = q6apm_graph_open(dev, event_handler, prtd, graph_id);
+       prtd->graph = q6apm_graph_open(dev, event_handler, prtd, graph_id, substream->stream);
        if (IS_ERR(prtd->graph)) {
                dev_err(dev, "%s: Could not allocate memory\n", __func__);
                ret = PTR_ERR(prtd->graph);
@@ -496,7 +496,8 @@ static int q6apm_dai_compr_open(struct snd_soc_component *component,
                return -ENOMEM;
 
        prtd->cstream = stream;
-       prtd->graph = q6apm_graph_open(dev, event_handler_compr, prtd, graph_id);
+       prtd->graph = q6apm_graph_open(dev, event_handler_compr, prtd, graph_id,
+                                       SNDRV_PCM_STREAM_PLAYBACK);
        if (IS_ERR(prtd->graph)) {
                ret = PTR_ERR(prtd->graph);
                kfree(prtd);
index e904066484d5cf0e6ed0cd12733866e5824d6263..006b283484d9e978a6352a5097ac53ff1f49c38e 100644 (file)
@@ -203,7 +203,7 @@ static int q6apm_lpass_dai_prepare(struct snd_pcm_substream *substream, struct s
         * graph, so sequence for playback and capture will be different
         */
        if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && dai_data->graph[dai->id] == NULL) {
-               graph = q6apm_graph_open(dai->dev, NULL, dai->dev, graph_id);
+               graph = q6apm_graph_open(dai->dev, NULL, dai->dev, graph_id, substream->stream);
                if (IS_ERR(graph)) {
                        dev_err(dai->dev, "Failed to open graph (%d)\n", graph_id);
                        rc = PTR_ERR(graph);
@@ -240,7 +240,7 @@ static int q6apm_lpass_dai_startup(struct snd_pcm_substream *substream, struct s
        int graph_id = dai->id;
 
        if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
-               graph = q6apm_graph_open(dai->dev, NULL, dai->dev, graph_id);
+               graph = q6apm_graph_open(dai->dev, NULL, dai->dev, graph_id, substream->stream);
                if (IS_ERR(graph)) {
                        dev_err(dai->dev, "Failed to open graph (%d)\n", graph_id);
                        return PTR_ERR(graph);
index 5751e80b3b9289b87d743617c758a92cb44f327b..6a3942a1ed283ffa6cf54dffdcfdad2966348967 100644 (file)
@@ -411,12 +411,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;
-       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);
+                                       graph->port->id, graph->shm_iid);
        if (IS_ERR(pkt))
                return PTR_ERR(pkt);
 
@@ -449,11 +448,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;
-       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);
+                                       graph->tx_data.dsp_buf, graph->port->id, graph->shm_iid);
        if (IS_ERR(pkt))
                return PTR_ERR(pkt);
 
@@ -604,7 +602,7 @@ static int graph_callback(const struct gpr_resp_pkt *data, void *priv, int op)
 }
 
 struct q6apm_graph *q6apm_graph_open(struct device *dev, q6apm_cb cb,
-                                    void *priv, int graph_id)
+                                    void *priv, int graph_id, int dir)
 {
        struct q6apm *apm = dev_get_drvdata(dev->parent);
        struct audioreach_graph *ar_graph;
@@ -631,6 +629,12 @@ struct q6apm_graph *q6apm_graph_open(struct device *dev, q6apm_cb cb,
        graph->id = ar_graph->id;
        graph->dev = dev;
 
+       if (dir == SNDRV_PCM_STREAM_PLAYBACK)
+               graph->shm_iid = q6apm_graph_get_rx_shmem_module_iid(graph);
+       else
+               graph->shm_iid = q6apm_graph_get_tx_shmem_module_iid(graph);
+
+
        mutex_init(&graph->lock);
        init_waitqueue_head(&graph->cmd_wait);
 
index 5cf538397841a7fdbace6fea6b02c8fd3a5230c4..7c646ffcf956fd4e12470c158a9ad4372ad54e34 100644 (file)
@@ -99,6 +99,7 @@ struct q6apm_graph {
        void *priv;
        q6apm_cb cb;
        uint32_t id;
+       uint32_t shm_iid;
        struct device *dev;
        struct q6apm *apm;
        gpr_port_t *port;
@@ -113,7 +114,7 @@ struct q6apm_graph {
 
 /* Graph Operations */
 struct q6apm_graph *q6apm_graph_open(struct device *dev, q6apm_cb cb,
-                                    void *priv, int graph_id);
+                                    void *priv, int graph_id, int dir);
 int q6apm_graph_close(struct q6apm_graph *graph);
 int q6apm_graph_prepare(struct q6apm_graph *graph);
 int q6apm_graph_start(struct q6apm_graph *graph);