From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
vkoul@kernel.org
Cc: yung-chuan.liao@linux.intel.com, alsa-devel@alsa-project.org,
linux-kernel@vger.kernel.org, steev@kali.org,
johan+linaro@kernel.org, quic_bjorande@quicinc.com
Subject: Re: [PATCH 3/5] soundwire: qcom: wait for fifo to be empty before suspend
Date: Thu, 9 Feb 2023 15:52:29 +0000 [thread overview]
Message-ID: <a1d79008-3ec4-d7b5-12b5-ea5c6c5a8370@linaro.org> (raw)
In-Reply-To: <dbec6aab-6456-72b3-39b6-3490dfdf083c@linux.intel.com>
On 09/02/2023 15:23, Pierre-Louis Bossart wrote:
>
>
> On 2/9/23 07:13, Srinivas Kandagatla wrote:
>> Wait for Fifo to be empty before going to suspend or before bank
>> switch happens. Just to make sure that all the reads/writes are done.
>
> For the suspend case that seems like a valid approach, but for bank
> switch don't we already have a bus->msg_lock mutex that will prevent the
> bank switch command from being sent before the other commands are handled?
All read/writes are fifo based, so writes could be still pending.
--srini
>
>> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
>> ---
>> drivers/soundwire/qcom.c | 29 +++++++++++++++++++++++++++++
>> 1 file changed, 29 insertions(+)
>>
>> diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
>> index b2363839624c..465b2a2ef0d5 100644
>> --- a/drivers/soundwire/qcom.c
>> +++ b/drivers/soundwire/qcom.c
>> @@ -325,6 +325,32 @@ static int swrm_wait_for_wr_fifo_avail(struct qcom_swrm_ctrl *swrm)
>> return 0;
>> }
>>
>> +static bool swrm_wait_for_wr_fifo_done(struct qcom_swrm_ctrl *swrm)
>> +{
>> + u32 fifo_outstanding_cmds, value;
>> + int fifo_retry_count = SWR_OVERFLOW_RETRY_COUNT;
>> +
>> + /* Check for fifo overflow during write */
>> + swrm->reg_read(swrm, SWRM_CMD_FIFO_STATUS, &value);
>> + fifo_outstanding_cmds = FIELD_GET(SWRM_WR_CMD_FIFO_CNT_MASK, value);
>> +
>> + if (fifo_outstanding_cmds) {
>> + while (fifo_retry_count) {
>> + usleep_range(500, 510);
>> + swrm->reg_read(swrm, SWRM_CMD_FIFO_STATUS, &value);
>> + fifo_outstanding_cmds = FIELD_GET(SWRM_WR_CMD_FIFO_CNT_MASK, value);
>> + fifo_retry_count--;
>> + if (fifo_outstanding_cmds == 0)
>> + return true;
>> + }
>> + } else {
>> + return true;
>> + }
>> +
>> +
>> + return false;
>> +}
>> +
>> static int qcom_swrm_cmd_fifo_wr_cmd(struct qcom_swrm_ctrl *swrm, u8 cmd_data,
>> u8 dev_addr, u16 reg_addr)
>> {
>> @@ -356,6 +382,7 @@ static int qcom_swrm_cmd_fifo_wr_cmd(struct qcom_swrm_ctrl *swrm, u8 cmd_data,
>> usleep_range(150, 155);
>>
>> if (cmd_id == SWR_BROADCAST_CMD_ID) {
>> + swrm_wait_for_wr_fifo_done(swrm);
>> /*
>> * sleep for 10ms for MSM soundwire variant to allow broadcast
>> * command to complete.
>> @@ -1122,6 +1149,7 @@ static void qcom_swrm_shutdown(struct snd_pcm_substream *substream,
>> {
>> struct qcom_swrm_ctrl *ctrl = dev_get_drvdata(dai->dev);
>>
>> + swrm_wait_for_wr_fifo_done(ctrl);
>> sdw_release_stream(ctrl->sruntime[dai->id]);
>> ctrl->sruntime[dai->id] = NULL;
>> pm_runtime_mark_last_busy(ctrl->dev);
>> @@ -1558,6 +1586,7 @@ static int __maybe_unused swrm_runtime_suspend(struct device *dev)
>> struct qcom_swrm_ctrl *ctrl = dev_get_drvdata(dev);
>> int ret;
>>
>> + swrm_wait_for_wr_fifo_done(ctrl);
>> if (!ctrl->clock_stop_not_supported) {
>> /* Mask bus clash interrupt */
>> ctrl->intr_mask &= ~SWRM_INTERRUPT_STATUS_MASTER_CLASH_DET;
next prev parent reply other threads:[~2023-02-09 15:52 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-09 13:13 [PATCH 0/5] soundwire: qcom: stablity fixes Srinivas Kandagatla
2023-02-09 13:13 ` [PATCH 1/5] soundwire: qcom: update status correctly with mask Srinivas Kandagatla
2023-02-09 13:13 ` [PATCH 2/5] soundwire: qcom: enable runtime pm before controller is registered Srinivas Kandagatla
2023-02-09 15:21 ` Pierre-Louis Bossart
2023-02-09 15:49 ` Srinivas Kandagatla
2023-02-09 13:13 ` [PATCH 3/5] soundwire: qcom: wait for fifo to be empty before suspend Srinivas Kandagatla
2023-02-09 15:23 ` Pierre-Louis Bossart
2023-02-09 15:52 ` Srinivas Kandagatla [this message]
2023-02-09 16:33 ` Pierre-Louis Bossart
2023-02-09 17:12 ` Srinivas Kandagatla
2023-02-09 18:24 ` Pierre-Louis Bossart
2023-02-09 13:13 ` [PATCH 4/5] soundwire: qcom: add software workaround for bus clash interrupt assertion Srinivas Kandagatla
2023-02-09 13:13 ` [PATCH 5/5] soundwire: qcom: set clk stop need reset flag at runtime Srinivas Kandagatla
2023-02-09 15:33 ` Pierre-Louis Bossart
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a1d79008-3ec4-d7b5-12b5-ea5c6c5a8370@linaro.org \
--to=srinivas.kandagatla@linaro.org \
--cc=alsa-devel@alsa-project.org \
--cc=johan+linaro@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=quic_bjorande@quicinc.com \
--cc=steev@kali.org \
--cc=vkoul@kernel.org \
--cc=yung-chuan.liao@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®