From nobody Tue Dec 16 08:34:54 2025 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.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 502B320371B for ; Fri, 14 Mar 2025 17:48:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741974517; cv=none; b=YrB8VTAbJXMK5neqW5RurIVJUXzyYm0nyBMrGrziGq+LSTpmHkkeMHQM2qKIkJ2Qo9rt4Yk+Lr1bKnHnn3bLP1TD0gzm3TahJh6LuSqFBfqpIaaXJVe6qw3LiMoLa4yYs/ujPMtxwOFWYLNzX1bKW7/ocAfRKJ6zGsVO8cR1mPY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741974517; c=relaxed/simple; bh=HQ7LBpR32xGBqxjc9huA/ExDfMvzkYa6j2dkGfkbsHc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YGCoAeGiB/V3+s21SfjUPOd8pmdbWSuh9ujPnT6UPABLE4YG9b4DJBl514k+zDO6d1ceKWeIsdDX16senB8/xROfR9mLGlfaEpqRLgijUxhaHO6LQap7Tojop4QsBBqS1QgKIkOLZpaCNNXnTMsK9jFKbB1UXUKt/l26r9Hla28= 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=kuUq1lb0; arc=none smtp.client-ip=209.85.128.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="kuUq1lb0" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-4394036c0efso16058525e9.2 for ; Fri, 14 Mar 2025 10:48:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741974513; x=1742579313; 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=UeWiGiaBOkfBI5CIl4K/bsXJMAc22L9UaitEm54UW/g=; b=kuUq1lb0x+x1x0LNJC/9iWGDXpuCQQJBrw/7vMM0yTXL1AQZuZpzadhI+MbwbmGGCG Jq5DDi+ckwaI/stPo/nOeMW5iBw4nSmPinnng8zQTOZiSxAgK2bwg5JomaTAfZHjTCDJ IiZGym5M1P3QpBdwWb10Hi8BN3IwJSES2JbvXIFWioYkG8MCEbUZwajyodEq/j39g/kL sSZWjIO/5f4L42lIqLPi6j3Ez2euJK1Lg7jLskj0IumWCePwkxe5s+rnNscufxhFZelt kgS2dkVIBZK+7q/7GVsNBmF47Y9Z10voTm9Mycj8znSAOZ5XdLf+Zfex8mXLYxZoMFTH aTcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741974513; x=1742579313; 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=UeWiGiaBOkfBI5CIl4K/bsXJMAc22L9UaitEm54UW/g=; b=oLcNOaavR6uroZThjXqlipZad8zJiLXk+uJoV5ps4xOyytXP0O5jRh7fhXZRGzw2bz nYR1c1KCleGyD/QRdfYXRzvGOJ0Pa9CTVMV8Fke0IQLepwngdcW7YjXRCKYgJVZQkutN ynoqURnVbpwvDDbTyh8w/POUw5ZnwylibA0heQOTB5Mbl8/sVgm/wpAMzAOHuw/7/2ve OgGQ+dXKR7sekSeSGUegFVoq0cOLK5+vD1YHei7nJEMQe+4N2TdSJX71sd2XDlrnr04t +dx4kGiLquJ5gz8Ri6yOEM5fj+T4FNizVIIrZbpaRqCZhx7hI9GwyVV+cJNto/VloQNv PqIA== X-Forwarded-Encrypted: i=1; AJvYcCX2OGK5O+88/7g3FWVZnA5FzSruhov8FikH4a7GkLLMt9FkP3XfsWZBe5s3rT4FZXgB1GNZd3xLioxyC4s=@vger.kernel.org X-Gm-Message-State: AOJu0YwUfOtpP7bWHZukiEkiT32QRtbAXFwiYZCYntmenFeWanvZ2OX1 1zxbr0sVFNQTOtakP+dQdtM9cDKMkEEhcnKLJsgTSkeV5euy21Wf8jGYSJZH/C4= X-Gm-Gg: ASbGncts1No32XCZuuazZ8WYSPh56Dozt/2Frcm5tkMQRsVKgOlTK/0m4zg0JzbFiG7 8MV/1GfwPx8RjhzWpgYYyY8VCZXfz0iJb9VIpbhd2Xna2sVLLmFbVgk7IsfQYJMgAH9nC92pcyV q48bz7bMWOlDFjwsw36QLbTDG4woaueNpQgaQxKhqfgZzNzsGnTaSo71LP3XO4xWSt6h+Ey+Aih Z8jMap+UZm/z8SCeVcfbxJRS9F+QqcsTWZCtYeECQgY5ZYwrb37dil/KaYaMuRTaivOMKELdwdn uDQiCz8I6fm0tAThpg3NNVWQNZRayHXWo06as+/JNxhR1komq7vKSqorxct9E3yI/iLAkA== X-Google-Smtp-Source: AGHT+IGXspLE+tLwuq/II5uBd+Om3QATYkBGBnFc09jyWv2iMP8x/7KV53ItXjMrWcN1x5c51ID4zQ== X-Received: by 2002:a5d:6c65:0:b0:390:f641:d8bb with SMTP id ffacd0b85a97d-3971f12d12amr5027495f8f.36.1741974513301; Fri, 14 Mar 2025 10:48:33 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-395c8975afesm6117243f8f.47.2025.03.14.10.48.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Mar 2025 10:48:32 -0700 (PDT) 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 , stable@vger.kernel.org Subject: [PATCH v5 1/5] ASoC: q6apm-dai: schedule all available frames to avoid dsp under-runs Date: Fri, 14 Mar 2025 17:47:56 +0000 Message-Id: <20250314174800.10142-2-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250314174800.10142-1-srinivas.kandagatla@linaro.org> References: <20250314174800.10142-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") Cc: stable@vger.kernel.org Reported-by: Krzysztof Kozlowski Signed-off-by: Srinivas Kandagatla Tested-by: Krzysztof Kozlowski Tested-by: Johan Hovold --- 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 Tue Dec 16 08:34:54 2025 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (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 DEE0A2046A3 for ; Fri, 14 Mar 2025 17:48:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741974519; cv=none; b=uC5uqi5EYr0tPu1r1Pv1YlnO3AV0tN9p9CXVd5Ytq8YPB/3RyTDr6AYOy8oZ6iKOp5alhHqCQioUdKoYYxxtzTPEKQN79WJYGJxcEu8PSdFiR7kyNoiKQohESiRP1rDnjBhNUOy4c79CaONyakcRWcZ9ZKPpi9ga4nhetXxG3+g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741974519; c=relaxed/simple; bh=kR7vQIpKuKVU6uOBjHBa7C2tnbKEH2GpwQgL9Z6Aaqc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=j3eUWvhSzOgjBEKUyo0HxGFyImV/xqexWUOW6BrumncFtgbOXoKd6wT/tRzyX2lCsUqgm4U9Lri9QTe6NQY+wHqeaWTE+6jd66OZeV4cCNusXGFNuUjuRQKjkgMJZCfd7WSMucjjuyqWt2y/NZiJNOP/dxBouwSpdYLcgaHKXuo= 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=qJKBzx7e; arc=none smtp.client-ip=209.85.221.44 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="qJKBzx7e" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-3912baafc58so2110211f8f.1 for ; Fri, 14 Mar 2025 10:48:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741974515; x=1742579315; 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=ekNUjvV0aZinr/Wdt5BX9JoNO1SKBq/J2zFS3VBUJfM=; b=qJKBzx7erXlBrDrOHAxlrJqYfMV9V8SU6mm2rQhgVH48uzIePmZkitHrlcravbY+wL 8bkDKqEKUnRYEDlBcBjAIQ97SQ6Jtcgrb0BKIL3kp5I3DICUqAW5dJatztvqa53FNyuX FKq5dNZNBm0CdPXkp0j+IrVYebOlQZ5iqH2CLpSmmnSAmO9CEl0RWlgHOOA+kaUn/0Cn oYHeLS7SZVvH5Z8fr0fajwwGlN0SIeKd55tLKA3IY7RqKT5eEQFbv76kthPjp6D2vPst IQrbvkKGLmTtnLWrJhNjUL+BZUNbSMwAasIRNX5J74NykSlRe6ycdrMucCwc0acpPeIM OT5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741974515; x=1742579315; 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=ekNUjvV0aZinr/Wdt5BX9JoNO1SKBq/J2zFS3VBUJfM=; b=tApzLnaEnBD5nCdpqmaobzwld2EhoCP/eSRg0diTYlBW4WXhKBVWsFz1LYuyavwJUx 6GbvmZGZpzDEatoL0l5C9tExD9aF9KPovSHvG91BwVEXuDImdIaaHy0rFV8MDK+rqMA/ rP+hEMA8dDELPuSv0S+4/wuOgckhsHEJ2D999xxj9TMkrWi/f5WKSd6BFnPZquV3I3jD sbqIiuSlUftTCDsmy8hnCdipXQk0x2p/ny/J2iHSQq13YsLg/IZfqnxEDqoJmgFZ+u7m xeWAm9g991/drHFyWtz20UrtonHV6nJGj1KQGYH2M+9z9XW8ouYKlkAIduYY12UL0WLq jAqw== X-Forwarded-Encrypted: i=1; AJvYcCV8Yg2oCeUXk4ZcmiUFNfTs5blRGUtOqWIEsHR/Y/RCRXEpn1oQdj0mDnPrNISTxZETdIcCCqgCgWt5qPQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyNjbk09aN2dLv4fb2NpHVqAYMamPCiOOepmx92DVaBdQ/crTIy 57xr+/5Yztg5223ot34Nx6cUrPvBiE4V8tq8Mt//PeHsQPmD7Gduyz4Ie93iSPMmbcIQ8GQOOpH c X-Gm-Gg: ASbGnctcMGJcbzzYU3nq0vgESY5tzh6UCsduU6Pc65f0Ij+frNr5sfHS6ATX9KM0XkO 81yhKoB8ldkcH+61qv3xaF4AAT71trFizwKQnNeE0OjXUXQQ7U8EL6/Y5XLW655LlZ0DdBtFzlV V5/gW7Cs72oPo4qOyzU/+Vt3hkSRc8zlE1Xiejvz49e1HF/x8h1UULwz0hSQGqmD+qvJ/o2oTGw glFg7kj+Gs1C/nw1jtQOr6Ryj3ZI7V7CRc5xAFo1P3ZKn0s3hpyHA9ES9lXwpzBJQx7FvtnFvnN V4ek8+6kioDLdxDn5bmsaEYchGHBZhnWZ9qAQvjZrKlRq+VTXi9RkfL7e59DtA2VO7KtPsGY+ov 0V6rW X-Google-Smtp-Source: AGHT+IENJZZgGY1aoIK7LKxCJxD7lsJhw1CEecwJGhMThtbgrKvCf51QCn31YGELReUPaDMQwLikmw== X-Received: by 2002:a05:6000:1f8b:b0:391:1458:2233 with SMTP id ffacd0b85a97d-3971d235022mr5382107f8f.11.1741974514979; Fri, 14 Mar 2025 10:48:34 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-395c8975afesm6117243f8f.47.2025.03.14.10.48.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Mar 2025 10:48:33 -0700 (PDT) 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 , stable@vger.kernel.org Subject: [PATCH v5 2/5] ASoC: q6apm: add q6apm_get_hw_pointer helper Date: Fri, 14 Mar 2025 17:47:57 +0000 Message-Id: <20250314174800.10142-3-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250314174800.10142-1-srinivas.kandagatla@linaro.org> References: <20250314174800.10142-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") Cc: stable@vger.kernel.org Signed-off-by: Srinivas Kandagatla Tested-by: Krzysztof Kozlowski Tested-by: Johan Hovold --- 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 Tue Dec 16 08:34:54 2025 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (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 A9720204C15 for ; Fri, 14 Mar 2025 17:48:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741974521; cv=none; b=qpz9kMIxYVMHd15fhS9odiXs/r04e5zC4pH1tBS0Qpq9cLyt65/2honM3AV0P4hbFw4qaDpGSlEZZ+JrhB42Akyd0t3buNBaLbHd50egyeqqorxaKywBtjEHQ9b9STjiDlGHOPNWXDcUjg22RxwDEDXGN93hvNv/WpgpSISNSfU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741974521; c=relaxed/simple; bh=GTv0VCH3s0WKdgoZHW+Neb05F5hHPFrcMTNWEHTQEPc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fejA436yjhlgstptj4uX20N2vFTKiS3acV+V5YLw/f+uac5ZspnqsWc7IUmfN4kgUl+oqL8V6B2sHsVxMqt/ph0t7b4O/c6uFw5SP4ommkZdQO9DBValZQbmAsfXJQEYduLZKU/M9XL2IsqtuLU3yd3rCE1hGZjgKt3TptmR7Co= 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=FQk1h7zb; arc=none smtp.client-ip=209.85.221.53 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="FQk1h7zb" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-390fdaf2897so2132958f8f.0 for ; Fri, 14 Mar 2025 10:48:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741974517; x=1742579317; 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=UmD5vNzSSLCYtQiI6TARd80NsNkLFJqSnN180ML5a34=; b=FQk1h7zbG/In83KeSzc7kav2fg+TJmkzb9qqyGOf1JQkubfTfBTtfKNg7dCmKjpXu0 PCDyBEQNDXzn+tisQNBydCsHL83TvzatS1OqrPXXLTjnqPLSbKrPnxiVIXVzpMfiGX+P M396vjnoecIevnUsUNYRJKRoYmFaJ1QRpF04b69AyFAPJ8/N5AUE833NBesTyEYkVB+a cxqekdPkdL1xGKO/a7PXK7q1wasPnO9H9ALe5nlagHWbzWSyg7LiKFOXw9RC+eqMrFtV OkJLN815O8ad/b3Y6ZfJgXE9C0ghNnONUf+2XrZry05hCqvR1IPEofHm2eMLq1q5x4ng G1YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741974517; x=1742579317; 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=UmD5vNzSSLCYtQiI6TARd80NsNkLFJqSnN180ML5a34=; b=POfdbGVZv0p+6BuOjXaJJb3pxyYcIzv49t3TZl0LjLgMJL6Su//2QFwhFGpICVtNFa ZEc9KUQdQTA2JaxFNwDrAmSKlNZZF2+fFtc7y0QDIdkaT9COk9l/xapz1R6MMo3Gqha3 1noh7yse6tuPHeMccCJDDb4FgfqZUgFYda29q6JYBX9ycFBbbhYMis16k6E8IJrpLsFX 9foj0tN7LyNaqwwRm3IxHPsaq2aea7+uMSyqRlLhX7TnkrCZJ9r3J2kLDFYo3QDDkHpy qr9JvjjChkElBiG72jpUzHrwImni9XzWaf0Q1XpgiSNIZkb5OSluhzgKcPMHHmYXuflt 4s4g== X-Forwarded-Encrypted: i=1; AJvYcCWq5MH49gcuRWqKwp2M08uHRM6sC18OXi9tz4+6oRlc4an3/PMWMUaug5Zj920N7+DBuk2V7xxV+JnQnYU=@vger.kernel.org X-Gm-Message-State: AOJu0Yx3T87Q7tS+CkbTp1Yc7VMY+xSgLYRcoSklNnv978ZSAuZxrWW0 vXZej5uhFlL7PbHf5oegWwTyqT8ZZwlJra/Q37RIxVsyM2v5bji54n9LL4R5jNA= X-Gm-Gg: ASbGncsyzxiR16UQqB4+s0ox6z2xBozl3hgG6Eot3puj++d/vt6p0r8xc/bvjrL1Mcw v2xK4EvHKxzYQAYAL3MhM6Rg2Z7aGbNYjUb+J1RQydIKfJbZhMCjNFnzw/KrROQuDqYwdiGEXhB 5MjLwDg2lOwrmBJLqmSqsNEDRxljJSXkfVRjx6awjRJH9SMSXcuhKe06gbZfMMSKWyOsMsnZTJd FEi9OipUsujk2G2StcrtmCwxurP9WQ2YCNLTyS7sp/9g0i8/0nsnGWLb3fIbGlfqqhJckFOZFAJ zwdqNt+jv9MqIGjxr0X/m9xnNdW5nhNdcpSgmKJWYD26bCWJ7dIxQNg0wjJP01MdR+8qFw== X-Google-Smtp-Source: AGHT+IEDC3mTs5ZEgnH5M13Yv5WSovrEtsi3f3jqP63eSIlzIlegYCTCHHMMtUO2OfGOcqcPh6kT9w== X-Received: by 2002:a5d:64c2:0:b0:38c:2745:2df3 with SMTP id ffacd0b85a97d-397202a1acemr4508526f8f.37.1741974516847; Fri, 14 Mar 2025 10:48:36 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-395c8975afesm6117243f8f.47.2025.03.14.10.48.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Mar 2025 10:48:35 -0700 (PDT) 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 , stable@vger.kernel.org Subject: [PATCH v5 3/5] ASoC: q6apm-dai: make use of q6apm_get_hw_pointer Date: Fri, 14 Mar 2025 17:47:58 +0000 Message-Id: <20250314174800.10142-4-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250314174800.10142-1-srinivas.kandagatla@linaro.org> References: <20250314174800.10142-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") Cc: stable@vger.kernel.org Signed-off-by: Srinivas Kandagatla Tested-by: Krzysztof Kozlowski Tested-by: Johan Hovold Tested-by: Christopher Obbard --- 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 Tue Dec 16 08:34:54 2025 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 DBBA3204C3F for ; Fri, 14 Mar 2025 17:48:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741974521; cv=none; b=QRfifWqdncllPsVE2AFpCSiMdjbO94UNCC/KF96nOUF81HxJt3s9+OPty+dT2NQilSMjuge6GHSDq0+FAzbl/YDJMPiMxawcgxDuQ6VFVfXFeBiMNlHrHCD9RO+QX18icAozj9cVeYlEtSpJ7QGli88xM303ZBBfVOjF/AJINB8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741974521; c=relaxed/simple; bh=mDhcxCgdC1Fi4Bo8nQTGMpqT/fTEu0Rlo6oOEAE3xhM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=E0bmXpHO/a+OsWiXlgpKslFVln2KXqns/tszUekByGY8qz0Gp2EZ/hnpNRCF7xaukBK8vmxeu8rX1GWe2SOlC0fgVvkZZbEjrg2b/IUV2FuLdzF2IQ4/3tSmTYcKcaa3FbR+AkB4UkGjQ4eHZ8pPAJEzUdFt40CNqTdpCz/MXD8= 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=gXfqWfDm; arc=none smtp.client-ip=209.85.128.41 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="gXfqWfDm" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-43cf848528aso22666815e9.2 for ; Fri, 14 Mar 2025 10:48:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741974518; x=1742579318; 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=jdTVjAwVNmK2jLxhOXzxyRxn49OEqRRCS+ScTGbOGto=; b=gXfqWfDmh+B1szU5Xa0RAATYoSCm5lGgeMqwIDeQB+jdV+yo6hkpOndNHNCax5Y1oa rGLvo89PnQfVQyKDvicTfVKhEJiZcX8bXUfinrnm3txJnn1xbQe5r3zTbVM9GetXTvwf Gmo1twwUXRJnqTo8z0q1kLoq05jYJCkX0lrqBAuOeMDzV5VVLOsOXZk31yy/bmNjNAfd oXDihB0gUzyURfOy7/OaIYxl6u0yEeKT85X0j33Ff8ajytNEgMgnEhlxVvG4W78gmVLV BHJPsORyFJhUc9qH6WuQ+afT5KFe0QeoDAVjx1tKqbFCdc1wBsDseisnfrTSQrHh3RD0 RjFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741974518; x=1742579318; 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=jdTVjAwVNmK2jLxhOXzxyRxn49OEqRRCS+ScTGbOGto=; b=rc92jfut9EfEnjq+wmOogCltYEatCy2XkL0GZNXk0kyUHPmWcbZ7JuTRL79IwbxJIT +/tbwYjlsWvOpyOKbbiFtyZdfwOYDL6UAZI43K6V9pZjz7+XEmkPKRkJea4m5RQ8UWLz O5iWcepHvymNS9kxYfESXKAbqVGO6vgYrlTANpzG9BRTbi9bQHynrWIEqA7ceZbK/Gvd H7rgmb79A4CVYR6pvSFkUUTR5ebCxhRBjs1jS314qeyQYtK/MJLlPgJyjZP7IUyad/3O nHLr1ta9Aw0sktydnwl+Rz4wu7erOLAT78BalHpDhqYszk9TBugaJbxVON6xUqmytWzp MRgA== X-Forwarded-Encrypted: i=1; AJvYcCWlDN99FnZZ22UWYbfAB45etOWpd81vKMBc68bFrfB8gn1NWyK5+0rL9bJgJ8tsodtsEAnoJRCeWeCUtmI=@vger.kernel.org X-Gm-Message-State: AOJu0YwWkPFjnfmS3XnhbloLmnI8fvBiouDXrjiJ9hjb5kvf9NryxVKM gYYY+Oyv/V9ZAIJKGYy59ccc6pD4u0JvicANSD2Jywgaq8WWkP0yK43k9DK1hHk= X-Gm-Gg: ASbGncsWc1gP5MZ65w4xAMC4bOmvArD0XrRmYadDWnF7s6HdoAuMWl12TLGFdbq7jTo hYUUX3Tzj7Q+7ohM0NFz4XPPoOHMt5g41w4DbjKjKsOHZ8XStJYqaVGmq1hYauAzx6gXqSxHPJ0 50qPfJyARrcWVo/bvV4zVY4I71obuibi76UFHhr/Zzfkrg1oZErq/ym5cn9Z8nvhGIjtzQsPekK m1ofH/5XxHO3g1mJHcVQjBDHZCq40mrfrLqCSwlM8d3FeAcG5DRFVMbMNBg/BR1Kxg6APGTi+YR //f8+cOHFZ4RyYd8BMZy8QmoJ5l894dfmkgzI4Sq4xGggvK1TVzpqOxJ7F1VBGhisErPzQ== X-Google-Smtp-Source: AGHT+IGcUNko8z5XQMYL2/1B8FhFeQVonlKSYBeZ53undzrD9L8aOYiUUqdt7GUF3RfwMi42lXGfRA== X-Received: by 2002:a05:600c:1994:b0:43c:f470:7605 with SMTP id 5b1f17b1804b1-43d1ec80e5cmr44898745e9.12.1741974518070; Fri, 14 Mar 2025 10:48:38 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-395c8975afesm6117243f8f.47.2025.03.14.10.48.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Mar 2025 10:48:37 -0700 (PDT) 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 , stable@vger.kernel.org Subject: [PATCH v5 4/5] ASoC: qdsp6: q6apm-dai: set 10 ms period and buffer alignment. Date: Fri, 14 Mar 2025 17:47:59 +0000 Message-Id: <20250314174800.10142-5-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250314174800.10142-1-srinivas.kandagatla@linaro.org> References: <20250314174800.10142-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 periods to be aligned to fragment sizes, currently setting up to hw constriants on periods bytes is not going to work correctly as we can endup with periods sizes aligned to 32 bytes however not aligned to fragment size. Update the constriants to use fragment size, and also set at step of 10ms for period size to accommodate DSP requirements of 10ms latency. Fixes: 9b4fe0f1cd79 ("ASoC: qdsp6: audioreach: add q6apm-dai support") Cc: stable@vger.kernel.org Signed-off-by: Srinivas Kandagatla Tested-by: Johan Hovold --- sound/soc/qcom/qdsp6/q6apm-dai.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/soc/qcom/qdsp6/q6apm-dai.c b/sound/soc/qcom/qdsp6/q6apm-= dai.c index 90cb24947f31..180ff24041bf 100644 --- a/sound/soc/qcom/qdsp6/q6apm-dai.c +++ b/sound/soc/qcom/qdsp6/q6apm-dai.c @@ -385,13 +385,14 @@ 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); + /* setup 10ms latency to accommodate DSP restrictions */ + ret =3D snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_= SIZE, 480); 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_= SIZE, 480); if (ret < 0) { dev_err(dev, "constraint for buffer bytes step ret =3D %d\n", ret); goto err; --=20 2.39.5 From nobody Tue Dec 16 08:34:54 2025 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.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 A451B204F96 for ; Fri, 14 Mar 2025 17:48:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741974524; cv=none; b=XvfQqEVqhXrIWwS6pUxa4J0SGWUPeSeFDmbKvs24fqV9gFpBNrzO6rhSmz/kJjV9tuYgCdlGYbC7M+R9GnsRwiOB8eGpFTSFR6DhsJVq3i504XcSN3Mj4VBNhQ9yk36sVufpirWUdYt4WFdt4rK6LN85g/YToUaDHVQ14Axiru8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741974524; c=relaxed/simple; bh=WZz3v+vsHhPD1tXnM2Sgca+yquBEKJ/qJRDwgWjeJjQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Q4j9WJEcxXiH+e1PzindI+KJl7rkhhiHYVU0f61ufK2KyjW6HZOGtE1yfkrBx75CY2IDNDKVS30C9GJSAObAy7lpCoRDGJzboANmqrxojsqf4GeY2HJvJTeqx4cCbfqcU9YuMSrHqIwT2qe+MXEXmS246tGuumgIcn2H2s95hbY= 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=r86B2yOL; arc=none smtp.client-ip=209.85.221.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="r86B2yOL" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-3913fdd003bso1274762f8f.1 for ; Fri, 14 Mar 2025 10:48:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741974520; x=1742579320; 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=J/0LkOzwwvJNcYMQhvQr0pJ6M6A5VssVoqwJh0FipfI=; b=r86B2yOLrp5ovBL+sphVOm7K+tIjuBHFQSZ4+WqizlY5llipVKCrSY84Wk8kFSlOwa jxc4o7LZHP5h1wT9oIiUfYqMwCZetBrYCywa0qOngkxNwfbFD8SEwMePLXaT9oUUldAE 2vaHBFec4+lgB+ri/yRit/iclJ7YC3JNFIcdNQTWFfeyBvJGu2+uDOJO++VKsUgsYuLU gFSxpIBnvExg5ozA1LOC3LiDKy0rwzXM56xLvGvRKYWsdzKDC/ty8XxivYvWWs+ZH4ae 7W4gYAk/tNYVWRcsTh6DDqni1hhWfg9cZuLHrrKyfcCdlZcaIpG71ftPZUhxUkgj+/BO FgeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741974520; x=1742579320; 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=J/0LkOzwwvJNcYMQhvQr0pJ6M6A5VssVoqwJh0FipfI=; b=UuSha/rMmG8mcdg13y1rWEhFuDsix/nOyuSHEKdB8+NT77RulYcJZiLw/MItsOSgUL euygda0nGxqVo2C48YC0t+BUkZz50pU6IgP3ODG/WWllZuFAiwkk7XgoQuYc40uQAY7o xZrhTr54Brt734WkAdXVSehMjuv7ghjLkKgTJnBDcTx72/TeZDgwKL4u1SBkM5s8w1P3 EqdZx73wGyG2PYmIYpSvbvNjGpjxD18jm1B/ZzCPZ3tq6DFV6nAA/FV4niNDlFvjigb8 7ilI5ZM/K8YhQlBQBrXBQEBr5C2wsvZhCFqZJah4fDQ6Zqto5N/thvRJZLHxBHfzYClX dFDw== X-Forwarded-Encrypted: i=1; AJvYcCWdSdOC01TP3vSPOMve87ZZLsEnmq2yrtkiLu/tVoNR8XyNVNFzFKvLTF+r3cmd6oEcSHWsOyp3QypWjFE=@vger.kernel.org X-Gm-Message-State: AOJu0YwJamSx8M6j1X7oJHwIljBaMPApkaCOt/nkCg1JbdGmsbj2sRd1 LnqhmA37857wkFkplShDl3RHxvlSxeR1t4uYMgucYwcolQSqv3Vlmv0A3Vl2ONg= X-Gm-Gg: ASbGncu6LPBfDovpodctg8pslytE8RD97XhCtIOtAGbjtNPMt3/7U56f/ARLWED7ZB4 Ur+ZK15GYV/DEpggOg71EBuqf1lk6LzYJPC+NoStJAmGOVevQuRwsEVT4RezTthZKpo48E55CU9 4TIvPVs0goubeUf5seJH0jZPReqPfzTCotWaUhf4BRCrjStxYsKfpUflDRX2m4Zet8uzw2IVS6G zJs/JfUofWDbMXvE0KxBTRQsxVzXKP1o0TwOROI5i4DsItnJ0qmX3UM1o4Wm5Hmm5NS2XU7PtQt CUUUx8GQT3MuAmaPNoN5A6fBiex6utggkCz9heSj40y1OtCcXaMywPO15nwJk9MBfnyIcJ5NhT2 NcllF X-Google-Smtp-Source: AGHT+IFSURXCATif01r54d+KQHoWw2qah8uuJQ120su2MkweaWrQyfg3Zuqy7P/UA//iCx8NnbbY1Q== X-Received: by 2002:a05:6000:1a8c:b0:38d:ae1e:2f3c with SMTP id ffacd0b85a97d-3971dbe80bemr5173220f8f.25.1741974519796; Fri, 14 Mar 2025 10:48:39 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-395c8975afesm6117243f8f.47.2025.03.14.10.48.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Mar 2025 10:48:38 -0700 (PDT) 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 , stable@vger.kernel.org Subject: [PATCH v5 5/5] ASoC: qdsp6: q6apm-dai: fix capture pipeline overruns. Date: Fri, 14 Mar 2025 17:48:00 +0000 Message-Id: <20250314174800.10142-6-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250314174800.10142-1-srinivas.kandagatla@linaro.org> References: <20250314174800.10142-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") Cc: stable@vger.kernel.org Signed-off-by: Srinivas Kandagatla Tested-by: Krzysztof Kozlowski Tested-by: Johan Hovold --- 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 180ff24041bf..2cd522108221 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