From patchwork Sat May 13 22:13:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Sverdlin X-Patchwork-Id: 9725451 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 5F3FC60387 for ; Sat, 13 May 2017 22:15:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 52F45288F3 for ; Sat, 13 May 2017 22:15:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 479CF288F9; Sat, 13 May 2017 22:15:56 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 D6DEE288F8 for ; Sat, 13 May 2017 22:15:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757648AbdEMWPy (ORCPT ); Sat, 13 May 2017 18:15:54 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:36597 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755053AbdEMWPv (ORCPT ); Sat, 13 May 2017 18:15:51 -0400 Received: by mail-lf0-f65.google.com with SMTP id h4so2683809lfj.3; Sat, 13 May 2017 15:15:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=txSh7ftmVV4uGu46feRGpDxoKKUp9jHHpU7BljtZrbM=; b=AmBQRl0C7m6Z1oDOLYSpYh0LjJtH2ZHjRQYROnAxNT/kTb4hZoVsFITCRYxH8FY1GW dQbhVutc4h6phRpSi+YUZRQiKdJCefsF07fxEpG/15NAseuXYzxFsVVxJFCJJxOCruRf 1oEfnsCdezAxHk9OgE9Kc87Jn5xFd3EJt74aO9kkl1QjlwDvUR/lgN3aQsvJSB3DYOqB NXcjuPekCvWS4H3kYSy8tcuMs6iNfX2OAEbuvmDRmbWDtUKDqp2/sx1bc2yraCMXIApW cbLoWwNb8cNOTP4NBw3LBFYOoMqcevewMfgNLWPS+tuXSZpXj9GjAVTtt3w1Ch2HO8Dg ZDcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=txSh7ftmVV4uGu46feRGpDxoKKUp9jHHpU7BljtZrbM=; b=G3YaIbrQrLNtGGWyZr6O/T/101YdgCM22ZfReBUROKMja26dyaKRjhE0pYynVIxnrR OLe1pApp00f75kTwmCwdTUK7J+RpP68b1iI4MGQs6OXfFFHKg0RS9VsgBBIARn4qj3+Q kh9F31FrZsZgJHnIsrYeK0i1lGL/XN4jXXv8ubIcnx0/bU2NNGuhyW+DQRl20Et+Eslf 2SOHBgxE/nsdEJ2A7vc6B1I1s0vISvpZ5ZTni1ZlhFyRy+NEZS+7M5EWAc+KOGCMBaDU 11V4lsDdmPfGXpGCm+3dTvLyDAh0ANtnoTK4/Be2rT27Xy370zSG9ZwpzWtKG75Rpfbv AJ5A== X-Gm-Message-State: AODbwcDh7LW4c5+cS5qUmuiM8pKP6nbuX2A9T02KnwYv6Eyml62eV2Q6 p1cSfIMB7aSE4g== X-Received: by 10.25.162.211 with SMTP id l202mr4621090lfe.147.1494713744695; Sat, 13 May 2017 15:15:44 -0700 (PDT) Received: from giga1.localdomain ([195.245.52.203]) by smtp.gmail.com with ESMTPSA id u24sm1301705ljd.34.2017.05.13.15.15.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 13 May 2017 15:15:44 -0700 (PDT) From: Alexander Sverdlin To: dmaengine@vger.kernel.org Cc: Alexander Sverdlin , Dan Williams , Vinod Koul , stable@vger.kernel.org Subject: [PATCH 2/2] dmaengine: ep93xx: Don't drain the transfers in terminate_all() Date: Sun, 14 May 2017 00:13:27 +0200 Message-Id: <20170513221327.10114-3-alexander.sverdlin@gmail.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170513221327.10114-1-alexander.sverdlin@gmail.com> References: <20170513221327.10114-1-alexander.sverdlin@gmail.com> Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As dmaengine.h suggests, device_terminate_all() "Aborts all transfers on a channel". Seems that no other driver tried to busy-wait and actually drain the data. Moreover, this happens with IRQs disabled, therefore induces huge latency: irqsoff latency trace v1.1.5 on 4.11.0 -------------------------------------------------------------------- latency: 39770 us, #57/57, CPU#0 | (M:preempt VP:0, KP:0, SP:0 HP:0) ----------------- | task: process-129 (uid:0 nice:0 policy:2 rt_prio:50) ----------------- => started at: _snd_pcm_stream_lock_irqsave => ended at: snd_pcm_stream_unlock_irqrestore _------=> CPU# / _-----=> irqs-off | / _----=> need-resched || / _---=> hardirq/softirq ||| / _--=> preempt-depth |||| / delay cmd pid ||||| time | caller \ / ||||| \ | / process-129 0d.s. 3us : _snd_pcm_stream_lock_irqsave process-129 0d.s1 9us : snd_pcm_stream_lock <-_snd_pcm_stream_lock_irqsave process-129 0d.s1 15us : preempt_count_add <-snd_pcm_stream_lock process-129 0d.s2 22us : preempt_count_add <-snd_pcm_stream_lock process-129 0d.s3 32us : snd_pcm_update_hw_ptr0 <-snd_pcm_period_elapsed process-129 0d.s3 41us : soc_pcm_pointer <-snd_pcm_update_hw_ptr0 process-129 0d.s3 50us : dmaengine_pcm_pointer <-soc_pcm_pointer process-129 0d.s3 58us+: snd_dmaengine_pcm_pointer_no_residue <-dmaengine_pcm_pointer process-129 0d.s3 96us : update_audio_tstamp <-snd_pcm_update_hw_ptr0 process-129 0d.s3 103us : snd_pcm_update_state <-snd_pcm_update_hw_ptr0 process-129 0d.s3 112us : xrun <-snd_pcm_update_state process-129 0d.s3 119us : snd_pcm_stop <-xrun process-129 0d.s3 126us : snd_pcm_action <-snd_pcm_stop process-129 0d.s3 134us : snd_pcm_action_single <-snd_pcm_action process-129 0d.s3 141us : snd_pcm_pre_stop <-snd_pcm_action_single process-129 0d.s3 150us : snd_pcm_do_stop <-snd_pcm_action_single process-129 0d.s3 157us : soc_pcm_trigger <-snd_pcm_do_stop process-129 0d.s3 166us : snd_dmaengine_pcm_trigger <-soc_pcm_trigger process-129 0d.s3 175us : ep93xx_dma_terminate_all <-snd_dmaengine_pcm_trigger process-129 0d.s3 182us : preempt_count_add <-ep93xx_dma_terminate_all process-129 0d.s4 189us*: m2p_hw_shutdown <-ep93xx_dma_terminate_all process-129 0d.s4 39472us : m2p_hw_setup <-ep93xx_dma_terminate_all ... rest skipped... process-129 0d.s. 40080us : => ep93xx_dma_tasklet => tasklet_action => __do_softirq => irq_exit => __handle_domain_irq => vic_handle_irq => __irq_usr => 0xb66c6668 Just abort the transfers and warn if the HW state is not what we expect. Signed-off-by: Alexander Sverdlin Cc: stable@vger.kernel.org --- drivers/dma/ep93xx_dma.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/dma/ep93xx_dma.c b/drivers/dma/ep93xx_dma.c index a3d946d2a8e1..e78d1fbf2179 100644 --- a/drivers/dma/ep93xx_dma.c +++ b/drivers/dma/ep93xx_dma.c @@ -345,19 +345,10 @@ static inline u32 m2p_channel_state(struct ep93xx_dma_chan *edmac) static void m2p_hw_shutdown(struct ep93xx_dma_chan *edmac) { - u32 control; - - control = readl(edmac->regs + M2P_CONTROL); - control &= ~(M2P_CONTROL_STALLINT | M2P_CONTROL_NFBINT); - m2p_set_control(edmac, control); - - while (m2p_channel_state(edmac) >= M2P_STATE_ON) - cpu_relax(); - m2p_set_control(edmac, 0); - while (m2p_channel_state(edmac) == M2P_STATE_STALL) - cpu_relax(); + while (m2p_channel_state(edmac) != M2P_STATE_IDLE) + dev_warn(chan2dev(edmac), "M2P: Not yet IDLE\n"); } static void m2p_fill_desc(struct ep93xx_dma_chan *edmac)