Re: Size of SD devices supported?

2009-01-08 Thread Jonathan Gray
On Thu, Jan 08, 2009 at 10:58:52AM +1100, Jonathan Gray wrote:
 On Wed, Jan 07, 2009 at 02:49:50PM -0500, STeve Andre' wrote:
 My new Thinkpad W500 has a SD slot, and stuffing a 1G card in
  works just fine.
  
 I borrowed a 16G SD card, and that gives a can't enable card
  error.
  
 I just found specs for the SD card, and wonder if the current
  code works with cards beyond 4G?  Or, do I have a defective 16G
  card? (I currently have no way to test that).  I haven't seen much
  in the way of discussion about this.
 
 This diff should let you use SDHC cards (most cards = 4GB).
 Let me know how it goes.

Last one didn't have the change needed for block writes, try this:

Index: sdmmc.c
===
RCS file: /cvs/src/sys/dev/sdmmc/sdmmc.c,v
retrieving revision 1.16
diff -u -p -r1.16 sdmmc.c
--- sdmmc.c 2 Dec 2008 23:49:54 -   1.16
+++ sdmmc.c 8 Jan 2009 12:05:53 -
@@ -569,6 +569,32 @@ sdmmc_go_idle_state(struct sdmmc_softc *
 }
 
 /*
+ * Send the SEND_IF_COND command, to check operating condition
+ */
+int
+sdmmc_send_if_cond(struct sdmmc_softc *sc, uint32_t card_ocr)
+{
+   struct sdmmc_command cmd;
+   uint8_t pat = 0x23;
+   uint8_t res;
+
+   bzero(cmd, sizeof cmd);
+
+   cmd.c_opcode = SD_SEND_IF_COND;
+   cmd.c_arg = ((card_ocr  SD_OCR_VOL_MASK) != 0)  8 | pat;
+   cmd.c_flags = SCF_CMD_BCR | SCF_RSP_R7;
+
+   if (sdmmc_mmc_command(sc, cmd) != 0)
+   return 1;
+
+   res = cmd.c_resp[0];
+   if (res != pat)
+   return 1;
+   else
+   return 0;
+}
+
+/*
  * Retrieve (SD) or set (MMC) the relative card address (RCA).
  */
 int
Index: sdmmc_mem.c
===
RCS file: /cvs/src/sys/dev/sdmmc/sdmmc_mem.c,v
retrieving revision 1.9
diff -u -p -r1.9 sdmmc_mem.c
--- sdmmc_mem.c 2 Dec 2008 23:49:54 -   1.9
+++ sdmmc_mem.c 8 Jan 2009 12:05:53 -
@@ -93,6 +93,9 @@ sdmmc_mem_enable(struct sdmmc_softc *sc)
/* Tell the card(s) to enter the idle state (again). */
sdmmc_go_idle_state(sc);
 
