Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3202901imu; Thu, 29 Nov 2018 17:53:03 -0800 (PST) X-Google-Smtp-Source: AFSGD/XuZc0G31m1Fn6b5mG8JEspBZev/m8CPFeelP8LJB9Pg/EELmcrpn/2qcin3pvC7Dw8h3/b X-Received: by 2002:a62:a1a:: with SMTP id s26mr3764197pfi.31.1543542783513; Thu, 29 Nov 2018 17:53:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543542783; cv=none; d=google.com; s=arc-20160816; b=cRzyvgtzGxYAbsBGuCFDO5MWNk91dHXa7kgpcUeHpmJmyAUfSWqK0kbuympTkWmAJz Sp7KRL2L5+T4C1XCwvlBR1G5O4LViHne8G502KIbYvMwDD8pQkGExVhboFOT+TMJzUey W7vm7GuhFPtLQgzRKuRjFZ2iG8U0zg9lrTJSQ09OCP7x28/voib6h969t3og3Q3Gnxfl bqIffaHFbPIcYilobuX6JYC900bP7BKK+sjFoFzRyPW1UtJB64EOaECvY4p6lC0EIED1 2PbyLVe6qh/wuVp/ujfWW6CBMoFHZgNogKpPrxOlhkxE2CimtD+jCBybAwn9BonRlvSU nndw== 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=nwKmuygAxGMGHSUtaB7XKREacaY2G4ENMasbAQ+ggHg=; b=qzPapIst8HRnZ5JKFClp47/aBd56dW74E3pV7eMlbz/c2h7RI8j595bQFLX1ll+WEK ycBAlbVnjn6KWrg7usKqrjkbPRFGdNJwWDH9Y03/2ig6tTvhH6AELt+zFexy1lPAj5Fv 8y38AHM28NL38lEfGyUQ9QuRSQ8PF2aCLhUudT/oPDrZ2O+4T2nDBFZIDVwNo7Twni2N nJolHk7Q3bHHukRGah2qJucZclYs7WBRRlN7dmWLm9VfJo+0aYKFCV5gW4WTkoT1UHlH 9ADJYpF5ydu6yvGkSlDsoSsW80g2BagMvJiF7H7NHmz0FwrH8bVa9hTTgpm/L+UIYRde aojA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DKtbE9Bi; 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 o28si3560886pgm.238.2018.11.29.17.52.48; Thu, 29 Nov 2018 17:53:03 -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=DKtbE9Bi; 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 S1727095AbeK3M7k (ORCPT + 99 others); Fri, 30 Nov 2018 07:59:40 -0500 Received: from mail-it1-f196.google.com ([209.85.166.196]:51817 "EHLO mail-it1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726332AbeK3M7k (ORCPT ); Fri, 30 Nov 2018 07:59:40 -0500 Received: by mail-it1-f196.google.com with SMTP id x19so6935813itl.1 for ; Thu, 29 Nov 2018 17:52:05 -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=nwKmuygAxGMGHSUtaB7XKREacaY2G4ENMasbAQ+ggHg=; b=DKtbE9BiuTiIFJMb3NSypZJfhv8U6MEpYNafZnS9oLo7VuLfSk3cTk9ouJbW4ZfTS1 x6dd7RC3fpGBPAKwHxe9FiJMYdZZP3myUGi30A88oprKSI8jdA63ics4mAonVOF3lu9B f+prAV0SeLxLJCojUgFVfDM91Dxu94RCrTFFs= 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=nwKmuygAxGMGHSUtaB7XKREacaY2G4ENMasbAQ+ggHg=; b=np7UH2WUNfvo6k4lb8WLvyZoUGoutn9ywLGzA30RrhsZF9+Ffb1cMuB/bMmuv4TfJF 44kp2SLnz7BJmc1nPurAOP3/39GNuOrXCO82wIDRnUo6pQz742DWmSqLgT0tMah/mK7n TnpvuOrlAKYf4sFNNaMJ2GpEUbJHcqUYKM1pVdRgXBZ6/WDBJEcOz0N3hYR93E5nCI62 6H/AXaJDkBCAk5/Tb6/j0TXisDQR4rojvTfIZzYWS+vy7vqClnMI3rKZFnrK7ZxUas5k 1zcsb4mGFl2sDmHuG3DtreK1hsbmMd885Y23ESnnCbPKRXaH+DFKqRZ4of9sYQ3NHse5 UlDQ== X-Gm-Message-State: AA+aEWZwdTK9wCJYH3kxiFGtkI8x/6CNJ8B/YpwaxKKVyprsOsQtp/8q 6Viw2gbOUJrcFbNhwpCnj3B+qUfogpZiuGnA+LOD7w== X-Received: by 2002:a02:8449:: with SMTP id l9-v6mr3629472jah.130.1543542724697; Thu, 29 Nov 2018 17:52:04 -0800 (PST) MIME-Version: 1.0 References: <20181128235459.180940-1-ryandcase@chromium.org> In-Reply-To: From: Ryan Case Date: Thu, 29 Nov 2018 17:51:53 -0800 Message-ID: Subject: Re: [PATCH v2] tty: serial: qcom_geni_serial: Fix softlock To: Doug Anderson Cc: Greg Kroah-Hartman , Jiri Slaby , Evan Green , linux-kernel@vger.kernel.org, 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 On Thu, Nov 29, 2018 at 2:12 PM Doug Anderson wrote: > > 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/ Comment is correct as is, but will reword to make things clearer. > > > > +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. Yeah, this flag has different behavior on the hardware than you're expecting. Active will be set for the duration of the command no matter the size of the transfer or across how many interrupts the transfer takes, including after we're done on our side (port->tx_remaining is zero). > > > -Doug