Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3025629imu; Thu, 29 Nov 2018 14:13:52 -0800 (PST) X-Google-Smtp-Source: AFSGD/XeOvWyR+Mw/qKnMGkBFxCuHRR0FhRBB/IgGcKcptM3R7n6Yzu1URKb489ZkZKc8GK4E4T8 X-Received: by 2002:a17:902:e08b:: with SMTP id cb11mr3219063plb.263.1543529632418; Thu, 29 Nov 2018 14:13:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543529632; cv=none; d=google.com; s=arc-20160816; b=ebwy37is+7PCVWi/XKTzIqYFcJn+dCYkDkmdNlvjB1uPCL9SB47KmQv9RpNSKDromx PGMwcmqjuW7eEDuIUy46ds5+Y2/v6E1rrHCCXV/yTl1c8sIeycESLEzk2ASXjKmTunwp fK2vAjKGoVNTPLdnQVNjAj9mx3pvOt7sNuoWgy4Ju2xRwqbtZY7UcLOxHfp69RpB0nyP cqA1akJQe0UqkMaGp8q3hoK00f/3KAZIPO6YumtlSZF9kjxca3H4jpTtAoI8n0P3ZYzP Ey/deh6P/mg+KkhGi+gvIIlnDb+vOoIZEqGrppMU9eqEyasE2bZzGfKX8157FkTmYj12 eMag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=UlF+FE3QTGVYbK2iC+cpaRNKT7/QyQS/1YiJabKOFRs=; b=opa7uB46c+7XMQytFXOI+HWMFxn0Y1bzIGfXxz0ACZM1D1FBEq1Nj37tysSeQdsMr2 7/d13ijCkbupiz1rk7ivo2DUmth+x+KGcEQIx118+odA41OdcrIlKcB0myR73twsIhK0 UiL5vz3uVv2UVOStjhN9PMDEMiuWxHfuSAwqgNxdJAW1t6W67wzIBS0Bojcsg0d7fdNJ 6CGccCKEV5RYGqN9r1gOTDxobql7eC1jZnyyZ61rdLbvjc0RJAE5S1P5ZX58V+sdbZIj mJj2gm4nmbTZn7WQWQocpH4l9ezqqyUY/smUEiCTXZepjX4FCHi4MMUDmukTHlLqUGz6 eu3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=noOOovSe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l6si2990676pgg.592.2018.11.29.14.13.36; Thu, 29 Nov 2018 14:13:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=noOOovSe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726403AbeK3JTn (ORCPT + 99 others); Fri, 30 Nov 2018 04:19:43 -0500 Received: from mail-ua1-f66.google.com ([209.85.222.66]:46093 "EHLO mail-ua1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726344AbeK3JTn (ORCPT ); Fri, 30 Nov 2018 04:19:43 -0500 Received: by mail-ua1-f66.google.com with SMTP id v24so1200262uap.13 for ; Thu, 29 Nov 2018 14:12:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=UlF+FE3QTGVYbK2iC+cpaRNKT7/QyQS/1YiJabKOFRs=; b=noOOovSe1gq4q2eHcmzs6TxxTLYPpiY+FXNs2polTgVXBV77qwAig7HdYZI2F2kTm0 qgfceP61Gs8foh+GBfwBEMRctPGCnVoXyL8WUSVjtpHdAvHoFW4mhFLuu7bz/tKBClF+ V/b8r1w2xqhoENP2IxK5740k1jlQaQD2rW9/s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=UlF+FE3QTGVYbK2iC+cpaRNKT7/QyQS/1YiJabKOFRs=; b=IH8O46wAtQA8jTNMa/3+XJwm1nYCijum7Ikt7LZnFQRzVQKaXCa2w7WZMlsAsjuTk4 92EnF0yBjJr7RVS9zdFHFiujnkKqs2ZLGh/49Mj5S8zUcAJJFoiKMhNC5zwy3axQ048S uqg8C4zgbuftpG+CtKwKHjo7wN1ikaT+2WGVkRXCnaG57/YeQ39a5AqRdFjf33/HmNe7 jUTTu7GCkpS3x+8XiB/z4Yn9g3twwqrE+g5KUa4lNEStFEbmZcQdmC83io4rzDqc9NSq Bo817UoqXEWevUxAO8ZzL1PYClRT2xo3P9YYjxY2B6vRLfK4vwntSygHrq3A0mIT0nAU n0XQ== X-Gm-Message-State: AA+aEWa7s0h7qR1FQXEbFrINBxE828cdR/2T1V63MW2zvTqUSKACL6vX B4a+2zm51PQb3/j3juX4b4lW9CXhxM8= X-Received: by 2002:a9f:3703:: with SMTP id z3mr1477840uad.86.1543529564494; Thu, 29 Nov 2018 14:12:44 -0800 (PST) Received: from mail-ua1-f47.google.com (mail-ua1-f47.google.com. [209.85.222.47]) by smtp.gmail.com with ESMTPSA id 2sm875781vsd.13.2018.11.29.14.12.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 14:12:44 -0800 (PST) Received: by mail-ua1-f47.google.com with SMTP id n7so1209244uao.7 for ; Thu, 29 Nov 2018 14:12:43 -0800 (PST) X-Received: by 2002:ab0:1c12:: with SMTP id a18mr1380356uaj.15.1543529562133; Thu, 29 Nov 2018 14:12:42 -0800 (PST) MIME-Version: 1.0 References: <20181128235459.180940-1-ryandcase@chromium.org> In-Reply-To: <20181128235459.180940-1-ryandcase@chromium.org> From: Doug Anderson Date: Thu, 29 Nov 2018 14:12:30 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] tty: serial: qcom_geni_serial: Fix softlock To: ryandcase@chromium.org Cc: Greg Kroah-Hartman , Jiri Slaby , Evan Green , LKML , linux-serial@vger.kernel.org, Stephen Boyd Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Wed, Nov 28, 2018 at 3:55 PM Ryan Case wrote: > @@ -465,9 +470,19 @@ static void qcom_geni_serial_console_write(struct console *co, const char *s, > } > writel_relaxed(M_CMD_CANCEL_EN, uport->membase + > SE_GENI_M_IRQ_CLEAR); > + } else if ((geni_status & M_GENI_CMD_ACTIVE) && !port->tx_remaining) { > + /* > + * It seems we can interrupt existing transfers unless all data s/It seems we can interrupt/It seems we can't interrupt/ > +static void qcom_geni_serial_handle_tx(struct uart_port *uport, bool done, > + bool active) > { > struct qcom_geni_serial_port *port = to_dev_port(uport, uport); > struct circ_buf *xmit = &uport->state->xmit; > size_t avail; > size_t remaining; > + size_t pending; > int i; > u32 status; > unsigned int chunk; > int tail; > - u32 irq_en; > > - chunk = uart_circ_chars_pending(xmit); > status = readl_relaxed(uport->membase + SE_GENI_TX_FIFO_STATUS); > - /* Both FIFO and framework buffer are drained */ > - if (!chunk && !status) { > + > + /* Complete the current tx command before taking newly added data */ > + if (active) > + pending = port->tx_remaining; I almost feel like this should be: if (port->tx_remaining) pending = port->tx_remaining I could imagine active being false but "port->tx_remaining" being non-zero if we happened to take a long time to handle the interrupt for some reason. Presumably you could simulator this and see what breaks. I think what would happen would be "pending" will be larger than you expect and you could write a few extra bytes into the FIFO causing it to go beyond the length of the transfer you setup. ...so I guess you'd drop some bytes? If it's somehow important for "pending" to be 0 still when we're active but port->tx_remaining is non-zero, then I guess you could also write it as: if (active || port->tx_remaining) pending = port->tx_remaining Maybe I'm misunderstanding though. -Doug