From nobody Sun Apr 5 18:33:18 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 CA94E3845C7 for ; Mon, 23 Mar 2026 22:39:18 +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=1774305561; cv=none; b=ZEb7uKDddsH0mWe6fcgF8T1yBgo3hZT3PNkyanLA8XzV0vVpijkQPfScYF43XloUBdsZ24iOBWCM3ohvLsQwOd3YWjVeNsBGaZa3aR9qNIhSd58ha+zLMqNsqb2SPW7iFQ9LhODokITzsdgrRQwwdiOiqrlWbTEuBsLE237bOSI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774305561; c=relaxed/simple; bh=PuJFamBh81bE/Zj8ZHvJy/U5gL5zjKCwi4dfSJ851vE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZSzr5qq63BulQAsjHiqpFu5koFb+KvisLV2s9dtfnarmilikWKS5247cTQEgT7oWq8LUg2ijapvMR7p1GmhfwUBjhGTaDTAHWsRGrTwuBVqfE51pwm16XUWwJTq43VZNA3mc3RxUl0iSBB9dbHqX1jv1KMH96n2fKpZuc4sAUOg= 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=k8uoxNSM; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=QWX8KDpc; 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="k8uoxNSM"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="QWX8KDpc" Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62NHqjI42681214 for ; Mon, 23 Mar 2026 22:39:18 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=k8uoxNSMU7vahl7ty1y7PsIVjy0 bUz8emvwcfiiy5VJ4nUMIG4yQzzVW+D0yl5PYy5SbBrNrCd/2NbG7ZYCg59Purdz 4+oxrhwTjp1UR8cQ+/h3DefyKriagCORWUsDjt0JcAiE/BvL506weLWq6R5Umj27 uw2msCxcVLtQP7w5D0G1DBiAi15QYZ2d0dutZt92gPTFp85JJPLSIdIWUOv9LrJc 3e/5+5CBKj7ZXxfHgH7oIFbs2LDAYppONCNaQ8G+XUX72LTOegJ08YCU4e6tzQO5 reMAL7DykwnCDpOrYuJaqgM+trdgdql5X26TKrsbk79R280V4x3i0Y6k4fA== Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4d31p7axrb-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 23 Mar 2026 22:39:17 +0000 (GMT) Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-5090bc4823cso167388141cf.3 for ; Mon, 23 Mar 2026 15:39:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1774305557; x=1774910357; 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=QWX8KDpc9x5c7/eM4/cDxHAaybH1LB2qDpAc1/Fw69mIQ6wTWWm9WGJu6cZgwT4bim DlESHwTWO/PXxq7Jk969bHP2Psn1GqDG/oHuo+ohNstf8JOOtHsi7OYSsu1yN0EBguST KhexXU67mvoQrThM8vESp1cqZRzieaQNDTmiPR6+S9sdpJaXLzCgM6n4eXnFOW3HYj5T Mehjigwbe8DKox7DVJ32Za/4zNaluyr76XTcEqfaFoxGJeowjAUQ7uaF2XXQg2zT0KM9 mxBqJ9yXMs/dEHkDpw1+krAEO1MuJaFvsvct8vdjJhI2glqPvVeGL52qY6VyDr3isG61 zYIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774305557; x=1774910357; 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=fbyfB3qjuqZVtol4MpBMImtKQcOlfWEpi83qoGW4VaNyy970ApC7nkYwh0S3NfcU7v 0vpOyMaX2jxhw8Awd4Jh0CrRpw4RpIjOUfpa5MO5lkZzP+9MTtQp52zwze6SpgB2U89H 3Pxp5/dHkkdRPr4E58Qz+ZEEbOkZz4S2MXsLbaexxe7+KyxsjNqobhOSfOIWtr8z1aBT FKmKkWqfVFdLeWu91VXpw/1TvWFIu3mHEfOOBQB4K0wntaaSdN/HPyqodvm5jFyQbh/5 g0fbvvzpvLerKsYYjZ+S3vE98ViNp/IJeb1ZdkieUWHzfbkh4VCgTsSt8DqVYPHOsjUJ gFjg== X-Forwarded-Encrypted: i=1; AJvYcCX1nRYePJUlAG4fzLrutb9qgHL0bKv8F6MUoLIXnxBSNv0E6iWvZShK7mmlOg5I/m3OkrZCv9ZIKpxZSC4=@vger.kernel.org X-Gm-Message-State: AOJu0YzLMUoLtnqAMdySXPsNMoePmRP32HiLObC4yEP+lljE8JeQJZjw lRaTvCqOfHjlgRE4B1eRHZAQpAPG9OMy2+g9B5A0lp1Y8fxqTcTdvde4B3rWvaqwAeU9+m/EjFy 9FLwjyvOb8nudD0VrlnxHQNa8rRJ6OJOqWX+4ePQTugMI5+wGbcua3ewz0MYpDEHlHaE= X-Gm-Gg: ATEYQzxfhu0XaJfAX4ICMlgfzliFiyaapgVKgYyqQTHqEoYlWz/Ol1Z2PT1J++des4A gw/S+rtn84bOdQMW/by/VeQ2PBWnWHaueynbvnPZ27Tgs+57G06Ur6Vz8Nmx1nzYAQ7m5r0ZLaM 2sVu0wZmvkWmruz5CcPlEuu32nnbvxUEwZleISNcU/c8lJtNk1OtW7z1f/DbkmxEOtVXNkvfmhm 9JSdJBTVSCxiIsth3RCpqrtU3+/wIV+kmgJaelESrJhMoce8lHBjcPI//DEB7fWs+Yb1n+tPHHS FHHNp7YhoDj0qEDEFCq49lDH8K5N9tFIl2p8jP+KnBnam0j9A/lbMsE0ssJxjVEf7F+xVVF7Xaz OUAmEUBI3P3UZPbXPmS90NJjJB6hEKxQsd5v62OvMnblCCg89cW6x0lg= X-Received: by 2002:a05:622a:1391:b0:50b:1e5d:9930 with SMTP id d75a77b69052e-50b375a89acmr211411271cf.58.1774305557248; Mon, 23 Mar 2026 15:39:17 -0700 (PDT) X-Received: by 2002:a05:622a:1391:b0:50b:1e5d:9930 with SMTP id d75a77b69052e-50b375a89acmr211411001cf.58.1774305556758; Mon, 23 Mar 2026 15:39:16 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43b64715539sm33320351f8f.33.2026.03.23.15.39.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2026 15:39:15 -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 v7 12/13] ASoC: qcom: qdsp6: remove search for module iid in hot path Date: Mon, 23 Mar 2026 22:38:44 +0000 Message-ID: <20260323223845.2126142-13-srinivas.kandagatla@oss.qualcomm.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260323223845.2126142-1-srinivas.kandagatla@oss.qualcomm.com> References: <20260323223845.2126142-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-Authority-Analysis: v=2.4 cv=RMC+3oi+ c=1 sm=1 tr=0 ts=69c1c115 cx=c_pps a=WeENfcodrlLV9YRTxbY/uA==:117 a=ZsC4DHZuhs/kKio7QBcDoQ==:17 a=Yq5XynenixoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=rJkE3RaqiGZ5pbrm-msn:22 a=EUspDBNiAAAA:8 a=Ll4dbTg5roZnn8cDlSAA:9 a=kacYvNCVWA4VmyqE58fU:22 X-Proofpoint-ORIG-GUID: 6Aexn4OGd_dUzDIF-wYt0f0dWYNYyFOO X-Proofpoint-GUID: 6Aexn4OGd_dUzDIF-wYt0f0dWYNYyFOO X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzIzMDE2NyBTYWx0ZWRfX3rIGxMO10pJd GAu7antNYNyYKdDs1w/6PWOWOfxuCRgcIUclVTHhk+sqHhn+Xj5rHksqItpc5HjkLbAIdks1aS4 kYLimvMDJ6/OldM9h2ePEmaz1JH7NkvMbwSYHbcn1G/YfjMPjSw/mx2AFR4NWxfe/dQohvkKnlK L0e69kfVKIlrZTJxqsbzWRnETbnuIHoLddX84jC90FLPHcbfX9EYn/dx2kMeoYgFTrc7Ry7Om0x 2js8C7g1ywA0wlurvEYp+RH3XpOdPRNvCwOjvjeVePAPf24gS9P3mCu8EAjvbP7QHN83N3MebRy Opy3nWnj6dM3CxhOKf9kVafx4KfbgT73/7JlKYfFl8Uu4mNCZDAakbhquye+05g15jHYEwFfRqG oIbL81SfxumAMNir2WTJTkmVNGQGRsSfGWx1QureFrFqIL3/CiAxUoQm3c1CfGMlzYcKFw+Awag YEKyOQFb0s1XuJ3CwMw== 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-23_06,2026-03-23_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 phishscore=0 lowpriorityscore=0 impostorscore=0 priorityscore=1501 bulkscore=0 spamscore=0 adultscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603230167 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