OMAP: McBSP: Do not use extensive spin locks for dma_op_mode
Subsystems (2)
PATCH 1/1 OMAP: McBSP: Do not use extensive spin locks for dma_op_mode
The use of the spin lock, which supposed to protect the the dma_op_mode causing "INFO: inconsistent lock state" on playback start.
Remove the spin locks around the dma_op_mode, when it's purpuse is to protect the dma_op_mode.
--- arch/arm/plat-omap/mcbsp.c | 6 ------ 1 files changed, 0 insertions(+), 6 deletions(-)
arch/arm/plat-omap/mcbsp.c +0 -6
@@ -298,9 +298,7 @@ int omap_mcbsp_get_dma_op_mode(unsigned int id) } mcbsp =id_to_mcbsp_ptr (id); -spin_lock_irq (&mcbsp->lock); dma_op_mode = mcbsp->dma_op_mode; -spin_unlock_irq (&mcbsp->lock);return dma_op_mode; }
@@ -318,7 +316,6 @@ static inline void omap34xx_mcbsp_request(struct omap_mcbsp *mcbsp) syscon =OMAP_MCBSP_READ (mcbsp->io_base,SYSCON ); syscon &= ~(ENAWAKEUP |SIDLEMODE (0x03 ) |CLOCKACTIVITY (0x03 )); -spin_lock_irq (&mcbsp->lock);if (mcbsp->dma_op_mode ==MCBSP_DMA_MODE_THRESHOLD ) { syscon |= (ENAWAKEUP |SIDLEMODE (0x02 ) |CLOCKACTIVITY (0x02 ));
@@ -327,7 +324,6 @@ static inline void omap34xx_mcbsp_request(struct omap_mcbsp *mcbsp) }else { syscon |=SIDLEMODE (0x01 ); } -spin_unlock_irq (&mcbsp->lock);OMAP_MCBSP_WRITE (mcbsp->io_base,SYSCON , syscon); }
@@ -1145,9 +1141,7 @@ static ssize_t dma_op_mode_show(struct device *dev,ssize_t len =0 ;const char *const *s; -spin_lock_irq (&mcbsp->lock); dma_op_mode = mcbsp->dma_op_mode; -spin_unlock_irq (&mcbsp->lock);for (s = &dma_op_modes[i]; i <ARRAY_SIZE (dma_op_modes); s++, i++) {if (dma_op_mode == i)
Signature · 1 line
1.6.5.1
Quoted 8 lines · Ujfalusi Peter (Nokia-D/Tampere)
The use of the spin lock, which supposed to protect the the
dma_op_modecausing "INFO: inconsistent lock state" on playback start.
Remove the spin locks around thedma_op_mode, when it's purpuse is to protect thedma_op_mode.Signed-off-by Peter Ujfalusi <[email protected]>---
You may wish to double read the message above, as it's quite confusing =)
Otherwise, that spinlocking is highly unnecessary and things are far better without than with it. The only case it could be useful is in SMPs, but OMAPs are not such quite yet - and when they are, things will need to be re-though anyway.
- Eero
Quoted 9 lines · On Tuesday 27 October 2009 13:07:23 Nurkkala Eero.An (EXT-Offcode/Oulu) wrote:
On Tue, 2009-10-27 at 12:00 +0100, Ujfalusi Peter (Nokia-D/Tampere)
Quoted 6 lines · wrote:
The use of the spin lock, which supposed to protect the the
dma_op_modecausing "INFO: inconsistent lock state" on playback start.
Remove the spin locks around thedma_op_mode, when it's purpuse is to protect thedma_op_mode.
Quoted 5 lines
Quoted 2 lines
Signed-off-by Peter Ujfalusi <[email protected]>---
You may wish to double read the message above, as it's quite confusing =)
Yes it is ;)
I have left one spinlock around the dma_op_mode, when it also protects the mcbsp->active, so that is why that last sentence.
Signature · 1 line
Péter
Quoted 8 lines · Peter Ujfalusi
Quoted 2 lines · On Tuesday 27 October 2009 13:07:23 Nurkkala Eero.An (EXT-Offcode/Oulu) wrote:
You may wish to double read the message above, as it's quite confusing =)
Yes it is ;)
I have left one spinlock around thedma_op_mode, when it also protects themcbsp->active, so that is why that last sentence.
I have to confess that I'm still not entirely clear what the lock is supposed to be doing or why it's OK to drop it. I gather that it's just that dmap_on_mode() doesn't need a lock at all?
Quoted 6 lines · ext Mark Brown
Quoted 4 lines · Peter Ujfalusi
Quoted 2 lines · On Tuesday 27 October 2009 13:07:23 Nurkkala Eero.An (EXT-Offcode/Oulu) wrote:
You may wish to double read the message above, as it's quite confusing =)
Quoted 7 lines
Quoted 3 lines
Yes it is ;)
I have left one spinlock around thedma_op_mode, when it also protects themcbsp->active, so that is why that last sentence.I have to confess that I'm still not entirely clear what the lock is supposed to be doing or why it's OK to drop it. I gather that it's just that
dmap_on_mode()doesn't need a lock at all?
Mostly thinko's with this locking:
- spin_lock_irq(&mcbsp->lock);
dma_op_mode = mcbsp->dma_op_mode;- spin_unlock_irq(&mcbsp->lock);
return dma_op_mode;
--> same as
return mcbsp->dma_op_mode;
and worst, it's called from pcm_trigger() ->
so irqs are enabled -> lockdep isn't happy ->
so currently things are pretty much "broken".
- Eero
Quoted 4 lines · On Tuesday 27 October 2009 14:00:09 ext Mark Brown wrote:
I have to confess that I'm still not entirely clear what the lock is supposed to be doing or why it's OK to drop it. I gather that it's just that
dmap_on_mode()doesn't need a lock at all?
In my opinion it does not need a lock.
If the user space is so broken that it is doing different things in parallel, I would rather crash the kernel if it is possible to force someone to fix the mess upstairs.
But the lock is not needed, I think it was a result of over-engineering.
Signature · 5 lines
Péter -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 5 lines · On Tue, 27 Oct 2009 13:07:23 +0200 Eero Nurkkala <[email protected]>…
Otherwise, that spinlocking is highly unnecessary and things are far better without than with it. The only case it could be useful is in SMPs, but OMAPs are not such quite yet - and when they are, things will need to be re-though anyway.
Following commit is suggesting that mcbsp code *must* be SMP safe already now:
commit a5b92cc348299c20be215b9f4b50853ecfbf3864
Author: Syed Rafiuddin <[email protected]> Date: Tue Jul 28 18:57:10 2009 +0530
ARM: OMAP4: Add McBSP support
Signature · 1 line
Jarkko
Quoted 8 lines · On Tuesday 27 October 2009 16:00:00 ext Jarkko Nikula wrote:
On Tue, 27 Oct 2009 13:07:23 +0200
Quoted 4 lines · Eero Nurkkala
Otherwise, that spinlocking is highly unnecessary and things are far better without than with it. The only case it could be useful is in SMPs, but OMAPs are not such quite yet - and when they are, things will need to be re-though anyway.
Quoted 8 lines
Following commit is suggesting that mcbsp code *must* be SMP safe already now:
commit
a5b92cc348299c20be215b9f4b50853ecfbf3864Author: Syed Rafiuddin <[email protected]> Date: Tue Jul 28 18:57:10 2009 +0530ARM: OMAP4: Add McBSP support
Yeah, but I think this locking issue has nothing to do with SMP safe or not. On playback start in omap_mcbsp_request the mcbsp->free is cleared. Further modification to the dma_op_mode in dma_op_mode_store is not allowed if the mcbsp port is in use, thus the dma_op_mode is protected against change while the port is in use (ensuring that the mode is same in omap34xx_mcbsp_request and omap_mcbsp_get_dma_op_mode functions). This alone makes the use of spinlock around the dma_op_mode unnecessary.
Signature · 1 line
Péter
Quoted 18 lines · Ujfalusi Peter (Nokia-D/Tampere)
Quoted 8 lines · On Tuesday 27 October 2009 16:00:00 ext Jarkko Nikula wrote:
On Tue, 27 Oct 2009 13:07:23 +0200
Quoted 4 lines · Eero Nurkkala
Otherwise, that spinlocking is highly unnecessary and things are far better without than with it. The only case it could be useful is in SMPs, but OMAPs are not such quite yet - and when they are, things will need to be re-though anyway.
Quoted 8 lines
Following commit is suggesting that mcbsp code *must* be SMP safe already now:
commit
a5b92cc348299c20be215b9f4b50853ecfbf3864Author: Syed Rafiuddin <[email protected]> Date: Tue Jul 28 18:57:10 2009 +0530ARM: OMAP4: Add McBSP support
Quoted 8 lines
Yeah, but I think this locking issue has nothing to do with SMP safe or not. On playback start in
omap_mcbsp_requestthemcbsp->freeis cleared. Further modification to thedma_op_modeindma_op_mode_storeis not allowed if the mcbsp port is in use, thus thedma_op_modeis protected against change while the port is in use (ensuring that the mode is same inomap34xx_mcbsp_requestandomap_mcbsp_get_dma_op_modefunctions). This alone makes the use of spinlock around thedma_op_modeunnecessary.
Yeah, maybe I took the SMP safeness into play without looking any code, my bad =) I was remembering a different version of this McBSP thing, now that I looked into it, it looked different.
Right, I reviewed the code, and it was first looking really bad at sound/soc/omap/omap-mcbsp.c, where it calls omap_mcbsp_get_dma_op_mode() from different places. However, it's not an issue because in:arch/arm/plat-omap/mcbsp.c : dma_op_mode_store(),
the dma_op_mode is written only if the mcbsp is unoccupied. So it is SMP safe.
..and a single read is always atomic, so this is buggy code:
301 spin_lock_irq(&mcbsp->lock); 302 dma_op_mode = mcbsp->dma_op_mode; 303 spin_unlock_irq(&mcbsp->lock);
304
305 return dma_op_mode;
The spinlocks are unnecessary. In the above example, you get the same with just "return mcbsp->dma_op_mode;"
-> Peter's patch is a good cleanup.
Quoted 16 lines · On Wednesday 28 October 2009 08:53:34 Nurkkala Eero.An (EXT-Offcode/Oulu) wrote:
Yeah, maybe I took the SMP safeness into play without looking any code, my bad =) I was remembering a different version of this McBSP thing, now that I looked into it, it looked different.
Right, I reviewed the code, and it was first looking really bad at
sound/soc/omap/omap-mcbsp.c, where it callsomap_mcbsp_get_dma_op_mode()from different places. However, it's not an issue because in:arch/arm/plat-omap/mcbsp.c:dma_op_mode_store(),
thedma_op_modeis written only if the mcbsp is unoccupied. So it is SMP safe...and a single read is always atomic, so this is buggy code:
301 spin_lock_irq(&mcbsp->lock); 302 dma_op_mode = mcbsp->dma_op_mode; 303 spin_unlock_irq(&mcbsp->lock);
Quoted 7 lines
304
305 returndma_op_mode;The spinlocks are unnecessary. In the above example, you get the same with just "return
mcbsp->dma_op_mode;"-> Peter's patch is a good cleanup.
Jarkko: are we going to take this?
Signature · 1 line
Péter
Jarkko Nikula
Acked-byQuoted 7 lines · On Thu, 29 Oct 2009 08:35:51 +0200 Peter Ujfalusi <[email protected]>…
Quoted 4 lines
The spinlocks are unnecessary. In the above example, you get the same with just "return
mcbsp->dma_op_mode;"-> Peter's patch is a good cleanup.
Jarkko: are we going to take this?
Yep, you can have my
Quoted 6 lines · On Thursday 29 October 2009 09:15:24 ext Jarkko Nikula wrote:
On Thu, 29 Oct 2009 08:35:51 +0200
Quoted 3 lines · Peter Ujfalusi
Quoted 3 lines
The spinlocks are unnecessary. In the above example, you get the same with just "return
mcbsp->dma_op_mode;"
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
-> Peter's patch is a good cleanup.
Jarkko: are we going to take this?
Yep, you can have my
Acked-by Jarkko Nikula <[email protected]>
Just want to bring up this thread.
Should I resend the patch?
Signature · 5 lines
Péter -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 2 lines · Peter Ujfalusi
Just want to bring up this thread.
Should I resend the patch?
This is an arch/arm thing so I'd expect it to go via the OMAP tree.
Quoted 10 lines · On Wed, 28 Oct 2009 08:53:34 +0200 Eero Nurkkala <[email protected]>…
On Wed, 2009-10-28 at 06:52 +0100, Ujfalusi Peter (Nokia-D/Tampere)
Quoted 8 lines
Yeah, but I think this locking issue has nothing to do with SMP safe or not. On playback start in
omap_mcbsp_requestthemcbsp->freeis cleared. Further modification to thedma_op_modeindma_op_mode_storeis not allowed if the mcbsp port is in use, thus thedma_op_modeis protected against change while the port is in use (ensuring that the mode is same inomap34xx_mcbsp_requestandomap_mcbsp_get_dma_op_modefunctions). This alone makes the use of spinlock around thedma_op_modeunnecessary.
...
Quoted 7 lines
Right, I reviewed the code, and it was first looking really bad at
sound/soc/omap/omap-mcbsp.c, where it callsomap_mcbsp_get_dma_op_mode()from different places. However, it's not an issue because in:arch/arm/plat-omap/mcbsp.c:dma_op_mode_store(),
thedma_op_modeis written only if the mcbsp is unoccupied. So it is SMP safe.
...
Quoted 5 lines
The spinlocks are unnecessary. In the above example, you get the same with just "return
mcbsp->dma_op_mode;"-> Peter's patch is a good cleanup.
Yeah, agree, only now I looked the patch itself :-)
Sorry that I didn't express it clearly that my comment was a side note for general awareness that SMP's are becoming reality for ARMs as well than nak for Peter's patch.
According to defconfigs the OMAP4 will be the first commercial ARM SMP having mainline support (I count realview as development device):
grep 'CONFIG_SMP=y' -r arch/arm/configs/ arch/arm/configs/realview-smp_defconfig:CONFIG_SMP=y arch/arm/configs/omap_4430sdp_defconfig:CONFIG_SMP=y
Signature · 1 line
Jarkko
PATCH 1/1 OMAP: McBSP: Do not use extensive spin locks for dma_op_mode
In reply to Peter UjfalusiThis patch has been applied to the linux-omap
by youw fwiendly patch wobot.
Branch in linux-omap: for-next
Initial commit ID (Likely to change): e1d8daf0013a8c6dd9f53dbde4c80f4723dee85f
PatchWorks
http://patchwork.kernel.org/patch/56075/
Git (Likely to change, and takes a while to get mirrored)
http://git.kernel.org/?p=linux/kernel/git/tmlind/linux-omap-2.6.git;a=commit;h=e1d8daf0013a8c6dd9f53dbde4c80f4723dee85f