From patchwork Wed Mar 25 07:00:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nobuhiro Iwamatsu X-Patchwork-Id: 6088841 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E159D9F350 for ; Wed, 25 Mar 2015 07:00:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EE2B920251 for ; Wed, 25 Mar 2015 07:00:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B8406201B9 for ; Wed, 25 Mar 2015 07:00:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751220AbbCYHAi (ORCPT ); Wed, 25 Mar 2015 03:00:38 -0400 Received: from mail-pa0-f54.google.com ([209.85.220.54]:34213 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750910AbbCYHAh (ORCPT ); Wed, 25 Mar 2015 03:00:37 -0400 Received: by pacwe9 with SMTP id we9so19298143pac.1 for ; Wed, 25 Mar 2015 00:00:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=mDPnwQyVYOsV1b439GdJddX/uke/QORdm9JJ/3Cvr/A=; b=kvBRjcvL3LqkhhdOrmhxQw6gqCfZJpkQclgBcWXzVh3RGsL/NMUvDmONuh3UxLzX/l K7BsVUWvYC7ChNUFzHYfPeFTQM7eSc79rvvXaHl65nxywKdRASzxBr/Ter5xfXI0l2mb Vfh1HpRczCVFAJ8cTBFq33/bMhjzGFeQ7emiJhrnemb9EWH31tKV/TnxQY8zdG0deXR8 hV5ZZl1WdGlZxcUIKNjNyQddcA180RitEtHsPzS5qexn5kX/+K9IhKdbg9Aw3VqxiauO jUziegUzkzcm2YSxbwkbkZiGkUM+PzD8npmvE5m3n49j9sLah6ps/+FAsgQb1OXHCptx KHTw== X-Gm-Message-State: ALoCoQkdSbFo+MTOsw5mA98w4OUUEXRoeogxfchfU2KrDhbPtL5DF4ZBHOlq7E7K9jyuWXee99D1 X-Received: by 10.66.193.72 with SMTP id hm8mr14522059pac.24.1427266836956; Wed, 25 Mar 2015 00:00:36 -0700 (PDT) Received: from xps-iwamatsu.renesas.com (49.14.32.202.bf.2iij.net. [202.32.14.49]) by mx.google.com with ESMTPSA id ji6sm1349696pac.30.2015.03.25.00.00.33 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Mar 2015 00:00:35 -0700 (PDT) From: Nobuhiro Iwamatsu To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-sh@vger.kernel.org, Nobuhiro Iwamatsu Subject: [PATCH] serial: sh-sci: Add overrun handling of SCIFA and SCIFB Date: Wed, 25 Mar 2015 16:00:18 +0900 Message-Id: <1427266818-10985-1-git-send-email-nobuhiro.iwamatsu.yj@renesas.com> X-Mailer: git-send-email 2.1.3 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 SCIFA and SCIFB can detect the overrun, but it does not support. This adds overrun handling of SCIFA and SCIFB. Signed-off-by: Nobuhiro Iwamatsu --- drivers/tty/serial/sh-sci.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index 5b50c79..0a78e1d 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -844,14 +844,26 @@ static int sci_handle_fifo_overrun(struct uart_port *port) struct tty_port *tport = &port->state->port; struct sci_port *s = to_sci_port(port); struct plat_sci_reg *reg; - int copied = 0; + int copied = 0, offset; + u16 status, bit; + + if (port->type == PORT_SCIF || port->type == PORT_HSCIF) + offset = SCLSR; + else if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) + offset = SCxSR; + else + return 0; - reg = sci_getreg(port, SCLSR); + reg = sci_getreg(port, offset); if (!reg->size) return 0; - if ((serial_port_in(port, SCLSR) & (1 << s->overrun_bit))) { - serial_port_out(port, SCLSR, 0); + status = serial_port_in(port, offset); + bit = 1 << s->overrun_bit; + + if (status & bit) { + status &= ~bit; + serial_port_out(port, offset, status); port->icount.overrun++; @@ -996,7 +1008,7 @@ static inline unsigned long port_rx_irq_mask(struct uart_port *port) static irqreturn_t sci_mpxed_interrupt(int irq, void *ptr) { - unsigned short ssr_status, scr_status, err_enabled; + unsigned short ssr_status, scr_status, err_enabled, orer_status = 0; unsigned short slr_status = 0; struct uart_port *port = ptr; struct sci_port *s = to_sci_port(port); @@ -1005,7 +1017,10 @@ static irqreturn_t sci_mpxed_interrupt(int irq, void *ptr) ssr_status = serial_port_in(port, SCxSR); scr_status = serial_port_in(port, SCSCR); if (port->type == PORT_SCIF || port->type == PORT_HSCIF) - slr_status = serial_port_in(port, SCLSR); + orer_status = serial_port_in(port, SCLSR); + else if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) + orer_status = ssr_status; + err_enabled = scr_status & port_rx_irq_mask(port); /* Tx Interrupt */ @@ -1033,10 +1048,8 @@ static irqreturn_t sci_mpxed_interrupt(int irq, void *ptr) ret = sci_br_interrupt(irq, ptr); /* Overrun Interrupt */ - if (port->type == PORT_SCIF || port->type == PORT_HSCIF) { - if (slr_status & 0x01) - sci_handle_fifo_overrun(port); - } + if (orer_status & (1 << s->overrun_bit)) + sci_handle_fifo_overrun(port); return ret; }