linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Revert "spi: omap2-mcspi: Switch to readl_poll_timeout()"
@ 2020-09-10 12:26 Aswath Govindraju
  2020-09-21 18:56 ` Mark Brown
  2020-09-22  0:06 ` Mark Brown
  0 siblings, 2 replies; 4+ messages in thread
From: Aswath Govindraju @ 2020-09-10 12:26 UTC (permalink / raw)
  Cc: Aswath Govindraju, Sekhar Nori, Mark Brown, Vignesh R, linux-spi,
	linux-kernel

This reverts commit 13d515c796adc49a49b0cd2212ccd7f43a37fc5a.

The amount of time spent polling for the MCSPI_CHSTAT bits to be set on
AM335x-icev2 platform is less than 1us (about 0.6us) in most cases, with
or without using DMA. So, in most cases the function need not sleep.
Also, setting the sleep_usecs to zero would not be optimal here because
ktime_add_us() used in readl_poll_timeout() is slower compared to the
direct addition used after the revert. So, it is sub-optimal to use
readl_poll_timeout in this case. 

When DMA is not enabled, this revert results in an increase of about 27%
in throughput and decrease of about 20% in CPU usage. However, the CPU
usage and throughput are almost the same when used with DMA. 

Therefore, fix this by reverting the commit which switched to using
readl_poll_timeout().

Fixes: 13d515c796ad ("spi: omap2-mcspi: Switch to readl_poll_timeout()")
Signed-off-by: Aswath Govindraju <a-govindraju@ti.com>
---

 drivers/spi/spi-omap2-mcspi.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 1c9478e6e5d9..d4c9510af393 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -24,7 +24,6 @@
 #include <linux/of.h>
 #include <linux/of_device.h>
 #include <linux/gcd.h>
-#include <linux/iopoll.h>
 
 #include <linux/spi/spi.h>
 
@@ -348,9 +347,19 @@ static void omap2_mcspi_set_fifo(const struct spi_device *spi,
 
 static int mcspi_wait_for_reg_bit(void __iomem *reg, unsigned long bit)
 {
-	u32 val;
-
-	return readl_poll_timeout(reg, val, val & bit, 1, MSEC_PER_SEC);
+	unsigned long timeout;
+
+	timeout = jiffies + msecs_to_jiffies(1000);
+	while (!(readl_relaxed(reg) & bit)) {
+		if (time_after(jiffies, timeout)) {
+			if (!(readl_relaxed(reg) & bit))
+				return -ETIMEDOUT;
+			else
+				return 0;
+		}
+		cpu_relax();
+	}
+	return 0;
 }
 
 static int mcspi_wait_for_completion(struct  omap2_mcspi *mcspi,

base-commit: dff9f829e5b0181d4ed9d35aa62d695292399b54
-- 
2.17.1


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

* Re: [PATCH] Revert "spi: omap2-mcspi: Switch to readl_poll_timeout()"
  2020-09-10 12:26 [PATCH] Revert "spi: omap2-mcspi: Switch to readl_poll_timeout()" Aswath Govindraju
@ 2020-09-21 18:56 ` Mark Brown
  2020-09-21 19:00   ` Mark Brown
  2020-09-22  0:06 ` Mark Brown
  1 sibling, 1 reply; 4+ messages in thread
From: Mark Brown @ 2020-09-21 18:56 UTC (permalink / raw)
  To: Aswath Govindraju; +Cc: Sekhar Nori, Vignesh R, linux-spi, linux-kernel

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

On Thu, Sep 10, 2020 at 05:56:24PM +0530, Aswath Govindraju wrote:
> This reverts commit 13d515c796adc49a49b0cd2212ccd7f43a37fc5a.
> 
> The amount of time spent polling for the MCSPI_CHSTAT bits to be set on
> AM335x-icev2 platform is less than 1us (about 0.6us) in most cases, with

Please submit patches using subject lines reflecting the style for the
subsystem, this makes it easier for people to identify relevant patches.
Look at what existing commits in the area you're changing are doing and
make sure your subject lines visually resemble what they're doing.
There's no need to resubmit to fix this alone.

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

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

* Re: [PATCH] Revert "spi: omap2-mcspi: Switch to readl_poll_timeout()"
  2020-09-21 18:56 ` Mark Brown
@ 2020-09-21 19:00   ` Mark Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2020-09-21 19:00 UTC (permalink / raw)
  To: Aswath Govindraju; +Cc: Sekhar Nori, Vignesh R, linux-spi, linux-kernel

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

On Mon, Sep 21, 2020 at 07:56:38PM +0100, Mark Brown wrote:
> On Thu, Sep 10, 2020 at 05:56:24PM +0530, Aswath Govindraju wrote:
> > This reverts commit 13d515c796adc49a49b0cd2212ccd7f43a37fc5a.
> > 
> > The amount of time spent polling for the MCSPI_CHSTAT bits to be set on
> > AM335x-icev2 platform is less than 1us (about 0.6us) in most cases, with
> 
> Please submit patches using subject lines reflecting the style for the
> subsystem, this makes it easier for people to identify relevant patches.
> Look at what existing commits in the area you're changing are doing and
> make sure your subject lines visually resemble what they're doing.
> There's no need to resubmit to fix this alone.

Oh, and also:

Please include human readable descriptions of things like commits and
issues being discussed in e-mail in your mails, this makes them much
easier for humans to read especially when they have no internet access.
I do frequently catch up on my mail on flights or while otherwise
travelling so this is even more pressing for me than just being about
making things a bit easier to read.

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

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

* Re: [PATCH] Revert "spi: omap2-mcspi: Switch to readl_poll_timeout()"
  2020-09-10 12:26 [PATCH] Revert "spi: omap2-mcspi: Switch to readl_poll_timeout()" Aswath Govindraju
  2020-09-21 18:56 ` Mark Brown
@ 2020-09-22  0:06 ` Mark Brown
  1 sibling, 0 replies; 4+ messages in thread
From: Mark Brown @ 2020-09-22  0:06 UTC (permalink / raw)
  To: Aswath Govindraju; +Cc: Vignesh R, linux-spi, linux-kernel, Sekhar Nori

On Thu, 10 Sep 2020 17:56:24 +0530, Aswath Govindraju wrote:
> This reverts commit 13d515c796adc49a49b0cd2212ccd7f43a37fc5a.
> 
> The amount of time spent polling for the MCSPI_CHSTAT bits to be set on
> AM335x-icev2 platform is less than 1us (about 0.6us) in most cases, with
> or without using DMA. So, in most cases the function need not sleep.
> Also, setting the sleep_usecs to zero would not be optimal here because
> ktime_add_us() used in readl_poll_timeout() is slower compared to the
> direct addition used after the revert. So, it is sub-optimal to use
> readl_poll_timeout in this case.
> 
> [...]

Applied to

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

Thanks!

[1/1] spi: omap2-mcspi: Improve performance waiting for CHSTAT
      commit: 7b1d96813317358312440d0d07abbfbeb0ef8d22

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] 4+ messages in thread

end of thread, other threads:[~2020-09-22  0:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-10 12:26 [PATCH] Revert "spi: omap2-mcspi: Switch to readl_poll_timeout()" Aswath Govindraju
2020-09-21 18:56 ` Mark Brown
2020-09-21 19:00   ` Mark Brown
2020-09-22  0:06 ` 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).