Skip to contentSkip to conversation

ARM: mx5: Use clk_prepare_enable/clk_disable_unprepare

PATCH Applied Fabio Estevam 8 participants 34 messages May 25, 2012 – Jun 11, 2012

Subsystems (14)
lore
Share & tools
lore

Fabio Estevam

author reviewer
#0 lore raw

PATCH 1/15 ARM: mx5: Use clk_prepare_enable/clk_disable_unprepare

From: Fabio Estevam <[email protected]>

Prepare the clock before enabling it.

---
 arch/arm/mach-imx/mm-imx5.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-imx/mm-imx5.c +2 -2
index feeee17..fcad95c 100644
@@ -35,11 +35,11 @@ static void imx5_idle(void)
 			return;
 		clk_prepare(gpc_dvfs_clk);
 	}
-	clk_enable(gpc_dvfs_clk);
+	clk_prepare_enable(gpc_dvfs_clk);
 	mx5_cpu_lp_set(WAIT_UNCLOCKED_POWER_OFF);
 	if (!tzic_enable_wake())
 		cpu_do_idle();
-	clk_disable(gpc_dvfs_clk);
+	clk_disable_unprepare(gpc_dvfs_clk);
 }
 
 /*
Signature · 1 line
1.7.1
author reviewer
#1 lore raw

PATCH 2/15 ata: Use clk_prepare_enable/clk_disable_unprepare

From: Fabio Estevam <[email protected]>

Prepare the clock before enabling it.

---
 drivers/ata/pata_imx.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
drivers/ata/pata_imx.c +5 -5
index c5af97f..87bb05b 100644
@@ -118,7 +118,7 @@ static int __devinit pata_imx_probe(struct platform_device *pdev)
 		return PTR_ERR(priv->clk);
 	}
 
-	clk_enable(priv->clk);
+	clk_prepare_enable(priv->clk);
 
 	host = ata_host_alloc(&pdev->dev, 1);
 	if (!host)
@@ -162,7 +162,7 @@ static int __devinit pata_imx_probe(struct platform_device *pdev)
 				&pata_imx_sht);
 
 free_priv:
-	clk_disable(priv->clk);
+	clk_disable_unprepare(priv->clk);
 	clk_put(priv->clk);
 	return -ENOMEM;
 }
@@ -176,7 +176,7 @@ static int __devexit pata_imx_remove(struct platform_device *pdev)
 
 	__raw_writel(0, priv->host_regs + PATA_IMX_ATA_INT_EN);
 
-	clk_disable(priv->clk);
+	clk_disable_unprepare(priv->clk);
 	clk_put(priv->clk);
 
 	return 0;
@@ -194,7 +194,7 @@ static int pata_imx_suspend(struct device *dev)
 		__raw_writel(0, priv->host_regs + PATA_IMX_ATA_INT_EN);
 		priv->ata_ctl =
 			__raw_readl(priv->host_regs + PATA_IMX_ATA_CONTROL);
-		clk_disable(priv->clk);
+		clk_disable_unprepare(priv->clk);
 	}
 
 	return ret;
@@ -205,7 +205,7 @@ static int pata_imx_resume(struct device *dev)
 	struct ata_host *host = dev_get_drvdata(dev);
 	struct pata_imx_priv *priv = host->private_data;
 
-	clk_enable(priv->clk);
+	clk_prepare_enable(priv->clk);
 
 	__raw_writel(priv->ata_ctl, priv->host_regs + PATA_IMX_ATA_CONTROL);
 
Signature · 1 line
1.7.1
maintainer Acked-by on v1 2/15
#2 lore raw

Re: [PATCH 02/15] ata: Use clk_prepare_enable/clk_disable_unprepare

Quoted 7 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

Prepare the clock before enabling it.

Quoted 57 lines
---
 drivers/ata/pata_imx.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
drivers/ata/pata_imx.c +5 -5
index c5af97f..87bb05b 100644
@@ -118,7 +118,7 @@ static int __devinit pata_imx_probe(struct platform_device *pdev)
 		return PTR_ERR(priv->clk);
 	}
 
-	clk_enable(priv->clk);
+	clk_prepare_enable(priv->clk);
 
 	host = ata_host_alloc(&pdev->dev, 1);
 	if (!host)
@@ -162,7 +162,7 @@ static int __devinit pata_imx_probe(struct platform_device *pdev)
 				&pata_imx_sht);
 
 free_priv:
-	clk_disable(priv->clk);
+	clk_disable_unprepare(priv->clk);
 	clk_put(priv->clk);
 	return -ENOMEM;
 }
@@ -176,7 +176,7 @@ static int __devexit pata_imx_remove(struct platform_device *pdev)
 
 	__raw_writel(0, priv->host_regs + PATA_IMX_ATA_INT_EN);
 
-	clk_disable(priv->clk);
+	clk_disable_unprepare(priv->clk);
 	clk_put(priv->clk);
 
 	return 0;
@@ -194,7 +194,7 @@ static int pata_imx_suspend(struct device *dev)
 		__raw_writel(0, priv->host_regs + PATA_IMX_ATA_INT_EN);
 		priv->ata_ctl =
 			__raw_readl(priv->host_regs + PATA_IMX_ATA_CONTROL);
-		clk_disable(priv->clk);
+		clk_disable_unprepare(priv->clk);
 	}
 
 	return ret;
@@ -205,7 +205,7 @@ static int pata_imx_resume(struct device *dev)
 	struct ata_host *host = dev_get_drvdata(dev);
 	struct pata_imx_priv *priv = host->private_data;
 
-	clk_enable(priv->clk);
+	clk_prepare_enable(priv->clk);
 
 	__raw_writel(priv->ata_ctl, priv->host_regs + PATA_IMX_ATA_CONTROL);
 
Signature · 1 line
1.7.1
Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#4 lore raw

Re: [PATCH 02/15] ata: Use clk_prepare_enable/clk_disable_unprepare

Quoted 8 lines · Fabio Estevam

Jeff,

Quoted 5 lines · Sascha Hauer
Quoted 4 lines · Fabio Estevam

From: Fabio Estevam<[email protected]>

Prepare the clock before enabling it.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Can this be applied?

Just got back from Europe, and will get this in ASAP...

author reviewer
#5 lore raw

PATCH 3/15 hw_random: mxc-rnga: Use clk_prepare_enable/clk_disable_unprepare

In reply to Fabio Estevam

From: Fabio Estevam <[email protected]>

Prepare the clock before enabling it.

---
 drivers/char/hw_random/mxc-rnga.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/char/hw_random/mxc-rnga.c +2 -2
index 187c6be..6f20f56 100644
@@ -154,7 +154,7 @@ static int __init mxc_rnga_probe(struct platform_device *pdev)
 		goto out;
 	}
 
-	clk_enable(clk);
+	clk_prepare_enable(clk);
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res) {
@@ -196,7 +196,7 @@ err_ioremap:
 	release_mem_region(res->start, resource_size(res));
 
 err_region:
-	clk_disable(clk);
+	clk_disable_unprepare(clk);
 	clk_put(clk);
 
 out:
Signature · 1 line
1.7.1
maintainer
#6 lore raw

Re: [PATCH 03/15] hw_random: mxc-rnga: Use clk_prepare_enable/clk_disable_unprepare

Quoted 25 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

Prepare the clock before enabling it.

---
 drivers/char/hw_random/mxc-rnga.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/char/hw_random/mxc-rnga.c +1 -1
index 187c6be..6f20f56 100644
@@ -154,7 +154,7 @@ static int __init mxc_rnga_probe(struct platform_device *pdev)
 		goto out;
 	}
 
-	clk_enable(clk);
+	clk_prepare_enable(clk);
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res) {

drivers/char/hw_random/mxc-rnga.c err_ioremap: · line 199

Quoted 5 lines
drivers/char/hw_random/mxc-rnga.c +1 -1
@@ -196,7 +196,7 @@ err_ioremap:
 	release_mem_region(res->start, resource_size(res));
 
 err_region:
-	clk_disable(clk);
+	clk_disable_unprepare(clk);

You forgot the clk_disable_unprepare in the remove path.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
author reviewer
#7 lore raw

PATCH 4/15 dma: imx-sdma: Use clk_prepare_enable/clk_disable_unprepare

In reply to Fabio Estevam

From: Fabio Estevam <[email protected]>

Prepare the clock before enabling it.

---
 drivers/dma/imx-sdma.c |   28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)
drivers/dma/imx-sdma.c +14 -14
index fb4f499..b6174e6 100644
@@ -868,8 +868,8 @@ static int sdma_alloc_chan_resources(struct dma_chan *chan)
 	sdmac->peripheral_type = data->peripheral_type;
 	sdmac->event_id0 = data->dma_request;
 
-	clk_enable(sdmac->sdma->clk_ipg);
-	clk_enable(sdmac->sdma->clk_ahb);
+	clk_prepare_enable(sdmac->sdma->clk_ipg);
+	clk_prepare_enable(sdmac->sdma->clk_ahb);
 
 	ret = sdma_request_channel(sdmac);
 	if (ret)
@@ -906,8 +906,8 @@ static void sdma_free_chan_resources(struct dma_chan *chan)
 
 	dma_free_coherent(NULL, PAGE_SIZE, sdmac->bd, sdmac->bd_phys);
 
-	clk_disable(sdma->clk_ipg);
-	clk_disable(sdma->clk_ahb);
+	clk_disable_unprepare(sdma->clk_ipg);
+	clk_disable_unprepare(sdma->clk_ahb);
 }
 
 static struct dma_async_tx_descriptor *sdma_prep_slave_sg(
@@ -1180,14 +1180,14 @@ static void sdma_load_firmware(const struct firmware *fw, void *context)
 	addr = (void *)header + header->script_addrs_start;
 	ram_code = (void *)header + header->ram_code_start;
 
-	clk_enable(sdma->clk_ipg);
-	clk_enable(sdma->clk_ahb);
+	clk_prepare_enable(sdma->clk_ipg);
+	clk_prepare_enable(sdma->clk_ahb);
 	/* download the RAM image for SDMA */
 	sdma_load_script(sdma, ram_code,
 			header->ram_code_size,
 			addr->ram_code_start_addr);
