From patchwork Thu May 21 00:34:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 6451131 Return-Path: X-Original-To: patchwork-dmaengine@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 797879F318 for ; Thu, 21 May 2015 00:34:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9592020131 for ; Thu, 21 May 2015 00:34:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1F22520123 for ; Thu, 21 May 2015 00:34:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752874AbbEUAeZ (ORCPT ); Wed, 20 May 2015 20:34:25 -0400 Received: from mailout3.w1.samsung.com ([210.118.77.13]:47893 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752819AbbEUAeY (ORCPT ); Wed, 20 May 2015 20:34:24 -0400 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout3.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NOO00EG9C99LW60@mailout3.w1.samsung.com>; Thu, 21 May 2015 01:34:21 +0100 (BST) X-AuditID: cbfec7f4-f79c56d0000012ee-3d-555d280d941f Received: from eusync4.samsung.com ( [203.254.199.214]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id EC.1C.04846.D082D555; Thu, 21 May 2015 01:34:21 +0100 (BST) Received: from localhost.localdomain ([10.252.80.64]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NOO00IYIC8Z3L00@eusync4.samsung.com>; Thu, 21 May 2015 01:34:21 +0100 (BST) From: Krzysztof Kozlowski To: Dan Williams , Vinod Koul , dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Krzysztof Kozlowski , stable@vger.kernel.org, Dinh Nguyen Subject: [PATCH] dmaengine: pl330: Fix hang on dmaengine_terminate_all on certain boards Date: Thu, 21 May 2015 09:34:09 +0900 Message-id: <1432168449-18850-1-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrGJMWRmVeSWpSXmKPExsVy+t/xa7q8GrGhBi9PMVtMn3qB0WLVpzXM Fqun/mW1eP3C0OLyrjlsFgs2PmK0eNm3n8WB3WPxnpdMHv3XJrF79G1ZxejxeZNcAEsUl01K ak5mWWqRvl0CV8bpzy/ZCybzVZztnMzawDiRp4uRk0NCwESiufcLG4QtJnHh3nogm4tDSGAp o8SO592MIAkhgf+MElMn1IHYbALGEpuXLwErEhHoZJT4OPkkK0iCWaBS4tOt/ewgtrBAlMTB SSeZQWwWAVWJc1MhNvAKuEvcPbyFGWKbnMTJY5NZJzByL2BkWMUomlqaXFCclJ5rqFecmFtc mpeul5yfu4kREhpfdjAuPmZ1iFGAg1GJh/fEoehQIdbEsuLK3EOMEhzMSiK859bHhArxpiRW VqUW5ccXleakFh9ilOZgURLnnbvrfYiQQHpiSWp2ampBahFMlomDU6qBkfGyGJukjQzjglN/ yvVOVXxbM2XSFaaawzcC9XYuYJa78ofnmaXO1+8Ft64L7l+/e07vGxGGHGfrh/VW29dzmPdd /Jz/IzP6xVIWkQdzOoRsJ5x8N/trw3PzbTW+DKtmVX7MVP8teyNK/pzpNq/bE0t9w5O3frLv qvYQ+Gz6zDnMes4h0cisrUosxRmJhlrMRcWJAOy4MDEJAgAA Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 The pl330 device could hang infinitely on certain boards when DMA channels are terminated. It was caused by lack of runtime resume when executing pl330_terminate_all() which calls the _stop() function. _stop() accesses device register and can loop infinitely while checking for device state. The hang was confirmed by Dinh Nguyen on Altera SOCFPGA Cyclone V board during boot. It can be also triggered with: $ echo 1 > /sys/module/dmatest/parameters/iterations $ echo dma1chan0 > /sys/module/dmatest/parameters/channel $ echo 1 > /sys/module/dmatest/parameters/run $ sleep 1 $ cat /sys/module/dmatest/parameters/run Reported-by: Dinh Nguyen Signed-off-by: Krzysztof Kozlowski Fixes: ae43b3289186 ("ARM: 8202/1: dmaengine: pl330: Add runtime Power Management support v12") Cc: Cc: Dinh Nguyen Tested-by: Dinh Nguyen --- drivers/dma/pl330.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index a7d9d3029b14..340f9e607cd8 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c @@ -2127,6 +2127,7 @@ static int pl330_terminate_all(struct dma_chan *chan) struct pl330_dmac *pl330 = pch->dmac; LIST_HEAD(list); + pm_runtime_get_sync(pl330->ddma.dev); spin_lock_irqsave(&pch->lock, flags); spin_lock(&pl330->lock); _stop(pch->thread); @@ -2151,6 +2152,8 @@ static int pl330_terminate_all(struct dma_chan *chan) list_splice_tail_init(&pch->work_list, &pl330->desc_pool); list_splice_tail_init(&pch->completed_list, &pl330->desc_pool); spin_unlock_irqrestore(&pch->lock, flags); + pm_runtime_mark_last_busy(pl330->ddma.dev); + pm_runtime_put_autosuspend(pl330->ddma.dev); return 0; }