diff mbox series

spi: mux: Fix master controller settings after mux select

Message ID 20240422114150.84426-1-heikki.keranen@bittium.com (mailing list archive)
State Superseded
Commit 856d9e8e9d42759b7fe6c6e13a2d6ff325b65f91
Headers show
Series spi: mux: Fix master controller settings after mux select | expand

Commit Message

Heikki Keranen April 22, 2024, 11:41 a.m. UTC
In some cases SPI child devices behind spi-mux require different
settings like: max_speed_hz, mode and bits_per_word.

Typically the slave device driver puts the settings in place and calls
spi_setup() once during probe and assumes they stay in place for all
following spi transfers.

However spi-mux forwarded spi_setup() -call to SPI master driver only
when slave driver calls spi_setup(). If second slave device was
accessed meanwhile and that driver called spi_setup(), the
settings did not change back to the first spi device.
In case of wrong max_speed_hz this caused spi trasfers to fail.

This commit adds spi_setup() call after mux is changed. This way
the right device specific parameters are set to the master driver.

The fix has been tested by using custom hardware and debugging
spi master driver speed settings.

Co-authored-by: Petri Tauriainen <petri.tauriainen@bittium.com>
Signed-off-by: Heikki Keranen <heikki.keranen@bittium.com>
---
 drivers/spi/spi-mux.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Mark Brown April 23, 2024, 5:20 a.m. UTC | #1
On Mon, 22 Apr 2024 14:41:50 +0300, Heikki Keranen wrote:
> In some cases SPI child devices behind spi-mux require different
> settings like: max_speed_hz, mode and bits_per_word.
> 
> Typically the slave device driver puts the settings in place and calls
> spi_setup() once during probe and assumes they stay in place for all
> following spi transfers.
> 
> [...]

Applied to

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

Thanks!

[1/1] spi: mux: Fix master controller settings after mux select
      commit: 856d9e8e9d42759b7fe6c6e13a2d6ff325b65f91

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
Andy Shevchenko April 23, 2024, 10:45 a.m. UTC | #2
Mon, Apr 22, 2024 at 02:41:50PM +0300, Heikki Keranen kirjoitti:
> In some cases SPI child devices behind spi-mux require different
> settings like: max_speed_hz, mode and bits_per_word.
> 
> Typically the slave device driver puts the settings in place and calls
> spi_setup() once during probe and assumes they stay in place for all
> following spi transfers.
> 
> However spi-mux forwarded spi_setup() -call to SPI master driver only
> when slave driver calls spi_setup(). If second slave device was
> accessed meanwhile and that driver called spi_setup(), the
> settings did not change back to the first spi device.
> In case of wrong max_speed_hz this caused spi trasfers to fail.
> 
> This commit adds spi_setup() call after mux is changed. This way
> the right device specific parameters are set to the master driver.
> 
> The fix has been tested by using custom hardware and debugging
> spi master driver speed settings.

> Co-authored-by: Petri Tauriainen <petri.tauriainen@bittium.com>

Since it's already applied for the future please note, the correct tag is
Co-developed-by and in accordance with Submitting Patches it must followed by
the respective Signed-off-by. In this case it had to be

Co-developed-by: Petri Tauriainen <petri.tauriainen@bittium.com>
Signed-off-by: Petri Tauriainen <petri.tauriainen@bittium.com>
diff mbox series

Patch

diff --git a/drivers/spi/spi-mux.c b/drivers/spi/spi-mux.c
index bd988f53753e..5d72e3d59df8 100644
--- a/drivers/spi/spi-mux.c
+++ b/drivers/spi/spi-mux.c
@@ -68,6 +68,8 @@  static int spi_mux_select(struct spi_device *spi)
 
 	priv->current_cs = spi_get_chipselect(spi, 0);
 
+	spi_setup(priv->spi);
+
 	return 0;
 }