-	clk_disable(sdma->clk_ipg);
-	clk_disable(sdma->clk_ahb);
+	clk_disable_unprepare(sdma->clk_ipg);
+	clk_disable_unprepare(sdma->clk_ahb);
 
 	sdma_add_scripts(sdma, addr);
 
@@ -1229,8 +1229,8 @@ static int __init sdma_init(struct sdma_engine *sdma)
 		return -ENODEV;
 	}
 
-	clk_enable(sdma->clk_ipg);
-	clk_enable(sdma->clk_ahb);
+	clk_prepare_enable(sdma->clk_ipg);
+	clk_prepare_enable(sdma->clk_ahb);
 
 	/* Be sure SDMA has not started yet */
 	writel_relaxed(0, sdma->regs + SDMA_H_C0PTR);
@@ -1283,14 +1283,14 @@ static int __init sdma_init(struct sdma_engine *sdma)
 	/* Initializes channel's priorities */
 	sdma_set_channel_priority(&sdma->channel[0], 7);
 
-	clk_disable(sdma->clk_ipg);
-	clk_disable(sdma->clk_ahb);
+	clk_disable_unprepare(sdma->clk_ipg);
+	clk_disable_unprepare(sdma->clk_ahb);
 
 	return 0;
 
 err_dma_alloc:
-	clk_disable(sdma->clk_ipg);
-	clk_disable(sdma->clk_ahb);
+	clk_disable_unprepare(sdma->clk_ipg);
+	clk_disable_unprepare(sdma->clk_ahb);
 	dev_err(sdma->dev, "initialisation failed with %d\n", ret);
 	return ret;
 }
Signature · 1 line
1.7.1
maintainer
#8 lore raw

Re: [PATCH 04/15] dma: imx-sdma: Use clk_prepare_enable/clk_disable_unprepare

Quoted 16 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

Prepare the clock before enabling it.

---
 drivers/dma/imx-sdma.c |   28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)
drivers/dma/imx-sdma.c +0 -0
index fb4f499..b6174e6 100644

drivers/dma/imx-sdma.c static int sdma_alloc_chan_resources(struct dma_chan *chan) · line 872

Quoted 7 lines
drivers/dma/imx-sdma.c +2 -2
@@ -868,8 +868,8 @@ static int sdma_alloc_chan_resources(struct dma_chan *chan)
 	sdmac->peripheral_type = data->peripheral_type;
 	sdmac->event_id0 = data->dma_request;
 
-	clk_enable(sdmac->sdma->clk_ipg);
-	clk_enable(sdmac->sdma->clk_ahb);
+	clk_prepare_enable(sdmac->sdma->clk_ipg);
+	clk_prepare_enable(sdmac->sdma->clk_ahb);

No, the clock already is prepared, see the probe function.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
author reviewer
#9 lore raw

PATCH v2 3/15 hw_random: mxc-rnga: Use clk_prepare_enable/clk_disable_unprepare

In reply to Fabio Estevam

From: Fabio Estevam <[email protected]>

Prepare the clock before enabling it.

