Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions drivers/soundwire/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/init.h>
#include <linux/iopoll.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/slab.h>
Expand All @@ -26,6 +27,8 @@ static int p_lane;
module_param(p_lane, int, 0444);
MODULE_PARM_DESC(p_lane, "Peripheral lane");

#define SDW_PORT_PREP_POLL_USEC 1000

/*
* Array of supported rows and columns as per MIPI SoundWire Specification 1.1
*
Expand Down Expand Up @@ -451,7 +454,6 @@ static int sdw_prep_deprep_slave_ports(struct sdw_bus *bus,
struct sdw_port_runtime *p_rt,
bool prep)
{
struct completion *port_ready;
struct sdw_dpn_prop *dpn_prop;
struct sdw_prepare_ch prep_ch;
u32 imp_def_interrupts;
Expand Down Expand Up @@ -492,7 +494,7 @@ static int sdw_prep_deprep_slave_ports(struct sdw_bus *bus,

prep_ch.bank = bus->params.next_bank;

if (imp_def_interrupts || !simple_ch_prep_sm ||
if (imp_def_interrupts ||
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this change is needed.

bus->params.s_data_mode != SDW_PORT_DATA_MODE_NORMAL)
intr = true;

Expand Down Expand Up @@ -526,13 +528,15 @@ static int sdw_prep_deprep_slave_ports(struct sdw_bus *bus,
return ret;
}

/* Wait for completion on port ready */
port_ready = &s_rt->slave->port_ready[prep_ch.num];
wait_for_completion_timeout(port_ready,
msecs_to_jiffies(ch_prep_timeout));

val = sdw_read_no_pm(s_rt->slave, SDW_DPN_PREPARESTATUS(p_rt->num));
if ((val < 0) || (val & p_rt->ch_mask)) {
/*
* Poll for NOT_PREPARED. Cannot use the interrupt because this
* code holds bus_lock which blocks interrupt handling.
*/
ret = read_poll_timeout(sdw_read_no_pm, val,
(val < 0) || ((val & p_rt->ch_mask) == 0),
SDW_PORT_PREP_POLL_USEC, ch_prep_timeout * USEC_PER_MSEC,
false, s_rt->slave, SDW_DPN_PREPARESTATUS(p_rt->num));
if (ret || (val < 0) || (val & p_rt->ch_mask)) {
ret = (val < 0) ? val : -ETIMEDOUT;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we not convert ret if it is not 0? In that case val could be 0

dev_err(&s_rt->slave->dev,
"Chn prep failed for port %d: %d\n", prep_ch.num, ret);
Expand Down
Loading