From nobody Mon Jun 8 14:37:09 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 72907331A6D for ; Thu, 28 May 2026 18:58:26 +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=1779994707; cv=none; b=pSJazlPTKyOby0MEF4oKZdDgSH6vgsYj0CWwsQ6chCJ1jO9sM9z+EGJwWoQ8H2APeF7cDELjAEUwAX3lJCDLMj1F0cZpHxq79Qk6sGOXeuT23vM1qoY4CE3Nbm3VRtaluY3VlYNSZrWcPHpmDo8l3CYqJ8nQ8+459+DMviuf1jo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779994707; c=relaxed/simple; bh=3uufymgDjrfmRs+0w3ITYF149b9XqCSZt0eWOf3mE9I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uwU5Crx8UuJrvqnsHY1qFTMx3flfWmcjC2QzUYAFWS9+N4yfJyQdWRtxel00R6NI95AanLK9rZhSImD9J6CgbLIQCSvAANhw8R4lEMD1eZYv6PB6d4G8Oi6V+6xCCrBW+pcFtmYIDNjht90g59SpIwLrqE9hHAojPkFUvAe6PNM= 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=MxtYe28c; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=IFMY6UtJ; 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="MxtYe28c"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="IFMY6UtJ" 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 64SHgUPJ4031237 for ; Thu, 28 May 2026 18:58:25 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=ro7jAEZHtS1 9BWp9r4OxQrpxP6WVAcio2xbYmtk4Pwo=; b=MxtYe28cwv0zkdGPJEsb6qzPoD+ 8z5CeY7J/zsfkKhIpIGl737rqTgc8Bcbz0Bv18GaLGzsaQYVh9lBh4fEi2vYRuWK sUCSjd6lTiDcMu5h0eE3hztsJ8+FHQESGn8RR6kap5qD0xsHgzltXScuIJUg+kLm nMN9bK8uBgJvhDatMg7hBt3Dk6uC0U9ADkBAOsd+Z2Xz9PSrh172ooWpRgseBO7F p9U573SOKtzOd2IopcqFZYLgkONp1a8u031pbKIY9EjSo1OaY5Pmrre50T9a/lbo SC1Je813XJXZZpvMKDpzklSEUp00IGUhHjxBr1ZCXeRGW5pX6zaohHCvcog== Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4ee7y4v84j-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 28 May 2026 18:58:25 +0000 (GMT) Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-516d4a9e852so1035241cf.0 for ; Thu, 28 May 2026 11:58:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1779994705; x=1780599505; 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=ro7jAEZHtS19BWp9r4OxQrpxP6WVAcio2xbYmtk4Pwo=; b=IFMY6UtJdynUBzu4EpbggxNvZUvnwEK5t70dpAsz7mLMkkdmojAJum52UFB5o2zAHP XalbiFWe2WtTzNuPhE3lgOK+u/AM9uGxeo2WUsQ6cPTkIP7k9281uHdyJlIerScclUkq M20CXlh+RaUO/CsEOeXTFEsAtTerNh2+xCZxUHsO9gQkLVBT/mxwLHuitetaiNJZeZg+ l1eE7rFDI//JApBy+Yu/67n7bTqgYqKULvPufMB9ecTIZaYx/MOoehP4QHXeUqu6SFEU xgJm4+LDUjBYQhmAu2QvfAl2rWFd76Q/lQhrCW2EKzKekZi6XoguA9qXM/UotSv2Z6Gx 8yCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779994705; x=1780599505; 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=ro7jAEZHtS19BWp9r4OxQrpxP6WVAcio2xbYmtk4Pwo=; b=T7tkjNjMJMlljCj4HncWlcfskO/QG4t86OmMETBbNfP5K6KChjs32kO/tR8j9EZYmH DAWmkHFwTGO/B10f9/Jec9ufbcWFuTMKW0uYwSeWEaVbZOC6MtRyd+u37ADyX9Tngxi9 lsyE2xXlSGTb0xJTX2eCWGn/n+Ce+Xiv1a+LvbHQp+DsQN9vKncI99Ypvruez/FLgOUS uNsjlL6bEgUEUhQKm/wSXnjuVwFRtXULVeOl6/WKfHPXqKb0Q1gqCHo5oX+EErLKYHst qtH9SK8pOF3nqYYwYgiSefjMWhKsva2O/6FtQJSa3xWmN38aA7fzvrSKs5tvG9eVoqg6 chmg== X-Forwarded-Encrypted: i=1; AFNElJ+FXU3C6Quh4ocDcP0Q5hxzGo5/ehJATQHnfmk5xIDEo8XTLxuU1BCc15Nemdmt5BU7RNB4NvwwIdeNCak=@vger.kernel.org X-Gm-Message-State: AOJu0YxZ00UfX50KLUogug+ULiWTzatiAiMnqvlENXzrpBVdsiRjmpOU ZZNuY6L1DVbYzYuzLk/UNKV14DAHbYVGVhsi08cbhm8PKW5VjakeeUfiicbIxC8YPdHAXFbd5W2 mWFTklMAY7WOYNuZMKFBgYaMzdiTRSU1HaehbZJQC41S7K50gD7Nnu1BzK0OKGmkg7DI= X-Gm-Gg: Acq92OEU+/wa+SI+RDTLSB1HQ+AY9tKvr1kD3t2UnHxgksmnxU9WTLCOC7MH0e2QGDS olpjUehlQ9Ko+Yl3z0mGadqUKKuqp1tIBXv/3YgSVlrVR1uu4+McXL5bTX/4I12mCiP5iiWpj6g c9WfZUJHo1JTu82iKLgK8+sHO4ZdBIVygJEL/wsr+m6PhP0KJnYtWOe6DSzpbv0mLtTT0xITkqX cudaPn+etOQa3TzVCqKQtkWGiN57Q17M9cKDCqArFhcR2Gd/wadSpVykVfcH1h4Y+xZ6k9n6mzG ZentQYEei3SeW2ezP9X2696LH4QjU42LYrYH6dtyPiPjB/x47Bvw1QVqhG2tEpuDZRtdkGG0nYN 4NJ+nHRovl2pICuX5MXIDq4yRz8TtfbzDKYSQLOF7CWmqw6zGx9OIPmC02kCVqHahHNjQDw== X-Received: by 2002:ac8:5808:0:b0:509:3940:30ea with SMTP id d75a77b69052e-5172ce1899emr239911cf.55.1779994704838; Thu, 28 May 2026 11:58:24 -0700 (PDT) X-Received: by 2002:ac8:5808:0:b0:509:3940:30ea with SMTP id d75a77b69052e-5172ce1899emr239521cf.55.1779994704324; Thu, 28 May 2026 11:58:24 -0700 (PDT) Received: from debian (71.248.69.85.rev.sfr.net. [85.69.248.71]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49099feef7esm3107165e9.0.2026.05.28.11.58.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 May 2026 11:58:22 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com, krzysztof.kozlowski@oss.qualcomm.com, alexey.klimov@linaro.org, mohammad.rafi.shaik@oss.qualcomm.com, ravi.hothi@oss.qualcomm.com, mathieu.poirier@linaro.org, andersson@kernel.org, kees@kernel.org, verhaegen@google.com, linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH v2 1/6] ASoC: qcom: audioreach: use cached shared memory module IID Date: Thu, 28 May 2026 19:58:00 +0100 Message-ID: <20260528185806.6316-2-srinivas.kandagatla@oss.qualcomm.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260528185806.6316-1-srinivas.kandagatla@oss.qualcomm.com> References: <20260528185806.6316-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: AW1haW4tMjYwNTI4MDE5MSBTYWx0ZWRfXyLZD7eE0Ydxl F5H5JCVKHAIXtTlr5cHjQ4oKEqoN25S0a6YdFQUpmV8hV9ecTmTESHeAuMLu+0k7dON8JK258DL 3n0sKB/RNDN1XnzPcdd8+WesBPHQT+iG+Y8SjRdcV8UlvKbSvzwHlRc12zDOvncaULAmE1H72a4 7xUEcqQQ86waKT3GUxy2WKX1oWl6DcGrcEpZXczYyJZQqKW52pcJpswiWaaFLCIE1uhsDlbhmaK 0wXuFzLxk0EwSCqEhLMWn/MNZnCFjvJGtOg+05ZjGSNqmIusafyA4o666Id9szv86044nRpjBWY Ra/vtpHdMGpcSDDPOedofxZnzoEYFqsdZnio9vNp5JfjnVrlb9T9LLU2JAKH/nnW1dLQ3+9e5KY 7yXWXqovpZoR7OIP8ZUbPNcO/abaNUkEzZKMigU5YFO3g4VnPjx8wxoTYqQJQ74n0O00Heoxey3 jSx7dl5k/eOStkeCPzA== X-Authority-Analysis: v=2.4 cv=feidDUQF c=1 sm=1 tr=0 ts=6a189051 cx=c_pps a=JbAStetqSzwMeJznSMzCyw==:117 a=hLrqdhl2Yb02WBc7oxehMg==:17 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=3WHJM1ZQz_JShphwDgj5:22 a=EUspDBNiAAAA:8 a=IKYrml1x1okdUiGWNaYA:9 a=uxP6HrT_eTzRwkO_Te1X:22 X-Proofpoint-GUID: IrmuYVSeqG3Ex4H_CxJg-qNDSlJe9naN X-Proofpoint-ORIG-GUID: IrmuYVSeqG3Ex4H_CxJg-qNDSlJe9naN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-05-28_05,2026-05-28_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 spamscore=0 priorityscore=1501 phishscore=0 suspectscore=0 bulkscore=0 impostorscore=0 adultscore=0 lowpriorityscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605210000 definitions=main-2605280191 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.53.0 From nobody Mon Jun 8 14:37:09 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 0093433120C for ; Thu, 28 May 2026 18:58:28 +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=1779994710; cv=none; b=ky9oDFn4iCay+0zYAp/jCQL5k9x1OYhDWPiI2LYNGOMDg0PLPEK7ssKDGYPZfPZk5eCls5Jy2LYW4ZDLPNMpCBHOLVT2NbyT2I+m/mmOD6AKGJ0ph+EcZR+zS3PTW8BelrjPOnbIUil8lEgAnSK9P3LQzmyYFgfTTjYvq1udAR8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779994710; c=relaxed/simple; bh=JIyAc8HzCFIctpaTaYCtShxqBl5dQxTPCA8RyRIQEs0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Nb980bQTuQTrzdULo8DZ+gzFQfliV1h2iw+qmUMpmWg0q1AExx1pKy5tk1siMBCXt0Uf5FU4EVxK7uh6lEzK4TxiVIiOs2STCaiN/Rypf24bORfxzjkJMBjotfydTqQoLuKH/fSxMK8qh3/tc881AwpZxMHhYrK1EBSN9XOgsyk= 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=kbs2VywY; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=KYwKajLc; 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="kbs2VywY"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="KYwKajLc" Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64SGh9QJ1562576 for ; Thu, 28 May 2026 18:58:28 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=jYL+Urw2JHq HhWlEtb/v/2zPyR0WLaQqmSD+Jj+rY1c=; b=kbs2VywYzanl0V4veyQlgkKDouG D1BawuHqwYgQAPBbwsNxQo8vy1m+Pfb9eXlUaYTO+VmlpjAudfsQvbMYEIJqIV0T g/O1tHAxzzSFy+kHtWubAPTGWEhBmar/byXarA+ULtiPQ1huMY1HuUSAP3Z5sbhK ogtYEWKo3/PP2EnVdk43x4sZiDB5UeU5JaRAUdbzBd/1GPpbIpS0qqwcXBpRHm0u AT3ijRV+ykxjqME6LXt1nK2iQnyfvh75lnyGALruaThjU14QeRfMYLPWdzABDmNS lSX6b/rMJ+9AbE69Oph74qE5bofZQbkd+JFIYwcy96NmPGuGwSpzBROIttg== Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4ee7y2v95t-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 28 May 2026 18:58:28 +0000 (GMT) Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-50f13da9684so159048061cf.3 for ; Thu, 28 May 2026 11:58:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1779994708; x=1780599508; 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=jYL+Urw2JHqHhWlEtb/v/2zPyR0WLaQqmSD+Jj+rY1c=; b=KYwKajLcbO6coM1hcCfJ4L1jmVXLIEJs1Qf/isnQYNWE6Lu2IiuwuMHErBiDmiRSNe rhe/BYz5lKfZhIWefOlSLQnCprbuGLwYnnm/6C9YumGiMUR9QshM++Nh5RPA5raP8AXD od1KVZDx6ALzUhDGDx0TM4h9yyK9hoz1n+loL7LlFemd5gXahF9N4oGmmFaMTWzm0rf+ o8DKxHQcy98mGBP92nioacw5B+eGsViB20C2GKqhsAPmPD55hKvEb0XW6+EQ+f6JzG39 DdAp5NmEbezHoEViySmSCeTVbiE/oZJZDEDNX5i4ZxtjFhy5bPZoOWMXmRXXdH/uF0cg /kBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779994708; x=1780599508; 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=jYL+Urw2JHqHhWlEtb/v/2zPyR0WLaQqmSD+Jj+rY1c=; b=car6HXJjszrQLuVVUIezSUi8bVV0xLJZ+gt5oPx/9drADuE5m9QDnu2qIQNDrsytQP YNLSpf3/p2uLG1KblDdeO3yQITx0CLfN86BsiOGM3EiI0QNEyHvuACAMw3nMlM+1gCaw 05rGPznHU+f0tM/KPiGElqPOYpjbdsEGVDeb/S3h+dHce+2XKG8C0v8Jg5vbmFel8hX0 p+i3qK3urkMLMgI2NFImigVRy9IoUOsSFdHEdGC1LFQYcLreMJZw5LbK2/0Q1+BnkyAM 8Q+lRSZO9NrI1qoynjJKYMnleDPYNWqGHuwHtnzY+fJQ0sKLDwSOHtd9YR2xyicnJe06 8PpQ== X-Forwarded-Encrypted: i=1; AFNElJ+aVhOpgh3jmltuSnqw/Qyb8aF9FziSUrpbUDtMSpmufG7o77KhqUcDOcMNNSMyhl0CwjjDhtTVX2WCs9k=@vger.kernel.org X-Gm-Message-State: AOJu0Yza6RWU7O44k6yO51DKq8oWgv8O2Vo96bO2FwY9/fTswADoU++K vHwN4cQB1DmGzIrJeAxqjHSKAd0DwuhfmD3b0ENRGy2wQ2jq4lfXtJyAMcU/8PKXWWVCQ9tkFSD olBeJDe820PsgHk2//9b7Ic0XTcxckpxw/takQHr82FzyVmxGxqxrwC5ZD7MLJAffPHc= X-Gm-Gg: Acq92OEm5esoI/wrThXngALYD76xeuuJ8Te2tMPKwTn8Li8ZsbushsKy6R+jmeQtR1h vJacpQQXZIAl5qTS1qIdcOfVBK5buov42AJ7eFAi6OoN33HdRPuUeviaLKAtfALFWOg6vnlf9MX toyH8rYYDILFV5rKHkdOeCYp/R0Z34kBtkA2QH8WBRvox6d2BypSnoTk3YwNLLpciUHsFfOEplO izMrq+hg2PZ9oUw/l8nav4Y48B94B4amE3UgCM3H9kWwKHbvaTckm48OrFqJw4CJzh4K23yetRO ZOvwvRi0XSJtaPzfaZGkyV1ec55XL6MWq7OOipnxvdwZNtRzthxWWzaFTwNkM8OeMi/XJhYd/vR +/OQRTfOv9gIPktjVaoL2N/Htpr/l+mY2hQldYofU1j/YKm5tQHioGHvAyiHVp9C3UpjYIQ== X-Received: by 2002:a05:622a:40c4:b0:50f:b904:457 with SMTP id d75a77b69052e-5172cbd6423mr1002161cf.25.1779994707596; Thu, 28 May 2026 11:58:27 -0700 (PDT) X-Received: by 2002:a05:622a:40c4:b0:50f:b904:457 with SMTP id d75a77b69052e-5172cbd6423mr1001741cf.25.1779994707084; Thu, 28 May 2026 11:58:27 -0700 (PDT) Received: from debian (71.248.69.85.rev.sfr.net. [85.69.248.71]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49099feef7esm3107165e9.0.2026.05.28.11.58.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 May 2026 11:58:25 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com, krzysztof.kozlowski@oss.qualcomm.com, alexey.klimov@linaro.org, mohammad.rafi.shaik@oss.qualcomm.com, ravi.hothi@oss.qualcomm.com, mathieu.poirier@linaro.org, andersson@kernel.org, kees@kernel.org, verhaegen@google.com, linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH v2 2/6] ASoC: qcom: q6apm: return error code to consumers on failures Date: Thu, 28 May 2026 19:58:01 +0100 Message-ID: <20260528185806.6316-3-srinivas.kandagatla@oss.qualcomm.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260528185806.6316-1-srinivas.kandagatla@oss.qualcomm.com> References: <20260528185806.6316-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=VeXH+lp9 c=1 sm=1 tr=0 ts=6a189054 cx=c_pps a=mPf7EqFMSY9/WdsSgAYMbA==:117 a=hLrqdhl2Yb02WBc7oxehMg==:17 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_K5XuSEh1TEqbUxoQ0s3:22 a=EUspDBNiAAAA:8 a=Kj_hsjq-VXR9WAeqRSUA:9 a=dawVfQjAaf238kedN5IG:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTI4MDE5MSBTYWx0ZWRfXzndEFqaxSLF9 o1OjL6nzDWudEEdYLPdaS4dojoJTAENHHb1Cv+Ft52TxlAbllhs/i9TRig+3eYZsMy5x+n9kilv WLYh3p46xLLlruiHjION7kYdzAwgbBhdLnDBFp4dKfjEDGkmK+sMnZ+4oXKbws1mXclq2Zj0cqD fuyjQqP2Rec6Kur3DjmH0MDyW/prsVBNYRtc6S2P/x8oL9qQBAPrlYDUtA2hLPfgA19K5T9zhUY mg/HbMW513QCO2AiELYLMjbxR9xvKTnjfNX9UbB7mkpWnDdjb3TRkgc8DFZYy+NLLua3zEGHc+o 66Fr6zqti5ua9RBNOcHUEl7n9KQ+oxEnnravWfIiF/Kj8PQimBEM0rdZ3GpvoGRQ2+4GSRd8qbi wRoBwngmmYXKUEsr8QPVBnf2OksC7w== X-Proofpoint-GUID: bZHXnuJL0KY7yjpwpaDpEPRFE6AZjVT1 X-Proofpoint-ORIG-GUID: bZHXnuJL0KY7yjpwpaDpEPRFE6AZjVT1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-05-28_05,2026-05-28_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 spamscore=0 suspectscore=0 adultscore=0 phishscore=0 lowpriorityscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605210000 definitions=main-2605280191 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 Reviewed-by: Alexey Klimov --- 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.53.0 From nobody Mon Jun 8 14:37:09 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 5E80F330B3B for ; Thu, 28 May 2026 18:58:31 +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=1779994712; cv=none; b=BCykk9AZxpH3I8Oa64vI/vcxwTZFKBNyHd7bg66zRGzLON4p+3F+xJTAgVV4fYveV8fYXPo7lK0BllGyyuST4rw6HywNRigiByQwi4RjCr4Gz0QMTFQ+lUfSZMlbFuuMAZL62Hu5H8Pd3JhNvJsiPGuTjlh3RaZiUDCq0jfuPV4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779994712; c=relaxed/simple; bh=CXlj9K23mR8qPUX3PeSAShFKAdclQLFGUkSjy2wEbQQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MKgcchKOYUVYjVcG+tWWzS+eGhFwYzEa5t8y99xeRWJ6p9zvY6tq8/B3f3thnGxF16YPL+9deQd0jEsPjeMOVPkv/T5eu8W3/N0z4dQFlEK1vZvdug35w6WeJ6cDL0lg6EVXQpjGqkuDexKs/JgDI4H7lD5opd2qlHh55R6GVwI= 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=BaJljEms; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=h6XV/iG+; 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="BaJljEms"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="h6XV/iG+" 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 64SGw22T2753284 for ; Thu, 28 May 2026 18:58:30 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=LT5tF3xgMpv qZXrzTVKQeff3Id1ajAsfnsR/quIBRtw=; b=BaJljEmsdo483x8J22C/4LrS9Pp T4IPr/1ARn+M3RIw7ucrEOxcA/8i2cMRkBAk7YWvL316JOferUiJay4Y5ILHyZmY bR2ca6uj7uhlebcEx6HgNVj4Tt0jrZmc1YWwCOkNM4pzQpSI9C7oc6PCz2U5K2er a2/lrCz/jU2MoauKNRQ8jIWYwi5Me8o522vfmMM7lVxPtuLzfoT3cJRnsSrE1CwM Pzqxtx1uRGN4TF5bRNnKsIZ+6xUeIrcvEN5bcvf/Q/lVSmbKlMKbffcuCxLRi+3u uAoddxc3+ruXcZNfN7wrackR7T5c+v+UWjseSIb72ZcUziiFnJnFV610EEA== 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 4eespn0fb9-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 28 May 2026 18:58:30 +0000 (GMT) Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-516e0846095so106387531cf.0 for ; Thu, 28 May 2026 11:58:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1779994710; x=1780599510; 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=LT5tF3xgMpvqZXrzTVKQeff3Id1ajAsfnsR/quIBRtw=; b=h6XV/iG+oNzQHQMJ7VqWtl7RHlbOZ2SgbQODqfM+fUdDtCcjk199aiqWi/7ZPOmgvk aSnOJltsR+9nfTJ0YdrtIq0LnZ70RYuTI01dibVTiWYxAWyFeLjfvC9d3WLkJjJGYEGo PgvLQa+z/daLfZ7Tk3gyZF94mv5PGwf85hokC/6qey9tTobZC3p0evL2LbJEYffHgwTM 1C5AEzUvTTaEowgjFIsreNy7KYjX6yC4LtC+l3lMzhLdx/ZFrUCOKAImCOuqZSiIRXi/ RnQKL1H3KoH/rLNiaX+SPWW5EviZ1vrhFuSav2QySEnLGq3ibYLiadLtxfA+OORAkq2P dttg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779994710; x=1780599510; 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=LT5tF3xgMpvqZXrzTVKQeff3Id1ajAsfnsR/quIBRtw=; b=UxgIplaQj5Bu3A44XxF881LGaUaagf/So6AviLANJDILIWFwRReyJv7IPlino5FFwC Nqkxc2psGYTLWo5N8mvrDWpmmNjkh1vRWx/iz4aqq6M9RjHwyzfhCiATkHRXbhKsjxlL ddGczLIcUUWGQnCphPVKXxzrBWOuYwbIQ3DomLCM4NhhzAplafF8vEQZBcx33UWxBnzr Jkw59vrEYjWO7f95JQGq35ZG89XlwDgzK94/Uy6mig7wMx4Q+CPiDXedv4ITBLKBsWtJ 287zmzkwgaIvt8p2nMf16BdzQej5FPjxRcPwJ38WSeHdNNeEIojcRw6YV3wymHR0KKec xSRQ== X-Forwarded-Encrypted: i=1; AFNElJ9AWj4dX7JtKdoEbLDPCkjup+037ta4mnUkZv9RfthyjiHcwZUELKglsbTJcyQOh9yhWtfCdrcsswylV8s=@vger.kernel.org X-Gm-Message-State: AOJu0YwSTFBoy+s2/ULzjp7arTIwgKnu0MtEpW1F9FKH1GcRN5WbdpeN YTfuXgz21viUeAYo2nVlcc9IPFiIsvIlZcd6xFYHk3xDEm+WkXXs5oxc5MPhxRUOriCxYqbtO+b 9nFixNd2oeSYDtyappxlK79jvFKuwETaCIY1tR8gczpjCfAHStFrwNNZXaU9nH/lDsWU= X-Gm-Gg: Acq92OEA1eN47RnmJ4kxLKGFjOkEIEuS1I01xQP9wBtIENDhwYGD8MPXgthAkOsIRpM V07fqC/ayxa3gEhBUnd2MMwdNJEAgFHQqie5Sq1s+QSNh0qZ2OeyaAT5rmgyTDbuAiMdAoRftcI Va4zm4KSRZuaEt+8nYAZyrMjDOtN/52dp0Va+8auNTNUMt7pUxPDO/q+DraFvwT6EZ+6BANrXgR FlaTqfI+3ImXhrimBdI3knD3Px/+rfcVz12rEkL6KXLXs7NcvDXEq/qrCG5PTFI0XrasM6TCroM APwlBHXwoVFbz/KOhPP/s06l0r+XfzbiWjDKsFbm8wcjHEzhDWdg+9wB5EapMYfefffEU/8NnYG T3BZHOypzzhkyQHFn0E31p4UyhRJNgLKguEwZY/M7u+Y/64DKEtzBToqq98kuHm6kE0XR+Q== X-Received: by 2002:a05:622a:6182:b0:516:e1d4:5541 with SMTP id d75a77b69052e-5172cc88c21mr847121cf.37.1779994709708; Thu, 28 May 2026 11:58:29 -0700 (PDT) X-Received: by 2002:a05:622a:6182:b0:516:e1d4:5541 with SMTP id d75a77b69052e-5172cc88c21mr846761cf.37.1779994709314; Thu, 28 May 2026 11:58:29 -0700 (PDT) Received: from debian (71.248.69.85.rev.sfr.net. [85.69.248.71]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49099feef7esm3107165e9.0.2026.05.28.11.58.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 May 2026 11:58:28 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com, krzysztof.kozlowski@oss.qualcomm.com, alexey.klimov@linaro.org, mohammad.rafi.shaik@oss.qualcomm.com, ravi.hothi@oss.qualcomm.com, mathieu.poirier@linaro.org, andersson@kernel.org, kees@kernel.org, verhaegen@google.com, linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH v2 3/6] ASoC: qcom: q6apm: remove shared memory IID helpers Date: Thu, 28 May 2026 19:58:02 +0100 Message-ID: <20260528185806.6316-4-srinivas.kandagatla@oss.qualcomm.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260528185806.6316-1-srinivas.kandagatla@oss.qualcomm.com> References: <20260528185806.6316-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: tEaYaWI-qK5K9Dmlt5wuezB4Zjyb7xyV X-Proofpoint-ORIG-GUID: tEaYaWI-qK5K9Dmlt5wuezB4Zjyb7xyV X-Authority-Analysis: v=2.4 cv=auOCzyZV c=1 sm=1 tr=0 ts=6a189056 cx=c_pps a=WeENfcodrlLV9YRTxbY/uA==:117 a=hLrqdhl2Yb02WBc7oxehMg==:17 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=Um2Pa8k9VHT-vaBCBUpS:22 a=EUspDBNiAAAA:8 a=j5C22CDG7AQ3G0DocvUA:9 a=kacYvNCVWA4VmyqE58fU:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTI4MDE5MSBTYWx0ZWRfX8t2W9J8tuaXw 8qL6d1d+atZqUWogl98q8P0rMMD/HQdeg9qDg6F/RzQH4jq+U0GuhKQKLILSvm9JQ69IcgLd/ct yp+bEXzSPl3s+BfGSxz0QArNP2qBvkKqDQZASB43FAkgjLMYQbr1opLhTcDkV0wnUyMzCkum+yt 5ZTFRHbXS1o8tIqjahJeEDgxMXD/Y74gJZamm7i4eR6ej5ObMR4cKcJZ1Bk8vUdsAId5kKmvTPQ q/WaHggLZFzoE5oMDwXOGssqRk1tchPigaCe+m/AW03gVHjX3uCA8OW46SH+dv38nIkMKIjAG+x drXDc48t1vtSoVmoV0qJmvoJdb0rAXXR6EDUrVaZvZ/fzrueyAnmLJpBeDwg6dUo4XSARuBtHGX Fz/gpnXLtgRDcnDUtGUy/9+vITSt+zeb5evRLMb+F3bUBjCzEkhAdpL3fEGh/Dl5Z1XF8PGIeYP RYlQ7cQ3pB+hLUjUNBQ== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-05-28_05,2026-05-28_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 impostorscore=0 bulkscore=0 spamscore=0 lowpriorityscore=0 suspectscore=0 clxscore=1015 phishscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605210000 definitions=main-2605280191 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.53.0 From nobody Mon Jun 8 14:37:09 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 7C30A3368A4 for ; Thu, 28 May 2026 18:58: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=1779994721; cv=none; b=S+vkCMGs8NrrK3jnXtcWUm9vS4Of6qfpE8HDb7uXEdWAcJfIqs4LAXBBEpGwDDFOcjsjexCYdvQqbEcFGyWeQ7Y+zZWMmLoxYduZpGPr7WfjG+0nvVC7ZQrzzOAKeMBJhQHmydGGS9R8NQ67+FDp8I9smM0puvvObsdg5fOQdlU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779994721; c=relaxed/simple; bh=ApaDNDS3C7+IsYBvmZYT4kP7WppNyNcjdG1Ib/IIE9w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jABZ2BmmHyPQQBmjPUT9OpXDOHZOTBE5DEPehFNtYr3G1YgxrdXj7UAPoXjQlEu4dksPyLhQX+V6w+k8vcryEbydXTjgoKrs8mmJKpkDFWTI/Jvyw1Z506DMieJEtGG1dxT92gnUFsMBXbfZH8x/7nyCd9JV/4viLt0CvQrAg/g= 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=NlImDt/O; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=CFeQ9Y5w; 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="NlImDt/O"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="CFeQ9Y5w" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64SHNpn23203243 for ; Thu, 28 May 2026 18:58:33 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=uxel72aCS7k ulDd81/nJWJKhmII+A/lNBec0BYNUuME=; b=NlImDt/Od7BMoDyWcOr8sIrTm9D R66+3mnrKs+whiRgFLJuL5rcdB3X3nhdiMNrZMLm35V9kz5TjD1XRHtH1EQcQglW 2KRBcrDjLiunQPGhz2A57A5B2YA/FFnIdnLV3GeuRLM4V0t+fzPh/zFSr3Dm2FaT BZ7ne0atpGqNYUR3ty1tS0+fkEcsOXLO78FCQdc9zmJwQ1ULWHysq9sPQp+FQMgM o2tEbn/qZCoZ9pzR2wpmj5jlVD5Tkb8C/SD2ufRDgS1RDIyYEnuxb04nkCOuAjmy GjMpBhSwYgCVJGu+92DuXwwp49gL+zJnxyX0Vjmc8ecMj8I1oiD0jIJ209A== Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4ee7ynma7s-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 28 May 2026 18:58:33 +0000 (GMT) Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-516dd6e4ed4so131982781cf.0 for ; Thu, 28 May 2026 11:58:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1779994713; x=1780599513; 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=uxel72aCS7kulDd81/nJWJKhmII+A/lNBec0BYNUuME=; b=CFeQ9Y5wROI6BJ9/ZD810FXzEJYbqaC8gYy9nRDTs3rg1Lqxc2nRHqY7C9xJzK0u1b Xenw28GgSVIxn80q6d4y/wS/MUXb2mROXKDuLW4UU8Bjta7GtJgTu+e8NcakcTh04ZQh Khu0+kn9xxfYgcKMjNDWCZmq3ZfR708njj2OQqKBd14YnEPep+Qvs/xvX7LxlgcCk0RH jdcE7cr+XKPFPIimHeaZ/YdNkXE/HqEAQN67geE7pGFD88zAdRgy0nPBoF6YEJUxitEQ X/dpfZnHH/kYLkegbn92lA04LCyY7yTcQYMJksg0epv5frra1v010Awk4wcFg2eCSPZr w/Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779994713; x=1780599513; 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=uxel72aCS7kulDd81/nJWJKhmII+A/lNBec0BYNUuME=; b=lnoABahsLRqzaqi07C8CeWYPrSFMcTIYs3HZVZ/HKTQDP1LQ3aDyVWqy1BPbIANTv7 VZT2RIT6c3y9lXDgJaing+I5+Dphn5HMmMZjW+elwtF2/ICo+YEm6ja+RdbzTKDVWUcQ A2py+89HpPkHSXive5dl43xiRxplTsMMh5N7EMsoRSvczuvdxE25LnQ8/lwCXsxiUeJT 5PBDQKbmZj8qGvgvmWftF5uX5PBXKG93uirK7CZPC/tPbCtXJ960LgfpGm5YWjblr4EE KiWVwzhRzSAtaKCIiRqHz2OtpWpmhQV2EtjgEKtNnblKEzfuBKjPGnDNDzKpySQUyvG1 lvFg== X-Forwarded-Encrypted: i=1; AFNElJ/oRuKFWilkB8jFdliMaXONs3Y3UXf2a4Yeh0tTmvHqKSNnXrWpE8Oas1j8mCMYw02phmp4On3/81XXW3k=@vger.kernel.org X-Gm-Message-State: AOJu0YyD42kML0nzAG1hB1COz21Z9mhZ5sw67+e/jc4rvEsmf5G3PfkD vyu8gGGCeynsKqGeC+PPNNcTBKY5LqI5IMje3Rph/aKDR6B9hLtRdoyb9YQTAEBhJLHY4tEFlxI 2/9dxHmQz06Z1tPsBlDZX6NHRvzPA8bKpS/7vYDnV9Yh9s9CoWfoDlfZ6v/YtAcwFVzE= X-Gm-Gg: Acq92OH1+fquoim6iN6adbNpBXPO/Yh3MOR/vajsR0Mg0w7N9+U3bPxFhRJbUPEMnCZ 9s+y8RSeRg4T+tLIZi0WodgckjIVofMPpxw+QU//sk3GU8/FuqkzQnGRMeR/ik8GS+toAJjnDYV 94xy8HfNquY2bxuXSj2Dgp2vChNTYqG5lFuw4P2oK5j5WpPmjd4ZuzySfk0auooU8jO1ECKU6BM VPHA4OUZnzAoXMiXU3C+JTgWXBsgRh8uW/HTQ4H0eqZAKtBZb/rQu+Bh8vttF9q34qW9QJ4BVw2 nwFbNUHhvdyxSsEYIPcO4pj0+IBrSc9SQBBgzVdTxb2PHPqJH17g3n6XbQh9Cw/0adNzpud95nb 9Yfu1P4MoLs8b9XiR1FfHbwOtXciWvOye91krq7PVdJBeUU/0fmknu+v5FAlVCaFoZt5AYg== X-Received: by 2002:a05:622a:418d:b0:50d:e471:2d1e with SMTP id d75a77b69052e-5172cd74b11mr502731cf.35.1779994712363; Thu, 28 May 2026 11:58:32 -0700 (PDT) X-Received: by 2002:a05:622a:418d:b0:50d:e471:2d1e with SMTP id d75a77b69052e-5172cd74b11mr502231cf.35.1779994711863; Thu, 28 May 2026 11:58:31 -0700 (PDT) Received: from debian (71.248.69.85.rev.sfr.net. [85.69.248.71]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49099feef7esm3107165e9.0.2026.05.28.11.58.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 May 2026 11:58:30 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com, krzysztof.kozlowski@oss.qualcomm.com, alexey.klimov@linaro.org, mohammad.rafi.shaik@oss.qualcomm.com, ravi.hothi@oss.qualcomm.com, mathieu.poirier@linaro.org, andersson@kernel.org, kees@kernel.org, verhaegen@google.com, linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH v2 4/6] ASoC: qcom: audioreach: Add support for shared memory push/pull modules Date: Thu, 28 May 2026 19:58:03 +0100 Message-ID: <20260528185806.6316-5-srinivas.kandagatla@oss.qualcomm.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260528185806.6316-1-srinivas.kandagatla@oss.qualcomm.com> References: <20260528185806.6316-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: AW1haW4tMjYwNTI4MDE5MSBTYWx0ZWRfX+MEhRMS9MGki f0yQdZGgnGOvt0jTeA1/mF8FX87WKUgxuHATmbiGDlKdbY01rPBlZ6qSTBMto/O6AobknT7fZr8 +V/0Icb1pi7lNkZ+GJnFdw61TxlNxYRrBYL4Jxjc5nFTZuQO07RaLvM1m8F8b4u4FemXZbTkCkM rDgR21ez5TilPXaqbcW6x/oWeYqk2d8d0M0WncQ9ek/ery/1slF9M/3DJQMqWbDqMChIB6XYw0w dR8dYD9VOsCrPAYSdvV+CgaYwYLZaXiILKvZibgt3aXhVauPwO8wCEBQj5d51HgwcKrSd0p2+ZK 4WU0wsYGS+LrhT3K305yO8mjDLKLVlhQk4aL91NRcLjCdy9FIchaFrrt9o/MnkDdxqQGfbz5Yys HYhYCVLPmUYQIco7Uwb/0L4Sm2WqU5cldHjiOP6AP6LkoaZVTNh4oKdQ0uOZ89rF8zIncrPxccH X4B7t7tHT79O4W+xpOw== X-Proofpoint-ORIG-GUID: FfjbmznTYWorEH4BYzwVtfN1vxA4l-wt X-Proofpoint-GUID: FfjbmznTYWorEH4BYzwVtfN1vxA4l-wt X-Authority-Analysis: v=2.4 cv=EdL4hvmC c=1 sm=1 tr=0 ts=6a189059 cx=c_pps a=JbAStetqSzwMeJznSMzCyw==:117 a=hLrqdhl2Yb02WBc7oxehMg==:17 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yOCtJkima9RkubShWh1s:22 a=EUspDBNiAAAA:8 a=eJp2UY_-qWcN76HEE-cA:9 a=uxP6HrT_eTzRwkO_Te1X:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-05-28_05,2026-05-28_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 priorityscore=1501 phishscore=0 clxscore=1015 bulkscore=0 spamscore=0 adultscore=0 malwarescore=0 impostorscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605210000 definitions=main-2605280191 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 | 51 ++++++++++ sound/soc/qcom/qdsp6/q6apm.c | 158 +++++++++++++++++++++++++----- sound/soc/qcom/qdsp6/q6apm.h | 9 ++ 4 files changed, 231 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..b85c7e5b085e 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 @@ -61,6 +63,9 @@ struct q6apm_graph; #define APM_CMD_SHARED_MEM_MAP_REGIONS 0x0100100C #define APM_CMD_SHARED_MEM_UNMAP_REGIONS 0x0100100D #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 @@ -710,6 +715,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 +768,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 +902,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.53.0 From nobody Mon Jun 8 14:37:09 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 3984333262F for ; Thu, 28 May 2026 18:58: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=1779994720; cv=none; b=uxrBbnyWmyFzRiZnTqrb2G3sEigYJuQYOdstSzwu5DHCBTE64vyryTgM8TaG6IAh3mxl2WWFjTZee0XN9oVmMFpIWPKyqVBoGRyF99UoSvm8f9xfqhz5E43XgkjOfaZq7VZAqyuoidEZv7TqULdCTjQ/MJ88tCiFrr6i2JPa/Gs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779994720; c=relaxed/simple; bh=qLUhuLwVPjChuycrUmttdHPf8StA0wYdTF9zQMVxxRk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=B61rWRERxWwqkHO3blJvsljxcAB5swqEhUHnqTJiFjGjNQFSgAkUDHHGn63FNbRLpj0V9wIi5Bzlwm+U52n2ufhFpHpGV5G2AjLBpd51ugjshD2h1pUcge0nvupf8NpW+aikFDsSJt/1jiL1jUr0Ir1SUby4Ca7292HUJJxn1Ys= 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=CArtEfJc; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=ZCEQFu7R; 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="CArtEfJc"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="ZCEQFu7R" Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64SI52ZL2794043 for ; Thu, 28 May 2026 18:58:36 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=MgdLusidFaY 6ZcoM7gj5BjToDJmFX6Csm44/ud8xC/w=; b=CArtEfJc3qrUmGbhNOt8TTeLmPb fCr4hCPehv2WXXHBP4vdx3q7V190yGEvKq+glc5R98eSoU4hqbC1gSseexNUYdkk ecKzp/ds2Ps1RH4hSIBbRdou1zVDlmLaHOiOdu7qvelaH+iZkD+knNrq82PjVSIj JoWVGAQwAZ99qcwVuDVLYmPZNgRVAxQuwkwIBA40bQ/6o35biHnKu/GHhWNQBcmQ gjmVazZCqIzqEPrC2xk/w0Yyjecn4ciFNVOs+0UUimTPE4KfpgsQpgwDQZQUvBcq +93h/WwO/gBqxQIWH4Lo0O33Lxut7k0Af8dWaTUUiPK0omx1qKNIGT02Urw== 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 4ee7y1v9jv-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 28 May 2026 18:58:35 +0000 (GMT) Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-516ccfa109dso142694741cf.0 for ; Thu, 28 May 2026 11:58:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1779994715; x=1780599515; 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=MgdLusidFaY6ZcoM7gj5BjToDJmFX6Csm44/ud8xC/w=; b=ZCEQFu7RwkPs1VmDHjb0+FE3vas6lEawxGo5buAXcLws9vnwQwgF35gpJyQhiISt3D sB8m0A9Gq+5FJcka+mber/rs+DOoWsV3TxhnY+6bhIMMJiS4TT9rTY+Ziy3ZnJy2X4QY dbxGp2KD1fZ51pUhCjbfTFbZZz1RmNFFa9/VCMieC7CeVIAh/u5I5A47B0mOE8adMHvl /irRWHeauygUgL5qlsZL5rtkjN2S1MJJr6svygbL9BuwGmqbvdjVsuefwwDppwxjZK3k xG5Bz57FcPj+pSnnL7zAWIyvX5xXGyDEFHFoWmmQIQe9onV4/FYIKBdQvnwxHEwM1yF4 7UHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779994715; x=1780599515; 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=MgdLusidFaY6ZcoM7gj5BjToDJmFX6Csm44/ud8xC/w=; b=Y5MGiIJw4/IZEMkwfgNW+gmQ4KjcpIk3QB8CTiNNTTL1vJNRrAZR7OmBek8/jqz3lB zEXbtNxK1X/pa2csendw7iIQ13itgjH0nKoRLqLtZzIOiRzDm360SH4gAQ6BBRnDTSZg nfOydjcXL1Kok6oaj6ks+q0/ucul/l5p3asCC0l7ab/doVTmP2oa/GoYMw8VA87qXhaW 07YrFOF/4BFrlIb8fUmMlxEwQkxZv5TRJ9RNILwELVL9H1AIJcIzBZr4zinc2tuOGXBs JQlO1IF4isJzPUGIxVyiPcxmMIRM/UoIDawb4ZC8V+6Qow0lJdDvhV4QZ7kZgga0Dlpo yjhA== X-Forwarded-Encrypted: i=1; AFNElJ+BNRZk0R2FoIllFgQ0Lzi/fdZODMG+TmNbpIGKnUlrTkbj6ZOCMf19UbcT/ncKjsSHtWQCzTgsldRsY0c=@vger.kernel.org X-Gm-Message-State: AOJu0YzpC5+iAOsiYqeAFLVdBJQu3GTBX19PGvnaMlo7KD5ipN7AzVzq SxSr/jtD2gVzrQxiMBOMdhEo16iiPt79c5+nM4/koPvnrVp+frWqnlWit9x1FY7YpiDYmSf08Tb Cw8MbE+rLIaavha332ZftG2aF00Rbnx1v74h3BDy1+/EO9kQDSHA/9oLRGu/L/A2NNwY= X-Gm-Gg: Acq92OGRDq2RL23o+K5spd9Q/g2U67AJAinbPYCfh8x1aATz9e6+Tpssq7dqJEOafhP hPv13Xs7Rej+c5jEMwj/qvqmF7IKIjI2uOsszaF66X6Bd5WksCtPrU6qBd8bqmSYzSglPfLd4qn J5wsG4YqfYUUkeDLda6Hyo9bcqrNjQSuBvB0YXdWEWrGt7t1pTIhSOv1/XnXXiMjiz20fhjJ/Cu 7bXb56Qs0tkNt3GKj6Em8iAn+1wr6Y1VfKgnuVQdIqWfdjxuY38aaiWSWVomTBvHCzs7yzaikjJ TLwaB3d9X168ORelhFXV8Ji9NKld4+8Pp4emReoMPbR2X3XzzuBNFV8Xk/FRB5VDuG5qpgxrf43 d1AdZ6NfznCpMJZvp2Ri6TAKvTkrmvbTjvAv4xRc8LT936MigSzjpNBc4Tr1sqKlKUsZ/LA== X-Received: by 2002:a05:622a:4813:b0:50b:6a79:45c5 with SMTP id d75a77b69052e-5172cb814famr1324721cf.22.1779994715058; Thu, 28 May 2026 11:58:35 -0700 (PDT) X-Received: by 2002:a05:622a:4813:b0:50b:6a79:45c5 with SMTP id d75a77b69052e-5172cb814famr1324301cf.22.1779994714571; Thu, 28 May 2026 11:58:34 -0700 (PDT) Received: from debian (71.248.69.85.rev.sfr.net. [85.69.248.71]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49099feef7esm3107165e9.0.2026.05.28.11.58.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 May 2026 11:58:33 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com, krzysztof.kozlowski@oss.qualcomm.com, alexey.klimov@linaro.org, mohammad.rafi.shaik@oss.qualcomm.com, ravi.hothi@oss.qualcomm.com, mathieu.poirier@linaro.org, andersson@kernel.org, kees@kernel.org, verhaegen@google.com, linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH v2 5/6] ASoC: qcom: q6apm: add watermark event support Date: Thu, 28 May 2026 19:58:04 +0100 Message-ID: <20260528185806.6316-6-srinivas.kandagatla@oss.qualcomm.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260528185806.6316-1-srinivas.kandagatla@oss.qualcomm.com> References: <20260528185806.6316-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=DsNmPm/+ c=1 sm=1 tr=0 ts=6a18905b cx=c_pps a=WeENfcodrlLV9YRTxbY/uA==:117 a=hLrqdhl2Yb02WBc7oxehMg==:17 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_glEPmIy2e8OvE2BGh3C:22 a=EUspDBNiAAAA:8 a=sDYR-nuGp-UazcQISOsA:9 a=kacYvNCVWA4VmyqE58fU:22 X-Proofpoint-ORIG-GUID: SNlieK6Id33N49YHySmIN9xEipHHCvki X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTI4MDE5MSBTYWx0ZWRfX9bRDIrtUuQPG 7ZFXyGeXC79bpxRReF5CcWKc/GBuhGOWO6k7ODF2JF2H7isMwZU2vndw7IWZHnlp3F5dBCqyB1N z1IR5I+HB6piG+ug48Y80Ik+VMfg4S62wDL052YEb5BWSvDwzdaA/SIp2UFgz6EGYr/kW/Qv3cL 1IxidO5d+X2sUJh7RtiaGC8w6WazJnxqrvv5WPwFifvy060GeXCIQnHaVq/TDaaiNx/beipMq80 Nsp2Dkns7XyqRonkVRqFA5eu0+dXYqA/rQ20ZRjyPQ3WUSx2W43pAa14V62W6A5WYm4uh1wnOUa JbifILpw8v1FB34heb2vOqfgJ4ZUhdMpmZO0MLVt9Z+8GfNL14sGj7WxPl2H1Il4bfAdMXJeuRt a1gT0+NJvo4PxsAnOqvXRMHlc2Mb5GLwj4/1DSevt4rijotDmquvvoC/Aqd/H4/vzZMCK7JpL0q 4h+8rzQflT/QDRU/2zQ== X-Proofpoint-GUID: SNlieK6Id33N49YHySmIN9xEipHHCvki X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-05-28_05,2026-05-28_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 phishscore=0 suspectscore=0 adultscore=0 clxscore=1015 priorityscore=1501 malwarescore=0 impostorscore=0 bulkscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605210000 definitions=main-2605280191 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 | 45 +++++++++++++++++++++++++++++++ sound/soc/qcom/qdsp6/q6apm.c | 19 +++++++++++++ sound/soc/qcom/qdsp6/q6apm.h | 2 ++ 4 files changed, 102 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 b85c7e5b085e..62a2fd79bbcb 100644 --- a/sound/soc/qcom/qdsp6/audioreach.h +++ b/sound/soc/qcom/qdsp6/audioreach.h @@ -62,6 +62,8 @@ 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) @@ -69,6 +71,48 @@ struct q6apm_graph; #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 @@ -907,4 +951,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.53.0 From nobody Mon Jun 8 14:37:09 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 DAD8432F749 for ; Thu, 28 May 2026 18:58:39 +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=1779994722; cv=none; b=bn67phVbuV9A96XE4x5Q9/BviJ77Srxh9R6/DnrLjr8fYX8/wPnSCwSmb2I7cV0HCDH5Zeu0sg51136bkzFkvYEBXil4vdbFCttRTqvMDMdk+PdDQiAG71+/m8hzKGLEhWl8tcKxsUMPfFcXb66vYlglAZ43LFrWdMBdQ8i046M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779994722; c=relaxed/simple; bh=f8ON3seXiBC4PP8iYLytKvnzTFD/bo/frUMYwfPs5SI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o0J8xYtG22WfKe03KleGS0F9PxKIo6ozweALk9GWuqCKFAa16DSifls0XWBumt8H4VayWFLLKUzGoAQhpY9VwE9FVziRwNTNWYPXshfOgM6F8Ik3iU2tZuWPJG/osG5WnrbPa6YiRHY8MFIdWWyo7ENah/PhOb2ILqqvZ31HQ0A= 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=CEdmOLUp; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=EnRnEOTT; 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="CEdmOLUp"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="EnRnEOTT" Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64SHENVl1469567 for ; Thu, 28 May 2026 18:58:39 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=+PFci7Clpma ENpXCHboxKKWeOXbrMw24+6hrewU5IwA=; b=CEdmOLUpNl+K32eaUYKB6HxyDSN LF3OeUB99rxfdorFhFHHSn2AL8mB0T75I2kksQ2b1NZ6M4NL8eaMtDcu8p3hkfCw s9r4ZASq0MJAd+f2T7ndu4ci60X7lPgWFMJCfS/vKau/Q3zmZJvQ2QuhBd4Ljs3Q K4IQ1yn/XSFFlhit1cg3TzXkkF2F4XwKs+x7ON/tp6Ih3XzAwXVT7x2wsWqsy24e c+EWSCP0L8PsU1WX+hd7icLeMwBD+HYdsTCumhiQ9s2DZ/2+nDbUT+YalYjuTsCJ OzAkheU3fwaLBbcqlDBplAoG+lKkFU/HrmRrDA3whRYbBGp5aXp+4e9n4Aw== Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4eesxa8dvt-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 28 May 2026 18:58:38 +0000 (GMT) Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-516cde13e8cso153929441cf.1 for ; Thu, 28 May 2026 11:58:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1779994718; x=1780599518; 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=+PFci7ClpmaENpXCHboxKKWeOXbrMw24+6hrewU5IwA=; b=EnRnEOTT8i1i3eGG/ZD1Ksv6qbRVQF2Yb6QS+bVgM5t716x4ZPKfZ1X0NvuIiVv6go gR8mkPaNsvl5nW12rWTUGHFug9OBjVB9ljFu0iI5n5/kgZppXvvDCOITCLWTzgM3yhCT 81gLQujytFwCsFAZPHGBUbjYNbaHnph5UYd6TG6NoT5GUWcSUNUSkx0BF8JPAhVEyak2 7ax8xmKaab+TSP0mMOUB9Y7ZT11AbDhMdhzs+NyoLzyVtPXGPCl1vw80AzffAi4cHzkf lUDNtTD1G667Nnn7ROuuwmJyO/RgWqxvZXkFkBztOT60h/nDvkPUd00bKPOdFYwUo9yS +cuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779994718; x=1780599518; 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=+PFci7ClpmaENpXCHboxKKWeOXbrMw24+6hrewU5IwA=; b=nvHOaOBEs/iGT+xin2rvMoIdxhDSarlAIWn6NIE8bFTohkXbbSxCb9w9lbQc52qYc1 RQg18Uv0UalC1cY4m8+XNmIma88fyTc2qna3IxYxJDbqthAoKHTuMcaaYmcSdBtEkC8+ 6PxMcxUlE7MYl6hS6rr1HuWPODBUIcOXNDcMTYmLlLfWrIkYbkoTQnfOw7dTlcJq0Xdn JKu2GjNb0yuLTaNbqRupTjjfsl0SHDynVjdE+0VhnIuvHDjLo6MeWAy0dNsI/fNUW6Mi 8Ltss6lyDhiZDTEPXDSlma2OMoDNgnWunM0ts8QEa0mZtFHg4fPeroVrJK1dA79BeByW 9Hxg== X-Forwarded-Encrypted: i=1; AFNElJ8bj+I5DJQK5kTc8Co/O4Vk591US4Zwqo8gIBEoPwdO6d0A8dV6sXuid3iC/qz5sc222YWa8kMXCGvYeUM=@vger.kernel.org X-Gm-Message-State: AOJu0YwMHv1BB5cmCk9Q9xEHFZPBxrwJUlmvx+0rioJKGStvRSI9BWKI poL4Xm2YHW2tLh+N6OJm+qm5F1xEDIw3Q5RmEq4DzNeluIqr3vW52FCTRXP3p47CWUhfPGmKoUx JaD6IWvjcYAnD/sxXnQlVk+yxM95eAh3U3QyFXJ9tc6on5nICcXwcbyPb3UENzhXebq0= X-Gm-Gg: Acq92OFp9I2gE41xS7ihA0/IBzjx0jQ8TRov+av8O/jFHGOT1hyQQYoqitVRe+2AvSq G2SkLTTvgvsVW2GhPJH4qNHxFD0F1iQR34a/LCgYvfVcD7J1ztOHqElPS9AYdMlO9EyQ9OUIOYN NnhGrB94GtYEUQAdGDlcHi4yioYBO6O+77WDcE7BmhP59eOpHEDly1+M1+OOzydCZR93i05wldS EBuI1RUeP7J6CpNwr33D6fCilPeIf7OoLHjN2Z3t8sBmWNsom71EmTpYR54CFwGDF46mP+JZmzh d6Z8xhn32eKPEqpKSnS2QMIG54KXxGSlXMhZb6OMXUzJc/S4PkRkcwnH4ReY2cQY59BOPcgXpuK jC2P2wwNtRHZbbAUGF1TBXxpKmPYczyLl3z5ZAMsPrgDlickY0N8A1quCfhkSHMK0wuAn6A== X-Received: by 2002:ac8:5756:0:b0:50f:c5d3:a191 with SMTP id d75a77b69052e-5172cb3807cmr1742021cf.13.1779994717825; Thu, 28 May 2026 11:58:37 -0700 (PDT) X-Received: by 2002:ac8:5756:0:b0:50f:c5d3:a191 with SMTP id d75a77b69052e-5172cb3807cmr1741601cf.13.1779994717321; Thu, 28 May 2026 11:58:37 -0700 (PDT) Received: from debian (71.248.69.85.rev.sfr.net. [85.69.248.71]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49099feef7esm3107165e9.0.2026.05.28.11.58.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 May 2026 11:58:35 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com, krzysztof.kozlowski@oss.qualcomm.com, alexey.klimov@linaro.org, mohammad.rafi.shaik@oss.qualcomm.com, ravi.hothi@oss.qualcomm.com, mathieu.poirier@linaro.org, andersson@kernel.org, kees@kernel.org, verhaegen@google.com, linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH v2 6/6] ASoC: qcom: q6apm-dai: add push-pull and watermark event support Date: Thu, 28 May 2026 19:58:05 +0100 Message-ID: <20260528185806.6316-7-srinivas.kandagatla@oss.qualcomm.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260528185806.6316-1-srinivas.kandagatla@oss.qualcomm.com> References: <20260528185806.6316-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: t4nnQVC_SApFYkmNqye8-JtQqFGTbj9e X-Proofpoint-ORIG-GUID: t4nnQVC_SApFYkmNqye8-JtQqFGTbj9e X-Authority-Analysis: v=2.4 cv=ZdIt8MVA c=1 sm=1 tr=0 ts=6a18905e cx=c_pps a=JbAStetqSzwMeJznSMzCyw==:117 a=hLrqdhl2Yb02WBc7oxehMg==:17 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=eoimf2acIAo5FJnRuUoq:22 a=EUspDBNiAAAA:8 a=FoGQ1hqfDKlkNBk9xSEA:9 a=uxP6HrT_eTzRwkO_Te1X:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTI4MDE5MSBTYWx0ZWRfX3YQsZU7501N2 5gUmjQfS1II/fwBfxVDNyThR+ncGQ7/zViDdwUHwsRuY0ztgz9iBomsX8PDjlAag7lXMuohlSg4 EDPinOveRgk3V/PK8AKvdYXIwOPMK9zg3MHFdluIRxDeXhEwz4XCCyIYZOlC8UAj4p5LB5mkKZ5 TZXWNdOsvEIDbFO5BdyFf+jy0ue5vuFl85LJGxuxBr0V0rTAGdl9ZgzF+vFgYXFAp4WZtU6Koj4 byBjBTpPZJJE135dhlDf5crIKDbr/Q43YPVTO/n5NcJPdpItH+cLNLRdIPnFkW+MeP8Y+NOWZEF peqpjg7gAydhtcrj/T++TXBwpqbOE99tfsAfRc/hlybLE7CAJcd+QqXYUqTelpF9J6jKe32YjSA 1Xn+l7F3RL/cGruFY2jpOgP8z3ZbKQmn8xyw/cAo7JR8dhAHXY5ERnRroszqwzotMMHQQA662Oc aN0QT1s1UAMCtEGp50w== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-05-28_05,2026-05-28_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 phishscore=0 impostorscore=0 bulkscore=0 clxscore=1015 priorityscore=1501 suspectscore=0 lowpriorityscore=0 adultscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605210000 definitions=main-2605280191 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.53.0