From patchwork Fri Dec 21 20:13:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Murali Karicheri X-Patchwork-Id: 1904681 Return-Path: X-Original-To: patchwork-spi-devel-general@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by patchwork2.kernel.org (Postfix) with ESMTP id E46EBDF215 for ; Fri, 21 Dec 2012 20:13:43 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1Tm8yT-0003dF-2T; Fri, 21 Dec 2012 20:13:41 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1Tm8yQ-0003d8-Uf for spi-devel-general@lists.sourceforge.net; Fri, 21 Dec 2012 20:13:38 +0000 Received-SPF: pass (sog-mx-4.v43.ch3.sourceforge.com: domain of ti.com designates 192.94.94.40 as permitted sender) client-ip=192.94.94.40; envelope-from=m-karicheri2@ti.com; helo=arroyo.ext.ti.com; Received: from arroyo.ext.ti.com ([192.94.94.40]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1Tm8yN-0005yB-7u for spi-devel-general@lists.sourceforge.net; Fri, 21 Dec 2012 20:13:38 +0000 Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id qBLKDTxZ017044; Fri, 21 Dec 2012 14:13:29 -0600 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id qBLKDTXE018113; Fri, 21 Dec 2012 14:13:29 -0600 Received: from dlelxv22.itg.ti.com (172.17.1.197) by dfle72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.1.323.3; Fri, 21 Dec 2012 14:13:28 -0600 Received: from ares-ubuntu.am.dhcp.ti.com (ares-ubuntu.am.dhcp.ti.com [158.218.103.17]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id qBLKDSOU023961; Fri, 21 Dec 2012 14:13:29 -0600 Received: from a0868495 by ares-ubuntu.am.dhcp.ti.com with local (Exim 4.76) (envelope-from ) id 1Tm8yG-00006p-IK; Fri, 21 Dec 2012 15:13:28 -0500 From: Murali Karicheri To: , , Subject: [PATCH] spi: davinci: use request_threaded_irq() to fix deadlock Date: Fri, 21 Dec 2012 15:13:26 -0500 Message-ID: <1356120806-27964-1-git-send-email-m-karicheri2@ti.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-Spam-Score: -1.5 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record X-Headers-End: 1Tm8yN-0005yB-7u Cc: Murali Karicheri X-BeenThere: spi-devel-general@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux SPI core/device drivers discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spi-devel-general-bounces@lists.sourceforge.net With RT pre-empt patch applied to Linux kernel, the irq handler will be force converted to an irq thread. spi driver can get back to back messages from the slave device. In such cases, IRQ thread doesn't get a chance to run to read the slave data. Hence the irq handler must be run in hard irq context to read/write data from slave device. Otherwise, the kernel goes into a deadlock. This patch fixes this issue when PREEMPT_RT_FULL is enabled in the kernel. A dummy thread function is provided to satisfy the request_threaded_irq() API. Passing a NULL for function also causes the irq handler to be executed in the thread context. Signed-off-by: Murali Karicheri --- drivers/spi/spi-davinci.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c index 50bd2cd..8234d22 100644 --- a/drivers/spi/spi-davinci.c +++ b/drivers/spi/spi-davinci.c @@ -702,6 +702,19 @@ err_alloc_dummy_buf: } /** + * dummy_thread_fn - dummy thread function + * @irq: IRQ number for this SPI Master + * @context_data: structure for SPI Master controller davinci_spi + * + * This is to satisfy the request_threaded_irq() API so that the irq + * handler is called in interrupt context. + */ +static irqreturn_t dummy_thread_fn(s32 irq, void *data) +{ + return IRQ_HANDLED; +} + +/** * davinci_spi_irq - Interrupt handler for SPI Master Controller * @irq: IRQ number for this SPI Master * @context_data: structure for SPI Master controller davinci_spi @@ -899,8 +912,8 @@ static int davinci_spi_probe(struct platform_device *pdev) goto unmap_io; } - ret = request_irq(dspi->irq, davinci_spi_irq, 0, dev_name(&pdev->dev), - dspi); + ret = request_threaded_irq(dspi->irq, davinci_spi_irq, dummy_thread_fn, + 0, dev_name(&pdev->dev), dspi); if (ret) goto unmap_io;