From patchwork Tue Mar 4 10:57:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 14000436 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 869AF1FE469 for ; Tue, 4 Mar 2025 10:57:53 +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=1741085876; cv=none; b=FqlGfajWpqZNBW0aYMRvhjU8e5n9mWLaPhKWqwJhZLde/7t9ieTV1lxrVuiW6YYhNXC2e9NL2dDZrmL3onFbxiFG51AWgKY4Q5FHHADQu9cxhRN6+F1Zj0o+mfmkPeHsQx9+2aGqrwjMi/3x1UXNu66jTeVSw4PNbOfMkwQvE8s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741085876; c=relaxed/simple; bh=a8wBb5Pu3Xn+ai4AGmTn/n+jSwHVc64nuzgsrIqk6KU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VcbFTrX6DpABWGo4N2MYSB2X3yujZHdW//QmgqNLVh/ZJLFKkZw8Pleht5jp009oTDi+vaTJJN9jQQubfZpKWSlp/5xQ78DWNyAFa9TGpJZ0I0EFzUZ6iFRDm0UCE74bhfgQCh0n2Wae8hjx+fJonRWrcliHPj1mzc09Y0mBy+I= 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.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="uy/lLvWZ" Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-5e4c0c12bccso9692974a12.1 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=gPSoEwekVylkfftWM9uA9iffznUOnSlrbQC3znbDquNFvxumUYhhzEv9OSF4JJRxg5 +7JBzPZ5dkXVIg2klwSwuoDRAfPB1n2SezSrP78UlZcdOZQdnrMqWMTtBnFDG9ci8WVe gv9EcIf+k0QahxPL+raNmS9wqyH+jIrsYohfMwi/av1vh0PLzOlroPHAi70X5tEFWsA2 EonUNY2VHUbNUVQRoVO2AXLhfx8X7DDo6mgqm+aafqQyVpqGr53POiVPa4SUQswWH9nx ZlA4t8Wqc0Lx88TV9XWRoH42J7wgV375mEBLCZW9iuOm7iCAcXg5UOr8NfMr8VU53kP2 ddBg== X-Forwarded-Encrypted: i=1; AJvYcCUwfvMF3EStte4FvgO7gRk82jt9/CsbHa1dyuN1+q8Q1r9nt8Xhz2dbQp7A9L23Q32x/S6SX0FSdclDmQ==@vger.kernel.org X-Gm-Message-State: AOJu0YyJ7KD/DkS5gr1s5VNYLoiie/fOlKckcm9n3iAAR8aXMCIpJv0r 7wdSiqq/ER4X8WCUT0khGbq2+w0QTjlurfMBXS7QdjH09CXbQQEJPQmCmH+T3kY= X-Gm-Gg: ASbGncv7nKlyDKSsrNDwpdN9nasGR13jkgPU+GVjNt5cDDnv4odLJKJe/6Q5tjfU1lE wpaXgzFFRUkcIF2b1s+Zuywu25HuRHpLJRh1Z12+VtQIgOwMfMSfJQO7wnCPHXx/9eEECU7cpM7 a57usRpzgxapuzakk9vp6scbJWGZwb6rd3mL5aTghkwA0OyE2VJBajGUZ5aoqMjseUFonoREtUo eWKBcyL/iXZpXhe1weSxtgo6So8Xu2bCF+Pk28VlZBeD/RwxpWXbeRlkH57ZviWESounU8qWIx7 z2o/wE4/iYghSmdYuCiGpZyfulH2rJyNQ5qTyM3o0xhyyQ0O/PzDI5+Q0suiErKuzqHwPQ== 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-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- 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 token, void *payload, void * prtd->pos += prtd->pcm_count; spin_unlock_irqrestore(&prtd->lock, flags); snd_pcm_period_elapsed(substream); - if (prtd->state == Q6APM_STREAM_RUNNING) - q6apm_write_async(prtd->graph, prtd->pcm_count, 0, 0, 0); break; case APM_CLIENT_EVENT_DATA_READ_DONE: @@ -294,6 +293,27 @@ static int q6apm_dai_prepare(struct snd_soc_component *component, return 0; } +static int q6apm_dai_ack(struct snd_soc_component *component, struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct q6apm_dai_rtd *prtd = runtime->private_data; + int i, ret = 0, avail_periods; + + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + avail_periods = (runtime->control->appl_ptr - prtd->queue_ptr)/runtime->period_size; + for (i = 0; i < avail_periods; i++) { + ret = q6apm_write_async(prtd->graph, prtd->pcm_count, 0, 0, NO_TIMESTAMP); + if (ret < 0) { + dev_err(component->dev, "Error queuing playback buffer %d\n", ret); + return ret; + } + prtd->queue_ptr += 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 == SNDRV_PCM_STREAM_PLAYBACK) - ret = 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_dai_component = { .hw_params = q6apm_dai_hw_params, .pointer = q6apm_dai_pointer, .trigger = q6apm_dai_trigger, + .ack = q6apm_dai_ack, .compress_ops = &q6apm_dai_compress_ops, .use_dai_pcm_id = true, }; From patchwork Tue Mar 4 10:57:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 14000437 Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) (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 A56A11FF1AB for ; Tue, 4 Mar 2025 10:57:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741085877; cv=none; b=AmsoekmmTWUIrBG1aRXu4F27aeRiu/gGKVEhFRiK5rR5bkdqf9WQvkRAgAr5j7np4zQnf7rRRFAx4VTlrVQruCUVehAIoqewgbjX3qhuLxH85ThKUAyz0dDl1MAPMpbWAn1AUFCoJDpXZInPXJYC//X9XgB0zPDziHKCuPQ8QiE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741085877; c=relaxed/simple; bh=1xefXhqlbqpAB2oQqLsGbrSi7RBtCPYZ7ZpO6A4CBvY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QJkd7uZkIxqVJdSNZZudyOvGantDk7eEutCsxhkdxQso0tIY2PfrGch5IuUurME8iU+OpxoIgfOWwFhGEZaq7frFgcYGQOGb/9sW0sqhZS5ap0lDpaX4A5BzuiJ6Vt5SZ1DvD3cMQ4bYeN4ZVGNFF2zZJ7hn5qJvS6qfiN9/Mw0= 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.51 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-f51.google.com with SMTP id 4fb4d7f45d1cf-5e4ce6e3b8cso2000684a12.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=ZyWQj2esOTS0x5mWaROE0f40/Q6ZT6Qc7kxu3Sj/juyNnYkdOJyhWXHq+IlhJgoEWI AoGY7sDBq0qEGnxrtBIe9fBvcL2y6aRNYEwTfeiK9ls/dqxPgBelx8IHCMkY0LMu1QGS OxUfcDCeYBXWQH7HVmnVfFSEIVqR8m61NPc/U7iba+G5LFsAHTxNUgltMgA6BCXUVdUY 9s6bxdD7s/n9OXR2ntH7acPdcqPSlA6pLzkcuORAvNx/yO8/D5r9HeFASFJmxfyzL6vr EeWXXn5ehtGEVIP9t8quQQYiJgohtiuaQI0apRU/BpDPfhexdhFqTtsEiOuayR0goZcl RgIQ== X-Forwarded-Encrypted: i=1; AJvYcCUK3gRVWJKpy4q/jzT4tmN8l++whAYoaCSUJrc4WNZRLdHpG3p965ZCnlpal9DglqTVVSatwit2icYvGA==@vger.kernel.org X-Gm-Message-State: AOJu0Yw+69fGTouOOtvgrTiTMSS6BeQGHqy7swoxX3MJn3yzO0HRTaef o1wmFzCAYGG74TJf5btgHKFkMw2jattru4HuuR90DxL8duERoYwmf5P9bpMMd6I= X-Gm-Gg: ASbGncvMDSlUWiQeHaN3iz818HG16kqHb035pRTqQH/91RhL3kdStynjXYxg5XnBkS0 R626eRDImm0LeRmfIKHm1WWKSpAs5XWsz3qaqZJNuOeWX6nsx7qnKaWxjombWGUG0DNcK4+GuBY FYG1DyEa7+kSORZ0O0uXjdoCgbNeoAshKM4C5vx4r80dKPAyPezFDX9hWklAzSV5/6QjTK5by8I meh4bXF2tvJspWaj/+DHT/b04wpJte49QUmeTBYgkcg52O7Gm1dqh1vP0YrThH0lMHB5wqjRHo/ RMd8fDYmWmh1oa4bxSoPy1PfLwnPByRCAA6crYZcZ5PCRowPgeE7LPKUrltZ4tDWmFzC8Q== 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-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- 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); +int q6apm_get_hw_pointer(struct q6apm_graph *graph, int dir) +{ + struct audioreach_graph_data *data; + + if (dir == SNDRV_PCM_STREAM_PLAYBACK) + data = &graph->rx_data; + else + data = &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, void *priv, int op) done = data->payload; phys = 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) == done->buf_addr_lsw && upper_32_bits(phys) == done->buf_addr_msw) { graph->result.opcode = hdr->opcode; @@ -553,6 +567,8 @@ static int graph_callback(struct gpr_resp_pkt *data, void *priv, int op) rd_done = data->payload; phys = 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); if (upper_32_bits(phys) == rd_done->buf_addr_msw && lower_32_bits(phys) == 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; }; struct audioreach_graph { @@ -150,4 +152,5 @@ int q6apm_enable_compress_module(struct device *dev, struct q6apm_graph *graph, int q6apm_remove_initial_silence(struct device *dev, struct q6apm_graph *graph, 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_ */ From patchwork Tue Mar 4 10:57:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 14000438 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 509881FF611 for ; Tue, 4 Mar 2025 10:57:56 +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=1741085878; cv=none; b=HB8teNJRoUm43AtgPcUiawoTzSTzMNDm6SF/MWuiqgKWXcFdCL+3IR9HkOf1oTQ3M6vu6qYlauVDoWM69oW1P8ffzL8tg9+scsDnIx5L2tJbnuEfnOvoBBQrPTePMfTAgHKlnIvpJDTLyw8O43SkzDV+/tQ3JpCVkh0EnjDHxAU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741085878; c=relaxed/simple; bh=2cyClla8P6nWRItjw60GOMchhN9i8E2qxWYIAydEh1U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IuKOLM8wpT+KaIIXcDPWR9qejbX8JjcFvkxVXSGflvdShha2o6+t97J4YQNok47JefIVpxthmjNl6cmF1ZSpEEH0ZE0RYdia8oI9lkjztFLc6WUa/AqrfWy0BY6I7b14ZS5Y29e9N/DVkwU+Tce3GErF/iyVM0wzx+EiSS/yGns= 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.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="pNba2wxU" Received: by mail-ed1-f50.google.com with SMTP id 4fb4d7f45d1cf-5dca468c5e4so9845396a12.1 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=W1EwpekSmvQTVPVsjFFLKdb5twnWzczpCHc11hQKAi3iKbQdbyB5NnuF7SZ3lOA5t/ ZI7ME9kiVqFK5C16thOPA7avKxRgPkeKXFxEuf8WQawRHPmROGJNJL6JcbKVTnGX52aC Qowql//xHPefp1pf8IEl2Uzn0+d/y5LzXZFSwm3BfCmVMnNXX9MVF8OOtfSOeswl6oUz CKOtFEz2Y5UDc54QZmVf5WvjLClHRwKEokAa6SpXeF6Apq0u5XRRFaoUYRLQzJV10Sb6 P0tcksgHGfAf/BWDtOa4zgvDh24qAk2+vLaYMd3cKRj4ApVXNNZkG6ZNnEI27abMOUxe 4hzg== X-Forwarded-Encrypted: i=1; AJvYcCW9JqJHHEkYjvHiEjpYqW9L05UbtSfp5wPe5i6RPr1Nxkx7HxYbwwieUyl4a24ZCc02DZGrhELOWFS3MQ==@vger.kernel.org X-Gm-Message-State: AOJu0YwyTGYIwlBamUsjGBHp3L4JwtPl/y/yB0x1112IZ0XcFebXVdjy HPQ5ZiUdcEoLnnPneZPRK0zIz1ic83xZAhtPiUEvPUm0iJeqkhrQEEdoS0lNtTQ= X-Gm-Gg: ASbGncv5UWigU+4LclpSPn8G3v8B7bjq7p4EdU+UZtScw1c7c3q9JlOO+XkMikPsfoa 4t6mRiG7U0cPwVXtCCraxZFzZ46GFYXTPmTGqrswfj82yNPS9VD1JYYfZnzpVl/Ptht8MwaTaYj qwKlqu+Nk26TCDt8n4B77uT+I0kJexf7De7BRZSoB0+hH09oTpH88h3LRRQV6Tye+UvuHNmOLaM c15Ro9ykjYVBtiq4kt+Y3Kc49T0vJ4LCbveAyZrD376cgoT+c9McgXlTM2x/lTEC6pcaiHdzcIk khoDUQvWOp9weu71uQdwvApK5yOugvwHPv37dy47CAJ9TOonD4dXEk5nR5TpCfJxP4XVoA== 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-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 = 12288, buffer size = 12288, period size = 1536 snd-x1e80100 sound: invalid position: pcmC0D0p:0, pos = 12288, buffer size = 12288, period size = 1536 Fixes: 9b4fe0f1cd79 ("ASoC: qdsp6: audioreach: add q6apm-dai support") Signed-off-by: Srinivas Kandagatla --- 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 token, void *payload, void * { struct q6apm_dai_rtd *prtd = priv; struct snd_pcm_substream *substream = prtd->substream; - unsigned long flags; switch (opcode) { case APM_CLIENT_EVENT_CMD_EOS_DONE: prtd->state = Q6APM_STREAM_STOPPED; break; case APM_CLIENT_EVENT_DATA_WRITE_DONE: - spin_lock_irqsave(&prtd->lock, flags); - prtd->pos += prtd->pcm_count; - spin_unlock_irqrestore(&prtd->lock, flags); snd_pcm_period_elapsed(substream); break; case APM_CLIENT_EVENT_DATA_READ_DONE: - spin_lock_irqsave(&prtd->lock, flags); - prtd->pos += prtd->pcm_count; - spin_unlock_irqrestore(&prtd->lock, flags); snd_pcm_period_elapsed(substream); if (prtd->state == Q6APM_STREAM_RUNNING) q6apm_read(prtd->graph); @@ -247,7 +239,6 @@ static int q6apm_dai_prepare(struct snd_soc_component *component, } prtd->pcm_count = snd_pcm_lib_period_bytes(substream); - prtd->pos = 0; /* rate and channels are sent to audio driver */ ret = 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 = substream->runtime; struct q6apm_dai_rtd *prtd = runtime->private_data; snd_pcm_uframes_t ptr; - unsigned long flags; - spin_lock_irqsave(&prtd->lock, flags); - if (prtd->pos == prtd->pcm_size) - prtd->pos = 0; - - ptr = bytes_to_frames(runtime, prtd->pos); - spin_unlock_irqrestore(&prtd->lock, flags); + ptr = q6apm_get_hw_pointer(prtd->graph, substream->stream) * runtime->period_size; + if (ptr) + return ptr - 1; - return ptr; + return 0; } 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_component *component, prtd->pcm_size = runtime->fragments * runtime->fragment_size; prtd->bits_per_sample = 16; - prtd->pos = 0; - if (prtd->next_track != true) { memcpy(&prtd->codec, codec, sizeof(*codec)); From patchwork Tue Mar 4 10:57:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 14000439 Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) (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 89D421FFC4C for ; Tue, 4 Mar 2025 10:57:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741085879; cv=none; b=R3UiwBAZnGL5BrrAtbLjAnvHtPaQFoSAvCSdxgQGoRmLP7fxAykTPWRSLT7j7rVB3bIQgLWAoYaTnpiNkkAnAlWrHPrMfl31oGXBuZ55BYz79Na3nXHkN5/T1w9z2ZsLb7nxHZGg56/Ek6fl/xPMBwR55+aGo+w4VVuBhMALlr0= 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.48 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-f48.google.com with SMTP id 4fb4d7f45d1cf-5dc89df7eccso8989890a12.3 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=YkEOMs6oB3B1ey+VCW6DzTztD6hy+NoHouxUf+6wrm+1OkBMCDcDLX1pnro3RuzxHv vJTpFQzNzEjfdTJ7d9Im6jC+IJZE+ckkbhOE9eDLgCgHxuP+7O95mLO213Pk88yVGPG/ an36R5KWkubJR/x+jLadWQ1s3WNtDyKbdadAcWOgrCHAldMIppPNJeMnK70/c3nZlmHz kRi77UaXI/3C8HN97pQauCWptJA/S82FAbb7gsN2W4/JI0stTIde+vcffKMFbwjz4G2S oBWSosXqJp3e92c8oUfj804+ABkk8LowBkDg01P7AV9Sw00/ZFFxvjrRzRoUKNyEchsd 40Yw== X-Forwarded-Encrypted: i=1; AJvYcCWm6THntIwvdlNbqc6Df38uJqL/9tcu0IX/PvtWKUAsxWzCrpvjXK2An15h6XcyH9WUWvK7CIAwjomi0w==@vger.kernel.org X-Gm-Message-State: AOJu0YyvJIIOAR73K9ifekQAEQ9pkwwkHLUj1iKYc19bxqYJPak+885A NFrLNvsEDNHSqXd6ew//72wsVVWWGPkcea6BX3DfO50xGD/k4Smgj1gfafbDqAw= X-Gm-Gg: ASbGncsa4R4xmh5ICv4eTxAAtnZ2a3PCk6qj7Z8wNOGkf83zkzUcCDovFsG5rjL06/W 9glNPX3wzxpMgpX5XNBRPReK4ZYetUrYiAoqUY8XYVAWKOaFxcm5WCZ/tMvCc1x5cD82jtU/ASF TjXezg7AWUSCq9c60PlGoLOzcmqE9NVhAAsA/x+CzYBookMl9/zOk4wLP/wFAaKuiXWvLFvSUuH qftRFe0A/0g7lg09qWwmJWO9e6sx+0cAO0dFfIQf20s/6q9U/m+U4ZBYb4TpGi5GcaPTd5hp123 KOZ4W81TOf8LZ6Bgr40NW17z7keKduh9Z31dqypbNKIvWtCsP3AfFuveyZVgyT7C1ZiTdg== 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-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- 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 *component, } } - ret = snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 32); + ret = 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 = %d\n", ret); goto err; } - ret = snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 32); + ret = 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 = %d\n", ret); goto err; From patchwork Tue Mar 4 10:57:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 14000440 Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.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 B74FF1FF605 for ; Tue, 4 Mar 2025 10:57:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741085880; cv=none; b=ppkBnTZasGLKJGoOEaBcaF2NGMHVOsJ9Q3r+IH8HQnUoYRQLAfIjMOwB4kBRN6yKpfSAGbAeAAJCvTPejdADvjmiE4JtLRa3Di2yxrapo7xu4YyoOhB2VwY/JgEHZk/v3DRtfDOwv8a745JUxif1m5UO04296vwYvKafOD/w1xA= 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.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="MbZ5SdHZ" Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-5e538388dd1so3017108a12.1 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=TFlyJzw7eITzpK1tDz5L+pFlTcmUlMygg4ydqrZ4uCyKrFiyIDqPdsdNjtmRcVxGD0 mzyCW8vNeeBwYE7/HWhvPklFJ9/lrj9Ji+IKTgauA8mnQT5eM869R9A5RnnGSGmMBK/J o0/S/6h6eXLJc/AvD9vMLfC9rAwJTFnsjpXyB4uuyd1jpoMTelaUVUme39OJIzzMFmtm UXkpKIt6RJqExbxEUk5Vz4qCM9tMCpx/LQuzwS0MeBWZiGoRLnrSqTEECKV829SflSt5 SsQLOErrZ6o94JtYaK5u4yp8GsCNumv4dcpupKd4kRFv2QK8JWvWutFzFYRCj4ZfI7Qi pYiA== X-Forwarded-Encrypted: i=1; AJvYcCUmKueauc7puIYrvaytcR3J4iD5QASfa1xg/kd1VRtyRGuG4G0TN8MzFqqgNIWvuai1nw4RwdPO1b1Ngg==@vger.kernel.org X-Gm-Message-State: AOJu0YwKk9eWgYvwt9gHXcLsj9hLPpBfoFdiaCaSGM7kUql5a3bntBag 5sL9NUp9dPAoiWzksJpElL0bmH4yuPS7XoiC7/mxDur45ss5BDCNEYKsuLa07x0= X-Gm-Gg: ASbGncsOY4EB93eI77bhcyWg7Pzdrpju+Dkdyo/7OmTYf6fUuHbFaG8LCfI3XLanJFS e7+McJCfv1RXEbjDNzlpwsNGEi8O3tUEO7+NeVh1w8MtUMPzlsRLtCL7jCRuwJOGEYQku7VG2oQ waZvqf82G9bZZi8lpVqaAv4ttUyxv+eyT60SnCC619zASgVC64D4wmtao5U4ryiNcChukCk/77P BnQe0bIfVMdOIODH8mC2YqdCslJ8hiNqO0PTENOWekfC5wKPMk9hysxK2ZAb1BkDqP9H/s91Hgt 4Mt+4EFls5hCl45SCvR3FvqcZzt5sQljRd6OyiQ7Lu6G8OTIn2SZ/Nt+KMxBxRTLwM9iig== 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-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 with. Fixes: 9b4fe0f1cd79 ("ASoC: qdsp6: audioreach: add q6apm-dai support") Signed-off-by: Srinivas Kandagatla --- 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_SIZE) #define BUFFER_BYTES_MIN (PLAYBACK_MIN_NUM_PERIODS * PLAYBACK_MIN_PERIOD_SIZE) #define COMPR_PLAYBACK_MAX_FRAGMENT_SIZE (128 * 1024) From patchwork Tue Mar 4 10:57:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 14000441 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 09152200B8B for ; Tue, 4 Mar 2025 10:57:59 +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=1741085881; cv=none; b=I7/VetGu4gTkAAwXGFySPJ0pyFfyq5xg049iHMxyt35P1g8rr0Xh5myqHkUFndrqyszx7cdgzzBEgffEEvlJHtiKI2iPTRFPzchMwAuEesvrDIk3juBsYtABRylYm22BRymARlgcI1QnSigNpKjvQtmU5r+4tgsNoLU6ZutQQ34= 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.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="whPv99s3" Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-5e0b70fb1daso9507786a12.1 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=Q7QNNdnnOlWQTXGFoOb19bhYNcEp9X6f8CtT/QrIa5nsWC57sgUY4NJjtBtjZP53z8 MQvg8beLfmvG5NSl9DKLkPpcVqo7h8FKuoxsuQ5B12i/20FXB4aEmpAcrZ1hlYRW5y7Y 9ZCXVoEBJEb44WwZ30CP5kx6yBYVyZi29T+7wXOAgU8pAcjQLWgjcHFukjgI+ctvagGD kcSay08Q5bQtBvq5fOrihH2EiWIVZipvVRYnka6/1lzBHCLR7Ox4kioA2WhiirZ5eQ6i DslzWd5c+7itZcHUNI7LOoV5t6gw0uazu5Xr5V8hygNvclw1EatFmO2GjBFBvs4WvCxZ w7sw== X-Forwarded-Encrypted: i=1; AJvYcCXWkMQ15qAwAkneH9bTr/RV2yCERau8oLDpEuu1JlSnrbFZmiSa/Xb5zuapd9RDU89hdH++UN4x/6Gc0g==@vger.kernel.org X-Gm-Message-State: AOJu0Yy7em5nu9Ou2C6gsHRJ76GgX3p0mp2jKsDLEMTMBewClgIGutlJ 789lOiczbHk078xlVz/bG6jK4krLc5UZCzaYrXsDdKhDTVW95OOAGrpX/IgDDzRvEkTQYTyoMQO H X-Gm-Gg: ASbGncsK42+t9Hhqpd9JvlGZFlOEXYq0ZK46/nZxb6ohGeYSvxOhcvpBMaYvSRTD5k/ brSsUWhbU8ovhSzkb1Hbr9JsFytAaaWkxvxZny+c6RC0BukOcH0D0KQSRbd1HQ3OfTR9sEAgtb1 7/s5+y+viraCABvf7qAtu0aG/i925RLbNa8idq4rn8FSgbT094kZRqGRLLzrXWfImvYI0J/yKov PrqyeJSP8OolTQTAyM1oOgUrc4rPYvWl/06UM5QiHsfypnPqi7mtLDFlp/Pj84RUKQcDolarbLq oz58m3WqJ4NL6wgit4+oL2EBNmbVM6Hc5A1bYRWKaPcWKs+JrxGCchBkDS4CiORX5NyiIQ== 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-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- 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 @@ #define DRV_NAME "q6apm-dai" -#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