OMAP: Fix McBSP spin_lock deadlock
Subsystems (4)
PATCH v4 1/1 OMAP: Fix McBSP spin_lock deadlock
A spin_lock deadlock will occur when omap_mcbsp_request() is invoked.
omap_mcbsp_request()
\- clk_enable(mcbsp->clk) [takes and holds clockfw_lock]
\- omap2_clk_enable()
\- _omap2_clk_enable()
\- omap_mcbsp_clk_enable()
\- clk_enable(child clock) [tries for clockfw_lock again]mcbsp_clk is a virtual clock and it comprises several child clocks. when enable mcbsp_clk in omap_mcbsp_request(), the enable function of mcbsp_clk will enable its child clocks, then the deadlock occurs.
The solution is to remove the virtual clock and enable these child clocks in omap_mcbsp_request() directly.
--- arch/arm/mach-omap1/mcbsp.c | 98 ++------------------ arch/arm/mach-omap2/mcbsp.c | 150 +++++------------------------- arch/arm/plat-omap/include/mach/mcbsp.h | 6 +- arch/arm/plat-omap/mcbsp.c | 52 ++++++++--- 4 files changed, 78 insertions(+), 228 deletions(-)
arch/arm/mach-omap1/mcbsp.c +10 -88
@@ -26,81 +26,8 @@#define DPS_RSTCT2_PER_EN (1 << 0)#define DSP_RSTCT2_WD_PER_EN (1 << 1) -struct mcbsp_internal_clk { -struct clk clk; -struct clk **childs; -int n_childs; -}; -#if defined(CONFIG_ARCH_OMAP15XX ) || defined(CONFIG_ARCH_OMAP16XX ) -static void omap_mcbsp_clk_init (struct mcbsp_internal_clk *mclk) -{ -const char *clk_names[] = {"dsp_ck" ,"api_ck" ,"dspxor_ck" }; -int i; - - mclk->n_childs =ARRAY_SIZE (clk_names); - mclk->childs =kzalloc (mclk->n_childs *sizeof (struct clk *), -GFP_KERNEL ); - -for (i =0 ; i < mclk->n_childs; i++) { -/* We fake a platform device to get correct device id */ -struct platform_device pdev; - - pdev.dev.bus = &platform_bus_type; - pdev.id = mclk->clk.id; - mclk->childs[i] =clk_get (&pdev.dev, clk_names[i]); -if (IS_ERR (mclk->childs[i])) -printk (KERN_ERR "Could not get clock %s (%d).\n" , - clk_names[i], mclk->clk.id); - } -} - -static int omap_mcbsp_clk_enable (struct clk *clk) -{ -struct mcbsp_internal_clk *mclk =container_of (clk, - struct mcbsp_internal_clk, clk); -int i; - -for (i =0 ; i < mclk->n_childs; i++) -clk_enable (mclk->childs[i]); -return 0 ; -} - -static void omap_mcbsp_clk_disable (struct clk *clk) -{ -struct mcbsp_internal_clk *mclk =container_of (clk, - struct mcbsp_internal_clk, clk); -int i; - -for (i =0 ; i < mclk->n_childs; i++) -clk_disable (mclk->childs[i]); -} - -static struct mcbsp_internal_clk omap_mcbsp_clks[] = { - { - .clk = { - .name ="mcbsp_clk" , - .id =1 , - .enable = omap_mcbsp_clk_enable, - .disable = omap_mcbsp_clk_disable, - }, - }, - { - .clk = { - .name ="mcbsp_clk" , - .id =3 , - .enable = omap_mcbsp_clk_enable, - .disable = omap_mcbsp_clk_disable, - }, - }, -}; - -#define omap_mcbsp_clks_size ARRAY_SIZE(omap_mcbsp_clks) -#else -#define omap_mcbsp_clks_size 0 -static struct mcbsp_internal_clk __initdata *omap_mcbsp_clks; -static inline void omap_mcbsp_clk_init (struct mcbsp_internal_clk *mclk) -{ } +const char *clk_names[] = {"dsp_ck" ,"api_ck" ,"dspxor_ck" };#endif static void omap1_mcbsp_request (unsigned int id)
@@ -165,8 +92,9 @@ static struct omap_mcbsp_platform_data omap15xx_mcbsp_pdata[] = { .rx_irq = INT_McBSP1RX, .tx_irq = INT_McBSP1TX, .ops = &omap1_mcbsp_ops, - .clk_name = "mcbsp_clk", - }, + .clk_names = clk_names, + .num_clks = 3, + }, { .phys_base = OMAP1510_MCBSP2_BASE, .dma_rx_sync = OMAP_DMA_MCBSP2_RX,
@@ -182,7 +110,8 @@ static struct omap_mcbsp_platform_data omap15xx_mcbsp_pdata[] = { .rx_irq = INT_McBSP3RX, .tx_irq = INT_McBSP3TX, .ops = &omap1_mcbsp_ops, - .clk_name = "mcbsp_clk", + .clk_names = clk_names, + .num_clks = 3, }, };#define OMAP15XX_MCBSP_PDATA_SZ ARRAY_SIZE(omap15xx_mcbsp_pdata)
@@ -200,7 +129,8 @@ static struct omap_mcbsp_platform_data omap16xx_mcbsp_pdata[] = { .rx_irq = INT_McBSP1RX, .tx_irq = INT_McBSP1TX, .ops = &omap1_mcbsp_ops, - .clk_name = "mcbsp_clk", + .clk_names = clk_names, + .num_clks = 3, }, { .phys_base = OMAP1610_MCBSP2_BASE,
@@ -217,7 +147,8 @@ static struct omap_mcbsp_platform_data omap16xx_mcbsp_pdata[] = { .rx_irq = INT_McBSP3RX, .tx_irq = INT_McBSP3TX, .ops = &omap1_mcbsp_ops, - .clk_name = "mcbsp_clk", + .clk_names = clk_names, + .num_clks = 3, }, };#define OMAP16XX_MCBSP_PDATA_SZ ARRAY_SIZE(omap16xx_mcbsp_pdata)
@@ -228,15 +159,6 @@ static struct omap_mcbsp_platform_data omap16xx_mcbsp_pdata[] = {int __init omap1_mcbsp_init (void ) { -int i; - -for (i =0 ; i < omap_mcbsp_clks_size; i++) { -if (cpu_is_omap15xx () ||cpu_is_omap16xx ()) { -omap_mcbsp_clk_init (&omap_mcbsp_clks[i]); -clk_register (&omap_mcbsp_clks[i].clk); - } - } -if (cpu_is_omap730 ()) omap_mcbsp_count =OMAP730_MCBSP_PDATA_SZ ;if (cpu_is_omap15xx ())
arch/arm/mach-omap2/mcbsp.c +25 -125
234 lines not on this page · raw message
arch/arm/plat-omap/include/mach/mcbsp.h +4 -2
@@ -340,7 +340,8 @@ struct omap_mcbsp_platform_data {u8 dma_rx_sync, dma_tx_sync;u16 rx_irq, tx_irq;struct omap_mcbsp_ops *ops; -char const *clk_name; +char const **clk_names; +int num_clks; };struct omap_mcbsp {
@@ -372,7 +373,8 @@ struct omap_mcbsp {/* Protect the field .free, while checking if the mcbsp is in use */ spinlock_t lock;struct omap_mcbsp_platform_data *pdata; -struct clk *clk; +struct clk **clks; +int num_clks; };extern struct omap_mcbsp **mcbsp_ptr;extern int omap_mcbsp_count;
arch/arm/plat-omap/mcbsp.c +39 -13
109 lines not on this page · raw message
Signature · 1 line
1.5.6.3
Quoted 1 line · Stanley.Miao
4 files changed, 78 insertions(+), 228 deletions(-)
You know, I'm always predisposed to like bugfixes that delete more code than they add. ;)
--
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
Tony Lindgren
maintainerQuoted 5 lines · David Brownell
Quoted 1 line · Stanley.Miao
4 files changed, 78 insertions(+), 228 deletions(-)You know, I'm always predisposed to like bugfixes that delete more code than they add. ;)
Thanks Stanley, pushed to linux-omap at 2.6.29-rc1, omap-2.6.28, and added to omap-fixes queue for the mainline kernel.
Regards,
Tony
--
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