From patchwork Mon Sep 1 14:35:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 4820081 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 39027C0338 for ; Mon, 1 Sep 2014 14:35:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8FA2A20155 for ; Mon, 1 Sep 2014 14:35:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B3A912013A for ; Mon, 1 Sep 2014 14:35:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753527AbaIAOfU (ORCPT ); Mon, 1 Sep 2014 10:35:20 -0400 Received: from metis.ext.pengutronix.de ([92.198.50.35]:49738 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752008AbaIAOfT (ORCPT ); Mon, 1 Sep 2014 10:35:19 -0400 Received: from dude.hi.4.pengutronix.de ([10.1.0.7] helo=dude.pengutronix.de.) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1XOShQ-0000OV-VU; Mon, 01 Sep 2014 16:35:16 +0200 From: Lucas Stach To: Mark Brown Cc: linux-spi@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH] spi: spi-imx: use threaded interrupt Date: Mon, 1 Sep 2014 16:35:06 +0200 Message-Id: <1409582106-2845-1-git-send-email-l.stach@pengutronix.de> X-Mailer: git-send-email 2.1.0 X-SA-Exim-Connect-IP: 10.1.0.7 X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-spi@vger.kernel.org Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-8.6 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 From: Sascha Hauer The i.MX SPI driver fills/flushes the FIFOs in interrupt context. With longer SPI messages this introduces big latencies in the system. Using a threaded interrupt avoids this issue. Signed-off-by: Sascha Hauer Signed-off-by: Lucas Stach --- drivers/spi/spi-imx.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index 5daff2054ae4..5e40801e1c52 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c @@ -672,6 +672,15 @@ static irqreturn_t spi_imx_isr(int irq, void *dev_id) { struct spi_imx_data *spi_imx = dev_id; + spi_imx->devtype_data->intctrl(spi_imx, 0); + + return IRQ_WAKE_THREAD; +} + +static irqreturn_t spi_imx_isr_thread(int irq, void *dev_id) +{ + struct spi_imx_data *spi_imx = dev_id; + while (spi_imx->devtype_data->rx_available(spi_imx)) { spi_imx->rx(spi_imx); spi_imx->txfifo--; @@ -679,6 +688,7 @@ static irqreturn_t spi_imx_isr(int irq, void *dev_id) if (spi_imx->count) { spi_imx_push(spi_imx); + spi_imx->devtype_data->intctrl(spi_imx, MXC_INT_TE); return IRQ_HANDLED; } @@ -691,7 +701,6 @@ static irqreturn_t spi_imx_isr(int irq, void *dev_id) return IRQ_HANDLED; } - spi_imx->devtype_data->intctrl(spi_imx, 0); complete(&spi_imx->xfer_done); return IRQ_HANDLED; @@ -883,8 +892,8 @@ static int spi_imx_probe(struct platform_device *pdev) goto out_master_put; } - ret = devm_request_irq(&pdev->dev, spi_imx->irq, spi_imx_isr, 0, - dev_name(&pdev->dev), spi_imx); + ret = request_threaded_irq(spi_imx->irq, spi_imx_isr, + spi_imx_isr_thread, 0, dev_name(&pdev->dev), spi_imx); if (ret) { dev_err(&pdev->dev, "can't get irq%d: %d\n", spi_imx->irq, ret); goto out_master_put;