---
Changes since v1:
- Add missing clk_disable_unprepare(clk) in the remove path

 drivers/char/hw_random/mxc-rnga.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/char/hw_random/mxc-rnga.c +3 -3
index 187c6be..430582c 100644
@@ -154,7 +154,7 @@ static int __init mxc_rnga_probe(struct platform_device *pdev)
 		goto out;
 	}
 
-	clk_enable(clk);
+	clk_prepare_enable(clk);
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res) {
@@ -196,7 +196,7 @@ err_ioremap:
 	release_mem_region(res->start, resource_size(res));
 
 err_region:
-	clk_disable(clk);
+	clk_disable_unprepare(clk);
 	clk_put(clk);
 
 out:
@@ -215,7 +215,7 @@ static int __exit mxc_rnga_remove(struct platform_device *pdev)
 
 	release_mem_region(res->start, resource_size(res));
 
-	clk_disable(clk);
+	clk_disable_unprepare(clk);
 	clk_put(clk);
 
 	return 0;
Signature · 1 line
1.7.1
maintainer Acked-by on v2 3/15
#10 lore raw

Re: [PATCH v2 03/15] hw_random: mxc-rnga: Use clk_prepare_enable/clk_disable_unprepare

Quoted 7 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

Prepare the clock before enabling it.

Quoted 42 lines

---
Changes since v1:
- Add missing clk_disable_unprepare(clk) in the remove path

 drivers/char/hw_random/mxc-rnga.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/char/hw_random/mxc-rnga.c +3 -3
index 187c6be..430582c 100644
@@ -154,7 +154,7 @@ static int __init mxc_rnga_probe(struct platform_device *pdev)
 		goto out;
 	}
 
-	clk_enable(clk);
+	clk_prepare_enable(clk);
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res) {
@@ -196,7 +196,7 @@ err_ioremap:
 	release_mem_region(res->start, resource_size(res));
 
 err_region:
-	clk_disable(clk);
+	clk_disable_unprepare(clk);
 	clk_put(clk);
 
 out:
@@ -215,7 +215,7 @@ static int __exit mxc_rnga_remove(struct platform_device *pdev)
 
 	release_mem_region(res->start, resource_size(res));
 
-	clk_disable(clk);
+	clk_disable_unprepare(clk);
 	clk_put(clk);
 
 	return 0;
Signature · 1 line
1.7.1
Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#12 lore raw

Re: [PATCH v2 03/15] hw_random: mxc-rnga: Use clk_prepare_enable/clk_disable_unprepare

Quoted 8 lines · Fabio Estevam

Herbert,

Quoted 5 lines · Sascha Hauer
Quoted 4 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

Prepare the clock before enabling it.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Can this be applied?

Your patch is in my queue. I'm at LinuxCon Japan right now, so I'll be applying them later this week.

Cheers,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
author reviewer
#13 lore raw

PATCH 5/15 keyboard: imx_keypad: Use clk_prepare_enable/clk_disable_unprepare

In reply to Fabio Estevam

From: Fabio Estevam <[email protected]>

Prepare the clock before enabling it.

---
 drivers/input/keyboard/imx_keypad.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
drivers/input/keyboard/imx_keypad.c +4 -4
index 6ee7421..9d57945 100644
@@ -378,7 +378,7 @@ static void imx_keypad_close(struct input_dev *dev)
 	imx_keypad_inhibit(keypad);
 
 	/* Disable clock unit */
-	clk_disable(keypad->clk);
+	clk_disable_unprepare(keypad->clk);
 }
 
 static int imx_keypad_open(struct input_dev *dev)
@@ -391,7 +391,7 @@ static int imx_keypad_open(struct input_dev *dev)
 	keypad->enabled = true;
 
 	/* Enable the kpp clock */
-	clk_enable(keypad->clk);
+	clk_prepare_enable(keypad->clk);
 	imx_keypad_config(keypad);
 
 	/* Sanity control, not all the rows must be actived now. */
@@ -581,7 +581,7 @@ static int imx_kbd_suspend(struct device *dev)
 	mutex_lock(&input_dev->mutex);
 
 	if (input_dev->users)
-		clk_disable(kbd->clk);
+		clk_disable_unprepare(kbd->clk);
 
 	mutex_unlock(&input_dev->mutex);
 
@@ -603,7 +603,7 @@ static int imx_kbd_resume(struct device *dev)
 	mutex_lock(&input_dev->mutex);
 
 	if (input_dev->users)
-		clk_enable(kbd->clk);
+		clk_prepare_enable(kbd->clk);
 
 	mutex_unlock(&input_dev->mutex);
 
Signature · 1 line
1.7.1
maintainer Acked-by on v1 5/15
#14 lore raw

Re: [PATCH 05/15] keyboard: imx_keypad: Use clk_prepare_enable/clk_disable_unprepare

Quoted 7 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

Prepare the clock before enabling it.

Quoted 48 lines
---
 drivers/input/keyboard/imx_keypad.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
drivers/input/keyboard/imx_keypad.c +4 -4
index 6ee7421..9d57945 100644
@@ -378,7 +378,7 @@ static void imx_keypad_close(struct input_dev *dev)
 	imx_keypad_inhibit(keypad);
 
 	/* Disable clock unit */
-	clk_disable(keypad->clk);
+	clk_disable_unprepare(keypad->clk);
 }
 
 static int imx_keypad_open(struct input_dev *dev)
@@ -391,7 +391,7 @@ static int imx_keypad_open(struct input_dev *dev)
 	keypad->enabled = true;
 
 	/* Enable the kpp clock */
-	clk_enable(keypad->clk);
+	clk_prepare_enable(keypad->clk);
 	imx_keypad_config(keypad);
 
 	/* Sanity control, not all the rows must be actived now. */
@@ -581,7 +581,7 @@ static int imx_kbd_suspend(struct device *dev)
 	mutex_lock(&input_dev->mutex);
 
 	if (input_dev->users)
-		clk_disable(kbd->clk);
+		clk_disable_unprepare(kbd->clk);
 
 	mutex_unlock(&input_dev->mutex);
 
@@ -603,7 +603,7 @@ static int imx_kbd_resume(struct device *dev)
 	mutex_lock(&input_dev->mutex);
 
 	if (input_dev->users)
-		clk_enable(kbd->clk);
+		clk_prepare_enable(kbd->clk);
 
 	mutex_unlock(&input_dev->mutex);
 
Signature · 1 line
1.7.1
Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
author reviewer
#16 lore raw

PATCH 6/15 video: mx1_camera: Use clk_prepare_enable/clk_disable_unprepare

In reply to Fabio Estevam

From: Fabio Estevam <[email protected]>

