[PATCH 08/12] DMAENGINE: be more explicit when freeing PL08X signals

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linus Walleij
Date: Tuesday, August 31, 2010 - 5:12 am

The signals connected to the PL08X physical channels shall not
be tangled up with the physical channels themselves. This gets
some reference counting right.

Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
---
 drivers/dma/amba-pl08x.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/amba-pl08x.c b/drivers/dma/amba-pl08x.c
index a99ad19..a7ce08e 100644
--- a/drivers/dma/amba-pl08x.c
+++ b/drivers/dma/amba-pl08x.c
@@ -449,7 +449,6 @@ static inline void pl08x_put_phy_channel(struct pl08x_driver_data *pl08x,
 	/* Mark it as free */
 	spin_lock_irqsave(&ch->lock, flags);
 	ch->serving = NULL;
-	ch->signal = -1;
 	spin_unlock_irqrestore(&ch->lock, flags);
 }
 
@@ -1100,8 +1099,10 @@ static void pl08x_tasklet(unsigned long data)
 		 * No more jobs, so free up the physical channel
 		 * Free any allocated signal on slave transfers too
 		 */
-		if ((phychan->signal >= 0) && pl08x->pd->put_signal)
+		if ((phychan->signal >= 0) && pl08x->pd->put_signal) {
 			pl08x->pd->put_signal(plchan);
+			phychan->signal = -1;
+		}
 		pl08x_put_phy_channel(pl08x, phychan);
 		plchan->phychan = NULL;
 	}
@@ -1193,6 +1194,7 @@ static int prep_phy_channel(struct pl08x_dma_chan *plchan,
 	 */
 	if ((txd->direction == DMA_FROM_DEVICE ||
 	     txd->direction == DMA_TO_DEVICE) &&
+	    ch->signal < 0 &&
 	    pl08x->pd->get_signal) {
 		ret = pl08x->pd->get_signal(plchan);
 		if (ret < 0) {
@@ -1653,8 +1655,10 @@ static int pl08x_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
 			 * signal
 			 */
 			if ((plchan->phychan->signal >= 0) &&
-			    pl08x->pd->put_signal)
+			    pl08x->pd->put_signal) {
 				pl08x->pd->put_signal(plchan);
+				plchan->phychan->signal = -1;
+			}
 			pl08x_put_phy_channel(pl08x, plchan->phychan);
 			plchan->phychan = NULL;
 		}
-- 
1.6.3.3

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[00/12] DMAENGINE: PL08X driver updates, Linus Walleij, (Tue Aug 31, 5:12 am)
[PATCH 07/12] DMAENGINE: add debugfs file for PL08X, Linus Walleij, (Tue Aug 31, 5:12 am)
[PATCH 08/12] DMAENGINE: be more explicit when freeing PL0 ..., Linus Walleij, (Tue Aug 31, 5:12 am)
[PATCH 11/12] DMAENGINE: let PL08X memcpy TXDs wait, Linus Walleij, (Tue Aug 31, 5:12 am)
Re: [00/12] DMAENGINE: PL08X driver updates, Linus Walleij, (Wed Sep 8, 7:26 am)
Re: [00/12] DMAENGINE: PL08X driver updates, Dan Williams, (Sat Sep 18, 11:52 am)
Re: [PATCH 11/12] DMAENGINE: let PL08X memcpy TXDs wait, Dan Williams, (Wed Sep 22, 9:59 pm)
Re: [PATCH 11/12] DMAENGINE: let PL08X memcpy TXDs wait, Linus Walleij, (Thu Sep 23, 12:39 am)
Re: [PATCH 11/12] DMAENGINE: let PL08X memcpy TXDs wait, Linus Walleij, (Thu Sep 23, 12:46 am)
Re: [PATCH 11/12] DMAENGINE: let PL08X memcpy TXDs wait, Dan Williams, (Thu Sep 23, 8:29 am)
Re: [PATCH 11/12] DMAENGINE: let PL08X memcpy TXDs wait, Dan Williams, (Thu Sep 23, 8:35 am)