2013-07-18 07:49:28

by Boris BREZILLON

[permalink] [raw]
Subject: [PATCH v4 0/5] ARM: at91: prepare transition to common clk framework

Hello,

This patch series prepares the transition to common clk framework by
replacing all the clk_enable and clk_disable calls by clk_prepare_unable and
clk_disable_unprepare to avoid common clock framework warnings.

Best Regards,
Boris

Changes since v3:
- move usb clock config patches out of this series
- move clk_prepare/unprepare calls out of critical sections (ssc and
mci drivers)
- remove already applied spi clk_prepare patch

Changes since v2:
- add configuraton of usb clock in ohci and udc drivers
- add clk_prepare patch for usba udc driver
- add clk_prepare patch for spi driver
- remove already applied udc clk_prepare patch

Changes since v1:
- remove unneeded clk_unprepare in mci driver
- remove already applied patches (ehci, ohci, dma and serial)

Changes since common clk patch series:
- add clk_prepare_enable return check
- fix a deadlock in atmel-mci (missing spin_unlock)
- remove already applied patches (atmel-ssc and pwm-atmel-tcb)

Boris BREZILLON (5):
ARM: at91/tc/clocksource: replace clk_enable/disable with
clk_prepare_enable/disable_unprepare.
mmc: atmel-mci: prepare clk before calling enable
at91/avr32/atmel_lcdfb: prepare clk before calling enable
USB: gadget: atmel_usba: prepare clk before calling enable
ASoC: atmel-ssc: remove clk_disable_unprepare call from critical
section

drivers/clocksource/tcb_clksrc.c | 10 +++++-----
drivers/misc/atmel-ssc.c | 11 ++++++++---
drivers/mmc/host/atmel-mci.c | 34 +++++++++++++++++++++++++++-------
drivers/usb/gadget/atmel_usba_udc.c | 28 +++++++++++++++++++++-------
drivers/video/atmel_lcdfb.c | 8 ++++----
5 files changed, 65 insertions(+), 26 deletions(-)

--
1.7.9.5


2013-07-18 07:34:46

by Boris BREZILLON

[permalink] [raw]
Subject: [PATCH v4 1/5] ARM: at91/tc/clocksource: replace clk_enable/disable with clk_prepare_enable/disable_unprepare.

Replace clk_enable/disable with clk_prepare_enable/disable_unprepare to
avoid common clk framework warnings.

Signed-off-by: Boris BREZILLON <[email protected]>
---
drivers/clocksource/tcb_clksrc.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/clocksource/tcb_clksrc.c b/drivers/clocksource/tcb_clksrc.c
index 8a61872..229c019 100644
--- a/drivers/clocksource/tcb_clksrc.c
+++ b/drivers/clocksource/tcb_clksrc.c
@@ -100,7 +100,7 @@ static void tc_mode(enum clock_event_mode m, struct clock_event_device *d)
|| tcd->clkevt.mode == CLOCK_EVT_MODE_ONESHOT) {
__raw_writel(0xff, regs + ATMEL_TC_REG(2, IDR));
__raw_writel(ATMEL_TC_CLKDIS, regs + ATMEL_TC_REG(2, CCR));
- clk_disable(tcd->clk);
+ clk_disable_unprepare(tcd->clk);
}

