All of lore.kernel.org
 help / color / mirror / Atom feed
* [PULL 0/1] SD/MMC patches for 2020-11-17
@ 2020-11-17 10:52 Philippe Mathieu-Daudé
  2020-11-17 10:52 ` [PULL 1/1] hw/sd: Fix 2 GiB card CSD register values Philippe Mathieu-Daudé
  2020-11-17 15:58 ` [PULL 0/1] SD/MMC patches for 2020-11-17 Peter Maydell
  0 siblings, 2 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-11-17 10:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: Philippe Mathieu-Daudé, qemu-block

The following changes since commit cb5ed407a1ddadf788fd373fed41c87c9e81e5b0:

  Merge remote-tracking branch 'remotes/huth-gitlab/tags/pull-request-2020-11-15' into staging (2020-11-16 17:00:36 +0000)

are available in the Git repository at:

  https://gitlab.com/philmd/qemu.git tags/sdmmc-20201117

for you to fetch changes up to 575094b786e999e5fbd04c0456f518a5ebefab5b:

  hw/sd: Fix 2 GiB card CSD register values (2020-11-17 11:45:13 +0100)

----------------------------------------------------------------
SD/MMC patches

- Correctly handle 2 GB SCSD Memory Cards (Bin Meng)

CI jobs result:
. https://cirrus-ci.com/build/4688743904837632
. https://gitlab.com/philmd/qemu/-/pipelines/216829732
. https://travis-ci.org/github/philmd/qemu/builds/744026099
----------------------------------------------------------------

Bin Meng (1):
  hw/sd: Fix 2 GiB card CSD register values

 hw/sd/sd.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

-- 
2.26.2



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

* [PULL 1/1] hw/sd: Fix 2 GiB card CSD register values
  2020-11-17 10:52 [PULL 0/1] SD/MMC patches for 2020-11-17 Philippe Mathieu-Daudé
@ 2020-11-17 10:52 ` Philippe Mathieu-Daudé
  2020-11-30 12:53   ` Bin Meng
  2020-11-17 15:58 ` [PULL 0/1] SD/MMC patches for 2020-11-17 Peter Maydell
  1 sibling, 1 reply; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-11-17 10:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: Niek Linnenbank, Bin Meng, Philippe Mathieu-Daudé, qemu-block

From: Bin Meng <bin.meng@windriver.com>

Per the SD spec, to indicate a 2 GiB card, BLOCK_LEN shall be 1024
bytes, hence the READ_BL_LEN field in the CSD register shall be 10
instead of 9.

This fixes the acceptance test error for the NetBSD 9.0 test of the
Orange Pi PC that has an expanded SD card image of 2 GiB size.

Fixes: 6d2d4069c47e ("hw/sd: Correct the maximum size of a Standard Capacity SD Memory Card")
Reported-by: Niek Linnenbank <nieklinnenbank@gmail.com>
Signed-off-by: Bin Meng <bin.meng@windriver.com>
Tested-by: Niek Linnenbank <nieklinnenbank@gmail.com>
Message-Id: <20201025152357.11865-1-bmeng.cn@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/sd/sd.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 30913826145..1842c037978 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -389,10 +389,17 @@ static const uint8_t sd_csd_rw_mask[16] = {
 
 static void sd_set_csd(SDState *sd, uint64_t size)
 {
-    uint32_t csize = (size >> (CMULT_SHIFT + HWBLOCK_SHIFT)) - 1;
+    int hwblock_shift = HWBLOCK_SHIFT;
+    uint32_t csize;
     uint32_t sectsize = (1 << (SECTOR_SHIFT + 1)) - 1;
     uint32_t wpsize = (1 << (WPGROUP_SHIFT + 1)) - 1;
 
+    /* To indicate 2 GiB card, BLOCK_LEN shall be 1024 bytes */
+    if (size == SDSC_MAX_CAPACITY) {
+        hwblock_shift += 1;
+    }
+    csize = (size >> (CMULT_SHIFT + hwblock_shift)) - 1;
+
     if (size <= SDSC_MAX_CAPACITY) { /* Standard Capacity SD */
         sd->csd[0] = 0x00;	/* CSD structure */
         sd->csd[1] = 0x26;	/* Data read access-time-1 */
@@ -400,7 +407,7 @@ static void sd_set_csd(SDState *sd, uint64_t size)
         sd->csd[3] = 0x32;      /* Max. data transfer rate: 25 MHz */
         sd->csd[4] = 0x5f;	/* Card Command Classes */
         sd->csd[5] = 0x50 |	/* Max. read data block length */
-            HWBLOCK_SHIFT;
+            hwblock_shift;
         sd->csd[6] = 0xe0 |	/* Partial block for read allowed */
             ((csize >> 10) & 0x03);
         sd->csd[7] = 0x00 |	/* Device size */
@@ -414,9 +421,9 @@ static void sd_set_csd(SDState *sd, uint64_t size)
         sd->csd[11] = 0x00 |	/* Write protect group size */
             ((sectsize << 7) & 0x80) | wpsize;
         sd->csd[12] = 0x90 |	/* Write speed factor */
-            (HWBLOCK_SHIFT >> 2);
+            (hwblock_shift >> 2);
         sd->csd[13] = 0x20 |	/* Max. write data block length */
-            ((HWBLOCK_SHIFT << 6) & 0xc0);
+            ((hwblock_shift << 6) & 0xc0);
         sd->csd[14] = 0x00;	/* File format group */
     } else {			/* SDHC */
         size /= 512 * KiB;
-- 
2.26.2



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

* Re: [PULL 0/1] SD/MMC patches for 2020-11-17
  2020-11-17 10:52 [PULL 0/1] SD/MMC patches for 2020-11-17 Philippe Mathieu-Daudé
  2020-11-17 10:52 ` [PULL 1/1] hw/sd: Fix 2 GiB card CSD register values Philippe Mathieu-Daudé