+   if (sdmmc_send_if_cond(sc, card_ocr) == 0)
+   host_ocr |= SD_OCR_SDHC_CAP;
+
/* Send the new OCR value until all cards are ready. */
if (sdmmc_mem_send_op_cond(sc, host_ocr, NULL) != 0) {
DPRINTF((%s: can't send memory OCR\n, SDMMCDEVNAME(sc)));
@@ -224,14 +227,23 @@ sdmmc_decode_csd(struct sdmmc_softc *sc,
 * specification version 1.0 - 1.10. (SanDisk, 3.5.3)
 */
csd-csdver = SD_CSD_CSDVER(resp);
-   if (csd-csdver != SD_CSD_CSDVER_1_0) {
+   switch (csd-csdver) {
+   case SD_CSD_CSDVER_2_0:
+   sc-sc_flags |= SMF_SDHC;
+   csd-capacity = SD_CSD_V2_CAPACITY(resp);
+   csd-read_bl_len = SD_CSD_V2_BL_LEN;
+   break;
+   case SD_CSD_CSDVER_1_0:
+   csd-capacity = SD_CSD_CAPACITY(resp);
+   csd-read_bl_len = SD_CSD_READ_BL_LEN(resp);
+   break;
+   default:
printf(%s: unknown SD CSD structure version 0x%x\n,
SDMMCDEVNAME(sc), csd-csdver);
return 1;
+   break;
}
 
-   csd-capacity = SD_CSD_CAPACITY(resp);
-   csd-read_bl_len = SD_CSD_READ_BL_LEN(resp);
} else {
csd-csdver = MMC_CSD_CSDVER(resp);
if (csd-csdver != MMC_CSD_CSDVER_1_0 
@@ -403,7 +415,10 @@ sdmmc_mem_read_block(struct sdmmc_functi
cmd.c_blklen = sf-csd.sector_size;
cmd.c_opcode = (datalen / cmd.c_blklen)  1 ?
MMC_READ_BLOCK_MULTIPLE : MMC_READ_BLOCK_SINGLE;
-   cmd.c_arg = blkno  9;
+   if (sc-sc_flags  SMF_SDHC)
+   cmd.c_arg = blkno;
+   else
+   cmd.c_arg = blkno  9;
cmd.c_flags = SCF_CMD_ADTC | SCF_CMD_READ | SCF_RSP_R1;
 
error = sdmmc_mmc_command(sc, cmd);
@@ -458,7 +473,10 @@ sdmmc_mem_write_block(struct sdmmc_funct
cmd.c_blklen = sf-csd.sector_size;
cmd.c_opcode = (datalen / cmd.c_blklen)  1 ?
MMC_WRITE_BLOCK_MULTIPLE : MMC_WRITE_BLOCK_SINGLE;
-   cmd.c_arg = blkno  9;
+   if (sc-sc_flags  SMF_SDHC)
+   cmd.c_arg = blkno;
+   else
+   cmd.c_arg = blkno  9;
cmd.c_flags = SCF_CMD_ADTC | SCF_RSP_R1;
 
error = sdmmc_mmc_command(sc, cmd);
Index: sdmmcreg.h
===
RCS file: /cvs/src/sys/dev/sdmmc/sdmmcreg.h,v
retrieving revision 1.3
diff -u -p -r1.3 sdmmcreg.h
--- sdmmcreg.h  18 Mar 2007 22:21:21 -  1.3
+++ sdmmcreg.h  8 Jan 2009 12:05:54 -
@@ -38,6 +38,7 @@
 
 /* SD commands */  /* response type */
 

Re: Size of SD devices supported?

2009-01-08 Thread Dan Colish
On Thu, Jan 8, 2009 at 7:10 AM, Jonathan Gray j...@goblin.cx wrote:

 On Thu, Jan 08, 2009 at 10:58:52AM +1100, Jonathan Gray wrote:
  On Wed, Jan 07, 2009 at 02:49:50PM -0500, STeve Andre' wrote:
  My new Thinkpad W500 has a SD slot, and stuffing a 1G card in
   works just fine.
  
  I borrowed a 16G SD card, and that gives a can't enable card
   error.
  
  I just found specs for the SD card, and wonder if the current
   code works with cards beyond 4G?  Or, do I have a defective 16G
   card? (I currently have no way to test that).  I haven't seen much
   in the way of discussion about this.
 
  This diff should let you use SDHC cards (most cards = 4GB).
  Let me know how it goes.

 Last one didn't have the change needed for block writes, try this:

 Index: sdmmc.c
 ===
 RCS file: /cvs/src/sys/dev/sdmmc/sdmmc.c,v
 retrieving revision 1.16
 diff -u -p -r1.16 sdmmc.c
 --- sdmmc.c 2 Dec 2008 23:49:54 -   1.16
 +++ sdmmc.c 8 Jan 2009 12:05:53 -
 @@ -569,6 +569,32 @@ sdmmc_go_idle_state(struct sdmmc_softc *
  }

  /*
 + * Send the SEND_IF_COND command, to check operating condition
 + */
 +int
 +sdmmc_send_if_cond(struct sdmmc_softc *sc, uint32_t card_ocr)
 +{
 +   struct sdmmc_command cmd;
 +   uint8_t pat = 0x23;
 +   uint8_t res;
 +
 +   bzero(cmd, sizeof cmd);
 +
 +   cmd.c_opcode = SD_SEND_IF_COND;
 +   cmd.c_arg = ((card_ocr  SD_OCR_VOL_MASK) != 0)  8 | pat;
 +   cmd.c_flags = SCF_CMD_BCR | SCF_RSP_R7;
 +
 +   if (sdmmc_mmc_command(sc, cmd) != 0)
 +   return 1;
 +
 +   res = cmd.c_resp[0];
 +   if (res != pat)
 +   return 1;
 +   else
 +   return 0;
 +}
 +
 +/*
  * Retrieve (SD) or set (MMC) the relative card address (RCA).
  */
  int
 Index: sdmmc_mem.c
 ===
 RCS file: /cvs/src/sys/dev/sdmmc/sdmmc_mem.c,v
 retrieving revision 1.9
 diff -u -p -r1.9 sdmmc_mem.c
 --- sdmmc_mem.c 2 Dec 2008 23:49:54 -   1.9
 +++ sdmmc_mem.c 8 Jan 2009 12:05:53 -
 @@ -93,6 +93,9 @@ sdmmc_mem_enable(struct sdmmc_softc *sc)
/* Tell the card(s) to enter the idle state (again). */
sdmmc_go_idle_state(sc);

 +   if (sdmmc_send_if_cond(sc, card_ocr) == 0)
 +   host_ocr |= SD_OCR_SDHC_CAP;
 +
/* Send the new OCR value until all cards are ready. */
if (sdmmc_mem_send_op_cond(sc, host_ocr, NULL) != 0) {
DPRINTF((%s: can't send memory OCR\n, SDMMCDEVNAME(sc)));
 @@ -224,14 +227,23 @@ sdmmc_decode_csd(struct sdmmc_softc *sc,
 * specification version 1.0 - 1.10. (SanDisk, 3.5.3)
 */
csd-csdver = SD_CSD_CSDVER(resp);
 -   if (csd-csdver != SD_CSD_CSDVER_1_0) {
 +   switch (csd-csdver) {
 +   case SD_CSD_CSDVER_2_0:
 +   sc-sc_flags |= SMF_SDHC;
 +   csd-capacity = SD_CSD_V2_CAPACITY(resp);
 +   csd-read_bl_len = SD_CSD_V2_BL_LEN;
 +   break;
 +   case SD_CSD_CSDVER_1_0:
 +   csd-capacity = SD_CSD_CAPACITY(resp);
 +   csd-read_bl_len = SD_CSD_READ_BL_LEN(resp);
 +   break;
 +   default:
printf(%s: unknown SD CSD structure version
 0x%x\n,
SDMMCDEVNAME(sc), csd-csdver);
return 1;
 +   break;
}

 -   csd-capacity = SD_CSD_CAPACITY(resp);
 -   csd-read_bl_len = SD_CSD_READ_BL_LEN(resp);
} else {
csd-csdver = MMC_CSD_CSDVER(resp);
if (csd-csdver != MMC_CSD_CSDVER_1_0 
 @@ -403,7 +415,10 @@ sdmmc_mem_read_block(struct sdmmc_functi
cmd.c_blklen = sf-csd.sector_size;
cmd.c_opcode = (datalen / cmd.c_blklen)  1 ?
MMC_READ_BLOCK_MULTIPLE : MMC_READ_BLOCK_SINGLE;
 -   cmd.c_arg = blkno  9;
 +   if (sc-sc_flags  SMF_SDHC)
 +   cmd.c_arg = blkno;
 +   else
 +   cmd.c_arg = blkno  9;
cmd.c_flags = SCF_CMD_ADTC | SCF_CMD_READ | SCF_RSP_R1;

error = sdmmc_mmc_command(sc, cmd);
 @@ -458,7 +473,10 @@ sdmmc_mem_write_block(struct sdmmc_funct
 cmd.c_blklen = sf-csd.sector_size;
cmd.c_opcode = (datalen / cmd.c_blklen)  1 ?
 MMC_WRITE_BLOCK_MULTIPLE : MMC_WRITE_BLOCK_SINGLE;
 -   cmd.c_arg = blkno  9;
 +   if (sc-sc_flags  SMF_SDHC)
 +   cmd.c_arg = blkno;
 +   else
 +   cmd.c_arg = blkno  9;
 cmd.c_flags = SCF_CMD_ADTC | SCF_RSP_R1;

error = sdmmc_mmc_command(sc, cmd);
 Index: sdmmcreg.h
 ===
 RCS file: /cvs/src/sys/dev/sdmmc/sdmmcreg.h,v
 retrieving revision 1.3
 diff -u -p -r1.3 sdmmcreg.h
 --- sdmmcreg.h  18 

Re: Size of SD devices supported?

2009-01-08 Thread Jonathan Gray
On Thu, Jan 08, 2009 at 09:32:47AM -0500, Dan Colish wrote:
 
 The latest patch works great for me. I was not able to write disklabels with
 the prior patch, probably due to the block write code missing. As soon as I
 get the card up, I'll post some i/o benchmarks.

Well it's an SD card, don't expect miracles.

Here is a bonus revised revised patch that lets you use SD cards
after SDHC cards by storing the flag state in a better card specific
state structure.

I'd appreciate it if people testing this stuff could test on
a range of SDHC and normal cards and tell me what size cards/
which controllers they are testing against.

Thanks

Index: sdmmc.c
===
RCS file: /cvs/src/sys/dev/sdmmc/sdmmc.c,v
retrieving revision 1.16
diff -u -p -r1.16 sdmmc.c
--- sdmmc.c 2 Dec 2008 23:49:54 -   1.16
+++ sdmmc.c 8 Jan 2009 12:49:43 -
@@ -569,6 +569,32 @@ sdmmc_go_idle_state(struct sdmmc_softc *
 }
 
 /*
+ * Send the SEND_IF_COND command, to check operating condition
+ */
+int
+sdmmc_send_if_cond(struct sdmmc_softc *sc, uint32_t card_ocr)
+{
+   struct sdmmc_command cmd;
+   uint8_t pat = 0x23;
+   uint8_t res;
+
+   bzero(cmd, sizeof cmd);
+
+   cmd.c_opcode = SD_SEND_IF_COND;
+   cmd.c_arg = ((card_ocr  SD_OCR_VOL_MASK) != 0)  8 | pat;
+   cmd.c_flags = SCF_CMD_BCR | SCF_RSP_R7;
+
+   if (sdmmc_mmc_command(sc, cmd) != 0)
+   return 1;
+
+   res = cmd.c_resp[0];
+   if (res != pat)
+   return 1;
+   else
+   return 0;
+}
+
+/*
  * Retrieve (SD) or set (MMC) the relative card address (RCA).
  */
 int
Index: sdmmc_mem.c
===
RCS file: /cvs/src/sys/dev/sdmmc/sdmmc_mem.c,v
retrieving revision 1.9
diff -u -p -r1.9 sdmmc_mem.c
--- sdmmc_mem.c 2 Dec 2008 23:49:54 -   1.9
+++ sdmmc_mem.c 8 Jan 2009 12:49:43 -
@@ -93,6 +93,9 @@ sdmmc_mem_enable(struct sdmmc_softc *sc)
/* Tell the card(s) to enter the idle state (again). */
sdmmc_go_idle_state(sc);
 
+   if (sdmmc_send_if_cond(sc, card_ocr) == 0)
+   host_ocr |= SD_OCR_SDHC_CAP;
+
/* Send the new OCR value until all cards are ready. */
if (sdmmc_mem_send_op_cond(sc, host_ocr, NULL) != 0) {
DPRINTF((%s: can't send memory OCR\n, SDMMCDEVNAME(sc)));
@@ -224,14 +227,23 @@ sdmmc_decode_csd(struct sdmmc_softc *sc,
 * specification version 1.0 - 1.10. (SanDisk, 3.5.3)
 */
csd-csdver = SD_CSD_CSDVER(resp);
-   if (csd-csdver != SD_CSD_CSDVER_1_0) {
+   switch (csd-csdver) {
+   case SD_CSD_CSDVER_2_0:
+   sf-flags |= SFF_SDHC;
+   csd-capacity = SD_CSD_V2_CAPACITY(resp);
+   csd-read_bl_len = SD_CSD_V2_BL_LEN;
+   break;
+   case SD_CSD_CSDVER_1_0:
+   csd-capacity = SD_CSD_CAPACITY(resp);
+   csd-read_bl_len = SD_CSD_READ_BL_LEN(resp);
+   break;
+   default:
printf(%s: unknown SD CSD structure version 0x%x\n,
SDMMCDEVNAME(sc), csd-csdver);
return 1;
+   break;
}
 
-   csd-capacity = SD_CSD_CAPACITY(resp);
-   csd-read_bl_len = SD_CSD_READ_BL_LEN(resp);
} else {
csd-csdver = MMC_CSD_CSDVER(resp);
if (csd-csdver != MMC_CSD_CSDVER_1_0 
@@ -403,7 +415,10 @@ sdmmc_mem_read_block(struct sdmmc_functi
cmd.c_blklen = sf-csd.sector_size;
cmd.c_opcode = (datalen / cmd.c_blklen)  1 ?
MMC_READ_BLOCK_MULTIPLE : MMC_READ_BLOCK_SINGLE;
-   cmd.c_arg = blkno  9;
+   if (sf-flags  SFF_SDHC)
+   cmd.c_arg = blkno;
+   else
+   cmd.c_arg = blkno  9;
cmd.c_flags = SCF_CMD_ADTC | SCF_CMD_READ | SCF_RSP_R1;
 
error = sdmmc_mmc_command(sc, cmd);
@@ -458,7 +473,10 @@ sdmmc_mem_write_block(struct sdmmc_funct
cmd.c_blklen = sf-csd.sector_size;
cmd.c_opcode = (datalen / cmd.c_blklen)  1 ?
MMC_WRITE_BLOCK_MULTIPLE : MMC_WRITE_BLOCK_SINGLE;
-   cmd.c_arg = blkno  9;
+   if (sf-flags  SFF_SDHC)
+   cmd.c_arg = blkno;
+   else
+   cmd.c_arg = blkno  9;
cmd.c_flags = SCF_CMD_ADTC | SCF_RSP_R1;
 
error = sdmmc_mmc_command(sc, cmd);
Index: sdmmcreg.h
===
RCS file: /cvs/src/sys/dev/sdmmc/sdmmcreg.h,v
retrieving revision 1.3
diff -u -p -r1.3 sdmmcreg.h
--- sdmmcreg.h  18 Mar 2007 22:21:21 -  1.3
+++ sdmmcreg.h  8 Jan 2009 12:49:44 -
@@ -38,6 +38,7 @@
 
 /* SD commands */  /* response type */
 #define SD_SEND_RELATIVE_ADDR  3   /* R6 */

Re: Size of SD devices supported?

2009-01-08 Thread Dan Colish
On Thu, Jan 8, 2009 at 9:51 AM, Jonathan Gray j...@goblin.cx wrote:

 On Thu, Jan 08, 2009 at 09:32:47AM -0500, Dan Colish wrote:
 
  The latest patch works great for me. I was not able to write disklabels
 with
  the prior patch, probably due to the block write code missing. As soon as
 I
  get the card up, I'll post some i/o benchmarks.

 Well it's an SD card, don't expect miracles.

 Here is a bonus revised revised patch that lets you use SD cards
 after SDHC cards by storing the flag state in a better card specific
 state structure.

 I'd appreciate it if people testing this stuff could test on
 a range of SDHC and normal cards and tell me what size cards/
 which controllers they are testing against.

 Thanks

 Index: sdmmc.c
 ===
 RCS file: /cvs/src/sys/dev/sdmmc/sdmmc.c,v
 retrieving revision 1.16
 diff -u -p -r1.16 sdmmc.c
 --- sdmmc.c 2 Dec 2008 23:49:54 -   1.16
 +++ sdmmc.c 8 Jan 2009 12:49:43 -
 @@ -569,6 +569,32 @@ sdmmc_go_idle_state(struct sdmmc_softc *
  }

  /*
 + * Send the SEND_IF_COND command, to check operating condition
 + */
 +int
 +sdmmc_send_if_cond(struct sdmmc_softc *sc, uint32_t card_ocr)
 +{
 +   struct sdmmc_command cmd;
 +   uint8_t pat = 0x23;
 +   uint8_t res;
 +
 +   bzero(cmd, sizeof cmd);
 +
 +   cmd.c_opcode = SD_SEND_IF_COND;
 +   cmd.c_arg = ((card_ocr  SD_OCR_VOL_MASK) != 0)  8 | pat;
 +   cmd.c_flags = SCF_CMD_BCR | SCF_RSP_R7;
 +
 +   if (sdmmc_mmc_command(sc, cmd) != 0)
 +   return 1;
 +
 +   res = cmd.c_resp[0];
 +   if (res != pat)
 +   return 1;
 +   else
 +   return 0;
 +}
 +
 +/*
  * Retrieve (SD) or set (MMC) the relative card address (RCA).
  */
  int
 Index: sdmmc_mem.c
 ===
 RCS file: /cvs/src/sys/dev/sdmmc/sdmmc_mem.c,v
 retrieving revision 1.9
 diff -u -p -r1.9 sdmmc_mem.c
 --- sdmmc_mem.c 2 Dec 2008 23:49:54 -   1.9
 +++ sdmmc_mem.c 8 Jan 2009 12:49:43 -
 @@ -93,6 +93,9 @@ sdmmc_mem_enable(struct sdmmc_softc *sc)
/* Tell the card(s) to enter the idle state (again). */
sdmmc_go_idle_state(sc);

 +   if (sdmmc_send_if_cond(sc, card_ocr) == 0)
 +   host_ocr |= SD_OCR_SDHC_CAP;
 +
/* Send the new OCR value until all cards are ready. */
if (sdmmc_mem_send_op_cond(sc, host_ocr, NULL) != 0) {
DPRINTF((%s: can't send memory OCR\n, SDMMCDEVNAME(sc)));
 @@ -224,14 +227,23 @@ sdmmc_decode_csd(struct sdmmc_softc *sc,
 * specification version 1.0 - 1.10. (SanDisk, 3.5.3)
 */
csd-csdver = SD_CSD_CSDVER(resp);
 -   if (csd-csdver != SD_CSD_CSDVER_1_0) {
 +   switch (csd-csdver) {
 +   case SD_CSD_CSDVER_2_0:
 +   sf-flags |= SFF_SDHC;
 +   csd-capacity = SD_CSD_V2_CAPACITY(resp);
 +   csd-read_bl_len = SD_CSD_V2_BL_LEN;
 +   break;
 +   case SD_CSD_CSDVER_1_0:
 +   csd-capacity = SD_CSD_CAPACITY(resp);
 +   csd-read_bl_len = SD_CSD_READ_BL_LEN(resp);
 +   break;
 +   default:
printf(%s: unknown SD CSD structure version
 0x%x\n,
SDMMCDEVNAME(sc), csd-csdver);
return 1;
 +   break;
}

 -   csd-capacity = SD_CSD_CAPACITY(resp);
 -   csd-read_bl_len = SD_CSD_READ_BL_LEN(resp);
} else {
csd-csdver = MMC_CSD_CSDVER(resp);
if (csd-csdver != MMC_CSD_CSDVER_1_0 
 @@ -403,7 +415,10 @@ sdmmc_mem_read_block(struct sdmmc_functi
cmd.c_blklen = sf-csd.sector_size;
cmd.c_opcode = (datalen / cmd.c_blklen)  1 ?
MMC_READ_BLOCK_MULTIPLE : MMC_READ_BLOCK_SINGLE;
 -   cmd.c_arg = blkno  9;
 +   if (sf-flags  SFF_SDHC)
 +   cmd.c_arg = blkno;
 +   else
 +   cmd.c_arg = blkno  9;
cmd.c_flags = SCF_CMD_ADTC | SCF_CMD_READ | SCF_RSP_R1;

error = sdmmc_mmc_command(sc, cmd);
 @@ -458,7 +473,10 @@ sdmmc_mem_write_block(struct sdmmc_funct
cmd.c_blklen = sf-csd.sector_size;
cmd.c_opcode = (datalen / cmd.c_blklen)  1 ?
MMC_WRITE_BLOCK_MULTIPLE : MMC_WRITE_BLOCK_SINGLE;
 -   cmd.c_arg = blkno  9;
 +   if (sf-flags  SFF_SDHC)
 +   cmd.c_arg = blkno;
 +   else
 +   cmd.c_arg = blkno  9;
cmd.c_flags = SCF_CMD_ADTC | SCF_RSP_R1;

error = sdmmc_mmc_command(sc, cmd);
 Index: sdmmcreg.h
 ===
 RCS file: /cvs/src/sys/dev/sdmmc/sdmmcreg.h,v
 retrieving revision 1.3
 diff -u -p -r1.3 sdmmcreg.h
 --- sdmmcreg.h  18 Mar 2007 22:21:21 -  1.3
 +++ sdmmcreg.h  8 Jan 2009 

Re: Size of SD devices supported?

2009-01-08 Thread Dan Colish
I've worked out my mount issues and I was able to run a bonnie++ test on the
card:

littleguy ~$ bonnie++ -d /opt/ -s 100 -r 10 -f -n
0
Writing intelligently...done
Rewriting...done
Reading intelligently...done
start 'em...done...done...done...
Version  1.03   --Sequential Output-- --Sequential Input-
--Random-
-Per Chr- --Block-- -Rewrite- -Per Chr- --Block--
--Seeks--
MachineSize K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP  /sec
%CP
littleguy  100M2144   1  1746   18950   1
170.5   0


Looks like its writing at 2Mb/sec and reading at almost 9mb/sec. The test
size was 100Mb

--dan



Size of SD devices supported?

2009-01-07 Thread STeve Andre'
   My new Thinkpad W500 has a SD slot, and stuffing a 1G card in
works just fine.

   I borrowed a 16G SD card, and that gives a can't enable card
error.

   I just found specs for the SD card, and wonder if the current
code works with cards beyond 4G?  Or, do I have a defective 16G
card? (I currently have no way to test that).  I haven't seen much
in the way of discussion about this.

Thanks, STeve Andre'

(dmesg with  the 1G card inserted)
OpenBSD 4.4-current (GENERIC.MP) #5: Tue Jan  6 21:23:56 EST 2009
r...@paladin.pls.msu.edu:/usr/src/sys/arch/i386/compile/GENERIC.MP
cpu0: Intel(R) Core(TM)2 Duo CPU T9600 @ 2.80GHz (GenuineIntel 686-class) 
2.80 GHz
cpu0: 
FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,SBF,SSE3,MWAIT,DS-CPL,VMX,SMX,EST,TM2,CX16,xTPR
real mem  = 2123657216 (2025MB)
avail mem = 2045169664 (1950MB)
mainbus0 at root
bios0 at mainbus0: AT/286+ BIOS, date 09/24/08, BIOS32 rev. 0 @ 0xfdc80, 
SMBIOS rev. 2.4 @ 0xe0010 (74 entries)
bios0: vendor LENOVO version 6FET46WW (1.16 ) date 09/24/2008
bios0: LENOVO 4061CTO
acpi0 at bios0: rev 2
acpi0: tables DSDT FACP SSDT ECDT APIC MCFG HPET SLIC BOOT ASF! SSDT SSDT SSDT 
SSDT
acpi0: wakeup devices LID_(S3) SLPB(S3) UART(S3) IGBE(S4) EXP0(S4) EXP1(S4) 
EXP2(S4) EXP3(S4) EXP4(S4) PCI1(S4) USB0(S3) USB1(S3) USB2(S3) USB3(S3) USB4
(S3) USB5(S3) EHC0(S3) EHC1(S3) HDEF(S4)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: unknown i686 EBL_CR_POWERON value 3 (0x428c0800)
cpu0: apic clock running at 266MHz
cpu1 at mainbus0: apid 1 (application processor)
cpu1: Intel(R) Core(TM)2 Duo CPU T9600 @ 2.80GHz (GenuineIntel 686-class) 
2.80 GHz
cpu1: 
FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,SBF,SSE3,MWAIT,DS-CPL,VMX,SMX,EST,TM2,CX16,xTPR
ioapic0 at mainbus0: apid 1 pa 0xfec0, version 20, 24 pins
ioapic0: misconfigured as apic 2, remapped to apid 1
acpihpet0 at acpi0: 14318179 Hz
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus 1 (AGP_)
acpiprt2 at acpi0: bus 2 (EXP0)
acpiprt3 at acpi0: bus 3 (EXP1)
acpiprt4 at acpi0: bus -1 (EXP2)
acpiprt5 at acpi0: bus 5 (EXP3)
acpiprt6 at acpi0: bus 13 (EXP4)
acpiprt7 at acpi0: bus 21 (PCI1)
acpiec0 at acpi0
acpicpu0 at acpi0: C3, C2
acpicpu1 at acpi0: C3, C2
acpitz0 at acpi0: critical temperature 127 degC
acpitz1 at acpi0: critical temperature 100 degC
acpibtn0 at acpi0: LID_
acpibtn1 at acpi0: SLPB
acpibat0 at acpi0: BAT0 model 42T4619 serial 30781 type LION oem SANYO
acpibat1 at acpi0: BAT1 not present
acpiac0 at acpi0: AC unit online
acpithinkpad0 at acpi0
acpidock at acpi0 not configured
acpivideo at acpi0 not configured
acpivideo at acpi0 not configured
bios0: ROM list: 0xc/0xfc00 0xd/0x1000 0xd1000/0x1000 0xd2000/0x1000 
0xde000/0x1800! 0xe/0x1
cpu0: EST: unknown system bus clock
pci0 at mainbus0 bus 0: configuration mode 1 (bios)
pchb0 at pci0 dev 0 function 0 Intel GM45 Host rev 0x07
ppb0 at pci0 dev 1 function 0 Intel GM45 PCIE rev 0x07: apic 1 int 16 (irq 
11)
pci1 at ppb0 bus 1
vga1 at pci1 dev 0 function 0 ATI Mobility Radeon HD 3650 rev 0x00
wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
Intel GM45 HECI rev 0x07 at pci0 dev 3 function 0 not configured
pciide0 at pci0 dev 3 function 2 Intel GM45 PT IDER rev 0x07: DMA 
(unsupported), channel 0 wired to native-PCI, channel 1 wired to native-PCI
pciide0: using apic 1 int 18 (irq 11) for native-PCI interrupt
pciide0: channel 0 ignored (not responding; disabled or no drives?)
pciide0: channel 1 ignored (not responding; disabled or no drives?)
Intel GM45 AMT SOL rev 0x07 at pci0 dev 3 function 3 not configured
em0 at pci0 dev 25 function 0 Intel ICH9 IGP M AMT rev 0x03: apic 1 int 20 
(irq 11), address 00:1c:25:99:d7:77
uhci0 at pci0 dev 26 function 0 Intel 82801I USB rev 0x03: apic 1 int 20 
(irq 11)
uhci1 at pci0 dev 26 function 1 Intel 82801I USB rev 0x03: apic 1 int 21 
(irq 11)
uhci2 at pci0 dev 26 function 2 Intel 82801I USB rev 0x03: apic 1 int 22 
(irq 11)
ehci0 at pci0 dev 26 function 7 Intel 82801I USB rev 0x03: apic 1 int 23 
(irq 11)
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 Intel EHCI root hub rev 2.00/1.00 addr 1
azalia0 at pci0 dev 27 function 0 Intel 82801I HD Audio rev 0x03: apic 1 int 
17 (irq 11)
azalia0: RIRB time out
azalia0: codecs: Conexant CX20561, Conexant/0x2c06, using Conexant CX20561
audio0 at azalia0
ppb1 at pci0 dev 28 function 0 Intel 82801I PCIE rev 0x03: apic 1 int 20 
(irq 11)
pci2 at ppb1 bus 2
ppb2 at pci0 dev 28 function 1 Intel 82801I PCIE rev 0x03: apic 1 int 21 
(irq 11)
pci3 at ppb2 bus 3
iwn0 at pci3 dev 0 function 0 Intel WiFi Link 5300AGN rev 0x00: apic 1 int 
17 (irq 11), MIMO 3T3R, MoW, address 00:21:6a:01:d0:b6
ppb3 at pci0 dev 28 function 3 Intel 82801I PCIE rev 0x03: apic 1 int 23 
(irq 11)
pci4 at 

Re: Size of SD devices supported?

2009-01-07 Thread Floor Terra

STeve Andre' wrote:

   My new Thinkpad W500 has a SD slot, and stuffing a 1G card in
works just fine.

   I borrowed a 16G SD card, and that gives a can't enable card
error.
  

My Eee PC supports an 8GB card just fine:
umass0 at uhub0 port 5 configuration 1 interface 0 Generic Mass Storage 
Device rev 2.00/1.05 addr 2

umass0: using SCSI over Bulk-Only
scsibus0 at umass0: 2 targets, initiator 0
sd0 at scsibus0 targ 1 lun 0: Single, Flash Reader, 1.00 SCSI0 
0/direct removable

sd0: 7790MB, 512 bytes/sec, 15954944 sec total

Mounting the filesystem  works too. 8GB is my largest card so I can't 
test any more.

   I just found specs for the SD card, and wonder if the current
code works with cards beyond 4G?  Or, do I have a defective 16G
card? (I currently have no way to test that).  I haven't seen much
in the way of discussion about this.

Thanks, STeve Andre'

(dmesg with  the 1G card inserted)
OpenBSD 4.4-current (GENERIC.MP) #5: Tue Jan  6 21:23:56 EST 2009
r...@paladin.pls.msu.edu:/usr/src/sys/arch/i386/compile/GENERIC.MP
cpu0: Intel(R) Core(TM)2 Duo CPU T9600 @ 2.80GHz (GenuineIntel 686-class) 
2.80 GHz
cpu0: 
FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,SBF,SSE3,MWAIT,DS-CPL,VMX,SMX,EST,TM2,CX16,xTPR

real mem  = 2123657216 (2025MB)
avail mem = 2045169664 (1950MB)
mainbus0 at root
bios0 at mainbus0: AT/286+ BIOS, date 09/24/08, BIOS32 rev. 0 @ 0xfdc80, 
SMBIOS rev. 2.4 @ 0xe0010 (74 entries)

bios0: vendor LENOVO version 6FET46WW (1.16 ) date 09/24/2008
bios0: LENOVO 4061CTO
acpi0 at bios0: rev 2
acpi0: tables DSDT FACP SSDT ECDT APIC MCFG HPET SLIC BOOT ASF! SSDT SSDT SSDT 
SSDT
acpi0: wakeup devices LID_(S3) SLPB(S3) UART(S3) IGBE(S4) EXP0(S4) EXP1(S4) 
EXP2(S4) EXP3(S4) EXP4(S4) PCI1(S4) USB0(S3) USB1(S3) USB2(S3) USB3(S3) USB4

(S3) USB5(S3) EHC0(S3) EHC1(S3) HDEF(S4)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: unknown i686 EBL_CR_POWERON value 3 (0x428c0800)
cpu0: apic clock running at 266MHz
cpu1 at mainbus0: apid 1 (application processor)
cpu1: Intel(R) Core(TM)2 Duo CPU T9600 @ 2.80GHz (GenuineIntel 686-class) 
2.80 GHz
cpu1: 
FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,SBF,SSE3,MWAIT,DS-CPL,VMX,SMX,EST,TM2,CX16,xTPR

ioapic0 at mainbus0: apid 1 pa 0xfec0, version 20, 24 pins
ioapic0: misconfigured as apic 2, remapped to apid 1
acpihpet0 at acpi0: 14318179 Hz
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus 1 (AGP_)
acpiprt2 at acpi0: bus 2 (EXP0)
acpiprt3 at acpi0: bus 3 (EXP1)
acpiprt4 at acpi0: bus -1 (EXP2)
acpiprt5 at acpi0: bus 5 (EXP3)
acpiprt6 at acpi0: bus 13 (EXP4)
acpiprt7 at acpi0: bus 21 (PCI1)
acpiec0 at acpi0
acpicpu0 at acpi0: C3, C2
acpicpu1 at acpi0: C3, C2
acpitz0 at acpi0: critical temperature 127 degC
acpitz1 at acpi0: critical temperature 100 degC
acpibtn0 at acpi0: LID_
acpibtn1 at acpi0: SLPB
acpibat0 at acpi0: BAT0 model 42T4619 serial 30781 type LION oem SANYO
acpibat1 at acpi0: BAT1 not present
acpiac0 at acpi0: AC unit online
acpithinkpad0 at acpi0
acpidock at acpi0 not configured
acpivideo at acpi0 not configured
acpivideo at acpi0 not configured
bios0: ROM list: 0xc/0xfc00 0xd/0x1000 0xd1000/0x1000 0xd2000/0x1000 
0xde000/0x1800! 0xe/0x1

cpu0: EST: unknown system bus clock
pci0 at mainbus0 bus 0: configuration mode 1 (bios)
pchb0 at pci0 dev 0 function 0 Intel GM45 Host rev 0x07
ppb0 at pci0 dev 1 function 0 Intel GM45 PCIE rev 0x07: apic 1 int 16 (irq 
11)

pci1 at ppb0 bus 1
vga1 at pci1 dev 0 function 0 ATI Mobility Radeon HD 3650 rev 0x00
wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
Intel GM45 HECI rev 0x07 at pci0 dev 3 function 0 not configured
pciide0 at pci0 dev 3 function 2 Intel GM45 PT IDER rev 0x07: DMA 
(unsupported), channel 0 wired to native-PCI, channel 1 wired to native-PCI

pciide0: using apic 1 int 18 (irq 11) for native-PCI interrupt
pciide0: channel 0 ignored (not responding; disabled or no drives?)
pciide0: channel 1 ignored (not responding; disabled or no drives?)
Intel GM45 AMT SOL rev 0x07 at pci0 dev 3 function 3 not configured
em0 at pci0 dev 25 function 0 Intel ICH9 IGP M AMT rev 0x03: apic 1 int 20 
(irq 11), address 00:1c:25:99:d7:77
uhci0 at pci0 dev 26 function 0 Intel 82801I USB rev 0x03: apic 1 int 20 
(irq 11)
uhci1 at pci0 dev 26 function 1 Intel 82801I USB rev 0x03: apic 1 int 21 
(irq 11)
uhci2 at pci0 dev 26 function 2 Intel 82801I USB rev 0x03: apic 1 int 22 
(irq 11)
ehci0 at pci0 dev 26 function 7 Intel 82801I USB rev 0x03: apic 1 int 23 
(irq 11)

usb0 at ehci0: USB revision 2.0
uhub0 at usb0 Intel EHCI root hub rev 2.00/1.00 addr 1
azalia0 at pci0 dev 27 function 0 Intel 82801I HD Audio rev 0x03: apic 1 int 
17 (irq 11)

azalia0: RIRB time out
azalia0: codecs: Conexant CX20561, 

Re: Size of SD devices supported?

2009-01-07 Thread K K
My understanding is that when a device appears as 'umass', support for
large cards and/or SDHC is entirely at the mercy of the reader chipset
'behind' the USB interface that hides it from the host.

For the Thinkpad, it looks like the card reader is detected as an
actual SDHC device (sdhc0 at pci6 dev 0 function 2 Ricoh 5C822
SD/MMC), so support for larger cards might require specific support
in the OpenBSD driver?

My new work laptop has a similar Ricoh reader, so I am interested in
the outcome of this question.


Kevin



Re: Size of SD devices supported?

2009-01-07 Thread Jonathan Gray
On Wed, Jan 07, 2009 at 02:49:50PM -0500, STeve Andre' wrote:
My new Thinkpad W500 has a SD slot, and stuffing a 1G card in
 works just fine.
 
I borrowed a 16G SD card, and that gives a can't enable card
 error.
 
I just found specs for the SD card, and wonder if the current
 code works with cards beyond 4G?  Or, do I have a defective 16G
 card? (I currently have no way to test that).  I haven't seen much
 in the way of discussion about this.

This diff should let you use SDHC cards (most cards = 4GB).
Let me know how it goes.

Index: sdmmc.c
===
RCS file: /cvs/src/sys/dev/sdmmc/sdmmc.c,v
retrieving revision 1.16
diff -u -p -r1.16 sdmmc.c
--- sdmmc.c 2 Dec 2008 23:49:54 -   1.16
+++ sdmmc.c 7 Jan 2009 09:47:35 -
@@ -569,6 +569,32 @@ sdmmc_go_idle_state(struct sdmmc_softc *
 }
 
 /*
+ * Send the SEND_IF_COND command, to check operating condition
+ */
+int
+sdmmc_send_if_cond(struct sdmmc_softc *sc, uint32_t card_ocr)
+{
+   struct sdmmc_command cmd;
+   uint8_t pat = 0x23;
+   uint8_t res;
+
+   bzero(cmd, sizeof cmd);
+
+   cmd.c_opcode = SD_SEND_IF_COND;
+   cmd.c_arg = ((card_ocr  SD_OCR_VOL_MASK) != 0)  8 | pat;
+   cmd.c_flags = SCF_CMD_BCR | SCF_RSP_R7;
+
+   if (sdmmc_mmc_command(sc, cmd) != 0)
+   return 1;
+
+   res = cmd.c_resp[0];
+   if (res != pat)
+   return 1;
+   else
+   return 0;
+}
+
+/*
  * Retrieve (SD) or set (MMC) the relative card address (RCA).
  */
 int
Index: sdmmc_mem.c
===
RCS file: /cvs/src/sys/dev/sdmmc/sdmmc_mem.c,v
retrieving revision 1.9
diff -u -p -r1.9 sdmmc_mem.c
--- sdmmc_mem.c 2 Dec 2008 23:49:54 -   1.9
+++ sdmmc_mem.c 7 Jan 2009 09:47:35 -
@@ -93,6 +93,9 @@ sdmmc_mem_enable(struct sdmmc_softc *sc)
/* Tell the card(s) to enter the idle state (again). */
sdmmc_go_idle_state(sc);
 
+   if (sdmmc_send_if_cond(sc, card_ocr) == 0)
+   host_ocr |= SD_OCR_SDHC_CAP;
+
/* Send the new OCR value until all cards are ready. */
if (sdmmc_mem_send_op_cond(sc, host_ocr, NULL) != 0) {
DPRINTF((%s: can't send memory OCR\n, SDMMCDEVNAME(sc)));
@@ -224,14 +227,23 @@ sdmmc_decode_csd(struct sdmmc_softc *sc,
 * specification version 1.0 - 1.10. (SanDisk, 3.5.3)
 */
csd-csdver = SD_CSD_CSDVER(resp);
-   if (csd-csdver != SD_CSD_CSDVER_1_0) {
+   switch (csd-csdver) {
+   case SD_CSD_CSDVER_2_0:
+   sc-sc_flags |= SMF_SDHC;
+   csd-capacity = SD_CSD_V2_CAPACITY(resp);
+   csd-read_bl_len = SD_CSD_V2_BL_LEN;
+   break;
+   case SD_CSD_CSDVER_1_0:
+   csd-capacity = SD_CSD_CAPACITY(resp);
+   csd-read_bl_len = SD_CSD_READ_BL_LEN(resp);
+   break;
+   default:
printf(%s: unknown SD CSD structure version 0x%x\n,
SDMMCDEVNAME(sc), csd-csdver);
return 1;
+   break;
}
 
-   csd-capacity = SD_CSD_CAPACITY(resp);
-   csd-read_bl_len = SD_CSD_READ_BL_LEN(resp);
} else {
csd-csdver = MMC_CSD_CSDVER(resp);
if (csd-csdver != MMC_CSD_CSDVER_1_0 
@@ -403,7 +415,10 @@ sdmmc_mem_read_block(struct sdmmc_functi
cmd.c_blklen = sf-csd.sector_size;
cmd.c_opcode = (datalen / cmd.c_blklen)  1 ?
MMC_READ_BLOCK_MULTIPLE : MMC_READ_BLOCK_SINGLE;
-   cmd.c_arg = blkno  9;
+   if (sc-sc_flags  SMF_SDHC)
+   cmd.c_arg = blkno;
+   else
+   cmd.c_arg = blkno  9;
cmd.c_flags = SCF_CMD_ADTC | SCF_CMD_READ | SCF_RSP_R1;
 
error = sdmmc_mmc_command(sc, cmd);
Index: sdmmcreg.h
===
RCS file: /cvs/src/sys/dev/sdmmc/sdmmcreg.h,v
retrieving revision 1.3
diff -u -p -r1.3 sdmmcreg.h
--- sdmmcreg.h  18 Mar 2007 22:21:21 -  1.3
+++ sdmmcreg.h  7 Jan 2009 09:47:36 -
@@ -38,6 +38,7 @@
 
 /* SD commands */  /* response type */
 #define SD_SEND_RELATIVE_ADDR  3   /* R6 */
+#define SD_SEND_IF_COND8   /* R7 */
 
 /* SD application commands */  /* response type */
 #define SD_APP_SET_BUS_WIDTH   6   /* R1 */
@@ -66,6 +67,9 @@
 #define MMC_OCR_1_7V_1_8V  (15)
 #define MMC_OCR_1_6V_1_7V  (14)
 
+#define SD_OCR_SDHC_CAP(130)
+#define SD_OCR_VOL_MASK0xFF8000 /* bits 23:15 */
+
 /* R1 response type bits */
 #define MMC_R1_READY_FOR_DATA  (18)  /* ready for next transfer */
 #define