OMAP: McBSP: Minor issues
Subsystems (2)
cover OMAP: McBSP: Minor issues
From: Eero Nurkkala <[email protected]>
This patchset fixes a few minor issues:
- Keep McBSP fclk active when McBSP is active
- Enable/disable clocks at the proper location
PATCH 1/2 OMAP: McBSP: Always maintain McBSP fclk while active
From: Eero Nurkkala <[email protected]>
McBSP fclk must be maintained for the duration of audio playback or recording. Otherwise the fclk may get autogated when the PER96M clk is no longer required by other modules. This results in audio playback being hang. Fix this phenomenom by enabling the McBSP fclk clockactivity bit for the entire active duration of McBSP usage
--- arch/arm/plat-omap/include/mach/mcbsp.h | 1 + arch/arm/plat-omap/mcbsp.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-)
arch/arm/plat-omap/include/mach/mcbsp.h +1 -0
@@ -252,6 +252,7 @@#define RDISABLE 0x0001/********************** McBSP SYSCONFIG bit definitions ********************/ +#define CLOCKACTIVITY (value) ((value)<<8)#define SIDLEMODE (value) ((value)<<3)#define ENAWAKEUP 0x0004#define SOFTRST 0x0002
arch/arm/plat-omap/mcbsp.c +3 -3
@@ -248,8 +248,8 @@ int omap_mcbsp_request(unsigned int id)u16 w; w =OMAP_MCBSP_READ (mcbsp->io_base,SYSCON ); - w &= ~(ENAWAKEUP |SIDLEMODE (0x03 )); - w |= (ENAWAKEUP |SIDLEMODE (0x02 )); + w &= ~(ENAWAKEUP |SIDLEMODE (0x03 ) |CLOCKACTIVITY (0x03 )); + w |= (ENAWAKEUP |SIDLEMODE (0x02 ) |CLOCKACTIVITY (0x01 ));OMAP_MCBSP_WRITE (mcbsp->io_base,SYSCON , w);OMAP_MCBSP_WRITE (mcbsp->io_base,WAKEUPEN ,WAKEUPEN_ALL );
@@ -308,7 +308,7 @@ void omap_mcbsp_free(unsigned int id)u16 w; w =OMAP_MCBSP_READ (mcbsp->io_base,SYSCON ); - w &= ~(ENAWAKEUP |SIDLEMODE (0x03 )); + w &= ~(ENAWAKEUP |SIDLEMODE (0x03 ) |CLOCKACTIVITY (0x03 ));OMAP_MCBSP_WRITE (mcbsp->io_base,SYSCON , w); w =OMAP_MCBSP_READ (mcbsp->io_base,WAKEUPEN );
Signature · 1 line
1.5.2
PATCH 2/2 OMAP: McBSP: Do not enable or disable clocks on failed path
From: Eero Nurkkala <[email protected]>
McBSP clocks are being double enabled in the event the McBSP is already active. Also, they are unnecessarily disabled when there's no active McBSP in use. Fix this phenomenom by enabling and disabling the clocks at a proper location.
--- arch/arm/plat-omap/mcbsp.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
arch/arm/plat-omap/mcbsp.c +6 -6
@@ -226,9 +226,6 @@ int omap_mcbsp_request(unsigned int id)if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->request) mcbsp->pdata->ops->request (id); -for (i =0 ; i < mcbsp->num_clks; i++) -clk_enable (mcbsp->clks[i]); -spin_lock (&mcbsp->lock);if (!mcbsp->free) { dev_err(mcbsp->dev, "McBSP%d is currently in use\n",
@@ -240,6 +237,9 @@ int omap_mcbsp_request(unsigned int id) mcbsp->free =0 ;spin_unlock (&mcbsp->lock); +for (i =0 ; i < mcbsp->num_clks; i++) +clk_enable (mcbsp->clks[i]); +/* * Enable wakup behavior, smart idle and all wakeups * REVISIT: some wakeups may be unnecessary
@@ -319,9 +319,6 @@ void omap_mcbsp_free(unsigned int id)if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->free) mcbsp->pdata->ops->free (id); -for (i = mcbsp->num_clks -1 ; i >=0 ; i--) -clk_disable (mcbsp->clks[i]); -spin_lock (&mcbsp->lock);if (mcbsp->free) { dev_err(mcbsp->dev, "McBSP%d was not reserved\n",
@@ -333,6 +330,9 @@ void omap_mcbsp_free(unsigned int id) mcbsp->free =1 ;spin_unlock (&mcbsp->lock); +for (i = mcbsp->num_clks -1 ; i >=0 ; i--) +clk_disable (mcbsp->clks[i]); +if (mcbsp->io_type ==OMAP_MCBSP_IRQ_IO ) {/* Free IRQs */ free_irq (mcbsp->rx_irq, (void *)mcbsp);
Signature · 1 line
1.5.2
Re: [PATCH 2/2] OMAP: McBSP: Do not enable or disable clocks on failed path
Quoted 19 lines · On Mon, 9 Mar 2009 08:05:12 +0100 "Nurkkala Eero.An (EXT-Offcode/Oulu)"…
From: Eero Nurkkala <[email protected]>
McBSP clocks are being double enabled in the event the McBSP is already active. Also, they are unnecessarily disabled when there's no active McBSP in use. Fix this phenomenom by enabling and disabling the clocks at a proper location.
arch/arm/plat-omap/mcbsp.c +0
-3@@ -226,9 +226,6 @@ int omap_mcbsp_request(unsigned int id)if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->request) mcbsp->pdata->ops->request (id); -for (i =0 ; i < mcbsp->num_clks; i++) -clk_enable (mcbsp->clks[i]); -spin_lock (&mcbsp->lock);if (!mcbsp->free) { dev_err(mcbsp->dev, "McBSP%d is currently in use\n",
arch/arm/plat-omap/mcbsp.c int omap_mcbsp_request(unsigned int id) · line 242
Quoted 6 lines
arch/arm/plat-omap/mcbsp.c +3
-0@@ -240,6 +237,9 @@ int omap_mcbsp_request(unsigned int id) mcbsp->free =0 ;spin_unlock (&mcbsp->lock); +for (i =0 ; i < mcbsp->num_clks; i++) +clk_enable (mcbsp->clks[i]); +
Valid fix.
Quoted 11 lines
arch/arm/plat-omap/mcbsp.c +0
-3@@ -319,9 +319,6 @@ void omap_mcbsp_free(unsigned int id)if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->free) mcbsp->pdata->ops->free (id); -for (i = mcbsp->num_clks -1 ; i >=0 ; i--) -clk_disable (mcbsp->clks[i]); -spin_lock (&mcbsp->lock);if (mcbsp->free) { dev_err(mcbsp->dev, "McBSP%d was not reserved\n",
arch/arm/plat-omap/mcbsp.c void omap_mcbsp_free(unsigned int id) · line 335
Quoted 6 lines
arch/arm/plat-omap/mcbsp.c +3
-0@@ -333,6 +330,9 @@ void omap_mcbsp_free(unsigned int id) mcbsp->free =1 ;spin_unlock (&mcbsp->lock); +for (i = mcbsp->num_clks -1 ; i >=0 ; i--) +clk_disable (mcbsp->clks[i]); +
Race here? See, McBSP is marked free before disabling the clocks and thus omap_mcbsp_request can start enabling them. So should you keep clock disabling after test for mcbsp->free as here now but mark McBSP free only after clocks are disabled?
I think you should send this as an separate fix since this should go to the upstream also.
Jarkko
RE: [PATCH 2/2] OMAP: McBSP: Do not enable or disable clocks on failed path
Quoted 8 lines
Race here? See, McBSP is marked free before disabling the clocks and thus
omap_mcbsp_requestcan start enabling them. So should you keep clock disabling after test formcbsp->freeas here now but mark McBSP free only after clocks are disabled?I think you should send this as an separate fix since this should go to the upstream also.
Good comment... why do I always do everything in such a hurry, without thinking any =)
Either that or leave clock disabling within the spin_lock covered code? (probably risky business)
- Eero
Re: [PATCH 2/2] OMAP: McBSP: Do not enable or disable clocks on failed path
Quoted 5 lines · On Tue, 10 Mar 2009 19:43:40 +0100 "Nurkkala Eero.An (EXT-Offcode/Oulu)"…
Good comment... why do I always do everything in such a hurry, without thinking any =)
Either that or leave clock disabling within thespin_lockcovered code? (probably risky business)
Didn't check any deeply can clk_disable sleep in any case but anyway there is no need to cover it with spinlock so better to not hold the lock while disabling.
Jarkko
RE: [PATCH 2/2] OMAP: McBSP: Do not enable or disable clocks on failed path
Quoted 7 lines
Didn't check any deeply can
clk_disablesleep in any case but anyway there is no need to cover it with spinlock so better to not hold the lock while disabling.Jarkko
Actually, is there any room for the race? I remember someone saying the clk:s have counters, so:
1. If mcbsp is "taken", clks on;
- and at the same time, the previous mcbsp has been released, leaving clks off , clk counter decrements, nothing bad happens..
- Eero
Re: [PATCH 1/2] OMAP: McBSP: Always maintain McBSP fclk while active
In reply to [email protected]Quoted 10 lines · On Mon, 9 Mar 2009 08:05:11 +0100 "Nurkkala Eero.An (EXT-Offcode/Oulu)"…
From: Eero Nurkkala <[email protected]>
McBSP fclk must be maintained for the duration of audio playback or recording. Otherwise the fclk may get autogated when the PER96M clk is no longer required by other modules. This results in audio playback being hang. Fix this phenomenom by enabling the McBSP fclk clockactivity bit for the entire active duration of McBSP usage
...
Quoted 8 lines
arch/arm/plat-omap/mcbsp.c +1
-2w =OMAP_MCBSP_READ (mcbsp->io_base,SYSCON ); - w &= ~(ENAWAKEUP |SIDLEMODE (0x03 )); - w |= (ENAWAKEUP |SIDLEMODE (0x02 )); + w &= ~(ENAWAKEUP | SIDLEMODE(0x03) | CLOCKACTIVITY(
0x03));(quoted diff) +1
-0+ w |= (ENAWAKEUP | SIDLEMODE(0x02) | CLOCKACTIVITY(
0x01));OMAP_MCBSP_WRITE(mcbsp->io_base, SYSCON, w);
Looks like a valid change eventhough haven't tested the actual problem. Would it be possible with the PM branch and Beagle now?
Jarkko
Re: [PATCH 1/2] OMAP: McBSP: Always maintain McBSP fclk while active
Quoted 5 lines · Nikula Jarkko (Nokia-D/Helsinki)
Looks like a valid change eventhough haven't tested the actual problem. Would it be possible with the PM branch and Beagle now?
Jarkko
Now this appears to be inherently wrong =)
Read this:
http://marc.info/?l=linux-omap&m=123674373120880&w=2
(Of course I went in to mention "I am 100% certain the McBSP FCLK is the
bit 8" =)
- Eero
Re: [PATCH 1/2] OMAP: McBSP: Always maintain McBSP fclk while active
Quoted 9 lines · On Wed, 11 Mar 2009 06:48:10 +0100 "Nurkkala Eero.An (EXT-Offcode/Oulu)"…
Quoted 5 lines · Nikula Jarkko (Nokia-D/Helsinki)
Looks like a valid change eventhough haven't tested the actual problem. Would it be possible with the PM branch and Beagle now?
Jarkko
Quoted 9 lines
Now this appears to be inherently wrong =)
Read this:
http://marc.info/?l=linux-omap&m=123674373120880&w=2
(Of course I went in to mention "I am 100% certain the McBSP FCLK is the bit 8" =)
Ah, ok. I was also reviewing your patch with even some older TRM (but this was going to be updated anyway only into next TRM) :-)
Jarkko