From nobody Mon Apr 6 09:13:44 2026 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EDCE23CE4BD for ; Fri, 20 Mar 2026 14:49:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774018187; cv=none; b=Cn/Y7gvukg9PrqZ3FbbbG7tvYJSssPz8GfPX5RTPOsyLjQs38nUee+FZfKFbdTSW5f4pnqJHPjmpb6yftpH8IJAnzeff15qiGN8PsPn7/Cp17z1LkPD27Z1vfqkiz61pMHrav3KSyQtx1VCRt3PpQNUSB17t+GtYJWWx9E1blHY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774018187; c=relaxed/simple; bh=PuJFamBh81bE/Zj8ZHvJy/U5gL5zjKCwi4dfSJ851vE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FFXtR/doB9FXUZl+62l0ZJna4O1JWAy5MpOrs9LSi7IreN79K4Zf8TG3LvYyfn/3EvP4aTkMHTM60Eqqu2QcAdnVzN+QSw9p+Leg0y+BX9yPBkbJ23a/a46fDKkhtqhEmQA31Krr9nqNHIlwDzh5xgI2Uua2OfJNaHaJviH97zk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=PIf+Gxh6; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=eTO1L5oB; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="PIf+Gxh6"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="eTO1L5oB" Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62KEgwi43557797 for ; Fri, 20 Mar 2026 14:49:45 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=fSPCBd3T5A0 bZHkS+KsyEWqVlhqEkiuzb7wl/h6xEi0=; b=PIf+Gxh6gReVtKCx/XaMei+cyOk LJsr9T65zMiFuTVilv11nxNflIQB/S+xoMTnH1s7SVGLjvv3pEJ0qpcOcLoXJjrp ozt1eDEWaS4ciOIIvE5YtmS4ENiTpoLHVYhYg3/ruZfV1NCBVeth3pwjhLty9elm 2lPhfd9tdN/+89mJOBlQSJh/nnDCXIncEDp2LgDDDhggrJ3YH/oHjn5treRfyFkq XU8p/X1iWkv60/w6p7sDkcFpfNzeAw7XIzmTVekPdUZMjilEydb1QX8SOeMM9Ib8 ZL4aFqcBzigQgDGknyXijPoDlfjbGEsdBjkE9gSequHbyxivfF2PbWb3eLA== Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4d0r1gtfph-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 20 Mar 2026 14:49:44 +0000 (GMT) Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-50925fed647so153626941cf.3 for ; Fri, 20 Mar 2026 07:49:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1774018184; x=1774622984; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fSPCBd3T5A0bZHkS+KsyEWqVlhqEkiuzb7wl/h6xEi0=; b=eTO1L5oBU5VlS79m9WxCcqTnF45y6Gbg5a0cQdSECq3ZX8pbyUq7dXFjdex6KG1ylP 9NkJwf2ADxz119p2W419UhevvX1TelcIcz70tXrBiYZtmvR71YSE0tzk7z7HnZn/wLdS KumlYylQTm6aMKpjzixDf24SaJU9AiOVgWc1gRpNkFE/Yj83Jij8ajro+d9ridXkZ1Da fPApmAAA7Z/2kyp6/jqkGvfhwoEgIRjzdhZc9N+KEmK33F29PwM84oikr3lsIzIuP8pC BzsJJ7roRwNPpamPgftDZELqktn4ep0dj1rXtHp4n0JwWjkIxui69c7dWNyra+8goMqO O6Zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774018184; x=1774622984; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=fSPCBd3T5A0bZHkS+KsyEWqVlhqEkiuzb7wl/h6xEi0=; b=LU7OveWbD5ZyFbYNamebbHG/OUqsCPnEhyOjEGmuZSkuP0BYhX+RG85V3E6l/co8Av B1sgzKZ7IQO7mbI08sVGRI3/hmyHMge14E/SThXTdZckrM8RzVK/tV1qGZ6PXtelMPUD funePTd2eE1BXhiKJbVI1E606hPFUUtmtmDP876OsOY/M0LbETSGdgUqsIqTwSd4VYk4 9SDMA84dGjCbhzm44+7SXQnrCdHrzHOxd/DBDDFPt2tvoYlfYdaOBmvEqkUWYl74IXNG RRwDuaGdi2k+ViiKa/jFwVdRCK33YSSPlkQu1fWM3xkKzIANbx2sD2A1eqSJ9PGtcdRm 4JDQ== X-Forwarded-Encrypted: i=1; AJvYcCWpxuWkxEwlwOJgOxjrQP8GpyMMYRd5Hd8KgS9MI2F9BZIaCxrMfsQol/f8NzOGDzeQjFsb8ewda0A2MrU=@vger.kernel.org X-Gm-Message-State: AOJu0YzjVOQgeGjTgBmC7yY8jH+cy3SDa5aQsIQLwmIzE1Yf4PlyuAaT Z4HFWq2HeBAW5J5mPP6eWXIMD4usJd/Ka86cMUmXAIY1NhVdA5czsGoTmYfUEScC3a6bCLYxIJn JtoGxjgZQmy/KP0y5ma8Dx3gsKLs43GfrehVU71lz2oHk3H5tx74xpQs+6ND0j0tv4xE= X-Gm-Gg: ATEYQzwi25bQNfsvigqU3lrwgi2KR9cKuavAqiLdGfp1yZKg2gchsoUuBb+hFc9pEIk Ne5PQjLGOMjVm1FTuX9TIQau6e21kW8bBh6NwSwAa+AqDn8eUJen8yh/fR3/0GgekjiiW6BTGC0 UxsOBFydNUwbOhgKu3wF5VRbvT9xwrHxwulmZTsrvSNNET+UCbwT22gAVYHaDQaWDtoVnD336zY SySsXYSYk7c2SpVxZyxD+TwzTNonlSUZ+UO9p0rYkiL8/lgWo+L4MYp0qktTqGVgEo/Qjq7gQtF IzK30zmm9kW0xmo+t0uzR7HKjaSV7uzKXkniI8F7yig+/KTGHFtRWPT/9N3sOCio0RlU4NBHpNw pnqlOvdtWtwEQsojF/DmLHSxwhBHvw9x5TLNxILBfBTmg7PqpDxdFNyk= X-Received: by 2002:ac8:5a8b:0:b0:509:2997:b929 with SMTP id d75a77b69052e-50b375b02ccmr43326061cf.67.1774018184275; Fri, 20 Mar 2026 07:49:44 -0700 (PDT) X-Received: by 2002:ac8:5a8b:0:b0:509:2997:b929 with SMTP id d75a77b69052e-50b375b02ccmr43325601cf.67.1774018183772; Fri, 20 Mar 2026 07:49:43 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-486ff109b95sm47906825e9.1.2026.03.20.07.49.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Mar 2026 07:49:42 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org Cc: mohammad.rafi.shaik@oss.qualcomm.com, linux-sound@vger.kernel.org, lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com, johan@kernel.org, dmitry.baryshkov@oss.qualcomm.com, konrad.dybcio@oss.qualcomm.com, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, srini@kernel.org, val@packett.cool, mailingradian@gmail.com, Srinivas Kandagatla Subject: [PATCH v6 12/13] ASoC: qcom: qdsp6: remove search for module iid in hot path Date: Fri, 20 Mar 2026 14:49:17 +0000 Message-ID: <20260320144918.1685838-13-srinivas.kandagatla@oss.qualcomm.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260320144918.1685838-1-srinivas.kandagatla@oss.qualcomm.com> References: <20260320144918.1685838-1-srinivas.kandagatla@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzIwMDExOCBTYWx0ZWRfX10+xv+nOlh1P n/2Htbl2ZiJ6VUeUnoQOzrM6DKxYf6K+fD42fOmLpn6Km7YCaAfYxel0CaAGgBty6oK926f5Wkb scB4Kv70RREm36d68js7S3OdfYFStjxnVGAfFlDDYNdloDx9/dZcnUjOXzuafQQyPtH7Cv7xtOP zeqiVca0HLcZMv5UHJJG9uCvcz1Nd9/yZwgMbrht956s6QlBgvT4yvkh7WmsvszbuMzd+riGaYs +F7RZx1rBqmzYTDl7OdXHXpEbQAzth/UY6kquR8XuwJGRQ5HD1iRKIE4C8NG6i+YKNbn7UDWo4y tcTbdZaO2HbPrQKhhDhtyeP2pzupCuef/FFIwPKdicugIG7tbnTxh9WOTdaibS6QwQX6k5Gjl9p vwf9EbHq4NbagN2ihsn2ufzvu0NS+LDVrM/C7NTeKdolHWRdOkKV8sTO41JMREEM29davQ+VuwI MQTZM2j3AVBKP8ERFig== X-Proofpoint-GUID: 6Jn13TO1sBoe7EwfIv2UNZ0tPo6fWd7l X-Proofpoint-ORIG-GUID: 6Jn13TO1sBoe7EwfIv2UNZ0tPo6fWd7l X-Authority-Analysis: v=2.4 cv=Y/D1cxeN c=1 sm=1 tr=0 ts=69bd5e88 cx=c_pps a=JbAStetqSzwMeJznSMzCyw==:117 a=ZsC4DHZuhs/kKio7QBcDoQ==:17 a=Yq5XynenixoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=ZpdpYltYx_vBUK5n70dp:22 a=EUspDBNiAAAA:8 a=Ll4dbTg5roZnn8cDlSAA:9 a=uxP6HrT_eTzRwkO_Te1X:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-20_02,2026-03-19_05,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 spamscore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 phishscore=0 bulkscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603200118 Content-Type: text/plain; charset="utf-8" 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 --- sound/soc/qcom/qdsp6/q6apm-dai.c | 5 +++-- sound/soc/qcom/qdsp6/q6apm-lpass-dais.c | 4 ++-- sound/soc/qcom/qdsp6/q6apm.c | 14 +++++++++----- sound/soc/qcom/qdsp6/q6apm.h | 3 ++- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/sound/soc/qcom/qdsp6/q6apm-dai.c b/sound/soc/qcom/qdsp6/q6apm-= dai.c index 292be457764f..86d6438bd9fd 100644 --- a/sound/soc/qcom/qdsp6/q6apm-dai.c +++ b/sound/soc/qcom/qdsp6/q6apm-dai.c @@ -355,7 +355,7 @@ static int q6apm_dai_open(struct snd_soc_component *com= ponent, =20 spin_lock_init(&prtd->lock); prtd->substream =3D substream; - prtd->graph =3D q6apm_graph_open(dev, event_handler, prtd, graph_id); + prtd->graph =3D q6apm_graph_open(dev, event_handler, prtd, graph_id, subs= tream->stream); if (IS_ERR(prtd->graph)) { dev_err(dev, "%s: Could not allocate memory\n", __func__); ret =3D PTR_ERR(prtd->graph); @@ -496,7 +496,8 @@ static int q6apm_dai_compr_open(struct snd_soc_componen= t *component, return -ENOMEM; =20 prtd->cstream =3D stream; - prtd->graph =3D q6apm_graph_open(dev, event_handler_compr, prtd, graph_id= ); + prtd->graph =3D q6apm_graph_open(dev, event_handler_compr, prtd, graph_id, + SNDRV_PCM_STREAM_PLAYBACK); if (IS_ERR(prtd->graph)) { ret =3D PTR_ERR(prtd->graph); kfree(prtd); diff --git a/sound/soc/qcom/qdsp6/q6apm-lpass-dais.c b/sound/soc/qcom/qdsp6= /q6apm-lpass-dais.c index e904066484d5..006b283484d9 100644 --- a/sound/soc/qcom/qdsp6/q6apm-lpass-dais.c +++ b/sound/soc/qcom/qdsp6/q6apm-lpass-dais.c @@ -203,7 +203,7 @@ static int q6apm_lpass_dai_prepare(struct snd_pcm_subst= ream *substream, struct s * graph, so sequence for playback and capture will be different */ if (substream->stream =3D=3D SNDRV_PCM_STREAM_PLAYBACK && dai_data->graph= [dai->id] =3D=3D NULL) { - graph =3D q6apm_graph_open(dai->dev, NULL, dai->dev, graph_id); + graph =3D 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 =3D PTR_ERR(graph); @@ -240,7 +240,7 @@ static int q6apm_lpass_dai_startup(struct snd_pcm_subst= ream *substream, struct s int graph_id =3D dai->id; =20 if (substream->stream =3D=3D SNDRV_PCM_STREAM_CAPTURE) { - graph =3D q6apm_graph_open(dai->dev, NULL, dai->dev, graph_id); + graph =3D 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); diff --git a/sound/soc/qcom/qdsp6/q6apm.c b/sound/soc/qcom/qdsp6/q6apm.c index 9d4cbe29cf94..c874dae53163 100644 --- a/sound/soc/qcom/qdsp6/q6apm.c +++ b/sound/soc/qcom/qdsp6/q6apm.c @@ -411,12 +411,11 @@ int q6apm_write_async(struct q6apm_graph *graph, uint= 32_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 =3D q6apm_graph_get_rx_shmem_module_iid(graph); =20 struct gpr_pkt *pkt __free(kfree) =3D 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); =20 @@ -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 =3D q6apm_graph_get_tx_shmem_module_iid(graph); =20 struct gpr_pkt *pkt __free(kfree) =3D audioreach_alloc_pkt(sizeof(*read_b= uffer), 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); =20 @@ -604,7 +602,7 @@ static int graph_callback(const struct gpr_resp_pkt *da= ta, void *priv, int op) } =20 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 =3D dev_get_drvdata(dev->parent); struct audioreach_graph *ar_graph; @@ -631,6 +629,12 @@ struct q6apm_graph *q6apm_graph_open(struct device *de= v, q6apm_cb cb, graph->id =3D ar_graph->id; graph->dev =3D dev; =20 + if (dir =3D=3D SNDRV_PCM_STREAM_PLAYBACK) + graph->shm_iid =3D q6apm_graph_get_rx_shmem_module_iid(graph); + else + graph->shm_iid =3D q6apm_graph_get_tx_shmem_module_iid(graph); + + mutex_init(&graph->lock); init_waitqueue_head(&graph->cmd_wait); =20 diff --git a/sound/soc/qcom/qdsp6/q6apm.h b/sound/soc/qcom/qdsp6/q6apm.h index 5cf538397841..7c646ffcf956 100644 --- a/sound/soc/qcom/qdsp6/q6apm.h +++ b/sound/soc/qcom/qdsp6/q6apm.h @@ -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 { =20 /* 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); --=20 2.47.3