From patchwork Mon Mar 16 16:19:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Kaneko X-Patchwork-Id: 6022851 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 3A36F9F2A9 for ; Mon, 16 Mar 2015 16:19:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 34BFA201F2 for ; Mon, 16 Mar 2015 16:19:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EEA0C202EC for ; Mon, 16 Mar 2015 16:19:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933182AbbCPQTx (ORCPT ); Mon, 16 Mar 2015 12:19:53 -0400 Received: from mail-pa0-f52.google.com ([209.85.220.52]:35747 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933194AbbCPQTw (ORCPT ); Mon, 16 Mar 2015 12:19:52 -0400 Received: by pabyw6 with SMTP id yw6so69108786pab.2; Mon, 16 Mar 2015 09:19:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=kNWlkC5r8n6kKdyNya8gZTmQ4HvskPNU5l93qACOVdQ=; b=En0ATgrfyyb+CEQxq5iwURQWD68azIygqMa2Wox2TkpBncdBfDDKxwO63z7ILYS8Vt 8ZeQenY2UEaS3EhXq2l0vv/WveBBmfJQC+fH53n9tMvgAcEtUSLiz2vdqBLtxNVfNzGr 0d8UozAc9jEXq+6zNBh2pzRfRPT92RNzPgzd/KDoX8LT1e+mVO1/bBc5arOIqBu5T62c tUEOMjmQc5X/CDlncbbdj+SHAU/a18TbwE8fJ+DgSUMsbmMf+mX9Oqa+TnsZRenekSze L1M4wqjjYQa8AQKPtnI/7HmdhPAELwjGiDojBFKGJiB8vH3gRZfb3Fd8uyquxOBl1bzd bvGw== X-Received: by 10.70.65.105 with SMTP id w9mr80510248pds.129.1426522791380; Mon, 16 Mar 2015 09:19:51 -0700 (PDT) Received: from localhost.localdomain (KD118152108246.ppp-bb.dion.ne.jp. [118.152.108.246]) by mx.google.com with ESMTPSA id c16sm18036080pdk.94.2015.03.16.09.19.49 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 Mar 2015 09:19:50 -0700 (PDT) From: Yoshihiro Kaneko To: linux-serial@vger.kernel.org Cc: Greg Kroah-Hartman , Simon Horman , Magnus Damm , linux-sh@vger.kernel.org Subject: [PATCH v2] serial: sh-sci: Add overrun handling of SCIFA and SCIFB Date: Tue, 17 Mar 2015 01:19:19 +0900 Message-Id: <1426522759-25802-1-git-send-email-ykaneko0929@gmail.com> X-Mailer: git-send-email 1.9.1 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.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, 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 From: Nobuhiro Iwamatsu 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 Signed-off-by: Yoshihiro Kaneko --- This patch is based on the tty-next branch of Greg Kroah-Hartman's tty tree. v2 [Yoshihiro Kaneko] * use the switch statement instead of a verbose if statement. drivers/tty/serial/sh-sci.c | 48 +++++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index 5b50c79..5bf9972 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -844,14 +844,32 @@ 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; - reg = sci_getreg(port, SCLSR); + switch (port->type) { + case PORT_SCIF: + case PORT_HSCIF: + offset = SCLSR; + break; + case PORT_SCIFA: + case PORT_SCIFB: + offset = SCxSR; + break; + default: + return 0; + } + + 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,16 +1014,24 @@ 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 slr_status = 0; + unsigned short ssr_status, scr_status, err_enabled, orer_status = 0; struct uart_port *port = ptr; struct sci_port *s = to_sci_port(port); irqreturn_t ret = IRQ_NONE; 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); + switch (port->type) { + case PORT_SCIF: + case PORT_HSCIF: + orer_status = serial_port_in(port, SCLSR); + break; + case PORT_SCIFA: + case PORT_SCIFB: + orer_status = ssr_status; + break; + } + err_enabled = scr_status & port_rx_irq_mask(port); /* Tx Interrupt */ @@ -1033,10 +1059,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; }