Correct bug parsing DisCo booleans
Subsystems (5)
Charles Keepax
maintainercover Correct bug parsing DisCo booleans
MIPI DisCo uses the unfortunate convention of allowing boolean properties to be present but having a zero value. Opposed to the normal convention of simply not specifying the property. Fix an issue in the SDCA code where mipi-sdca-control-deferrable is not parsed correctly.
However, we also have some shipping ACPIs where these properties are not specified correctly. Update the MBQ regmap to attempt defers albeit with a warning in the case where a control attempts to defer but is not marked at such. There is little down side to this as if defer is genuinely not supported then the control will just return the same error again.
Thanks,
Charles
Charles Keepax (2):
regmap: sdw-mbq: Allow defers on undeferrable controls
ASoC: SDCA: Fix reading of mipi-sdca-control-deferrable
drivers/base/regmap/regmap-sdw-mbq.c | 36 ++++++++++++++-------------- sound/soc/sdca/sdca_functions.c | 7 ++++-- 2 files changed, 23 insertions(+), 20 deletions(-)
Signature · 1 line
2.47.3
Charles Keepax
maintainerPATCH 1/2 regmap: sdw-mbq: Allow defers on undeferrable controls
It is a fairly common DisCo issue to have the deferrability of controls marked incorrectly and Windows seems very permissive in this regard. As there isn't really any down side to trying a defer even if the control isn't deferrable, allow this but add a warning message.
--- drivers/base/regmap/regmap-sdw-mbq.c | 36 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/base/regmap/regmap-sdw-mbq.c +18 -18
@@ -74,7 +74,7 @@ static int regmap_sdw_mbq_poll_busy(struct sdw_slave *slave, unsigned int reg,static int regmap_sdw_mbq_write_impl (struct sdw_slave *slave,unsigned int reg,unsigned int val, -int mbq_size,bool deferrable) +int mbq_size) {int shift = mbq_size *BITS_PER_BYTE ;int ret;
@@ -88,17 +88,14 @@ static int regmap_sdw_mbq_write_impl(struct sdw_slave *slave,return ret; } - ret =sdw_write_no_pm (slave, reg, val &0xff ); -if (deferrable && ret == -ENODATA ) -return -EAGAIN ; - -return ret; +return sdw_write_no_pm (slave, reg, val &0xff ); }static int regmap_sdw_mbq_write (void *context,unsigned int reg,unsigned int val) {struct regmap_mbq_context *ctx = context;struct sdw_slave *slave = ctx->sdw; +struct device *dev = ctx->dev;bool deferrable =regmap_sdw_mbq_deferrable (ctx, reg);int mbq_size =regmap_sdw_mbq_size (ctx, reg);int ret;
@@ -113,13 +110,16 @@ static int regmap_sdw_mbq_write(void *context, unsigned int reg, unsigned int va* process a single wait/timeout on function busy and a single retry * of the transaction. */ - ret =regmap_sdw_mbq_write_impl (slave, reg, val, mbq_size, deferrable); -if (ret == -EAGAIN ) { + ret =regmap_sdw_mbq_write_impl (slave, reg, val, mbq_size); +if (ret == -ENODATA ) { +if (!deferrable) +dev_warn (dev,"Defer on undeferrable control: %x\n" , reg); + ret =regmap_sdw_mbq_poll_busy (slave, reg, ctx);if (ret)return ret; - ret =regmap_sdw_mbq_write_impl (slave, reg, val, mbq_size, false); + ret =regmap_sdw_mbq_write_impl (slave, reg, val, mbq_size); }return ret;
@@ -127,18 +127,14 @@ static int regmap_sdw_mbq_write(void *context, unsigned int reg, unsigned int vastatic int regmap_sdw_mbq_read_impl (struct sdw_slave *slave,unsigned int reg,unsigned int *val, -int mbq_size,bool deferrable) +int mbq_size) {int shift =BITS_PER_BYTE ;int read; read =sdw_read_no_pm (slave, reg); -if (read <0 ) { -if (deferrable && read == -ENODATA ) -return -EAGAIN ; - +if (read <0 )return read; - } *val = read;
@@ -158,6 +154,7 @@ static int regmap_sdw_mbq_read(void *context, unsigned int reg, unsigned int *va {struct regmap_mbq_context *ctx = context;struct sdw_slave *slave = ctx->sdw; +struct device *dev = ctx->dev;bool deferrable =regmap_sdw_mbq_deferrable (ctx, reg);int mbq_size =regmap_sdw_mbq_size (ctx, reg);int ret;
@@ -172,13 +169,16 @@ static int regmap_sdw_mbq_read(void *context, unsigned int reg, unsigned int *va* process a single wait/timeout on function busy and a single retry * of the transaction. */ - ret =regmap_sdw_mbq_read_impl (slave, reg, val, mbq_size, deferrable); -if (ret == -EAGAIN ) { + ret =regmap_sdw_mbq_read_impl (slave, reg, val, mbq_size); +if (ret == -ENODATA ) { +if (!deferrable) +dev_warn (dev,"Defer on undeferable control: %x\n" , reg); + ret =regmap_sdw_mbq_poll_busy (slave, reg, ctx);if (ret)return ret; - ret =regmap_sdw_mbq_read_impl (slave, reg, val, mbq_size, false); + ret =regmap_sdw_mbq_read_impl (slave, reg, val, mbq_size); }return ret;
Signature · 1 line
2.47.3
Charles Keepax
maintainerPATCH 2/2 ASoC: SDCA: Fix reading of mipi-sdca-control-deferrable
In reply to Charles KeepaxThe discussion in [1] highlighted that the SDCA code shouldn't be using fwnode_property_read_bool() for DisCo controls, as the spec allows setting the value to zero meaning the property should not be used. Correct a small bug in the SDCA code that will mark such controls as deferrable.
--- sound/soc/sdca/sdca_functions.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
sound/soc/sdca/sdca_functions.c +5 -2
@@ -1006,8 +1006,11 @@ static int find_sdca_entity_control(struct device *dev, struct sdca_entity *enti control->has_fixed = true; fallthrough;case SDCA_ACCESS_MODE_RO : - control->deferrable =fwnode_property_read_bool (control_node, -"mipi-sdca-control-deferrable" ); + ret =fwnode_property_read_u32 (control_node, +"mipi-sdca-control-deferrable" , + &tmp); +if (ret ==0 ) + control->deferrable = !!tmp;break ;default :break ;
Signature · 1 line
2.47.3
Mark Brown
maintainerQuoted 9 lines · Charles Keepax
Correct bug parsing DisCo booleans
MIPI DisCo uses the unfortunate convention of allowing boolean properties to be present but having a zero value. Opposed to the normal convention of simply not specifying the property. Fix an issue in the SDCA code where mipi-sdca-control-deferrable is not parsed correctly.
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.1
Thanks!
[1/2] regmap: sdw-mbq: Allow defers on undeferrable controls
https://git.kernel.org/broonie/sound/c/ca1b11b36d82 [2/2] ASoC: SDCA: Fix reading of mipi-sdca-control-deferrable https://git.kernel.org/broonie/sound/c/956c032be7ca
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark