Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/sdmmc For SD cards, send the SET_WR_BLK_ERASE_COUNT ...
details: https://anonhg.NetBSD.org/src/rev/d6754e4d681a
branches: trunk
changeset: 356253:d6754e4d681a
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Tue Sep 12 13:43:37 2017 +0000
description:
For SD cards, send the SET_WR_BLK_ERASE_COUNT app command before a
multi-block write to improve write performance.
diffstat:
sys/dev/sdmmc/sdmmc_mem.c | 16 ++++++++++++++--
sys/dev/sdmmc/sdmmcreg.h | 3 ++-
2 files changed, 16 insertions(+), 3 deletions(-)
diffs (54 lines):
diff -r c3247c96fdce -r d6754e4d681a sys/dev/sdmmc/sdmmc_mem.c
--- a/sys/dev/sdmmc/sdmmc_mem.c Tue Sep 12 10:46:33 2017 +0000
+++ b/sys/dev/sdmmc/sdmmc_mem.c Tue Sep 12 13:43:37 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sdmmc_mem.c,v 1.62 2017/08/20 15:58:43 mlelstv Exp $ */
+/* $NetBSD: sdmmc_mem.c,v 1.63 2017/09/12 13:43:37 jmcneill Exp $ */
/* $OpenBSD: sdmmc_mem.c,v 1.10 2009/01/09 10:55:22 jsg Exp $ */
/*
@@ -45,7 +45,7 @@
/* Routines for SD/MMC memory cards. */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sdmmc_mem.c,v 1.62 2017/08/20 15:58:43 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdmmc_mem.c,v 1.63 2017/09/12 13:43:37 jmcneill Exp $");
#ifdef _KERNEL_OPT
#include "opt_sdmmc.h"
@@ -2021,6 +2021,18 @@
goto out;
}
+ const int nblk = howmany(datalen, SDMMC_SECTOR_SIZE);
+ if (ISSET(sc->sc_flags, SMF_SD_MODE) && nblk > 1) {
+ /* Set the number of write blocks to be pre-erased */
+ memset(&cmd, 0, sizeof(cmd));
+ cmd.c_opcode = SD_APP_SET_WR_BLK_ERASE_COUNT;
+ cmd.c_flags = SCF_RSP_R1 | SCF_RSP_SPI_R1 | SCF_CMD_AC;
+ cmd.c_arg = nblk;
+ error = sdmmc_app_command(sc, sf, &cmd);
+ if (error)
+ goto out;
+ }
+
memset(&cmd, 0, sizeof(cmd));
cmd.c_data = data;
cmd.c_datalen = datalen;
diff -r c3247c96fdce -r d6754e4d681a sys/dev/sdmmc/sdmmcreg.h
--- a/sys/dev/sdmmc/sdmmcreg.h Tue Sep 12 10:46:33 2017 +0000
+++ b/sys/dev/sdmmc/sdmmcreg.h Tue Sep 12 13:43:37 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sdmmcreg.h,v 1.32 2017/07/16 17:11:46 jmcneill Exp $ */
+/* $NetBSD: sdmmcreg.h,v 1.33 2017/09/12 13:43:37 jmcneill Exp $ */
/* $OpenBSD: sdmmcreg.h,v 1.4 2009/01/09 10:55:22 jsg Exp $ */
/*
@@ -67,6 +67,7 @@
/* SD application commands */ /* response type */
#define SD_APP_SET_BUS_WIDTH 6 /* R1 */
#define SD_APP_SD_STATUS 13 /* R1 */
+#define SD_APP_SET_WR_BLK_ERASE_COUNT 23 /* R1 */
#define SD_APP_OP_COND 41 /* R3 */
#define SD_APP_SEND_SCR 51 /* R1 */
Home |
Main Index |
Thread Index |
Old Index