Prepare the clock before enabling it.

---
 drivers/media/video/mx1_camera.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/media/video/mx1_camera.c +2 -2
index 4296a83..dc58084 100644
@@ -402,7 +402,7 @@ static void mx1_camera_activate(struct mx1_camera_dev *pcdev)
 
 	dev_dbg(pcdev->icd->parent, "Activate device\n");
 
-	clk_enable(pcdev->clk);
+	clk_prepare_enable(pcdev->clk);
 
 	/* enable CSI before doing anything else */
 	__raw_writel(csicr1, pcdev->base + CSICR1);
@@ -421,7 +421,7 @@ static void mx1_camera_deactivate(struct mx1_camera_dev *pcdev)
 	/* Disable all CSI interface */
 	__raw_writel(0x00, pcdev->base + CSICR1);
 
-	clk_disable(pcdev->clk);
+	clk_disable_unprepare(pcdev->clk);
 }
 
 /*
Signature · 1 line
1.7.1
maintainer Acked-by on v1 6/15
#17 lore raw

Re: [PATCH 06/15] video: mx1_camera: Use clk_prepare_enable/clk_disable_unprepare

Quoted 7 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

Prepare the clock before enabling it.

Quoted 30 lines
---
 drivers/media/video/mx1_camera.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/media/video/mx1_camera.c +2 -2
index 4296a83..dc58084 100644
@@ -402,7 +402,7 @@ static void mx1_camera_activate(struct mx1_camera_dev *pcdev)
 
 	dev_dbg(pcdev->icd->parent, "Activate device\n");
 
-	clk_enable(pcdev->clk);
+	clk_prepare_enable(pcdev->clk);
 
 	/* enable CSI before doing anything else */
 	__raw_writel(csicr1, pcdev->base + CSICR1);
@@ -421,7 +421,7 @@ static void mx1_camera_deactivate(struct mx1_camera_dev *pcdev)
 	/* Disable all CSI interface */
 	__raw_writel(0x00, pcdev->base + CSICR1);
 
