Repository navigation
Conversation
When the cache_only flag is set, reading from a volatile register results in -EBUSY. Change the test to allow volatile reads. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
|
I shared this in an issue but somehow no one looked into it. Re-sharing as a formal PR for comments. |
|
@plbossart This doesn't work with the existing sdw drivers. The point is that we resume sdw bus, but do not wait for codec attached when we try to read codec register in suspend. Currently, codec driver will wait for log |
|
@plbossart still observe the dump with patch, PFA- |
When we do a sdw_read, we do a pm_runtime_get_sync() so we should wait for everything to resume nicely. initialization_complete should also be set when the codec is actually present. I can accept this doesn't work but this probably shows a bug somewhere else. |
So we may want to
Maybe enumeration_complete is a better choice in this case. We don't need to wait for codec initialization if we just want to read a register. @naveen-manohar Can you test #2526
I still have a concern on other devices with different IO interfaces. For example, I2C codecs may be powered off when it set cache only flag and I don't know if it will be woke up if we try to read its register when it is powered off. |
Agree, it's risky since it impacts everyone using regmap, but at the same time is returning - EBUSY the right thing to do if the codec is not powered? My solution may not be the right one, but the existing behavior doesn't seem right either. |
|
@bardliao I found a couple of bugs in our soundwire code, but there is also a conceptual deadlock with regmap. When we use regmap_read, we take a lock int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val)
{
int ret;
if (!IS_ALIGNED(reg, map->reg_stride))
return -EINVAL;
map->lock(map->lock_arg);
ret = _regmap_read(map, reg, val);
map->unlock(map->lock_arg);
return ret;
}then if we use my patch and do a sdw_regmap_read, we will resume the slave device, but in the resume routines, we call regcache_cache_only which takes the same lock -> deadlock void regcache_cache_only(struct regmap *map, bool enable)
{
map->lock(map->lock_arg);
WARN_ON(map->cache_bypass && enable);
map->cache_only = enable;
trace_regmap_cache_only(map, enable);
map->unlock(map->lock_arg);
}
EXPORT_SYMBOL_GPL(regcache_cache_only);what we would need to do is change the ASoC core to call pm_runtime_get_sync() before calling regmap_read. Or maybe we keep the existing solution and accessing a volatile register while in suspend returns -EBUSY. |
@plbossart Yeah, returning -EBUSY doesn't seem be right. -EIO makes more sense to me.
IMHO, codec driver should avoid reading volatile registers in suspend. See #2532 |
JFYI, with #2532 Verified Basic Maxim-Speaker Functionality(non-dsm) & also issue mentioned at #2510 isn't observed. Thanks |
|
closing, this PR exposed just too many issues with pm_runtime that need to be fixed first. |
When the cache_only flag is set, reading from a volatile register
results in -EBUSY. Change the test to allow volatile reads.
Signed-off-by: Pierre-Louis Bossart pierre-louis.bossart@linux.intel.com