switch (m) {
@@ -109,7 +109,7 @@ static void tc_mode(enum clock_event_mode m, struct clock_event_device *d)
* of oneshot, we get lower overhead and improved accuracy.
*/
case CLOCK_EVT_MODE_PERIODIC:
- clk_enable(tcd->clk);
+ clk_prepare_enable(tcd->clk);

/* slow clock, count up to RC, then irq and restart */
__raw_writel(timer_clock
@@ -126,7 +126,7 @@ static void tc_mode(enum clock_event_mode m, struct clock_event_device *d)
break;

case CLOCK_EVT_MODE_ONESHOT:
- clk_enable(tcd->clk);
+ clk_prepare_enable(tcd->clk);

/* slow clock, count up to RC, then irq and stop */
__raw_writel(timer_clock | ATMEL_TC_CPCSTOP
@@ -275,7 +275,7 @@ static int __init tcb_clksrc_init(void)
pdev = tc->pdev;

t0_clk = tc->clk[0];
- clk_enable(t0_clk);
+ clk_prepare_enable(t0_clk);

/* How fast will we be counting? Pick something over 5 MHz. */
rate = (u32) clk_get_rate(t0_clk);
@@ -313,7 +313,7 @@ static int __init tcb_clksrc_init(void)
/* tclib will give us three clocks no matter what the
* underlying platform supports.
*/
- clk_enable(tc->clk[1]);
+ clk_prepare_enable(tc->clk[1]);
/* setup both channel 0 & 1 */
tcb_setup_dual_chan(tc, best_divisor_idx);
}
--
1.7.9.5

2013-07-18 07:39:01

by Boris BREZILLON

[permalink] [raw]
Subject: [PATCH v4 2/5] mmc: atmel-mci: prepare clk before calling enable

Replace clk_enable/disable with clk_prepare_enable/disable_unprepare to
avoid common clk framework warnings.

Signed-off-by: Boris BREZILLON <[email protected]>
Acked-by: Ludovic Desroches <[email protected]>
---
drivers/mmc/host/atmel-mci.c | 34 +++++++++++++++++++++++++++-------
1 file changed, 27 insertions(+), 7 deletions(-)

diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index bdb84da..69e438e 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -378,6 +378,8 @@ static int atmci_regs_show(struct seq_file *s, void *v)
{
struct atmel_mci *host = s->private;
u32 *buf;
+ int ret = 0;
+

buf = kmalloc(ATMCI_REGS_SIZE, GFP_KERNEL);
if (!buf)
@@ -388,12 +390,16 @@ static int atmci_regs_show(struct seq_file *s, void *v)
* not disabling interrupts, so IMR and SR may not be
* consistent.
*/
+ ret = clk_prepare_enable(host->mck);
+ if (ret)
+ goto out;
+
spin_lock_bh(&host->lock);
- clk_enable(host->mck);
memcpy_fromio(buf, host->regs, ATMCI_REGS_SIZE);
- clk_disable(host->mck);
spin_unlock_bh(&host->lock);

+ clk_disable_unprepare(host->mck);
+
seq_printf(s, "MR:\t0x%08x%s%s ",
buf[ATMCI_MR / 4],
buf[ATMCI_MR / 4] & ATMCI_MR_RDPROOF ? " RDPROOF" : "",
@@ -442,9 +448,10 @@ static int atmci_regs_show(struct seq_file *s, void *v)
val & ATMCI_CFG_LSYNC ? " LSYNC" : "");
}

+out:
kfree(buf);

- return 0;
+ return ret;
}

static int atmci_regs_open(struct inode *inode, struct file *file)
@@ -1262,6 +1269,7 @@ static void atmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
struct atmel_mci_slot *slot = mmc_priv(mmc);
struct atmel_mci *host = slot->host;
unsigned int i;
+ bool unprepare_clk;

slot->sdc_reg &= ~ATMCI_SDCBUS_MASK;
switch (ios->bus_width) {
@@ -1277,9 +1285,13 @@ static void atmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
unsigned int clock_min = ~0U;
u32 clkdiv;

+ clk_prepare(host->mck);
+ unprepare_clk = true;
+
spin_lock_bh(&host->lock);
if (!host->mode_reg) {
clk_enable(host->mck);
+ unprepare_clk = false;
atmci_writel(host, ATMCI_CR, ATMCI_CR_SWRST);
atmci_writel(host, ATMCI_CR, ATMCI_CR_MCIEN);
if (host->caps.has_cfg_reg)
@@ -1347,6 +1359,8 @@ static void atmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
} else {
bool any_slot_active = false;

+ unprepare_clk = false;
+
spin_lock_bh(&host->lock);
slot->clock = 0;
for (i = 0; i < ATMCI_MAX_NR_SLOTS; i++) {
@@ -1360,12 +1374,16 @@ static void atmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
if (host->mode_reg) {
atmci_readl(host, ATMCI_MR);
clk_disable(host->mck);
+ unprepare_clk = true;
}
host->mode_reg = 0;
}
spin_unlock_bh(&host->lock);
}

+ if (unprepare_clk)
+ clk_unprepare(host->mck);
+
switch (ios->power_mode) {
case MMC_POWER_UP:
set_bit(ATMCI_CARD_NEED_INIT, &slot->flags);
@@ -2376,10 +2394,12 @@ static int __init atmci_probe(struct platform_device *pdev)
if (!host->regs)
goto err_ioremap;

- clk_enable(host->mck);
+ ret = clk_prepare_enable(host->mck);
+ if (ret)
+ goto err_request_irq;
atmci_writel(host, ATMCI_CR, ATMCI_CR_SWRST);
host->bus_hz = clk_get_rate(host->mck);
- clk_disable(host->mck);
+ clk_disable_unprepare(host->mck);

host->mapbase = regs->start;

@@ -2482,11 +2502,11 @@ static int __exit atmci_remove(struct platform_device *pdev)
atmci_cleanup_slot(host->slot[i], i);
}

- clk_enable(host->mck);
+ clk_prepare_enable(host->mck);
atmci_writel(host, ATMCI_IDR, ~0UL);
atmci_writel(host, ATMCI_CR, ATMCI_CR_MCIDIS);
atmci_readl(host, ATMCI_SR);
- clk_disable(host->mck);
+ clk_disable_unprepare(host->mck);

if (host->dma.chan)
dma_release_channel(host->dma.chan);
--
1.7.9.5

2013-07-18 07:43:15

by Boris BREZILLON

[permalink] [raw]
Subject: [PATCH v4 4/5] USB: gadget: atmel_usba: prepare clk before calling enable

Replace clk_enable/disable with clk_prepare_enable/disable_unprepare to
avoid common clk framework warnings.

Signed-off-by: Boris BREZILLON <[email protected]>
---
drivers/usb/gadget/atmel_usba_udc.c | 28 +++++++++++++++++++++-------
1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c
index 1d97222..f018017 100644
--- a/drivers/usb/gadget/atmel_usba_udc.c
+++ b/drivers/usb/gadget/atmel_usba_udc.c
@@ -1772,6 +1772,7 @@ out:
static int atmel_usba_start(struct usb_gadget *gadget,
struct usb_gadget_driver *driver)
{
+ int ret = 0;
struct usba_udc *udc = container_of(gadget, struct usba_udc, gadget);
unsigned long flags;

@@ -1781,8 +1782,14 @@ static int atmel_usba_start(struct usb_gadget *gadget,
udc->driver = driver;
spin_unlock_irqrestore(&udc->lock, flags);

- clk_enable(udc->pclk);
- clk_enable(udc->hclk);
+ ret = clk_prepare_enable(udc->pclk);
+ if (ret)
+ goto out;
+ ret = clk_prepare_enable(udc->hclk);
+ if (ret) {
+ clk_disable_unprepare(udc->pclk);
+ goto out;
+ }

DBG(DBG_GADGET, "registered driver `%s'\n", driver->driver.name);

@@ -1797,9 +1804,11 @@ static int atmel_usba_start(struct usb_gadget *gadget,
usba_writel(udc, CTRL, USBA_ENABLE_MASK);
usba_writel(udc, INT_ENB, USBA_END_OF_RESET);
}
+
+out:
spin_unlock_irqrestore(&udc->lock, flags);

- return 0;
+ return ret;
}

static int atmel_usba_stop(struct usb_gadget *gadget,
@@ -1822,8 +1831,8 @@ static int atmel_usba_stop(struct usb_gadget *gadget,

udc->driver = NULL;

- clk_disable(udc->hclk);
- clk_disable(udc->pclk);
+ clk_disable_unprepare(udc->hclk);
+ clk_disable_unprepare(udc->pclk);

DBG(DBG_GADGET, "unregistered driver `%s'\n", driver->driver.name);

@@ -2022,10 +2031,14 @@ static int __init usba_udc_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, udc);

/* Make sure we start from a clean slate */
- clk_enable(pclk);
+ ret = clk_prepare_enable(pclk);
+ if (ret) {
+ dev_err(&pdev->dev, "Unable to enable pclk, aborting.\n");
+ goto err_clk_enable;
+ }
toggle_bias(0);
usba_writel(udc, CTRL, USBA_DISABLE_MASK);
- clk_disable(pclk);
+ clk_disable_unprepare(pclk);

if (pdev->dev.of_node)
udc->usba_ep = atmel_udc_of_init(pdev, udc);
@@ -2081,6 +2094,7 @@ err_add_udc:
free_irq(irq, udc);
err_request_irq:
err_alloc_ep:
+err_clk_enable:
iounmap(udc->fifo);
err_map_fifo:
iounmap(udc->regs);
--
1.7.9.5

2013-07-18 07:48:45

by Boris BREZILLON

[permalink] [raw]
Subject: [PATCH v4 5/5] ASoC: atmel-ssc: remove clk_disable_unprepare call from critical section

clk_prepare/unprepare (and indirectly clk_prepare_enable/disable_unprepare)
may sleep and thus cannot be called in critical section.

This patch fix a bug introduced by commit
6f0d94790efe9f4481bbd7c174ef0e9b5e5db7c4 where clk_disable_unprepare was
called with user_lock hold.

Signed-off-by: Boris BREZILLON <[email protected]>
---
drivers/misc/atmel-ssc.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c
index f7b90661..e068a76 100644
--- a/drivers/misc/atmel-ssc.c
+++ b/drivers/misc/atmel-ssc.c
@@ -66,14 +66,19 @@ EXPORT_SYMBOL(ssc_request);

void ssc_free(struct ssc_device *ssc)
{
+ bool disable_clk = true;
+
spin_lock(&user_lock);
- if (ssc->user) {
+ if (ssc->user)
ssc->user--;
- clk_disable_unprepare(ssc->clk);
- } else {
+ else {
+ disable_clk = false;
dev_dbg(&ssc->pdev->dev, "device already free\n");
}
spin_unlock(&user_lock);
+
+ if (disable_clk)
+ clk_disable_unprepare(ssc->clk);
}
EXPORT_SYMBOL(ssc_free);

--
1.7.9.5

2013-07-18 07:49:30

by Boris BREZILLON

[permalink] [raw]
Subject: [PATCH v4 3/5] at91/avr32/atmel_lcdfb: prepare clk before calling enable

Replace clk_enable/disable with clk_prepare_enable/disable_unprepare to
avoid common clk framework warnings.

Signed-off-by: Boris BREZILLON <[email protected]>
Acked-by: Nicolas Ferre <[email protected]>
---
drivers/video/atmel_lcdfb.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c
index ece49d5..bf9c5d0 100644
--- a/drivers/video/atmel_lcdfb.c
+++ b/drivers/video/atmel_lcdfb.c
@@ -954,14 +954,14 @@ static int __init atmel_lcdfb_init_fbinfo(struct atmel_lcdfb_info *sinfo)

static void atmel_lcdfb_start_clock(struct atmel_lcdfb_info *sinfo)
{
- clk_enable(sinfo->bus_clk);
- clk_enable(sinfo->lcdc_clk);
+ clk_prepare_enable(sinfo->bus_clk);
+ clk_prepare_enable(sinfo->lcdc_clk);
}

static void atmel_lcdfb_stop_clock(struct atmel_lcdfb_info *sinfo)
{
- clk_disable(sinfo->bus_clk);
- clk_disable(sinfo->lcdc_clk);
+ clk_disable_unprepare(sinfo->bus_clk);
+ clk_disable_unprepare(sinfo->lcdc_clk);
}

#ifdef CONFIG_OF
--
1.7.9.5

2013-07-18 08:04:31

by Boris BREZILLON

[permalink] [raw]
Subject: [PATCH v4 1/5] ARM: at91/tc/clocksource: replace clk_enable/disable with clk_prepare_enable/disable_unprepare.

Replace clk_enable/disable with clk_prepare_enable/disable_unprepare to
avoid common clk framework warnings.

Signed-off-by: Boris BREZILLON <[email protected]>
---
drivers/clocksource/tcb_clksrc.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/clocksource/tcb_clksrc.c b/drivers/clocksource/tcb_clksrc.c
index 8a61872..229c019 100644
--- a/drivers/clocksource/tcb_clksrc.c
+++ b/drivers/clocksource/tcb_clksrc.c
@@ -100,7 +100,7 @@ static void tc_mode(enum clock_event_mode m, struct clock_event_device *d)
|| tcd->clkevt.mode == CLOCK_EVT_MODE_ONESHOT) {
__raw_writel(0xff, regs + ATMEL_TC_REG(2, IDR));
__raw_writel(ATMEL_TC_CLKDIS, regs + ATMEL_TC_REG(2, CCR));
- clk_disable(tcd->clk);
+ clk_disable_unprepare(tcd->clk);
}

switch (m) {
@@ -109,7 +109,7 @@ static void tc_mode(enum clock_event_mode m, struct clock_event_device *d)
* of oneshot, we get lower overhead and improved accuracy.
*/
case CLOCK_EVT_MODE_PERIODIC:
- clk_enable(tcd->clk);
+ clk_prepare_enable(tcd->clk);

/* slow clock, count up to RC, then irq and restart */
__raw_writel(timer_clock
@@ -126,7 +126,7 @@ static void tc_mode(enum clock_event_mode m, struct clock_event_device *d)
break;

case CLOCK_EVT_MODE_ONESHOT:
- clk_enable(tcd->clk);
+ clk_prepare_enable(tcd->clk);

/* slow clock, count up to RC, then irq and stop */
__raw_writel(timer_clock | ATMEL_TC_CPCSTOP
@@ -275,7 +275,7 @@ static int __init tcb_clksrc_init(void)
pdev = tc->pdev;

t0_clk = tc->clk[0];
- clk_enable(t0_clk);
+ clk_prepare_enable(t0_clk);

/* How fast will we be counting? Pick something over 5 MHz. */
rate = (u32) clk_get_rate(t0_clk);
@@ -313,7 +313,7 @@ static int __init tcb_clksrc_init(void)
/* tclib will give us three clocks no matter what the
* underlying platform supports.
*/
- clk_enable(tc->clk[1]);
+ clk_prepare_enable(tc->clk[1]);
/* setup both channel 0 & 1 */
tcb_setup_dual_chan(tc, best_divisor_idx);
}
--
1.7.9.5

2013-07-18 09:53:55

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH v4 5/5] ASoC: atmel-ssc: remove clk_disable_unprepare call from critical section

On Thu, Jul 18, 2013 at 09:48:40AM +0200, Boris BREZILLON wrote:
> clk_prepare/unprepare (and indirectly clk_prepare_enable/disable_unprepare)
> may sleep and thus cannot be called in critical section.

I'm missing patches 1-4?


Attachments:
(No filename) (228.00 B)
signature.asc (836.00 B)
Digital signature
Download all attachments

2013-07-18 10:39:36

by Boris BREZILLON

[permalink] [raw]
Subject: Re: [PATCH v4 5/5] ASoC: atmel-ssc: remove clk_disable_unprepare call from critical section

On 18/07/2013 11:53, Mark Brown wrote:
> On Thu, Jul 18, 2013 at 09:48:40AM +0200, Boris BREZILLON wrote:
>> clk_prepare/unprepare (and indirectly clk_prepare_enable/disable_unprepare)
>> may sleep and thus cannot be called in critical section.
> I'm missing patches 1-4?
I can send you the whole series if you want (already sent to LKML and
LAKML).

But I'd like to understand who I should send patches from this series to.

Here's my approach:
1) send all patches of the series to at91 maintainers (as they are
directly concerned).
2) send all patches of the series LKML and LAKML
3) send each patch of the series to the persons and mailing lists
concerned by this patch :
contributors and maintainers (retrieved by get_maintainer.pl script)

Could you tell me if I'm doing something wrong?

Thanks

Best Regards,

Boris

2013-07-18 10:58:57

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH v4 5/5] ASoC: atmel-ssc: remove clk_disable_unprepare call from critical section

On Thu, Jul 18, 2013 at 12:21:38PM +0200, boris brezillon wrote:

> I can send you the whole series if you want (already sent to LKML
> and LAKML).

> But I'd like to understand who I should send patches from this series to.

When you send me patch 5/5 with no other information on the rest of the
series I've no idea if there's any dependencies on the other code or
anything like that. The key thing here is to make sure the people
getting the patch can understand the interdependencies somehow.

If you're sending a bunch of unrelated changes with no dependencies
you're better off sending them all separately rather than as a part of a
series.


Attachments:
(No filename) (648.00 B)
signature.asc (836.00 B)
Digital signature
Download all attachments

2013-07-18 11:26:00

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH v4 5/5] ASoC: atmel-ssc: remove clk_disable_unprepare call from critical section

