linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] regmap: sdw: check for invalid multi-register writes config
@ 2023-05-23 15:47 Srinivas Kandagatla
  2023-05-23 16:58 ` Mark Brown
  2023-05-24 11:58 ` Mark Brown
  0 siblings, 2 replies; 5+ messages in thread
From: Srinivas Kandagatla @ 2023-05-23 15:47 UTC (permalink / raw)
  To: broonie
  Cc: gregkh, rafael, ckeepax, tanureal, linux-kernel, alsa-devel,
	Srinivas Kandagatla

SoundWire code as it is only supports Bulk register writes and
it does not support multi-register writes.

Any drivers that set can_multi_write and use regmap_multi_reg_write() will
easily endup with programming the hardware incorrectly without any errors.

So, add this check in bus code to be able to validate the drivers config.

Fixes: 522272047dc6 ("regmap: sdw: Remove 8-bit value size restriction")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/base/regmap/regmap-sdw.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/base/regmap/regmap-sdw.c b/drivers/base/regmap/regmap-sdw.c
index 09899ae99fc1..159c0b740b00 100644
--- a/drivers/base/regmap/regmap-sdw.c
+++ b/drivers/base/regmap/regmap-sdw.c
@@ -59,6 +59,10 @@ static int regmap_sdw_config_check(const struct regmap_config *config)
 	if (config->pad_bits != 0)
 		return -ENOTSUPP;
 
+	/* Only bulk writes are supported not multi-register writes */
+	if (config->can_multi_write)
+		return -ENOTSUPP;
+
 	return 0;
 }
 
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] regmap: sdw: check for invalid multi-register writes config
  2023-05-23 15:47 [PATCH] regmap: sdw: check for invalid multi-register writes config Srinivas Kandagatla
@ 2023-05-23 16:58 ` Mark Brown
  2023-05-23 17:13   ` Srinivas Kandagatla
  2023-05-24 11:58 ` Mark Brown
  1 sibling, 1 reply; 5+ messages in thread
From: Mark Brown @ 2023-05-23 16:58 UTC (permalink / raw)
  To: Srinivas Kandagatla
  Cc: gregkh, rafael, ckeepax, tanureal, linux-kernel, alsa-devel

[-- Attachment #1: Type: text/plain, Size: 343 bytes --]

On Tue, May 23, 2023 at 04:47:47PM +0100, Srinivas Kandagatla wrote:

> +	/* Only bulk writes are supported not multi-register writes */
> +	if (config->can_multi_write)
> +		return -ENOTSUPP;
> +

This doesn't seem like the right fix - I'd expect us to simply choose
not to use multiple writes, with an additional flag/check for bus
support.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] regmap: sdw: check for invalid multi-register writes config
  2023-05-23 16:58 ` Mark Brown
@ 2023-05-23 17:13   ` Srinivas Kandagatla
  2023-05-23 17:25     ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Srinivas Kandagatla @ 2023-05-23 17:13 UTC (permalink / raw)
  To: Mark Brown; +Cc: gregkh, rafael, ckeepax, tanureal, linux-kernel, alsa-devel



On 23/05/2023 17:58, Mark Brown wrote:
> On Tue, May 23, 2023 at 04:47:47PM +0100, Srinivas Kandagatla wrote:
> 
>> +	/* Only bulk writes are supported not multi-register writes */
>> +	if (config->can_multi_write)
>> +		return -ENOTSUPP;
>> +
> 
> This doesn't seem like the right fix - I'd expect us to simply choose
> not to use multiple writes, with an additional flag/check for bus
> support.
Is there a way to check if bus support multi-register writes?

All I can see from the code is that regmap can_multi_write is set based 
on regmap_config from device and write callback from bus.


--srini

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] regmap: sdw: check for invalid multi-register writes config
  2023-05-23 17:13   ` Srinivas Kandagatla
@ 2023-05-23 17:25     ` Mark Brown
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2023-05-23 17:25 UTC (permalink / raw)
  To: Srinivas Kandagatla
  Cc: gregkh, rafael, ckeepax, tanureal, linux-kernel, alsa-devel

[-- Attachment #1: Type: text/plain, Size: 825 bytes --]

On Tue, May 23, 2023 at 06:13:25PM +0100, Srinivas Kandagatla wrote:
> On 23/05/2023 17:58, Mark Brown wrote:
> > On Tue, May 23, 2023 at 04:47:47PM +0100, Srinivas Kandagatla wrote:

> > > +	/* Only bulk writes are supported not multi-register writes */
> > > +	if (config->can_multi_write)
> > > +		return -ENOTSUPP;

> > This doesn't seem like the right fix - I'd expect us to simply choose
> > not to use multiple writes, with an additional flag/check for bus
> > support.

> Is there a way to check if bus support multi-register writes?

> All I can see from the code is that regmap can_multi_write is set based on
> regmap_config from device and write callback from bus.

No, that'd be the additional flag/check bit - see also my question about
if this is something the hardware actually has or not on the CODEC patch.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] regmap: sdw: check for invalid multi-register writes config
  2023-05-23 15:47 [PATCH] regmap: sdw: check for invalid multi-register writes config Srinivas Kandagatla
  2023-05-23 16:58 ` Mark Brown
@ 2023-05-24 11:58 ` Mark Brown
  1 sibling, 0 replies; 5+ messages in thread
From: Mark Brown @ 2023-05-24 11:58 UTC (permalink / raw)
  To: Srinivas Kandagatla
  Cc: gregkh, rafael, ckeepax, tanureal, linux-kernel, alsa-devel

On Tue, 23 May 2023 16:47:47 +0100, Srinivas Kandagatla wrote:
> SoundWire code as it is only supports Bulk register writes and
> it does not support multi-register writes.
> 
> Any drivers that set can_multi_write and use regmap_multi_reg_write() will
> easily endup with programming the hardware incorrectly without any errors.
> 
> So, add this check in bus code to be able to validate the drivers config.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next

Thanks!

[1/1] regmap: sdw: check for invalid multi-register writes config
      commit: 95856d1f3c223c015780fffb8373a827fc4efd2e

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-05-24 11:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-23 15:47 [PATCH] regmap: sdw: check for invalid multi-register writes config Srinivas Kandagatla
2023-05-23 16:58 ` Mark Brown
2023-05-23 17:13   ` Srinivas Kandagatla
2023-05-23 17:25     ` Mark Brown
2023-05-24 11:58 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).