Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965226AbbKDAXK (ORCPT ); Tue, 3 Nov 2015 19:23:10 -0500 Received: from mail-bn1on0088.outbound.protection.outlook.com ([157.56.110.88]:7596 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932695AbbKDAVL (ORCPT ); Tue, 3 Nov 2015 19:21:11 -0500 Authentication-Results: spf=pass (sender IP is 149.199.60.100) smtp.mailfrom=xilinx.com; linuxfoundation.org; dkim=none (message not signed) header.d=none;linuxfoundation.org; dmarc=bestguesspass action=none header.from=xilinx.com; From: Soren Brinkmann To: Greg Kroah-Hartman , Jiri Slaby CC: Michal Simek , , , , "Soren Brinkmann" Subject: [PATCH 2/9] tty: xuartps: Use spinlock to serialize HW access Date: Tue, 3 Nov 2015 16:20:43 -0800 Message-ID: <1446596450-20918-3-git-send-email-soren.brinkmann@xilinx.com> X-Mailer: git-send-email 2.6.2.3.ga463a5b In-Reply-To: <1446596450-20918-1-git-send-email-soren.brinkmann@xilinx.com> References: <1446596450-20918-1-git-send-email-soren.brinkmann@xilinx.com> X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.0.0.1202-21918.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11FD024;1:586FqVqFfSQBIzsPRkAZOBb9ux1TdZE2FeCgG/R+I7LT5FSdcg3Ry5TS/5ao/suzcLGoZ1psAQ6a+MxJf5d5uCGUtGIvD0ZWZtfrrOOI8zypZyK51izdC2xKYJmK+GyVQpjYgpJQNPT6AnzbfCsigZel4BV6ZkGkLLFdQH9PLbIaBTqjbrMaVZd0oG1JhHPfZ806F5zpCJOFUVzb2QW8/OvXIu5IKMxw+Xbsk6I3ylrlToQ2QYGrcM5g+RkP84fnSB5bv8q46BU0OOcHjELqddJpmz4f6pQngzPNbvbQ+1ruewr+dh2LT59VzrKEuBCly+U/LwPCM7sSb+3UmvPHZ3yXNLF3I/iHGw/lE3qkaeY= X-Forefront-Antispam-Report: CIP:149.199.60.100;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(438002)(199003)(189002)(107886002)(48376002)(81156007)(189998001)(36756003)(5008740100001)(77096005)(5003940100001)(50466002)(19580395003)(4001430100002)(5001960100002)(33646002)(87936001)(2950100001)(50226001)(6806005)(11100500001)(229853001)(5007970100001)(5001770100001)(86362001)(36386004)(106466001)(92566002)(575784001)(47776003)(16796002)(57986006)(63266004)(19580405001)(76506005)(50986999)(76176999)(107986001)(5001870100001);DIR:OUT;SFP:1101;SCL:1;SRVR:BN1AFFO11HUB039;H:xsj-pvapsmtpgw02;FPR:;SPF:Pass;PTR:unknown-60-100.xilinx.com,xapps1.xilinx.com;A:1;MX:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11HUB039;2:gqVi7PUKftrjVWYIfa1XqBZPNO8Bu4hhLfJlx/JOtGUuA8GVxNoErDFfOys3qW3mG5jRZ3hwnF1cF8l1lEEd4Cb/rswmV5rmS+TviMbeJcCr6lcDStst0fqMgNhydLE9fGlX8ARblqKPlBjQGt6KzNEVg/t3NkBu58JzUO5uOw4=;3:yGAkQeGkOi16DjZtYFhbSEznQDjBfbHsejHxHURxukmihJ3VGzZylYRfFuaJ3cLVR0MMth49viCvluA6oxE5bkUj4kuiTPlE00hg7T7cZfgQ9HMiTOrmcrhQAj63XGaKM/vN+zq1yPxfYj3gmOPRt++UoTtrDxY7GaaJ/UXjI51xDb5lcGgEC6a9jrIEtrC4190QpAAY9c8wa8OvveJVTsakgJNLaTJ8tmFb0H/M5LpIleEvUHkOOHxm4rwwGgy5QYs5qIYLdtOpITcDZu093A==;25:djb5hnHx1E7PwXUdfUE/0ScV3AYWGk8j1BSHb/9awhL6FKJmatyqUI8zb0QXIg4lQ/G/HUVeUWWXjHyt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lKvMY02x/YZdRMvzMu9XaKaclA/ocO2XR52e1ln94g0VNxYhd5HGtJxRWFIe48kRbupbAIpw75eztc+fx+hdeVMBucXVF X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(192813158149592); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(8121501046)(5005006)(520078)(10201501046)(3002001);SRVR:BN1AFFO11HUB039;BCL:0;PCL:0;RULEID:;SRVR:BN1AFFO11HUB039; X-Forefront-PRVS: 0750463DC9 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN1AFFO11HUB039;23:VZIP1QhnwDon8BBjV5L4SNtJej0e0DI2Lpcj4UD?= =?us-ascii?Q?CIWOiG4yl2OOkQzMIssG/TZZtUd/5Un7pfwvMnDtvqkMDw+hGnsLaPY0zNbm?= =?us-ascii?Q?VT2+Vhlw3HVHi11QvExw8uswvCqtgWeKKcZzVhs/Ch82xCHGgvRZ/MBGRP+i?= =?us-ascii?Q?RVr/cUd0bEljjzSI6oFoC3lXymwq71YMjHxvSefas5ISkr5qshAKOulPnbpF?= =?us-ascii?Q?xN9ATqmJY7QJhHFaA2gtMNBzj4Jhp0yPsdciGoLUZC38Juu3YjU0X39wLMWD?= =?us-ascii?Q?vWwx8r98+cXlYD2MEMI1AmWQcoG+9m5z5Fj8f4nmaqtd9op1t8BsYJITJO8z?= =?us-ascii?Q?76hrq5DFEHJcfOvkxV7JAXPzzM4tPoaeNxzoZRhUGosIj4V+UWgrjkJAuktZ?= =?us-ascii?Q?TNTQ+O60QhTSmLq8HumQtOcuxB3AIwZW+zhebjuHH2ZzfBiurYxeUwc9DnAz?= =?us-ascii?Q?YWlRH2S99Las4Psl0PAXa2RzSWmqpR6Ma0ta+oaNWJ/fkDiZY9Jk0KCLuVFK?= =?us-ascii?Q?BaC5jiR7ypu1ukDsErePElF6zLxYzPxtlnlgUTBrGzwTSG5j82BiM/IhJ6Um?= =?us-ascii?Q?LecmkHPsJvjdbxZj40jirN0GJ9TaVniz3suqqfTcN24cJm1M3VlETO8dc3Rw?= =?us-ascii?Q?7x3OooQmmnwedIA/WrSrqdDt3CV8pRxtPrm/nXKb0zCNJbgRtgr+3yIxsrZX?= =?us-ascii?Q?OD2Jq28a2gnsOrKZ24OMk5EOfHHkjPvSpzwXKLIn5T0JGp5s2/xVzmJn1Orv?= =?us-ascii?Q?tierIh5RhqWI9CLNoFx/vvMUWjs6i2LLCOqkCr8FG/Pu9Zrq+nc47l0qAX/9?= =?us-ascii?Q?1pP1x2WOH314D230zt6d/6u2lpx2DruP2GoIBZWrYtXi9GSrmQmWK3uRhpQV?= =?us-ascii?Q?+JvDp8Av2pttjMg+/1wdiQltosyqofVDSc97ux7w2T4eJk7xUgCf//vIjHpC?= =?us-ascii?Q?Q52Ue/LpHrQXXtUdkK8imeW5BtM/jCXLDNIc9QlmbIftHXSmvhPVCqWBiWHr?= =?us-ascii?Q?Agad6HzxLAPoQoR+mThfFw1mpynbAUcxy1aJx9DIqj1PCKTbY6+jUGE+GzZs?= =?us-ascii?Q?jj0LX/nQTDDHSKpEAc068xSJ2cx42LRRrKD+TVyWL/0rT0j4HVgc6d5Vo3a1?= =?us-ascii?Q?gYrZwcaSZEpt/b7teuGJmtQL40w6WyO1V?= X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11HUB039;5:pjPAiZ13p+zrXLbY1YGszhpW0MH8PMZtgF03gr2dg6HjR2o+ztifvgy0zA0BRHx6z2qw+pdmeISc3bWIN6fenKmoor7mcrpUPLvt3OHLDRkiYweJ+l/fOMN6baLpnLd4izveAPfFG8gRIwVBT4t/kA==;24:G+YnLW2ElbPXo+dFKnmzMYkMaFXfdwvdyGZHvDLPBfsXnbQkzfXlkusb+sKbbtl50WT8UnPpzAh82yPAYv9EMlh4iZaE7L1Qiir4CgFf5Sw= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2015 00:21:08.2740 (UTC) X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.60.100];Helo=[xsj-pvapsmtpgw02] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN1AFFO11HUB039 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2335 Lines: 68 Instead of disabling the IRQ, use the spin lock to serialize accesses to the HW. This protects the driver from interference of non-IRQ callbacks with each other and makes the driver more consistent in its serialization method. Signed-off-by: Soren Brinkmann --- drivers/tty/serial/xilinx_uartps.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index 50d4082d2354..dc1987f3dc0a 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -947,10 +947,9 @@ static int cdns_uart_poll_get_char(struct uart_port *port) { u32 imr; int c; + unsigned long flags; - /* Disable all interrupts */ - imr = readl(port->membase + CDNS_UART_IMR_OFFSET); - writel(imr, port->membase + CDNS_UART_IDR_OFFSET); + spin_lock_irqsave(&port->lock, flags); /* Check if FIFO is empty */ if (readl(port->membase + CDNS_UART_SR_OFFSET) & CDNS_UART_SR_RXEMPTY) @@ -959,8 +958,7 @@ static int cdns_uart_poll_get_char(struct uart_port *port) c = (unsigned char) readl( port->membase + CDNS_UART_FIFO_OFFSET); - /* Enable interrupts */ - writel(imr, port->membase + CDNS_UART_IER_OFFSET); + spin_unlock_irqrestore(&port->lock, flags); return c; } @@ -968,10 +966,9 @@ static int cdns_uart_poll_get_char(struct uart_port *port) static void cdns_uart_poll_put_char(struct uart_port *port, unsigned char c) { u32 imr; + unsigned long flags; - /* Disable all interrupts */ - imr = readl(port->membase + CDNS_UART_IMR_OFFSET); - writel(imr, port->membase + CDNS_UART_IDR_OFFSET); + spin_lock_irqsave(&port->lock, flags); /* Wait until FIFO is empty */ while (!(readl(port->membase + CDNS_UART_SR_OFFSET) & @@ -986,8 +983,7 @@ static void cdns_uart_poll_put_char(struct uart_port *port, unsigned char c) CDNS_UART_SR_TXEMPTY)) cpu_relax(); - /* Enable interrupts */ - writel(imr, port->membase + CDNS_UART_IER_OFFSET); + spin_unlock_irqrestore(&port->lock, flags); return; } -- 2.6.2.3.ga463a5b -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/