On Thu, Jul 18, 2013 at 09:48:40AM +0200, Boris BREZILLON wrote:
> clk_prepare/unprepare (and indirectly clk_prepare_enable/disable_unprepare)
> may sleep and thus cannot be called in critical section.

Applied, thanks.


Attachments:
(No filename) (220.00 B)
signature.asc (836.00 B)
Digital signature
Download all attachments

2013-07-18 11:34:16

by Boris BREZILLON

[permalink] [raw]
Subject: Re: [PATCH v4 5/5] ASoC: atmel-ssc: remove clk_disable_unprepare call from critical section

On 18/07/2013 13:25, Mark Brown wrote:
> On Thu, Jul 18, 2013 at 09:48:40AM +0200, Boris BREZILLON wrote:
>> clk_prepare/unprepare (and indirectly clk_prepare_enable/disable_unprepare)
>> may sleep and thus cannot be called in critical section.
> Applied, thanks.
Thanks

2013-07-18 12:09:34

by Boris BREZILLON

[permalink] [raw]
Subject: Re: [PATCH v4 5/5] ASoC: atmel-ssc: remove clk_disable_unprepare call from critical section

On 18/07/2013 12:58, Mark Brown wrote:
> On Thu, Jul 18, 2013 at 12:21:38PM +0200, boris brezillon wrote:
>
>> I can send you the whole series if you want (already sent to LKML
>> and LAKML).
>> But I'd like to understand who I should send patches from this series to.
> When you send me patch 5/5 with no other information on the rest of the
> series I've no idea if there's any dependencies on the other code or
> anything like that. The key thing here is to make sure the people
> getting the patch can understand the interdependencies somehow.
>
> If you're sending a bunch of unrelated changes with no dependencies
> you're better off sending them all separately rather than as a part of a
> series.
Noted, I will send each patch separately next time (if they are unrelated).

