From patchwork Sun Sep 14 14:45:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Epler X-Patchwork-Id: 4901501 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id F06259F2EC for ; Sun, 14 Sep 2014 15:03:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C03A52020E for ; Sun, 14 Sep 2014 15:06:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B2FA42018E for ; Sun, 14 Sep 2014 15:06:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752599AbaINPGg (ORCPT ); Sun, 14 Sep 2014 11:06:36 -0400 Received: from rrcs-76-79-27-186.west.biz.rr.com ([76.79.27.186]:36485 "EHLO rrcs-76-79-27-186.west.biz.rr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752595AbaINPGg (ORCPT ); Sun, 14 Sep 2014 11:06:36 -0400 X-Greylist: delayed 1283 seconds by postgrey-1.27 at vger.kernel.org; Sun, 14 Sep 2014 11:06:35 EDT Received: from jepler by zaphod.unpythonic.net with local (Exim 4.80) (envelope-from ) id 1XTB36-0005RK-Bf; Sun, 14 Sep 2014 09:45:08 -0500 From: Jeff Epler To: linux@vger.kernel.org, linux-spi@vger.kernel.org Subject: [RFC 1/4] spi: reenable sync SPI transfers Date: Sun, 14 Sep 2014 09:45:05 -0500 Message-Id: <1410705908-20847-2-git-send-email-jepler@unpythonic.net> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1410705908-20847-1-git-send-email-jepler@unpythonic.net> References: <1410705908-20847-1-git-send-email-jepler@unpythonic.net> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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; }