linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Epler <jepler@unpythonic.net>
To: linux-rt-users@vger.kernel.org
Subject: [PATCH 1/4] spi: reenable sync SPI transfers
Date: Mon,  1 Sep 2014 09:30:32 -0500	[thread overview]
Message-ID: <1409581835-70814-2-git-send-email-jepler@unpythonic.net> (raw)
In-Reply-To: <1409581835-70814-1-git-send-email-jepler@unpythonic.net>

one source of excess latency in hm2_spi / hal_spidev is latency due
to async transfers.  Make the __spi_sync primitive actually synchronous,
rather than building on an asynchronous primitive.
---
 drivers/spi/spi.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 19ee901..55404b5 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -664,10 +664,18 @@ void spi_finalize_current_message(struct spi_master *master)
 	struct spi_message *mesg;
 	unsigned long flags;
 
+        if(!master->cur_msg)
+                return;
+
 	spin_lock_irqsave(&master->queue_lock, flags);
 	mesg = master->cur_msg;
 	master->cur_msg = NULL;
 
+        if(!mesg) {
+                spin_unlock_irqrestore(&master->queue_lock, flags);
+                return;
+        }
+
 	queue_kthread_work(&master->kworker, &master->pump_messages);
 	spin_unlock_irqrestore(&master->queue_lock, flags);
 
@@ -1490,24 +1498,26 @@ static int __spi_sync(struct spi_device *spi, struct spi_message *message,
 		      int bus_locked)
 {
 	DECLARE_COMPLETION_ONSTACK(done);
-	int status;
+	int status = 0;
 	struct spi_master *master = spi->master;
 
 	message->complete = spi_complete;
 	message->context = &done;
+	message->spi = spi;
 
 	if (!bus_locked)
 		mutex_lock(&master->bus_lock_mutex);
 
-	status = spi_async_locked(spi, message);
+        if(master->prepare_transfer_hardware)
+            status = master->prepare_transfer_hardware(master);
+        if(status >= 0)
+            status = master->transfer_one_message(master, message);
+        if(status >= 0 && master->unprepare_transfer_hardware)
+            status = master->unprepare_transfer_hardware(master);
 
 	if (!bus_locked)
 		mutex_unlock(&master->bus_lock_mutex);
 
-	if (status == 0) {
-		wait_for_completion(&done);
-		status = message->status;
-	}
 	message->context = NULL;
 	return status;
 }
-- 
2.0.1


  reply	other threads:[~2014-09-01 15:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-01 14:30 [RFC 0/4] Improving SPI driver latency (vs v3.8.13.14-rt31) Jeff Epler
2014-09-01 14:30 ` Jeff Epler [this message]
2014-09-01 14:30 ` [PATCH 2/4] spidev: Avoid runtime memory allocations Jeff Epler
2014-09-01 14:30 ` [PATCH 3/4] spidev: actually use synchronous transfers Jeff Epler
2014-09-01 14:30 ` [PATCH 4/4] spidev-s3c64xx: allocate dma channel at startup Jeff Epler
2014-09-01 15:41 ` [RFC 0/4] Improving SPI driver latency (vs v3.8.13.14-rt31) Philipp Lutz
2014-09-01 18:13   ` Jeff Epler
2014-09-01 22:30     ` Harry van Haaren
2014-09-09 20:01 ` Uwe Kleine-König

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=1409581835-70814-2-git-send-email-jepler@unpythonic.net \
    --to=jepler@unpythonic.net \
    --cc=linux-rt-users@vger.kernel.org \
    /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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).