Subject: Re: [PATCH v4 0/5] ARM: at91: prepare transition to common clk framework

On 09:32 Thu 18 Jul , Boris BREZILLON wrote:
> Hello,
>
> This patch series prepares the transition to common clk framework by
> replacing all the clk_enable and clk_disable calls by clk_prepare_unable and
> clk_disable_unprepare to avoid common clock framework warnings.
on the whole serie

Acked-by: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>

>
> Best Regards,
> Boris
>
> Changes since v3:
> - move usb clock config patches out of this series
> - move clk_prepare/unprepare calls out of critical sections (ssc and
> mci drivers)
> - remove already applied spi clk_prepare patch
>
> Changes since v2:
> - add configuraton of usb clock in ohci and udc drivers
> - add clk_prepare patch for usba udc driver
> - add clk_prepare patch for spi driver
> - remove already applied udc clk_prepare patch
>
> Changes since v1:
> - remove unneeded clk_unprepare in mci driver
> - remove already applied patches (ehci, ohci, dma and serial)
>
> Changes since common clk patch series:
> - add clk_prepare_enable return check
> - fix a deadlock in atmel-mci (missing spin_unlock)
> - remove already applied patches (atmel-ssc and pwm-atmel-tcb)
>
> Boris BREZILLON (5):
> ARM: at91/tc/clocksource: replace clk_enable/disable with
> clk_prepare_enable/disable_unprepare.
> mmc: atmel-mci: prepare clk before calling enable
> at91/avr32/atmel_lcdfb: prepare clk before calling enable
> USB: gadget: atmel_usba: prepare clk before calling enable
> ASoC: atmel-ssc: remove clk_disable_unprepare call from critical
> section
>
> drivers/clocksource/tcb_clksrc.c | 10 +++++-----
> drivers/misc/atmel-ssc.c | 11 ++++++++---
> drivers/mmc/host/atmel-mci.c | 34 +++++++++++++++++++++++++++-------
> drivers/usb/gadget/atmel_usba_udc.c | 28 +++++++++++++++++++++-------
> drivers/video/atmel_lcdfb.c | 8 ++++----
> 5 files changed, 65 insertions(+), 26 deletions(-)
>
> --
> 1.7.9.5
>

