All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>
To: Richard Fitzgerald <rf@opensource.cirrus.com>,
	vkoul@kernel.org, yung-chuan.liao@linux.intel.com
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
	patches@opensource.cirrus.com
Subject: Re: [PATCH] soundwire: cadence: Clear message complete before signaling waiting thread
Date: Wed, 11 Mar 2026 21:34:43 -0700	[thread overview]
Message-ID: <5e488437-68eb-43e9-a774-babea5879e4a@linux.dev> (raw)
In-Reply-To: <20260310113133.1707288-1-rf@opensource.cirrus.com>

On 3/10/26 04:31, Richard Fitzgerald wrote:
> Clear the CDNS_MCP_INT_RX_WL interrupt before signaling completion.
> 
> This is to prevent the potential race where:
> - The main thread is scheduled immediately the completion is signaled,
>    and starts a new message
> - The RX_WL IRQ for this new message happens before sdw_cdns_irq() has
>   been re-scheduled.
> - When sdw_cdns_irq() is re-scheduled it clears the new RX_WL interrupt.
> 
> MAIN THREAD                        |  IRQ THREAD
>                                    |
>   _cdns_xfer_msg()                 |
>   {                                |
>      write data to FIFO            |
>      wait_for_completion_timeout() |
>      <BLOCKED>                     |                       <---- RX_WL IRQ
>                                    | sdw_cdns_irq()
>                                    | {
>                                    |    signal completion
>                           <== RESCHEDULE <==
>   Handle message completion        |
>   }                                |
>                                    |
> Start new message                  |
>   _cdns_xfer_msg()                 |
>   {                                |
>      write data to FIFO            |
>      wait_for_completion_timeout() |
>      <BLOCKED>                     |                       <---- RX_WL IRQ
>                           ==> RESCHEDULE ==>
>                                    |    // New RX_WL IRQ is cleared before
>                                    |    // it has been handled.
>                                    |    clear CDNS_MCP_INTSTAT
> 
>                                    |    return IRQ_HANDLED;
>                                    | }
> 
> Before this change, this error message was sometimes seen on kernels
> that have large amounts of debugging enabled:
> 
>    SCP Msg trf timed out
> 
> This error indicates that the completion has not been signalled after
> 500ms.
> 
> Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
> Fixes: 956baa1992f9 ("soundwire: cdns: Add sdw_master_ops and IO transfer support")
> Reported-by: Norman Bintang <normanbt@google.com>
> Closes: https://issuetracker.google.com/issues/477099834

Makes sense to me, nice fix!

Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>

> ---
>  drivers/soundwire/cadence_master.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/soundwire/cadence_master.c b/drivers/soundwire/cadence_master.c
> index f245c3ffb9e9..b8b62735c893 100644
> --- a/drivers/soundwire/cadence_master.c
> +++ b/drivers/soundwire/cadence_master.c
> @@ -933,6 +933,14 @@ irqreturn_t sdw_cdns_irq(int irq, void *dev_id)
>  
>  		cdns_read_response(cdns);
>  
> +		/*
> +		 * Clear interrupt before signalling the completion to avoid
> +		 * a race between this thread and the main thread starting
> +		 * another TX.
> +		 */
> +		cdns_writel(cdns, CDNS_MCP_INTSTAT, CDNS_MCP_INT_RX_WL);
> +		int_status &= ~CDNS_MCP_INT_RX_WL;
> +
>  		if (defer && defer->msg) {
>  			cdns_fill_msg_resp(cdns, defer->msg,
>  					   defer->length, 0);


  reply	other threads:[~2026-03-12  4:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-10 11:31 [PATCH] soundwire: cadence: Clear message complete before signaling waiting thread Richard Fitzgerald
2026-03-12  4:34 ` Pierre-Louis Bossart [this message]
2026-03-13  7:51 ` Vinod Koul

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=5e488437-68eb-43e9-a774-babea5879e4a@linux.dev \
    --to=pierre-louis.bossart@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=patches@opensource.cirrus.com \
    --cc=rf@opensource.cirrus.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.