Patch "spi: omap2-mcspi: Improve performance waiting for CHSTAT" has been added to the 5.9-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    spi: omap2-mcspi: Improve performance waiting for CHSTAT

to the 5.9-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     spi-omap2-mcspi-improve-performance-waiting-for-chst.patch
and it can be found in the queue-5.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit c4d05d64e5324974e07f9e4a663862b09faa909d
Author: Aswath Govindraju <a-govindraju@xxxxxx>
Date:   Thu Sep 10 17:56:24 2020 +0530

    spi: omap2-mcspi: Improve performance waiting for CHSTAT
    
    [ Upstream commit 7b1d96813317358312440d0d07abbfbeb0ef8d22 ]
    
    This reverts commit 13d515c796 (spi: omap2-mcspi: Switch to
    readl_poll_timeout()).
    
    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@xxxxxx>
    Link: https://lore.kernel.org/r/20200910122624.8769-1-a-govindraju@xxxxxx
    Signed-off-by: Mark Brown <broonie@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 1c9478e6e5d99..d4c9510af3931 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,



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux