Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1032765AbbKEHW2 (ORCPT ); Thu, 5 Nov 2015 02:22:28 -0500 Received: from mail-bn1bon0077.outbound.protection.outlook.com ([157.56.111.77]:40714 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1032413AbbKEHVi (ORCPT ); Thu, 5 Nov 2015 02:21:38 -0500 Authentication-Results: spf=pass (sender IP is 149.199.60.83) 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 v2 02/10] tty: xuartps: Use spinlock to serialize HW access Date: Wed, 4 Nov 2015 23:21:11 -0800 Message-ID: <1446708079-1105-3-git-send-email-soren.brinkmann@xilinx.com> X-Mailer: git-send-email 2.6.2.3.ga463a5b In-Reply-To: <1446708079-1105-1-git-send-email-soren.brinkmann@xilinx.com> References: <1446708079-1105-1-git-send-email-soren.brinkmann@xilinx.com> X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.0.0.1202-21920.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11FD040;1:g+kNTqZsKSh2wf3s/FkNoYyL8S9V195CH+HoA5ZBQpQlSRBh8HTULllEuaEkp7HH/vAIdxXStaGLl4qcf83ciSGv5/Wngx7r1KCpFLQPmcNhdNh6oNn+dKjnyA/3ae/zsWoSFvrGV27aonAJYWpKEL8JxMzsdA7slFEm1jcPJvj718B9BQEGhUzJSDvjjHa9KNk4UOUT7qMwYhhpQP2HzGOhgX1obJzEBMzROo47ksPhVEWpE5+VCoiQsle19pTBGQwBbjxHV6M/EPAUJ7XOjxnN01yDG/cy23MKHCrVXK8rZR/6OJz5j4GiMILeT26zAo9UHX8C8qyufHZdIwF9UpJkt6pSW9ukBREC8p08ayY= X-Forefront-Antispam-Report: CIP:149.199.60.83;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(438002)(199003)(189002)(107886002)(189998001)(5001920100001)(81156007)(36756003)(86362001)(5007970100001)(106466001)(5001770100001)(11100500001)(5003940100001)(50226001)(36386004)(5008740100001)(6806005)(87936001)(19580395003)(48376002)(229853001)(57986006)(4001430100002)(5001960100002)(33646002)(19580405001)(63266004)(76176999)(92566002)(2950100001)(47776003)(16796002)(50466002)(77096005)(76506005)(50986999)(107986001);DIR:OUT;SFP:1101;SCL:1;SRVR:BL2FFO11HUB034;H:xsj-pvapsmtpgw01;FPR:;SPF:Pass;PTR:unknown-60-83.xilinx.com;A:1;MX:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11HUB034;2:+OaWKmSHmBYi2VBnQFJP7BJq6LY39IOfepisJL+dbQRB+HuP+ZiYFZhcOAHsgr/ctaqDdqtdT+SvXh6DrL9rlpC/F1loMhh0QC65vrKshaLEa05n62z84MWtaMs/EKMJo0tdC2CFSZmUIypq3OvcySwNwN+O47r4owcDpRN22Gk=;3:YCgJtJmn+SNKlFhOnORDJjMSKgI9GRKIEkOhE5peDo0hctmKLU7nxbqqQ68MzkuHHIcSnCjy387kc9C0DXQqTfoiwM+nSrR62AhzruAgfBU4j/hRLnhYOYSiQINm0l9d/LStiCxhjBc18JpRjP+8dsbMIQPP/X0FQfI9ysZ5xPNBsmAgM8gRZiy4mw6xEzqc4bawBAqTTrss6OVvH+qzN4VtD/4ojMHoEjolb2ynjQFHDct+HHXz1LxyZNb7RP4tNxkrrEvMO/Yn+HUk7v3exg==;25:AJ6qLqWHZz9hYYwPEjfdII/47/9yiTvwuLNyhcXJznKwzn8U3TauCEA8dhOAtvP9p3yvS05xZ2elEScicUBzhJg01bGww5rYzgRiTBRgsSPxfj2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CV9gI8hedwlxXFwY7tX+zZSi7w1PWNfeqS22CtOyj7Ug2WESwgFtVTOjTh4Esw X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(192813158149592); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(8121501046)(520078)(10201501046)(3002001);SRVR:BL2FFO11HUB034;BCL:0;PCL:0;RULEID:;SRVR:BL2FFO11HUB034; X-Forefront-PRVS: 0751474A44 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BL2FFO11HUB034;23:i6vX350iKANncXeMjYHWauoHSrj7Hv+1E6eBHBxI?= =?us-ascii?Q?PJVyImnp+aK6gjD8p8d/eCgWhmvAbQRzOwa/0i9qWklQF8/NQrp9lPTV5mtU?= =?us-ascii?Q?7rzNL4MuwB/fnDp+K1z+pxYua6vH8/8uKDOwjX6cYx5eNxDtPZGmzG+VMU9p?= =?us-ascii?Q?azD4ZE8WUAZhFKukske61TahkG+AYUJG92flTGJ92B6Bgt3wbJr6jNTdUuFd?= =?us-ascii?Q?JLX3Tvcq50vxPIPyNbn5fa7Gt/TGnmDtRpLJRpEOz6mjfZU6BMbpZe6jWTZm?= =?us-ascii?Q?reSMC9Ephq9hUr49tmza2QzhXBbM/Hn5SvI4TvxD/b9yBb9fR+cdBsoTPvOS?= =?us-ascii?Q?yiHGPMUCWRFdfycdZ1vPhCq/wO/VHg27Lmvgzmx3Csh46H95Ulh3X6uXiaST?= =?us-ascii?Q?sChSwsBqNsYBsK1D+eNzBj0KpmvpZ21kx2yrlBntEcrZCe9+5xWHwzH8SxVS?= =?us-ascii?Q?q6Ysw7rwBP6hnDhpURc5ggc2hyLhcqgxxiBXysVxb+xtH8x3GEGw3QysgAMB?= =?us-ascii?Q?6gWJZxbVbYbL/9p1+I1pe+QRVhU1QC63kF+afw9R+it42ReOuhsFCo/HDuoW?= =?us-ascii?Q?/dlEE+SK1YTgfhMlUlrV4LuW5ZTnDUcXpjGwlffnkkN7l2+nuTT8VSdvH2n9?= =?us-ascii?Q?fqte+YCK/g/+tf0D2X+KigWRqF7L5tOPd3Wm51Wm1QiX1hYShW+kZWyXa1qN?= =?us-ascii?Q?OsdG54aOHSg5VKehxQz9/Ata42Hgbaf6CUpnrVl2m5EE1Wxzxi2V1JkvUoIf?= =?us-ascii?Q?cpQ/YZIkDVrX2nmDCpPJ+K/LjPv6+8j5+x0cKTAwD5Z/US28t/xekCHy2GY+?= =?us-ascii?Q?H/fbUZW4+R1YnX11+bn1L+cBoNz3bsECGUX8XKgUkNwfxSSqC/9JJcUfpNi1?= =?us-ascii?Q?7thxNSyo7q6I9qOat6xw2Gc/5eOZP3HhBtvOa/sRzardFCn7iE7G1PKQPx2e?= =?us-ascii?Q?7pDmWs/tVMzrN0xgY4WvPhEoaRPjPt5JyZDLEQkkIIHA/3pVmgscV9S7d8mV?= =?us-ascii?Q?MHzH6oAyBSO/6DBcSFHOc03/sPJ0ORqAAa9Y7Oly5nWwJnLPRZUwzmj1cnBp?= =?us-ascii?Q?rNErl/OQJZ7gfE/spN/TT8ntJuvc7myC/xp2K0GHA4ZqBkSLuqaTh8WZKj3B?= =?us-ascii?Q?sGylnDD8GD8=3D?= X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11HUB034;5:IqY++QQMj/RJXAXSvNLIFEFzeFnoh7nvDI9ECOrmHyM0CU46PZFxuSceOV3l6jFO1t2quh/m/yTB1PJ1pKQk+dmiPsK4+ahi09i6hr2/Jze1rfZFH1jz9L4dwqptKPskFeLQojew1unM4h/bz7HYeA==;24:tHssiKpkVJkifOpkac+Fzedv+nqfc5N7LQKrlA418/BWl5BDgy4BeQj+2Tivu2HGpvvsUsSXbauX+DRUNkJExwZynnXonVCu3TfgqBPtHME= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2015 07:21:36.1028 (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.83];Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2FFO11HUB034 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2401 Lines: 73 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 --- v2: - remove unused variable --- drivers/tty/serial/xilinx_uartps.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index 50d4082d2354..2c98c357d9a0 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -945,12 +945,10 @@ static void cdns_uart_set_mctrl(struct uart_port *port, unsigned int mctrl) #ifdef CONFIG_CONSOLE_POLL 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,19 +957,16 @@ 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; } 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 +981,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/