Skip to content

Commit 973794e

Browse files
plbossartvinodkoul
authored andcommitted
soundwire: bus: fix confusion on device used by pm_runtime
Intel stress-tests routinely report IO timeouts and invalid power management transitions. Upon further analysis, we seem to be using the wrong devices in pm_runtime calls. Before reading and writing registers, we first need to make sure the Slave is fully resumed. The existing code attempts to do such that, however because of a confusion dating from 2017 and copy/paste, we end-up resuming the parent only instead of resuming the codec device. This can lead to accesses to the Slave registers while the bus is still being configured and the Slave not enumerated, and as a result IO errors occur. This is a classic problem, similar confusions happened for HDaudio between bus and codec device, leading to power management issues. Fix by using the relevant device for all uses of pm_runtime functions. Fixes: 60ee9be ('soundwire: bus: add PM/no-PM versions of read/write functions') Fixes: aa79293 ('soundwire: bus: fix io error when processing alert event') Fixes: 9d715fa ('soundwire: Add IO transfer') Reported-by: Bard Liao <[email protected]> Signed-off-by: Pierre-Louis Bossart <[email protected]> Reviewed-by: Rander Wang <[email protected]> Signed-off-by: Bard Liao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 167790a commit 973794e

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

drivers/soundwire/bus.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -515,16 +515,16 @@ int sdw_nread(struct sdw_slave *slave, u32 addr, size_t count, u8 *val)
515515
{
516516
int ret;
517517

518-
ret = pm_runtime_get_sync(slave->bus->dev);
518+
ret = pm_runtime_get_sync(&slave->dev);
519519
if (ret < 0 && ret != -EACCES) {
520-
pm_runtime_put_noidle(slave->bus->dev);
520+
pm_runtime_put_noidle(&slave->dev);
521521
return ret;
522522
}
523523

524524
ret = sdw_nread_no_pm(slave, addr, count, val);
525525

526-
pm_runtime_mark_last_busy(slave->bus->dev);
527-
pm_runtime_put(slave->bus->dev);
526+
pm_runtime_mark_last_busy(&slave->dev);
527+
pm_runtime_put(&slave->dev);
528528

529529
return ret;
530530
}
@@ -541,16 +541,16 @@ int sdw_nwrite(struct sdw_slave *slave, u32 addr, size_t count, u8 *val)
541541
{
542542
int ret;
543543

544-
ret = pm_runtime_get_sync(slave->bus->dev);
544+
ret = pm_runtime_get_sync(&slave->dev);
545545
if (ret < 0 && ret != -EACCES) {
546-
pm_runtime_put_noidle(slave->bus->dev);
546+
pm_runtime_put_noidle(&slave->dev);
547547
return ret;
548548
}
549549

550550
ret = sdw_nwrite_no_pm(slave, addr, count, val);
551551

552-
pm_runtime_mark_last_busy(slave->bus->dev);
553-
pm_runtime_put(slave->bus->dev);
552+
pm_runtime_mark_last_busy(&slave->dev);
553+
pm_runtime_put(&slave->dev);
554554

555555
return ret;
556556
}
@@ -1451,7 +1451,7 @@ static int sdw_handle_slave_alerts(struct sdw_slave *slave)
14511451
ret = pm_runtime_get_sync(&slave->dev);
14521452
if (ret < 0 && ret != -EACCES) {
14531453
dev_err(&slave->dev, "Failed to resume device: %d\n", ret);
1454-
pm_runtime_put_noidle(slave->bus->dev);
1454+
pm_runtime_put_noidle(&slave->dev);
14551455
return ret;
14561456
}
14571457

0 commit comments

Comments
 (0)