Skip to content

Commit ff435da

Browse files
plbossartvinodkoul
authored andcommitted
soundwire: bus: improve error handling for clock stop prepare/deprepare
The same logic is used for clock stop prepare and deprepare, and having different logs for the two steps helps identify problems. In addition, when the "NotFinished" bit remains set, the error handling is not quite right: a) for the clock stop prepare, the error is handled at the caller level, and the error is ignored: there's no good reason to prevent the pm_runtime suspend from happening. Throwing an error that is later ignored is confusing. b) for the clock stop deprepare, the error is ignored in bus.c and a dev_warn() log shown. Throwing an error is also alarming users for no good reason. For both cases, demoting the error to dev_dbg() makes more sense. Link: thesofproject#4619 Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Rander Wang <rander.wang@intel.com> Reviewed-by: Richard Fitzgerald <rf@opensource.cirrus.com> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://lore.kernel.org/r/20231013010812.114216-1-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 95b0f3a commit ff435da

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

drivers/soundwire/bus.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,7 @@ static int sdw_slave_clk_stop_prepare(struct sdw_slave *slave,
10221022
return ret;
10231023
}
10241024

1025-
static int sdw_bus_wait_for_clk_prep_deprep(struct sdw_bus *bus, u16 dev_num)
1025+
static int sdw_bus_wait_for_clk_prep_deprep(struct sdw_bus *bus, u16 dev_num, bool prepare)
10261026
{
10271027
int retry = bus->clk_stop_timeout;
10281028
int val;
@@ -1036,7 +1036,8 @@ static int sdw_bus_wait_for_clk_prep_deprep(struct sdw_bus *bus, u16 dev_num)
10361036
}
10371037
val &= SDW_SCP_STAT_CLK_STP_NF;
10381038
if (!val) {
1039-
dev_dbg(bus->dev, "clock stop prep/de-prep done slave:%d\n",
1039+
dev_dbg(bus->dev, "clock stop %s done slave:%d\n",
1040+
prepare ? "prepare" : "deprepare",
10401041
dev_num);
10411042
return 0;
10421043
}
@@ -1045,7 +1046,8 @@ static int sdw_bus_wait_for_clk_prep_deprep(struct sdw_bus *bus, u16 dev_num)
10451046
retry--;
10461047
} while (retry);
10471048

1048-
dev_err(bus->dev, "clock stop prep/de-prep failed slave:%d\n",
1049+
dev_dbg(bus->dev, "clock stop %s did not complete for slave:%d\n",
1050+
prepare ? "prepare" : "deprepare",
10491051
dev_num);
10501052

10511053
return -ETIMEDOUT;
@@ -1116,7 +1118,7 @@ int sdw_bus_prep_clk_stop(struct sdw_bus *bus)
11161118
*/
11171119
if (!simple_clk_stop) {
11181120
ret = sdw_bus_wait_for_clk_prep_deprep(bus,
1119-
SDW_BROADCAST_DEV_NUM);
1121+
SDW_BROADCAST_DEV_NUM, true);
11201122
/*
11211123
* if there are no Slave devices present and the reply is
11221124
* Command_Ignored/-ENODATA, we don't need to continue with the
@@ -1236,7 +1238,7 @@ int sdw_bus_exit_clk_stop(struct sdw_bus *bus)
12361238
* state machine
12371239
*/
12381240
if (!simple_clk_stop) {
1239-
ret = sdw_bus_wait_for_clk_prep_deprep(bus, SDW_BROADCAST_DEV_NUM);
1241+
ret = sdw_bus_wait_for_clk_prep_deprep(bus, SDW_BROADCAST_DEV_NUM, false);
12401242
if (ret < 0)
12411243
dev_warn(bus->dev, "clock stop deprepare wait failed:%d\n", ret);
12421244
}

0 commit comments

Comments
 (0)