From nobody Wed Jun 10 08:23:10 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 5FDA23F1AC5 for ; Tue, 19 May 2026 13:15:33 +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=1779196534; cv=none; b=fNxNWWT6W5EDO1rXMebeMyry9PS/OhSMVcN+jXYbSLfgUfxKoz0iaJaxZ2fHSz1IR1PPRZaH/EdTm6K2Xy6cW9OYdfmVvMKATZiT2n1nD8H23Dcy6+451XIomfreLSVHoSiqq0ql242lmO6N1y84GpaSeeq9bCuJqjM5w8CLYFM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779196534; c=relaxed/simple; bh=K/hVO6qPHgKUGTSudx4uDg+YCovP5hpQlsKCypYbQ1U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Om/y9a/sYCuqPLt8HI98MKdkLevHOzeX9aXbDDoryFV10jVq7MNFBkP+3WE8t5l2isgacca/vEI/i+dPRFKOjp+rB5SII2tJvSeuEv+/KRkvQ3YRfjcsXPbvWCKfebc/pAZgiY09+1NBq/A3O2Ne6pUdVxU7mTVm8nrhnAMLD7Y= 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=f1ON02rr; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=ckIh+6Ew; 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="f1ON02rr"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="ckIh+6Ew" 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 64J9ll1E254433 for ; Tue, 19 May 2026 13:15:32 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=0yq9S2r8Arp oCxn5kQzyttucSExAujLx06AGO3snZjs=; b=f1ON02rrSqP7FX1ciEogJIv0IJr CfSiJD3jynepNykVBF3YxXnoGnqybrL9coIsHPE2/kzbRNI7OGzL6DP6o4VSWWuR 0QmUZrYOFeaOiJ4qZ5bGYv2F+j70VFDRMymkYvfJ3+UBF6maFsMe1jgX5OK0m8xW f40gTmvfhxUGGbmAzMJzU+Gy4DryRvPw9oVxN8qebXs6ZKQW52WXndF7rTVf3RZZ Bi2kQLGvlL0OgfGXKjGZ80qbc+yHhutZ/H23l4BmSZncnI8T9pEqdNiO6w7Px2CB tbCT1ywTZlUlRc/8ZUBJaT0PmDNxQlFOEwkP5A6K5v9VdHMg0NB2M1EPQMg== Received: from mail-ua1-f69.google.com (mail-ua1-f69.google.com [209.85.222.69]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4e8h87t114-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 19 May 2026 13:15:32 +0000 (GMT) Received: by mail-ua1-f69.google.com with SMTP id a1e0cc1a2514c-95fc647f356so5866717241.3 for ; Tue, 19 May 2026 06:15:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1779196532; x=1779801332; 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=0yq9S2r8ArpoCxn5kQzyttucSExAujLx06AGO3snZjs=; b=ckIh+6Ewx/l6PToOr5Aa367R5k8BReAF8p2itYQq1oYxRdhxEVmeuti/bmXWVVOKcS Qlg5bxpOs+kF7UKrPwSyc5fGhVcWhF91VObzId/pliANQTTmMEtpseHNmUgYnD5qX51R wttNEqoF/rXcx58IeFEYoh+AOAf+qoEmhVhRdOTzbqtoqtTKUNSbmQKdP//RX+IYsGFv lDzcmFAkJ9L6zfkQi7LdstA2zIyy8ejWWWKhjiEFIvbEqE8SdKHtPo74VNzDbMxlJxZi u+cNm5mkhj534ru35Gc0TpqUeXKLYjhAInfBRlt0uGAfEWHT3gRPTCjB/dK+8d+xi7NY yHqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779196532; x=1779801332; 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=0yq9S2r8ArpoCxn5kQzyttucSExAujLx06AGO3snZjs=; b=VPrriMdSGqs8t9acDF9nrgzxcA+dEvoB8YJ/Xl8Me9Xt1eFkiiXF/+czjKvFIXTll9 AIQcERAYODsxpeyH0krndoJ50KyCbvuOzyNSmkrH5CUVoHPLrqsNivcABoESbMIUfGO6 IZEL30IN6RcCR/ZkwapAKaOqW1i/JkRvgt/u+BaHTwVsRQEApM5Og22cClI4NH2LE1xL KNZjBwOhbpSMW6/Z2l3yi22bgOGehpUX/vroheVAtH15yltvXg4OxEsqLkyMhfhIw2Ab CjFhgngm97fbAkemChXq3hlnRsxOUqlJk6PIKc5yuuVn2VmlMFyDCjmmrC7z+MaDvGE1 tO/w== X-Forwarded-Encrypted: i=1; AFNElJ9cTlQhkKSbP3Y+OZdF/8G5AAUKHsFl5sqZJv6ybEryIN6G+EYMgsRyEXn0iYnm4xTxDSRmtxhgcfOq/7g=@vger.kernel.org X-Gm-Message-State: AOJu0YxHhJJ1FnJVFTUz1kU+uqzbAuEugTyUmdR/IJTbzlQRGEAHGKfw kH9v4NzVglRzgNxqXnmi6liiq+RoKJz63F0j8FirvMuiCQyXdCt0izkokEIOYWZJ12y+VIwY8YL KlXKyeMJmUEK53KneWwa7KhlbR8XqiXBbpsEtgAIdxmHTPgRsGPzAnkIZw48d4OxL7o4= X-Gm-Gg: Acq92OGaV6pnXmUXfCuUUTKJ/G14NIkrNhIiKHxGm6Td1cWCPOjtNhFcS5oezMn05Ro x5JJhz0vd5wVnjyBL0hZJGKuyT2WXFXOBylxksNv1Ja59+sS7pugibPEilXbW+r99yxAcRCrBvz 17nI934TMvR89cKKle9HLOnzjCbTsHztO/4oUss63cuim0D00jugZOL/TdZVGZ5G7A1bhgr0TS7 OIXg11BwRW2tOn9gQCSUBW+s510o8tMwhSBbPwZoBN0llH1zT4eDVcrwVChW3JuN1WgYWS5fU8n Hpx4/5dIeADa62WDS7TeBFuVN12JNDhgXL0OjryyiVQJKzq9RNyvWuq3VSKGKKVmeNgcOr/d3FX g4qP0g6zGRnTiPMbVrQoOby0e+H4O4s5dsbI2mlx07W69k7dgnayVywQ= X-Received: by 2002:a05:6122:4d0d:b0:56e:e80c:bb25 with SMTP id 71dfb90a1353d-5760c0a673cmr10979868e0c.13.1779196531860; Tue, 19 May 2026 06:15:31 -0700 (PDT) X-Received: by 2002:a05:6122:4d0d:b0:56e:e80c:bb25 with SMTP id 71dfb90a1353d-5760c0a673cmr10979779e0c.13.1779196531415; Tue, 19 May 2026 06:15:31 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45da0a1aeafsm48018609f8f.23.2026.05.19.06.15.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2026 06:15:30 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: srini@kernel.org, lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com, krzysztof.kozlowski@oss.qualcomm.com, mohammad.rafi.shaik@oss.qualcomm.com, alexey.klimov@linaro.org, ravi.hothi@oss.qualcomm.com, mathieu.poirier@linaro.org, verhaegen@google.com, andersson@kernel.org, linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH 1/6] ASoC: qcom: audioreach: use cached shared memory module IID Date: Tue, 19 May 2026 13:15:22 +0000 Message-ID: <20260519131527.4002526-2-srinivas.kandagatla@oss.qualcomm.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260519131527.4002526-1-srinivas.kandagatla@oss.qualcomm.com> References: <20260519131527.4002526-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-GUID: anVlHrAt1A8SH_K_uFhDXEM56YzKNB_N X-Proofpoint-ORIG-GUID: anVlHrAt1A8SH_K_uFhDXEM56YzKNB_N X-Authority-Analysis: v=2.4 cv=a9sAM0SF c=1 sm=1 tr=0 ts=6a0c6274 cx=c_pps a=UbhLPJ621ZpgOD2l3yZY1w==:117 a=ZsC4DHZuhs/kKio7QBcDoQ==:17 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=rJkE3RaqiGZ5pbrm-msn:22 a=EUspDBNiAAAA:8 a=IKYrml1x1okdUiGWNaYA:9 a=TOPH6uDL9cOC6tEoww4z:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTE5MDEzMSBTYWx0ZWRfX1u9lRkBTQtjb 5rdl6UdUw8Ho0uFsueORpsoX1i9QA5POXON75qHgconwGMcvN3Pl+v3Sh8o12mc/IPB7nsxEpI4 b6PPdGn6YxIOgK4hb90TuIAQeZSZM4dFneCCTWvRXv8YbMZjybxfxayx7V2Z6q0/NE5MrF5QVXv 5tah5y9kR6q2Xfbju/61uEQE464NMEfUObvLYS0RLjhiTb7CrrHp6+hMgUBU8BvWX20yU0toFW1 vp0oC/SiiNMA5gICfleL1XeQkHt6AKHx/WCix7LcuIVX4TYGYQUZz3zp9zlA8bc8cApjSUtrdo9 +B+NXAratk+EOe4aDPx8V84YFXXZht4iP7qGVkq77glW/hnVbS85jKWKvL+obsK5VdXudiZJTty QdD59P/HnTnEZPMnEwW2SjaX4TkVJ8q3lXdy8jU2pVtQxgB12xLDfvoUFfI4uT0ct9zwRhQHEVY h+SbPyJlvE6lSRhQTqg== 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-05-19_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 priorityscore=1501 impostorscore=0 adultscore=0 clxscore=1015 lowpriorityscore=0 bulkscore=0 suspectscore=0 spamscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605190131 Content-Type: text/plain; charset="utf-8" audioreach currently calls q6apm_graph_get_rx_shmem_module_iid() to get the shared memory module IID. The graph already caches this value in graph->shm_iid, so use it directly in audioreach_compr_set_param() and audioreach_shared_memory_send_eos(). This prepares for removing the helper in a later patch. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/qdsp6/audioreach.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audio= reach.c index a13f753eff98..5b73f1d81c9b 100644 --- a/sound/soc/qcom/qdsp6/audioreach.c +++ b/sound/soc/qcom/qdsp6/audioreach.c @@ -955,7 +955,7 @@ int audioreach_compr_set_param(struct q6apm_graph *grap= h, struct media_format *header; int rc; void *p; - int iid =3D q6apm_graph_get_rx_shmem_module_iid(graph); + int iid =3D graph->shm_iid; int payload_size =3D sizeof(struct apm_sh_module_media_fmt_cmd); =20 struct gpr_pkt *pkt __free(kfree) =3D audioreach_alloc_cmd_pkt(payload_si= ze, @@ -1404,7 +1404,7 @@ EXPORT_SYMBOL_GPL(audioreach_graph_free_buf); int audioreach_shared_memory_send_eos(struct q6apm_graph *graph) { struct data_cmd_wr_sh_mem_ep_eos *eos; - int iid =3D q6apm_graph_get_rx_shmem_module_iid(graph); + int iid =3D graph->shm_iid; struct gpr_pkt *pkt __free(kfree) =3D audioreach_alloc_cmd_pkt(sizeof(*eo= s), DATA_CMD_WR_SH_MEM_EP_EOS, 0, graph->port->id, iid); if (IS_ERR(pkt)) --=20 2.47.3 From nobody Wed Jun 10 08:23:10 2026 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.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 C99604DD6E7 for ; Tue, 19 May 2026 13:15:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779196536; cv=none; b=aHUUIdhViYTKQ+KD33VP5e9vDbhKJh9ym+W+W8ZD1yoedvs9T/NAL/HRjcL/oH0bGDO8rPlZmBPOrH6KcxlZPyNg6whYOcRnS2kvtmDWOsCnqmlhyRCHosfgHjugCCFSwjSbiQPmUCQzrcefzv2Qbmwp4HDmLR9STu2Q5FqROPg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779196536; c=relaxed/simple; bh=oN4YAwisdhuOOBqKPXKvtfaC8/IwBvjgjFO5k7lYNDc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ad8wG3Ujyy2IXftP5a7axf0TJ/rhfacuDY2MMHI8T1C6WqT0vHhc0VGzCutVfse9eKVFILrO7ZzxAkG8/JxsVpsjU7rC/QsrzCDzsPE90MXl23uKSH/opjtOBgJZU481NX2ikbC4bLXdDiOJMLE0oX5BIlSn6SgMrOIMtEv8Mac= 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=ONO5jxmN; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=CEkL3+go; arc=none smtp.client-ip=205.220.168.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="ONO5jxmN"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="CEkL3+go" Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64J7qhfG2975772 for ; Tue, 19 May 2026 13:15:34 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=iT2sk4+d3te ABIp894CGle6jPBeXLUcSVA+RvxJ/hQA=; b=ONO5jxmNXuqKjsEVdNjC9qMlaDd W9Bd4bzGElJdm6Y4O86fYKm/UpxZYIdtNyhl8G0B4p7xStVPqQgYSoQxAYwb5ZUk 2Zl6Rkjadn3RHt7gA1PayyXH2Ov7ZEcK/Am83+8I7q8NDI0a1oozdV77nDb2q1bc L0Asd31Hv6u39WF77DM6bUA4zxa1J7fUPylIGiUwxp0LQsOKGW4A0Choe7uErx+b O9QoN050qOt+AyKz6Wy/HKli9NxC+OIgE4ZpxSDMejQTKgCTbsCS9jdB2zlvMYyN XlaHsrvI1fEl9ii0d2IwqP/2JHcEHXBLdEZQFy/KIvrKyoqfL+AVBrTi2VQ== Received: from mail-vk1-f199.google.com (mail-vk1-f199.google.com [209.85.221.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4e84v4cme9-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 19 May 2026 13:15:34 +0000 (GMT) Received: by mail-vk1-f199.google.com with SMTP id 71dfb90a1353d-56fab6d9242so9649884e0c.0 for ; Tue, 19 May 2026 06:15:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1779196533; x=1779801333; 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=iT2sk4+d3teABIp894CGle6jPBeXLUcSVA+RvxJ/hQA=; b=CEkL3+goNCFTG9Es5YHJ1KyS9Prq4+k6BOeY0mHvE4YcwBqpljsKyMTl7bNwvZVhzX Rud5diX4rPVBDxkhEhA87jahyDwzIa4KkbhLkZmytE42skWEBjSjcGT3Y7CsRfZTFhpf YU+RNmkuUzfaeiA7JiouwVCOJz1P9utDaRT2W5dElvhV6+1uXLGREMdtXORpMNZOOCSl 6/kSnu1sRJRFm5FM8xMr+dF5Wjr5AQNjVTqe2JSQ6S01j3PL5xkNwnupece3H+us/8Wc A1LUCGf0P4RKOIYmfJf2U81ACJtez0Dur0J14tHpZnRmOPvIjVyS4VE9sq536gSinfc6 tDPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779196533; x=1779801333; 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=iT2sk4+d3teABIp894CGle6jPBeXLUcSVA+RvxJ/hQA=; b=Vdu7R8GniJwrz5aRC50pML6lCztb59hDks7oJcQmjEP+b/ebpU6+//TtZywpdnA0iX SvITWEt1wox2ZV61yIQZC118dlD8BlM3QpdUJ7vJ50871hzDEfR9P1IxEsPANPsqrp65 0gK+0pJMh5CkIwRtOaIjRh67T3wFdXr5ic7S4nmZb01JHGoTmnnfzBc7K9vOMW0BtvgN 0wwPJALAw+84VA3PfrGS7enSZLWKz/ZrWI4Z7n08rsfRXRMDfN/RCRHAFRmDFqyfAwUk lCJpgnh3yEXZk5p+HVXxrimrWcJgNy6Usyzy+1TvOIx6F2jKLYNAk8caUJ+RcZujmt4Z 3DKw== X-Forwarded-Encrypted: i=1; AFNElJ9xHv2SavYu3VcSD4SC2erlBlTID8j5m5iWStF55pcgxv5DQXVZ2dJqdV8hXSE8PO7Y31OuXF9mEJEY+q4=@vger.kernel.org X-Gm-Message-State: AOJu0YyPMo2VaL0Ha1sH1HRJtpgj5PMcxwKPIdrso6Ebms5LCvVYICDB LOabjYRMF9GydIVFNI9Z/Z6jFAifUpWOpweLqZ4PTIkWQ0q+l5TStvcVsRBKHV2dTVlVYwvB8BB II3uyXNkrugfLZLzPdXVFuqdBYGlFheqy9pfXiGybVY0q0D4sdNVZJZAkiAVA7/K6q00= X-Gm-Gg: Acq92OEAdgDEx0uBHctxXJxUSwD6cf9mryQdYTfpEbQM2MWmMRqCEHjC5mVe/hExaUx I5DQ/P3ofE1aduGOjZzlU+cS2xG0PiJb4dF+RsWbbQwAVgD9jc67O5ojgKhzGIa9b8+zSJRaMMC kDtwan+4c9IzFyCgBPhGtUk8AePUsiHbNdpA2EVmqbOyCe1GNhPR1863r9lDSx5J24IT+R2CG8c Sjp4hSJPlKcyoCVpS4l4SVH7VSm8RimA8hWZWT3/dRULCOAQiWeC5EDbgTEpdkgAN2fudWcDcCW d9NYRz2mzGgarEmfVXAbERUqncqv0Ty+okRDX41/4kM9a2y6YXs1GZWNyn/b7u6daLcqBIFGjkG 0xZ50rGYZVRisDX21ZZrVLQo/GUIDFkOofYPhCSJO2F5kX57VNhBzCgwaP2KDdXWQhw== X-Received: by 2002:a05:6122:d1e:b0:575:27de:3eab with SMTP id 71dfb90a1353d-5760c057c54mr11756778e0c.9.1779196533164; Tue, 19 May 2026 06:15:33 -0700 (PDT) X-Received: by 2002:a05:6122:d1e:b0:575:27de:3eab with SMTP id 71dfb90a1353d-5760c057c54mr11756699e0c.9.1779196532737; Tue, 19 May 2026 06:15:32 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45da0a1aeafsm48018609f8f.23.2026.05.19.06.15.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2026 06:15:32 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: srini@kernel.org, lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com, krzysztof.kozlowski@oss.qualcomm.com, mohammad.rafi.shaik@oss.qualcomm.com, alexey.klimov@linaro.org, ravi.hothi@oss.qualcomm.com, mathieu.poirier@linaro.org, verhaegen@google.com, andersson@kernel.org, linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH 2/6] ASoC: qcom: q6apm: return error code to consumers on failures Date: Tue, 19 May 2026 13:15:23 +0000 Message-ID: <20260519131527.4002526-3-srinivas.kandagatla@oss.qualcomm.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260519131527.4002526-1-srinivas.kandagatla@oss.qualcomm.com> References: <20260519131527.4002526-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=VJPtWdPX c=1 sm=1 tr=0 ts=6a0c6276 cx=c_pps a=+D9SDfe9YZWTjADjLiQY5g==:117 a=ZsC4DHZuhs/kKio7QBcDoQ==:17 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=DJpcGTmdVt4CTyJn9g5Z:22 a=EUspDBNiAAAA:8 a=Kj_hsjq-VXR9WAeqRSUA:9 a=vmgOmaN-Xu0dpDh8OwbV:22 X-Proofpoint-ORIG-GUID: 2Ea5wRLFVeb7_oUhp9cFwhkSc8xjgIpG X-Proofpoint-GUID: 2Ea5wRLFVeb7_oUhp9cFwhkSc8xjgIpG X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTE5MDEzMSBTYWx0ZWRfX1c8cllihJ5SL XvlEmgXoDa+MvmNYAUbFxdZUu0n1IEqND6PmkKv8iC/vHsW/lF7qJNjYUBv53KR4wo6EhD0T0hB knJ/P7bkN3r/gVYT4Rbhfij1s76u1mV8Fkh2Hz3jFceVEg30NP5FMOvkO9yzkc9e9ZaZqz+Hotj bvf6j4hlkdGy0sV3LksFC4k70rFFgDIeXYH+b+JsZJ5v0ZEGMoIOqxDE6IRyOsfGC2t4sqF4H8e SzQ2FpQoGA52d4zkhQ1AP/uErzjueVBQ0B2VZabLYHOOdyoePx5pyFrusPOP+TeRryHhMsXLn7q urfJARQVb8rPFiJBQ6wum/+/1/ifSin4n5qj6LE8DdGuAaDRvZ2MlzIAEU11g7YhF3yLa/fqSUg O2e/91WKQMdokuftQnOqDGRneykr9402oPayoKbvb0PLYj8Lwj2vItGBCGVFRcBZrMAacFQo/Ja qB8ZO1sL2TtKJnLs81Q== 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-05-19_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 adultscore=0 malwarescore=0 bulkscore=0 spamscore=0 suspectscore=0 lowpriorityscore=0 clxscore=1015 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605190131 Content-Type: text/plain; charset="utf-8" Return errors from audioreach_set_media_format() to ensure callers are notified when media format setup fails. This could hide failures while programming media format parameters for individual modules and allow graph setup to continue with incomplete configuration. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/qdsp6/q6apm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sound/soc/qcom/qdsp6/q6apm.c b/sound/soc/qcom/qdsp6/q6apm.c index 2ab378fb5032..2cebeb767cd6 100644 --- a/sound/soc/qcom/qdsp6/q6apm.c +++ b/sound/soc/qcom/qdsp6/q6apm.c @@ -194,10 +194,7 @@ int q6apm_graph_media_format_shmem(struct q6apm_graph = *graph, if (!module) return -ENODEV; =20 - audioreach_set_media_format(graph, module, cfg); - - return 0; - + return audioreach_set_media_format(graph, module, cfg); } EXPORT_SYMBOL_GPL(q6apm_graph_media_format_shmem); =20 @@ -399,6 +396,7 @@ int q6apm_graph_media_format_pcm(struct q6apm_graph *gr= aph, struct audioreach_mo struct audioreach_sub_graph *sgs; struct audioreach_container *container; struct audioreach_module *module; + int ret; =20 list_for_each_entry(sgs, &info->sg_list, node) { list_for_each_entry(container, &sgs->container_list, node) { @@ -407,7 +405,9 @@ int q6apm_graph_media_format_pcm(struct q6apm_graph *gr= aph, struct audioreach_mo (module->module_id =3D=3D MODULE_ID_RD_SHARED_MEM_EP)) continue; =20 - audioreach_set_media_format(graph, module, cfg); + ret =3D audioreach_set_media_format(graph, module, cfg); + if (ret) + return ret; } } } --=20 2.47.3 From nobody Wed Jun 10 08:23:10 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 329364DC546 for ; Tue, 19 May 2026 13:15:36 +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=1779196541; cv=none; b=JE6hFB9OvU/+wEf5mFU78+KJ0UBxnwhPB8sDDnvyPt794KSIlZxWkkwASeWCOpFcS0lBikKQIcfuMSpfbbBsEPCAWkEYyJyO3HOeHgcWK0cgSt8ZOpDBG+JcEi7eQ+/GbccOUNdJOlNHtEFlUelLe08y/wg7Sbt5mh9Ppq0Wmi0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779196541; c=relaxed/simple; bh=xzzL21LQ0JUCoqtli3nm8gu0EEyFSRN9RZAEojxLUxw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jEgQGy8Mrg7JFuNXdIoOqwOONqHmSdsSrN03Gtimpwg6x4Pjim9fXbDEH9pvUTH7KJcRgbp7+hS+7PB2EHl3Wo8pYS3n1tPp+IVTN8h1BJbHCWbY6+AJkJyQQUVCDHNBGtj/0DjKJGrSCXY1I/AiEJl8rp2VM2/gWD3xNdGg0bc= 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=CO/S+5jR; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=FKIxdPnt; 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="CO/S+5jR"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="FKIxdPnt" Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64JA386l1393051 for ; Tue, 19 May 2026 13:15:35 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=mYev7kpgqkN DdJjz3ITaD4t3ttI5h9By3yLE/B2VHDM=; b=CO/S+5jRfpwx/lp2O9gCt+uvZJD BtLpcrtr1Byt6F8ZzWsThSMkDg2ZfvJ2qC+stzldEy9OQABssEqdojyo/vgJHj8a JopoydrrWfs2U9cBTL0qLX0BJIAUqlj6sTFg3Lnm7yJMLvA7YSu/W+wlT85SSxdc DtCIWvPs7GD3Hk16bdW4NZECstf/o+uK/lZGTa49ufQ7f/5Mk7vddNUWrssLzqU2 LTrYCwA2Whp8ycw1ShA0veCwgeiuHA9OC6EFuIIQvNiwsa05qDzeMc3fL9qcEko4 xe6VbSbebiBUxMEVqsu6TzJ2oSpdT0IuCxINe0ALzw0qkkMCZ4JI6MnoaUw== Received: from mail-vk1-f198.google.com (mail-vk1-f198.google.com [209.85.221.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4e8ns48px4-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 19 May 2026 13:15:35 +0000 (GMT) Received: by mail-vk1-f198.google.com with SMTP id 71dfb90a1353d-575242b4308so9409848e0c.1 for ; Tue, 19 May 2026 06:15:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1779196534; x=1779801334; 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=mYev7kpgqkNDdJjz3ITaD4t3ttI5h9By3yLE/B2VHDM=; b=FKIxdPnt2AxaTKEl8PfBKNSrMH262uW3dYOVepLd7Q5Rc1dFDzbDOt8Gs4j48McnUo uZ3sch1AAm4j2gpQ/OPgaELAmx9MREj3Hs20zjrr2ZRpXDCzgvHOaeemK+2bJz3jyfBN 6uc/UloxEG5ns00AgsXI9ZQhq2v0EIS3xWDxkYxG08WnIuaRsV4ERZaAH8+SmEl5QreM LtoQWz4sK2Ka/nQLE6WpBqiVYvBf6zNAy7hkjtdOz4XLLfIEkONM/UoKV2aqpZ5oCg5C FcAYujF9FGqRnXm+8Y23oKygum3wk6X86qkLF75dZ/addxBNuMxsI/XncdmdCnHMynfH mzSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779196534; x=1779801334; 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=mYev7kpgqkNDdJjz3ITaD4t3ttI5h9By3yLE/B2VHDM=; b=JvbXeKufoLCt0IKkT0No8OBDWgshBj0XG8IFMWkOZinJkc9GEdFVzoDyZlTwFH5+7w WzWIY/p2jKmkbYaY0E4WRMAsAHnp4CeiY6eYE7EaVWFzIC4VqlK+/2ywhTH/rWIaV0RX GJugTYhYxGUfwhjyXKauGveL7gGqfbz0uxLsCCBL70Ghq4ZoibwdNOVPI1mk5GlTEWql MWfyEmLd4mnFEZLoPxSjdWbvALPhIBdbZJrYn3o3C8abv0CTl6hkCgjPOtTjTpISStXH gfrQtHFPGYrrinMjfnjhFE7CRbZEylRsmKYkOdBp11xb7QulRbkA9X4mhdjbspyLvKRw WR5g== X-Forwarded-Encrypted: i=1; AFNElJ9ySxH1LkhrmSd++WZjkSmd6m3mP9+H0BiBH91q27qIKcP+Aa4rXBu99uJ2zjnN6nQEddQfJbnWt9LrpqY=@vger.kernel.org X-Gm-Message-State: AOJu0YwAGOnrBTP1bfiiP8zbzyBQnUZCif1Xx+XowrMUtuwHHbIFE6Xj GyObI4n18UUoqKPPxVl8IlhKP3lKXOHh8OaZvrk3n/ZD54B7oV0E2fahhB/0cMzwxMowqG9UxV8 u+fEUUWJpTEe1TGC1C0StZDPnja8tQtWVlqC7/Dk9e6SptduXEWqSW64ipmwzqBomFhg= X-Gm-Gg: Acq92OHLg4nXaTe4uakrc4e3vbl+dp6S2+VelkkvxV5ebxGIHIM6Q5ayN4jtl/Zjt2I 0AElHdWu/IgILGs/2lfPG8FfX5xhqdUWiZX8O6x0VLcekW4zxKsAcqI5Fhp7B1STx3lZs/lMt1Y Zip83ScMnqyvjpE6KMKJSNUB0Rr+zlrRJSj/91d89xTNoSZiFDWNx5wdPGRFypw8cnqdC3/OB2P dHifdCUh/zyuH/jlDoX9RalhVxdOGKjo3Da/OIKDO4VDtt8M7E7ciBy6lS67U6cAv84uk1/0BWF hZLop4kJHMWj379ZsbeBCMBHkfD/eRzzlOUklbVLS7qRc0IJ0lJuF0xAbZ2FZO07ZK3a5IxBAWF Z1ZzNlIee2qG5om3Us39fXSV9l2dFcX5bCVQU1DAzEUfZEpn6mtX+xOg= X-Received: by 2002:a05:6122:6b8e:10b0:577:51e4:ef20 with SMTP id 71dfb90a1353d-57751e4f011mr3849582e0c.10.1779196534540; Tue, 19 May 2026 06:15:34 -0700 (PDT) X-Received: by 2002:a05:6122:6b8e:10b0:577:51e4:ef20 with SMTP id 71dfb90a1353d-57751e4f011mr3849493e0c.10.1779196534073; Tue, 19 May 2026 06:15:34 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45da0a1aeafsm48018609f8f.23.2026.05.19.06.15.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2026 06:15:33 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: srini@kernel.org, lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com, krzysztof.kozlowski@oss.qualcomm.com, mohammad.rafi.shaik@oss.qualcomm.com, alexey.klimov@linaro.org, ravi.hothi@oss.qualcomm.com, mathieu.poirier@linaro.org, verhaegen@google.com, andersson@kernel.org, linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH 3/6] ASoC: qcom: q6apm: remove shared memory IID helpers Date: Tue, 19 May 2026 13:15:24 +0000 Message-ID: <20260519131527.4002526-4-srinivas.kandagatla@oss.qualcomm.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260519131527.4002526-1-srinivas.kandagatla@oss.qualcomm.com> References: <20260519131527.4002526-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: AW1haW4tMjYwNTE5MDEzMSBTYWx0ZWRfX3+pMz/XFpD53 GyvgOg1PfYhgmaop8cSU6ezWQwhX3Hue3kZHHh76gxrWBvrqP/bZQJh6gM8c9yTtmzOc3Ja/miK STc7bM/ld6XogYClHz6bTRhNVlFi3Bc4W80/9ZQEVhTC1ZSnfvvvwPOlZyvRNLpx7FYY3Ixept5 sC2AuWn/ITo+z9IVsope5SDYpzGhO4Qyoth5QnwLKauYlNT2m4rpJyhFr9GLCNiEf7lPt113Wio fKk7oiF/pY9qPB6tD8MYH2pG+hSIaznmGOdZY+BKcv0U9yip6hcG1fzPikfkXCIzFxK5xTJ3D7j cfb+fmAolxkaDIAsDsNQWwKjJ0a7dj7vpWL911pdqUv+GJNvnMWBFYcZkaGClzwH79ccylPL+GB AseZS/TzkC7KVLWJgQBvb8urG/zfbZI7Qvl7jWJqkOCPk3DF+OvpelYODrteMvxUhJyt2syK/66 SJkBHliH2HD8k2zjfEQ== X-Authority-Analysis: v=2.4 cv=F6dnsKhN c=1 sm=1 tr=0 ts=6a0c6277 cx=c_pps a=1Os3MKEOqt8YzSjcPV0cFA==:117 a=ZsC4DHZuhs/kKio7QBcDoQ==:17 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=3WHJM1ZQz_JShphwDgj5:22 a=EUspDBNiAAAA:8 a=j5C22CDG7AQ3G0DocvUA:9 a=hhpmQAJR8DioWGSBphRh:22 X-Proofpoint-GUID: sFPbIBu7SIl1Et-Ev8GWduExTTT6BESk X-Proofpoint-ORIG-GUID: sFPbIBu7SIl1Et-Ev8GWduExTTT6BESk 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-05-19_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 adultscore=0 bulkscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 phishscore=0 clxscore=1015 impostorscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605190131 Content-Type: text/plain; charset="utf-8" The shared memory module instance ID is now cached in graph->shm_iid when the graph is opened. The old WR/RD shared memory IID helper functions are no longer used. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/qdsp6/q6apm.c | 41 ++++++++++++------------------------ sound/soc/qcom/qdsp6/q6apm.h | 2 -- 2 files changed, 14 insertions(+), 29 deletions(-) diff --git a/sound/soc/qcom/qdsp6/q6apm.c b/sound/soc/qcom/qdsp6/q6apm.c index 2cebeb767cd6..6ae7d1645dce 100644 --- a/sound/soc/qcom/qdsp6/q6apm.c +++ b/sound/soc/qcom/qdsp6/q6apm.c @@ -417,31 +417,6 @@ int q6apm_graph_media_format_pcm(struct q6apm_graph *g= raph, struct audioreach_mo } EXPORT_SYMBOL_GPL(q6apm_graph_media_format_pcm); =20 -static int q6apm_graph_get_tx_shmem_module_iid(struct q6apm_graph *graph) -{ - struct audioreach_module *module; - - module =3D q6apm_find_module_by_mid(graph, MODULE_ID_RD_SHARED_MEM_EP); - if (!module) - return -ENODEV; - - return module->instance_id; - -} - -int q6apm_graph_get_rx_shmem_module_iid(struct q6apm_graph *graph) -{ - struct audioreach_module *module; - - module =3D q6apm_find_module_by_mid(graph, MODULE_ID_WR_SHARED_MEM_EP); - if (!module) - return -ENODEV; - - return module->instance_id; - -} -EXPORT_SYMBOL_GPL(q6apm_graph_get_rx_shmem_module_iid); - int q6apm_write_async(struct q6apm_graph *graph, uint32_t len, uint32_t ms= w_ts, uint32_t lsw_ts, uint32_t wflags) { @@ -614,6 +589,18 @@ static int graph_callback(const struct gpr_resp_pkt *d= ata, void *priv, int op) return 0; } =20 +static int q6apm_graph_get_module_iid(struct q6apm_graph *graph, uint32_t = mid) +{ + struct audioreach_module *module; + + module =3D q6apm_find_module_by_mid(graph, mid); + if (!module) + return -ENODEV; + + return module->instance_id; + +} + struct q6apm_graph *q6apm_graph_open(struct device *dev, q6apm_cb cb, void *priv, int graph_id, int dir) { @@ -643,9 +630,9 @@ struct q6apm_graph *q6apm_graph_open(struct device *dev= , q6apm_cb cb, 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); + graph->shm_iid =3D q6apm_graph_get_module_iid(graph, MODULE_ID_WR_SHARED= _MEM_EP); else - graph->shm_iid =3D q6apm_graph_get_tx_shmem_module_iid(graph); + graph->shm_iid =3D q6apm_graph_get_module_iid(graph, MODULE_ID_RD_SHARED= _MEM_EP); =20 =20 mutex_init(&graph->lock); diff --git a/sound/soc/qcom/qdsp6/q6apm.h b/sound/soc/qcom/qdsp6/q6apm.h index 376a36700c53..8ea64085860f 100644 --- a/sound/soc/qcom/qdsp6/q6apm.h +++ b/sound/soc/qcom/qdsp6/q6apm.h @@ -148,8 +148,6 @@ int q6apm_send_cmd_sync(struct q6apm *apm, const struct= gpr_pkt *pkt, /* Callback for graph specific */ struct audioreach_module *q6apm_find_module_by_mid(struct q6apm_graph *gra= ph, uint32_t mid); -int q6apm_graph_get_rx_shmem_module_iid(struct q6apm_graph *graph); - bool q6apm_is_adsp_ready(void); =20 int q6apm_enable_compress_module(struct device *dev, struct q6apm_graph *g= raph, bool en); --=20 2.47.3 From nobody Wed Jun 10 08:23:10 2026 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.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 058484DD6EC for ; Tue, 19 May 2026 13:15:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779196543; cv=none; b=vGpXnFXnKVVRRraTZ5F95MhriieE2WanDBu4RyoCbTdbCRMBL68l1i9EzSFhE6TTNEQvLLK7Vv+v8ax8oMtD6bIeenfbtZpidn7FJ2vvZEDm6RFXJIvbCbL4gdEZDGpH/oVz1E4PV6do9JQjP8j7T+XfGPnxox2bpW6TG3C04uo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779196543; c=relaxed/simple; bh=BTj2KL+dLb4ULPkUGDrOO4gjDvy9oKLU6oqhZSB3bqQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=guzQMextEXktvui5SKaInX69HeCoG5xZ2EismmlKrTKBFRKPelWlUKP6SOFAObSqQEaG0fxBahTjuXwq1RrMUClcF8fLRRs0o45enYS1PjjL5M8nB5shDDccivoQHeGBqbFc/TqYdhHpL80urYBNhtA6YHbR7T6zy73r7B+xC+o= 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=FBxxob1d; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=M1ghoson; arc=none smtp.client-ip=205.220.168.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="FBxxob1d"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="M1ghoson" Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64J7jZEP1146359 for ; Tue, 19 May 2026 13:15:37 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=lumGDobfStR XGabvnziVfxbEzSmJpltC0nS/hMOdM+k=; b=FBxxob1dyg8PzHlLChWpH0OBp1C 1YVB1Khdbnr3gdA1IGaSzDeZoGTm8ahca0/B9BTYFeZ29JeQEWLIIrxgvog9FheY 46u6EX7W+G52ShbWQ7kB7dBFjw5I1ytrpZGGFTtWRkvaJjbSfHkrBnKaYM/OZt4X UQVWbzYqPWCqztQy9rJeUMTfMf+KwRLkFz2UZtYoJjVXM3zV/NOurMP6NSNo8k42 4B6NBCrxwrs+VwYFspW9EkMBmcdpOWWfyy2Yn8aAzAi1jNd4DfoobJC64VynA9fX ftMYuUDIoLUID9NXCk2ksmelsc0/6DNTWMP4yWRWzO0otqQiEb5JAYw1HIw== Received: from mail-vk1-f199.google.com (mail-vk1-f199.google.com [209.85.221.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4e8e7ejmj5-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 19 May 2026 13:15:37 +0000 (GMT) Received: by mail-vk1-f199.google.com with SMTP id 71dfb90a1353d-57524a62f0dso9051473e0c.0 for ; Tue, 19 May 2026 06:15:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1779196536; x=1779801336; 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=lumGDobfStRXGabvnziVfxbEzSmJpltC0nS/hMOdM+k=; b=M1ghosonigvvQL5zwf/GbKtsfQzS0wVSpW+L4ZH9mV3YqktUvUJF+rwt0P8rxz/4Hd 8pgyLotIu9DCATw/I9IFKBue+eKTe/HfQqp8ylwLA9Lhe+AWzwEI8JCq1BM0CWsd2zbn e5rsiaETgrbRcrpcJdNNkHslxygJuxkXM47Wekco3diXt8wapDxc2vIilYKZqek0yRbY su+j6Bd+yyN1GdUxKyfli1TF8BSZMAPHqBwIYOeOow3XBlPmhb4LEAgsqqePH9ltwV0w D5ZsjSqTHLrlFYduRuT4u22Rg7eUERtsFuPA8+MXef4WAqyDDX+0XyERH2WsVwhBRbFJ hEVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779196536; x=1779801336; 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=lumGDobfStRXGabvnziVfxbEzSmJpltC0nS/hMOdM+k=; b=HiwZXjHdAvCyCD0iVWMu5mkyBPEt633FAO2bywTmwFgn8uNOCURBldXabklJFKkGua ANnIY0rQzcUvnnjB4ZRMAztg3v5KfCkfRDnH09IpoTzTR1FICaEAaMh825WZ4XX8E6s+ uPaUjYHcTKP2mdeLAPwZYt2Ep52gjpT/YxQZ5oQYJBAUyuUyk1AVubYkIRJpevnpN0uy fDQLOdl70WdSomJBW+hu1cKltrGENpqwVJiOujaOW1W6bwqr+kQ7n89sjjLce8/+EGl9 FPFKQC9Mx2n+O1ILj4ZX/loqkeJ00+YqIsjvtce8QcJg119z2XvvXCKJ4wYj+FqLOHhA fmHA== X-Forwarded-Encrypted: i=1; AFNElJ9WbtvVYTJvBFttDhmKHUncSewkn8mKwA33vYHWkpGMuQ06xAOsgDj2vQN7mJO/Nxu8ijws5dfS90S4vyE=@vger.kernel.org X-Gm-Message-State: AOJu0YzGWgkKwLxbiBa3ryJUGIP2aq3PKGQnbyGvwgI5WH3xRT7fHbQh 2+pb1GHeC4r76ptOE6A4YHAxYNJOqoj+IJNg+p0kgKtX2xgXipTWMCEjPAsTa7VqDnM7meoJoN5 CQHLjy/cFd0+IKTvCTPHHO6Eby6nJ0AYQjf/yQwR/552TZQVMsleemCzupUSceSsDcfk= X-Gm-Gg: Acq92OGmG3BjJ6A6kafUbk2HzyX8+CoxxVOAV0gxGALjInriw+iCHzBJYKH8snLxBDX qJk+Hvwta16sG35jMej9wJyV77ROzXe97lCVXq6xSoxn4vaKIP5fLRmr3uQuEKUv4v6u7Rl3Zlv +jWSf7jv73FHtDq1F6LdED36Aeqghz4+jUNQSpErwp4cxZbTK8E1cKU4DFtVLGFYHtmI3sPS3Kk MjKBoXbYZ9tSuTPaM2b2qnxOrMOvCXDVaMBCAWSnqpZR5PA4xNRzryPyH9gAXAWuRscwEKglhJj UfUI8XlCkol6rVcqDiXfPF3EPyIpDdBSIk0HwNS+rDYWsumL/SpqAAzQ+lxzeVpN+T4quP6wPuA IDqKKYZhvcq760t0LTl72HIF3DnlhC7IMDg3BquDPLTvlIJUOgj3ploCIiaomOwReJQ== X-Received: by 2002:a05:6122:3384:b0:575:eaa3:2a95 with SMTP id 71dfb90a1353d-575f582411cmr9803020e0c.5.1779196535985; Tue, 19 May 2026 06:15:35 -0700 (PDT) X-Received: by 2002:a05:6122:3384:b0:575:eaa3:2a95 with SMTP id 71dfb90a1353d-575f582411cmr9802963e0c.5.1779196535472; Tue, 19 May 2026 06:15:35 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45da0a1aeafsm48018609f8f.23.2026.05.19.06.15.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2026 06:15:34 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: srini@kernel.org, lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com, krzysztof.kozlowski@oss.qualcomm.com, mohammad.rafi.shaik@oss.qualcomm.com, alexey.klimov@linaro.org, ravi.hothi@oss.qualcomm.com, mathieu.poirier@linaro.org, verhaegen@google.com, andersson@kernel.org, linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH 4/6] ASoC: qcom: audioreach: Add support for shared memory push/pull modules Date: Tue, 19 May 2026 13:15:25 +0000 Message-ID: <20260519131527.4002526-5-srinivas.kandagatla@oss.qualcomm.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260519131527.4002526-1-srinivas.kandagatla@oss.qualcomm.com> References: <20260519131527.4002526-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=Rt316imK c=1 sm=1 tr=0 ts=6a0c6279 cx=c_pps a=+D9SDfe9YZWTjADjLiQY5g==:117 a=ZsC4DHZuhs/kKio7QBcDoQ==:17 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=Um2Pa8k9VHT-vaBCBUpS:22 a=EUspDBNiAAAA:8 a=eJp2UY_-qWcN76HEE-cA:9 a=vmgOmaN-Xu0dpDh8OwbV:22 X-Proofpoint-ORIG-GUID: oErXWkiXyAZJo7cEjlrRZej6uBXozbuz X-Proofpoint-GUID: oErXWkiXyAZJo7cEjlrRZej6uBXozbuz X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTE5MDEzMSBTYWx0ZWRfX/307b1Pxdd5f 3dTwT9fq6KjWiZrSYKtn04X6Ru7xgXXQ+/z6zOIUHRje5qrKnKCmZ6GMVYVQW1NiHj7YOjkGrwz Xl2ArW2iYpM8cCiQSvEEIiQbKUeEltiRexUOAbXxh7pGb1KtQB0jUElvCtHbTs6RKmEX/txwqMz 9FGE3vZOXCjCK8diIY08JwzO+NHbcXShZFuIH4fstLPUAItnii+45mHl08w6Uyb3eM/w8PqnYqt ZdC1ebclKwGY74mtcBWXVfou4kY1yZ2z0V5W9YuPz49dFYG54KJi32CxwFbmXq9j/m+Sht6qFwU yny3M4TMF44fUtqETFySLIeCxFpgF+idE7k/9+kgdHaPQg3XLRxtYmKm8XhKYN/UZI0VSrkxuJO /C/QsKVVdGsST+6VsODOX3dMAWODvSPMu1d8/x0bVkqEJzWnUvF4tepsHXLEZwMmw31MLBU9KqF jZL1nmsHTmfwb/Z/f3Q== 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-05-19_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 phishscore=0 spamscore=0 impostorscore=0 lowpriorityscore=0 clxscore=1015 suspectscore=0 adultscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605190131 Content-Type: text/plain; charset="utf-8" Push-pull graphs use MODULE_ID_SH_MEM_PULL_MODE for playback and MODULE_ID_SH_MEM_PUSH_MODE for capture instead of the legacy WR/RD shared memory endpoints. Detect these modules when opening the graph, cache their instance ID in graph->shm_iid, and use them for media format setup. Also add support for mapping the position buffer required by push-pull mode and configuring the DSP with circular buffer and position buffer addresses. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/qdsp6/audioreach.c | 39 ++++++++ sound/soc/qcom/qdsp6/audioreach.h | 48 +++++++++ sound/soc/qcom/qdsp6/q6apm.c | 158 +++++++++++++++++++++++++----- sound/soc/qcom/qdsp6/q6apm.h | 9 ++ 4 files changed, 228 insertions(+), 26 deletions(-) diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audio= reach.c index 5b73f1d81c9b..c984b12409dd 100644 --- a/sound/soc/qcom/qdsp6/audioreach.c +++ b/sound/soc/qcom/qdsp6/audioreach.c @@ -1342,6 +1342,7 @@ int audioreach_set_media_format(struct q6apm_graph *g= raph, rc =3D audioreach_i2s_set_media_format(graph, module, cfg); break; case MODULE_ID_WR_SHARED_MEM_EP: + case MODULE_ID_SH_MEM_PULL_MODE: rc =3D audioreach_shmem_set_media_format(graph, module, cfg); break; case MODULE_ID_GAIN: @@ -1401,6 +1402,44 @@ void audioreach_graph_free_buf(struct q6apm_graph *g= raph) } EXPORT_SYMBOL_GPL(audioreach_graph_free_buf); =20 +int audioreach_setup_push_pull(struct q6apm_graph *graph, phys_addr_t bphy= s, + phys_addr_t pphys, uint32_t mem_map_handle, + uint32_t pos_buf_mem_map_handle, uint32_t size) +{ + struct param_id_sh_mem_pull_push_mode_cfg *cfg; + struct apm_module_param_data *param_data; + int payload_size; + struct gpr_pkt *pkt __free(kfree) =3D NULL; + void *p; + + payload_size =3D sizeof(*cfg) + APM_MODULE_PARAM_DATA_SIZE; + pkt =3D audioreach_alloc_apm_cmd_pkt(payload_size, APM_CMD_SET_CFG, 0); + if (IS_ERR(pkt)) + return PTR_ERR(pkt); + + p =3D (void *)pkt + GPR_HDR_SIZE + APM_CMD_HDR_SIZE; + + param_data =3D p; + param_data->module_instance_id =3D graph->shm_iid; + param_data->error_code =3D 0; + param_data->param_id =3D PARAM_ID_SH_MEM_PULL_PUSH_MODE_CFG; + param_data->param_size =3D payload_size - APM_MODULE_PARAM_DATA_SIZE; + + p =3D p + APM_MODULE_PARAM_DATA_SIZE; + cfg =3D p; + + cfg->shared_circ_buf_addr_lsw =3D lower_32_bits(bphys); + cfg->shared_circ_buf_addr_msw =3D upper_32_bits(bphys); + cfg->shared_circ_buf_size =3D size; + cfg->circ_buf_mem_map_handle =3D mem_map_handle; + cfg->shared_pos_buf_addr_lsw =3D lower_32_bits(pphys); + cfg->shared_pos_buf_addr_msw =3D upper_32_bits(pphys); + cfg->pos_buf_mem_map_handle =3D pos_buf_mem_map_handle; + + return q6apm_send_cmd_sync(graph->apm, pkt, 0); +} +EXPORT_SYMBOL_GPL(audioreach_setup_push_pull); + int audioreach_shared_memory_send_eos(struct q6apm_graph *graph) { struct data_cmd_wr_sh_mem_ep_eos *eos; diff --git a/sound/soc/qcom/qdsp6/audioreach.h b/sound/soc/qcom/qdsp6/audio= reach.h index 6859770b38a6..0504e8abc8e2 100644 --- a/sound/soc/qcom/qdsp6/audioreach.h +++ b/sound/soc/qcom/qdsp6/audioreach.h @@ -16,6 +16,8 @@ struct q6apm_graph; #define MODULE_ID_PCM_CNV 0x07001003 #define MODULE_ID_PCM_ENC 0x07001004 #define MODULE_ID_PCM_DEC 0x07001005 +#define MODULE_ID_SH_MEM_PULL_MODE 0x07001006 +#define MODULE_ID_SH_MEM_PUSH_MODE 0x07001007 #define MODULE_ID_PLACEHOLDER_ENCODER 0x07001008 #define MODULE_ID_PLACEHOLDER_DECODER 0x07001009 #define MODULE_ID_I2S_SINK 0x0700100A @@ -710,6 +712,46 @@ struct param_id_placeholder_real_module_id { uint32_t real_module_id; } __packed; =20 + +#define PARAM_ID_SH_MEM_PULL_PUSH_MODE_CFG 0x0800100A + +/** + * struct param_id_sh_mem_pull_push_mode_cfg - Shared memory push/pull con= fig + * @shared_circ_buf_addr_lsw: Lower 32 bits of the circular buffer address. + * @shared_circ_buf_addr_msw: Upper 32 bits of the circular buffer address. + * @shared_circ_buf_size: Circular buffer size in bytes. + * @circ_buf_mem_map_handle: Circular buffer memory map handle. + * @shared_pos_buf_addr_lsw: Lower 32 bits of the position buffer address. + * @shared_pos_buf_addr_msw: Upper 32 bits of the position buffer address. + * @pos_buf_mem_map_handle: Position buffer memory map handle. + */ +struct param_id_sh_mem_pull_push_mode_cfg { + uint32_t shared_circ_buf_addr_lsw; + uint32_t shared_circ_buf_addr_msw; + uint32_t shared_circ_buf_size; + uint32_t circ_buf_mem_map_handle; + uint32_t shared_pos_buf_addr_lsw; + uint32_t shared_pos_buf_addr_msw; + uint32_t pos_buf_mem_map_handle; +} __packed; + +/** + * struct sh_mem_pull_push_mode_position_buffer - Shared position buffer + * @frame_counter: Synchronization counter. + * @index: Current read/write index in bytes. + * @timestamp_us_lsw: Lower 32 bits of the timestamp in microseconds. + * @timestamp_us_msw: Upper 32 bits of the timestamp in microseconds. + * + * The frame counter should be read before and after the other fields to + * ensure the DSP did not update them while they were being read. + */ +struct sh_mem_pull_push_mode_position_buffer { + uint32_t frame_counter; + uint32_t index; + uint32_t timestamp_us_lsw; + uint32_t timestamp_us_msw; +} __packed; + /* Graph */ struct audioreach_connection { /* Connections */ @@ -723,8 +765,10 @@ struct audioreach_connection { struct audioreach_graph_info { int id; uint32_t mem_map_handle; + uint32_t pos_buf_mem_map_handle; uint32_t num_sub_graphs; struct list_head sg_list; + bool is_push_pull_mode; /* DPCM connection from FE Graph to BE graph */ uint32_t src_mod_inst_id; uint32_t src_mod_op_port_id; @@ -855,5 +899,9 @@ int audioreach_send_u32_param(struct q6apm_graph *graph, uint32_t param_id, uint32_t param_val); int audioreach_compr_set_param(struct q6apm_graph *graph, const struct audioreach_module_config *mcfg); +int audioreach_setup_push_pull(struct q6apm_graph *graph, phys_addr_t bphy= s, + phys_addr_t pphys, uint32_t mem_map_handle, + uint32_t pos_buf_mem_map_handle, uint32_t size); +int audioreach_map_memory_position_buffer(struct q6apm_graph *graph, unsig= ned int dir); =20 #endif /* __AUDIOREACH_H__ */ diff --git a/sound/soc/qcom/qdsp6/q6apm.c b/sound/soc/qcom/qdsp6/q6apm.c index 6ae7d1645dce..9235089c1b46 100644 --- a/sound/soc/qcom/qdsp6/q6apm.c +++ b/sound/soc/qcom/qdsp6/q6apm.c @@ -186,20 +186,27 @@ int q6apm_graph_media_format_shmem(struct q6apm_graph= *graph, { struct audioreach_module *module; =20 - if (cfg->direction =3D=3D SNDRV_PCM_STREAM_CAPTURE) - module =3D q6apm_find_module_by_mid(graph, MODULE_ID_RD_SHARED_MEM_EP); - else - module =3D q6apm_find_module_by_mid(graph, MODULE_ID_WR_SHARED_MEM_EP); + if (cfg->direction =3D=3D SNDRV_PCM_STREAM_CAPTURE) { + module =3D q6apm_find_module_by_mid(graph, MODULE_ID_SH_MEM_PUSH_MODE); + if (!module) + module =3D q6apm_find_module_by_mid(graph, MODULE_ID_RD_SHARED_MEM_EP); + } else { + module =3D q6apm_find_module_by_mid(graph, MODULE_ID_SH_MEM_PULL_MODE); + if (!module) + module =3D q6apm_find_module_by_mid(graph, MODULE_ID_WR_SHARED_MEM_EP); + } =20 - if (!module) + if (!module) { + dev_err(graph->dev, "No SHMEM module found in graph\n"); return -ENODEV; + } =20 return audioreach_set_media_format(graph, module, cfg); } EXPORT_SYMBOL_GPL(q6apm_graph_media_format_shmem); =20 -int q6apm_map_memory_fixed_region(struct device *dev, unsigned int graph_i= d, phys_addr_t phys, - size_t sz) +static int __q6apm_map_memory_fixed_region(struct device *dev, unsigned in= t graph_id, + phys_addr_t phys, size_t sz, bool is_pos_buf) { struct audioreach_graph_info *info; struct q6apm *apm =3D dev_get_drvdata(dev->parent); @@ -208,8 +215,10 @@ int q6apm_map_memory_fixed_region(struct device *dev, = unsigned int graph_id, phy int payload_size =3D sizeof(*cmd) + (sizeof(*mregions)); uint32_t buf_sz; void *p; + uint32_t pos_mask =3D is_pos_buf ? APM_MMAP_TOKEN_MAP_TYPE_POS_BUF : 0; struct gpr_pkt *pkt __free(kfree) =3D audioreach_alloc_apm_cmd_pkt(payloa= d_size, - APM_CMD_SHARED_MEM_MAP_REGIONS, graph_id); + APM_CMD_SHARED_MEM_MAP_REGIONS, (graph_id | pos_mask)); + if (IS_ERR(pkt)) return PTR_ERR(pkt); =20 @@ -217,8 +226,13 @@ int q6apm_map_memory_fixed_region(struct device *dev, = unsigned int graph_id, phy if (!info) return -ENODEV; =20 - if (info->mem_map_handle) - return 0; + if (is_pos_buf) { + if (info->pos_buf_mem_map_handle) + return 0; + } else { + if (info->mem_map_handle) + return 0; + } =20 /* DSP expects size should be aligned to 4K */ buf_sz =3D ALIGN(sz, 4096); @@ -227,7 +241,10 @@ int q6apm_map_memory_fixed_region(struct device *dev, = unsigned int graph_id, phy cmd =3D p; cmd->mem_pool_id =3D APM_MEMORY_MAP_SHMEM8_4K_POOL; cmd->num_regions =3D 1; - cmd->property_flag =3D 0x0; + if (is_pos_buf) + cmd->property_flag =3D 0x2; + else + cmd->property_flag =3D 0x0; =20 mregions =3D p + sizeof(*cmd); =20 @@ -237,6 +254,18 @@ int q6apm_map_memory_fixed_region(struct device *dev, = unsigned int graph_id, phy =20 return q6apm_send_cmd_sync(apm, pkt, APM_CMD_RSP_SHARED_MEM_MAP_REGIONS); } + +int q6apm_map_pos_buffer(struct device *dev, unsigned int graph_id, phys_a= ddr_t phys, size_t sz) +{ + return __q6apm_map_memory_fixed_region(dev, graph_id, phys, sz, true); +} +EXPORT_SYMBOL_GPL(q6apm_map_pos_buffer); + +int q6apm_map_memory_fixed_region(struct device *dev, unsigned int graph_i= d, + phys_addr_t phys, size_t sz) +{ + return __q6apm_map_memory_fixed_region(dev, graph_id, phys, sz, false); +} EXPORT_SYMBOL_GPL(q6apm_map_memory_fixed_region); =20 int q6apm_alloc_fragments(struct q6apm_graph *graph, unsigned int dir, phy= s_addr_t phys, @@ -290,11 +319,13 @@ int q6apm_alloc_fragments(struct q6apm_graph *graph, = unsigned int dir, phys_addr } EXPORT_SYMBOL_GPL(q6apm_alloc_fragments); =20 -int q6apm_unmap_memory_fixed_region(struct device *dev, unsigned int graph= _id) +static int __q6apm_unmap_memory_fixed_region(struct device *dev, unsigned = int graph_id, + bool is_pos_buf) { struct apm_cmd_shared_mem_unmap_regions *cmd; struct q6apm *apm =3D dev_get_drvdata(dev->parent); struct audioreach_graph_info *info; + uint32_t mem_map_handle; struct gpr_pkt *pkt __free(kfree) =3D audioreach_alloc_apm_cmd_pkt(sizeof= (*cmd), APM_CMD_SHARED_MEM_UNMAP_REGIONS, graph_id); if (IS_ERR(pkt)) @@ -304,16 +335,35 @@ int q6apm_unmap_memory_fixed_region(struct device *de= v, unsigned int graph_id) if (!info) return -ENODEV; =20 - if (!info->mem_map_handle) - return 0; + if (is_pos_buf) { + if (!info->pos_buf_mem_map_handle) + return 0; + mem_map_handle =3D info->pos_buf_mem_map_handle; + } else { + + if (!info->mem_map_handle) + return 0; + mem_map_handle =3D info->mem_map_handle; + } =20 cmd =3D (void *)pkt + GPR_HDR_SIZE; - cmd->mem_map_handle =3D info->mem_map_handle; + cmd->mem_map_handle =3D mem_map_handle; =20 return q6apm_send_cmd_sync(apm, pkt, APM_CMD_SHARED_MEM_UNMAP_REGIONS); } + +int q6apm_unmap_memory_fixed_region(struct device *dev, unsigned int graph= _id) +{ + return __q6apm_unmap_memory_fixed_region(dev, graph_id, false); +} EXPORT_SYMBOL_GPL(q6apm_unmap_memory_fixed_region); =20 +int q6apm_unmap_pos_buffer(struct device *dev, unsigned int graph_id) +{ + return __q6apm_unmap_memory_fixed_region(dev, graph_id, true); +} +EXPORT_SYMBOL_GPL(q6apm_unmap_pos_buffer); + int q6apm_free_fragments(struct q6apm_graph *graph, unsigned int dir) { audioreach_graph_free_buf(graph); @@ -402,7 +452,9 @@ int q6apm_graph_media_format_pcm(struct q6apm_graph *gr= aph, struct audioreach_mo list_for_each_entry(container, &sgs->container_list, node) { list_for_each_entry(module, &container->modules_list, node) { if ((module->module_id =3D=3D MODULE_ID_WR_SHARED_MEM_EP) || - (module->module_id =3D=3D MODULE_ID_RD_SHARED_MEM_EP)) + (module->module_id =3D=3D MODULE_ID_RD_SHARED_MEM_EP) || + (module->module_id =3D=3D MODULE_ID_SH_MEM_PULL_MODE) || + (module->module_id =3D=3D MODULE_ID_SH_MEM_PUSH_MODE)) continue; =20 ret =3D audioreach_set_media_format(graph, module, cfg); @@ -589,6 +641,42 @@ static int graph_callback(const struct gpr_resp_pkt *d= ata, void *priv, int op) return 0; } =20 +int q6apm_push_pull_config(struct q6apm_graph *graph, phys_addr_t bphys, + phys_addr_t pphys, uint32_t size) +{ + struct audioreach_graph_info *info =3D graph->info; + + return audioreach_setup_push_pull(graph, bphys, pphys, info->mem_map_hand= le, + info->pos_buf_mem_map_handle, size); +} +EXPORT_SYMBOL_GPL(q6apm_push_pull_config); + +bool q6apm_is_graph_in_push_pull_mode_from_id(struct device *dev, unsigned= int graph_id, int dir) +{ + struct audioreach_graph_info *info; + struct q6apm *apm =3D dev_get_drvdata(dev->parent); + struct audioreach_module *module; + + info =3D idr_find(&apm->graph_info_idr, graph_id); + if (!info) + return false; + + if (dir =3D=3D SNDRV_PCM_STREAM_PLAYBACK) + module =3D __q6apm_find_module_by_mid(apm, info, MODULE_ID_SH_MEM_PULL_M= ODE); + else + module =3D __q6apm_find_module_by_mid(apm, info, MODULE_ID_SH_MEM_PUSH_M= ODE); + + return !!module; + +} +EXPORT_SYMBOL_GPL(q6apm_is_graph_in_push_pull_mode_from_id); + +bool q6apm_is_graph_in_push_pull_mode(struct q6apm_graph *graph) +{ + return graph->info->is_push_pull_mode; +} +EXPORT_SYMBOL_GPL(q6apm_is_graph_in_push_pull_mode); + static int q6apm_graph_get_module_iid(struct q6apm_graph *graph, uint32_t = mid) { struct audioreach_module *module; @@ -598,7 +686,6 @@ static int q6apm_graph_get_module_iid(struct q6apm_grap= h *graph, uint32_t mid) return -ENODEV; =20 return module->instance_id; - } =20 struct q6apm_graph *q6apm_graph_open(struct device *dev, q6apm_cb cb, @@ -607,7 +694,7 @@ struct q6apm_graph *q6apm_graph_open(struct device *dev= , q6apm_cb cb, struct q6apm *apm =3D dev_get_drvdata(dev->parent); struct audioreach_graph *ar_graph; struct q6apm_graph *graph; - int ret; + int ret, iid =3D 0; =20 ar_graph =3D q6apm_get_audioreach_graph(apm, graph_id); if (IS_ERR(ar_graph)) { @@ -629,11 +716,23 @@ struct q6apm_graph *q6apm_graph_open(struct device *d= ev, 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_module_iid(graph, MODULE_ID_WR_SHARED= _MEM_EP); - else - graph->shm_iid =3D q6apm_graph_get_module_iid(graph, MODULE_ID_RD_SHARED= _MEM_EP); + if (dir =3D=3D SNDRV_PCM_STREAM_PLAYBACK) { + iid =3D q6apm_graph_get_module_iid(graph, MODULE_ID_SH_MEM_PULL_MODE); + if (iid < 0) + iid =3D q6apm_graph_get_module_iid(graph, MODULE_ID_WR_SHARED_MEM_EP); + else + graph->info->is_push_pull_mode =3D true; =20 + } else { + iid =3D q6apm_graph_get_module_iid(graph, MODULE_ID_SH_MEM_PUSH_MODE); + if (iid < 0) + iid =3D q6apm_graph_get_module_iid(graph, MODULE_ID_RD_SHARED_MEM_EP); + else + graph->info->is_push_pull_mode =3D true; + } + + if (iid > 0) + graph->shm_iid =3D iid; =20 mutex_init(&graph->lock); init_waitqueue_head(&graph->cmd_wait); @@ -790,6 +889,7 @@ static int apm_callback(const struct gpr_resp_pkt *data= , void *priv, int op) struct device *dev =3D &gdev->dev; struct gpr_ibasic_rsp_result_t *result; const struct gpr_hdr *hdr =3D &data->hdr; + int graph_id, is_pos_buf; =20 result =3D data->payload; =20 @@ -840,13 +940,19 @@ static int apm_callback(const struct gpr_resp_pkt *da= ta, void *priv, int op) apm->result.opcode =3D hdr->opcode; apm->result.status =3D 0; rsp =3D data->payload; + graph_id =3D hdr->token & APM_MMAP_TOKEN_GID_MASK; + is_pos_buf =3D hdr->token & APM_MMAP_TOKEN_MAP_TYPE_POS_BUF; =20 - info =3D idr_find(&apm->graph_info_idr, hdr->token); - if (info) - info->mem_map_handle =3D rsp->mem_map_handle; - else + info =3D idr_find(&apm->graph_info_idr, graph_id); + if (info) { + if (is_pos_buf) + info->pos_buf_mem_map_handle =3D rsp->mem_map_handle; + else + info->mem_map_handle =3D rsp->mem_map_handle; + } else { dev_err(dev, "Error (%d) Processing 0x%08x cmd\n", result->status, result->opcode); + } =20 wake_up(&apm->wait); break; diff --git a/sound/soc/qcom/qdsp6/q6apm.h b/sound/soc/qcom/qdsp6/q6apm.h index 8ea64085860f..780933ff17e9 100644 --- a/sound/soc/qcom/qdsp6/q6apm.h +++ b/sound/soc/qcom/qdsp6/q6apm.h @@ -136,6 +136,10 @@ int q6apm_write_async(struct q6apm_graph *graph, uint3= 2_t len, uint32_t msw_ts, int q6apm_map_memory_fixed_region(struct device *dev, unsigned int graph_id, phys_addr_t phys, size_t sz); +int q6apm_map_pos_buffer(struct device *dev, + unsigned int graph_id, phys_addr_t phys, + size_t sz); +int q6apm_unmap_pos_buffer(struct device *dev, unsigned int graph_id); int q6apm_alloc_fragments(struct q6apm_graph *graph, unsigned int dir, phys_addr_t phys, size_t period_sz, unsigned int periods); @@ -155,4 +159,9 @@ int q6apm_remove_initial_silence(struct device *dev, st= ruct q6apm_graph *graph, int q6apm_remove_trailing_silence(struct device *dev, struct q6apm_graph *= graph, uint32_t samples); int q6apm_set_real_module_id(struct device *dev, struct q6apm_graph *graph= , uint32_t codec_id); int q6apm_get_hw_pointer(struct q6apm_graph *graph, int dir); +bool q6apm_is_graph_in_push_pull_mode(struct q6apm_graph *graph); +bool q6apm_is_graph_in_push_pull_mode_from_id(struct device *dev, unsigned= int graph_id, int dir); +int q6apm_push_pull_config(struct q6apm_graph *graph, phys_addr_t bphys, + phys_addr_t pphys, uint32_t size); + #endif /* __APM_GRAPH_ */ --=20 2.47.3 From nobody Wed Jun 10 08:23:10 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 EAB174DC540 for ; Tue, 19 May 2026 13:15:38 +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=1779196541; cv=none; b=ki49bmjENt02afGsds+O/W9cTdsYCgEQRO53X1NgOfPmpx3blwCmxUbMiF+1CR3h1Abt8yNDfaYDgLNlcatzXt1nq9LRhgSIENtiPxrTtA8tIeWGMBZk/1EtOdPE0bjYXAnNHUh98W2AqHdMB2MnM4eknrt1T/2vUCutDfS5ooY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779196541; c=relaxed/simple; bh=Eojsjq92nlo2AdgTwb8BLdVR/DF5UkFPWwvqnE41UZQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UT8JVF8tqgiPB6WSEBrzjlYqcnJFVROzj1NYdvHXvAZpj09QRHJDQJJD1M4P1X3O1OsD0s1e88tQ0Vfv3nyKBvJsLLKuURIqAfJv9IT5mFkzbObfUH8YwbFHb5koppsANL2gT9aJmKr9io32v4JH0c2qmV25OYOVaHWXYtu+2RU= 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=Rg81kQNV; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=gMpEniO4; 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="Rg81kQNV"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="gMpEniO4" 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 64J9tm8f253382 for ; Tue, 19 May 2026 13:15:38 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=O1fqH3pRoYY kfZnh9hO2XreKl13dtCV/1mBNYELIMnM=; b=Rg81kQNVVa4d8SXwffeLB00IWLu crCC9yfqYFerb6B3CG8naD4gUrju2bhuKUnNJho7qJGAPRR3/8Pmgm7mB4RSzO0z JMDBlsJdGDw3nCGwS0/UDvzBN3vTY3CkpFi49LoD+UUvsyL0roLIKwWDFZ94YEDy 50lcfWUuTE2ZdDzV/7UsVU0j0Fhuhd5OUeBBVDje+o3/OYP2vi307oHkBDnJXO+i p3fHLWOyvVf5814lI9xglz0yq3jPpYksKcVaWp99zwUn5bVRkczDL0tgmvjNFior Ynw/vOWBogkPj8cJsP1tMa58KDquSLqk0ViyHJU+SVJizYZEfr6Ak6/BNUA== Received: from mail-vk1-f198.google.com (mail-vk1-f198.google.com [209.85.221.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4e8h87t11s-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 19 May 2026 13:15:37 +0000 (GMT) Received: by mail-vk1-f198.google.com with SMTP id 71dfb90a1353d-577c69d3f04so3549014e0c.0 for ; Tue, 19 May 2026 06:15:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1779196537; x=1779801337; 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=O1fqH3pRoYYkfZnh9hO2XreKl13dtCV/1mBNYELIMnM=; b=gMpEniO4V6n8Tuy62iY/U8AGzLKotorWeviI66v9eGeGv9G/WOjKNcCUXNG6rBdr+B p5IAk94tzyC2m6BUfp54BuQGjCwQ4Bu+ioD+Hz/1u8begDnoNymfuJl/RfNUlmb5xdZi OSHy9c387YG8s99WvutVkGz5OKxJyduA+EZsznM9A4w/75NzmWpfJhxOSbtYyP+3XIq/ Mrz5cETi7eKAKNa+LmfZvUsFxocQg/lu7mh3YnDgE5/nIni0tsBMvoCa/YNw3vhZueq1 kmaQKHHLVEQXdqtlnSGHgt7LMV2119QUWd81Wi+Z/H5XrshY1AILemnLYglw7LiskAsR 1yfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779196537; x=1779801337; 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=O1fqH3pRoYYkfZnh9hO2XreKl13dtCV/1mBNYELIMnM=; b=WlsSxMwQMGrm6cHmppCD0INNac1kFp6LIjvhL5XWRND5wOpUguxoyFxFw46EhiE0co AwjpBlq0jpCC5vFIOgFds5Q+0TbFIu+A7iv9BNqiptkFbBdFP1kAj3Cwn9INpC4DpZCc wmd+F9fRAhc5qcF1wV7iq7aewDiQvoTLa9IpZO/ll2QVYT5jC/CMpxkcFD4fCfxNrMr7 Yy7JUfK/kDfRn8LVaJ2k/+8hms08q4RwwALcpc3df3hWsl0BphSt51WlUe+oCWtGAX7e WzP7EOx4m4VhayXSeyfU0wJXYfGj0Cuf7xBMIKc7i4nZXyR/idgc3uLWIQjjRJ/CVi9B Uihw== X-Forwarded-Encrypted: i=1; AFNElJ9EbsEVvAKcxCor74zA2TSzGTikxUpg/xkulNnrAGxnnMu9Vh+Z2R6h+fcGRe0j6gGiDyOT8XuEPL7jqAI=@vger.kernel.org X-Gm-Message-State: AOJu0Yzw0TcuEFUNQCDil8MwBpJYu8NKDy5+e4lXWeI/woWsDJbtgnyK lhCvFvxQkwhGC7W+HXuj178yyGbxB0eaaMizKngImU2Gd98nITdJea0DAEXF6xxNGhT2eFRxzft yQulSuc3sqJfm+iatsK+sjJNdNUEineFYkjMVkmHyLxjM8dUbLu3bVQ19JCvTUnFll2WfiDhGi+ E= X-Gm-Gg: Acq92OFK78ucF/QwNQ8WDJWZimHZbAR1IvkIWp9rQ3UdHub/nzAMbCFVIbjiySsNCQk kmC9t7m6brrRX2aTXlAri9AV6aOeEhz55TvLsBvYgw8GADeZN+ljI0cCb9Rcqu42Fv0E9qy8dHA SfiC7ZpHEqyQ9ar6Ac1R4f93LxFYmaz7YLET+AF12910SoSgC7UaiKzf+kEemlBI98MzjdSO1SV L2kIKGP/1by7/PyICOBa/DXfuqvFNf9sxDVvuGWHUv0L6vwtE8RE5xvJobKh97jhSikI4XstQ26 BVT3PHM704oOfrrYScjca7/ZP13A/NHMfQsgaMPyRTjd2nDTz7iBPpfiDHjWJbg9KAARU8fXJkC WYCTC5P+TpVgkd9LA8A4tFnlDNKKCLH5kE/a4lgBpUr+i8LGw1ji+ios= X-Received: by 2002:a05:6122:4f9f:b0:56f:6add:9029 with SMTP id 71dfb90a1353d-5760be34e4amr10646299e0c.1.1779196537210; Tue, 19 May 2026 06:15:37 -0700 (PDT) X-Received: by 2002:a05:6122:4f9f:b0:56f:6add:9029 with SMTP id 71dfb90a1353d-5760be34e4amr10646222e0c.1.1779196536748; Tue, 19 May 2026 06:15:36 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45da0a1aeafsm48018609f8f.23.2026.05.19.06.15.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2026 06:15:36 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: srini@kernel.org, lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com, krzysztof.kozlowski@oss.qualcomm.com, mohammad.rafi.shaik@oss.qualcomm.com, alexey.klimov@linaro.org, ravi.hothi@oss.qualcomm.com, mathieu.poirier@linaro.org, verhaegen@google.com, andersson@kernel.org, linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH 5/6] ASoC: qcom: q6apm: add watermark event support Date: Tue, 19 May 2026 13:15:26 +0000 Message-ID: <20260519131527.4002526-6-srinivas.kandagatla@oss.qualcomm.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260519131527.4002526-1-srinivas.kandagatla@oss.qualcomm.com> References: <20260519131527.4002526-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-GUID: Fs4F8p_DYaOKA7xsEO-VjwJGYEQ_5mai X-Proofpoint-ORIG-GUID: Fs4F8p_DYaOKA7xsEO-VjwJGYEQ_5mai X-Authority-Analysis: v=2.4 cv=a9sAM0SF c=1 sm=1 tr=0 ts=6a0c6279 cx=c_pps a=1Os3MKEOqt8YzSjcPV0cFA==:117 a=ZsC4DHZuhs/kKio7QBcDoQ==:17 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=rJkE3RaqiGZ5pbrm-msn:22 a=EUspDBNiAAAA:8 a=cig4ayqGPX1rv0pnnd0A:9 a=hhpmQAJR8DioWGSBphRh:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTE5MDEzMSBTYWx0ZWRfXwsOx1VElRX9u A601Tl1/pyQLj4mJYKr7URJm4HnCaIUwR+jMZlQZZOm5J3BSKkyVxsnS6ayiwHE22aXlelszHvx h/LjNPCEhi/Fi0M2R7PrbWiKmuFuNduAey0yMlF6zCxUbCcIZgcnr7amSy57B5myDXvi8TjfFsb fFMYcGo+G1Yue4eQ0ERhGFjRqxha/9gH97hPNE0lvanwKjFO72B+Nc9JUhnq57LB6McOvsEwBc3 UfeN5/YBXX068vFjuxZqBouxhZ6o0yJOKgEl1mGuyNnvELP6YVDkeyDmyF+sPmMKnNzJePEKvAo +RNg7jiAt8pTRdjh8i5Demi4FtJbAdDU8q0xhWKbmgF+8iqulL87vIChq/imKWbKzkalWIj1vKS egh8LM1pW+5odvXqhI7/DSEaXSzcL1l9byw1A5KjL3fH4r2BXJbzccB4KmFzkpY5HI1N+a8rcrH 1hLWR4SXH3aIVgTLy+g== 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-05-19_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 priorityscore=1501 impostorscore=0 adultscore=0 clxscore=1015 lowpriorityscore=0 bulkscore=0 suspectscore=0 spamscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605190131 Content-Type: text/plain; charset="utf-8" Push-pull shared memory modules can report watermark events when the DSP read/write index reaches configured circular buffer levels. Add support for registering watermark levels with the shared memory module and route the resulting module event to q6apm clients using a new APM_CLIENT_EVENT_WATERMARK_EVENT event. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/qdsp6/audioreach.c | 36 ++++++++++++++++++++++ sound/soc/qcom/qdsp6/audioreach.h | 50 +++++++++++++++++++++++++++++++ sound/soc/qcom/qdsp6/q6apm.c | 19 ++++++++++++ sound/soc/qcom/qdsp6/q6apm.h | 2 ++ 4 files changed, 107 insertions(+) diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audio= reach.c index c984b12409dd..e6e9eb2e85aa 100644 --- a/sound/soc/qcom/qdsp6/audioreach.c +++ b/sound/soc/qcom/qdsp6/audioreach.c @@ -1118,6 +1118,42 @@ static int audioreach_pcm_set_media_format(struct q6= apm_graph *graph, return q6apm_send_cmd_sync(graph->apm, pkt, 0); } =20 +int audioreach_shmem_register_event(struct q6apm_graph *graph, int bytes, = int num_levels) +{ + struct apm_module_register_events *event; + struct event_cfg_sh_mem_pull_push_mode_watermark_t *level; + int i, payload_size; + struct gpr_pkt *pkt __free(kfree) =3D NULL; + void *p; + + if (num_levels <=3D 0 || bytes <=3D 0) + return -EINVAL; + + payload_size =3D sizeof(*event) + sizeof(*level) + num_levels * sizeof(ui= nt32_t); + + pkt =3D audioreach_alloc_cmd_pkt(payload_size, APM_CMD_REGISTER_MODULE_EV= ENTS, 0, + graph->port->id, graph->shm_iid); + if (IS_ERR(pkt)) + return PTR_ERR(pkt); + + p =3D (void *)pkt + GPR_HDR_SIZE + APM_CMD_HDR_SIZE; + + event =3D p; + event->module_instance_id =3D graph->shm_iid; + event->event_id =3D EVENT_ID_SH_MEM_PULL_PUSH_MODE_WATERMARK; + event->is_register =3D 1; + event->event_config_payload_size =3D sizeof(*level) + num_levels * sizeof= (uint32_t); + p +=3D sizeof(*event); + level =3D p; + level->num_water_mark_levels =3D num_levels; + + for (i =3D 0; i < num_levels; i++) + level->level[i] =3D (i + 1) * bytes; + + return audioreach_graph_send_cmd_sync(graph, pkt, 0); +} +EXPORT_SYMBOL_GPL(audioreach_shmem_register_event); + static int audioreach_shmem_set_media_format(struct q6apm_graph *graph, const struct audioreach_module *module, const struct audioreach_module_config *mcfg) diff --git a/sound/soc/qcom/qdsp6/audioreach.h b/sound/soc/qcom/qdsp6/audio= reach.h index 0504e8abc8e2..50c7aa9a82aa 100644 --- a/sound/soc/qcom/qdsp6/audioreach.h +++ b/sound/soc/qcom/qdsp6/audioreach.h @@ -62,10 +62,59 @@ struct q6apm_graph; #define APM_CMD_GET_CFG 0x01001007 #define APM_CMD_SHARED_MEM_MAP_REGIONS 0x0100100C #define APM_CMD_SHARED_MEM_UNMAP_REGIONS 0x0100100D +#define APM_CMD_REGISTER_MODULE_EVENTS 0x0100100E +#define APM_EVENT_MODULE_TO_CLIENT 0x03001000 + #define APM_CMD_RSP_SHARED_MEM_MAP_REGIONS 0x02001001 +#define APM_MMAP_TOKEN_GID_MASK GENMASK(15, 0) +#define APM_MMAP_TOKEN_MAP_TYPE_POS_BUF BIT(16) +#define APM_MMAP_TOKEN_MAP_TYPE_SHIFT 16 + #define APM_CMD_RSP_GET_CFG 0x02001000 #define APM_CMD_CLOSE_ALL 0x01001013 #define APM_CMD_REGISTER_SHARED_CFG 0x0100100A +#define EVENT_ID_SH_MEM_PULL_PUSH_MODE_WATERMARK 0x0800101C + +/** + * struct event_cfg_sh_mem_pull_push_mode_watermark_t - Watermark config + * @num_water_mark_levels: Number of watermark levels. + * @level: Watermark levels. + * + * If @num_water_mark_levels is zero, no watermark levels are specified + * and watermark events are not supported. + */ +struct event_cfg_sh_mem_pull_push_mode_watermark_t { + uint32_t num_water_mark_levels; + uint32_t level[]; +} __packed; + +/** + * struct apm_module_register_events - Register or unregister module events + * @module_instance_id: Module instance identifier. + * @event_id: Module event identifier. + * @is_register: 1 to register the event, 0 to unregister it. + * @error_code: Error code for out-of-band command mode. + * @event_config_payload_size: Event configuration payload size in bytes. + * @reserved: Reserved for alignment; must be zero. + */ +struct apm_module_register_events { + uint32_t module_instance_id; + uint32_t event_id; + uint32_t is_register; + uint32_t error_code; + uint32_t event_config_payload_size; + uint32_t reserved; +} __packed; + +/** + * struct apm_module_event - Module event descriptor + * @event_id: Module event identifier. + * @event_payload_size: Event payload size in bytes. + */ +struct apm_module_event { + uint32_t event_id; + uint32_t event_payload_size; +} __packed; =20 #define APM_MEMORY_MAP_SHMEM8_4K_POOL 3 =20 @@ -904,4 +953,5 @@ int audioreach_setup_push_pull(struct q6apm_graph *grap= h, phys_addr_t bphys, uint32_t pos_buf_mem_map_handle, uint32_t size); int audioreach_map_memory_position_buffer(struct q6apm_graph *graph, unsig= ned int dir); =20 +int audioreach_shmem_register_event(struct q6apm_graph *graph, int bytes, = int num_levels); #endif /* __AUDIOREACH_H__ */ diff --git a/sound/soc/qcom/qdsp6/q6apm.c b/sound/soc/qcom/qdsp6/q6apm.c index 9235089c1b46..2e5b25b8d00f 100644 --- a/sound/soc/qcom/qdsp6/q6apm.c +++ b/sound/soc/qcom/qdsp6/q6apm.c @@ -557,6 +557,7 @@ static int graph_callback(const struct gpr_resp_pkt *da= ta, void *priv, int op) { struct data_cmd_rsp_rd_sh_mem_ep_data_buffer_done_v2 *rd_done; struct data_cmd_rsp_wr_sh_mem_ep_data_buffer_done_v2 *done; + struct apm_module_event *event; const struct gpr_ibasic_rsp_result_t *result; struct q6apm_graph *graph =3D priv; const struct gpr_hdr *hdr =3D &data->hdr; @@ -568,6 +569,16 @@ static int graph_callback(const struct gpr_resp_pkt *d= ata, void *priv, int op) result =3D data->payload; =20 switch (hdr->opcode) { + case APM_EVENT_MODULE_TO_CLIENT: + event =3D data->payload; + switch (event->event_id) { + case EVENT_ID_SH_MEM_PULL_PUSH_MODE_WATERMARK: + client_event =3D APM_CLIENT_EVENT_WATERMARK_EVENT; + graph->cb(client_event, hdr->token, data->payload, graph->priv); + break; + } + + break; case DATA_CMD_RSP_WR_SH_MEM_EP_DATA_BUFFER_DONE_V2: if (!graph->ar_graph) break; @@ -623,6 +634,7 @@ static int graph_callback(const struct gpr_resp_pkt *da= ta, void *priv, int op) switch (result->opcode) { case APM_CMD_SHARED_MEM_MAP_REGIONS: case DATA_CMD_WR_SH_MEM_EP_MEDIA_FORMAT: + case APM_CMD_REGISTER_MODULE_EVENTS: case APM_CMD_SET_CFG: graph->result.opcode =3D result->opcode; graph->result.status =3D result->status; @@ -641,6 +653,13 @@ static int graph_callback(const struct gpr_resp_pkt *d= ata, void *priv, int op) return 0; } =20 +int q6apm_register_watermark_event(struct q6apm_graph *graph, int water_ma= rk_level_bytes, + int num_levels) +{ + return audioreach_shmem_register_event(graph, water_mark_level_bytes, num= _levels); +} +EXPORT_SYMBOL_GPL(q6apm_register_watermark_event); + int q6apm_push_pull_config(struct q6apm_graph *graph, phys_addr_t bphys, phys_addr_t pphys, uint32_t size) { diff --git a/sound/soc/qcom/qdsp6/q6apm.h b/sound/soc/qcom/qdsp6/q6apm.h index 780933ff17e9..5cb51ca491dc 100644 --- a/sound/soc/qcom/qdsp6/q6apm.h +++ b/sound/soc/qcom/qdsp6/q6apm.h @@ -41,6 +41,7 @@ #define APM_CLIENT_EVENT_CMD_RUN_DONE 0x1008 #define APM_CLIENT_EVENT_DATA_WRITE_DONE 0x1009 #define APM_CLIENT_EVENT_DATA_READ_DONE 0x100a +#define APM_CLIENT_EVENT_WATERMARK_EVENT 0x100b #define APM_WRITE_TOKEN_MASK GENMASK(15, 0) #define APM_WRITE_TOKEN_LEN_MASK GENMASK(31, 16) #define APM_WRITE_TOKEN_LEN_SHIFT 16 @@ -164,4 +165,5 @@ bool q6apm_is_graph_in_push_pull_mode_from_id(struct de= vice *dev, unsigned int g int q6apm_push_pull_config(struct q6apm_graph *graph, phys_addr_t bphys, phys_addr_t pphys, uint32_t size); =20 +int q6apm_register_watermark_event(struct q6apm_graph *graph, int watermar= k_bytes, int num_levels); #endif /* __APM_GRAPH_ */ --=20 2.47.3 From nobody Wed Jun 10 08:23:10 2026 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.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 8E8D34E3792 for ; Tue, 19 May 2026 13:15:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779196543; cv=none; b=hMF7s5gwhftAEVIn67y7T5Y1BQnyjSEJiKpakhmcxsqcTJcKF+GyoyLLT3Cqd3QfVKl3tLo/TM6xq+P9S7Mczykti65Z6inAXR1V0pt+hbGS+jFIq9ITXQaCXdEkNpg6+dvEosgJZWv1paYTbNKRihamAomuN1Rrz2YDr6y+g4Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779196543; c=relaxed/simple; bh=44/1jWStuIN39XJe/tAIOn4LtblZLVTLwgCuGYftWnU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VoLSiHQ1R5aQhrTWwAmXFIlvkHLKymUZxyDkhSsYjVzkHA5Vz7pCZ6jDuzsAIAY1OjPntWa0aiu8oa9EHEhOrQNG2QCHmjyyUXAirwVfLRa+f9tBh044yP08q5X7z/oe/mx8R1lCj+qi+M/qt+sy3v5/JdWUyNIQHM6LXviRn+A= 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=c7owgYYD; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=ZSebCpsO; arc=none smtp.client-ip=205.220.168.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="c7owgYYD"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="ZSebCpsO" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64J9Lp844062966 for ; Tue, 19 May 2026 13:15:40 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=p2qDU3XsOH0 nCkDYHDKlXqlRcWGH6pIgmdP22P1u+iM=; b=c7owgYYDYABqXArDDMg1UHrdgAV CqntPlNqw5QUByesxp/rvGGz0elf0k7tTG9qGjLfalwCYpxxA8nNadZXiCYxoDnP ixP6MVxBzEeCvFZBn9nROYTPkxdqJPyDJeVA1ehnLwnsO0g0wTKxiyPIj6C6ni08 YF/OVSffsXCw7h8e4hneT3z5vfxG+/UQEGlsaYbBgIq+v3/M2/YNy0+abunrmQmT 1z7ttqa1xyFIQpEB7dBor2KIke4BYf1ZkdVur1ycW7KLyTjpaKcGVIOL+1gngJUq lU2hepC9dGkB+cE6Yfgu5unTwDbOLYf2ylMhj0523qZKvVH7H9DjjrNiUOQ== Received: from mail-vk1-f197.google.com (mail-vk1-f197.google.com [209.85.221.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4e8n5u0v6s-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 19 May 2026 13:15:39 +0000 (GMT) Received: by mail-vk1-f197.google.com with SMTP id 71dfb90a1353d-575b418c83cso1405567e0c.0 for ; Tue, 19 May 2026 06:15:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1779196539; x=1779801339; 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=p2qDU3XsOH0nCkDYHDKlXqlRcWGH6pIgmdP22P1u+iM=; b=ZSebCpsO+kF0Kf9FnMfFHqaNg0TE8jKczkVY2QEZFd8nYpumEfQG1+qmHHwJkfF1id rEAER3XmgUPNw6g2g+1LcgEzaqF6+F41kLzhaOdZnQU/++03WLgXreJMXziGxX3R0Wd3 z0rr6zxhybkHgpaKNL2jK8ZF830jGulZ+9ZI9FXIeVHnVLtxEepwbxEpZbZQ6tWh6XEu ctFReZ3lYSbwK6BYdWKYkviqihEWNaBc1MIUWh4yOxNXk5cTIGuReo6Xzak3RzE06xkr qrEbp5SM3z3F71dLjNeB9oFMcA8p/Cw4wf+61zK6jGVCf92qzqJVthR812fV4xc5V8I0 uL9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779196539; x=1779801339; 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=p2qDU3XsOH0nCkDYHDKlXqlRcWGH6pIgmdP22P1u+iM=; b=rUgYcY6QJ1smzxSolmPtTSNiYLY6BOwG4hKOSDjc0P8EW4H4Ettn3aE6BZ+ITq6/fS AHj3NAJqSH1G2zKKIEyB/JXYwoQCN9K4s1QM36RUwCKNF2NVpvgEJXYvu1H6D5zx9fLw pLQGS/cb4Fqd3iLCY6snsqPN1VtoYpwR/gH2mQ8jaROgYGcwoJGfKgUNeXzvLTmChuol 8AJLgYqrBRYeAD4gl4Xxe3WJPN4d4PbVTogjmEkrTe1p8VSNUhjZQSeOMqusBtFU+GiS FU3SMWhsCufIPeDXlWrf/YeJgxVhffyWYNWxVDj8MP+3u+ekgqBznhs1m9qgjp59kZma U4MQ== X-Forwarded-Encrypted: i=1; AFNElJ9iqTNsvKhB+oQj6rZIh5LtI+nSFIVTDmBqWw2BvV0lAI0avWA/AFTGr3rv/sNQqkU3GaBASzZiigZbNFc=@vger.kernel.org X-Gm-Message-State: AOJu0Yx3eIysBkdPZ82eiet0Sg0ipmi6Oaps0NngkctjZtw3i5w4KCfv 9RLGSKLm8BiCWQ7vUIXVQ1zM4rSKPpke7HtszYnXoaudEW0oDK6lELIz4t5DsU+8NS6seb4RkNF Gv5bGx6xDnqYFNqNBI8GwUlg08JrSMcIqvlLFygOpvnVep7qzMB8DKNR24eCaxP8us9tNVYCMl8 k= X-Gm-Gg: Acq92OFkjuq0b24npau/UFlAgTEcZ2Qv6VUvjCC0lAxxC+viaTM8Md8cdxG9Yqrxk6I dqjavyftwgzs9xEzQnK1nqnIHFGIAhh51DT3X6dNdcRdQKTVy6QjP9IpK2NmHRqwyl9CbRt8jCN F5RK2cu5BK6bH+cnle119aoRzuiFuJGZeUfo06vPoCB0nu8bet6hr8D8k5i8Y/LTqHDP6bCTs4s R8f/uRbgf8hBovGUIooPgiQZrmNxxwJ95Ll6h2LatJGmqFxeYBRen+u44NHaN9ELC47klqa5T0J V7mR/hgFx/b5rhMSTSOtPPNFOq1vvOz0FF2G9d5+XumQ5VZTczeaBTlrEtHJRR9FxrLQAfS0A4N WSu8Dp8SxP1HHQVt+dX/C5SwBeSh943vim6bNMHfKfao8vSK5VosmWQs= X-Received: by 2002:a05:6122:8b17:b0:56c:db8b:504e with SMTP id 71dfb90a1353d-5760c060419mr9942804e0c.13.1779196538625; Tue, 19 May 2026 06:15:38 -0700 (PDT) X-Received: by 2002:a05:6122:8b17:b0:56c:db8b:504e with SMTP id 71dfb90a1353d-5760c060419mr9942686e0c.13.1779196538010; Tue, 19 May 2026 06:15:38 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45da0a1aeafsm48018609f8f.23.2026.05.19.06.15.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2026 06:15:37 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: srini@kernel.org, lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com, krzysztof.kozlowski@oss.qualcomm.com, mohammad.rafi.shaik@oss.qualcomm.com, alexey.klimov@linaro.org, ravi.hothi@oss.qualcomm.com, mathieu.poirier@linaro.org, verhaegen@google.com, andersson@kernel.org, linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH 6/6] ASoC: qcom: q6apm-dai: add push-pull and watermark event support Date: Tue, 19 May 2026 13:15:27 +0000 Message-ID: <20260519131527.4002526-7-srinivas.kandagatla@oss.qualcomm.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260519131527.4002526-1-srinivas.kandagatla@oss.qualcomm.com> References: <20260519131527.4002526-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=MfBcfZ/f c=1 sm=1 tr=0 ts=6a0c627b cx=c_pps a=JIY1xp/sjQ9K5JH4t62bdg==:117 a=ZsC4DHZuhs/kKio7QBcDoQ==:17 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=YMgV9FUhrdKAYTUUvYB2:22 a=EUspDBNiAAAA:8 a=FoGQ1hqfDKlkNBk9xSEA:9 a=tNoRWFLymzeba-QzToBc:22 X-Proofpoint-GUID: uFDpSx-zHXiL1wZa-xzE4OpjjSxKtehs X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTE5MDEzMSBTYWx0ZWRfX2KUh50//uG5/ 0Rp7nDcJow8ywSRpkbbvFuFYbSFqDaKCy76xqbMDFflIy8dZc2//XG2dF5avfNxQS1QLOXNRVQ0 EhJHVQe7oLwLzKGZo1E+B/0p40cBG7pJqgpNWCeC75U+GmoaJpX2YZ0aFZc8I8fApIgaxNMb5iZ mwwvYZlDjejsJyrcovdHcwa7ARW5EgL1C0D3LRvkhjtC1ip96rdP6I/IC2JDzG50goj1Q1XsMpk AhGt7MmdXl2+sBaw90PdD5hJJc9HC21l+TBrFlS8yeWu+SjJPXNnA+noOxDe+X8VRb67RTzontq ggz1hrqlkZeiRi/Ct9sfKkpsnWhJhltV6NIXSc8XEb8cR9ECQu3Ne2/6UFPmRirkvc/rjt7pUkA Xe9MjFng5lCFq34dB4OTHXJW1bZ8jcCYbeblS7y3IW2w0kwnv0M3b8YDpsNAKwfR8rG6zHxn5IW Y8FZzoAPT2Vnhp/TfKg== X-Proofpoint-ORIG-GUID: uFDpSx-zHXiL1wZa-xzE4OpjjSxKtehs 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-05-19_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 clxscore=1015 adultscore=0 malwarescore=0 bulkscore=0 impostorscore=0 spamscore=0 phishscore=0 priorityscore=1501 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605190131 Content-Type: text/plain; charset="utf-8" Wire q6apm-dai to use push-pull shared memory graphs. For push-pull graphs, configure the circular buffer and position buffer, register watermark events, and use watermark notifications to report PCM period elapsed. Skip legacy fragment queueing and ACK handling because the DSP reads/writes directly from the shared circular buffer. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/qdsp6/q6apm-dai.c | 144 ++++++++++++++++++++++++------- 1 file changed, 114 insertions(+), 30 deletions(-) diff --git a/sound/soc/qcom/qdsp6/q6apm-dai.c b/sound/soc/qcom/qdsp6/q6apm-= dai.c index 3a1be41df096..bf1f872a09f4 100644 --- a/sound/soc/qcom/qdsp6/q6apm-dai.c +++ b/sound/soc/qcom/qdsp6/q6apm-dai.c @@ -18,6 +18,7 @@ #include "q6apm.h" =20 #define DRV_NAME "q6apm-dai" +#define POS_BUFFER_BYTES 4096 =20 #define PLAYBACK_MIN_NUM_PERIODS 2 #define PLAYBACK_MAX_NUM_PERIODS 8 @@ -62,8 +63,12 @@ struct q6apm_dai_rtd { struct snd_codec codec; struct snd_compr_params codec_param; struct snd_dma_buffer dma_buffer; + struct sh_mem_pull_push_mode_position_buffer *pos_buffer; + uint32_t last_pos_index; phys_addr_t phys; + phys_addr_t pos_phys; unsigned int pcm_size; + unsigned int push_pull_size; unsigned int pcm_count; unsigned int periods; uint64_t bytes_sent; @@ -128,6 +133,9 @@ static void event_handler(uint32_t opcode, uint32_t tok= en, void *payload, void * struct snd_pcm_substream *substream =3D prtd->substream; =20 switch (opcode) { + case APM_CLIENT_EVENT_WATERMARK_EVENT: + snd_pcm_period_elapsed(substream); + break; case APM_CLIENT_EVENT_CMD_EOS_DONE: prtd->state =3D Q6APM_STREAM_STOPPED; break; @@ -234,24 +242,47 @@ static int q6apm_dai_prepare(struct snd_soc_component= *component, q6apm_free_fragments(prtd->graph, substream->stream); } =20 + prtd->last_pos_index =3D 0; prtd->pcm_count =3D snd_pcm_lib_period_bytes(substream); - /* rate and channels are sent to audio driver */ - ret =3D q6apm_graph_media_format_shmem(prtd->graph, &cfg); - if (ret < 0) { - dev_err(dev, "%s: q6apm_open_write failed\n", __func__); - return ret; + if (q6apm_is_graph_in_push_pull_mode(prtd->graph)) { + if (prtd->pcm_size !=3D prtd->push_pull_size) { + ret =3D q6apm_push_pull_config(prtd->graph, prtd->phys, prtd->pos_phys, + prtd->pcm_size); + if (ret < 0) { + dev_err(dev, "Push/Pull config failed rc =3D %d\n", ret); + return ret; + } + + ret =3D q6apm_register_watermark_event(prtd->graph, + prtd->pcm_size / prtd->periods, + prtd->periods); + if (ret < 0) { + dev_err(dev, "WaterMark event config failed rc =3D %d\n", ret); + return ret; + } + prtd->push_pull_size =3D prtd->pcm_size; + } + } else { + ret =3D q6apm_alloc_fragments(prtd->graph, substream->stream, prtd->phys, + (prtd->pcm_size / prtd->periods), prtd->periods); + if (ret < 0) { + dev_err(dev, "Audio Start: Buffer Allocation failed rc =3D %d\n", ret); + return ret; + } + } =20 ret =3D q6apm_graph_media_format_pcm(prtd->graph, &cfg); - if (ret < 0) + if (ret < 0) { dev_err(dev, "%s: CMD Format block failed\n", __func__); + return ret; + } =20 - ret =3D q6apm_alloc_fragments(prtd->graph, substream->stream, prtd->phys, - (prtd->pcm_size / prtd->periods), prtd->periods); - + /* rate and channels are sent to audio driver */ + ret =3D q6apm_graph_media_format_shmem(prtd->graph, &cfg); if (ret < 0) { - dev_err(dev, "Audio Start: Buffer Allocation failed rc =3D %d\n", ret); - return -ENOMEM; + dev_err(dev, "Failed to set media format %d\n", ret); + return ret; } =20 ret =3D q6apm_graph_prepare(prtd->graph); @@ -265,13 +296,13 @@ static int q6apm_dai_prepare(struct snd_soc_component= *component, dev_err(dev, "Failed to Start Graph %d\n", ret); return ret; } - - if (substream->stream =3D=3D SNDRV_PCM_STREAM_CAPTURE) { - int i; - /* Queue the buffers for Capture ONLY after graph is started */ - for (i =3D 0; i < runtime->periods; i++) - q6apm_read(prtd->graph); - + if (!q6apm_is_graph_in_push_pull_mode(prtd->graph)) { + if (substream->stream =3D=3D SNDRV_PCM_STREAM_CAPTURE) { + int i; + /* Queue the buffers for Capture ONLY after graph is started */ + for (i =3D 0; i < runtime->periods; i++) + q6apm_read(prtd->graph); + } } =20 /* Now that graph as been prepared and started update the internal state = accordingly */ @@ -286,6 +317,9 @@ static int q6apm_dai_ack(struct snd_soc_component *comp= onent, struct snd_pcm_sub struct q6apm_dai_rtd *prtd =3D runtime->private_data; int i, ret =3D 0, avail_periods; =20 + if (q6apm_is_graph_in_push_pull_mode(prtd->graph)) + return 0; + if (substream->stream =3D=3D SNDRV_PCM_STREAM_PLAYBACK) { avail_periods =3D (runtime->control->appl_ptr - prtd->queue_ptr)/runtime= ->period_size; for (i =3D 0; i < avail_periods; i++) { @@ -317,6 +351,7 @@ static int q6apm_dai_trigger(struct snd_soc_component *= component, /* TODO support be handled via SoftPause Module */ prtd->state =3D Q6APM_STREAM_STOPPED; prtd->queue_ptr =3D 0; + prtd->last_pos_index =3D 0; break; case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: @@ -402,6 +437,14 @@ static int q6apm_dai_open(struct snd_soc_component *co= mponent, else prtd->phys =3D substream->dma_buffer.addr | (pdata->sid << 32); =20 + if (q6apm_is_graph_in_push_pull_mode(prtd->graph)) { + void *pos_buffer; + + prtd->pos_phys =3D prtd->phys + BUFFER_BYTES_MAX; + pos_buffer =3D (void *)(substream->dma_buffer.area + BUFFER_BYTES_MAX); + prtd->pos_buffer =3D (struct sh_mem_pull_push_mode_position_buffer *)(po= s_buffer); + } + return 0; err: kfree(prtd); @@ -436,6 +479,25 @@ static snd_pcm_uframes_t q6apm_dai_pointer(struct snd_= soc_component *component, struct q6apm_dai_rtd *prtd =3D runtime->private_data; snd_pcm_uframes_t ptr; =20 + if (q6apm_is_graph_in_push_pull_mode(prtd->graph)) { + int retries =3D 10; + uint32_t index, fc1, fc2; + + /* index is valid if frame_counter does not change while reading. */ + do { + fc1 =3D READ_ONCE(prtd->pos_buffer->frame_counter); + index =3D READ_ONCE(prtd->pos_buffer->index); + fc2 =3D READ_ONCE(prtd->pos_buffer->frame_counter); + } while (fc1 !=3D fc2 && --retries); + + if (fc1 !=3D fc2) + index =3D prtd->last_pos_index; + else + prtd->last_pos_index =3D index; + + ptr =3D bytes_to_frames(runtime, index); + return ptr; + } ptr =3D q6apm_get_hw_pointer(prtd->graph, substream->stream) * runtime->p= eriod_size; if (ptr) return ptr - 1; @@ -468,7 +530,8 @@ static int q6apm_dai_hw_params(struct snd_soc_component= *component, } =20 static int q6apm_dai_memory_map(struct snd_soc_component *component, - struct snd_pcm_substream *substream, int graph_id) + struct snd_pcm_substream *substream, + int graph_id, bool is_push_pull) { struct q6apm_dai_data *pdata; struct device *dev =3D component->dev; @@ -490,6 +553,19 @@ static int q6apm_dai_memory_map(struct snd_soc_compone= nt *component, if (ret < 0) dev_err(dev, "Audio Start: Buffer Allocation failed rc =3D %d\n", ret); =20 + if (is_push_pull) { + if (pdata->sid < 0) + phys =3D substream->dma_buffer.addr + BUFFER_BYTES_MAX; + else + phys =3D (substream->dma_buffer.addr + BUFFER_BYTES_MAX) | (pdata->sid = << 32); + + ret =3D q6apm_map_pos_buffer(dev, graph_id, phys, POS_BUFFER_BYTES); + if (ret < 0) + dev_err(dev, "Audio Start: Buffer Allocation failed rc =3D %d\n", ret); + } else { + + } + return ret; } =20 @@ -504,25 +580,30 @@ static int q6apm_dai_pcm_new(struct snd_soc_component= *component, struct snd_soc */ int size =3D BUFFER_BYTES_MAX + PAGE_SIZE; int graph_id, ret; - struct snd_pcm_substream *substream; + bool is_push_pull; + struct snd_pcm_substream *substream =3D NULL; =20 graph_id =3D cpu_dai->driver->id; =20 - ret =3D snd_pcm_set_fixed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, component->= dev, size); - if (ret) - return ret; - /* Note: DSP backend dais are uni-directional ONLY(either playback or cap= ture) */ - if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { + if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) substream =3D pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; - ret =3D q6apm_dai_memory_map(component, substream, graph_id); + else if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) + substream =3D pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; + + + if (substream) { + is_push_pull =3D q6apm_is_graph_in_push_pull_mode_from_id(component->dev, + graph_id, + substream->stream); + if (is_push_pull) + size +=3D POS_BUFFER_BYTES; + + ret =3D snd_pcm_set_fixed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, component-= >dev, size); if (ret) return ret; - } =20 - if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) { - substream =3D pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; - ret =3D q6apm_dai_memory_map(component, substream, graph_id); + ret =3D q6apm_dai_memory_map(component, substream, graph_id, is_push_pul= l); if (ret) return ret; } @@ -547,6 +628,9 @@ static void q6apm_dai_memory_unmap(struct snd_soc_compo= nent *component, =20 graph_id =3D cpu_dai->driver->id; q6apm_unmap_memory_fixed_region(component->dev, graph_id); + + if (q6apm_is_graph_in_push_pull_mode_from_id(component->dev, graph_id, su= bstream->stream)) + q6apm_unmap_pos_buffer(component->dev, graph_id); } =20 static void q6apm_dai_pcm_free(struct snd_soc_component *component, struct= snd_pcm *pcm) --=20 2.47.3