@ 2020-11-17 15:58 ` Peter Maydell
  1 sibling, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2020-11-17 15:58 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: QEMU Developers, Qemu-block

On Tue, 17 Nov 2020 at 10:54, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> The following changes since commit cb5ed407a1ddadf788fd373fed41c87c9e81e5b0:
>
>   Merge remote-tracking branch 'remotes/huth-gitlab/tags/pull-request-2020-11-15' into staging (2020-11-16 17:00:36 +0000)
>
> are available in the Git repository at:
>
>   https://gitlab.com/philmd/qemu.git tags/sdmmc-20201117
>
> for you to fetch changes up to 575094b786e999e5fbd04c0456f518a5ebefab5b:
>
>   hw/sd: Fix 2 GiB card CSD register values (2020-11-17 11:45:13 +0100)
>
> ----------------------------------------------------------------
> SD/MMC patches
>
> - Correctly handle 2 GB SCSD Memory Cards (Bin Meng)
>
> CI jobs result:
> . https://cirrus-ci.com/build/4688743904837632
> . https://gitlab.com/philmd/qemu/-/pipelines/216829732
> . https://travis-ci.org/github/philmd/qemu/builds/744026099


Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/5.2
for any user-visible changes.

-- PMM


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

* Re: [PULL 1/1] hw/sd: Fix 2 GiB card CSD register values
  2020-11-17 10:52 ` [PULL 1/1] hw/sd: Fix 2 GiB card CSD register values Philippe Mathieu-Daudé
@ 2020-11-30 12:53   ` Bin Meng
  2020-11-30 12:54     ` Peter Maydell
  0 siblings, 1 reply; 6+ messages in thread
From: Bin Meng @ 2020-11-30 12:53 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, Peter Maydell
  Cc: Niek Linnenbank, Bin Meng, qemu-devel@nongnu.org Developers, Qemu-block

+Peter,

On Tue, Nov 17, 2020 at 6:52 PM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> From: Bin Meng <bin.meng@windriver.com>
>
> Per the SD spec, to indicate a 2 GiB card, BLOCK_LEN shall be 1024
> bytes, hence the READ_BL_LEN field in the CSD register shall be 10
> instead of 9.
>
> This fixes the acceptance test error for the NetBSD 9.0 test of the
> Orange Pi PC that has an expanded SD card image of 2 GiB size.
>
> Fixes: 6d2d4069c47e ("hw/sd: Correct the maximum size of a Standard Capacity SD Memory Card")
> Reported-by: Niek Linnenbank <nieklinnenbank@gmail.com>
> Signed-off-by: Bin Meng <bin.meng@windriver.com>
> Tested-by: Niek Linnenbank <nieklinnenbank@gmail.com>
> Message-Id: <20201025152357.11865-1-bmeng.cn@gmail.com>
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  hw/sd/sd.c | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
>

Any chance to get this patch applied to 5.2 since it's a bug fix?

Regards,
Bin


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

