Skip to content

Commit

Permalink
soundwire: cadence_master: mask Slave interrupt before stopping clock
Browse files Browse the repository at this point in the history
Intel QA reported a very rare case, possibly hardware-dependent, where
a Slave can become UNATTACHED during a clock stop sequence, which
leads to timeouts and failed suspend sequences.

This patch suppresses the handling of all Slave events while this
transition happens. The two cases that matter are:

a) alerts: if the Slave wants to signal an alert condition, it can do
so using the in-band wake, so there's almost no impact with this
patch.

b) sync loss or imp-def reset: in those cases, bringing back the Slave
to functional state requires a complete re-enumeration. It's better to
just ignore this case and restart cleanly, rather than attempt a
'clean' suspend.

Validation results show the timeouts no longer visible with this patch.

GitHub issue: #1678
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
  • Loading branch information
plbossart committed Jan 11, 2020
1 parent e6960a4 commit 7639f10
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions drivers/soundwire/cadence_master.c
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,24 @@ int sdw_cdns_exit_reset(struct sdw_cdns *cdns)
}
EXPORT_SYMBOL(sdw_cdns_exit_reset);

/**
* sdw_cdns_enable_interrupt() - Enable SDW slave interrupts
* @cdns: Cadence instance
* @state: boolean for true/false
*/
static void cdns_enable_slave_interrupts(struct sdw_cdns *cdns, bool state)
{
u32 mask;

mask = cdns_readl(cdns, CDNS_MCP_INTMASK);
if (state)
mask |= CDNS_MCP_INT_SLAVE_MASK;
else
mask &= ~CDNS_MCP_INT_SLAVE_MASK;

cdns_writel(cdns, CDNS_MCP_INTMASK, mask);
}

/**
* sdw_cdns_enable_interrupt() - Enable SDW interrupts
* @cdns: Cadence instance
Expand Down Expand Up @@ -1266,6 +1284,13 @@ int sdw_cdns_clock_stop(struct sdw_cdns *cdns, bool block_wake)
return 1;
}

/*
* Before entering clock stop we mask the Slave
* interrupts. This helps avoid having to deal with e.g. a
* Slave becoming UNATTACHED while the clock is being stopped
*/
cdns_enable_slave_interrupts(cdns, false);

/*
* For specific platforms, it is required to be able to put
* master into a state in which it ignores wake-up trials
Expand Down Expand Up @@ -1339,6 +1364,9 @@ int sdw_cdns_clock_restart(struct sdw_cdns *cdns, bool bus_reset)
{
int ret;

/* unmask Slave interrupts that were masked when stopping the clock */
cdns_enable_slave_interrupts(cdns, true);

ret = cdns_clear_bit(cdns, CDNS_MCP_CONTROL,
CDNS_MCP_CONTROL_CLK_STOP_CLR);
if (ret < 0) {
Expand Down

0 comments on commit 7639f10

Please sign in to comment.