From patchwork Mon Aug 6 14:18:55 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 1279561 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id EAE033FD57 for ; Mon, 6 Aug 2012 14:26:31 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SyOCp-0006lC-15; Mon, 06 Aug 2012 14:22:51 +0000 Received: from na3sys009aog105.obsmtp.com ([74.125.149.75]) by merlin.infradead.org with smtps (Exim 4.76 #1 (Red Hat Linux)) id 1SyOCf-0006kF-6B for linux-arm-kernel@lists.infradead.org; Mon, 06 Aug 2012 14:22:42 +0000 Received: from mail-lb0-f171.google.com ([209.85.217.171]) (using TLSv1) by na3sys009aob105.postini.com ([74.125.148.12]) with SMTP ID DSNKUB/TL3j35wkEKMfgFGPBKFv2vR3b3omE@postini.com; Mon, 06 Aug 2012 07:22:40 PDT Received: by lbol12 with SMTP id l12so5683454lbo.16 for ; Mon, 06 Aug 2012 07:22:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=7iZG70MWfCJ5cnyO77tR3FMqxnG7Zgf2wnRlowA7kvE=; b=EQXSB5dVU0Hg6ZTervACOsRQ3iSI9gAbySVoa8gI2zRCt/9IsWJyry8V2HrzcJxp+g qvof3RFU0icFB1apJMpCfQSbhF8EHCQEESKMvrRXKhTWRT5tMIAGyUFU8lRuFw5Se2Lq eb8rAY7qFDipc+RJTiS4hMSnF+JvQfT/4tKtnp5ZwtC3nNQt/l8ljjeJXxrRbkZ10EBv 1Jx5tdh+7jVj6oXMBndhTfmHb2/6CkaxEtUSXDSaxC80bawsUn/G+2RlpPzqE8r0Nakp jMm1nW+weRqKIGqvGnZd4222xECWXUs8F4ouSKpEejI7MqQuuhxiNfOsqqNd1C/s6t2F 1WMQ== Received: by 10.112.85.202 with SMTP id j10mr2878162lbz.73.1344262957541; Mon, 06 Aug 2012 07:22:37 -0700 (PDT) Received: from localhost (cs78217178.pp.htv.fi. [62.78.217.178]) by mx.google.com with ESMTPS id gd9sm3772722lbb.15.2012.08.06.07.22.36 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 06 Aug 2012 07:22:36 -0700 (PDT) From: Felipe Balbi To: Shubhrajyoti Datta Subject: [PATCH 2/4] i2c: omap: switch to threaded IRQ support Date: Mon, 6 Aug 2012 17:18:55 +0300 Message-Id: <1344262737-6662-3-git-send-email-balbi@ti.com> X-Mailer: git-send-email 1.7.12.rc0 In-Reply-To: <1344262737-6662-1-git-send-email-balbi@ti.com> References: <1344262737-6662-1-git-send-email-balbi@ti.com> X-Gm-Message-State: ALoCoQng1WZtTGiIU9kde8fRNOp8zAZSpszjjVjVxi3zD+7F4PjQ/JAlmCFs+V3U5AoV/9PFZE4S X-Spam-Note: CRM114 invocation failed X-Spam-Score: -4.2 (----) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-4.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [74.125.149.75 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Linux OMAP Mailing List , Felipe Balbi , w.sang@pengutronix.de, Linux ARM Kernel Mailing List X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org for OMAP2, we can easily switch over to threaded IRQs on the I2C driver. This will allow us to spend less time in hardirq context. Signed-off-by: Felipe Balbi --- drivers/i2c/busses/i2c-omap.c | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index f5eafb7..a3db053 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c @@ -176,6 +176,7 @@ enum { #define I2C_OMAP_ERRATA_I462 (1 << 1) struct omap_i2c_dev { + spinlock_t lock; /* IRQ synchronization */ struct device *dev; void __iomem *base; /* virtual */ int irq; @@ -854,9 +855,30 @@ static int omap_i2c_transmit_data(struct omap_i2c_dev *dev, u8 num_bytes, } static irqreturn_t -omap_i2c_isr(int this_irq, void *dev_id) +omap_i2c_isr(int irq, void *dev_id) { struct omap_i2c_dev *dev = dev_id; + irqreturn_t ret = IRQ_HANDLED; + u16 mask; + u16 stat; + + spin_lock(&dev->lock); + mask = omap_i2c_read_reg(dev, OMAP_I2C_IE_REG); + stat = omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG); + + if (stat & mask) + ret = IRQ_WAKE_THREAD; + + spin_unlock(&dev->lock); + + return ret; +} + +static irqreturn_t +omap_i2c_isr_thread(int this_irq, void *dev_id) +{ + struct omap_i2c_dev *dev = dev_id; + unsigned long flags; u16 bits; u16 stat; int err = 0, count = 0; @@ -864,6 +886,7 @@ omap_i2c_isr(int this_irq, void *dev_id) if (pm_runtime_suspended(dev->dev)) return IRQ_HANDLED; + spin_lock_irqsave(&dev->lock, flags); do { bits = omap_i2c_read_reg(dev, OMAP_I2C_IE_REG); stat = omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG); @@ -877,6 +900,7 @@ omap_i2c_isr(int this_irq, void *dev_id) if (!stat) { /* my work here is done */ + spin_unlock_irqrestore(&dev->lock, flags); return IRQ_HANDLED; } @@ -985,6 +1009,8 @@ omap_i2c_isr(int this_irq, void *dev_id) out: omap_i2c_complete_cmd(dev, err); + spin_unlock_irqrestore(&dev->lock, flags); + return IRQ_HANDLED; } @@ -1028,7 +1054,6 @@ omap_i2c_probe(struct platform_device *pdev) struct omap_i2c_bus_platform_data *pdata = pdev->dev.platform_data; struct device_node *node = pdev->dev.of_node; const struct of_device_id *match; - irq_handler_t isr; int irq; int r; @@ -1078,6 +1103,8 @@ omap_i2c_probe(struct platform_device *pdev) dev->dev = &pdev->dev; dev->irq = irq; + spin_lock_init(&dev->lock); + platform_set_drvdata(pdev, dev); init_completion(&dev->cmd_complete); @@ -1130,10 +1157,13 @@ omap_i2c_probe(struct platform_device *pdev) /* reset ASAP, clearing any IRQs */ omap_i2c_init(dev); - isr = (dev->rev < OMAP_I2C_OMAP1_REV_2) ? omap_i2c_omap1_isr : - omap_i2c_isr; - r = devm_request_irq(&pdev->dev, dev->irq, isr, IRQF_NO_SUSPEND, - pdev->name, dev); + if (dev->rev < OMAP_I2C_OMAP1_REV_2) + r = devm_request_irq(&pdev->dev, dev->irq, omap_i2c_omap1_isr, + IRQF_NO_SUSPEND, pdev->name, dev); + else + r = devm_request_threaded_irq(&pdev->dev, dev->irq, omap_i2c_isr, + omap_i2c_isr_thread, IRQF_NO_SUSPEND | IRQF_ONESHOT, + pdev->name, dev); if (r) { dev_err(dev->dev, "failure requesting irq %i\n", dev->irq);