Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp45763yba; Wed, 3 Apr 2019 04:15:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqwDa9kHJ9OoOrfOTuHZjM5Zz/UYyJJymwS+gGQI8YAQIiq4Y9N+ohlot+xQfiSiDZq9Q1MY X-Received: by 2002:a63:115c:: with SMTP id 28mr45661906pgr.270.1554290107882; Wed, 03 Apr 2019 04:15:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554290107; cv=none; d=google.com; s=arc-20160816; b=Arv6j+vtx4o3yssh3s7pG/Qd+a47gcdVjLQeCtxDNWKMgwZpRJXS1KwyZnlbfvPuer eN1tH/IIFpG5/0NcmGu+wZ9hVfqAImOtVlLdeY9Zc0m4PHW8Ffjw87c3myFSJ1mifFU7 UfRIH/Ub/NGHQDyz9hPbergNZ8wbgbt2ceZagmetVwG9Db+6yvnkbl6Pk+r5kf/rPAK4 n9sSMmtd9YeNiIIXtXLPuJjRo6OeR4zgk/wg5raXf4zOZWuORyP6/O8b/eI98qXWw89Q 740aSAv5DBG9saWIAn0net3qtU6QV2ucwyeABEFihtxORnFxXT3NkgFJvAIpdQJ/K49H EjqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=OfvDaAv8GsqT645AORbrbyOzrkI+gitHmeNw4nmA3AM=; b=LvEgm5jzihHqOTm45eZwcoFNFldM1ssZw40aD7bbDQnxIqagkGuzaLV9+dqK6/acIG b91jxFY+8YeiVNlcE9qHUirAFgB/9dRJvk/yIyinp3XkQmC9praeBtRTNajc7YGDLGvv Q+eJq+3UAEuxwu4C7Bl8+ipE2UOv5WqcPEL7N91OoGF2i5qxGbv8IjQTQxL8zB4KCQkZ QXD7wopUmVUt+z+LDwUIRkwnzgaLQI1TIehaKkOPs+B9/hoHmGkTphsvVp1jy1k3iIdF eTWfqxBQahDMpB0A5lzaOqK/WN8HKSSasIxu5JPnTa0LDhR7+B5KlVcwpzZRZ8FIeX8o j2Fg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r133si13712986pgr.175.2019.04.03.04.14.52; Wed, 03 Apr 2019 04:15:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726105AbfDCLOL (ORCPT + 99 others); Wed, 3 Apr 2019 07:14:11 -0400 Received: from regular1.263xmail.com ([211.150.70.200]:41570 "EHLO regular1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725935AbfDCLOL (ORCPT ); Wed, 3 Apr 2019 07:14:11 -0400 X-Greylist: delayed 364 seconds by postgrey-1.27 at vger.kernel.org; Wed, 03 Apr 2019 07:14:03 EDT Received: from sugar.zhang?rock-chips.com (unknown [192.168.167.131]) by regular1.263xmail.com (Postfix) with ESMTP id E0991340; Wed, 3 Apr 2019 19:07:49 +0800 (CST) X-263anti-spam: KSV:0;BIG:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ADDR-CHECKED4: 1 X-ABS-CHECKED: 1 X-SKE-CHECKED: 1 X-ANTISPAM-LEVEL: 2 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (postfix) whith ESMTP id P28126T140503458764544S1554289667356895_; Wed, 03 Apr 2019 19:07:48 +0800 (CST) X-IP-DOMAINF: 1 X-UNIQUE-TAG: <6d284068b4b942efcdd023b0604119b3> X-RL-SENDER: sugar.zhang@rock-chips.com X-SENDER: zxg@rock-chips.com X-LOGIN-NAME: sugar.zhang@rock-chips.com X-FST-TO: heiko@sntech.de X-SENDER-IP: 58.22.7.114 X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 From: Sugar Zhang To: heiko@sntech.de, broonie@kernel.org Cc: linux-rockchip@lists.infradead.org, Sugar Zhang , Vinod Koul , Dan Williams , dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] dmaengine: pl330: _stop: clear interrupt status Date: Wed, 3 Apr 2019 19:06:22 +0800 Message-Id: <1554289582-43695-1-git-send-email-sugar.zhang@rock-chips.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch kill instructs the DMAC to immediately terminate execution of a thread. and then clear the interrupt status, at last, stop generating interrupts for DMA_SEV. to guarantee the next dma start is clean. otherwise, one interrupt maybe leave to next start and make some mistake. we can reporduce the problem as follows: DMASEV: modify the event-interrupt resource, and if the INTEN sets function as interrupt, the DMAC will set irq HIGH to generate interrupt. write INTCLR to clear interrupt. DMA EXECUTING INSTRUCTS DMA TERMINATE | | | | ... _stop | | | spin_lock_irqsave DMASEV | | | | mask INTEN | | | DMAKILL | | | spin_unlock_irqrestore in above case, a interrupt was left, and if we unmask INTEN, the DMAC will set irq HIGH to generate interrupt. to fix this, do as follows: DMA EXECUTING INSTRUCTS DMA TERMINATE | | | | ... _stop | | | spin_lock_irqsave DMASEV | | | | DMAKILL | | | clear INTCLR | mask INTEN | | | spin_unlock_irqrestore Signed-off-by: Sugar Zhang --- drivers/dma/pl330.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index eec79fd..56695ff 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c @@ -966,6 +966,7 @@ static void _stop(struct pl330_thread *thrd) { void __iomem *regs = thrd->dmac->base; u8 insn[6] = {0, 0, 0, 0, 0, 0}; + u32 inten = readl(regs + INTEN); if (_state(thrd) == PL330_STATE_FAULT_COMPLETING) UNTIL(thrd, PL330_STATE_FAULTING | PL330_STATE_KILLING); @@ -978,10 +979,13 @@ static void _stop(struct pl330_thread *thrd) _emit_KILL(0, insn); - /* Stop generating interrupts for SEV */ - writel(readl(regs + INTEN) & ~(1 << thrd->ev), regs + INTEN); - _execute_DBGINSN(thrd, insn, is_manager(thrd)); + + /* clear the event */ + if (inten & (1 << thrd->ev)) + writel(1 << thrd->ev, regs + INTCLR); + /* Stop generating interrupts for SEV */ + writel(inten & ~(1 << thrd->ev), regs + INTEN); } /* Start doing req 'idx' of thread 'thrd' */ -- 2.7.4