Skip to content

Commit

Permalink
soundwire: bus: fix io error when processing alert event
Browse files Browse the repository at this point in the history
There are two types of io error when processing alert event.
The first one is: master receives an alert event for jack event
and invokes implement_def function in slave to check jack status.
At this time codec is just suspended, so io registers can't be
accessed. Another one is: when waking up from clock stop state
and bus needs a complete re-enumeration for synchronization issue
, slave register can't be accessed.

This patch wakes up codec and wait for initialization complete
when processing slave alert event, so that io registers can be
accessed.

Signed-off-by: Rander Wang <rander.wang@intel.com>
  • Loading branch information
RanderWang committed Dec 9, 2019
1 parent b036eac commit cc704f5
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions drivers/soundwire/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -904,20 +904,27 @@ static int sdw_handle_slave_alerts(struct sdw_slave *slave)

sdw_modify_slave_status(slave, SDW_SLAVE_ALERT);

ret = pm_runtime_get_sync(&slave->dev);
if (ret < 0 && ret != -EACCES) {
dev_err(&slave->dev, "Failed to resume device: %d\n", ret);
pm_runtime_put_noidle(slave->bus->dev);
return ret;
}

/* Read Instat 1, Instat 2 and Instat 3 registers */
ret = sdw_read(slave, SDW_SCP_INT1);
if (ret < 0) {
dev_err(slave->bus->dev,
"SDW_SCP_INT1 read failed:%d\n", ret);
return ret;
goto io_err;
}
buf = ret;

ret = sdw_nread(slave, SDW_SCP_INTSTAT2, 2, buf2);
if (ret < 0) {
dev_err(slave->bus->dev,
"SDW_SCP_INT2/3 read failed:%d\n", ret);
return ret;
goto io_err;
}

do {
Expand Down Expand Up @@ -997,7 +1004,7 @@ static int sdw_handle_slave_alerts(struct sdw_slave *slave)
if (ret < 0) {
dev_err(slave->bus->dev,
"SDW_SCP_INT1 write failed:%d\n", ret);
return ret;
goto io_err;
}

/*
Expand All @@ -1008,15 +1015,15 @@ static int sdw_handle_slave_alerts(struct sdw_slave *slave)
if (ret < 0) {
dev_err(slave->bus->dev,
"SDW_SCP_INT1 read failed:%d\n", ret);
return ret;
goto io_err;
}
_buf = ret;

ret = sdw_nread(slave, SDW_SCP_INTSTAT2, 2, _buf2);
if (ret < 0) {
dev_err(slave->bus->dev,
"SDW_SCP_INT2/3 read failed:%d\n", ret);
return ret;
goto io_err;
}

/* Make sure no interrupts are pending */
Expand All @@ -1037,6 +1044,10 @@ static int sdw_handle_slave_alerts(struct sdw_slave *slave)
if (count == SDW_READ_INTR_CLEAR_RETRY)
dev_warn(slave->bus->dev, "Reached MAX_RETRY on alert read\n");

io_err:
pm_runtime_mark_last_busy(&slave->dev);
pm_runtime_put(&slave->dev);

return ret;
}

Expand Down

0 comments on commit cc704f5

Please sign in to comment.