Received: by 10.223.185.116 with SMTP id b49csp1104620wrg; Sat, 3 Mar 2018 15:41:37 -0800 (PST) X-Google-Smtp-Source: AG47ELseb3yTuxEPgmwf0k5AcWvYylBUorIu7agNHGoSH1fIsJ1av1BCdU94sPyRmgSu9zwmeQCk X-Received: by 2002:a17:902:968c:: with SMTP id n12-v6mr4488552plp.371.1520120497074; Sat, 03 Mar 2018 15:41:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520120497; cv=none; d=google.com; s=arc-20160816; b=G8fxgRnXcmSvGkULWQ/Y4i7W+J7xJmlQ3q+UNZ3yK915a1SeoJam/TVlFRViM4tHCU U2BuIdvHTsMotH5ylvodv2vqkJ11LVnv/Ilk9/j/zycxBFmbK1TxyaUb+1sIK7ano0J3 r3uKU76tQXO7Sbx4zPYEvn9wpdDze4HM4rnXF8jcE5GhACR4C88BYWqPbwQ22peiJbZ1 xSXeYWnN8fQdwUOy2K2dd5ioE8qfSQHGL+zRMLIuyfM0LXHSa2rs+JFjlCrewZ6CEF65 fiAr+s1LzlZKOJiCAHza8bb8mvZRi59nle/03X+llqbhfKEOhygoGdo6IQKy2AszBw+u bK5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=IlajqvRmZPIUU9AcRYhFguchbStJjG2QM8GWyWRG1HY=; b=mqFqsXF4osmL0nvZ0WjMzkeo1TKgcCzWn1nL7qrqzbDAHqsR8rtkR5b0Fz0ypk0Ya+ axgtUUSUR0Qv+2YtAB7QguXLHEJq2onhw2c1rYobXM/forf+IRAN1kotFtSGzrJ/OFvd b1OmLdgOs1xwmUjmwkukx6cOqu/5gXUg2ea4Oud5K6dUn3H7dmO8GM+rz8CA8NB+ysCx ImL15TrI2MpUr/XMNNZyjNE2QlsQ8DnQpCwxrHfUSFwtHCYbeiX9yY4wKyBV29PMjLcH rEQCU6b9LawnQ33Lj9xyTQNg2xTezYhwGA8zkutgLQUYnxQIsy1yGXlX8SMUtsxMmAqT 8Q3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=Kfb4VMIH; 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m10si6177416pgs.236.2018.03.03.15.41.23; Sat, 03 Mar 2018 15:41:37 -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=@microsoft.com header.s=selector1 header.b=Kfb4VMIH; 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934594AbeCCXkm (ORCPT + 99 others); Sat, 3 Mar 2018 18:40:42 -0500 Received: from mail-sn1nam01on0132.outbound.protection.outlook.com ([104.47.32.132]:20800 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933395AbeCCWfC (ORCPT ); Sat, 3 Mar 2018 17:35:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=IlajqvRmZPIUU9AcRYhFguchbStJjG2QM8GWyWRG1HY=; b=Kfb4VMIHYZpXByLl83E4/RA7f6UH0FV+qX8NneKBGjDzNe6CjF+PNgitJ8Ogo8xWkyUbXsAkFd854O9SCRqkYiKuy0m+G3ZNlLvCtvRqQkdO26KqPjewr29dSXdJ3gfYykHVi7eKpTTC9YNFmnTapSTz53I8b2GQlvcsNRtCsNc= Received: from MW2PR2101MB1034.namprd21.prod.outlook.com (52.132.149.10) by MW2PR2101MB0924.namprd21.prod.outlook.com (52.132.152.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.588.3; Sat, 3 Mar 2018 22:34:51 +0000 Received: from MW2PR2101MB1034.namprd21.prod.outlook.com ([fe80::1d56:338f:e2b:cec0]) by MW2PR2101MB1034.namprd21.prod.outlook.com ([fe80::1d56:338f:e2b:cec0%3]) with mapi id 15.20.0567.006; Sat, 3 Mar 2018 22:34:51 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Jayachandran C , Greg Kroah-Hartman , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 134/219] tty: amba-pl011: Fix spurious TX interrupts Thread-Topic: [PATCH AUTOSEL for 4.9 134/219] tty: amba-pl011: Fix spurious TX interrupts Thread-Index: AQHTsz8Oiq7USxOY5EqSfEjiP5FoQA== Date: Sat, 3 Mar 2018 22:29:14 +0000 Message-ID: <20180303222716.26640-134-alexander.levin@microsoft.com> References: <20180303222716.26640-1-alexander.levin@microsoft.com> In-Reply-To: <20180303222716.26640-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MW2PR2101MB0924;6:sHiDL+6kJPvA4n7sXVnXElerHsUnxw2mZbMJqG+6ikCSiBXL+wg1SKXakLzLZnrVF8IHx+UIgBYQKM5UTvscfZmFnvoHDSkMImJoyZDPWbfStkKpdM8nJCEzcE6z0Rf2ofPSGfUWjmta3M4fR2L8DDA8EsOJdSXNe0FgIJqdRL7fpGZi9HCQY1u6G1RbIHme8DJli7Sp58HS0efQXGxp4f4fehpZXRI2kmzl6ltzNP0ehKJ5Y3liJT4gCE9o04XVk+ZlrgXnA3MWHEq8rbSUDxCcYDJhMi+1cpwysu53wDHKe3fdYbH58YrjQt1R9jc6CAwV4jwkWZmLYVLlH60xMgVVEbh9BvQlRj3agD4OLqA=;5:IOE9uuSSyCsgtnugKYsa87xdjqJN+VYJ/BO/6fxwK5uHveg6ArYi0VmMkcAkqItiIzwWEqz/IzN/yDVvsw2jlNf87br444Q/mzKwF+nuHQmzpZ9UXTYVAAbo7Ghi421cdBWdLtIR+y2P75aUlWWvicjjGrEUYOVBJGyvFPtA//g=;24:Jbgqxjd4TTntzr2scJD21xNsQQ6ivies0sBqW8LgLkWemKCvhpbXvOlTIUGI/srhVmlV84xVXPY2Iw7KZiX8L+bk+wLCKjrl/s9WEazpNAA=;7:x8CRMz+gvGqFB4sivZ+fcKE8fy9gWQM3kQ6WFkciGit1KIyGM8uczir6UNMOftiUHV8/ZdjajTrdfmgzEC8+Zx+ERmsQjqGvKAF1NmOejQHSeultP6ReqVzB+6d3jcWODtcMjiF3FszTGvvsoQjGEalGUhWsWJ4/02EAGFNiaS8PQASuBjTHZUpulv2GLA7hM93JqXHmxPyKA6YXHhVwn9ssUWrunCwtyxBkXOv82rghBxznIaWytsJSVwmoLFpG x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 601a830f-7a75-4168-3bba-08d58156fab9 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603307)(7193020);SRVR:MW2PR2101MB0924; x-ms-traffictypediagnostic: MW2PR2101MB0924: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040501)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3231220)(944501244)(52105095)(3002001)(6055026)(61426038)(61427038)(6041288)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:MW2PR2101MB0924;BCL:0;PCL:0;RULEID:;SRVR:MW2PR2101MB0924; x-forefront-prvs: 0600F93FE1 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(376002)(39860400002)(396003)(366004)(39380400002)(189003)(199004)(102836004)(2950100002)(10090500001)(6666003)(316002)(26005)(186003)(25786009)(2900100001)(2906002)(54906003)(22452003)(110136005)(97736004)(6506007)(59450400001)(7736002)(4326008)(305945005)(5250100002)(86362001)(575784001)(2501003)(99286004)(68736007)(72206003)(53936002)(6436002)(6116002)(3846002)(5660300001)(66066001)(1076002)(76176011)(14454004)(36756003)(3660700001)(6486002)(86612001)(81156014)(8676002)(81166006)(10290500003)(6512007)(8936002)(3280700002)(478600001)(107886003)(106356001)(105586002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:MW2PR2101MB0924;H:MW2PR2101MB1034.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 601a830f-7a75-4168-3bba-08d58156fab9 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Mar 2018 22:29:14.0257 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR2101MB0924 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jayachandran C [ Upstream commit 7d05587c9e0e4611650bb403812e2d492c178a9f ] On SMP systems, we see a lot of spurious TX interrupts when a program generates a steady stream of output to the pl011 UART. The problem can be easily seen when one CPU generates the output while another CPU handles the pl011 interrupts, and the rate of output is low enough not to fill the TX FIFO. The problem seems to be: -- CPU a -- -- CPU b -- (take port lock) pl011_start_tx pl011_start_tx_pio enable TXIM in REG_IMSC -> causes uart tx intr (pl011_int) pl011_tx_chars pl011_int ...tx chars, all done... (wait for port lock) pl011_stop_tx . disable TXIM . (release port lock) -> (take port lock) check for TXIM, not enabled (release port lock) return IRQ_NONE Enabling the TXIM in pl011_start_tx_pio() causes the interrupt to be generated and delivered to CPU b, even though pl011_tx_chars() is able to complete the TX and then disable the tx interrupt. Fix this by enabling TXIM only after pl011_tx_chars, if it is needed. pl011_tx_chars will return a boolean indicating whether the TX interrupts have to be enabled. Debugged-by: Vijaya Kumar Signed-off-by: Jayachandran C Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/serial/amba-pl011.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl01= 1.c index e2c33b9528d8..b42d7f1c9089 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -1302,14 +1302,15 @@ static void pl011_stop_tx(struct uart_port *port) pl011_dma_tx_stop(uap); } =20 -static void pl011_tx_chars(struct uart_amba_port *uap, bool from_irq); +static bool pl011_tx_chars(struct uart_amba_port *uap, bool from_irq); =20 /* Start TX with programmed I/O only (no DMA) */ static void pl011_start_tx_pio(struct uart_amba_port *uap) { - uap->im |=3D UART011_TXIM; - pl011_write(uap->im, uap, REG_IMSC); - pl011_tx_chars(uap, false); + if (pl011_tx_chars(uap, false)) { + uap->im |=3D UART011_TXIM; + pl011_write(uap->im, uap, REG_IMSC); + } } =20 static void pl011_start_tx(struct uart_port *port) @@ -1389,25 +1390,26 @@ static bool pl011_tx_char(struct uart_amba_port *ua= p, unsigned char c, return true; } =20 -static void pl011_tx_chars(struct uart_amba_port *uap, bool from_irq) +/* Returns true if tx interrupts have to be (kept) enabled */ +static bool pl011_tx_chars(struct uart_amba_port *uap, bool from_irq) { struct circ_buf *xmit =3D &uap->port.state->xmit; int count =3D uap->fifosize >> 1; =20 if (uap->port.x_char) { if (!pl011_tx_char(uap, uap->port.x_char, from_irq)) - return; + return true; uap->port.x_char =3D 0; --count; } if (uart_circ_empty(xmit) || uart_tx_stopped(&uap->port)) { pl011_stop_tx(&uap->port); - return; + return false; } =20 /* If we are using DMA mode, try to send some characters. */ if (pl011_dma_tx_irq(uap)) - return; + return true; =20 do { if (likely(from_irq) && count-- =3D=3D 0) @@ -1422,8 +1424,11 @@ static void pl011_tx_chars(struct uart_amba_port *ua= p, bool from_irq) if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) uart_write_wakeup(&uap->port); =20 - if (uart_circ_empty(xmit)) + if (uart_circ_empty(xmit)) { pl011_stop_tx(&uap->port); + return false; + } + return true; } =20 static void pl011_modem_status(struct uart_amba_port *uap) --=20 2.14.1