From: Janne Grunau via B4 Relay <devnull+j.jannau.net@kernel.org> To: Mark Brown <broonie@kernel.org>, Amit Kumar Mahapatra <amit.kumar-mahapatra@amd.com> Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, regressions@lists.linux.dev, Janne Grunau <j@jannau.net> Subject: [PATCH] spi: Restore delays for non-GPIO chip select Date: Mon, 11 Mar 2024 23:53:17 +0100 [thread overview] Message-ID: <20240311-spi-cs-delays-regression-v1-1-0075020a90b2@jannau.net> (raw) From: Janne Grunau <j@jannau.net> SPI controller with integrated chip select handling still need to adhere to SPI device's CS setup, hold and inactive delays. For controller without set_cs_timing spi core shall handle the delays to avoid duplicated delay handling in each controller driver. Fixes a regression for the out of tree SPI controller and SPI HID transport on Apple M1/M1 Pro/Max notebooks. Fixes: 4d8ff6b0991d ("spi: Add multi-cs memories support in SPI core") Signed-off-by: Janne Grunau <j@jannau.net> --- #regzbot ^introduced 4d8ff6b0991d5e86b17b235fc46ec62e9195cb9 --- drivers/spi/spi.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index f2170f4b5077..71be2ba8402f 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1042,10 +1042,14 @@ static void spi_set_cs(struct spi_device *spi, bool enable, bool force) if (spi->mode & SPI_CS_HIGH) enable = !enable; - if (spi_is_csgpiod(spi)) { - if (!spi->controller->set_cs_timing && !activate) - spi_delay_exec(&spi->cs_hold, NULL); + /* + * Handle chip select delays for GPIO based CS or controllers without + * programmable chip select timing. + */ + if ((spi_is_csgpiod(spi) || !spi->controller->set_cs_timing) && !activate) + spi_delay_exec(&spi->cs_hold, NULL); + if (spi_is_csgpiod(spi)) { if (!(spi->mode & SPI_NO_CS)) { /* * Historically ACPI has no means of the GPIO polarity and @@ -1079,16 +1083,16 @@ static void spi_set_cs(struct spi_device *spi, bool enable, bool force) if ((spi->controller->flags & SPI_CONTROLLER_GPIO_SS) && spi->controller->set_cs) spi->controller->set_cs(spi, !enable); - - if (!spi->controller->set_cs_timing) { - if (activate) - spi_delay_exec(&spi->cs_setup, NULL); - else - spi_delay_exec(&spi->cs_inactive, NULL); - } } else if (spi->controller->set_cs) { spi->controller->set_cs(spi, !enable); } + + if (spi_is_csgpiod(spi) || !spi->controller->set_cs_timing) { + if (activate) + spi_delay_exec(&spi->cs_setup, NULL); + else + spi_delay_exec(&spi->cs_inactive, NULL); + } } #ifdef CONFIG_HAS_DMA --- base-commit: e8f897f4afef0031fe618a8e94127a0934896aba change-id: 20240311-spi-cs-delays-regression-fd7309fc0eff Best regards, -- Janne Grunau <j@jannau.net>
WARNING: multiple messages have this Message-ID (diff)
From: Janne Grunau <j@jannau.net> To: Mark Brown <broonie@kernel.org>, Amit Kumar Mahapatra <amit.kumar-mahapatra@amd.com> Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, regressions@lists.linux.dev, Janne Grunau <j@jannau.net> Subject: [PATCH] spi: Restore delays for non-GPIO chip select Date: Mon, 11 Mar 2024 23:53:17 +0100 [thread overview] Message-ID: <20240311-spi-cs-delays-regression-v1-1-0075020a90b2@jannau.net> (raw) SPI controller with integrated chip select handling still need to adhere to SPI device's CS setup, hold and inactive delays. For controller without set_cs_timing spi core shall handle the delays to avoid duplicated delay handling in each controller driver. Fixes a regression for the out of tree SPI controller and SPI HID transport on Apple M1/M1 Pro/Max notebooks. Fixes: 4d8ff6b0991d ("spi: Add multi-cs memories support in SPI core") Signed-off-by: Janne Grunau <j@jannau.net> --- #regzbot ^introduced 4d8ff6b0991d5e86b17b235fc46ec62e9195cb9 --- drivers/spi/spi.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index f2170f4b5077..71be2ba8402f 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1042,10 +1042,14 @@ static void spi_set_cs(struct spi_device *spi, bool enable, bool force) if (spi->mode & SPI_CS_HIGH) enable = !enable; - if (spi_is_csgpiod(spi)) { - if (!spi->controller->set_cs_timing && !activate) - spi_delay_exec(&spi->cs_hold, NULL); + /* + * Handle chip select delays for GPIO based CS or controllers without + * programmable chip select timing. + */ + if ((spi_is_csgpiod(spi) || !spi->controller->set_cs_timing) && !activate) + spi_delay_exec(&spi->cs_hold, NULL); + if (spi_is_csgpiod(spi)) { if (!(spi->mode & SPI_NO_CS)) { /* * Historically ACPI has no means of the GPIO polarity and @@ -1079,16 +1083,16 @@ static void spi_set_cs(struct spi_device *spi, bool enable, bool force) if ((spi->controller->flags & SPI_CONTROLLER_GPIO_SS) && spi->controller->set_cs) spi->controller->set_cs(spi, !enable); - - if (!spi->controller->set_cs_timing) { - if (activate) - spi_delay_exec(&spi->cs_setup, NULL); - else - spi_delay_exec(&spi->cs_inactive, NULL); - } } else if (spi->controller->set_cs) { spi->controller->set_cs(spi, !enable); } + + if (spi_is_csgpiod(spi) || !spi->controller->set_cs_timing) { + if (activate) + spi_delay_exec(&spi->cs_setup, NULL); + else + spi_delay_exec(&spi->cs_inactive, NULL); + } } #ifdef CONFIG_HAS_DMA --- base-commit: e8f897f4afef0031fe618a8e94127a0934896aba change-id: 20240311-spi-cs-delays-regression-fd7309fc0eff Best regards, -- Janne Grunau <j@jannau.net>
next reply other threads:[~2024-03-11 22:53 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-03-11 22:53 Janne Grunau via B4 Relay [this message] 2024-03-11 22:53 ` [PATCH] spi: Restore delays for non-GPIO chip select Janne Grunau 2024-03-12 14:47 ` Greg KH 2024-03-12 16:57 ` Mark Brown
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20240311-spi-cs-delays-regression-v1-1-0075020a90b2@jannau.net \ --to=devnull+j.jannau.net@kernel.org \ --cc=amit.kumar-mahapatra@amd.com \ --cc=asahi@lists.linux.dev \ --cc=broonie@kernel.org \ --cc=j@jannau.net \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-spi@vger.kernel.org \ --cc=regressions@lists.linux.dev \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.