From patchwork Wed Oct 29 16:38:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 39789 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4D92724029 for ; Wed, 29 Oct 2014 16:38:53 +0000 (UTC) Received: by mail-la0-f72.google.com with SMTP id mc6sf1943377lab.3 for ; Wed, 29 Oct 2014 09:38:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=dsZzBxZ1i6mbqpLu1/etXb3FF+Xrt9HS8H8BBKKbxc8=; b=YwO1AUAv8+n8dOAF5VaHcfP2S0iq32h91wdzHvVmJBMKXaoafyeGB+ZBJpWo18c2lE VRAYbe4nWiUwzJI5oXNf2TDB+U/ggP00ymSL5AladlIEu19RdAHwW3g50xHnohYY3D/R ibHhqtqTF2X8Y4bt1F/JrA8QvLiJm9nlPVlQ23oan2XEFtWe1SdkvSBgTlZOdOD01yzS vtWVdHb6f6jdsbv7vX9kJwylrGPnywDcyUK+kaykegH0JzRoD5YRZ22ZuY6S63HkS7gY I/j1KVm5ja9qeZcCx7dB5ixH0lB3/h35YTU3bQInFKyY2BUyGHcVK6aql7PeSm5t+wEr IEEA== X-Gm-Message-State: ALoCoQleLguYvGULBR5+vOPyYCZ0y7te9m6Pjj2qx702IbpviotvRQ7n/2Akm0hNTZGss9AJ2jjp X-Received: by 10.152.25.202 with SMTP id e10mr1948416lag.2.1414600732124; Wed, 29 Oct 2014 09:38:52 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.198.201 with SMTP id je9ls240056lac.92.gmail; Wed, 29 Oct 2014 09:38:52 -0700 (PDT) X-Received: by 10.152.121.68 with SMTP id li4mr12319974lab.77.1414600731984; Wed, 29 Oct 2014 09:38:51 -0700 (PDT) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id bk5si7915476lbb.109.2014.10.29.09.38.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 Oct 2014 09:38:51 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by mail-la0-f52.google.com with SMTP id pv20so1072030lab.11 for ; Wed, 29 Oct 2014 09:38:51 -0700 (PDT) X-Received: by 10.152.116.102 with SMTP id jv6mr12646432lab.40.1414600731652; Wed, 29 Oct 2014 09:38:51 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.84.229 with SMTP id c5csp693016lbz; Wed, 29 Oct 2014 09:38:50 -0700 (PDT) X-Received: by 10.194.60.109 with SMTP id g13mr13038368wjr.109.1414600730752; Wed, 29 Oct 2014 09:38:50 -0700 (PDT) Received: from mail-wi0-f173.google.com (mail-wi0-f173.google.com. [209.85.212.173]) by mx.google.com with ESMTPS id ek9si7178255wib.50.2014.10.29.09.38.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 Oct 2014 09:38:50 -0700 (PDT) Received-SPF: pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.212.173 as permitted sender) client-ip=209.85.212.173; Received: by mail-wi0-f173.google.com with SMTP id n3so2225561wiv.6 for ; Wed, 29 Oct 2014 09:38:50 -0700 (PDT) X-Received: by 10.194.235.132 with SMTP id um4mr13597703wjc.91.1414600730505; Wed, 29 Oct 2014 09:38:50 -0700 (PDT) Received: from sundance.lan (cpc4-aztw19-0-0-cust157.18-1.cable.virginm.net. [82.33.25.158]) by mx.google.com with ESMTPSA id s8sm5745523wjx.9.2014.10.29.09.38.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Oct 2014 09:38:49 -0700 (PDT) From: Daniel Thompson To: Greg Kroah-Hartman Cc: Daniel Thompson , David Brown , Daniel Walker , Bryan Huntsman , Jiri Slaby , linux-arm-msm@vger.kernel.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, patches@linaro.org, linaro-kernel@lists.linaro.org, John Stultz , Sumit Semwal Subject: [PATCH] serial: msm: Add magic SysRq support in dmmode Date: Wed, 29 Oct 2014 16:38:32 +0000 Message-Id: <1414600712-20721-1-git-send-email-daniel.thompson@linaro.org> X-Mailer: git-send-email 1.9.3 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: daniel.thompson@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Currently the _dm RX handler detects breaks but does not pass any characters to uart_handle_sysrq_char(). The _dm optimizations combined with the port's spin lock make if difficult to pass all characters to the sysrq logic because we cannot safely call uart_handle_sysrq_char() when the lock is held without deadlock (the console handler also takes the lock). Rather than passing all characters via uart_handle_sysrq_char() this patch only passes the last few characters in the FIFO. This should include all characters typed as a slow (human) rate. This makes the problem much simpler and allows us to move the handling of these characters outside of the port lock. This makes magic SysRq work if there is a human at the keyboard (or a short delay in a script). Signed-off-by: Daniel Thompson --- drivers/tty/serial/msm_serial.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) -- 1.9.3 diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c index 4b6c783..24c4fd1 100644 --- a/drivers/tty/serial/msm_serial.c +++ b/drivers/tty/serial/msm_serial.c @@ -104,6 +104,7 @@ static void handle_rx_dm(struct uart_port *port, unsigned int misr) unsigned int sr; int count = 0; struct msm_port *msm_port = UART_TO_MSM(port); + unsigned char buf[4]; if ((msm_read(port, UART_SR) & UART_SR_OVERRUN)) { port->icount.overrun++; @@ -125,11 +126,10 @@ static void handle_rx_dm(struct uart_port *port, unsigned int misr) port->icount.rx += count; while (count > 0) { - unsigned char buf[4]; - sr = msm_read(port, UART_SR); if ((sr & UART_SR_RX_READY) == 0) { msm_port->old_snap_state -= count; + count = 0; break; } ioread32_rep(port->membase + UARTDM_RF, buf, 1); @@ -140,13 +140,33 @@ static void handle_rx_dm(struct uart_port *port, unsigned int misr) } else if (sr & UART_SR_PAR_FRAME_ERR) port->icount.frame++; - /* TODO: handle sysrq */ + /* The last few characters receive special processing below. */ + if (count <= 2) + break; + tty_insert_flip_string(tport, buf, min(count, 4)); count -= 4; } spin_unlock(&port->lock); + + /* + * We have deferred the last few characters to be processed + * with the port unlocked. This allows all characters received at + * "human speed" to be passed through the magic SysRq handling. + * The hardware sends us two characters after a break (the second + * of which is \0) so we are forced to process up to two final + * characters rather than just one. + */ + if (count > 0) { + if (!uart_handle_sysrq_char(port, buf[0])) + tty_insert_flip_string(tport, buf, count); + else if (count > 1 && !uart_handle_sysrq_char(port, buf[1])) + tty_insert_flip_char(tport, buf[1], 0); + } + tty_flip_buffer_push(tport); + spin_lock(&port->lock); if (misr & (UART_IMR_RXSTALE))