linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mmc: renesas_sdhi_core: on R-Car 2+, make use of CBSY bit
@ 2017-05-30  9:03 Wolfram Sang
  2017-05-30 20:02 ` Wolfram Sang
  0 siblings, 1 reply; 4+ messages in thread
From: Wolfram Sang @ 2017-05-30  9:03 UTC (permalink / raw)
  To: linux-mmc; +Cc: linux-renesas-soc, Dirk Behme, Wolfram Sang

Most registers need to wait until the command is completed, not
necessarily until the bus is free. At least, R-Car 2+ SoCs can signal
that via the CBSY bit, so let's use it there instead of SCLKDIVEN to
save a little bit of delay.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---

Tested with a Renesas Lager board (H2). Moved big files around across different
SD cards, re- inserted cards multiple times. All worked fine.

@Dirk: can you do some additional testing for your use case? That would be much
appreciated!

Changes since RFC (from Jan 2016):
* rebased to latest code base
* use existing bit defines instead of creating new ones

 drivers/mmc/host/renesas_sdhi_core.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c
index 82150a96639195..288153b5f6835e 100644
--- a/drivers/mmc/host/renesas_sdhi_core.c
+++ b/drivers/mmc/host/renesas_sdhi_core.c
@@ -395,12 +395,14 @@ static void renesas_sdhi_hw_reset(struct tmio_mmc_host *host)
 		       sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL));
 }
 
-static int renesas_sdhi_wait_idle(struct tmio_mmc_host *host)
+static int renesas_sdhi_wait_idle(struct tmio_mmc_host *host, u32 bit)
 {
 	int timeout = 1000;
+	/* CBSY is set when busy, SCLKDIVEN is cleared when busy */
+	u32 wait_state = (bit == TMIO_STAT_CMD_BUSY ? TMIO_STAT_CMD_BUSY : 0);
 
-	while (--timeout && !(sd_ctrl_read16_and_16_as_32(host, CTL_STATUS)
-			      & TMIO_STAT_SCLKDIVEN))
+	while (--timeout && (sd_ctrl_read16_and_16_as_32(host, CTL_STATUS)
+			      & bit) == wait_state)
 		udelay(1);
 
 	if (!timeout) {
@@ -413,18 +415,23 @@ static int renesas_sdhi_wait_idle(struct tmio_mmc_host *host)
 
 static int renesas_sdhi_write16_hook(struct tmio_mmc_host *host, int addr)
 {
+	u32 bit = TMIO_STAT_SCLKDIVEN;
+
 	switch (addr)
 	{
 	case CTL_SD_CMD:
 	case CTL_STOP_INTERNAL_ACTION:
 	case CTL_XFER_BLK_COUNT:
-	case CTL_SD_CARD_CLK_CTL:
 	case CTL_SD_XFER_LEN:
 	case CTL_SD_MEM_CARD_OPT:
 	case CTL_TRANSACTION_CTL:
 	case CTL_DMA_ENABLE:
 	case EXT_ACC:
-		return renesas_sdhi_wait_idle(host);
+		if (host->pdata->flags & TMIO_MMC_MIN_RCAR2)
+			bit = TMIO_STAT_CMD_BUSY;
+		/* fallthrough */
+	case CTL_SD_CARD_CLK_CTL:
+		return renesas_sdhi_wait_idle(host, bit);
 	}
 
 	return 0;
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mmc: renesas_sdhi_core: on R-Car 2+, make use of CBSY bit
  2017-05-30  9:03 [PATCH] mmc: renesas_sdhi_core: on R-Car 2+, make use of CBSY bit Wolfram Sang
@ 2017-05-30 20:02 ` Wolfram Sang
  2017-05-31 19:56   ` Simon Horman
  0 siblings, 1 reply; 4+ messages in thread
From: Wolfram Sang @ 2017-05-30 20:02 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-mmc, linux-renesas-soc, Dirk Behme

[-- Attachment #1: Type: text/plain, Size: 883 bytes --]

On Tue, May 30, 2017 at 11:03:46AM +0200, Wolfram Sang wrote:
> Most registers need to wait until the command is completed, not
> necessarily until the bus is free. At least, R-Car 2+ SoCs can signal
> that via the CBSY bit, so let's use it there instead of SCLKDIVEN to
> save a little bit of delay.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
> 
> Tested with a Renesas Lager board (H2). Moved big files around across different
> SD cards, re- inserted cards multiple times. All worked fine.
> 
> @Dirk: can you do some additional testing for your use case? That would be much
> appreciated!

OK, since Dirk told me he'll need some more time to test it anyhow and
Simon meanwhile sent some cleanup patches, I'll simply post an updated
version of this patch once Simon's cleanup patches hit mmc/next. I think
this will be easiest.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mmc: renesas_sdhi_core: on R-Car 2+, make use of CBSY bit
  2017-05-30 20:02 ` Wolfram Sang
@ 2017-05-31 19:56   ` Simon Horman
  2017-05-31 20:21     ` Wolfram Sang
  0 siblings, 1 reply; 4+ messages in thread
From: Simon Horman @ 2017-05-31 19:56 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: Wolfram Sang, linux-mmc, linux-renesas-soc, Dirk Behme

On Tue, May 30, 2017 at 10:02:18PM +0200, Wolfram Sang wrote:
> On Tue, May 30, 2017 at 11:03:46AM +0200, Wolfram Sang wrote:
> > Most registers need to wait until the command is completed, not
> > necessarily until the bus is free. At least, R-Car 2+ SoCs can signal
> > that via the CBSY bit, so let's use it there instead of SCLKDIVEN to
> > save a little bit of delay.
> > 
> > Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> > ---
> > 
> > Tested with a Renesas Lager board (H2). Moved big files around across different
> > SD cards, re- inserted cards multiple times. All worked fine.
> > 
> > @Dirk: can you do some additional testing for your use case? That would be much
> > appreciated!
> 
> OK, since Dirk told me he'll need some more time to test it anyhow and
> Simon meanwhile sent some cleanup patches, I'll simply post an updated
> version of this patch once Simon's cleanup patches hit mmc/next. I think
> this will be easiest.

Thanks, sorry for the clash - we seem to often hit the SDHI driver
at about the same time.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mmc: renesas_sdhi_core: on R-Car 2+, make use of CBSY bit
  2017-05-31 19:56   ` Simon Horman
@ 2017-05-31 20:21     ` Wolfram Sang
  0 siblings, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2017-05-31 20:21 UTC (permalink / raw)
  To: Simon Horman; +Cc: Wolfram Sang, linux-mmc, linux-renesas-soc, Dirk Behme

[-- Attachment #1: Type: text/plain, Size: 213 bytes --]


> Thanks, sorry for the clash - we seem to often hit the SDHI driver
> at about the same time.

Yes, but given the amount of refactoring done, the rebase work is
surprisingly small. So, I am all fine :) Thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-05-31 20:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-30  9:03 [PATCH] mmc: renesas_sdhi_core: on R-Car 2+, make use of CBSY bit Wolfram Sang
2017-05-30 20:02 ` Wolfram Sang
2017-05-31 19:56   ` Simon Horman
2017-05-31 20:21     ` Wolfram Sang

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).