From patchwork Tue Aug 5 01:03:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 4674071 Return-Path: X-Original-To: patchwork-linux-arm-msm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 39E6AC0338 for ; Tue, 5 Aug 2014 01:03:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2FC872013D for ; Tue, 5 Aug 2014 01:03:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DA5602013A for ; Tue, 5 Aug 2014 01:03:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753152AbaHEBDJ (ORCPT ); Mon, 4 Aug 2014 21:03:09 -0400 Received: from mail-pd0-f169.google.com ([209.85.192.169]:38302 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752354AbaHEBDI (ORCPT ); Mon, 4 Aug 2014 21:03:08 -0400 Received: by mail-pd0-f169.google.com with SMTP id y10so303890pdj.0 for ; Mon, 04 Aug 2014 18:03:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:reply-to:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=9dsucyitGN2SYBD/02DAjxkP0ktwR9SUwoLf5u6JmI8=; b=DrBCd5cShPIeDNJY5EEOUph9SSq7f38+74s+HCuIlBAZgdDYF1cP4hv/i0XQByy15S UEfcjEeieg4fN+KMJsJHsIP7BLpLnb0oBgOmvTZDHN3al/oDonGqtrACB+hBCkQtgeE4 ImmbSfIUdC21cdE4H2wnlq+T+ZC9tbwDjy2F95UjC99cHjTZCZsMblALl4ZJWze2dxk1 r5Y0uBoRtVAwjuhqVrYUFTUC9gf/HHQY7imrOBDhd3Fqns86uIjiSUTEMXUNrBnfXHxW PbNkEV2rmGvq1R7DVY4rs0LWQ081XQx9PVHmW2d8/hT44Aah+6NfhAUehJ+Md7ic1yA4 wD1A== X-Received: by 10.68.69.46 with SMTP id b14mr442440pbu.70.1407200587519; Mon, 04 Aug 2014 18:03:07 -0700 (PDT) Received: from [172.26.79.116] ([64.211.224.253]) by mx.google.com with ESMTPSA id xo10sm106683pbc.36.2014.08.04.18.03.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 04 Aug 2014 18:03:06 -0700 (PDT) Message-ID: <53E02D48.1080002@gmail.com> Date: Mon, 04 Aug 2014 18:03:04 -0700 From: Frank Rowand Reply-To: frowand.list@gmail.com User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: Stephen Boyd CC: David Brown , Daniel Walker , Bryan Huntsman , Greg Kroah-Hartman , Jiri Slaby , "linux-arm-msm@vger.kernel.org" , linux-serial@vger.kernel.org, Linux Kernel list , Jason Wessel , kgdb-bugreport@lists.sourceforge.net Subject: [test patch 1/4] fix msm_serial for kgdb References: <53E02C7C.4090206@gmail.com> In-Reply-To: <53E02C7C.4090206@gmail.com> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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: Frank Rowand f7e54d7ad743 added support for poll_{get,put}_char() Additional fixes to cope with single character mode on RX FIFO for qcom,msm-uartdm-v1.4. With these fixes, kgdb properly communicates with the dragon board, but following the continue command, the serial driver does not get any stale (UART_IMR_RXSTALE) interrupts until 48 characters have been read, which triggers a high water interrupt. After the high water interrupt has been processed, the driver resumes properly getting stale interrupts. Not-signed-off-by-yet: Frank Rowand --- drivers/tty/serial/msm_serial.c | 74 ++++++++++++++++++++++++++++++++-------- 1 file changed, 61 insertions(+), 13 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: b/drivers/tty/serial/msm_serial.c =================================================================== --- a/drivers/tty/serial/msm_serial.c +++ b/drivers/tty/serial/msm_serial.c @@ -54,6 +54,7 @@ struct msm_port { unsigned int imr; void __iomem *gsbi_base; int is_uartdm; + int rx_sc_enabled; unsigned int old_snap_state; }; @@ -104,7 +105,10 @@ static void handle_rx_dm(struct uart_por struct tty_port *tport = &port->state->port; unsigned int sr; int count = 0; + int imr_rx_stale = misr & UART_IMR_RXSTALE; struct msm_port *msm_port = UART_TO_MSM(port); + int res; + char *cp; if ((msm_read(port, UART_SR) & UART_SR_OVERRUN)) { port->icount.overrun++; @@ -112,12 +116,14 @@ static void handle_rx_dm(struct uart_por msm_write(port, UART_CR_CMD_RESET_ERR, UART_CR); } - if (misr & UART_IMR_RXSTALE) { + if (imr_rx_stale) { count = msm_read(port, UARTDM_RX_TOTAL_SNAP) - msm_port->old_snap_state; msm_port->old_snap_state = 0; } else { - count = 4 * (msm_read(port, UART_RFWR)); + count = msm_read(port, UART_RFWR); + if (!msm_port->rx_sc_enabled) + count = 4 * count; msm_port->old_snap_state += count; } @@ -130,28 +136,60 @@ static void handle_rx_dm(struct uart_por sr = msm_read(port, UART_SR); if ((sr & UART_SR_RX_READY) == 0) { - msm_port->old_snap_state -= count; + if (!imr_rx_stale) + msm_port->old_snap_state -= count; break; } + c = msm_read(port, UARTDM_RF); + if (sr & UART_SR_RX_BREAK) { port->icount.brk++; - if (uart_handle_break(port)) - continue; + uart_handle_break(port); + if (msm_port->rx_sc_enabled) + count -= 1; + else + count -= 4; + continue; } else if (sr & UART_SR_PAR_FRAME_ERR) port->icount.frame++; - /* TODO: handle sysrq */ - tty_insert_flip_string(tport, (char *)&c, - (count > 4) ? 4 : count); - count -= 4; + if (msm_port->rx_sc_enabled) { + cp = (char *)&c; + + spin_unlock(&port->lock); + res = uart_handle_sysrq_char(port, *cp); + spin_lock(&port->lock); + + if (!res) + tty_insert_flip_string(tport, cp, 1); + count -= 1; + } else { + cp = (char *)&c; + + spin_unlock(&port->lock); + res = uart_handle_sysrq_char(port, *cp); + spin_lock(&port->lock); + + if (res) { + count -= 1; + cp++; + tty_insert_flip_string(tport, cp, + (count > 3) ? 3 : count); + count -= 3; + } else { + tty_insert_flip_string(tport, cp, + (count > 4) ? 4 : count); + count -= 4; + } + } } spin_unlock(&port->lock); tty_flip_buffer_push(tport); spin_lock(&port->lock); - if (misr & (UART_IMR_RXSTALE)) + if (imr_rx_stale) msm_write(port, UART_CR_CMD_RESET_STALE_INT, UART_CR); msm_write(port, 0xFFFFFF, UARTDM_DMRX); msm_write(port, UART_CR_CMD_STALE_EVENT_ENABLE, UART_CR); @@ -413,8 +451,11 @@ static int msm_set_baud_rate(struct uart watermark |= UART_IPR_STALE_TIMEOUT_MSB & (rxstale << 2); msm_write(port, watermark, UART_IPR); - /* set RX watermark */ - watermark = (port->fifosize * 3) / 4; + /* set RX watermark (number of words) */ + if (msm_port->rx_sc_enabled) + watermark = (port->fifosize * 3) / 4; /* 1 byte per word */ + else + watermark = (port->fifosize * 3) / 16; /* 4 bytes per word */ msm_write(port, watermark, UART_RFWR); /* set TX watermark */ @@ -728,10 +769,17 @@ static void msm_power(struct uart_port * static int msm_poll_init(struct uart_port *port) { struct msm_port *msm_port = UART_TO_MSM(port); + unsigned int watermark; /* Enable single character mode on RX FIFO */ - if (msm_port->is_uartdm >= UARTDM_1P4) + if (msm_port->is_uartdm >= UARTDM_1P4) { msm_write(port, UARTDM_DMEN_RX_SC_ENABLE, UARTDM_DMEN); + msm_port->rx_sc_enabled = 1; + } + + /* set RX watermark (number of words) */ + watermark = (port->fifosize * 3) / 4; /* 1 byte per word */ + msm_write(port, watermark, UART_RFWR); return 0; }