-	clk_disable(pcdev->clk);
+	clk_disable_unprepare(pcdev->clk);
 }
 
 /*
Signature · 1 line
1.7.1
Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#19 lore raw

Re: [PATCH 06/15] video: mx1_camera: Use clk_prepare_enable/clk_disable_unprepare

Quoted 8 lines · Fabio Estevam

Guennadi,

Quoted 5 lines · Sascha Hauer
Quoted 4 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

Prepare the clock before enabling it.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Can patches 6, 7 and 8 be applied?

Yes, I'll pick up #6 and 7. #8 is not for me - mx2_emmaprp is not an soc-camera driver, I'm not maintaining it. I understand, these patches are not really bug-fixes (is clk_prepare() a NOP on mx*?) and can wait until 3.6? Or should they be considered correctness fixes and go into 3.5?

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/

author reviewer
#20 lore raw

Re: [PATCH 06/15] video: mx1_camera: Use clk_prepare_enable/clk_disable_unprepare

Hi Guennadi,

Quoted 4 lines · Guennadi Liakhovetski

Yes, I'll pick up #6 and 7. #8 is not for me - mx2_emmaprp is not an soc-camera driver, I'm not maintaining it. I understand, these patches are not really bug-fixes (is clk_prepare() a NOP on mx*?) and can wait until 3.6? Or should they be considered correctness fixes and go into 3.5?

On i.MX we have transitioned to the common clock framework and my understanding is that we need the clk_prepare_enable/clk_disable_unprepare changes now. I experienced some kernel oops in some drivers that were not converted, so this patch series aim to address the clock conversion for the remaining imx drivers.

I think this is 3.5 material.

Sascha, would you agree?

Thanks,

Fabio Estevam

author reviewer
#21 lore raw

PATCH 7/15 video: mx2_camera: Use clk_prepare_enable/clk_disable_unprepare

In reply to Fabio Estevam

From: Fabio Estevam <[email protected]>

Prepare the clock before enabling it.

---
 drivers/media/video/mx2_camera.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
drivers/media/video/mx2_camera.c +6 -6
index ded26b7..71b67a3 100644
@@ -402,7 +402,7 @@ static void mx2_camera_deactivate(struct mx2_camera_dev *pcdev)
 {
 	unsigned long flags;
 
-	clk_disable(pcdev->clk_csi);
+	clk_disable_unprepare(pcdev->clk_csi);
 	writel(0, pcdev->base_csi + CSICR1);
 	if (cpu_is_mx27()) {
 		writel(0, pcdev->base_emma + PRP_CNTL);
@@ -430,7 +430,7 @@ static int mx2_camera_add_device(struct soc_camera_device *icd)
 	if (pcdev->icd)
 		return -EBUSY;
 
-	ret = clk_enable(pcdev->clk_csi);
+	ret = clk_prepare_enable(pcdev->clk_csi);
 	if (ret < 0)
 		return ret;
 
@@ -1664,7 +1664,7 @@ static int __devinit mx27_camera_emma_init(struct mx2_camera_dev *pcdev)
 		goto exit_free_irq;
 	}
 
-	clk_enable(pcdev->clk_emma);
+	clk_prepare_enable(pcdev->clk_emma);
 
 	err = mx27_camera_emma_prp_reset(pcdev);
 	if (err)
@@ -1673,7 +1673,7 @@ static int __devinit mx27_camera_emma_init(struct mx2_camera_dev *pcdev)
 	return err;
 
 exit_clk_emma_put:
-	clk_disable(pcdev->clk_emma);
+	clk_disable_unprepare(pcdev->clk_emma);
 	clk_put(pcdev->clk_emma);
 exit_free_irq:
 	free_irq(pcdev->irq_emma, pcdev);
@@ -1810,7 +1810,7 @@ exit_free_emma:
 eallocctx:
 	if (cpu_is_mx27()) {
 		free_irq(pcdev->irq_emma, pcdev);
-		clk_disable(pcdev->clk_emma);
+		clk_disable_unprepare(pcdev->clk_emma);
 		clk_put(pcdev->clk_emma);
 		iounmap(pcdev->base_emma);
 		release_mem_region(pcdev->res_emma->start, resource_size(pcdev->res_emma));
@@ -1850,7 +1850,7 @@ static int __devexit mx2_camera_remove(struct platform_device *pdev)
 	iounmap(pcdev->base_csi);
 
 	if (cpu_is_mx27()) {
-		clk_disable(pcdev->clk_emma);
+		clk_disable_unprepare(pcdev->clk_emma);
 		clk_put(pcdev->clk_emma);
 		iounmap(pcdev->base_emma);
 		res = pcdev->res_emma;
Signature · 1 line
1.7.1
maintainer Acked-by on v1 7/15
#22 lore raw

Re: [PATCH 07/15] video: mx2_camera: Use clk_prepare_enable/clk_disable_unprepare

Quoted 7 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

Prepare the clock before enabling it.

Quoted 66 lines
---
 drivers/media/video/mx2_camera.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
drivers/media/video/mx2_camera.c +6 -6
index ded26b7..71b67a3 100644
@@ -402,7 +402,7 @@ static void mx2_camera_deactivate(struct mx2_camera_dev *pcdev)
 {
 	unsigned long flags;
 
-	clk_disable(pcdev->clk_csi);
+	clk_disable_unprepare(pcdev->clk_csi);
 	writel(0, pcdev->base_csi + CSICR1);
 	if (cpu_is_mx27()) {
 		writel(0, pcdev->base_emma + PRP_CNTL);
@@ -430,7 +430,7 @@ static int mx2_camera_add_device(struct soc_camera_device *icd)
 	if (pcdev->icd)
 		return -EBUSY;
 
-	ret = clk_enable(pcdev->clk_csi);
+	ret = clk_prepare_enable(pcdev->clk_csi);
 	if (ret < 0)
 		return ret;
 
@@ -1664,7 +1664,7 @@ static int __devinit mx27_camera_emma_init(struct mx2_camera_dev *pcdev)
 		goto exit_free_irq;
 	}
 
-	clk_enable(pcdev->clk_emma);
+	clk_prepare_enable(pcdev->clk_emma);
 
 	err = mx27_camera_emma_prp_reset(pcdev);
 	if (err)
@@ -1673,7 +1673,7 @@ static int __devinit mx27_camera_emma_init(struct mx2_camera_dev *pcdev)
 	return err;
 
 exit_clk_emma_put:
-	clk_disable(pcdev->clk_emma);
+	clk_disable_unprepare(pcdev->clk_emma);
 	clk_put(pcdev->clk_emma);
 exit_free_irq:
 	free_irq(pcdev->irq_emma, pcdev);
@@ -1810,7 +1810,7 @@ exit_free_emma:
 eallocctx:
 	if (cpu_is_mx27()) {
 		free_irq(pcdev->irq_emma, pcdev);
-		clk_disable(pcdev->clk_emma);
+		clk_disable_unprepare(pcdev->clk_emma);
 		clk_put(pcdev->clk_emma);
 		iounmap(pcdev->base_emma);
 		release_mem_region(pcdev->res_emma->start, resource_size(pcdev->res_emma));
@@ -1850,7 +1850,7 @@ static int __devexit mx2_camera_remove(struct platform_device *pdev)
 	iounmap(pcdev->base_csi);
 
 	if (cpu_is_mx27()) {
-		clk_disable(pcdev->clk_emma);
+		clk_disable_unprepare(pcdev->clk_emma);
 		clk_put(pcdev->clk_emma);
 		iounmap(pcdev->base_emma);
 		res = pcdev->res_emma;
Signature · 1 line
1.7.1
Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
author reviewer
#23 lore raw

PATCH 8/15 video: mx2_emmaprp: Use clk_prepare_enable/clk_disable_unprepare

In reply to Fabio Estevam

From: Fabio Estevam <[email protected]>

Prepare the clock before enabling it.

---
 drivers/media/video/mx2_emmaprp.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/media/video/mx2_emmaprp.c +2 -2
index 0bd5815..b364557 100644
@@ -800,7 +800,7 @@ static int emmaprp_open(struct file *file)
 		return ret;
 	}
 
-	clk_enable(pcdev->clk_emma);
+	clk_prepare_enable(pcdev->clk_emma);
 	ctx->q_data[V4L2_M2M_SRC].fmt = &formats[1];
 	ctx->q_data[V4L2_M2M_DST].fmt = &formats[0];
 
@@ -816,7 +816,7 @@ static int emmaprp_release(struct file *file)
 
 	dprintk(pcdev, "Releasing instance %p\n", ctx);
 
-	clk_disable(pcdev->clk_emma);
+	clk_disable_unprepare(pcdev->clk_emma);
 	v4l2_m2m_ctx_release(ctx->m2m_ctx);
 	kfree(ctx);
 
Signature · 1 line
1.7.1
maintainer Acked-by on v1 8/15
#24 lore raw

Re: [PATCH 08/15] video: mx2_emmaprp: Use clk_prepare_enable/clk_disable_unprepare

Quoted 7 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

Prepare the clock before enabling it.

Quoted 30 lines
---
 drivers/media/video/mx2_emmaprp.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/media/video/mx2_emmaprp.c +2 -2
index 0bd5815..b364557 100644
@@ -800,7 +800,7 @@ static int emmaprp_open(struct file *file)
 		return ret;
 	}
 
-	clk_enable(pcdev->clk_emma);
+	clk_prepare_enable(pcdev->clk_emma);
 	ctx->q_data[V4L2_M2M_SRC].fmt = &formats[1];
 	ctx->q_data[V4L2_M2M_DST].fmt = &formats[0];
 
@@ -816,7 +816,7 @@ static int emmaprp_release(struct file *file)
 
 	dprintk(pcdev, "Releasing instance %p\n", ctx);
 
-	clk_disable(pcdev->clk_emma);
+	clk_disable_unprepare(pcdev->clk_emma);
 	v4l2_m2m_ctx_release(ctx->m2m_ctx);
 	kfree(ctx);
 
Signature · 1 line
1.7.1
Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
author reviewer
#25 lore raw

PATCH 9/15 nand: mxc_nand: Use clk_prepare_enable/clk_disable_unprepare

In reply to Fabio Estevam

From: Fabio Estevam <[email protected]>

Prepare the clock before enabling it.

---
 drivers/mtd/nand/mxc_nand.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/nand/mxc_nand.c +2 -2
index fd14966..d6efa17 100644
@@ -764,7 +764,7 @@ static void mxc_nand_select_chip_v2(struct mtd_info *mtd, int chip)
 	if (chip == -1) {
 		/* Disable the NFC clock */
 		if (host->clk_act) {
-			clk_disable(host->clk);
+			clk_disable_unprepare(host->clk);
 			host->clk_act = 0;
 		}
 		return;
@@ -772,7 +772,7 @@ static void mxc_nand_select_chip_v2(struct mtd_info *mtd, int chip)
 
 	if (!host->clk_act) {
 		/* Enable the NFC clock */
-		clk_enable(host->clk);
+		clk_prepare_enable(host->clk);
 		host->clk_act = 1;
 	}
 
Signature · 1 line
1.7.1
#26 lore raw

Re: [PATCH 09/15] nand: mxc_nand: Use clk_prepare_enable/clk_disable_unprepare

