From patchwork Mon Jun 10 17:23:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jorge Ramirez-Ortiz X-Patchwork-Id: 166356 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1283972ilk; Mon, 10 Jun 2019 10:23:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqx65qibKtm2GJs7HqfOCb41kTjtDjlbweHIF2n+A1drrcVzpTxV2AX3xcUr96LtkJkGLnfK X-Received: by 2002:a17:90a:9306:: with SMTP id p6mr21540589pjo.6.1560187395578; Mon, 10 Jun 2019 10:23:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560187395; cv=none; d=google.com; s=arc-20160816; b=bUA/0XWXvlAGzcgcCyWa6TGn3UDUX5rBoKO4IC6wXt0Dz5qyb6fDaQQlyL6Zb5onOZ l4/89p7glqanHFCHfq47Au+J/9BYmTWIGWwQyKF+xlI30PI8Jd8f5c88kFDDHztY4T3b DyY+GFWc2c9BlG6yFM4oiq0e2OHJLRKrUaQBldAaeJ+KBcY9MGu6ODaLZIwZ/K8JLnTz lQQjKy43J2wD7sGa7NbIg8iam4IJfPUQhlEY7E1NJky111xNWRfkMf3ORVynq4Vst4yw vtHBNHjKgtBb1XP1LYCOR/S70IWShu7UvLwaUrMT/+X9YemcMLqvNJekHhBf3zrS/rTi NUTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=hE4cR11QUq+RsE+T2OXtTk5Fiz8rk9hoeeEatdOHPQM=; b=elicH/WrSRiqmP3wdq2ymVDUF7ZJt92e3xGycV3PEqY4cFXmnMaR9Vbcd09ouOv3RA 0KigYNjCqBPd//sVBU7n7zuKe8FuTS3y28qDOPdEi8oIi5U7QHJeFB0pHF8IsGxX8yyB nnWtJ4MDuV3z6HT9UHtZzkxgyUzS4uc5hepkTfOi2tAgBHKcA6OVI+pwAi5/c4hKLuA1 NrkSZ2lVHo+NK57nxNltimN5vjhObZIe77e2dP69858L9UFDT2zIxDYMc+h5Kxz8/3YY T6236OvfRZS62f0mMhyLByTlZ15acIQObqMvNUflbQ+lJaMQPupKEImwB4Hh0W0okO6M RWKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DYCkAdiU; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e6si43501pjp.21.2019.06.10.10.23.15; Mon, 10 Jun 2019 10:23:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-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=@linaro.org header.s=google header.b=DYCkAdiU; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728438AbfFJRXO (ORCPT + 15 others); Mon, 10 Jun 2019 13:23:14 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:41434 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728394AbfFJRXO (ORCPT ); Mon, 10 Jun 2019 13:23:14 -0400 Received: by mail-wr1-f66.google.com with SMTP id c2so10001605wrm.8 for ; Mon, 10 Jun 2019 10:23:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=hE4cR11QUq+RsE+T2OXtTk5Fiz8rk9hoeeEatdOHPQM=; b=DYCkAdiUnfostkm8Hivw7VIDgB6ztRtb5vpXxRVM8Gy7u2qzeKbULe2FAkpkmxsGuC e8dFxmka3vVJmQtR0L+lKeCuI5rECXgOeNiuiqkohPLon3Zu/J6pIJGpDH6sAnVNBRdy iYj0cmRtJLOZIRfdYpm5c+25f1k1lOIQ9se8RXYe2kigfn9PjhP/jMhsnV4/FWwA8LMe vZ1pMlKVQDJHiSjjNr7yYS8h0bO1PSPX8pdEk1bbuu6UeNB+/3RqzTrG0tOSEYGNUQu0 XM6/RHV4jttnLWJzsGRkz+OgNKuLBkLRBKKRjzkOgNcrw86Cci352k8OrtwaNR0g+ul9 PiEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=hE4cR11QUq+RsE+T2OXtTk5Fiz8rk9hoeeEatdOHPQM=; b=fF46AP/x9yPGfX31DWKOOgZ/Q5bRJbK2FI5w6sw0XDaWEGw6ecPuU6omjZMvdFC/wz 009bkAlzSGnFbL/Yxr0YHDKyqgvDaAQbMQfBYGNWMxeWn9LpAltO4w6CXtvCkIG0OlJi W9Q+s2jcQfnlkqq+rrWH5pR6DYKh2gYfbD7FXACqfc5f0K3RXMx4Dkhpqaf0C5A7hIZy shME0tHVkd5lOV3/zft8n32C/veoDVKtWaatdxl5tODCHaVwIarfA3XdZah7BhyHfUCH AAalFGZiwoaeEZpaJGXLpoOkJZ1WHDK6LpJ4RzPAvifRthHIApSGL4TLP0MnyHtgy0V/ PXeQ== X-Gm-Message-State: APjAAAWCtrqkL8/Lczi8J305dWNu0ZZTTDPg4NyhDpIPC+y8bQcHRq46 bwC3J1JBSQN28QeAuCBqzqlO9g== X-Received: by 2002:a5d:4489:: with SMTP id j9mr656490wrq.15.1560187393072; Mon, 10 Jun 2019 10:23:13 -0700 (PDT) Received: from localhost.localdomain (233.red-79-146-84.dynamicip.rima-tde.net. [79.146.84.233]) by smtp.gmail.com with ESMTPSA id f2sm19853686wrq.48.2019.06.10.10.23.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 10 Jun 2019 10:23:12 -0700 (PDT) From: Jorge Ramirez-Ortiz To: jorge.ramirez-ortiz@linaro.org, gregkh@linuxfoundation.org, agross@kernel.org, david.brown@linaro.org, jslaby@suse.com Cc: linux-arm-msm@vger.kernel.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, khasim.mohammed@linaro.org, bjorn.andersson@linaro.org Subject: [PATCH v3] tty: serial: msm_serial: avoid system lockup condition Date: Mon, 10 Jun 2019 19:23:08 +0200 Message-Id: <20190610172308.21129-1-jorge.ramirez-ortiz@linaro.org> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The function msm_wait_for_xmitr can be taken with interrupts disabled. In order to avoid a potential system lockup - demonstrated under stress testing conditions on SoC QCS404/5 - make sure we wait for a bounded amount of time. Tested on SoC QCS404. Signed-off-by: Jorge Ramirez-Ortiz --- v2: fix exit condition (timeout --> !timeout) v3: add these clarification messages drivers/tty/serial/msm_serial.c | 4 ++++ 1 file changed, 4 insertions(+) -- 2.21.0 diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c index 23833ad952ba..3657a24913fc 100644 --- a/drivers/tty/serial/msm_serial.c +++ b/drivers/tty/serial/msm_serial.c @@ -383,10 +383,14 @@ static void msm_request_rx_dma(struct msm_port *msm_port, resource_size_t base) static inline void msm_wait_for_xmitr(struct uart_port *port) { + unsigned int timeout = 500000; + while (!(msm_read(port, UART_SR) & UART_SR_TX_EMPTY)) { if (msm_read(port, UART_ISR) & UART_ISR_TX_READY) break; udelay(1); + if (!timeout--) + break; } msm_write(port, UART_CR_CMD_RESET_TX_READY, UART_CR); }