2013-08-21 12:13:18

by Nicolas Ferre

[permalink] [raw]
Subject: Re: [PATCH v4 1/5] ARM: at91/tc/clocksource: replace clk_enable/disable with clk_prepare_enable/disable_unprepare.

On 18/07/2013 09:58, Boris BREZILLON :
> Replace clk_enable/disable with clk_prepare_enable/disable_unprepare to
> avoid common clk framework warnings.
>
> Signed-off-by: Boris BREZILLON <[email protected]>

Acked-by: Nicolas Ferre <[email protected]>

John, Thomas,

Do you want me to re-sent this patch with acked-by collected or you can
take it like this?

Also, tell me if I should take it with other AT91-related changes
through ARM-soc git tree?

Bye,

> ---
> drivers/clocksource/tcb_clksrc.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/clocksource/tcb_clksrc.c b/drivers/clocksource/tcb_clksrc.c
> index 8a61872..229c019 100644
> --- a/drivers/clocksource/tcb_clksrc.c
> +++ b/drivers/clocksource/tcb_clksrc.c
> @@ -100,7 +100,7 @@ static void tc_mode(enum clock_event_mode m, struct clock_event_device *d)
> || tcd->clkevt.mode == CLOCK_EVT_MODE_ONESHOT) {
> __raw_writel(0xff, regs + ATMEL_TC_REG(2, IDR));
> __raw_writel(ATMEL_TC_CLKDIS, regs + ATMEL_TC_REG(2, CCR));
> - clk_disable(tcd->clk);
> + clk_disable_unprepare(tcd->clk);
> }
>
> switch (m) {
> @@ -109,7 +109,7 @@ static void tc_mode(enum clock_event_mode m, struct clock_event_device *d)
> * of oneshot, we get lower overhead and improved accuracy.
> */
> case CLOCK_EVT_MODE_PERIODIC:
> - clk_enable(tcd->clk);
> + clk_prepare_enable(tcd->clk);
>
> /* slow clock, count up to RC, then irq and restart */
> __raw_writel(timer_clock
> @@ -126,7 +126,7 @@ static void tc_mode(enum clock_event_mode m, struct clock_event_device *d)
> break;
>
> case CLOCK_EVT_MODE_ONESHOT:
> - clk_enable(tcd->clk);
> + clk_prepare_enable(tcd->clk);
>
> /* slow clock, count up to RC, then irq and stop */
> __raw_writel(timer_clock | ATMEL_TC_CPCSTOP
> @@ -275,7 +275,7 @@ static int __init tcb_clksrc_init(void)
> pdev = tc->pdev;
>
> t0_clk = tc->clk[0];
> - clk_enable(t0_clk);
> + clk_prepare_enable(t0_clk);
>
> /* How fast will we be counting? Pick something over 5 MHz. */
> rate = (u32) clk_get_rate(t0_clk);
> @@ -313,7 +313,7 @@ static int __init tcb_clksrc_init(void)
> /* tclib will give us three clocks no matter what the
> * underlying platform supports.
> */
> - clk_enable(tc->clk[1]);
> + clk_prepare_enable(tc->clk[1]);
> /* setup both channel 0 & 1 */
> tcb_setup_dual_chan(tc, best_divisor_idx);
> }
>


--
Nicolas Ferre

2013-08-22 09:41:19

by Boris BREZILLON

[permalink] [raw]
Subject: Re: [PATCH v4 2/5] mmc: atmel-mci: prepare clk before calling enable

Hello Chris,

Could you take this patch ?

It has been acked by Ludovic, and I need it in order to gracefully handle
at91's SoCs migration to common clk framework.

Thanks.

Best Regards,

Boris

On 18/07/2013 09:38, Boris BREZILLON wrote:
> Replace clk_enable/disable with clk_prepare_enable/disable_unprepare to
> avoid common clk framework warnings.
>
> Signed-off-by: Boris BREZILLON <[email protected]>
> Acked-by: Ludovic Desroches <[email protected]>
> ---
> drivers/mmc/host/atmel-mci.c | 34 +++++++++++++++++++++++++++-------
> 1 file changed, 27 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
> index bdb84da..69e438e 100644
> --- a/drivers/mmc/host/atmel-mci.c
> +++ b/drivers/mmc/host/atmel-mci.c
> @@ -378,6 +378,8 @@ static int atmci_regs_show(struct seq_file *s, void *v)
> {
> struct atmel_mci *host = s->private;
> u32 *buf;
> + int ret = 0;
> +
>
> buf = kmalloc(ATMCI_REGS_SIZE, GFP_KERNEL);
> if (!buf)
> @@ -388,12 +390,16 @@ static int atmci_regs_show(struct seq_file *s, void *v)
> * not disabling interrupts, so IMR and SR may not be
> * consistent.
> */
> + ret = clk_prepare_enable(host->mck);
> + if (ret)
> + goto out;
> +
> spin_lock_bh(&host->lock);
> - clk_enable(host->mck);
> memcpy_fromio(buf, host->regs, ATMCI_REGS_SIZE);
> - clk_disable(host->mck);
> spin_unlock_bh(&host->lock);
>
> + clk_disable_unprepare(host->mck);
> +
> seq_printf(s, "MR:\t0x%08x%s%s ",
> buf[ATMCI_MR / 4],
> buf[ATMCI_MR / 4] & ATMCI_MR_RDPROOF ? " RDPROOF" : "",
> @@ -442,9 +448,10 @@ static int atmci_regs_show(struct seq_file *s, void *v)
> val & ATMCI_CFG_LSYNC ? " LSYNC" : "");
> }
>
> +out:
> kfree(buf);
>
> - return 0;
> + return ret;
> }
>
> static int atmci_regs_open(struct inode *inode, struct file *file)
> @@ -1262,6 +1269,7 @@ static void atmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
> struct atmel_mci_slot *slot = mmc_priv(mmc);
> struct atmel_mci *host = slot->host;
> unsigned int i;
> + bool unprepare_clk;
>
> slot->sdc_reg &= ~ATMCI_SDCBUS_MASK;
> switch (ios->bus_width) {
> @@ -1277,9 +1285,13 @@ static void atmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
> unsigned int clock_min = ~0U;
> u32 clkdiv;
>
> + clk_prepare(host->mck);
> + unprepare_clk = true;
> +
> spin_lock_bh(&host->lock);
> if (!host->mode_reg) {
> clk_enable(host->mck);
> + unprepare_clk = false;
> atmci_writel(host, ATMCI_CR, ATMCI_CR_SWRST);
> atmci_writel(host, ATMCI_CR, ATMCI_CR_MCIEN);
> if (host->caps.has_cfg_reg)
> @@ -1347,6 +1359,8 @@ static void atmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
> } else {
> bool any_slot_active = false;
>
> + unprepare_clk = false;
> +
> spin_lock_bh(&host->lock);
> slot->clock = 0;
> for (i = 0; i < ATMCI_MAX_NR_SLOTS; i++) {
> @@ -1360,12 +1374,16 @@ static void atmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
> if (host->mode_reg) {
> atmci_readl(host, ATMCI_MR);
> clk_disable(host->mck);
> + unprepare_clk = true;
> }
> host->mode_reg = 0;
> }
> spin_unlock_bh(&host->lock);
> }
>
> + if (unprepare_clk)
> + clk_unprepare(host->mck);
> +
> switch (ios->power_mode) {
> case MMC_POWER_UP:
> set_bit(ATMCI_CARD_NEED_INIT, &slot->flags);
> @@ -2376,10 +2394,12 @@ static int __init atmci_probe(struct platform_device *pdev)
> if (!host->regs)
> goto err_ioremap;
>
> - clk_enable(host->mck);
> + ret = clk_prepare_enable(host->mck);
> + if (ret)
> + goto err_request_irq;
> atmci_writel(host, ATMCI_CR, ATMCI_CR_SWRST);
> host->bus_hz = clk_get_rate(host->mck);
> - clk_disable(host->mck);
> + clk_disable_unprepare(host->mck);
>
> host->mapbase = regs->start;
>
> @@ -2482,11 +2502,11 @@ static int __exit atmci_remove(struct platform_device *pdev)
> atmci_cleanup_slot(host->slot[i], i);
> }
>
> - clk_enable(host->mck);
> + clk_prepare_enable(host->mck);
> atmci_writel(host, ATMCI_IDR, ~0UL);
> atmci_writel(host, ATMCI_CR, ATMCI_CR_MCIDIS);
> atmci_readl(host, ATMCI_SR);
> - clk_disable(host->mck);
> + clk_disable_unprepare(host->mck);
>
> if (host->dma.chan)
> dma_release_channel(host->dma.chan);

2013-08-25 03:18:22

by Chris Ball

[permalink] [raw]
Subject: Re: [PATCH v4 2/5] mmc: atmel-mci: prepare clk before calling enable

Hi,

On Thu, Jul 18 2013, Boris BREZILLON wrote:
> Replace clk_enable/disable with clk_prepare_enable/disable_unprepare to
> avoid common clk framework warnings.
>
> Signed-off-by: Boris BREZILLON <[email protected]>
> Acked-by: Ludovic Desroches <[email protected]>

Okay, pushed to mmc-next for 3.12.

Boris, you got feedback from Thomas Petazzoni and Russell King, but
you didn't CC either of them on the patch v4, and you didn't write a
changelog explaining the differences between patches v3 and v4 --
please do both of those next time.

Also, it looks like the Ack from Ludovic happened away from the MMC
list, since I don't see a message from Ludovic on the thread here.
It would be better if the Ack happened somewhere I can see it.

Thanks,

- Chris.
--
Chris Ball <[email protected]> <http://printf.net/>

2013-08-25 05:35:25

by Boris BREZILLON

[permalink] [raw]
Subject: Re: [PATCH v4 2/5] mmc: atmel-mci: prepare clk before calling enable

Hello Chris,

On 25/08/2013 05:18, Chris Ball wrote:
> Hi,
>
> On Thu, Jul 18 2013, Boris BREZILLON wrote:
>> Replace clk_enable/disable with clk_prepare_enable/disable_unprepare to
>> avoid common clk framework warnings.
>>
>> Signed-off-by: Boris BREZILLON <[email protected]>
>> Acked-by: Ludovic Desroches <[email protected]>
> Okay, pushed to mmc-next for 3.12.

Thanks.

>
> Boris, you got feedback from Thomas Petazzoni and Russell King, but
> you didn't CC either of them on the patch v4

I didn't knew I had to add the reviewers of a patch in the cc list
of the future versions. I'll do it next time.

> , and you didn't write a
> changelog explaining the differences between patches v3 and v4 --
> please do both of those next time.

The changelog is in the cover letter ("Changes since v3").
But I didn't send you this cover letter.

> Also, it looks like the Ack from Ludovic happened away from the MMC
> list, since I don't see a message from Ludovic on the thread here.
> It would be better if the Ack happened somewhere I can see it.

The 'Acked-by: Ludovic Desroches <[email protected]>' was added
in the 2nd version of this patch series.
But I don't know if I should have kept it in this version since this
patch has evolved.


Thanks for these feebacks, I'm still learning the good practices of the
kernel
submission process.
I'll check these points next time.

Best Regards,

Boris
> Thanks,
>
> - Chris.

2013-08-30 07:18:58

by Tomi Valkeinen

[permalink] [raw]
Subject: Re: [PATCH v4 3/5] at91/avr32/atmel_lcdfb: prepare clk before calling enable

On 18/07/13 10:40, Boris BREZILLON wrote:
> Replace clk_enable/disable with clk_prepare_enable/disable_unprepare to
> avoid common clk framework warnings.
>
> Signed-off-by: Boris BREZILLON <[email protected]>
> Acked-by: Nicolas Ferre <[email protected]>
> ---
> drivers/video/atmel_lcdfb.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c
> index ece49d5..bf9c5d0 100644
> --- a/drivers/video/atmel_lcdfb.c
> +++ b/drivers/video/atmel_lcdfb.c
> @@ -954,14 +954,14 @@ static int __init atmel_lcdfb_init_fbinfo(struct atmel_lcdfb_info *sinfo)
>
> static void atmel_lcdfb_start_clock(struct atmel_lcdfb_info *sinfo)
> {
> - clk_enable(sinfo->bus_clk);
> - clk_enable(sinfo->lcdc_clk);
> + clk_prepare_enable(sinfo->bus_clk);
> + clk_prepare_enable(sinfo->lcdc_clk);
> }
>
> static void atmel_lcdfb_stop_clock(struct atmel_lcdfb_info *sinfo)
> {
> - clk_disable(sinfo->bus_clk);
> - clk_disable(sinfo->lcdc_clk);
> + clk_disable_unprepare(sinfo->bus_clk);
> + clk_disable_unprepare(sinfo->lcdc_clk);
> }
>
> #ifdef CONFIG_OF

Thanks, queued this for 3.12.

Tomi




Attachments:
signature.asc (901.00 B)
OpenPGP digital signature