From patchwork Fri Aug 21 18:02:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 7053421 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CC893C05AC for ; Fri, 21 Aug 2015 18:04:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EA77820380 for ; Fri, 21 Aug 2015 18:04:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E01BB203B4 for ; Fri, 21 Aug 2015 18:04:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752163AbbHUSD5 (ORCPT ); Fri, 21 Aug 2015 14:03:57 -0400 Received: from michel.telenet-ops.be ([195.130.137.88]:35570 "EHLO michel.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752038AbbHUSDX (ORCPT ); Fri, 21 Aug 2015 14:03:23 -0400 Received: from ayla.of.borg ([84.193.93.87]) by michel.telenet-ops.be with bizsmtp id 7W3J1r0051t5w8s06W3Jtw; Fri, 21 Aug 2015 20:03:22 +0200 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.82) (envelope-from ) id 1ZSqer-0007oG-M9; Fri, 21 Aug 2015 20:03:17 +0200 Received: from geert by ramsan with local (Exim 4.82) (envelope-from ) id 1ZSqet-0001q6-GQ; Fri, 21 Aug 2015 20:03:19 +0200 From: Geert Uytterhoeven To: Greg Kroah-Hartman , Jiri Slaby Cc: Magnus Damm , Yoshihiro Shimoda , Laurent Pinchart , Nobuhiro Iwamatsu , Yoshihiro Kaneko , Kazuya Mizuguchi , Koji Matsuoka , Wolfram Sang , Guennadi Liakhovetski , linux-serial@vger.kernel.org, linux-sh@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v3 15/33] serial: sh-sci: Handle DMA init failures inside sci_request_dma() Date: Fri, 21 Aug 2015 20:02:39 +0200 Message-Id: <1440180177-6924-16-git-send-email-geert+renesas@glider.be> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1440180177-6924-1-git-send-email-geert+renesas@glider.be> References: <1440180177-6924-1-git-send-email-geert+renesas@glider.be> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Let sci_request_dma() handle failures to initialize DMA itself. This way sci_tx_dma_release() and sci_rx_dma_release() don't have to consider partial initialization, and thus don't need to reset DMA addresses to DMA_ERROR_CODE, which is not 100% portable access architectures. Signed-off-by: Geert Uytterhoeven --- v3: - New. --- drivers/tty/serial/sh-sci.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index cfef543df25271f5..ea6ab6173ce9f239 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -1371,9 +1371,8 @@ static void sci_rx_dma_release(struct sci_port *s, bool enable_pio) s->chan_rx = NULL; s->cookie_rx[0] = s->cookie_rx[1] = -EINVAL; dma_release_channel(chan); - if (sg_dma_address(&s->sg_rx[0])) - dma_free_coherent(port->dev, s->buf_len_rx * 2, - sg_virt(&s->sg_rx[0]), sg_dma_address(&s->sg_rx[0])); + dma_free_coherent(port->dev, s->buf_len_rx * 2, + sg_virt(&s->sg_rx[0]), sg_dma_address(&s->sg_rx[0])); if (enable_pio) sci_start_rx(port); } @@ -1709,7 +1708,8 @@ static void sci_request_dma(struct uart_port *port) nent = dma_map_sg(port->dev, &s->sg_tx, 1, DMA_TO_DEVICE); if (!nent) { dev_warn(port->dev, "Failed mapping Tx DMA descriptor\n"); - sci_tx_dma_release(s, false); + dma_release_channel(chan); + s->chan_tx = NULL; } else { dev_dbg(port->dev, "%s: mapped %d@%p to %pad\n", __func__, @@ -1743,7 +1743,9 @@ static void sci_request_dma(struct uart_port *port) if (!buf[0]) { dev_warn(port->dev, "Failed to allocate Rx dma buffer, using PIO\n"); - sci_rx_dma_release(s, true); + dma_release_channel(chan); + s->chan_rx = NULL; + sci_start_rx(port); return; }