LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* mmc does not work in qemu n900
@ 2015-01-26 21:04 Pali Rohár
  2015-01-26 23:21 ` Aaro Koskinen
  2015-12-25 12:57 ` Pali Rohár
  0 siblings, 2 replies; 7+ messages in thread
From: Pali Rohár @ 2015-01-26 21:04 UTC (permalink / raw)
  To: Chris Ball, Ulf Hansson
  Cc: linux-mmc, linux-kernel, Pavel Machek, Ivaylo Dimitrov,
	Sebastian Reichel, Aaro Koskinen

[-- Attachment #1: Type: Text/Plain, Size: 1661 bytes --]

Hello,

for unknown reason kernel in qemu n900 machine is not able to 
detect internal eMMC memory. External SD card is detected without 
problem.

If I apply this one-line patch eMMC in qemu start working:

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 9584bff..0d4461c 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -2337,6 +2337,9 @@ static int mmc_rescan_try_freq(
 		return 0;
 	if (!mmc_attach_sd(host))
 		return 0;
+
+	mmc_go_idle(host);
+
 	if (!mmc_attach_mmc(host))
 		return 0;

I played with mmc and qemu n900 a bit and also this simple patch 
(without first) fix problem (that mmc is not detected by kernel):

diff --git a/drivers/mmc/core/mmc_ops.c 
b/drivers/mmc/core/mmc_ops.c
index 3b044c5..0c93a2c 100644
--- a/drivers/mmc/core/mmc_ops.c
+++ b/drivers/mmc/core/mmc_ops.c
@@ -157,6 +157,10 @@ int mmc_send_op_cond(
 
 	BUG_ON(!host);
 
+	/* reset mmc before calling op_cond */
+	memset(&cmd, 0, sizeof(struct mmc_command));
+	mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES);
+
 	cmd.opcode = MMC_SEND_OP_COND;
 	cmd.arg = mmc_host_is_spi(host) ? 0 : ocr;
 	cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R3 | MMC_CMD_BCR;
 

I have no idea where is problem. I also do not understand mmc 
kernel code, but second patch I have on my HDD since 2.6.37.

Can somebody with knowledge of mmc subsystem look at this 
problem? Why any of these two patches fix problem when mmc is not 
detected by kernel in qemu (machine n900)? Detection of mmc fails 
because function mmc_send_op_cond() without one of above patches 
fails.

-- 
Pali Rohár
pali.rohar@gmail.com

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: mmc does not work in qemu n900
  2015-01-26 21:04 mmc does not work in qemu n900 Pali Rohár
@ 2015-01-26 23:21 ` Aaro Koskinen
  2015-01-27  9:17   ` Pali Rohár
  2015-12-25 12:57 ` Pali Rohár
  1 sibling, 1 reply; 7+ messages in thread
From: Aaro Koskinen @ 2015-01-26 23:21 UTC (permalink / raw)
  To: Pali Rohár
  Cc: Chris Ball, Ulf Hansson, linux-mmc, linux-kernel, Pavel Machek,
	Ivaylo Dimitrov, Sebastian Reichel

Hi,

On Mon, Jan 26, 2015 at 10:04:59PM +0100, Pali Rohár wrote:
> problem? Why any of these two patches fix problem when mmc is not 
> detected by kernel in qemu (machine n900)? Detection of mmc fails 
> because function mmc_send_op_cond() without one of above patches 
> fails.

Has it ever worked? It could be just that QEMU's emulation is broken.
Since the kernel works on actual HW, you probably should contact
QEMU maintainers.

I don't see n900 in Debian's QEMU. There's n800 and n810 but
I couldn't boot any of my kernels with those...

A.

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

* Re: mmc does not work in qemu n900
  2015-01-26 23:21 ` Aaro Koskinen
@ 2015-01-27  9:17   ` Pali Rohár
  2015-01-30 14:23     ` Pali Rohár
  0 siblings, 1 reply; 7+ messages in thread
From: Pali Rohár @ 2015-01-27  9:17 UTC (permalink / raw)
  To: Aaro Koskinen
  Cc: Chris Ball, Ulf Hansson, linux-mmc, linux-kernel, Pavel Machek,
	Ivaylo Dimitrov, Sebastian Reichel

[-- Attachment #1: Type: Text/Plain, Size: 921 bytes --]

On Tuesday 27 January 2015 00:21:04 Aaro Koskinen wrote:
> Hi,
> 
> On Mon, Jan 26, 2015 at 10:04:59PM +0100, Pali Rohár wrote:
> > problem? Why any of these two patches fix problem when mmc
> > is not detected by kernel in qemu (machine n900)? Detection
> > of mmc fails because function mmc_send_op_cond() without
> > one of above patches fails.
> 
> Has it ever worked? It could be just that QEMU's emulation is
> broken. Since the kernel works on actual HW, you probably
> should contact QEMU maintainers.
> 
> I don't see n900 in Debian's QEMU. There's n800 and n810 but
> I couldn't boot any of my kernels with those...
> 
> A.

It worked with stock Nokia kernel (2.6.28).

N900 qemu support is not in upstream qemu project, but in linaro 
qemu version. You can find it e.g. in ubuntu: 
http://packages.ubuntu.com/source/precise-updates/qemu-linaro

-- 
Pali Rohár
pali.rohar@gmail.com

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: mmc does not work in qemu n900
  2015-01-27  9:17   ` Pali Rohár
@ 2015-01-30 14:23     ` Pali Rohár
  2015-02-07 23:02       ` Pali Rohár
  2016-12-14 21:25       ` Pali Rohár
  0 siblings, 2 replies; 7+ messages in thread
From: Pali Rohár @ 2015-01-30 14:23 UTC (permalink / raw)
  To: Aaro Koskinen
  Cc: Chris Ball, Ulf Hansson, linux-mmc, linux-kernel, Pavel Machek,
	Ivaylo Dimitrov, Sebastian Reichel

[-- Attachment #1: Type: Text/Plain, Size: 1996 bytes --]

On Tuesday 27 January 2015 10:17:39 Pali Rohár wrote:
> On Tuesday 27 January 2015 00:21:04 Aaro Koskinen wrote:
> > Hi,
> > 
> > On Mon, Jan 26, 2015 at 10:04:59PM +0100, Pali Rohár wrote:
> > > problem? Why any of these two patches fix problem when mmc
> > > is not detected by kernel in qemu (machine n900)?
> > > Detection of mmc fails because function
> > > mmc_send_op_cond() without one of above patches fails.
> > 
> > Has it ever worked? It could be just that QEMU's emulation
> > is broken. Since the kernel works on actual HW, you
> > probably should contact QEMU maintainers.
> > 
> > I don't see n900 in Debian's QEMU. There's n800 and n810 but
> > I couldn't boot any of my kernels with those...
> > 
> > A.
> 
> It worked with stock Nokia kernel (2.6.28).
> 
> N900 qemu support is not in upstream qemu project, but in
> linaro qemu version. You can find it e.g. in ubuntu:
> http://packages.ubuntu.com/source/precise-updates/qemu-linaro

Here is another alternative patch which enable internal eMMC 
support in qemu n900:

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 9584bff..225df49 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -2330,13 +2330,13 @@ static int mmc_rescan_try_freq(struct 
mmc_host *host, unsigned freq)
 	sdio_reset(host);
 	mmc_go_idle(host);
 
-	mmc_send_if_cond(host, host->ocr_avail);
-
-	/* Order's important: probe SDIO, then SD, then MMC */
-	if (!mmc_attach_sdio(host))
-		return 0;
-	if (!mmc_attach_sd(host))
-		return 0;
+//	mmc_send_if_cond(host, host->ocr_avail);
+//
+//	/* Order's important: probe SDIO, then SD, then MMC */
+//	if (!mmc_attach_sdio(host))
+//		return 0;
+//	if (!mmc_attach_sd(host))
+//		return 0;
 	if (!mmc_attach_mmc(host))
 		return 0;
 
It just disable SDIO and SD code. It looks like using some SDIO 
or SD commands on mmc controller in qemu cause problems...

Any idea?

-- 
Pali Rohár
pali.rohar@gmail.com

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: mmc does not work in qemu n900
  2015-01-30 14:23     ` Pali Rohár
@ 2015-02-07 23:02       ` Pali Rohár
  2016-12-14 21:25       ` Pali Rohár
  1 sibling, 0 replies; 7+ messages in thread
From: Pali Rohár @ 2015-02-07 23:02 UTC (permalink / raw)
  To: Pavel Machek
  Cc: Aaro Koskinen, Chris Ball, Ulf Hansson, linux-mmc, linux-kernel,
	Ivaylo Dimitrov, Sebastian Reichel

[-- Attachment #1: Type: Text/Plain, Size: 2540 bytes --]

On Friday 30 January 2015 15:23:34 Pali Rohár wrote:
> On Tuesday 27 January 2015 10:17:39 Pali Rohár wrote:
> > On Tuesday 27 January 2015 00:21:04 Aaro Koskinen wrote:
> > > Hi,
> > > 
> > > On Mon, Jan 26, 2015 at 10:04:59PM +0100, Pali Rohár wrote:
> > > > problem? Why any of these two patches fix problem when
> > > > mmc is not detected by kernel in qemu (machine n900)?
> > > > Detection of mmc fails because function
> > > > mmc_send_op_cond() without one of above patches fails.
> > > 
> > > Has it ever worked? It could be just that QEMU's emulation
> > > is broken. Since the kernel works on actual HW, you
> > > probably should contact QEMU maintainers.
> > > 
> > > I don't see n900 in Debian's QEMU. There's n800 and n810
> > > but I couldn't boot any of my kernels with those...
> > > 
> > > A.
> > 
> > It worked with stock Nokia kernel (2.6.28).
> > 
> > N900 qemu support is not in upstream qemu project, but in
> > linaro qemu version. You can find it e.g. in ubuntu:
> > http://packages.ubuntu.com/source/precise-updates/qemu-linar
> > o
> 
> Here is another alternative patch which enable internal eMMC
> support in qemu n900:
> 
> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> index 9584bff..225df49 100644
> --- a/drivers/mmc/core/core.c
> +++ b/drivers/mmc/core/core.c
> @@ -2330,13 +2330,13 @@ static int mmc_rescan_try_freq(struct
> mmc_host *host, unsigned freq)
>  	sdio_reset(host);
>  	mmc_go_idle(host);
> 
> -	mmc_send_if_cond(host, host->ocr_avail);
> -
> -	/* Order's important: probe SDIO, then SD, then MMC */
> -	if (!mmc_attach_sdio(host))
> -		return 0;
> -	if (!mmc_attach_sd(host))
> -		return 0;
> +//	mmc_send_if_cond(host, host->ocr_avail);
> +//
> +//	/* Order's important: probe SDIO, then SD, then MMC */
> +//	if (!mmc_attach_sdio(host))
> +//		return 0;
> +//	if (!mmc_attach_sd(host))
> +//		return 0;
>  	if (!mmc_attach_mmc(host))
>  		return 0;
> 
> It just disable SDIO and SD code. It looks like using some
> SDIO or SD commands on mmc controller in qemu cause
> problems...
> 
> Any idea?

Pavel, see this email thread:
http://www.spinics.net/lists/linux-mmc/msg30424.html

You had problem with mounting mmc device as rootfs on (real) 
Nokia N900. Can you test one of those 3 patches which I sent to 
this email thread? If it change something for your kernel or 
userspace? I would like to know if I found another bug in qemu or 
same as you had...

-- 
Pali Rohár
pali.rohar@gmail.com

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: mmc does not work in qemu n900
  2015-01-26 21:04 mmc does not work in qemu n900 Pali Rohár
  2015-01-26 23:21 ` Aaro Koskinen
@ 2015-12-25 12:57 ` Pali Rohár
  1 sibling, 0 replies; 7+ messages in thread
From: Pali Rohár @ 2015-12-25 12:57 UTC (permalink / raw)
  To: Chris Ball
  Cc: Ulf Hansson, linux-mmc, linux-kernel, Pavel Machek,
	Ivaylo Dimitrov, Sebastian Reichel, Aaro Koskinen

[-- Attachment #1: Type: Text/Plain, Size: 1937 bytes --]

On Monday 26 January 2015 22:04:59 Pali Rohár wrote:
> Hello,
> 
> for unknown reason kernel in qemu n900 machine is not able to
> detect internal eMMC memory. External SD card is detected without
> problem.
> 
> If I apply this one-line patch eMMC in qemu start working:
> 
> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> index 9584bff..0d4461c 100644
> --- a/drivers/mmc/core/core.c
> +++ b/drivers/mmc/core/core.c
> @@ -2337,6 +2337,9 @@ static int mmc_rescan_try_freq(
>  		return 0;
>  	if (!mmc_attach_sd(host))
>  		return 0;
> +
> +	mmc_go_idle(host);
> +
>  	if (!mmc_attach_mmc(host))
>  		return 0;
> 
> I played with mmc and qemu n900 a bit and also this simple patch
> (without first) fix problem (that mmc is not detected by kernel):
> 
> diff --git a/drivers/mmc/core/mmc_ops.c
> b/drivers/mmc/core/mmc_ops.c
> index 3b044c5..0c93a2c 100644
> --- a/drivers/mmc/core/mmc_ops.c
> +++ b/drivers/mmc/core/mmc_ops.c
> @@ -157,6 +157,10 @@ int mmc_send_op_cond(
> 
>  	BUG_ON(!host);
> 
> +	/* reset mmc before calling op_cond */
> +	memset(&cmd, 0, sizeof(struct mmc_command));
> +	mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES);
> +
>  	cmd.opcode = MMC_SEND_OP_COND;
>  	cmd.arg = mmc_host_is_spi(host) ? 0 : ocr;
>  	cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R3 | MMC_CMD_BCR;
> 
> 
> I have no idea where is problem. I also do not understand mmc
> kernel code, but second patch I have on my HDD since 2.6.37.
> 
> Can somebody with knowledge of mmc subsystem look at this
> problem? Why any of these two patches fix problem when mmc is not
> detected by kernel in qemu (machine n900)? Detection of mmc fails
> because function mmc_send_op_cond() without one of above patches
> fails.

I will bring this tread to front again as mmc without one of provided 
patches does not work with 4.4-rc6 kernel in N900 qemu.

-- 
Pali Rohár
pali.rohar@gmail.com

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: mmc does not work in qemu n900
  2015-01-30 14:23     ` Pali Rohár
  2015-02-07 23:02       ` Pali Rohár
@ 2016-12-14 21:25       ` Pali Rohár
  1 sibling, 0 replies; 7+ messages in thread
From: Pali Rohár @ 2016-12-14 21:25 UTC (permalink / raw)
  To: Aaro Koskinen
  Cc: Chris Ball, Ulf Hansson, linux-mmc, linux-kernel, Pavel Machek,
	Ivaylo Dimitrov, Sebastian Reichel

[-- Attachment #1: Type: Text/Plain, Size: 2375 bytes --]

On Friday 30 January 2015 15:23:34 Pali Rohár wrote:
> On Tuesday 27 January 2015 10:17:39 Pali Rohár wrote:
> > On Tuesday 27 January 2015 00:21:04 Aaro Koskinen wrote:
> > > Hi,
> > > 
> > > On Mon, Jan 26, 2015 at 10:04:59PM +0100, Pali Rohár wrote:
> > > > problem? Why any of these two patches fix problem when mmc
> > > > is not detected by kernel in qemu (machine n900)?
> > > > Detection of mmc fails because function
> > > > mmc_send_op_cond() without one of above patches fails.
> > > 
> > > Has it ever worked? It could be just that QEMU's emulation
> > > is broken. Since the kernel works on actual HW, you
> > > probably should contact QEMU maintainers.
> > > 
> > > I don't see n900 in Debian's QEMU. There's n800 and n810 but
> > > I couldn't boot any of my kernels with those...
> > > 
> > > A.
> > 
> > It worked with stock Nokia kernel (2.6.28).
> > 
> > N900 qemu support is not in upstream qemu project, but in
> > linaro qemu version. You can find it e.g. in ubuntu:
> > http://packages.ubuntu.com/source/precise-updates/qemu-linaro
> 
> Here is another alternative patch which enable internal eMMC
> support in qemu n900:
> 
> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> index 9584bff..225df49 100644
> --- a/drivers/mmc/core/core.c
> +++ b/drivers/mmc/core/core.c
> @@ -2330,13 +2330,13 @@ static int mmc_rescan_try_freq(struct
> mmc_host *host, unsigned freq)
>  	sdio_reset(host);
>  	mmc_go_idle(host);
> 
> -	mmc_send_if_cond(host, host->ocr_avail);
> -
> -	/* Order's important: probe SDIO, then SD, then MMC */
> -	if (!mmc_attach_sdio(host))
> -		return 0;
> -	if (!mmc_attach_sd(host))
> -		return 0;
> +//	mmc_send_if_cond(host, host->ocr_avail);
> +//
> +//	/* Order's important: probe SDIO, then SD, then MMC */
> +//	if (!mmc_attach_sdio(host))
> +//		return 0;
> +//	if (!mmc_attach_sd(host))
> +//		return 0;
>  	if (!mmc_attach_mmc(host))
>  		return 0;
> 
> It just disable SDIO and SD code. It looks like using some SDIO
> or SD commands on mmc controller in qemu cause problems...
> 
> Any idea?

Now there are DT flags no-sdio and no-sd which skips mmc_attach_sdio() 
and mmc_attach_sd() calls. Same result as my commented code above...

I will send patch for Nokia N900 which will disable SDIO and SD.

-- 
Pali Rohár
pali.rohar@gmail.com

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

end of thread, other threads:[~2016-12-14 21:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-26 21:04 mmc does not work in qemu n900 Pali Rohár
2015-01-26 23:21 ` Aaro Koskinen
2015-01-27  9:17   ` Pali Rohár
2015-01-30 14:23     ` Pali Rohár
2015-02-07 23:02       ` Pali Rohár
2016-12-14 21:25       ` Pali Rohár
2015-12-25 12:57 ` Pali Rohár

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