Unverified Commit d8b41630 authored by Srinivas Kandagatla's avatar Srinivas Kandagatla Committed by Mark Brown
Browse files

ASoC: qcom: qdsp6: remove search for module iid in hot path



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: default avatarSrinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
Link: https://patch.msgid.link/20260402081118.348071-13-srinivas.kandagatla@oss.qualcomm.com


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent b54a38af
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -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);
+2 −2
Original line number Diff line number Diff line
@@ -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);
+9 −5
Original line number Diff line number Diff line
@@ -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);

+2 −1
Original line number Diff line number Diff line
@@ -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);