From patchwork Fri Aug 22 14:02:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frans Klaver X-Patchwork-Id: 4764591 Return-Path: X-Original-To: patchwork-linux-omap@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 1A5199F2E8 for ; Fri, 22 Aug 2014 14:03:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7A9AA2018E for ; Fri, 22 Aug 2014 14:03:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 550EE20172 for ; Fri, 22 Aug 2014 14:03:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932472AbaHVODJ (ORCPT ); Fri, 22 Aug 2014 10:03:09 -0400 Received: from filter1.ibarracuda.nl ([83.247.7.10]:53116 "EHLO filter1.ibarracuda.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932473AbaHVODF (ORCPT ); Fri, 22 Aug 2014 10:03:05 -0400 X-ASG-Debug-ID: 1408716182-0759e7416b4f6eff0002-g9IbbW Received: from XSMCASSVR01.xsens-tech.local (rev-215.116.249.87.virtu.nl [87.249.116.215]) by filter1.ibarracuda.nl with ESMTP id PDvfxhsix9M2gOSy (version=TLSv1 cipher=AES128-SHA bits=128 verify=NO); Fri, 22 Aug 2014 16:03:02 +0200 (CEST) X-Barracuda-Envelope-From: Frans.Klaver@xsens.com X-Barracuda-AUTH-User: xsenscom X-Barracuda-Apparent-Source-IP: 87.249.116.215 Received: from ci00147.xsens-tech.local (172.16.11.49) by XSMCASSVR01.xsens-tech.local (192.168.0.248) with Microsoft SMTP Server id 14.3.195.1; Fri, 22 Aug 2014 16:03:02 +0200 From: Frans Klaver To: Felipe Balbi CC: Frans Klaver , Tony Lindgren , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , Greg Kroah-Hartman , Alexey Pelykh , Jiri Slaby , Frans Klaver , , , , , Subject: [RFC PATCH 3/4] tty: omap-serial: use threaded interrupt handler Date: Fri, 22 Aug 2014 16:02:50 +0200 X-ASG-Orig-Subj: [RFC PATCH 3/4] tty: omap-serial: use threaded interrupt handler Message-ID: <1408716170-543-1-git-send-email-frans.klaver@xsens.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <20140819185701.GC22003@saruman.home> References: <20140819185701.GC22003@saruman.home> MIME-Version: 1.0 X-Originating-IP: [172.16.11.49] X-Barracuda-Connect: rev-215.116.249.87.virtu.nl[87.249.116.215] X-Barracuda-Start-Time: 1408716182 X-Barracuda-Encrypted: AES128-SHA X-Barracuda-URL: http://filter1.ibarracuda.nl:8000/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at ibarracuda.nl X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using per-user scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=5.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.8722 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 At 3.6Mbaud, with slightly over 2Mbit/s data coming in, we see 1600 uart rx buffer overflows within 30 seconds. Threading the interrupt handling reduces this to about 170 overflows in 10 minutes. In practice this therefore reduces the need for hardware flow control, meaning the sending side doesn't have to buffer as much either. Signed-off-by: Frans Klaver --- drivers/tty/serial/omap-serial.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c index 14a0167..1671443a 100644 --- a/drivers/tty/serial/omap-serial.c +++ b/drivers/tty/serial/omap-serial.c @@ -575,6 +575,20 @@ static void serial_omap_rdi(struct uart_omap_port *up, unsigned int lsr) } /** + * serial_omap_fast_irq() - schedule interrupt handling + */ +static irqreturn_t serial_omap_fast_irq(int irq, void *dev_id) +{ + struct uart_omap_port *up = dev_id; + unsigned int iir = serial_in(up, UART_IIR); + + if (iir & UART_IIR_NO_INT) + return IRQ_NONE; + + return IRQ_WAKE_THREAD; +} + +/** * serial_omap_irq() - This handles the interrupt from one port * @irq: uart port irq number * @dev_id: uart port info @@ -584,7 +598,6 @@ static irqreturn_t serial_omap_irq(int irq, void *dev_id) struct uart_omap_port *up = dev_id; unsigned int iir, lsr; unsigned int type; - irqreturn_t ret = IRQ_NONE; int max_count = 256; spin_lock(&up->port.lock); @@ -595,7 +608,6 @@ static irqreturn_t serial_omap_irq(int irq, void *dev_id) if (iir & UART_IIR_NO_INT) break; - ret = IRQ_HANDLED; lsr = serial_in(up, UART_LSR); /* extract IRQ type from IIR register */ @@ -634,7 +646,7 @@ static irqreturn_t serial_omap_irq(int irq, void *dev_id) pm_runtime_put_autosuspend(up->dev); up->port_activity = jiffies; - return ret; + return IRQ_HANDLED; } static unsigned int serial_omap_tx_empty(struct uart_port *port) @@ -731,15 +743,19 @@ static int serial_omap_startup(struct uart_port *port) /* * Allocate the IRQ */ - retval = request_irq(up->port.irq, serial_omap_irq, up->port.irqflags, - up->name, up); + retval = request_threaded_irq(up->port.irq, serial_omap_fast_irq, + serial_omap_irq, + IRQF_ONESHOT | up->port.irqflags, + up->name, up); if (retval) return retval; /* Optional wake-up IRQ */ if (up->wakeirq) { - retval = request_irq(up->wakeirq, serial_omap_irq, - up->port.irqflags, up->name, up); + retval = request_threaded_irq(up->wakeirq, serial_omap_fast_irq, + serial_omap_irq, + IRQF_ONESHOT | up->port.irqflags, + up->name, up); if (retval) { free_irq(up->port.irq, up); return retval;