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: 107326 Delivered-To: patches@linaro.org Received: by 10.140.101.44 with SMTP id t41csp3931772qge; Mon, 10 Jul 2017 13:53:51 -0700 (PDT) X-Received: by 10.98.30.194 with SMTP id e185mr15336156pfe.158.1499720031087; Mon, 10 Jul 2017 13:53:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499720031; cv=none; d=google.com; s=arc-20160816; b=OkwCZFlCsK7JPfZKcavVeYL4Il4TjCJtDzwdjIds7zOpDdDMzierrax1YZ56Bbqrib m8TmAVhRwe86qvxK/hLkvY/lgPf9K/q0CtSmPOY3TpVTfGOGMIbh/r/a6lYHY9r3wgf0 cQtGiryQtfLRfEhu6W7rCp1FeDdLDY1Zpb5dkZh+Wbd0YFjv+PYmyScHcOPwjHsn3/eV uGlpUOjQVNgLXEveCY4BFyqUNDNJtbkpEMIP0YMZEW3Q5Kjz1tykNg/IW01XpfJuGXoo Q8to04fduZE1BXvw9Wkv+R+/uHd4RUYmbVL2bcgrJeulpvRJ92cMU/zvfBqQQxX9xLST C/ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=4HKtQudWs36YCO5cbsjbBQrldBNoyUg1Es9PZP5hIa0=; b=nOlRj845T1/TysotVKaQNfJZvFOXCBbyjXxjaa+myjNqHRE/CzV9MrqP6T/abBFnUr mXCMX/DD7g6aYHaGY5c43GH8mYHjovI474QPJQALdIZOiEJcIKeWb+CHGZOSILfkn936 8cx6gUzC8398z0irfmUBuF7jC8r7U3V0O9v/BRqPK7cLPTAUEXy4ILk3lVnWiX045kd1 uKpo2DTGCOSl6lsE0Y9N5PJwScXWBQa51fkwLHzWygwHogYHdMvUegnvB+NSkXtYJsUf +xqgIm3Og7WWEBlAxPqdiJ9buE5pOWvYjMaLcgxqiI66rH9uPOgQI38U0bpzq6QDUNY9 u/jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=G+a+SyCy; spf=pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c00::22c as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-pf0-x22c.google.com (mail-pf0-x22c.google.com. [2607:f8b0:400e:c00::22c]) by mx.google.com with ESMTPS id z73si8549078pfi.49.2017.07.10.13.53.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Jul 2017 13:53:51 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c00::22c as permitted sender) client-ip=2607:f8b0:400e:c00::22c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.b=G+a+SyCy; spf=pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c00::22c as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-pf0-x22c.google.com with SMTP id c73so55670729pfk.2 for ; Mon, 10 Jul 2017 13:53:50 -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=tl+pEBQAqh7Wg+vqKABItfNKOCe9C/2m5/QO5RuG9Vb03gC8pZYMBcrX/P0maEyDzR VlbWo/mX0P/R5kxSU9aKMQY25r3P6b9lHxciUlVFQvW4wIJ+6O3+hiAf7Xx6Ca4XxVdo iNlb2ltA1iopNgnFeq8xJS/cwWAfu+5v1jAzjdBPpDg1FPG65zdS8Rq7WKUlhVuSKzRC D8e5f9xPOeZ/ATFoz6Yagqm21hGhoKV5Qwwv6ajUaUevaxK/4HMw4xKQSkzFz5KdRIm9 WzQ1RJw2TYNGhqitzgeGxuciUmGht61U2QHnd5HX71Cx/CGrO+mAQFryp/jiAgp0iBzx biMQ== X-Gm-Message-State: AIVw112QyaeeES/K0TWEtOY+8b8p3EbzYCeXh4ty8s4ZWlDmUnASWeAF 3DBHsrs3nAGp27Xn/Es= X-Received: by 10.98.159.16 with SMTP id g16mr46123742pfe.21.1499720030749; Mon, 10 Jul 2017 13:53:50 -0700 (PDT) Return-Path: 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 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 --- drivers/dma/k3dma.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) -- 2.7.4 Acked-by: Zhangfei Gao 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);