* [PATCH v2] mmc: tmio: Don't access hardware registers after stopping clocks
@ 2012-06-12 21:29 Laurent Pinchart
2012-06-13 1:17 ` Simon Horman
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Laurent Pinchart @ 2012-06-12 21:29 UTC (permalink / raw)
To: Guennadi Liakhovetski; +Cc: linux-mmc, linux-sh
The tmio_mmc_set_ios() function configures the MMC power, clock and bus
width. When the mmc core requests the driver to power off the card, we
inform runtime PM, that the controller can be suspended. This can lead
to the MSTP clock being turned off.
Writing to any 16-bit hardware registers with the MSTP clock off leads
to timeouts and errors being printed to the kernel log. This can occur
both when stopping the MMC clock and when configuring the bus width.
To fix this, stop the MMC clock before calling put_runtime_pm(), and
skip bus width configuration when power is off.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
drivers/mmc/host/tmio_mmc_pio.c | 18 ++++++++++--------
1 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index 9a7996a..53d1de6 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -810,19 +810,21 @@ static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
if (host->set_pwr && ios->power_mode = MMC_POWER_OFF)
host->set_pwr(host->pdev, 0);
if (host->power) {
+ tmio_mmc_clk_stop(host);
host->power = false;
pm_runtime_put(dev);
}
- tmio_mmc_clk_stop(host);
}
- switch (ios->bus_width) {
- case MMC_BUS_WIDTH_1:
- sd_ctrl_write16(host, CTL_SD_MEM_CARD_OPT, 0x80e0);
- break;
- case MMC_BUS_WIDTH_4:
- sd_ctrl_write16(host, CTL_SD_MEM_CARD_OPT, 0x00e0);
- break;
+ if (host->power) {
+ switch (ios->bus_width) {
+ case MMC_BUS_WIDTH_1:
+ sd_ctrl_write16(host, CTL_SD_MEM_CARD_OPT, 0x80e0);
+ break;
+ case MMC_BUS_WIDTH_4:
+ sd_ctrl_write16(host, CTL_SD_MEM_CARD_OPT, 0x00e0);
+ break;
+ }
}
/* Let things settle. delay taken from winCE driver */
--
Regards,
Laurent Pinchart
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2] mmc: tmio: Don't access hardware registers after stopping clocks
2012-06-12 21:29 [PATCH v2] mmc: tmio: Don't access hardware registers after stopping clocks Laurent Pinchart
@ 2012-06-13 1:17 ` Simon Horman
2012-06-13 7:42 ` Laurent Pinchart
2012-06-13 13:27 ` Guennadi Liakhovetski
2012-06-14 4:11 ` Kuninori Morimoto
2 siblings, 1 reply; 7+ messages in thread
From: Simon Horman @ 2012-06-13 1:17 UTC (permalink / raw)
To: Laurent Pinchart; +Cc: Guennadi Liakhovetski, linux-mmc, linux-sh
On Tue, Jun 12, 2012 at 11:29:35PM +0200, Laurent Pinchart wrote:
> The tmio_mmc_set_ios() function configures the MMC power, clock and bus
> width. When the mmc core requests the driver to power off the card, we
> inform runtime PM, that the controller can be suspended. This can lead
> to the MSTP clock being turned off.
>
> Writing to any 16-bit hardware registers with the MSTP clock off leads
> to timeouts and errors being printed to the kernel log. This can occur
> both when stopping the MMC clock and when configuring the bus width.
>
> To fix this, stop the MMC clock before calling put_runtime_pm(), and
> skip bus width configuration when power is off.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Hi Laurent,
could you let me know if there is a (simple :) way for me to exercise this?
> ---
> drivers/mmc/host/tmio_mmc_pio.c | 18 ++++++++++--------
> 1 files changed, 10 insertions(+), 8 deletions(-)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] mmc: tmio: Don't access hardware registers after stopping clocks
2012-06-13 1:17 ` Simon Horman
@ 2012-06-13 7:42 ` Laurent Pinchart
0 siblings, 0 replies; 7+ messages in thread
From: Laurent Pinchart @ 2012-06-13 7:42 UTC (permalink / raw)
To: Simon Horman; +Cc: Guennadi Liakhovetski, linux-mmc, linux-sh
Hi Simon,
On Wednesday 13 June 2012 10:17:12 Simon Horman wrote:
> On Tue, Jun 12, 2012 at 11:29:35PM +0200, Laurent Pinchart wrote:
> > The tmio_mmc_set_ios() function configures the MMC power, clock and bus
> > width. When the mmc core requests the driver to power off the card, we
> > inform runtime PM, that the controller can be suspended. This can lead
> > to the MSTP clock being turned off.
> >
> > Writing to any 16-bit hardware registers with the MSTP clock off leads
> > to timeouts and errors being printed to the kernel log. This can occur
> > both when stopping the MMC clock and when configuring the bus width.
> >
> > To fix this, stop the MMC clock before calling put_runtime_pm(), and
> > skip bus width configuration when power is off.
> >
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>
> Hi Laurent,
>
> could you let me know if there is a (simple :) way for me to exercise this?
Without the patch suspending the Armadillo board to RAM produces a "timeout
waiting for SD bus idle" message. Make sure you apply the "mmc: sh_mmcif:
Support MMC_SLEEP_AWAKE command" patch first, or suspending the board will
fail completely.
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] mmc: tmio: Don't access hardware registers after stopping clocks
2012-06-12 21:29 [PATCH v2] mmc: tmio: Don't access hardware registers after stopping clocks Laurent Pinchart
2012-06-13 1:17 ` Simon Horman
@ 2012-06-13 13:27 ` Guennadi Liakhovetski
2012-06-20 6:22 ` Chris Ball
2012-06-14 4:11 ` Kuninori Morimoto
2 siblings, 1 reply; 7+ messages in thread
From: Guennadi Liakhovetski @ 2012-06-13 13:27 UTC (permalink / raw)
To: Laurent Pinchart; +Cc: linux-mmc, linux-sh
On Tue, 12 Jun 2012, Laurent Pinchart wrote:
> The tmio_mmc_set_ios() function configures the MMC power, clock and bus
> width. When the mmc core requests the driver to power off the card, we
> inform runtime PM, that the controller can be suspended. This can lead
> to the MSTP clock being turned off.
>
> Writing to any 16-bit hardware registers with the MSTP clock off leads
> to timeouts and errors being printed to the kernel log. This can occur
> both when stopping the MMC clock and when configuring the bus width.
>
> To fix this, stop the MMC clock before calling put_runtime_pm(), and
> skip bus width configuration when power is off.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Thanks
Guennadi
> ---
> drivers/mmc/host/tmio_mmc_pio.c | 18 ++++++++++--------
> 1 files changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
> index 9a7996a..53d1de6 100644
> --- a/drivers/mmc/host/tmio_mmc_pio.c
> +++ b/drivers/mmc/host/tmio_mmc_pio.c
> @@ -810,19 +810,21 @@ static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
> if (host->set_pwr && ios->power_mode = MMC_POWER_OFF)
> host->set_pwr(host->pdev, 0);
> if (host->power) {
> + tmio_mmc_clk_stop(host);
> host->power = false;
> pm_runtime_put(dev);
> }
> - tmio_mmc_clk_stop(host);
> }
>
> - switch (ios->bus_width) {
> - case MMC_BUS_WIDTH_1:
> - sd_ctrl_write16(host, CTL_SD_MEM_CARD_OPT, 0x80e0);
> - break;
> - case MMC_BUS_WIDTH_4:
> - sd_ctrl_write16(host, CTL_SD_MEM_CARD_OPT, 0x00e0);
> - break;
> + if (host->power) {
> + switch (ios->bus_width) {
> + case MMC_BUS_WIDTH_1:
> + sd_ctrl_write16(host, CTL_SD_MEM_CARD_OPT, 0x80e0);
> + break;
> + case MMC_BUS_WIDTH_4:
> + sd_ctrl_write16(host, CTL_SD_MEM_CARD_OPT, 0x00e0);
> + break;
> + }
> }
>
> /* Let things settle. delay taken from winCE driver */
> --
> Regards,
>
> Laurent Pinchart
>
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] mmc: tmio: Don't access hardware registers after stopping clocks
2012-06-12 21:29 [PATCH v2] mmc: tmio: Don't access hardware registers after stopping clocks Laurent Pinchart
2012-06-13 1:17 ` Simon Horman
2012-06-13 13:27 ` Guennadi Liakhovetski
@ 2012-06-14 4:11 ` Kuninori Morimoto
2012-06-20 2:23 ` Simon Horman
2 siblings, 1 reply; 7+ messages in thread
From: Kuninori Morimoto @ 2012-06-14 4:11 UTC (permalink / raw)
To: Laurent Pinchart; +Cc: Guennadi Liakhovetski, linux-mmc, linux-sh
Laurent Pinchart wrote:
>
> The tmio_mmc_set_ios() function configures the MMC power, clock and bus
> width. When the mmc core requests the driver to power off the card, we
> inform runtime PM, that the controller can be suspended. This can lead
> to the MSTP clock being turned off.
>
> Writing to any 16-bit hardware registers with the MSTP clock off leads
> to timeouts and errors being printed to the kernel log. This can occur
> both when stopping the MMC clock and when configuring the bus width.
>
> To fix this, stop the MMC clock before calling put_runtime_pm(), and
> skip bus width configuration when power is off.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
This patch solved kzm9g MicroSD hang-up issue.
Tested-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Best regards
---
Kuninori Morimoto
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] mmc: tmio: Don't access hardware registers after stopping clocks
2012-06-14 4:11 ` Kuninori Morimoto
@ 2012-06-20 2:23 ` Simon Horman
0 siblings, 0 replies; 7+ messages in thread
From: Simon Horman @ 2012-06-20 2:23 UTC (permalink / raw)
To: Kuninori Morimoto
Cc: Laurent Pinchart, Guennadi Liakhovetski, linux-mmc, linux-sh
On Wed, Jun 13, 2012 at 09:11:13PM -0700, Kuninori Morimoto wrote:
>
> Laurent Pinchart wrote:
> >
> > The tmio_mmc_set_ios() function configures the MMC power, clock and bus
> > width. When the mmc core requests the driver to power off the card, we
> > inform runtime PM, that the controller can be suspended. This can lead
> > to the MSTP clock being turned off.
> >
> > Writing to any 16-bit hardware registers with the MSTP clock off leads
> > to timeouts and errors being printed to the kernel log. This can occur
> > both when stopping the MMC clock and when configuring the bus width.
> >
> > To fix this, stop the MMC clock before calling put_runtime_pm(), and
> > skip bus width configuration when power is off.
> >
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
>
> This patch solved kzm9g MicroSD hang-up issue.
>
> Tested-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Yes, it solves that issue for me too.
Tested-by: Simon Horman <horms@verge.net.au>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] mmc: tmio: Don't access hardware registers after stopping clocks
2012-06-13 13:27 ` Guennadi Liakhovetski
@ 2012-06-20 6:22 ` Chris Ball
0 siblings, 0 replies; 7+ messages in thread
From: Chris Ball @ 2012-06-20 6:22 UTC (permalink / raw)
To: Guennadi Liakhovetski; +Cc: Laurent Pinchart, linux-mmc, linux-sh
Hi,
On Wed, Jun 13 2012, Guennadi Liakhovetski wrote:
> On Tue, 12 Jun 2012, Laurent Pinchart wrote:
>
>> The tmio_mmc_set_ios() function configures the MMC power, clock and bus
>> width. When the mmc core requests the driver to power off the card, we
>> inform runtime PM, that the controller can be suspended. This can lead
>> to the MSTP clock being turned off.
>>
>> Writing to any 16-bit hardware registers with the MSTP clock off leads
>> to timeouts and errors being printed to the kernel log. This can occur
>> both when stopping the MMC clock and when configuring the bus width.
>>
>> To fix this, stop the MMC clock before calling put_runtime_pm(), and
>> skip bus width configuration when power is off.
>>
>> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>
> Acked-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Thanks, pushed to mmc-next for 3.6.
- Chris.
--
Chris Ball <cjb@laptop.org> <http://printf.net/>
One Laptop Per Child
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-06-20 6:22 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-12 21:29 [PATCH v2] mmc: tmio: Don't access hardware registers after stopping clocks Laurent Pinchart
2012-06-13 1:17 ` Simon Horman
2012-06-13 7:42 ` Laurent Pinchart
2012-06-13 13:27 ` Guennadi Liakhovetski
2012-06-20 6:22 ` Chris Ball
2012-06-14 4:11 ` Kuninori Morimoto
2012-06-20 2:23 ` Simon Horman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).