From patchwork Sun Mar 15 14:28:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Kaneko X-Patchwork-Id: 6013091 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 B8B9C9F318 for ; Sun, 15 Mar 2015 14:28:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C43DB2024C for ; Sun, 15 Mar 2015 14:28:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A82B32022A for ; Sun, 15 Mar 2015 14:28:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752737AbbCOO2v (ORCPT ); Sun, 15 Mar 2015 10:28:51 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:33285 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752232AbbCOO2u (ORCPT ); Sun, 15 Mar 2015 10:28:50 -0400 Received: by pagr17 with SMTP id r17so37866298pag.0; Sun, 15 Mar 2015 07:28:50 -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=i2h4jOYgfL6ob6M54Z/d4K+q8lKootL9F3LDvVL+n1g=; b=XHRNcFlMhcGftmEDuWGtlMJr4GeVap9rkySAFijWgNpgZ9b8mx1cRpuuUUVzoXuuTH ac44f/DzzSVrlVILGoW0WE4tKCNnP7QDD9MoGHlGFrZnqqrxvDB37CPXMr4FNCcmoRrk 7NxzN+ddz/lqpuqo4SSPUnghGX/6WKm5Bwd4AOC2cjeVUe4IWXtnhS+k4yAhsO92X4Ng XdUjms3kRI3jKYpvAm35Dy7t8S1+klAIzyxVdDp59ikdkqnBvUKuEMcWEj27WDerP81r PUZj1EEdIwdoF634dxw6RA/3oRRVfeDxw+VaX2kC7aEsGouvkYaCzpaRis1gn36qxLSX e0CQ== X-Received: by 10.70.119.3 with SMTP id kq3mr126863884pdb.85.1426429730264; Sun, 15 Mar 2015 07:28:50 -0700 (PDT) Received: from localhost.localdomain (KD118152108246.ppp-bb.dion.ne.jp. [118.152.108.246]) by mx.google.com with ESMTPSA id n10sm12672862pdp.18.2015.03.15.07.28.48 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 15 Mar 2015 07:28:49 -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/RFC] serial: sh-sci: Add overrun handling of SCIFA and SCIFB Date: Sun, 15 Mar 2015 23:28:15 +0900 Message-Id: <1426429695-2993-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. drivers/tty/serial/sh-sci.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index 5b50c79..d165b21 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,8 +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 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; @@ -1005,7 +1016,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 +1047,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; }