From patchwork Mon Aug 7 06:21:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neeraj Upadhyay X-Patchwork-Id: 9884433 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 11C7560364 for ; Mon, 7 Aug 2017 06:21:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 015172844B for ; Mon, 7 Aug 2017 06:21:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E99BB2856B; Mon, 7 Aug 2017 06:21:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E6EA2844B for ; Mon, 7 Aug 2017 06:21:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752113AbdHGGVw (ORCPT ); Mon, 7 Aug 2017 02:21:52 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:52466 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751564AbdHGGVv (ORCPT ); Mon, 7 Aug 2017 02:21:51 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id D436C6072D; Mon, 7 Aug 2017 06:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1502086910; bh=gY+pGCLxKd8bk7a/YBIyaGLPOLWKBYk49yDeMeqzFO0=; h=From:To:Cc:Subject:Date:From; b=SxVJRoFFIz7U1xQ10T+dmCfK1EzjN1WqCwZLRgDg3mOfRbeKM25zDexIH6jTX+48Z +8xsUNj37M6XUwHnxpVphsz4EgxaRt4MxBgTXPazzwBsnyI4CfKKMs4rETpkvWPaTu zVWk9MMuEcfz1sPFhc7vJfi2ibLrrIA95JbkimCw= Received: from neeraju-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: neeraju@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 7F7236072C; Mon, 7 Aug 2017 06:21:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1502086910; bh=gY+pGCLxKd8bk7a/YBIyaGLPOLWKBYk49yDeMeqzFO0=; h=From:To:Cc:Subject:Date:From; b=SxVJRoFFIz7U1xQ10T+dmCfK1EzjN1WqCwZLRgDg3mOfRbeKM25zDexIH6jTX+48Z +8xsUNj37M6XUwHnxpVphsz4EgxaRt4MxBgTXPazzwBsnyI4CfKKMs4rETpkvWPaTu zVWk9MMuEcfz1sPFhc7vJfi2ibLrrIA95JbkimCw= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 7F7236072C Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=neeraju@codeaurora.org From: Neeraj Upadhyay To: andy.gross@linaro.org, david.brown@linaro.org, gregkh@linuxfoundation.org, jslaby@suse.com Cc: sboyd@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-serial@vger.kernel.org, sramana@codeaurora.org, Neeraj Upadhyay Subject: [PATCH] tty: serial: msm: Move request_irq to the end of startup Date: Mon, 7 Aug 2017 11:51:25 +0530 Message-Id: <1502086885-8390-1-git-send-email-neeraju@codeaurora.org> X-Mailer: git-send-email 1.9.1 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Move the request_irq() call to the end of the msm_startup(), so that we don't handle interrupts while msm_startup() is running. This avoids potential races while initialization is in progress. For example, consider below scenario where rx handler reads the intermediate value of dma->chan, set in msm_request_rx_dma(), and tries to do dma mapping, which results in data abort. uart_port_startup() msm_startup() request_irq() ... msm_request_rx_dma() ... dma->chan = dma_request_slave_channel_reason(dev, "rx"); msm_uart_irq() msm_handle_rx_dm() msm_start_rx_dma() dma->desc = dma_map_single() Signed-off-by: Neeraj Upadhyay Reviewed-by: Stephen Boyd --- drivers/tty/serial/msm_serial.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c index 6788e75..1db79ee 100644 --- a/drivers/tty/serial/msm_serial.c +++ b/drivers/tty/serial/msm_serial.c @@ -1175,11 +1175,6 @@ static int msm_startup(struct uart_port *port) snprintf(msm_port->name, sizeof(msm_port->name), "msm_serial%d", port->line); - ret = request_irq(port->irq, msm_uart_irq, IRQF_TRIGGER_HIGH, - msm_port->name, port); - if (unlikely(ret)) - return ret; - msm_init_clock(port); if (likely(port->fifosize > 12)) @@ -1206,7 +1201,21 @@ static int msm_startup(struct uart_port *port) msm_request_rx_dma(msm_port, msm_port->uart.mapbase); } + ret = request_irq(port->irq, msm_uart_irq, IRQF_TRIGGER_HIGH, + msm_port->name, port); + if (unlikely(ret)) + goto err_irq; + return 0; + +err_irq: + if (msm_port->is_uartdm) + msm_release_dma(msm_port); + + clk_disable_unprepare(msm_port->pclk); + clk_disable_unprepare(msm_port->clk); + + return ret; } static void msm_shutdown(struct uart_port *port)