Skip to content

Commit 3d3e88e

Browse files
rfvirgilvinodkoul
authored andcommitted
soundwire: stream: Fix test for DP prepare complete
In sdw_prep_deprep_slave_ports(), after the wait_for_completion() the DP prepare status register is read. If this indicates that the port is now prepared, the code should continue with the port setup. It is irrelevant whether the wait_for_completion() timed out if the port is now ready. The previous implementation would always fail if the wait_for_completion() timed out, even if the port was reporting successful prepare. This patch also fixes a minor bug where the return from sdw_read() was not checked for error - any error code with LSBits clear could be misinterpreted as a successful port prepare. Fixes: 79df15b ("soundwire: Add helpers for ports operations") Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/20210618144745.30629-1-rf@opensource.cirrus.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 031e668 commit 3d3e88e

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

drivers/soundwire/stream.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,6 @@ static int sdw_prep_deprep_slave_ports(struct sdw_bus *bus,
422422
struct completion *port_ready;
423423
struct sdw_dpn_prop *dpn_prop;
424424
struct sdw_prepare_ch prep_ch;
425-
unsigned int time_left;
426425
bool intr = false;
427426
int ret = 0, val;
428427
u32 addr;
@@ -479,15 +478,15 @@ static int sdw_prep_deprep_slave_ports(struct sdw_bus *bus,
479478

480479
/* Wait for completion on port ready */
481480
port_ready = &s_rt->slave->port_ready[prep_ch.num];
482-
time_left = wait_for_completion_timeout(port_ready,
483-
msecs_to_jiffies(dpn_prop->ch_prep_timeout));
481+
wait_for_completion_timeout(port_ready,
482+
msecs_to_jiffies(dpn_prop->ch_prep_timeout));
484483

485484
val = sdw_read(s_rt->slave, SDW_DPN_PREPARESTATUS(p_rt->num));
486-
val &= p_rt->ch_mask;
487-
if (!time_left || val) {
485+
if ((val < 0) || (val & p_rt->ch_mask)) {
486+
ret = (val < 0) ? val : -ETIMEDOUT;
488487
dev_err(&s_rt->slave->dev,
489-
"Chn prep failed for port:%d\n", prep_ch.num);
490-
return -ETIMEDOUT;
488+
"Chn prep failed for port %d: %d\n", prep_ch.num, ret);
489+
return ret;
491490
}
492491
}
493492

0 commit comments

Comments
 (0)