From patchwork Thu Jan 14 10:16:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 8030891 Return-Path: X-Original-To: patchwork-dmaengine@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 59FE5BEEE5 for ; Thu, 14 Jan 2016 10:14:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6940320461 for ; Thu, 14 Jan 2016 10:14:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 623D92045A for ; Thu, 14 Jan 2016 10:14:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753379AbcANKOq (ORCPT ); Thu, 14 Jan 2016 05:14:46 -0500 Received: from mail-pa0-f53.google.com ([209.85.220.53]:36848 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753013AbcANKOm (ORCPT ); Thu, 14 Jan 2016 05:14:42 -0500 Received: by mail-pa0-f53.google.com with SMTP id yy13so282042235pab.3; Thu, 14 Jan 2016 02:14:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:date:message-id:subject; bh=AYBUZcHI8Nq9kh3Wt5PeG6iKFtAs7F7mmIsEsIzVL30=; b=oZGutfUc/Ar9Gb9jH0Vffp1pvtHLew1YjgEEmH1xEs2kmP6yLX3lQTA+XOvsGyj+Yf HG8679j08gXKdPfYGkgzCqou/kx6Kj7n5VjbYlbWn6rMt03LxC0oWlpxo7xKKHbvzoAI NZfvBYbCFhWMl/TxDUngFrttZdSeheTrLz6crZbvNZ+y64x+9mlej3lVqYuPnxfjN87P bFsQLmtJGVNuMC7NGAXHsC/bwgfptDDWu20nLjvZuk26zHltnQN/YP34ouAoKL23gBF6 Opqos4N1yki+f/62VH8ieiiwFFK7GHtUT5mAqiPHcBORpKxEX54KUigx/WqwiCEViV5l X2JQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:date:message-id:subject; bh=AYBUZcHI8Nq9kh3Wt5PeG6iKFtAs7F7mmIsEsIzVL30=; b=mt3LilC8A/e8YyrTyJBIzmupUTcmvxu4+RWaM3c3Ag+iePUlM7hKi5ppgagXq0iUHl +DZVvleUrW1DEWC56dQP92Di0GBq/M1h+ENWe5aHMv6bUHinr9gOlym2ilXYvMvvB1EN VhbQ6wTlUoiWGNzcus2gMRy+1gpp1QPfyjIlmV0/eUeUAIAh0VTtzrm89PV1tqJ5LePG +YxqHgrdbDrtSdgUykjiyCBWPgtA3uGOQbKSYrTG09GqUnmmJ9qCe+A20aPCYD/C50Uu tORo+KBt5DI8AE8uAnAC7gUA5gpXcMMbNGsyjdEqmrCQYQshTwia0JGdwieTSdIiA/WH 9tZQ== X-Gm-Message-State: ALoCoQm3DDJj5QGBLjxTzlL/BLL2WeTaIFLmrwdP2PnVDToNp+9WYuQD/v4wNExGiqnik5lE96Y4XRnTznhI5hEzowGy69kYVA== X-Received: by 10.67.4.100 with SMTP id cd4mr4636561pad.59.1452766482132; Thu, 14 Jan 2016 02:14:42 -0800 (PST) Received: from [127.0.0.1] (s214090.ppp.asahi-net.or.jp. [220.157.214.90]) by smtp.gmail.com with ESMTPSA id ud10sm8246393pab.27.2016.01.14.02.14.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Jan 2016 02:14:40 -0800 (PST) From: Magnus Damm To: linux-kernel@vger.kernel.org Cc: laurent.pinchart+renesas@ideasonboard.com, geert+renesas@glider.be, linux-sh@vger.kernel.org, vinod.koul@intel.com, dmaengine@vger.kernel.org, horms+renesas@verge.net.au, Magnus Damm Date: Thu, 14 Jan 2016 19:16:53 +0900 Message-Id: <20160114101653.16562.42789.sendpatchset@little-apple> Subject: [PATCH/RFC] dmaengine: rcar-dmac: Use CAE/CAIR instead of error IRQ Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Spam-Status: No, score=-6.8 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=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 From: Magnus Damm While using SYS-DMAC together with the IPMMU it became evident that the shared error interrupt hooked up by rcar-dmac.c never got invoked but instead the per-channel CAE bit got set which in turn may generate a per-channel interrupt if CAIE is set. This patch removes the shared interrupt handler and instead simply enables CAIE and makes sure CAE gets cleared by the interrupt handler. Without enabling CAIE and clearing CAE the DMA transfer blocks forever in case of error. During normal operation it is hard to trigger error interrupts, but I have managed to trigger the SYS-DMAC error by using local IPMMU debug code that tracks active page table entries using the AF bit. This debug code results in rather high latencies which in turn makes the SYS-DMAC generate error interrupts. Tested on r8a7795 Salvator-X. Not for upstream merge - needs more discussion and testing on other SoCs. Not-Yet-Signed-off-by: Magnus Damm --- drivers/dma/sh/rcar-dmac.c | 60 ++------------------------------------------ 1 file changed, 3 insertions(+), 57 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe dmaengine" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- 0001/drivers/dma/sh/rcar-dmac.c +++ work/drivers/dma/sh/rcar-dmac.c 2016-01-14 18:16:23.040513000 +0900 @@ -808,23 +808,6 @@ static void rcar_dmac_stop(struct rcar_d rcar_dmac_write(dmac, RCAR_DMAOR, 0); } -static void rcar_dmac_abort(struct rcar_dmac *dmac) -{ - unsigned int i; - - /* Stop all channels. */ - for (i = 0; i < dmac->n_channels; ++i) { - struct rcar_dmac_chan *chan = &dmac->channels[i]; - - /* Stop and reinitialize the channel. */ - spin_lock(&chan->lock); - rcar_dmac_chan_halt(chan); - spin_unlock(&chan->lock); - - rcar_dmac_chan_reinit(chan); - } -} - /* ----------------------------------------------------------------------------- * Descriptors preparation */ @@ -864,7 +847,7 @@ static void rcar_dmac_chan_configure_des } desc->xfer_shift = ilog2(xfer_size); - desc->chcr = chcr | chcr_ts[desc->xfer_shift]; + desc->chcr = chcr | chcr_ts[desc->xfer_shift] | RCAR_DMACHCR_CAIE; } /* @@ -1427,6 +1410,8 @@ static irqreturn_t rcar_dmac_isr_channel spin_lock(&chan->lock); chcr = rcar_dmac_chan_read(chan, RCAR_DMACHCR); + if (chcr & RCAR_DMACHCR_CAE) + mask |= RCAR_DMACHCR_CAE; if (chcr & RCAR_DMACHCR_TE) mask |= RCAR_DMACHCR_DE; rcar_dmac_chan_write(chan, RCAR_DMACHCR, chcr & ~mask); @@ -1497,24 +1482,6 @@ static irqreturn_t rcar_dmac_isr_channel return IRQ_HANDLED; } -static irqreturn_t rcar_dmac_isr_error(int irq, void *data) -{ - struct rcar_dmac *dmac = data; - - if (!(rcar_dmac_read(dmac, RCAR_DMAOR) & RCAR_DMAOR_AE)) - return IRQ_NONE; - - /* - * An unrecoverable error occurred on an unknown channel. Halt the DMAC, - * abort transfers on all channels, and reinitialize the DMAC. - */ - rcar_dmac_stop(dmac); - rcar_dmac_abort(dmac); - rcar_dmac_init(dmac); - - return IRQ_HANDLED; -} - /* ----------------------------------------------------------------------------- * OF xlate and channel filter */ @@ -1693,8 +1660,6 @@ static int rcar_dmac_probe(struct platfo struct rcar_dmac *dmac; struct resource *mem; unsigned int i; - char *irqname; - int irq; int ret; dmac = devm_kzalloc(&pdev->dev, sizeof(*dmac), GFP_KERNEL); @@ -1732,25 +1697,6 @@ static int rcar_dmac_probe(struct platfo if (IS_ERR(dmac->iomem)) return PTR_ERR(dmac->iomem); - irq = platform_get_irq_byname(pdev, "error"); - if (irq < 0) { - dev_err(&pdev->dev, "no error IRQ specified\n"); - return -ENODEV; - } - - irqname = devm_kasprintf(dmac->dev, GFP_KERNEL, "%s:error", - dev_name(dmac->dev)); - if (!irqname) - return -ENOMEM; - - ret = devm_request_irq(&pdev->dev, irq, rcar_dmac_isr_error, 0, - irqname, dmac); - if (ret) { - dev_err(&pdev->dev, "failed to request IRQ %u (%d)\n", - irq, ret); - return ret; - } - /* Enable runtime PM and initialize the device. */ pm_runtime_enable(&pdev->dev); ret = pm_runtime_get_sync(&pdev->dev);