From nobody Fri Dec 19 19:08:51 2025 Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B4451FE472 for ; Tue, 4 Mar 2025 10:57:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741085875; cv=none; b=SGD58qB6qGHBq2OeEVEX/9tIcKqZq5K+8KW380XDb8h/PvAH0ZRrgxed+jVd2W/0EaI0wc6Wd/GTZd6ehDwFbq5YTkJlRMJzXzSIDkxV4VuulUAIfE7tq/7Zp/E3UFb1plFGeyrpkt8AMSHyjg6HssHPkAxA/6Uu5psmrkFkDJ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741085875; c=relaxed/simple; bh=a8wBb5Pu3Xn+ai4AGmTn/n+jSwHVc64nuzgsrIqk6KU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rimuduWfHMzhFxbY+8Io3s5/hk4WuNP0ImeqFeYW02ot/whvjnMkz73FsGZC8MQ9vgxuCNKWL177jkZe4zoyR9RDHyJcH8pvVd0d8Cw5ieeszw9/5RQKq8ctLcVk/p06BqeoXCudqH6zTaQh9rm/4YY0U1n90G78CDmv9oFiJW8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=uy/lLvWZ; arc=none smtp.client-ip=209.85.208.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="uy/lLvWZ" Received: by mail-ed1-f42.google.com with SMTP id 4fb4d7f45d1cf-5e53b3fa7daso3716530a12.2 for ; Tue, 04 Mar 2025 02:57:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741085872; x=1741690672; 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=i0rt3fuU/Pf0rTgHYvdRPIfkUIcPPHNUBjw5GiQRLAs=; b=uy/lLvWZvtHfrQojVjj6SGU9ht9lfSFUHl06//CTzn9UZAGG3trTM+gYW66nD+pJhL C5xvfIM6DDHBA2KjO4iZrx6IwDKhdbm4u5slo+VeXQhZ766ixAH8YDUA/uCTjM4ZfyUL QXhNTG8JQXq+kmzNVi8oSRdshOe4EraWYNjd59ZhHAtpkdo+1j+V70dqClR69oLjR5Gk HC3+JCF+mlHiZT0ISG7HCftanfbObb8KLqRRA3Gu4sk2/9rR/vlvT/JGPfIjZqoKXM2x K8AAxUNO0cnJ+Z4du7+RlYvKVRvRzfLB46GUqS4JsWIkWzqEBPSTVMx/q2+JXfgl5MqY zpFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741085872; x=1741690672; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=i0rt3fuU/Pf0rTgHYvdRPIfkUIcPPHNUBjw5GiQRLAs=; b=ckDa6PmKxDkV0wfaNsC+u9A9+z4UWY2l3wHl7RKCSOQrJLV7hA7YFziLX/MnNINY1e XC4QC1VBosxDwhUSItrBwMLiAokFSCgMspOCKZqvcmIxh8Grx7EQd5mMw+hAo9oXzLMH e4+Zs5lnq9lQgS/q3EHP0KfdKlX7ZsBIwt+enUcUT0DZZMxEvo7t4CzzJTvesy9hBZQM hsxeL75xbw+ruNf1vEFpclukIlH1qYApk0dt2Rnwn4bIqoIEVAGwC55144fW08OoCJ7N cioM7xwaDYgycempqbiZr0+LKCS12fRtf8s7YQdad5iHH7eXBUsKNH/ySgEu0WUm+u8n BqsQ== X-Forwarded-Encrypted: i=1; AJvYcCUw67oMnLyMMTDEYUr4qyys55jg7SVTEMdeAry02cg1CrEJDS9RSFxTPnvQe5Yd/qDr7347eMFz5/7tMw4=@vger.kernel.org X-Gm-Message-State: AOJu0YySwSE0nGPP6u5NQ75pfYap9gmNYL8wrksfLL5KXmMpwsfApJu7 bay0q28naxi9KMIkAitYshsz7F4ETvCgyfQz+LfU+3JzzDP5F+xdrCm+y00C8tY= X-Gm-Gg: ASbGnctAozbPjgLkIBEQxYgwcGAKkg+BLa2/RRClGunyTti+poVrOsu77IJVfPN5jpd 8h1ZAfr+JKUNOsNl7Ol5nrrLcNTfjmcUVIqj1zFOIMDg9tzga38IPyx577K7KR/kLIi2hsen5Np c01pIKbbSzaNayKDGANOEEeTdn5xoLPtXx4UyHLBhq6gvSBpLUHmYgyy6Ir6oXE0pe/MIK0iGWz 9Jiq9HjmyCiNIU7bJfI967wb6VOm+GNqBGZdTwSNCjLL5aPN/FJqkxLyk/dQBPnF/LLYltUZxkp +PK2eA7HYE+tk5Lv+bzB4kjSWwvPivreofwPqcGHKby/LltGe5jgI0wQ9razfjnnBOskXA== X-Google-Smtp-Source: AGHT+IE2oxoC1L64pceFAJjINpFW78bsl4/VjfI/l/jWFrb64hOpXvLnDRUmBAhXfrCjNcCe085GuQ== X-Received: by 2002:a05:6402:848:b0:5dc:d10a:1be8 with SMTP id 4fb4d7f45d1cf-5e4d6b0e6c9mr19059467a12.19.1741085871828; Tue, 04 Mar 2025 02:57:51 -0800 (PST) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5e4c43a5acdsm8002966a12.77.2025.03.04.02.57.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Mar 2025 02:57:50 -0800 (PST) From: srinivas.kandagatla@linaro.org To: broonie@kernel.org Cc: perex@perex.cz, tiwai@suse.com, krzysztof.kozlowski@linaro.org, linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, dmitry.baryshkov@linaro.org, johan+linaro@kernel.org, Srinivas Kandagatla Subject: [PATCH v3 1/6] ASoC: q6apm-dai: schedule all available frames to avoid dsp under-runs Date: Tue, 4 Mar 2025 10:57:18 +0000 Message-Id: <20250304105723.10579-2-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250304105723.10579-1-srinivas.kandagatla@linaro.org> References: <20250304105723.10579-1-srinivas.kandagatla@linaro.org> 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 Content-Type: text/plain; charset="utf-8" From: Srinivas Kandagatla With the existing code, we are only setting up one period at a time, in a ping-pong buffer style. This triggers lot of underruns in the dsp leading to jitter noise during audio playback. Fix this by scheduling all available periods, this will ensure that the dsp has enough buffer feed and ultimatley fixing the underruns and audio distortion. Fixes: 9b4fe0f1cd79 ("ASoC: qdsp6: audioreach: add q6apm-dai support") Reported-by: Krzysztof Kozlowski Signed-off-by: Srinivas Kandagatla Tested-by: Krzysztof Kozlowski --- sound/soc/qcom/qdsp6/q6apm-dai.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/sound/soc/qcom/qdsp6/q6apm-dai.c b/sound/soc/qcom/qdsp6/q6apm-= dai.c index c9404b5934c7..9d8e8e37c6de 100644 --- a/sound/soc/qcom/qdsp6/q6apm-dai.c +++ b/sound/soc/qcom/qdsp6/q6apm-dai.c @@ -70,6 +70,7 @@ struct q6apm_dai_rtd { unsigned int bytes_received; unsigned int copied_total; uint16_t bits_per_sample; + snd_pcm_uframes_t queue_ptr; bool next_track; enum stream_state state; struct q6apm_graph *graph; @@ -134,8 +135,6 @@ static void event_handler(uint32_t opcode, uint32_t tok= en, void *payload, void * prtd->pos +=3D prtd->pcm_count; spin_unlock_irqrestore(&prtd->lock, flags); snd_pcm_period_elapsed(substream); - if (prtd->state =3D=3D Q6APM_STREAM_RUNNING) - q6apm_write_async(prtd->graph, prtd->pcm_count, 0, 0, 0); =20 break; case APM_CLIENT_EVENT_DATA_READ_DONE: @@ -294,6 +293,27 @@ static int q6apm_dai_prepare(struct snd_soc_component = *component, return 0; } =20 +static int q6apm_dai_ack(struct snd_soc_component *component, struct snd_p= cm_substream *substream) +{ + struct snd_pcm_runtime *runtime =3D substream->runtime; + struct q6apm_dai_rtd *prtd =3D runtime->private_data; + int i, ret =3D 0, avail_periods; + + 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++) { + ret =3D q6apm_write_async(prtd->graph, prtd->pcm_count, 0, 0, NO_TIMEST= AMP); + if (ret < 0) { + dev_err(component->dev, "Error queuing playback buffer %d\n", ret); + return ret; + } + prtd->queue_ptr +=3D runtime->period_size; + } + } + + return ret; +} + static int q6apm_dai_trigger(struct snd_soc_component *component, struct snd_pcm_substream *substream, int cmd) { @@ -305,9 +325,6 @@ static int q6apm_dai_trigger(struct snd_soc_component *= component, case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - /* start writing buffers for playback only as we already queued capture= buffers */ - if (substream->stream =3D=3D SNDRV_PCM_STREAM_PLAYBACK) - ret =3D q6apm_write_async(prtd->graph, prtd->pcm_count, 0, 0, 0); break; case SNDRV_PCM_TRIGGER_STOP: /* TODO support be handled via SoftPause Module */ @@ -836,6 +853,7 @@ static const struct snd_soc_component_driver q6apm_fe_d= ai_component =3D { .hw_params =3D q6apm_dai_hw_params, .pointer =3D q6apm_dai_pointer, .trigger =3D q6apm_dai_trigger, + .ack =3D q6apm_dai_ack, .compress_ops =3D &q6apm_dai_compress_ops, .use_dai_pcm_id =3D true, }; --=20 2.39.5 From nobody Fri Dec 19 19:08:51 2025 Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB6091FF1B0 for ; Tue, 4 Mar 2025 10:57:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741085876; cv=none; b=Ud7eEdzvxgT+9ekVvkMciNEZozgiFlNq9l5VU5aCd589C18Aw13OzZzdeoZEtjIQ+f2Od15ZfcVxcyOUYWh+YPkB1BByXdJNBkWo7AUJfv+DC9O7UGW1n8vhbTrEDmknWtYN6FOvvH6OENUO99NrabefpvmkMlJxKQue2LA0BE0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741085876; c=relaxed/simple; bh=1xefXhqlbqpAB2oQqLsGbrSi7RBtCPYZ7ZpO6A4CBvY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Uvpq8+xWSR65WbdcPMbN32rIOueovPd5cB66M5XZ9+5Jnasxydwr/f7E62oUg6eRfHT7muWB9iZcKOBHacjtB/UStudIUFmzm4bRy1XQ6up5Z4LvzyBFhfK4KhEU0kpeLt2BzDabq9VR8bAEuOz1EU8pVH1ZT/vEnv1kC68Ms/k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=bUi78mJH; arc=none smtp.client-ip=209.85.208.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="bUi78mJH" Received: by mail-ed1-f50.google.com with SMTP id 4fb4d7f45d1cf-5e4ce6e3b8cso2000683a12.1 for ; Tue, 04 Mar 2025 02:57:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741085873; x=1741690673; 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=vKxN+N8VR/L9rUJdIcbrBDE8Zwzij3KzY6U7lQgd2vE=; b=bUi78mJHtQDzhRT1SYzXepDMqL+rrb8RdnzLz32WBu96YGR6YV2YEhpA+Zafb0Z7NT JC0LWnJF5Y3oZ2JtQigO3nQOmiR1QmGTfNoO3ll4X3XCO0g5U6bLeMA1pyU3G2H3pmRm VhMjkMXQBcJMj4pE/2WyFCPyDeeGQzbDp+bIhADaZqPDfijm3Jd4IJQbSZPEbR8Qmgzb NgS92SIaUiNqFTvw720DDMJHKFh92RBSiP8z5YCMggC7zeR4H6/BlyZt+6MT8oEiwuNt R0KPyevhLH3JyG/Pc86jDL75DfJVTwGIB6x0R2Qomi+pYmG4Vldu2Qj+CYoUYcifryEO gT+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741085873; x=1741690673; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vKxN+N8VR/L9rUJdIcbrBDE8Zwzij3KzY6U7lQgd2vE=; b=S8FkVgg+1QeMmAexSirdG8goG4y8W0KznMtbFrKNK/KarkCC4lcv18JdAih5ugQ02P VgVs9pigAkxJKMCkAafYV8UahrJiUpM2+g+vpG0PX48F/yH92+V2mCb8Y5HFHn5+BlJa GutNehB0MNK5kgZYVyqzJZBY/uouImk+EQXsAMTzSw1GBQKrBGo51MeI2jnmu5SggP/0 qM0LS+x877sumsNx6/kZ/UOZuySpAl19lFp44A/lGBE2DjID3pkuSosnUZs6pRPcs6eM kreSFlOzmXV54/XbuORA5E3Pq1h0V8aMEBo1mt3fPUUTheXqjLGAZzPYsjj/3gHICyjq lZrA== X-Forwarded-Encrypted: i=1; AJvYcCXYTtgWjliErtbRbLjnGpAv9MaXo23ZSWnFy0P2gl84ctB49huRiFawvxRluCwv/YKqTvrcYsXpEm3VRsI=@vger.kernel.org X-Gm-Message-State: AOJu0Yy5PrWcfCupZo+f+zmJAXu40lV6t+sWkXNzLEWHbfchF7zoUppU 0ERoDO4hz+OBJnr8IzhpK8jJQUDX15J34LydN+LBWZZVtKKhNB2pwR8t/xaxQfadPqmpNlDN7h6 w X-Gm-Gg: ASbGncvSQaZKtHfOPj1ADvash+nK4kzjRI9RoQokW6XdXYGXRj2axOSgReD0RZy6ndr AY9BVMNDdjPOZrxu0hkPNibkiZ0Mvk9GUo/YbX+kjiLlykTMKex8KX8Sh/N6YaYx72tA07OQ+1z DPFpHV7DExgAeJaNQWapvwJgYVzpNB4QE1ZikOXGcTnm9qqePsVhUxux0iVhbipbLs4BR4VgGgW LdPhnB6LIy/CPP9SkVmCKH9e5KiaLpoeqEhD/rJviTJiDrArmQ1YSWAM99G6ohVLCh8pCt3VGYS L6l+o34ESzKJwAFvfAp0a/c+yjZk3D2yuQd/zVGpeVkBiO+T+IO+IjwEtWg81D8/uyXq8A== X-Google-Smtp-Source: AGHT+IE8Sal8KqA+qz4oZKZeTHOuVTnUfodH7MUUB6Y+bnPf6oi5PL4NudtJEqpBolNDyCLsfe6DJw== X-Received: by 2002:a05:6402:4585:b0:5e5:310d:256e with SMTP id 4fb4d7f45d1cf-5e584efa4c3mr2476157a12.14.1741085872947; Tue, 04 Mar 2025 02:57:52 -0800 (PST) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5e4c43a5acdsm8002966a12.77.2025.03.04.02.57.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Mar 2025 02:57:52 -0800 (PST) From: srinivas.kandagatla@linaro.org To: broonie@kernel.org Cc: perex@perex.cz, tiwai@suse.com, krzysztof.kozlowski@linaro.org, linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, dmitry.baryshkov@linaro.org, johan+linaro@kernel.org, Srinivas Kandagatla Subject: [PATCH v3 2/6] ASoC: q6apm: add q6apm_get_hw_pointer helper Date: Tue, 4 Mar 2025 10:57:19 +0000 Message-Id: <20250304105723.10579-3-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250304105723.10579-1-srinivas.kandagatla@linaro.org> References: <20250304105723.10579-1-srinivas.kandagatla@linaro.org> 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 Content-Type: text/plain; charset="utf-8" From: Srinivas Kandagatla Implement an helper function in q6apm to be able to read the current hardware pointer for both read and write buffers. This should help q6apm-dai to get the hardware pointer consistently without it doing manual calculation, which could go wrong in some race conditions. Fixes: 9b4fe0f1cd79 ("ASoC: qdsp6: audioreach: add q6apm-dai support") Signed-off-by: Srinivas Kandagatla Tested-by: Krzysztof Kozlowski --- sound/soc/qcom/qdsp6/q6apm.c | 18 +++++++++++++++++- sound/soc/qcom/qdsp6/q6apm.h | 3 +++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/sound/soc/qcom/qdsp6/q6apm.c b/sound/soc/qcom/qdsp6/q6apm.c index 2a2a5bd98110..ca57413cb784 100644 --- a/sound/soc/qcom/qdsp6/q6apm.c +++ b/sound/soc/qcom/qdsp6/q6apm.c @@ -494,6 +494,19 @@ int q6apm_read(struct q6apm_graph *graph) } EXPORT_SYMBOL_GPL(q6apm_read); =20 +int q6apm_get_hw_pointer(struct q6apm_graph *graph, int dir) +{ + struct audioreach_graph_data *data; + + if (dir =3D=3D SNDRV_PCM_STREAM_PLAYBACK) + data =3D &graph->rx_data; + else + data =3D &graph->tx_data; + + return (int)atomic_read(&data->hw_ptr); +} +EXPORT_SYMBOL_GPL(q6apm_get_hw_pointer); + static int graph_callback(struct gpr_resp_pkt *data, void *priv, int op) { struct data_cmd_rsp_rd_sh_mem_ep_data_buffer_done_v2 *rd_done; @@ -520,7 +533,8 @@ static int graph_callback(struct gpr_resp_pkt *data, vo= id *priv, int op) done =3D data->payload; phys =3D graph->rx_data.buf[token].phys; mutex_unlock(&graph->lock); - + /* token numbering starts at 0 */ + atomic_set(&graph->rx_data.hw_ptr, token + 1); if (lower_32_bits(phys) =3D=3D done->buf_addr_lsw && upper_32_bits(phys) =3D=3D done->buf_addr_msw) { graph->result.opcode =3D hdr->opcode; @@ -553,6 +567,8 @@ static int graph_callback(struct gpr_resp_pkt *data, vo= id *priv, int op) rd_done =3D data->payload; phys =3D graph->tx_data.buf[hdr->token].phys; mutex_unlock(&graph->lock); + /* token numbering starts at 0 */ + atomic_set(&graph->tx_data.hw_ptr, hdr->token + 1); =20 if (upper_32_bits(phys) =3D=3D rd_done->buf_addr_msw && lower_32_bits(phys) =3D=3D rd_done->buf_addr_lsw) { diff --git a/sound/soc/qcom/qdsp6/q6apm.h b/sound/soc/qcom/qdsp6/q6apm.h index c248c8d2b1ab..7ce08b401e31 100644 --- a/sound/soc/qcom/qdsp6/q6apm.h +++ b/sound/soc/qcom/qdsp6/q6apm.h @@ -2,6 +2,7 @@ #ifndef __Q6APM_H__ #define __Q6APM_H__ #include +#include #include #include #include @@ -77,6 +78,7 @@ struct audioreach_graph_data { uint32_t num_periods; uint32_t dsp_buf; uint32_t mem_map_handle; + atomic_t hw_ptr; }; =20 struct audioreach_graph { @@ -150,4 +152,5 @@ int q6apm_enable_compress_module(struct device *dev, st= ruct q6apm_graph *graph, int q6apm_remove_initial_silence(struct device *dev, struct q6apm_graph *g= raph, uint32_t samples); 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); #endif /* __APM_GRAPH_ */ --=20 2.39.5 From nobody Fri Dec 19 19:08:51 2025 Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 51A741FF7D9 for ; Tue, 4 Mar 2025 10:57:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741085880; cv=none; b=ZaqYjF2IQhrQQWOofuh+uj1S1timir9IiBTXofw9lW8rBdYtmbVTx9J8HgQ51sIqkf7RsQQMYTv5TDO23D9GcXEoyxQxrDsiEwQU28UB4N3MP081weLAhUOVjXJ2vc4cDhCeFbOnV703VDfRtMdTEEnwsdDcV5et+2TxZmD5eYA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741085880; c=relaxed/simple; bh=2cyClla8P6nWRItjw60GOMchhN9i8E2qxWYIAydEh1U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mV2J/tlegpaGEVfvw1L+8+iro2THxoxFa2ctzXBf2b5gRCZXD5pjp1hfufFlAUDZ1uiTdJ8L0Ab7Lp+y3z1+W1r12+DZyqvfcgA0b/ukvTkb0XNMjoUz73YDTbXX9DCqjzRWRri7LEx+2TwpCJ/prGbkJ/7DbydGQf/FHtfwLys= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=pNba2wxU; arc=none smtp.client-ip=209.85.208.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="pNba2wxU" Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-5e51e3274f1so5749462a12.0 for ; Tue, 04 Mar 2025 02:57:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741085874; x=1741690674; 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=1ey071ua+N+9tAjiihktgShgQiT43owN1w7pBcfUu5o=; b=pNba2wxU7i/nwvVqF1bqfLHzLYB5/OFSy++gxwjWYwP4KoGYRXQiOSImu9g9M770UF y7OPqZiimIM+R/g2R5zgbGztGH6CJaLjQGvvl5t/gSfBDbOpCbJ+DF2HB3GfC1qHooX+ L42uZDGihrjcpMu4Ov6MjOEZlrjwymQu6EPjVPsYtsjUoVkcAX2YiAZ3cqc2VbD7pnFD zmerkZOCzA5V+oHnWKrlGvlJGaFT8EBrbhXDu2ZxMPY5KSOm2Bu0DMLaExfym/cgi1Qv 7637g3XWm3HEME4qE5DYiYMmrgvI7VTxwxVyYWyeY6It08vKV7niARKCFCRB+TsZlr3W x/tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741085874; x=1741690674; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1ey071ua+N+9tAjiihktgShgQiT43owN1w7pBcfUu5o=; b=k4MNuG8Kj89xPmp77oZVsTNWDL7mSbI01oPDcobDoZJZn5D3URjFOmeUT50NPOOkqi dP17L2bVqvygOIbr88nH66QZxUPQJ3NzVulcw2W6yaGEmJzo0i368GTEyDVKcI9XVi5X 4Av5shSewxirTD1Lwx5BHSJFB47X1mr2T/2nnL7JuE7avDYJI9UKw9hcepVjrFQpkqPI yXtWPUVcJWyZK4zcxMjvY3hm6NFjvt+AjKPgxT5WX3cfkQKZ9AXi0GLi88beGPC7qoW9 saF1yInAGTzegJe2f+M18BI59uP45bvZv3Sq7hAxtkeSZp4FU2ej+79Jv0xKsAzdvH0m K8VQ== X-Forwarded-Encrypted: i=1; AJvYcCWwVUO+PoxEW4LjjhJJu8msoh9FxSahJtXCiizDlMLe3sTrsvIt+xGciEVUjQ60rF1LbaNS1u9PrrqbxxY=@vger.kernel.org X-Gm-Message-State: AOJu0YwgBAensj7YCzOaX0KzLLwb7hEqzVLHCoy2PHhjZFKc2JrT3NRc tSl9sfNsoXPz5SiGJTYKhBuuon3r5JXXkq7CQpaJT5SMh9pjozwnjPvYRRxR66c= X-Gm-Gg: ASbGnctVJC8MpKI3rNPBY4xodPRDNy5Wn/XSppbtLiJ0nHb88DJB54FwKUJXamAEzFd +SKtChjnpcLeB3Q6E00avNI29rr74m//Ebguipjns7UYLYxDj3+OMxKTS9vghO5WqCAHh6Gd0eC lLuteYKVr3FLbbVVW6QCodCUks3qqrS0Cn06LwdVQFqgFwdmb/zTFuP9e4yPhveOF5ewG20SSwW 3Ah2y/yoj5uYY4yGWwaKp8Lo+WNDTIT1Tmgdnh3XCveJL0K6Zojp0htzMaIPJiepwaNl1CExaD7 5QybkupqbSS6IEGwYHgkqY8YyBhsOYmdpzJMyB3SUnlZyJGWJIe0I5NQUfW0xrFIt1yPDw== X-Google-Smtp-Source: AGHT+IEl5dQ7SUi+h+pAoAiqxB4IHkrcoHFGA18aKW1ukykTVB77J+DM70kzsLvNIP2qQEyNm/KbYA== X-Received: by 2002:a05:6402:378a:b0:5e5:bb0:5d8b with SMTP id 4fb4d7f45d1cf-5e50bb0608emr14240833a12.10.1741085874589; Tue, 04 Mar 2025 02:57:54 -0800 (PST) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5e4c43a5acdsm8002966a12.77.2025.03.04.02.57.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Mar 2025 02:57:53 -0800 (PST) From: srinivas.kandagatla@linaro.org To: broonie@kernel.org Cc: perex@perex.cz, tiwai@suse.com, krzysztof.kozlowski@linaro.org, linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, dmitry.baryshkov@linaro.org, johan+linaro@kernel.org, Srinivas Kandagatla Subject: [PATCH v3 3/6] ASoC: q6apm-dai: make use of q6apm_get_hw_pointer Date: Tue, 4 Mar 2025 10:57:20 +0000 Message-Id: <20250304105723.10579-4-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250304105723.10579-1-srinivas.kandagatla@linaro.org> References: <20250304105723.10579-1-srinivas.kandagatla@linaro.org> 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 Content-Type: text/plain; charset="utf-8" From: Srinivas Kandagatla With the existing code, the buffer position is only reset in pointer callback, which leaves the possiblity of it going over the size of buffer size and reporting incorrect position to userspace. Without this patch, its possible to see errors like: snd-x1e80100 sound: invalid position: pcmC0D0p:0, pos =3D 12288, buffer siz= e =3D 12288, period size =3D 1536 snd-x1e80100 sound: invalid position: pcmC0D0p:0, pos =3D 12288, buffer siz= e =3D 12288, period size =3D 1536 Fixes: 9b4fe0f1cd79 ("ASoC: qdsp6: audioreach: add q6apm-dai support") Signed-off-by: Srinivas Kandagatla Tested-by: Krzysztof Kozlowski --- sound/soc/qcom/qdsp6/q6apm-dai.c | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/sound/soc/qcom/qdsp6/q6apm-dai.c b/sound/soc/qcom/qdsp6/q6apm-= dai.c index 9d8e8e37c6de..90cb24947f31 100644 --- a/sound/soc/qcom/qdsp6/q6apm-dai.c +++ b/sound/soc/qcom/qdsp6/q6apm-dai.c @@ -64,7 +64,6 @@ struct q6apm_dai_rtd { phys_addr_t phys; unsigned int pcm_size; unsigned int pcm_count; - unsigned int pos; /* Buffer position */ unsigned int periods; unsigned int bytes_sent; unsigned int bytes_received; @@ -124,23 +123,16 @@ static void event_handler(uint32_t opcode, uint32_t t= oken, void *payload, void * { struct q6apm_dai_rtd *prtd =3D priv; struct snd_pcm_substream *substream =3D prtd->substream; - unsigned long flags; =20 switch (opcode) { case APM_CLIENT_EVENT_CMD_EOS_DONE: prtd->state =3D Q6APM_STREAM_STOPPED; break; case APM_CLIENT_EVENT_DATA_WRITE_DONE: - spin_lock_irqsave(&prtd->lock, flags); - prtd->pos +=3D prtd->pcm_count; - spin_unlock_irqrestore(&prtd->lock, flags); snd_pcm_period_elapsed(substream); =20 break; case APM_CLIENT_EVENT_DATA_READ_DONE: - spin_lock_irqsave(&prtd->lock, flags); - prtd->pos +=3D prtd->pcm_count; - spin_unlock_irqrestore(&prtd->lock, flags); snd_pcm_period_elapsed(substream); if (prtd->state =3D=3D Q6APM_STREAM_RUNNING) q6apm_read(prtd->graph); @@ -247,7 +239,6 @@ static int q6apm_dai_prepare(struct snd_soc_component *= component, } =20 prtd->pcm_count =3D snd_pcm_lib_period_bytes(substream); - prtd->pos =3D 0; /* rate and channels are sent to audio driver */ ret =3D q6apm_graph_media_format_shmem(prtd->graph, &cfg); if (ret < 0) { @@ -445,16 +436,12 @@ static snd_pcm_uframes_t q6apm_dai_pointer(struct snd= _soc_component *component, struct snd_pcm_runtime *runtime =3D substream->runtime; struct q6apm_dai_rtd *prtd =3D runtime->private_data; snd_pcm_uframes_t ptr; - unsigned long flags; =20 - spin_lock_irqsave(&prtd->lock, flags); - if (prtd->pos =3D=3D prtd->pcm_size) - prtd->pos =3D 0; - - ptr =3D bytes_to_frames(runtime, prtd->pos); - spin_unlock_irqrestore(&prtd->lock, flags); + ptr =3D q6apm_get_hw_pointer(prtd->graph, substream->stream) * runtime->p= eriod_size; + if (ptr) + return ptr - 1; =20 - return ptr; + return 0; } =20 static int q6apm_dai_hw_params(struct snd_soc_component *component, @@ -669,8 +656,6 @@ static int q6apm_dai_compr_set_params(struct snd_soc_co= mponent *component, prtd->pcm_size =3D runtime->fragments * runtime->fragment_size; prtd->bits_per_sample =3D 16; =20 - prtd->pos =3D 0; - if (prtd->next_track !=3D true) { memcpy(&prtd->codec, codec, sizeof(*codec)); =20 --=20 2.39.5 From nobody Fri Dec 19 19:08:51 2025 Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA6091FCCF7 for ; Tue, 4 Mar 2025 10:57:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741085879; cv=none; b=XtQA3G0qJ0Lhy2lGNcHnUMQ7mDAMgISPA3/5yx7h1gvndFjtSWuhxMVHk11Ry8IrTul38IumJ3FGEIgiMrcN/xph1P7dV05xSHAaJngnLz9MJS2fv/12spQOVuDogew2j0Wgsxg8cG7hOey5g/J1WDXmtfIL79UUCmOj0eMTbkM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741085879; c=relaxed/simple; bh=T8BvseEhQtgXi/c6dzXEReCkqVf8+ZZBBGjoAN7DYSQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AJg3q2EhAwomAwVX9j+JIvr6ywemG2joBLcgL6u14uKdHkTFuyA/pkUaAXaarjWuqpT+eqbKlU6Mn27cm7ty9fOOOa0i8BTPRE2QbLP7IthTnpSKpi2Ec/7KS919yBM+hVDaDcVpnjwr5HZ+o+uw68EVMlRKPbZBduJviohQTBU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Of1OOs14; arc=none smtp.client-ip=209.85.208.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Of1OOs14" Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-5e04064af07so10231335a12.0 for ; Tue, 04 Mar 2025 02:57:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741085876; x=1741690676; 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=H8qpY34vr6GYk8mljhQq04C1Vg9LVV3uW0bLLDq/qwY=; b=Of1OOs14magff5WkzoscXE1E6o2u8goWZqXah/vmbZb+BR1l+k1+SuRISQGRT7+JWa KhN6itYTjZgtFdj+Kbi2oxRs6fmcwposhX36z+B62mwvR/2jgtNI16u4d6vuYOqMMVsQ wcqVyrGThcO1joVXOS22jz3tfJXhSgagdO5qF7+c0a5CNh3RZB/SNx0bZVdNz2YNfQa7 dg+lpDQVaCKcD26ZpUOjhAdoYww0pwPxBBskhK58I+srXbx/1G0Ll0+QZt50IrJ+DHww hOnAW5IfN5CEFXW/zoQhwOHVyQnqyTXXVcSu9b3C0+tpmE5YsrxV3BOQReNVuYEHHwlD mFXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741085876; x=1741690676; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=H8qpY34vr6GYk8mljhQq04C1Vg9LVV3uW0bLLDq/qwY=; b=vyl7plF6TBuGiouo39oy/xuDkpH8N6FIGfQlS2QdoZSNlPVW82EK8Y6+RKayfrqjmK pIjAQ1Qgutu5IxlN6cROrgrArDntd7H6GEAXozkLLYhEQl7JF3QiPej5DSGqNp4cU8U2 W0Df11gKI8fXgaJNiiq4s6KYKIDBRFywEVvFzajS2BhvCsdDou6rY55XbRAU7yHp3ehz k4m+K6nlgYkBlB21H8P2RVSzSggi3V9jgyFiDWKL6v8axkk1tWaPCWFTGi+sui+OYDAi 9VZex3h7DlTeRe8KPp7dAy0tzZW38W3ZOiQK1bI69kWczlnDl2UR08fL0p+RroDpeNZs ahxg== X-Forwarded-Encrypted: i=1; AJvYcCVsa82Jck7utquuntk/dGTCb6qk5EHpaU2FKnjLzVEpGktSXDFt+pguc5UIKBjf9cxe+Thoh1jh07AZkm8=@vger.kernel.org X-Gm-Message-State: AOJu0YyYAz3BgnyP93Ec7tD0yjQQGQpGR7zw5ukfN4nmJZh8O+nxSf2a o8w7RAAhTLQLM16l6PcqnxcqgDbsMG4YI6M85jO+gZneG7oVt0hKqebiyHcp9hs= X-Gm-Gg: ASbGnctl/U8I8S8qM2eBWGbg7lvstSWOdjFTXyt3cUa3Mj1fn7LP1G71VHGK3TESKWg MCybPPFhUp5J3xFkPUiRPopBu6OJQZIGvY1otIvRjAt9HN6ZjunM40AhU4wdFb5zMgajTvXH0Gm 7f6fJ86wK0J+irJ/WBDr3LLquX35CcC5ENpRKAvIzYufC23b06JDCKWuO+18BfDl2RXR/BdmI+G WM4Qj3NjlRxuqZ+mcLphn4+AA9Ur/jSKF2SlkJRKlzEU9HD4oKqR51R9nQ8J/zNw+uCdi2ZKtKj xvrLtioqMSPp4fOIHGvaHtGcQf+OcBYP8Mgi62k42bY52Wvyv2zMe5m0m9DL9ipVRvZejA== X-Google-Smtp-Source: AGHT+IEMtAPD+3mslBPe9dpUnwDfjI6yIrS86aj52AjEbtCekD+P8Nt1T5PEVviZq9Ti8UN7hLn8MA== X-Received: by 2002:a05:6402:1d54:b0:5e5:3643:c8b5 with SMTP id 4fb4d7f45d1cf-5e53643cd09mr11556338a12.30.1741085875856; Tue, 04 Mar 2025 02:57:55 -0800 (PST) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5e4c43a5acdsm8002966a12.77.2025.03.04.02.57.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Mar 2025 02:57:55 -0800 (PST) From: srinivas.kandagatla@linaro.org To: broonie@kernel.org Cc: perex@perex.cz, tiwai@suse.com, krzysztof.kozlowski@linaro.org, linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, dmitry.baryshkov@linaro.org, johan+linaro@kernel.org, Srinivas Kandagatla Subject: [PATCH v3 4/6] ASoC: qdsp6: q6apm-dai: set correct period and buffer alignment. Date: Tue, 4 Mar 2025 10:57:21 +0000 Message-Id: <20250304105723.10579-5-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250304105723.10579-1-srinivas.kandagatla@linaro.org> References: <20250304105723.10579-1-srinivas.kandagatla@linaro.org> 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 Content-Type: text/plain; charset="utf-8" From: Srinivas Kandagatla DSP expects the buffers to be aligned to 64 bytes. Having a 32 byte alignment can result in fast playback or capture in some configurations. Fixes: 9b4fe0f1cd79 ("ASoC: qdsp6: audioreach: add q6apm-dai support") Signed-off-by: Srinivas Kandagatla Tested-by: Krzysztof Kozlowski --- sound/soc/qcom/qdsp6/q6apm-dai.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/qcom/qdsp6/q6apm-dai.c b/sound/soc/qcom/qdsp6/q6apm-= dai.c index 90cb24947f31..bb761ee0164b 100644 --- a/sound/soc/qcom/qdsp6/q6apm-dai.c +++ b/sound/soc/qcom/qdsp6/q6apm-dai.c @@ -385,13 +385,13 @@ static int q6apm_dai_open(struct snd_soc_component *c= omponent, } } =20 - ret =3D snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_= BYTES, 32); + ret =3D snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_= BYTES, 64); if (ret < 0) { dev_err(dev, "constraint for period bytes step ret =3D %d\n", ret); goto err; } =20 - ret =3D snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_= BYTES, 32); + ret =3D snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_= BYTES, 64); if (ret < 0) { dev_err(dev, "constraint for buffer bytes step ret =3D %d\n", ret); goto err; --=20 2.39.5 From nobody Fri Dec 19 19:08:51 2025 Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9429F1FF611 for ; Tue, 4 Mar 2025 10:57:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741085880; cv=none; b=iyNR5bRwMIN22YCZXdOuEBBzcUHlJsrykrlQhka3s5/qT0B/j/J+in4GlRbC3X5XsCA7W167H0JYOjuOWZVW+daR4ma+a5j5qK2NRKmWfYNieFTv62+rcIGL2e1OzhYeSJKA2N0JV3bKHL46IdXTvVMN3wVa+7QBWvlNALcTF0g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741085880; c=relaxed/simple; bh=U03Y8+otvCPyp6B90WiniVnGB768hd4h2QJoJ4PjQL4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VoZ8PWYGUN2I8zlZ1MmuMrTJTxBJXnXmIHzGbpa4FADHZIBDvED0tDvDtheFIQfkURiV5inG8bbsWa6ii4bUolQA0Rx0L23V6GG73MAGcdfhhBLADgYujK7uLj4x1RQl37t3E1/XsLACKqiV8CgBk+qQI/j5tX6a9OBICgle5H8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=MbZ5SdHZ; arc=none smtp.client-ip=209.85.208.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="MbZ5SdHZ" Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-5e0573a84fcso7498503a12.2 for ; Tue, 04 Mar 2025 02:57:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741085877; x=1741690677; 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=EpWmkRDsOmXj9Ho1jnnfhy87hBtzpfdzQehUQCbXU8k=; b=MbZ5SdHZ6du5n6P1A2wKrr3gGiJWeafYrl4Cm1/jv60/XP43MWJByDr+gsUG1xv6qf t4fAmnBRvTe639oUT+WQfcMnThpiFoz9qtGh0H7Mhk0ONrJebz72zGmhQdS6xNd4Sl7z 1u+XRI1GId5iNsWXwEsplhBhfEHdfY2061wVyBk/Q4XL8p1VGFtGHc7QJtyfOJruSaqd Yp8c1Za29YMCe+uZcQo21Aa5OkemRqXCexFAAac22FAvb4Nsgcael3tCONnh8StMgtv5 RUbpff8nRxjNj8AovEz79Vvt79Z+gWeUEskZqeUlcpSLefCbfyXry+wRXOH0JyyO4PUM brnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741085877; x=1741690677; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EpWmkRDsOmXj9Ho1jnnfhy87hBtzpfdzQehUQCbXU8k=; b=El0u3Kk2KXQcjK64MOoU2Gmdtc8RmlKPKlhiGeXHjCgq3tL2UHbCCT1FR7fdstsgqF z3AtB625prs6lWs42+kULQ7xWfHlOA4esKrDPwHij6Ehf6JusyC+hHAlcguItqA9EZ02 uMPqFGdUBjtZKqqdRjMyqsXiR+IU4eVPN+h8DdiUvIEw+tF8iY8Yn5fyAYuo8STzxMqz eWQH0YLXQKiKGCacanwA+SqNyi63u/huzHeqLThgACwiA+KpSvTMnsCLQonLuxcOT97L dc0fV6C4GABCVoHtPEKewQ68H0QIjh51UG3lmaJERSS4aDvhYRbRbxx4gwNTinUhL6Cy M5iA== X-Forwarded-Encrypted: i=1; AJvYcCW+o/Lj8Yz8n+/LcPM1dT5rJlkdd7iF4PF4sZazMrhqk5fJAFJMw4nsgrE/cS4VifLUw+wynHFuPhnYBIo=@vger.kernel.org X-Gm-Message-State: AOJu0Yy6gMi8pxKikRkUgZfBvcJ3wYeva1OFZsE5sbmutaU6kpz69mJg kFwNLrGmUTmlhovJD136MrInLvKFbc74vKWmsTWWvbRL7caEKV9yLWVFx1kbBnI= X-Gm-Gg: ASbGncuWkTybSwNrGB7UOkEuQ925hOpaDT/s5FT1B754zEc4fjA6kdLeU6PYsypLGht 891rq0AM2qZwWKe1ONDWH2QfTZJSo0JEnBOq+gZmGsxmVwrx5rZcJON91r1G4Pm2LcFvp54F/XX b2osjedrSU4I6l1Tftw36morEUUY01rXreGFFf7zdbTJxxev3YoKcFddY5CaxLThcW2i9VSz/gY rp/Nz/ycfzBbmK3fWpXBF63eOPzZvqA+hwE/9KfkghHISffz00gOKXM8EpZ3g+vQY3r6fdoSbS5 yZsAIEjdCf4u7Fu59se76jxoMEdFewM6GPBB8GyAOHFdQqxmEHu9FclH3GDlP/89UM3Xeg== X-Google-Smtp-Source: AGHT+IGeygA0lA5u++5TADbRIt4j3Ll52BOM26+v0dT+XCymoz2shCvC0jL3k2lSpDpggwQ5CUbTmg== X-Received: by 2002:a05:6402:2794:b0:5e0:8c55:504 with SMTP id 4fb4d7f45d1cf-5e4d6ad3e21mr16124141a12.7.1741085877089; Tue, 04 Mar 2025 02:57:57 -0800 (PST) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5e4c43a5acdsm8002966a12.77.2025.03.04.02.57.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Mar 2025 02:57:56 -0800 (PST) From: srinivas.kandagatla@linaro.org To: broonie@kernel.org Cc: perex@perex.cz, tiwai@suse.com, krzysztof.kozlowski@linaro.org, linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, dmitry.baryshkov@linaro.org, johan+linaro@kernel.org, Srinivas Kandagatla Subject: [PATCH v3 5/6] ASoC: qdsp6: q6apm-dai: fix capture pipeline overruns. Date: Tue, 4 Mar 2025 10:57:22 +0000 Message-Id: <20250304105723.10579-6-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250304105723.10579-1-srinivas.kandagatla@linaro.org> References: <20250304105723.10579-1-srinivas.kandagatla@linaro.org> 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 Content-Type: text/plain; charset="utf-8" From: Srinivas Kandagatla Period sizes less than 6k for capture path triggers overruns in the dsp capture pipeline. Change the period size and number of periods to value which DSP is happy wi= th. Fixes: 9b4fe0f1cd79 ("ASoC: qdsp6: audioreach: add q6apm-dai support") Signed-off-by: Srinivas Kandagatla Tested-by: Krzysztof Kozlowski --- sound/soc/qcom/qdsp6/q6apm-dai.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/qcom/qdsp6/q6apm-dai.c b/sound/soc/qcom/qdsp6/q6apm-= dai.c index bb761ee0164b..aca0a98d58a5 100644 --- a/sound/soc/qcom/qdsp6/q6apm-dai.c +++ b/sound/soc/qcom/qdsp6/q6apm-dai.c @@ -24,8 +24,8 @@ #define PLAYBACK_MIN_PERIOD_SIZE 128 #define CAPTURE_MIN_NUM_PERIODS 2 #define CAPTURE_MAX_NUM_PERIODS 8 -#define CAPTURE_MAX_PERIOD_SIZE 4096 -#define CAPTURE_MIN_PERIOD_SIZE 320 +#define CAPTURE_MAX_PERIOD_SIZE 65536 +#define CAPTURE_MIN_PERIOD_SIZE 6144 #define BUFFER_BYTES_MAX (PLAYBACK_MAX_NUM_PERIODS * PLAYBACK_MAX_PERIOD_S= IZE) #define BUFFER_BYTES_MIN (PLAYBACK_MIN_NUM_PERIODS * PLAYBACK_MIN_PERIOD_S= IZE) #define COMPR_PLAYBACK_MAX_FRAGMENT_SIZE (128 * 1024) --=20 2.39.5 From nobody Fri Dec 19 19:08:51 2025 Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 141E1200B96 for ; Tue, 4 Mar 2025 10:57:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741085881; cv=none; b=meue9Z1v0pdsIxVZjKs9B202pf3uA4iKF0a1WbNjzCC9QjKNoi59ukRki9/WChQQR5zJ3DHqa4EAdo1JtEV0S0tr7rRnYwTx0uhyYi6s+iKC5+To3IxlLiEmcxWrrNE4phmG3GE4decwgcQltkvcHSYPnFBCxfInyIjd6AtSjOc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741085881; c=relaxed/simple; bh=OOlm6HNrfX6e8YtvAb7GXOiQezhdyWO8PXRO+Eqpahg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hNBhoZFP1sU/V8ubemXqXm1gSrFNbeB/rJVHtINu7TrT6H2q0RZTFHiJSa/62ZHqNFdZBlI72vpbKJRfUl6L/hDugyevBSejCdHcOnQJ0yCmf5FyKsYe7HZgLET8Wog6u3Jzc1z6xQ3OIAXRo7zYZOqvVgeNmjZeXNwApuZMzz4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=whPv99s3; arc=none smtp.client-ip=209.85.208.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="whPv99s3" Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-5e5050d19e9so6638614a12.3 for ; Tue, 04 Mar 2025 02:57:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741085878; x=1741690678; 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=ECyziH9vC+Bjbefgj+dSQZiFMSs3qn0VmvLNDRi3E2g=; b=whPv99s3ZZXLV09HG/qXihTThG/hPvVlI3lPr04mnk6DjMMa2Wma2pDDbMzWsRChk+ 1rXFd/wXIUUjLZ8uMZg6zYCeXqDY/Go+0shiokNZ+XZJAdG/36NuBpJJvt0TWsH/vtKZ aC2MGq8aXxny8Jo8V+v8sHbD8kunq4bPUHWsk9QePa8/dAMVkD0kTmYr/ZXxHP1GW7oZ 7cnZN0WF/0exB80PQIOTFNv4+5SGrxQS5B5/PFO8bs2/sI6YJXClL3sQUUDU0dufqnvL a1PyqMtyIu9ouqFtkoHeSLgjmqJL8fQMY7NB9pOVrqE3s6DCEL8u+Zibbg1jbL6c9CB0 Ar6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741085878; x=1741690678; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ECyziH9vC+Bjbefgj+dSQZiFMSs3qn0VmvLNDRi3E2g=; b=ol7ifqLzb6NsHlx6N4rS8uxqxwIArAZXUU8gCAJUiO9C2ihHZjlhKcwiaw7W4ZMp20 cNHA/6CS5T5UygcLpYpgj52N0QVY50cAuM6MV1zV5uM3LJdN5dS38i0t8GCZVx3w05eI 4QiV1wr1lgwM8t2dGhCxeEcNSANP5Ly1HBPic3p3lfpae16ne4XaAOGoPgNJSn+458uD gu7VAooFwum/P8FR2IteVB+Moz7wTkjhq8eMzZh5Vz3o8DE5BrF5mZNhOkZyywwMuhUt +nFkSl47xIren85yjGDAoasRuJADGVmMBPDAjnOIp0hEjTjAbSXgVzWeXbkengD+lwgh dv8g== X-Forwarded-Encrypted: i=1; AJvYcCXpvTTrZpVp5GvFG/CssbFACqZk487iDvwYNlDBEvpZs8htu6ocM2zqpHXLX2/fMEQYgWYICADLC3ST0es=@vger.kernel.org X-Gm-Message-State: AOJu0YxXZXU6T6zBnFNeMeV0Nc+GQyVAw9imsACRsRNRl9boHpOuaI9z ZaJk5X6rq/X1ehm6a3J11nRnjapb/xJ0OeNL651GTylLPYUPUUdC2Nyf0fKlFZY= X-Gm-Gg: ASbGncs2hO+hih+F2uUDzv3ZbuS+wLogwNdt9XzcLmTpOcUn60lXpFD8r9yX1/RBfHh 7DtJW2PFWQnVha4PHMNmpmyH43HgJnWN5PWT6pksHfmMPC7BwVnXHfH2mEIPClHS2w0TwCZI0Qj pkpB5SYMIiqWWnAhe82SIcSGS4cx8lnJPSSpPkvVE4baKQQdfWzjXjyxFh41jPrx3xjdCe8ctbd yL5th4wPpC8jmaHf2grh6C31jpWsYLmb95IU/0M6QQLr/aujLXRTpLL5YNXAeVaeraessz99iZF xCSFlFB/n/3RUo9F/BHChXMtyeUzWJKODXTH5FTSRqgLrE6rf8qgoJ/PPqKz4WgpLP2YJQ== X-Google-Smtp-Source: AGHT+IHfeHT/FTjffKPwdBKiP6ewQQTMUOqoklnatPZdqtNFAdsCpP2K8dPS2Eccu/L8rXNPyexCvA== X-Received: by 2002:a05:6402:350f:b0:5dc:58ad:b8d5 with SMTP id 4fb4d7f45d1cf-5e4d6ad5fa3mr17089784a12.9.1741085878276; Tue, 04 Mar 2025 02:57:58 -0800 (PST) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5e4c43a5acdsm8002966a12.77.2025.03.04.02.57.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Mar 2025 02:57:57 -0800 (PST) From: srinivas.kandagatla@linaro.org To: broonie@kernel.org Cc: perex@perex.cz, tiwai@suse.com, krzysztof.kozlowski@linaro.org, linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, dmitry.baryshkov@linaro.org, johan+linaro@kernel.org, Srinivas Kandagatla Subject: [PATCH v3 6/6] ASoC: qdsp6: q6apm-dai: fix playback dsp pipeline underruns Date: Tue, 4 Mar 2025 10:57:23 +0000 Message-Id: <20250304105723.10579-7-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250304105723.10579-1-srinivas.kandagatla@linaro.org> References: <20250304105723.10579-1-srinivas.kandagatla@linaro.org> 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 Content-Type: text/plain; charset="utf-8" From: Srinivas Kandagatla QDSP has latency of 10 plus milli seconds, Which is difficult to acheive with just 2 periods and fragment size starting at 128. Increase the number of fragments to 8 so that it fulfils the dsp requirements Without this patch, DSP playback pipeline seems to hit few underruns. Fixes: 9b4fe0f1cd79 ("ASoC: qdsp6: audioreach: add q6apm-dai support") Signed-off-by: Srinivas Kandagatla Tested-by: Krzysztof Kozlowski --- sound/soc/qcom/qdsp6/q6apm-dai.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/qcom/qdsp6/q6apm-dai.c b/sound/soc/qcom/qdsp6/q6apm-= dai.c index aca0a98d58a5..aa6bd359300b 100644 --- a/sound/soc/qcom/qdsp6/q6apm-dai.c +++ b/sound/soc/qcom/qdsp6/q6apm-dai.c @@ -18,8 +18,8 @@ =20 #define DRV_NAME "q6apm-dai" =20 -#define PLAYBACK_MIN_NUM_PERIODS 2 -#define PLAYBACK_MAX_NUM_PERIODS 8 +#define PLAYBACK_MIN_NUM_PERIODS 8 +#define PLAYBACK_MAX_NUM_PERIODS 16 #define PLAYBACK_MAX_PERIOD_SIZE 65536 #define PLAYBACK_MIN_PERIOD_SIZE 128 #define CAPTURE_MIN_NUM_PERIODS 2 --=20 2.39.5