mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] spi: spi-imx: fix use of more than four chip selects
@ 2023-04-25 13:45 Rasmus Villemoes
  2023-04-25 13:45 ` [PATCH 1/3] spi: spi-imx: use "controller" variable consistently in spi_imx_probe() Rasmus Villemoes
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: Rasmus Villemoes @ 2023-04-25 13:45 UTC (permalink / raw)
  To: Mark Brown, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, NXP Linux Team, linux-spi, linux-arm-kernel,
	linux-kernel
  Cc: Marc Kleine-Budde, Rasmus Villemoes

The current spi-imx driver completely fails when used with more than
four (gpio) chip-selects, since the chip select number is used
unconditionally as shift amount when updating the control and
configuration registers, so the code ends up modifying random bits
outside the intended fields.

This fixes it by making use of the unused_native_cs variable filled in
by the spi core, and use that as the "channel number" for all gpiod
chip selects.

In the presumably common case where all chip selects are gpios, this
means we end up using channel 0 exclusively, so the optimization where
the config register is left alone if it is unchanged (see
184434fcd617) might become less effective, if the workload consists of
different slaves with differing spi modes being accessed one after the
other. It would be nice if one could make use of the unused native
chip selects in a round-robin manner, but for that the core would have
to tell us not just unused_native_cs, but the whole ~native_cs_mask
from spi_get_gpio_descs(). Maybe a simpler fix, if there is anything
to fix, is to make the new mx51_ecspi_channel() do

	if (!spi->cs_gpiod || spi->controller->num_chipselect <= 4)


Rasmus Villemoes (3):
  spi: spi-imx: use "controller" variable consistently in
    spi_imx_probe()
  spi: spi-imx: set max_native_cs for imx51/imx53/imx6 variants
  spi: spi-imx: fix use of more than four chipselects

 drivers/spi/spi-imx.c | 56 +++++++++++++++++++++++++++----------------
 1 file changed, 35 insertions(+), 21 deletions(-)

-- 
2.37.2


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

end of thread, other threads:[~2023-05-23 21:22 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-25 13:45 [PATCH 0/3] spi: spi-imx: fix use of more than four chip selects Rasmus Villemoes
2023-04-25 13:45 ` [PATCH 1/3] spi: spi-imx: use "controller" variable consistently in spi_imx_probe() Rasmus Villemoes
2023-04-25 13:45 ` [PATCH 2/3] spi: spi-imx: set max_native_cs for imx51/imx53/imx6 variants Rasmus Villemoes
2023-04-25 13:45 ` [PATCH 3/3] spi: spi-imx: fix use of more than four chipselects Rasmus Villemoes
2023-05-16 12:07   ` Mahapatra, Amit Kumar
2023-04-26  7:19 ` [PATCH 0/3] spi: spi-imx: fix use of more than four chip selects Rasmus Villemoes
2023-04-26 12:25   ` Mark Brown
2023-04-26 12:47     ` Rasmus Villemoes
2023-04-26 13:10       ` Mark Brown
2023-04-26 13:23         ` Rasmus Villemoes
2023-05-16 11:43           ` Rasmus Villemoes
2023-05-16 15:22             ` Mark Brown
2023-05-23 21:22 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®