From mboxrd@z Thu Jan 1 00:00:00 1970 From: Grant Likely Subject: Re: [PATCH 1/2] spi: sh-hspi: Improve performance Date: Fri, 23 Nov 2012 09:51:37 +0000 Message-ID: <20121123095137.7DBB03E07BE@localhost> References: <1353595047-14558-1-git-send-email-phil.edworthy@renesas.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Phil Edworthy , Kuninori Morimoto To: Phil Edworthy , spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Return-path: In-Reply-To: <1353595047-14558-1-git-send-email-phil.edworthy-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spi-devel-general-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: linux-spi.vger.kernel.org On Thu, 22 Nov 2012 14:37:26 +0000, Phil Edworthy wrote: > The driver attempts to read the recieved data immediately after > writing to the transmit buffer. If no data is available, the driver > currently waits 20ms until trying again. Since the hardware needs > to shift out the transmitted data, the first poll always fails, > leading to 20ms delay between bytes. > > This patch reduces the polling interval to 1us, and also reduces > the timeout to 10ms. > > Signed-off-by: Phil Edworthy > --- > drivers/spi/spi-sh-hspi.c | 4 ++-- > 1 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/spi/spi-sh-hspi.c b/drivers/spi/spi-sh-hspi.c > index 934138c..0ca18c8 100644 > --- a/drivers/spi/spi-sh-hspi.c > +++ b/drivers/spi/spi-sh-hspi.c > @@ -73,13 +73,13 @@ static u32 hspi_read(struct hspi_priv *hspi, int reg) > */ > static int hspi_status_check_timeout(struct hspi_priv *hspi, u32 mask, u32 val) > { > - int t = 256; > + int t = 10000; /* 10ms max timeout */ > > while (t--) { > if ((mask & hspi_read(hspi, SPSR)) == val) > return 0; > > - msleep(20); > + udelay(1); > } This does have the side effect that the cpu is now spinning instead of scheduling something else when the device is busy. Is that what you want? (the answer depends on how big the fifo is and how fast the SPI bus runs). g. ------------------------------------------------------------------------------ Monitor your physical, virtual and cloud infrastructure from a single web console. Get in-depth insight into apps, servers, databases, vmware, SAP, cloud infrastructure, etc. Download 30-day Free Trial. Pricing starts from $795 for 25 servers or applications! http://p.sf.net/sfu/zoho_dev2dev_nov