From patchwork Mon Jul 10 20:53:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 9833789 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 527C060350 for ; Mon, 10 Jul 2017 20:53:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4264C1FFCA for ; Mon, 10 Jul 2017 20:53:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 32AF6265B9; Mon, 10 Jul 2017 20:53:53 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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 A14B01FFCA for ; Mon, 10 Jul 2017 20:53:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754447AbdGJUxw (ORCPT ); Mon, 10 Jul 2017 16:53:52 -0400 Received: from mail-pf0-f179.google.com ([209.85.192.179]:33367 "EHLO mail-pf0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752158AbdGJUxv (ORCPT ); Mon, 10 Jul 2017 16:53:51 -0400 Received: by mail-pf0-f179.google.com with SMTP id e7so55677232pfk.0 for ; Mon, 10 Jul 2017 13:53:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=4HKtQudWs36YCO5cbsjbBQrldBNoyUg1Es9PZP5hIa0=; b=G+a+SyCyQOTILRRVumGSnBUS9nyz1bk5mchouwuJbTOrKAGso2a21aL1IWj1yg6SUt vACk9Qvis5UIrR9U5iEJNtKPY8yaVx0u5U1CjZtYStHZnlasebmzWJEn1S6wHsAVtW+o Adp0bJOVQ+Wt6E2TodGQ9iqnv+auhwjkDC8pQ= 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; bh=4HKtQudWs36YCO5cbsjbBQrldBNoyUg1Es9PZP5hIa0=; b=bDBvj9QjWusbeJgKy3Fq1bdwdHl8h6BJbjiAEUaDlKVLs+xzYf9xAr6gZMbPuFKBp5 XP0kqFUSeprvgEqAyTu+btgGyNX0vfQro2CD3D+O8CLGWXYZK9okRkAFgeCYldiGEYIr +ti0Mfnowu/Yh+Cr3qDXJwllM6qnLb5dZqZuXz2Q36qZzj6Er9KNXWcWXHCEdtFRTnpd wyO1S5FMWHytZ+N+vQDOIlNye6FY/05HgFwT/mDwU1Kd+Q3wYDssMpE32USHRa6VpfFt D7e9842BIxFeoutSwAJPWQrCtFdZNASkXV2OVaZpTqIDaX13eiUj05zvW7VYYycdDQ9d PAqw== X-Gm-Message-State: AIVw112jDr64ld0WnHVh9gSmzLXNeJjY+krhbRO4zYpDms8RpARShmcE K7hg5JUIvDCYLusL X-Received: by 10.98.159.16 with SMTP id g16mr46123742pfe.21.1499720030749; Mon, 10 Jul 2017 13:53:50 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id z86sm27864535pfl.40.2017.07.10.13.53.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 10 Jul 2017 13:53:50 -0700 (PDT) From: John Stultz To: lkml Cc: Antonio Borneo , Vinod Koul , Dan Williams , Zhangfei Gao , dmaengine@vger.kernel.org, John Stultz Subject: [PATCH] dma: k3dma: Fix non-cyclic mode Date: Mon, 10 Jul 2017 13:53:43 -0700 Message-Id: <1499720023-6187-1-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Antonio Borneo Commit 36387a2b1f62b5c087c5fe6f0f7b23b94f722ad7 ("k3dma: Fix memory handling in preparation for cyclic mode") broke the logic around ds_run/ds_done in case of non-cyclic DMA. This went unnoticed as the only user of k3dma was the i2s audio driver, but with a patch set to enable dma on SPI, the issue cropped up. This patch resolves the issue by reverting part of the problematic commit. This patch has been tested to ensure both audio playback and SPI works fine using DMA and that no memory leak is present. Cc: Vinod Koul Cc: Dan Williams Cc: Zhangfei Gao Cc: dmaengine@vger.kernel.org Signed-off-by: Antonio Borneo [jstultz: Expanded commit message a bit] Signed-off-by: John Stultz Acked-by: Zhangfei Gao --- drivers/dma/k3dma.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/dma/k3dma.c b/drivers/dma/k3dma.c index 01e25c6..01d2a75 100644 --- a/drivers/dma/k3dma.c +++ b/drivers/dma/k3dma.c @@ -223,7 +223,6 @@ static irqreturn_t k3_dma_int_handler(int irq, void *dev_id) if (c && (tc1 & BIT(i))) { spin_lock_irqsave(&c->vc.lock, flags); vchan_cookie_complete(&p->ds_run->vd); - WARN_ON_ONCE(p->ds_done); p->ds_done = p->ds_run; p->ds_run = NULL; spin_unlock_irqrestore(&c->vc.lock, flags); @@ -274,13 +273,14 @@ static int k3_dma_start_txd(struct k3_dma_chan *c) */ list_del(&ds->vd.node); - WARN_ON_ONCE(c->phy->ds_run); - WARN_ON_ONCE(c->phy->ds_done); c->phy->ds_run = ds; + c->phy->ds_done = NULL; /* start dma */ k3_dma_set_desc(c->phy, &ds->desc_hw[0]); return 0; } + c->phy->ds_run = NULL; + c->phy->ds_done = NULL; return -EAGAIN; } @@ -722,11 +722,7 @@ static int k3_dma_terminate_all(struct dma_chan *chan) k3_dma_free_desc(&p->ds_run->vd); p->ds_run = NULL; } - if (p->ds_done) { - k3_dma_free_desc(&p->ds_done->vd); - p->ds_done = NULL; - } - + p->ds_done = NULL; } spin_unlock_irqrestore(&c->vc.lock, flags); vchan_dma_desc_free_list(&c->vc, &head);