* Re: [PULL 1/1] hw/sd: Fix 2 GiB card CSD register values
  2020-11-30 12:53   ` Bin Meng
@ 2020-11-30 12:54     ` Peter Maydell
  2020-11-30 12:59       ` Bin Meng
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Maydell @ 2020-11-30 12:54 UTC (permalink / raw)
  To: Bin Meng
  Cc: Niek Linnenbank, Bin Meng, Philippe Mathieu-Daudé,
	Qemu-block, qemu-devel@nongnu.org Developers

On Mon, 30 Nov 2020 at 12:53, Bin Meng <bmeng.cn@gmail.com> wrote:
>
> +Peter,
>
> On Tue, Nov 17, 2020 at 6:52 PM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> >
> > From: Bin Meng <bin.meng@windriver.com>
> >
> > Per the SD spec, to indicate a 2 GiB card, BLOCK_LEN shall be 1024
> > bytes, hence the READ_BL_LEN field in the CSD register shall be 10
> > instead of 9.
> >
> > This fixes the acceptance test error for the NetBSD 9.0 test of the
> > Orange Pi PC that has an expanded SD card image of 2 GiB size.
> >
> > Fixes: 6d2d4069c47e ("hw/sd: Correct the maximum size of a Standard Capacity SD Memory Card")
> > Reported-by: Niek Linnenbank <nieklinnenbank@gmail.com>
> > Signed-off-by: Bin Meng <bin.meng@windriver.com>
> > Tested-by: Niek Linnenbank <nieklinnenbank@gmail.com>
> > Message-Id: <20201025152357.11865-1-bmeng.cn@gmail.com>
> > Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> > ---
> >  hw/sd/sd.c | 15 +++++++++++----
> >  1 file changed, 11 insertions(+), 4 deletions(-)
> >
>
> Any chance to get this patch applied to 5.2 since it's a bug fix?

It's already in -- commit 575094b786e999e5fbd0.

thanks
-- PMM


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

* Re: [PULL 1/1] hw/sd: Fix 2 GiB card CSD register values
  2020-11-30 12:54     ` Peter Maydell
@ 2020-11-30 12:59       ` Bin Meng
  0 siblings, 0 replies; 6+ messages in thread
From: Bin Meng @ 2020-11-30 12:59 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Niek Linnenbank, Bin Meng, Philippe Mathieu-Daudé,
	Qemu-block, qemu-devel@nongnu.org Developers

On Mon, Nov 30, 2020 at 8:55 PM Peter Maydell <peter.maydell@linaro.org> wrote:
>
> On Mon, 30 Nov 2020 at 12:53, Bin Meng <bmeng.cn@gmail.com> wrote:
> >
> > +Peter,
> >
> > On Tue, Nov 17, 2020 at 6:52 PM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> > >
> > > From: Bin Meng <bin.meng@windriver.com>
> > >
> > > Per the SD spec, to indicate a 2 GiB card, BLOCK_LEN shall be 1024
> > > bytes, hence the READ_BL_LEN field in the CSD register shall be 10
> > > instead of 9.
> > >
> > > This fixes the acceptance test error for the NetBSD 9.0 test of the
> > > Orange Pi PC that has an expanded SD card image of 2 GiB size.
> > >
> > > Fixes: 6d2d4069c47e ("hw/sd: Correct the maximum size of a Standard Capacity SD Memory Card")
> > > Reported-by: Niek Linnenbank <nieklinnenbank@gmail.com>
> > > Signed-off-by: Bin Meng <bin.meng@windriver.com>
> > > Tested-by: Niek Linnenbank <nieklinnenbank@gmail.com>
> > > Message-Id: <20201025152357.11865-1-bmeng.cn@gmail.com>
> > > Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> > > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> > > ---
> > >  hw/sd/sd.c | 15 +++++++++++----
> > >  1 file changed, 11 insertions(+), 4 deletions(-)
> > >
> >
> > Any chance to get this patch applied to 5.2 since it's a bug fix?
>
> It's already in -- commit 575094b786e999e5fbd0.

Oops, did a wrong rebase in my local tree :(

Glad it's already in. Sorry Peter!

Regards,
Bin


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

end of thread, other threads:[~2020-11-30 13:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-17 10:52 [PULL 0/1] SD/MMC patches for 2020-11-17 Philippe Mathieu-Daudé
2020-11-17 10:52 ` [PULL 1/1] hw/sd: Fix 2 GiB card CSD register values Philippe Mathieu-Daudé
2020-11-30 12:53   ` Bin Meng
2020-11-30 12:54     ` Peter Maydell
2020-11-30 12:59       ` Bin Meng
2020-11-17 15:58 ` [PULL 0/1] SD/MMC patches for 2020-11-17 Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.