From patchwork Fri Aug 8 20:39:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Murali Karicheri X-Patchwork-Id: 35168 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f72.google.com (mail-pa0-f72.google.com [209.85.220.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3D55321457 for ; Fri, 8 Aug 2014 20:39:13 +0000 (UTC) Received: by mail-pa0-f72.google.com with SMTP id eu11sf39525002pac.3 for ; Fri, 08 Aug 2014 13:39:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :mime-version:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe:content-type; bh=pS+ceAHze3HFktUVzfN7VpDKrFjkDUbGInGNN+Ibf5I=; b=mWtA/NkaQSFIs4NFVID75Xp6aGcU78WJQR3IzCvjyh8ptBe3UO1AYPofPVB+f8Xuie vCnxOmzd5UyrSSHEoBNzt80v7P+17+36FgNJ4etfEso+Ja2SOja2ulrmAhFqLDPNF+uv OgZfG1BoJkYR74hfj8AiAFGuotKlfjgGjxxIIa7pnSECaq2rEbq6/uwdyapOr2ZvCUiG DLv8qvoMZ+Yzk4lIvpVf2lst88pToPwR80VYPLKc9gSYCg5yhuvc420i5U9qF2zzMIzN 0NBMfOAXImm/00nDZhzSg5VADf2p4awGNKIyymFt1/l/XagQqd1ZGkFClsCj/po+ZzSU YzzA== X-Gm-Message-State: ALoCoQncvnPtgD8baVWIqOH8Fr+Wtp2m87VhD5ja3o/Bbim+mvfZMh8lB+PVyaRYbUgpOkm/Jme6 X-Received: by 10.66.90.193 with SMTP id by1mr13754987pab.30.1407530352470; Fri, 08 Aug 2014 13:39:12 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.105.4 with SMTP id b4ls679580qgf.38.gmail; Fri, 08 Aug 2014 13:39:12 -0700 (PDT) X-Received: by 10.221.24.7 with SMTP id rc7mr2514265vcb.54.1407530352245; Fri, 08 Aug 2014 13:39:12 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id hw3si3257638vdb.67.2014.08.08.13.39.12 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 08 Aug 2014 13:39:12 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id ik5so8962031vcb.20 for ; Fri, 08 Aug 2014 13:39:12 -0700 (PDT) X-Received: by 10.52.232.200 with SMTP id tq8mr8334182vdc.32.1407530352151; Fri, 08 Aug 2014 13:39:12 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp152061vcb; Fri, 8 Aug 2014 13:39:11 -0700 (PDT) X-Received: by 10.70.93.42 with SMTP id cr10mr26627078pdb.42.1407530351201; Fri, 08 Aug 2014 13:39:11 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gz1si6887547pbd.106.2014.08.08.13.39.10 for ; Fri, 08 Aug 2014 13:39:11 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752003AbaHHUjJ (ORCPT + 26 others); Fri, 8 Aug 2014 16:39:09 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:55296 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751041AbaHHUjE (ORCPT ); Fri, 8 Aug 2014 16:39:04 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id s78Kd2mh014683; Fri, 8 Aug 2014 15:39:02 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s78Kd1I2007041; Fri, 8 Aug 2014 15:39:02 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.174.1; Fri, 8 Aug 2014 15:39:01 -0500 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s78Kd1cC014133; Fri, 8 Aug 2014 15:39:01 -0500 From: Murali Karicheri To: , , , CC: Murali Karicheri Subject: [RFC PATCH] serial: uart: update to support hw assisted hw flow control Date: Fri, 8 Aug 2014 16:39:12 -0400 Message-ID: <1407530352-6937-1-git-send-email-m-karicheri2@ti.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: m-karicheri2@ti.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , commit 06aa82e498c144c7784a6f3d3b55458b272d6146 serial: uart: add hw flow control support configuration partially support hw assisted hw flow control but requires implementation of throttle()/unthrottle() API as well. Also uart_handle_cts_change() is not expected to be called with hardware flow control enabled. So add WARN_ON_ONCE() to flag any misbehaving AFE supported 8250 device. Only limited testing is done on this patch. Need to get initial feedback on this. Will test and send the final patch based on the feedback and test result. Signed-off-by: Murali Karicheri --- This is a follow up patch to the discussion against the patch "serial: uart: add hw flow control support configuration" drivers/tty/serial/8250/8250_core.c | 26 ++++++++++++++++++++++++++ drivers/tty/serial/serial_core.c | 6 ++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c index 27f7ad6..8fcd218 100644 --- a/drivers/tty/serial/8250/8250_core.c +++ b/drivers/tty/serial/8250/8250_core.c @@ -1841,6 +1841,30 @@ static void serial8250_set_mctrl(struct uart_port *port, unsigned int mctrl) serial_port_out(port, UART_MCR, mcr); } +static void serial8250_throttle(struct uart_port *port) +{ + struct uart_8250_port *up = + container_of(port, struct uart_8250_port, port); + unsigned long flags; + + spin_lock_irqsave(&up->port.lock, flags); + up->ier &= ~(UART_IER_RLSI | UART_IER_RDI); + serial_out(up, UART_IER, up->ier); + spin_unlock_irqrestore(&up->port.lock, flags); +} + +static void serial8250_unthrottle(struct uart_port *port) +{ + struct uart_8250_port *up = + container_of(port, struct uart_8250_port, port); + unsigned long flags; + + spin_lock_irqsave(&up->port.lock, flags); + up->ier |= UART_IER_RLSI | UART_IER_RDI; + serial_out(up, UART_IER, up->ier); + spin_unlock_irqrestore(&up->port.lock, flags); +} + static void serial8250_break_ctl(struct uart_port *port, int break_state) { struct uart_8250_port *up = @@ -2732,6 +2756,8 @@ static struct uart_ops serial8250_pops = { .tx_empty = serial8250_tx_empty, .set_mctrl = serial8250_set_mctrl, .get_mctrl = serial8250_get_mctrl, + .throttle = serial8250_throttle, + .unthrottle = serial8250_unthrottle, .stop_tx = serial8250_stop_tx, .start_tx = serial8250_start_tx, .stop_rx = serial8250_stop_rx, diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index fbf6c5a..f2dc7f7 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -2779,9 +2779,11 @@ void uart_handle_cts_change(struct uart_port *uport, unsigned int status) uport->icount.cts++; + /* Not expected to be called if h/w flow control is enabled */ + WARN_ON_ONCE(uport->flags & UPF_HARD_FLOW); + /* skip below code if the hw flow control is supported */ - if (tty_port_cts_enabled(port) && - !(uport->flags & UPF_HARD_FLOW)) { + if (tty_port_cts_enabled(port)) { if (tty->hw_stopped) { if (status) { tty->hw_stopped = 0;