From patchwork Sun Jun 14 17:27:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Kaneko X-Patchwork-Id: 6605201 X-Patchwork-Delegate: horms@verge.net.au 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 0B2ADC0020 for ; Sun, 14 Jun 2015 17:28:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1AF5B203ED for ; Sun, 14 Jun 2015 17:28:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1001E2039D for ; Sun, 14 Jun 2015 17:27:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752445AbbFNR16 (ORCPT ); Sun, 14 Jun 2015 13:27:58 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:35819 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751961AbbFNR15 (ORCPT ); Sun, 14 Jun 2015 13:27:57 -0400 Received: by pacyx8 with SMTP id yx8so50827737pac.2; Sun, 14 Jun 2015 10:27:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=3EGCzAK4doi6Z3UgWw3kWXP0WC/x0w3DoCl/BN3O4Fo=; b=ggUKjyl8qwWgsV2LGNhWQMFmq+lFEWZhdDbBQkh3CBNjWYT0uQB7v7iTVUvQEBzZYQ fpepUIPF4LgUj+sFgiCvkDW3Wp1WK0r9pzxy9kImqpNoeOxHYHkOnS+dSye2XkcQGVGG AKHaqH/YZkSjA3TM0+wKsUrh2h5+pRjgrSHR60cck2i3jw8+LTtdeAA9uJJ9mz6zeqti HQEw3xyq85RPqNI6ddqkAgypq3UNSEBezR/nvNvHJV+etQCs1W5Hx2F9+plTw7RAcfh4 gcOcArcZqrYfW3Kd8xkr3QkTokuTKWW1KK2We28gvbw0Sts6sZbw332vc13cfiDkuj4L QJGg== X-Received: by 10.68.131.196 with SMTP id oo4mr40504126pbb.119.1434302877527; Sun, 14 Jun 2015 10:27:57 -0700 (PDT) Received: from localhost.localdomain (KD118152108246.ppp-bb.dion.ne.jp. [118.152.108.246]) by mx.google.com with ESMTPSA id pw7sm9752467pab.40.2015.06.14.10.27.55 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 14 Jun 2015 10:27:56 -0700 (PDT) From: Yoshihiro Kaneko To: linux-serial@vger.kernel.org Cc: Greg Kroah-Hartman , Simon Horman , Magnus Damm , linux-sh@vger.kernel.org Subject: [PATCH/RFC] serial: sh-sci: Fix exclusion of work_fn_rx and sci_dma_rx_complete Date: Mon, 15 Jun 2015 02:27:19 +0900 Message-Id: <1434302839-31216-1-git-send-email-ykaneko0929@gmail.com> X-Mailer: git-send-email 1.9.1 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.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 From: Kazuya Mizuguchi There is a problem when the sci_dma_rx_complete() is processed before cancel process of work_fn_rx() completes by rx_timer_fn(). This patch locks work_fn_rx(). Signed-off-by: Kazuya Mizuguchi Signed-off-by: Yoshihiro Kaneko --- This patch is based on the tty-next branch of Greg Kroah-Hartman's tty tree. drivers/tty/serial/sh-sci.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index b74a644..ef59842 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -1423,14 +1423,16 @@ static void work_fn_rx(struct work_struct *work) struct uart_port *port = &s->port; struct dma_async_tx_descriptor *desc; int new; + unsigned long flags; + spin_lock_irqsave(&port->lock, flags); if (s->active_rx == s->cookie_rx[0]) { new = 0; } else if (s->active_rx == s->cookie_rx[1]) { new = 1; } else { dev_err(port->dev, "cookie %d not found!\n", s->active_rx); - return; + goto out; } desc = s->desc_rx[new]; @@ -1440,36 +1442,35 @@ static void work_fn_rx(struct work_struct *work) struct dma_chan *chan = s->chan_rx; struct shdma_desc *sh_desc = container_of(desc, struct shdma_desc, async_tx); - unsigned long flags; int count; dmaengine_terminate_all(chan); dev_dbg(port->dev, "Read %zu bytes with cookie %d\n", sh_desc->partial, sh_desc->cookie); - spin_lock_irqsave(&port->lock, flags); count = sci_dma_rx_push(s, sh_desc->partial); - spin_unlock_irqrestore(&port->lock, flags); if (count) tty_flip_buffer_push(&port->state->port); sci_submit_rx(s); - return; + goto out; } s->cookie_rx[new] = desc->tx_submit(desc); if (s->cookie_rx[new] < 0) { dev_warn(port->dev, "Failed submitting Rx DMA descriptor\n"); sci_rx_dma_release(s, true); - return; + goto out; } s->active_rx = s->cookie_rx[!new]; dev_dbg(port->dev, "%s: cookie %d #%d, new active #%d\n", __func__, s->cookie_rx[new], new, s->active_rx); +out: + spin_unlock_irqrestore(&port->lock, flags); } static void work_fn_tx(struct work_struct *work)