From patchwork Mon Jun 10 07:37:37 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: 166285 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp705882ilk; Mon, 10 Jun 2019 00:37:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqy3LWiHak/MkVd+Q8aeq+VZY/X1k1jxXePSv/R/jlNqcpsFF1AD+OVWAieT7/83ghZwd9ys X-Received: by 2002:a63:4813:: with SMTP id v19mr8406124pga.124.1560152263044; Mon, 10 Jun 2019 00:37:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560152263; cv=none; d=google.com; s=arc-20160816; b=044Yv7CYT8kUFTc9+jW0wDSqR07xAmPAS7IL1/RNsBYCwlQg2DwI5ydImQCaSqZRxa OyKvzFOZgNhgo3+MCFEyp7Mc+VEs0tVgfpzFW/CLkgfsEp6XUjlAf7D0iXCIoCiR+8RW WJaJs3DTIzvumydmEnPyZ3rkJUm0V12Lnsra058emr4T+CaZTS8bfEKIs1UNWfccqnQr eBhc3L/xuSzbML0/8cqcTEBjAHnMI9QIKbn1u8amtlErZDIaLAhgXcSy2tQBKPu2JtYx YwD6ae9QCAztmJKqvl+Cwa6tgOlzY0yg/+kEN4+Lt1COngAk0he5x0p5Ojwmk52RCY2u ragg== 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=3aJUsVJEK9+CBcf4UpPeGea/cLMYkv5xsZDArHsWziA=; b=aaRC33YvPfgKDbeEDckiafZViBPoM0R/o6P04IPY1tNbql4ld+9FwC+I9BD7e/+ylH x4x2kycWFsRlUBiVYwe/rqCVercfkJ3ZBp1+lGdUlzgE1/9hWGAkKn1B94F0BdzLWtay pguVMntwrUzjrHcuw7JAeVk4Bg/xRXa+IcHjlSNRhlcXp8SFJnd7s/bkfXvh/uxkqNl2 w9CyT4POc6VXR0axgWU91J0SNchWDqgGC5ex7ZYESGN1YCLlT1PhU6Vy6zEZwrIizIu+ sY2e895CWBQ10vbwo8dDlZG5nkvLUigFxW841+zV3EN0dcKpvrjuKPFrRY0yRkQX+vpZ 68xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=x7cXKFFB; 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 b11si9180365pgq.455.2019.06.10.00.37.42; Mon, 10 Jun 2019 00:37:43 -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=x7cXKFFB; 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 S2388157AbfFJHhm (ORCPT + 15 others); Mon, 10 Jun 2019 03:37:42 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:35461 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388071AbfFJHhl (ORCPT ); Mon, 10 Jun 2019 03:37:41 -0400 Received: by mail-wr1-f67.google.com with SMTP id m3so8081039wrv.2 for ; Mon, 10 Jun 2019 00:37:41 -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=3aJUsVJEK9+CBcf4UpPeGea/cLMYkv5xsZDArHsWziA=; b=x7cXKFFBTeToSOdu9ScaVUDjqDt66N6zxwx5eiCRELdilz4D9HOV0PNBw0USpTHZyo pRyDwvR7FHnybSkI/LJYZw00nrY/2UmFQdxuklZCaowJP0dgKU9AkSgaiLYbmq16A1rq DZhmYxD5o/LDMc4Bu6RveBnZNWrIFtzHcRYI17JXx+3s1EhRfi7ZJoKoeFB+qZ0J7ubW TWeaZgAjZcBYdfawOgOIIxbBa7oRvhWafut/epTazByr2fkOnHkbS4hFO2iTzqmGTZlE Tx928gmgtLkiMPbuQdxchrEQ2aYEWIhfSjfrLSGV2PuhiExO1oP4JRtM0C/TY9hRwPWh zb5A== 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=3aJUsVJEK9+CBcf4UpPeGea/cLMYkv5xsZDArHsWziA=; b=EaLyCCudxwocvr5XfVIeZKn5B3ZYUAkaTVt34yOK7qOuQq9TQmrrDR5WBcL6uFFarA vwWH4sZ0kzHPoBSwI0yI+4g4EU9p7eqHovmu130J7yq7MuxA8RQj90D7NaoNjLYQdTZR dXIruDpMax9Tl5khpUYAyvJTH+dqcqjOzaOI5FdKFRi18UZS9kwiGJLpYZSnd8R3neK7 crkkmzAmy4/r01jO/Zqj1G5OhfbwysOBE7B4Y9MDF8y2qvT7a8Y+SPZcQ6k0OaGcq5ho 09OyZfdFF87EP5aYRcMbE1O+hRiPgISgvJYbXqNXZnRuaqgrWPpldee+HyC1G12kqtDt tdWw== X-Gm-Message-State: APjAAAUzQhw25TQqNkJ8M7hk9haaGnUfB9OEY1Vz5gkynbJPtAGq1ET7 Z8lOxaixbxLIabEc5IVDIAKupQh6ubA= X-Received: by 2002:adf:f951:: with SMTP id q17mr16745992wrr.173.1560152260502; Mon, 10 Jun 2019 00:37:40 -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 t7sm8769520wrn.52.2019.06.10.00.37.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 10 Jun 2019 00:37:40 -0700 (PDT) From: Jorge Ramirez-Ortiz To: jorge.ramirez-ortiz@linaro.org, agross@kernel.org, david.brown@linaro.org, gregkh@linuxfoundation.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] tty: serial: msm_serial: avoid system lockup condition Date: Mon, 10 Jun 2019 09:37:37 +0200 Message-Id: <20190610073737.22856-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 --- 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..0d4f1fe2b3a2 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); }