Quoted 3 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

Prepare the clock before enabling it.

Pushed to l2-mtd.git, thanks!

Signature · 2 lines
Best Regards,
Artem Bityutskiy
author reviewer
#27 lore raw

PATCH 11/15 serial: mxs-auart: Use clk_prepare_enable/clk_disable_unprepare

In reply to Fabio Estevam

From: Fabio Estevam <[email protected]>

Prepare the clock before enabling it.

---
 drivers/tty/serial/mxs-auart.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/mxs-auart.c +2 -2
index ec56d83..c109642 100644
@@ -552,7 +552,7 @@ auart_console_write(struct console *co, const char *str, unsigned int count)
 	s = auart_port[co->index];
 	port = &s->port;
 
-	clk_enable(s->clk);
+	clk_prepare_enable(s->clk);
 
 	/* First save the CR then disable the interrupts */
 	old_ctrl2 = readl(port->membase + AUART_CTRL2);
@@ -578,7 +578,7 @@ auart_console_write(struct console *co, const char *str, unsigned int count)
 	writel(old_ctrl0, port->membase + AUART_CTRL0);
 	writel(old_ctrl2, port->membase + AUART_CTRL2);
 
-	clk_disable(s->clk);
+	clk_disable_unprepare(s->clk);
 }
 
 static void __init
Signature · 1 line
1.7.1
#28 lore raw

Re: [PATCH 11/15] serial: mxs-auart: Use clk_prepare_enable/clk_disable_unprepare

Quoted 37 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

Prepare the clock before enabling it.

---
 drivers/tty/serial/mxs-auart.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/mxs-auart.c +2 -2
index ec56d83..c109642 100644
@@ -552,7 +552,7 @@ auart_console_write(struct console *co, const char *str, unsigned int count)
 	s = auart_port[co->index];
 	port = &s->port;
 
-	clk_enable(s->clk);
+	clk_prepare_enable(s->clk);
 
 	/* First save the CR then disable the interrupts */
 	old_ctrl2 = readl(port->membase + AUART_CTRL2);
@@ -578,7 +578,7 @@ auart_console_write(struct console *co, const char *str, unsigned int count)
 	writel(old_ctrl0, port->membase + AUART_CTRL0);
 	writel(old_ctrl2, port->membase + AUART_CTRL2);
 
-	clk_disable(s->clk);
+	clk_disable_unprepare(s->clk);
 }
 
 static void __init
Signature · 1 line
1.7.1

No, clk_prepare() should not be called in auart_console_write() which is an atomic context. However it reminds me that auart_console_setup() needs a fix as below.

Regards,
Shawn

--8<---

drivers/tty/serial/mxs-auart.c +4 -6
index ec56d83..a3bb06b 100644
@@ -638,18 +638,16 @@ auart_console_setup(struct console *co, char *options)
        if (!s)
                return -ENODEV;
 
-       clk_prepare_enable(s->clk);
+       clk_prepare(s->clk);
+       if (ret)
+               return ret;
 
        if (options)
                uart_parse_options(options, &baud, &parity, &bits, &flow);
        else
                auart_console_get_options(&s->port, &baud, &parity, &bits);
 
