From patchwork Fri Mar 14 14:32:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 14016948 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.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 2FAEC20101E for ; Fri, 14 Mar 2025 14:33:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741962807; cv=none; b=ZFf/yTlqOXCRNA2RZcENsXvacXBkAhvNrgpz1dOlCV5NMAo4pvs4Jf6B4vi/tMesSbGgcSRF2bL6YDNWk4sLrQp6/y9IDPz8TsdqfGzZLoYRPV4PGjxr9lnXIRd1miVc5fwfAPz2MEzd80cSj0PUo+VjS7YnDCHJXjVy9EEgdDg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741962807; c=relaxed/simple; bh=TAw1EHr+KGLgB3XkicmeA88VvxQqIZ56YNyuSffOm+E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Ox9IcyN/uuJfEaI/q0xNaP5EZclUM6oaOi16q8UfPwOWHaB4LoI0ZuPpPKz2jfpOOv0o6LaxFEmKd4Yjd0VoKUVDSQwKqzfA5L7bFAG0J9MdEKulJ5PUlALMCnLkaYQWQLNf0hx2RORBzV7vdnlmvfqdLKNwEcbguw1kWWofTeY= 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=QtHpDldG; arc=none smtp.client-ip=209.85.128.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="QtHpDldG" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-43cebe06e9eso14900605e9.3 for ; Fri, 14 Mar 2025 07:33:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741962803; x=1742567603; 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=chruVzlaUTkKurouBS2LcxGafUPd4GyPtKSm8NIC0fw=; b=QtHpDldGuK5JIGP+WKBGAsKCb0hEg3CiR33mzhwg4kIPGga5JT5dy5bjsS2pfPRXtc dgQ1VAkGd0PpjgryNzWOL69fqO38K9Fq5WalSzvNSSWtUQZJWaa7c+itaoy5accQkADY zR3H12QiIsDvmw3lAlZzVNc1orNRBgUnMCnv29sOt2fh6JxHbOEPiu6Ig9E6r/HDRj/f q3hAzOkIMEzo3WsAVAARWjrPlor8hbo+d2H0c1spiPaeIFUFqoCOTxXdJnW+GRkruX3a 5VRTNiIEeu5T7YIfR0Cmf5l0u8Lxjo+/g8lSKhNIw/D/zXGuDweyTfQ6n+gHJBEShodt 0FRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741962803; x=1742567603; 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=chruVzlaUTkKurouBS2LcxGafUPd4GyPtKSm8NIC0fw=; b=emBWnEjIe/23D1/8hXBSB2ybSTo1SHVOc8jPIQ2jbM0qCUjm5KekB1VPGQWfpZkQSH d7pddqgErXMA+hL4SNekI9vZzCkGxW9nSlX9rhabMBBf8EVHBREzFNYlpy4GYWCcri/s bIrfq6VfnMHzESsTy4ucUhWA2ZUdhEmTdM/lPDxPXCPwVzLyfCkUoRBcX8BZHA734OvF uobo1t5087jSCMhURb+XHHO/safOM7stLzuNVwCoofWEmZAMa//8wo+sbw2mwCkyIIkz MP95qk9Ee4HuKfKj10vq9K/71bd5J7rW/a6FV/rqJpD2MQBvEoY6HCIvEIfJXDdh4TN0 xITw== X-Forwarded-Encrypted: i=1; AJvYcCVmwno1szJUDsitSFy4xEHiGlj0h52LtY5/cZ69Cybzwjb22cTsR4fvfMGWTA3LOolirWVZm1qcWFFROQ==@vger.kernel.org X-Gm-Message-State: AOJu0YyCjx1pN49JEq9Kh3bewgHKwdKmjXe6xEnz7B+C4YP4ytnYacTE 9zXIUkNLwkpKZwefsI25zuSyiheAggRSBrmjG7YmkQNSQMQDUsoFGeNgdFwKT0Y= X-Gm-Gg: ASbGncuI5F35X8RznqmDaDwe/4rtpmYbGa2KyH7EI28pp0SUqt6buGS5KpRxRdGCasy vVHhN9E8z0VWjCscK7fgsU3WQdZ7oGvHdfSPUEITrGRXRiw9EN1qfu0OMzKuXAWkDn2qHqssHka 21xf2FlPt65wyntEphc51Wukwza5X+rNO6vdrBVZa7U2aXHjAnZGvekQoMCeoFI+KeIsyoDDNHS rGCKLCjQ2+gzMY38kF4wGkoYulF1hqQpDwXF96OruQbuI5NSzvIIa371swPR6nepT77DWAz+Y/s 40gnVI+fHVg3PWTgqbMruRP2KJDzT2OZK5LouD6uA0PQbSgXU1Ao2+dBOjw+HajUGTWF3w== X-Google-Smtp-Source: AGHT+IGkZEYytxBtdjySKaiItrRdrarx/PaGm+R/Jm71H8ErDxLmtWHVS1w8bgjGtTokv5oSf194nw== X-Received: by 2002:a5d:47c6:0:b0:391:ccf:2d1b with SMTP id ffacd0b85a97d-3971ffb36a4mr3785197f8f.49.1741962803514; Fri, 14 Mar 2025 07:33:23 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-395c82c2690sm5699168f8f.25.2025.03.14.07.33.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Mar 2025 07:33:22 -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 Subject: [PATCH v4 1/5] ASoC: q6apm-dai: schedule all available frames to avoid dsp under-runs Date: Fri, 14 Mar 2025 14:32:16 +0000 Message-Id: <20250314143220.6215-2-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250314143220.6215-1-srinivas.kandagatla@linaro.org> References: <20250314143220.6215-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 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 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 Fri Mar 14 14:32:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 14016949 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 63DA92010EE for ; Fri, 14 Mar 2025 14:33:26 +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=1741962808; cv=none; b=coXDV4WcDVgSXQsEXoRr5/dy5ROEu38HS+VF7tqE/IhLNmXX9jSbyO6bri5WXGvXiWqGfTwvhs8L3+Zk+5zrYYpUHmvmlFVHrARHhGDuNeuY1u2zrMUz1Vf+rsUZmOpxJ3WxAt41pFqKITdVaVv4l3fZBlaAh+U7ny4HeNGBju0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741962808; c=relaxed/simple; bh=/LrrjZsf1j7u5P5XbpBRADHJ1z3hQDnG5asCYJAEi6w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RoBMIc9r4KegrSYA/n/6u+hw4e+OUDwplliETcKt5DbIrfPDvei5QmVwGs8oqG/B+MCtSCC7e/KsgOALS4Fyy6wPGnTaTbbgyE7MrDnodRWe93mxmBVqGvX5TmJYfbJPPcq/8BQdypifGHBXcV7BCrkkBYgy5OGoYTBcxTdPiz4= 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=LtR/nbu4; 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="LtR/nbu4" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-3914a5def6bso1210105f8f.1 for ; Fri, 14 Mar 2025 07:33:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741962805; x=1742567605; 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=TFTzpqhJXhYVh1FwE3WUgch0eP/UhlF6Ae6PLQps0b8=; b=LtR/nbu4hwNy8hFvF3CRpJFtL+tFExuaBN0e2cQBkgVeAe276ZkhluQIVo8z3kBW2w aOr9kpANZa6lgbgMndUqiFRz/cE6Xtn8naP26oJoErxLr4iVvUPwFW3EHjyRqIAriSWg xUx6M5YGwoZxbLBNoBsPGqwBTambFdd9Vl9txE3X9WlygRIDpN4eyhRTCOCt1ysU5lgv LB/13OsHZP9Mdw4ak9M5aypIEJwbMqd8Fq/IEVPMf/DE+W8F7lcDLUGnC+uViYJK/8Vw RbpqJR8C0IM3281Nu7yKUYSDmLuUxhx43RjJCzVQLXq+xSUrzlIq8jDP2lqRdkZniybc HD/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741962805; x=1742567605; 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=TFTzpqhJXhYVh1FwE3WUgch0eP/UhlF6Ae6PLQps0b8=; b=Q28ieQJIXZKDrSI6Qjh/PSgNmQCY+OGSeqklTnq7BCkMlzLAODs71vq0PWwbjWCYFt aqnZy/U4Tv8oKXNl1T4iQA6KGr7rltn/Kek6N9WQ6kcbCT2jIFYEKmXDtaNDSWQHj3cL 4WyHUR7j21f4kV71OThBsHSgZEnpbFtHKYILjtXROcom9dQNiu1bxFA07qBtglN8jt9T 8ih2kWCeWK98e1fJb/L12Q2t+uY4968HSGiQE44fZzAd7VPzThFGRdBdDmQskPKuLR6x eUTI+oASMhn0rzrtpJa+wYtKFDQ6U9n3UwWQRgtLdBLGe0PyB97OZkJpmq0EUBQQDDJA FoPQ== X-Forwarded-Encrypted: i=1; AJvYcCU7fP6doPa6H6Pf2Sg64sEWdumZtaqjtLZpVKJHvHnq1jYRco810oCEDm2aGKmoECon0wqN3DSNtisWHQ==@vger.kernel.org X-Gm-Message-State: AOJu0YzBUW8YIhPUUC9uSrMUoVRfxfhdnh6mhqBThwOk2Jl33Hd3MaWp auBTwoVl1mBNTJhsEH4fQ8DNLaBwqBjouR0TOLJX9MQC/rA8+0T99fp+z65khVsAVNXmuj2N/yY h X-Gm-Gg: ASbGncu+iZ4+nl/bVpf/IdmPix1i30dAt7A7ipZ+ZuhFoTniBOu3Jw5Fup5ys8KYF1i Qe9rHdpalwaLlawxLpnbg/hWNmRv35g4MAycCDlJRZmL+XOsPUnC4iXQuwTAVZQkztw+Hm8ubr0 Y9mfI1bUuJ3a4uQUE1EQryAR7VfapJmP2G1ra8MIosmB5GLq4ZrLNDLt5UWUUufSIlrTaJma0wo 8EJEpQeUxF6E//GsIrngkKXKfGshNvZIawbC99kBcRz4ia3xw690d2RcTrp0Otnf41Oz8iDMxCn q8bWUA7L6ShgQMXMWhpk9CwMoS59fHyUsAjVVlimI8BVadnOi/a8HUib1P5aTg/TgyHhHw== X-Google-Smtp-Source: AGHT+IHeVYGxOJDDlfj6XFCcAFIk+y7PwJ4y20IgMQAQHLR/ud0eLQcjKFi54dZxDg4z7NiRfEtE2g== X-Received: by 2002:a05:6000:2ac:b0:390:e853:85bd with SMTP id ffacd0b85a97d-3971ffb22c0mr3946467f8f.48.1741962804718; Fri, 14 Mar 2025 07:33:24 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-395c82c2690sm5699168f8f.25.2025.03.14.07.33.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Mar 2025 07:33:23 -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 Subject: [PATCH v4 2/5] ASoC: q6apm: add q6apm_get_hw_pointer helper Date: Fri, 14 Mar 2025 14:32:17 +0000 Message-Id: <20250314143220.6215-3-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250314143220.6215-1-srinivas.kandagatla@linaro.org> References: <20250314143220.6215-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 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); +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 Fri Mar 14 14:32: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: 14016950 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.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 3588F20127A for ; Fri, 14 Mar 2025 14:33:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741962810; cv=none; b=QfnHbzjODDwDp7tLD2kJrYvBHVzZDunVfjadNJ25slVdDWrBPjFSaf11x4CnOaX++BuXGJBTaJ5QMFlF7loc21w8RHwfp/1EQE0V2y+wfKptlvOVRhTVf6iOdD3y7NkINkuzDPR61LoC/x2dCNsZbKACBPLk2c+pmh+dKtN6NwU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741962810; c=relaxed/simple; bh=rl1JUAbzuHruCH71rfySFM7KQHZ8STkXFPVIDYURSF0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=frv08kMcYvbNvjk/mDyf5W258TBHyXnIBd8rETqzZKn/DQA+MGZiF1ngpA3jPeqWmUW10E8jmFzp+N6GZuYgr/Ub8Xh+EWXOL82kMSfO/hLYPfebX75aHvuBa+Et4gM5HvrFKoa0qV36jGP2LEhc5HvV93A6SJvOr6DiGxtj8XQ= 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=UlrVHwKQ; arc=none smtp.client-ip=209.85.221.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="UlrVHwKQ" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-391211ea598so1323853f8f.1 for ; Fri, 14 Mar 2025 07:33:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741962806; x=1742567606; 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=m7r265E8NIQTLThxcAbd4dtQS3El8DVfLuvsTAa+XKw=; b=UlrVHwKQK+fpgNNXNiUJ2Z2aO/JsVlG23OaxaPfxm94E8CyXihZM2F+TbBxtZa0X09 R6tsSxpjyLE8Q3esMWiYxR3Py9upeIh3ArYeTevgtAsEbSkG8qzW4nKT9PWwrHCoK4uP fMnaAHre291zLFYsN+bAF7kweBTOc5R5afPZIxAvRud+TNsFBseJfnj/kt11YZeMp2UY +AqAqU8wYeQpoe+NQORNsL1xnHhyR/pS0JH2NomLoeRYt+KHdbzZeDc+LbSuV5mCC3BF /3D9s1DwD35mkLGjQ3PesnaMoj9PqlVcS8tN4IlBTy3LPpACYeWRLdt1mvRMO6ZML9hw MggA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741962806; x=1742567606; 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=m7r265E8NIQTLThxcAbd4dtQS3El8DVfLuvsTAa+XKw=; b=eH+LasVicOq/1twfxVfR/jNRMIZiKkYEheuWFILwO4JjDDeVOR+9wT8UZYdHgBt4U9 wUBZzTnWWL7Xw2fKg026+B0k+V2wN7ilYuqMWK+1OFH+iIXKeY8XqlkyhnthVvf29sYM /B2aQoPsuGMN8Kav2e7UTk0pritUaKlb+mFctz234bO+lfTzyFKh36RG9aLbRbDze5NH eS9RK93FmckNGrTwse4ZKI45lSNQmJdZOz1oMBYiaq/nzOTrh2P9HbGU2BKC62KtPZFH BfZ/cfbQ3j6NA1MI9pa6vsknhei2vGPxjq7VkLl9viWyJ2IWi7kAXnOfOWJkx70HZBF5 4s/Q== X-Forwarded-Encrypted: i=1; AJvYcCWQ42YvVO3dB3wi3pabdqoMnMXVrn+a+T/aUcfq1XWgJcFYZCtlTeoEDgzlvlszuCjtgCUvStLb5MILRA==@vger.kernel.org X-Gm-Message-State: AOJu0YyvkNF1xbBh3SJes5xuqwLzfL9EeBJ7JjwD7L5mFaPvEwRad33p zXsJPSXk9+augBpFC1PZuOBOxCrPCrlwQW7duzeiHbPRc6f/vOaarfiE1VPsWAA= X-Gm-Gg: ASbGncv6SCWePlGkIf4AvshBH90NKNws7m/duBYCEpPOnQPNYVvI/rPzQ7cgT9hLZBF VKyIkXbflNcadaUxIFk80WdGThGFtnw02U01z+TrRWyPL/dvRLkBDjeGn1S9HjO92wmzaBkZrp+ c4GugBI7opKqLMp/GuFI4+36/tB1WeHiwOXGMFoSl6Qe0jimsxMpPfM5lJi4dZHaF0RPJFtRGmI vJsgPrixkaILZC2VxsRJxBKg14fg41YxV1i/wzDwmj+xFks9Yv4Qn9sXxQIFzUhR8h1ELmh1v35 VGXNTjFQy4D/uZYa3SeNf4o4xDKMbm+346/iGQgjxz6oA/YNcEpiaq+7heIhzPQUxb/nJbpdgTy I0fw7 X-Google-Smtp-Source: AGHT+IHHvG7zpgRF/biasWJacaE8BgqYA/+Tzt9Ba1i6MJmKfz1aq1nD3PLvd4Da03+ceLCK/JoXgw== X-Received: by 2002:a5d:5f84:0:b0:391:4095:49b7 with SMTP id ffacd0b85a97d-3971f12e65amr4834829f8f.25.1741962806395; Fri, 14 Mar 2025 07:33:26 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-395c82c2690sm5699168f8f.25.2025.03.14.07.33.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Mar 2025 07:33:25 -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 Subject: [PATCH v4 3/5] ASoC: q6apm-dai: make use of q6apm_get_hw_pointer Date: Fri, 14 Mar 2025 14:32:18 +0000 Message-Id: <20250314143220.6215-4-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250314143220.6215-1-srinivas.kandagatla@linaro.org> References: <20250314143220.6215-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 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 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 Fri Mar 14 14:32: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: 14016951 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 C7C3A20299A for ; Fri, 14 Mar 2025 14:33:29 +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=1741962811; cv=none; b=V0KW+SS/GzyuGBWX5ydgbIEhISCjizAliyHHx9Zb59zS4YFB4YGEJlhxpbBjFNGKjD7fdNFO65ZFNblfL7CAxS6ni6cqWKO3KhAB1Dn9Gf7/ptmu6vc1GaH82QU6VENyhOprjfQh4zvkIBqO/7UYLYUWIsjbqXJIVQqpxtwcqBo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741962811; c=relaxed/simple; bh=etID88XhArSgmvosEDMawlWfvyYiW3vHyBAqplbUD90=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GYYM5ZFuAfWHQrB5DEKIGYPgjG7iE3dsNCfFsnuLXewt/Ix0vhRqWdzVgjzjOIlpuLJ9Z4odrGJmg5mu6Jw+AzUIunG+OWdN4lfJfHPvc926oRShufVAqvAvnLmD0KyzXY6c0TXZCfdGCCCMUjgH6Ct/XDbmEjAKFsCGpBi4oKU= 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=g73ymznm; 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="g73ymznm" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-3912e96c8e8so1428652f8f.2 for ; Fri, 14 Mar 2025 07:33:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741962808; x=1742567608; 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=86CJK2fc0cAvOYyDOyHTA5kr0QOMsZ602Wh5UOHhaX0=; b=g73ymznmPQ+l3wbZ7nChZLt9j0OptWwba7Z+ES3NZLj5jSpgMHRSXdKPx65IdCppwo hmHl6K/wxkd0h6QoI8+lfuRbXvSMuFnfvwSujBaIz4EnvYxLOcm5jBPZrC4d8rwkhEAP kCk2lVBl0fMl2KlqemjvJl7aD0zmK/NYdpGsXS8RLE7rglT/2MGmiNeBVpToubITKxv0 begNQiuZ01/ZmYJ0et3CiksswTp7dKSgLK55bs7OJBcO47bxR5ALGYeqIDWXZgVjoM3d +j26oZjTfmadrVxLENrDOA2z7uXEu/CyZ7+loLUGa7Ng0HXX1kGToU4lUQsHM4eEblHY aD5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741962808; x=1742567608; 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=86CJK2fc0cAvOYyDOyHTA5kr0QOMsZ602Wh5UOHhaX0=; b=GK7Pey2jsZngI9dtosDavtuvJlSDOCCMSmE5SF/940hrJyEXUvW08Zsldu7YJe9YG8 g+DJBmf3EZjTquw9p8Twrn87Pq8Xq6AgspkrhTIhxWlzla8+LGUxmEsp00Z0bt2oJZta tX+hyN1JGbsCOqu9zHcm9UN27W2aPaDCGaJmEMRy4FFWlZZOxEEvBWcDIWsRzwuIH9P5 Kpi0KtqgeEqPzqd/tBH5ypNklXGoVSNXzwfezqDTNnkgQwTyFIupkA+zw2Lum52Og20F gZxWjxalKjODNInlLsMMl+iMzKO1oChunl8trMFCuEIYNAgUNe3R3l+RvuQXnsAACDqA FiHQ== X-Forwarded-Encrypted: i=1; AJvYcCWcXrH6V5SwpgKAwOtx8+NaKwOJf/WkR2WpqtXfuR8cTe47OnCxZAN5ncvLK0OkdE8tt5ghtnDwuCuaoA==@vger.kernel.org X-Gm-Message-State: AOJu0YxKxIXSlxVTJktlYkS+tyneQqjnkMQt7CqcaDPLVaohu9nHph7x vC/NfcjW268ChEQHNeRz7qFnDOJ36P0akVu5xasR0JGFZCTQZVOJPtMni5Y9T+/wx9lMBShs3nR V X-Gm-Gg: ASbGncvCZmik9NI1ZM+AQHanQafVtUZakO6tCX3RF0ZChlcSD+Q4WLZnVMxzgnhez3V KeSHEfpS3tauDJGEw+kh5XmFLCvykbdaZ6nYN+4mCPBozo8diIkOqEBwqgJ3DldvLOIIp8f2Wdt VgG2SRQ2NO4bpVIA5CCzowpfuEAmoFM/3pB+O+sbDbjEpmY2Z1thJvOpMkWDFFG/88Gxas8dBrs Ub1yKfvY7tEp/+8oFxeEeuWI9CBJLw5AOsbxg39k2+G45l5e0GPp5qiqsDlisgTQFB9oHp1Nf5t m4ezqAtDGAYrAg37AiPA6O1/GucavSgefIEjOEeiyLPXxmTsmsb2yM9XGT2RxdZFL72jAw== X-Google-Smtp-Source: AGHT+IHVs9aqh53jMw+jTNDbDhOzV9r2dswK8/QSdrxt12hvlpFw9Rs059AvnN5+zk17YnDOTrO2nA== X-Received: by 2002:a5d:47cf:0:b0:391:31c8:ba58 with SMTP id ffacd0b85a97d-3971d03ee20mr3210099f8f.10.1741962808009; Fri, 14 Mar 2025 07:33:28 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-395c82c2690sm5699168f8f.25.2025.03.14.07.33.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Mar 2025 07:33:26 -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 Subject: [PATCH v4 4/5] ASoC: qdsp6: q6apm-dai: set 10 ms period and buffer alignment. Date: Fri, 14 Mar 2025 14:32:19 +0000 Message-Id: <20250314143220.6215-5-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250314143220.6215-1-srinivas.kandagatla@linaro.org> References: <20250314143220.6215-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 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") Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/qdsp6/q6apm-dai.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/soc/qcom/qdsp6/q6apm-dai.c b/sound/soc/qcom/qdsp6/q6apm-dai.c index 90cb24947f31..a636f9280645 100644 --- a/sound/soc/qcom/qdsp6/q6apm-dai.c +++ b/sound/soc/qcom/qdsp6/q6apm-dai.c @@ -231,7 +231,6 @@ static int q6apm_dai_prepare(struct snd_soc_component *component, cfg.bit_width = prtd->bits_per_sample; cfg.fmt = SND_AUDIOCODEC_PCM; audioreach_set_default_channel_mapping(cfg.channel_map, runtime->channels); - if (prtd->state) { /* clear the previous setup if any */ q6apm_graph_stop(prtd->graph); @@ -385,13 +384,14 @@ 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); + /* setup 10ms latency to accommodate DSP restrictions */ + ret = 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 = %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_SIZE, 480); if (ret < 0) { dev_err(dev, "constraint for buffer bytes step ret = %d\n", ret); goto err; From patchwork Fri Mar 14 14:32: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: 14016952 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (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 1E5DD201013 for ; Fri, 14 Mar 2025 14:33:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741962812; cv=none; b=TE3noQ6xtdrGekDTcfwx8PtB+UHJvVxi4Z/NrSl04Ky56k6MZuANnhyo3W26DzhqN6Qa7Tr4fiHq2rOCKk0jgfCSeXbMsY3oQ7j7u7Lps+eOei7F7iCsmceaeakLR0pnLrzEVGVeHnN8sr49w+5HHn3nyBDl8gAsJH+0LgPFwvY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741962812; c=relaxed/simple; bh=49SQFDPVrfSgd5vzQ59y3EoTLS1r9SAAvEbV2EPsJ2Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UlgSzZ2t5I7wbO86O+MpJyo2iPmwZNFxp9JMJC6WIkam9MmhTxZ4z4KW2a15S4Zog6d4yutQH656Q+SollnBRvvbpvqmOt+B9lzxlM73932XwnAoc4f/G5ijAqra4Kraim0tYkO+I/hrTjxe/wRtu42+pXFOJOw2BmcmW0DnDLM= 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=rzc3tv3K; arc=none smtp.client-ip=209.85.221.47 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="rzc3tv3K" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-39141ffa9fcso1826030f8f.0 for ; Fri, 14 Mar 2025 07:33:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741962809; x=1742567609; 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=BmrpnnLM0D4kCXujXrwrPhEB5OgiMQcaOkuo+01fN7M=; b=rzc3tv3Kd0ou7jNF7JWL+FlHnqVTYsD4DERINfn7Y7TPYu81vwaJ4gydWITQiL8Let pvI0/ihYKeViKibewSdmS37Vvsjtxx2lapsfoqUi+Cd6gMLPL5UAT5ZXPSarezmuvstH CI+8+/GuUsL4yoQr5PlpSsS8mZl0d06+9H+LfE0ikYeqYihUMqFxwa6LcYRnJ1x+Ss6x lQHNTWHP88aGohRijSwAPe5DZETw8BbeTpaDrI3icP9nziG5+AVwN68J2yJBrHPWuzUK iQsEsnmjLVVPMzok406CjcHssduRztpP9eUp+D2AA6ap6ZpsRvMkKmKVqVoZiF+vzj4I 4/bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741962809; x=1742567609; 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=BmrpnnLM0D4kCXujXrwrPhEB5OgiMQcaOkuo+01fN7M=; b=xT+MwkEB8q/syww9PWgJQf67d7wSwR2Dz0Uh+JBF2MESwJcAMRLw2wQVa6uDgNwY5R fTGojqhbSVaTa934xP5y6fmR0XV28I/tl3m4mang+z4B/oCpirTk1C/pAG2+JwKbvpVp 59tnootuTxADVVa4DaKR5/5o58/NwayexX5vlaeT5jkAj8YCSFJJtOahUIkQRHDlyqK+ 3ba7dop4RX8szQFHBGe4haQy3HskhgStlKTWY+t7j4XssOnvTHaujxCsOpbHhajCoab3 2/VX7n1yfJlkTl2AvIUGNzq8LCDyhM3I8jarTGA2aZ4vNGykkjI/CKCiZpMpIf+PTK3r woPw== X-Forwarded-Encrypted: i=1; AJvYcCVQe2fZ00d6Pe7JOpvArUSOKbC9BWlVfmnGIztlk3rn3mIeitL544gkjSsg1GTHu+fhJVvrdoWjqckphg==@vger.kernel.org X-Gm-Message-State: AOJu0YyQGCnzpiwiUsqkTn5I+3zNnbtVLe3Oz2OpMvtTopaPsbmpr7oi fytus8DPgn0gdMnh+IMBjDzKzHj9Pp9dJYbAHXAaIax15iWFmSDu7sSzuOGHwDA= X-Gm-Gg: ASbGncsUKG2amZIMU4PvVco9tZadr/AQxC9BKkApLBXegvbvTFQ9TbD4BKNPzicMakR H23ywsDQzkWBjwh+L8OC18HXwXCF/gW7pgAn978f7o+ZPH9AFC8fsPkjoJMxiiAx7s2F9SY7dSU UYV8vcML/tc1eNL3/t/W1D8NdU4cGWBdBKVbKJxvJ/tCqEME8B3pKq7F/niQ9PUnF6G9BMKIxBi /JQ5BNAwGrFe+t80A/9P3gZADpOjYWRdm3Jr6p9aXVBzjnIsNTxmXneljdxqUNe6vaBoXkmfuVv 19aNopc+KFSDLVyheTPs+VOJaSosPjvv6xGCXwZ72RZ0ltxgc4/kHx09xx2qDEtojfRoTQ== X-Google-Smtp-Source: AGHT+IHv9cZ7VMEGzbxjDU272hTTPtgC2UDh1G+FUstyJcGJxM6GpRj97dHRlcSdi5ciiW0phluAww== X-Received: by 2002:a5d:64a1:0:b0:390:e8e4:7e3e with SMTP id ffacd0b85a97d-3971cd573fbmr3738351f8f.6.1741962809334; Fri, 14 Mar 2025 07:33:29 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-395c82c2690sm5699168f8f.25.2025.03.14.07.33.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Mar 2025 07:33:28 -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 Subject: [PATCH v4 5/5] ASoC: qdsp6: q6apm-dai: fix capture pipeline overruns. Date: Fri, 14 Mar 2025 14:32:20 +0000 Message-Id: <20250314143220.6215-6-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250314143220.6215-1-srinivas.kandagatla@linaro.org> References: <20250314143220.6215-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 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 a636f9280645..292cab61831c 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)