linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams@intel.com>
To: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, neilb@suse.de
Cc: akpm@linux-foundation.org, yur@emcraft.com,
	saeed.bishara@gmail.com, shannon.nelson@intel.com
Subject: [PATCH 2.6.23-rc7 2/3] async_tx: fix dma_wait_for_async_tx
Date: Thu, 20 Sep 2007 18:27:45 -0700	[thread overview]
Message-ID: <20070921012745.17157.18043.stgit@dwillia2-linux.ch.intel.com> (raw)
In-Reply-To: <20070921012141.17157.65717.stgit@dwillia2-linux.ch.intel.com>

Fix dma_wait_for_async_tx to not loop forever in the case where a
dependency chain is longer than two entries.  This condition will not
happen with current in-kernel drivers, but fix it for future drivers.

Found-by: Saeed Bishara <saeed.bishara@gmail.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---

 crypto/async_tx/async_tx.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/crypto/async_tx/async_tx.c b/crypto/async_tx/async_tx.c
index 0350071..bc18cbb 100644
--- a/crypto/async_tx/async_tx.c
+++ b/crypto/async_tx/async_tx.c
@@ -80,6 +80,7 @@ dma_wait_for_async_tx(struct dma_async_tx_descriptor *tx)
 {
 	enum dma_status status;
 	struct dma_async_tx_descriptor *iter;
+	struct dma_async_tx_descriptor *parent;
 
 	if (!tx)
 		return DMA_SUCCESS;
@@ -87,8 +88,15 @@ dma_wait_for_async_tx(struct dma_async_tx_descriptor *tx)
 	/* poll through the dependency chain, return when tx is complete */
 	do {
 		iter = tx;
-		while (iter->cookie == -EBUSY)
-			iter = iter->parent;
+
+		/* find the root of the unsubmitted dependency chain */
+		while (iter->cookie == -EBUSY) {
+			parent = iter->parent;
+			if (parent && parent->cookie == -EBUSY)
+				iter = iter->parent;
+			else
+				break;
+		}
 
 		status = dma_sync_wait(iter->chan, iter->cookie);
 	} while (status == DMA_IN_PROGRESS || (iter != tx));

  parent reply	other threads:[~2007-09-21  1:27 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-21  1:27 [PATCH 2.6.23-rc7 0/3] async_tx and md-accel fixes for 2.6.23 Dan Williams
2007-09-21  1:27 ` [PATCH 2.6.23-rc7 1/3] async_tx: usage documentation and developer notes Dan Williams
2007-09-21  3:46   ` Randy Dunlap
2007-09-21 13:05   ` Bill Davidsen
2007-09-21 15:25   ` [PATCH 2.6.23-rc7 1/3] async_tx: usage documentation and developernotes Nelson, Shannon
2007-09-21  1:27 ` Dan Williams [this message]
2007-09-21  1:27 ` [PATCH 2.6.23-rc7 3/3] raid5: fix ops_complete_biofill Dan Williams
2007-09-21 18:48 ` [PATCH 2.6.23-rc7 0/3] async_tx and md-accel fixes for 2.6.23 Andrew Morton
2007-09-21 20:52   ` Williams, Dan J
2007-09-22  0:10   ` Neil Brown
2007-09-22  0:45     ` Williams, Dan J

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070921012745.17157.18043.stgit@dwillia2-linux.ch.intel.com \
    --to=dan.j.williams@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=saeed.bishara@gmail.com \
    --cc=shannon.nelson@intel.com \
    --cc=yur@emcraft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).