-       ret = uart_set_options(&s->port, co, baud, parity, bits, flow);
-
-       clk_disable_unprepare(s->clk);
-
-       return ret;
+       return uart_set_options(&s->port, co, baud, parity, bits, flow);
 }
 
 static struct console auart_console = {
author reviewer
#29 lore raw

PATCH 15/15 ASoC: mxs-saif: Use clk_prepare_enable/clk_disable_unprepare

In reply to Fabio Estevam

From: Fabio Estevam <[email protected]>

Prepare the clock before enabling it.

---
 sound/soc/mxs/mxs-saif.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
sound/soc/mxs/mxs-saif.c +4 -4
index aba71bf..15ad61a 100644
@@ -482,7 +482,7 @@ static int mxs_saif_trigger(struct snd_pcm_substream *substream, int cmd,
 	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
 		dev_dbg(cpu_dai->dev, "start\n");
 
-		clk_enable(master_saif->clk);
+		clk_prepare_enable(master_saif->clk);
 		if (!master_saif->mclk_in_use)
 			__raw_writel(BM_SAIF_CTRL_RUN,
 				master_saif->base + SAIF_CTRL + MXS_SET_ADDR);
@@ -492,7 +492,7 @@ static int mxs_saif_trigger(struct snd_pcm_substream *substream, int cmd,
 		 * itself clk for its internal basic logic to work.
 		 */
 		if (saif != master_saif) {
-			clk_enable(saif->clk);
+			clk_prepare_enable(saif->clk);
 			__raw_writel(BM_SAIF_CTRL_RUN,
 				saif->base + SAIF_CTRL + MXS_SET_ADDR);
 		}
@@ -534,13 +534,13 @@ static int mxs_saif_trigger(struct snd_pcm_substream *substream, int cmd,
 				master_saif->base + SAIF_CTRL + MXS_CLR_ADDR);
 			udelay(delay);
 		}
-		clk_disable(master_saif->clk);
+		clk_disable_unprepare(master_saif->clk);
 
 		if (saif != master_saif) {
 			__raw_writel(BM_SAIF_CTRL_RUN,
 				saif->base + SAIF_CTRL + MXS_CLR_ADDR);
 			udelay(delay);
-			clk_disable(saif->clk);
+			clk_disable_unprepare(saif->clk);
 		}
 
 		master_saif->ongoing = 0;
Signature · 1 line
1.7.1
Applied
#30 lore raw

Re: [PATCH 15/15] ASoC: mxs-saif: Use clk_prepare_enable/clk_disable_unprepare

Quoted 3 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

Prepare the clock before enabling it.

Applied, thanks.

author reviewer
#31 lore raw

Re: [PATCH 15/15] ASoC: mxs-saif: Use clk_prepare_enable/clk_disable_unprepare

Hi Shawn,

Quoted 6 lines · Mark Brown
Quoted 3 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

Prepare the clock before enabling it.

Applied, thanks.

With this patch applied I have just realized the following (only during the first 'aplay', subsequent 'aplay's do not show it):

root@freescale /home$ aplay audio48k16S.wav
Playing WAVE 'audio48k16S.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo

[   16.170000]
[   16.170000] =========================================================
[   16.170000] [ INFO: possible irq lock inversion dependency detected ]
[   16.170000] 3.4.0-next-20120524-00008-g5e6603c-dirty #962 Not tainted
[   16.170000] ---------------------------------------------------------
[   16.170000] swapper/0 just changed the state of lock:
[   16.170000]  (&(&substream->self_group.lock)->rlock){..-...}, at:
[<c022fda8>] snd_pcm_period_elapsed+0x34/0xd0
[   16.170000] but this lock took another, SOFTIRQ-unsafe lock in the past:
[   16.170000]  (prepare_lock){+.+...}
[   16.170000]
[   16.170000] and interrupts could create inverse lock ordering between them.
[   16.170000]
[   16.170000]
[   16.170000] other info that might help us debug this:
[   16.170000]  Possible interrupt unsafe locking scenario:
[   16.170000]
[   16.170000]        CPU0                    CPU1
[   16.170000]        ----                    ----
[   16.170000]   lock(prepare_lock);
[   16.170000]                                local_irq_disable();
[   16.170000]
lock(&(&substream->self_group.lock)->rlock);
[   16.170000]                                lock(prepare_lock);
[   16.170000]   <Interrupt>
[   16.170000]     lock(&(&substream->self_group.lock)->rlock);
[   16.170000]
[   16.170000]  *** DEADLOCK ***
[   16.170000]
[   16.170000] 1 lock held by swapper/0:
[   16.170000]  #0:  (snd_pcm_link_rwlock){...-..}, at: [<c022fd98>]
snd_pcm_period_elapsed+0x24/0xd0
[   16.170000]
[   16.170000] the shortest dependencies between 2nd lock and 1st lock:
[   16.170000]  -> (prepare_lock){+.+...} ops: 110 {
[   16.170000]     HARDIRQ-ON-W at:
[   16.170000]   [<c005bc10>] __lock_acquire+0xb04/0x1b98
[   16.170000]   [<c005cd44>] lock_acquire+0xa0/0x108
[   16.170000]   [<c02e4c20>] mutex_lock_nested+0x54/0x29c
[   16.170000]   [<c021d250>] clk_prepare+0x18/0x38
[   16.170000]   [<c04029f8>] mxs_machine_init+0x30/0x74
[   16.170000]   [<c03ff7b8>] customize_machine+0x1c/0x28
[   16.170000]   [<c000874c>] do_one_initcall+0x30/0x17c
[   16.170000]   [<c03fe340>] kernel_init+0x114/0x1f0
[   16.170000]   [<c001014c>] kernel_thread_exit+0x0/0x8
[   16.170000]     SOFTIRQ-ON-W at:
[   16.170000]   [<c005bc34>] __lock_acquire+0xb28/0x1b98
[   16.170000]   [<c005cd44>] lock_acquire+0xa0/0x108
[   16.170000]   [<c02e4c20>] mutex_lock_nested+0x54/0x29c
[   16.170000]   [<c021d250>] clk_prepare+0x18/0x38
[   16.170000]   [<c04029f8>] mxs_machine_init+0x30/0x74
[   16.170000]   [<c03ff7b8>] customize_machine+0x1c/0x28
[   16.170000]   [<c000874c>] do_one_initcall+0x30/0x17c
[   16.170000]   [<c03fe340>] kernel_init+0x114/0x1f0
[   16.170000]   [<c001014c>] kernel_thread_exit+0x0/0x8
[   16.170000]     INITIAL USE at:
[   16.170000]   [<c005b4d4>] __lock_acquire+0x3c8/0x1b98
[   16.170000]   [<c005cd44>] lock_acquire+0xa0/0x108
[   16.170000]   [<c02e4c20>] mutex_lock_nested+0x54/0x29c
[   16.170000]   [<c021c7b8>] __clk_init+0x20/0x3e4
[   16.170000]   [<c021cc64>] clk_register+0xe8/0x1b0
[   16.170000]   [<c021d570>] clk_register_fixed_rate+0x8c/0xe0
[   16.170000]   [<c04107b8>] mx28_clocks_init+0x7c/0xdac
[   16.170000]   [<c0400270>] time_init+0x20/0x30
[   16.170000]   [<c03fe794>] start_kernel+0x1a0/0x2a0
[   16.170000]   [<40008040>] 0x40008040
[   16.170000]   }
[   16.170000]   ... key      at: [<c044fb9c>] prepare_lock+0x38/0x48
[   16.170000]   ... acquired at:
[   16.170000]    [<c005cd44>] lock_acquire+0xa0/0x108
[   16.170000]    [<c02e4c20>] mutex_lock_nested+0x54/0x29c
[   16.170000]    [<c021d250>] clk_prepare+0x18/0x38
[   16.170000]    [<c024474c>] mxs_saif_trigger+0xd8/0x184
[   16.170000]    [<c023f8c0>] soc_pcm_trigger+0x94/0x9c
[   16.170000]    [<c0228804>] snd_pcm_do_start+0x28/0x2c
[   16.170000]    [<c0228718>] snd_pcm_action_single+0x38/0x78
[   16.170000]    [<c02306fc>] snd_pcm_lib_write1+0x2e4/0x340
[   16.170000]    [<c02307f8>] snd_pcm_lib_write+0x44/0x64
[   16.170000]    [<c022d0e0>] snd_pcm_playback_ioctl1+0xec/0x46c
[   16.170000]    [<c00d8834>] do_vfs_ioctl+0x7c/0x584
[   16.170000]    [<c00d8d74>] sys_ioctl+0x38/0x60
[   16.170000]    [<c000f180>] ret_fast_syscall+0x0/0x38
[   16.170000]
[   16.170000] -> (&(&substream->self_group.lock)->rlock){..-...} ops: 36 {
[   16.170000]    IN-SOFTIRQ-W at:
[   16.170000]  [<c005bbf4>] __lock_acquire+0xae8/0x1b98
[   16.170000]  [<c005cd44>] lock_acquire+0xa0/0x108
[   16.170000]  [<c02e67fc>] _raw_spin_lock+0x2c/0x3c
[   16.170000]  [<c022fda8>] snd_pcm_period_elapsed+0x34/0xd0
[   16.170000]  [<c01bed28>] mxs_dma_tasklet+0x18/0x1c
[   16.170000]  [<c00235e4>] tasklet_action+0xc8/0xd8
[   16.170000]  [<c0023b38>] __do_softirq+0xa0/0x1e0
[   16.170000]  [<c0023e10>] irq_exit+0x8c/0x94
[   16.170000]  [<c0010080>] handle_IRQ+0x34/0x84
[   16.170000]  [<c000edd8>] __irq_svc+0x38/0x60
[   16.170000]  [<c001029c>] default_idle+0x40/0x48
[   16.170000]  [<c00105b8>] cpu_idle+0x68/0xd0
[   16.170000]  [<c03fe854>] start_kernel+0x260/0x2a0
[   16.170000]    INITIAL USE at:
[   16.170000]  [<c005b4d4>] __lock_acquire+0x3c8/0x1b98
[   16.170000]  [<c005cd44>] lock_acquire+0xa0/0x108
[   16.170000]  [<c02e67fc>] _raw_spin_lock+0x2c/0x3c
[   16.170000]  [<c022978c>] snd_pcm_sync_ptr+0xb8/0x16c
[   16.170000]  [<c022c038>] snd_pcm_common_ioctl1+0x204/0xd48
[   16.170000]  [<c022d024>] snd_pcm_playback_ioctl1+0x30/0x46c
[   16.170000]  [<c00d8834>] do_vfs_ioctl+0x7c/0x584
[   16.170000]  [<c00d8d74>] sys_ioctl+0x38/0x60
[   16.170000]  [<c000f180>] ret_fast_syscall+0x0/0x38
[   16.170000]  }
[   16.170000]  ... key      at: [<c099e694>] __key.25802+0x0/0x8
[   16.170000]  ... acquired at:
[   16.170000]    [<c005a030>] check_usage_forwards+0xa0/0x10c
[   16.170000]    [<c0059120>] mark_lock+0x1d4/0x62c
[   16.170000]    [<c005bbf4>] __lock_acquire+0xae8/0x1b98
[   16.170000]    [<c005cd44>] lock_acquire+0xa0/0x108
[   16.170000]    [<c02e67fc>] _raw_spin_lock+0x2c/0x3c
[   16.170000]    [<c022fda8>] snd_pcm_period_elapsed+0x34/0xd0
[   16.170000]    [<c01bed28>] mxs_dma_tasklet+0x18/0x1c
[   16.170000]    [<c00235e4>] tasklet_action+0xc8/0xd8
[   16.170000]    [<c0023b38>] __do_softirq+0xa0/0x1e0
[   16.170000]    [<c0023e10>] irq_exit+0x8c/0x94
[   16.170000]    [<c0010080>] handle_IRQ+0x34/0x84
[   16.170000]    [<c000edd8>] __irq_svc+0x38/0x60
[   16.170000]    [<c001029c>] default_idle+0x40/0x48
[   16.170000]    [<c00105b8>] cpu_idle+0x68/0xd0
[   16.170000]    [<c03fe854>] start_kernel+0x260/0x2a0
[   16.170000]
[   16.170000]
[   16.170000] stack backtrace:
[   16.170000] [<c00148f0>] (unwind_backtrace+0x0/0xf4) from
[<c0059f20>] (print_irq_inversion_bug+0x1a0/0x210)
[   16.170000] [<c0059f20>] (print_irq_inversion_bug+0x1a0/0x210) from
[<c005a030>] (check_usage_forwards+0xa0/0x10c)
[   16.170000] [<c005a030>] (check_usage_forwards+0xa0/0x10c) from
[<c0059120>] (mark_lock+0x1d4/0x62c)
[   16.170000] [<c0059120>] (mark_lock+0x1d4/0x62c) from [<c005bbf4>]
(__lock_acquire+0xae8/0x1b98)
[   16.170000] [<c005bbf4>] (__lock_acquire+0xae8/0x1b98) from
[<c005cd44>] (lock_acquire+0xa0/0x108)
[   16.170000] [<c005cd44>] (lock_acquire+0xa0/0x108) from
[<c02e67fc>] (_raw_spin_lock+0x2c/0x3c)
[   16.170000] [<c02e67fc>] (_raw_spin_lock+0x2c/0x3c) from
[<c022fda8>] (snd_pcm_period_elapsed+0x34/0xd0)
[   16.170000] [<c022fda8>] (snd_pcm_period_elapsed+0x34/0xd0) from
[<c01bed28>] (mxs_dma_tasklet+0x18/0x1c)
[   16.170000] [<c01bed28>] (mxs_dma_tasklet+0x18/0x1c) from
[<c00235e4>] (tasklet_action+0xc8/0xd8)
[   16.170000] [<c00235e4>] (tasklet_action+0xc8/0xd8) from
[<c0023b38>] (__do_softirq+0xa0/0x1e0)
[   16.170000] [<c0023b38>] (__do_softirq+0xa0/0x1e0) from
[<c0023e10>] (irq_exit+0x8c/0x94)
[   16.170000] [<c0023e10>] (irq_exit+0x8c/0x94) from [<c0010080>]
(handle_IRQ+0x34/0x84)
[   16.170000] [<c0010080>] (handle_IRQ+0x34/0x84) from [<c000edd8>]
(__irq_svc+0x38/0x60)
[   16.170000] [<c000edd8>] (__irq_svc+0x38/0x60) from [<c001029c>]
(default_idle+0x40/0x48)
[   16.170000] [<c001029c>] (default_idle+0x40/0x48) from [<c00105b8>]
(cpu_idle+0x68/0xd0)
[   16.170000] [<c00105b8>] (cpu_idle+0x68/0xd0) from [<c03fe854>]

(start_kernel+0x260/0x2a0)

Will debug this, but any suggestion is appreaciated.

Thanks,

Fabio Estevam

#32 lore raw

Re: [PATCH 15/15] ASoC: mxs-saif: Use clk_prepare_enable/clk_disable_unprepare

Quoted 2 lines · Fabio Estevam

With this patch applied I have just realized the following (only during the first 'aplay', subsequent 'aplay's do not show it):

[Attempting to do stuff we shouldn't in hard IRQ context]

Is this not just a case of calling clk_prepare_and_enable() from atomic context - the whole reason the two are split is that only _enable() can be called in atomic context?

I'll discard this commit for now.

maintainer
#33 lore raw

PATCH 1/15 ARM: mx5: Use clk_prepare_enable/clk_disable_unprepare

In reply to Fabio Estevam
Quoted 16 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

Prepare the clock before enabling it.

---
 arch/arm/mach-imx/mm-imx5.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-imx/mm-imx5.c +0 -0
index feeee17..fcad95c 100644
@@ -35,11 +35,11 @@ static void imx5_idle(void)
 			return;

arch/arm/mach-imx/mm-imx5.c static void imx5_idle(void) · line 43

Quoted 10 lines
arch/arm/mach-imx/mm-imx5.c +2 -2
 		clk_prepare(gpc_dvfs_clk);
 	}
-	clk_enable(gpc_dvfs_clk);
+	clk_prepare_enable(gpc_dvfs_clk);
 	mx5_cpu_lp_set(WAIT_UNCLOCKED_POWER_OFF);
 	if (!tzic_enable_wake())
 		cpu_do_idle();
-	clk_disable(gpc_dvfs_clk);
+	clk_disable_unprepare(gpc_dvfs_clk);
 }

No, the clock already is prepared.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |