Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/sdmmc support hiding command timeout messages with a...



details:   https://anonhg.NetBSD.org/src/rev/0d19d7e302d9
branches:  trunk
changeset: 340854:0d19d7e302d9
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Tue Oct 06 14:32:51 2015 +0000

description:
support hiding command timeout messages with a new command flag and use this
when probing for cards. Should fix PR 50302.

diffstat:

 sys/dev/sdmmc/sdhc.c      |  34 +++++++++++++++++++++-------------
 sys/dev/sdmmc/sdmmc_io.c  |   6 +++---
 sys/dev/sdmmc/sdmmc_mem.c |   6 +++---
 sys/dev/sdmmc/sdmmcvar.h  |   4 +++-
 4 files changed, 30 insertions(+), 20 deletions(-)

diffs (197 lines):

diff -r d45ab48420c2 -r 0d19d7e302d9 sys/dev/sdmmc/sdhc.c
--- a/sys/dev/sdmmc/sdhc.c      Tue Oct 06 11:22:40 2015 +0000
+++ b/sys/dev/sdmmc/sdhc.c      Tue Oct 06 14:32:51 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sdhc.c,v 1.87 2015/09/09 08:09:28 mlelstv Exp $        */
+/*     $NetBSD: sdhc.c,v 1.88 2015/10/06 14:32:51 mlelstv Exp $        */
 /*     $OpenBSD: sdhc.c,v 1.25 2009/01/13 19:44:20 grange Exp $        */
 
 /*
@@ -23,7 +23,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.87 2015/09/09 08:09:28 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.88 2015/10/06 14:32:51 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -195,7 +195,7 @@
 static int     sdhc_start_command(struct sdhc_host *, struct sdmmc_command *);
 static int     sdhc_wait_state(struct sdhc_host *, uint32_t, uint32_t);
 static int     sdhc_soft_reset(struct sdhc_host *, int);
-static int     sdhc_wait_intr(struct sdhc_host *, int, int);
+static int     sdhc_wait_intr(struct sdhc_host *, int, int, bool);
 static void    sdhc_transfer_data(struct sdhc_host *, struct sdmmc_command *);
 static int     sdhc_transfer_data_dma(struct sdhc_host *, struct sdmmc_command *);
 static int     sdhc_transfer_data_pio(struct sdhc_host *, struct sdmmc_command *);
@@ -1331,7 +1331,7 @@
                        break;
 
                if (!sdhc_wait_intr(hp, SDHC_BUFFER_READ_READY,
-                   SDHC_TUNING_TIMEOUT)) {
+                   SDHC_TUNING_TIMEOUT, false)) {
                        break;
                }
 
@@ -1409,6 +1409,7 @@
 {
        struct sdhc_host *hp = (struct sdhc_host *)sch;
        int error;
+       bool probing;
 
        mutex_enter(&hp->intr_lock);
 
@@ -1451,7 +1452,8 @@
         * Wait until the command phase is done, or until the command
         * is marked done for any other reason.
         */
-       if (!sdhc_wait_intr(hp, SDHC_COMMAND_COMPLETE, SDHC_COMMAND_TIMEOUT)) {
+       probing = (cmd->c_flags & SCF_TOUT_OK) != 0;
+       if (!sdhc_wait_intr(hp, SDHC_COMMAND_COMPLETE, SDHC_COMMAND_TIMEOUT, probing)) {
                DPRINTF(1,("%s: timeout for command\n", __func__));
                cmd->c_error = ETIMEDOUT;
                goto out;
@@ -1488,7 +1490,7 @@
        if (cmd->c_error == 0 && cmd->c_data != NULL)
                sdhc_transfer_data(hp, cmd);
        else if (ISSET(cmd->c_flags, SCF_RSP_BSY)) {
-               if (!sdhc_wait_intr(hp, SDHC_TRANSFER_COMPLETE, hz * 10)) {
+               if (!sdhc_wait_intr(hp, SDHC_TRANSFER_COMPLETE, hz * 10, false)) {
                        DPRINTF(1,("%s: sdhc_exec_command: RSP_BSY\n",
                            HDEVNAME(hp)));
                        cmd->c_error = ETIMEDOUT;
@@ -1707,7 +1709,7 @@
                if (hp->sc->sc_vendor_transfer_data_dma != NULL) {
                        error = hp->sc->sc_vendor_transfer_data_dma(sc, cmd);
                        if (error == 0 && !sdhc_wait_intr(hp,
-                           SDHC_TRANSFER_COMPLETE, SDHC_DMA_TIMEOUT)) {
+                           SDHC_TRANSFER_COMPLETE, SDHC_DMA_TIMEOUT, false)) {
                                DPRINTF(1,("%s: timeout\n", __func__));
                                error = ETIMEDOUT;
                        }
@@ -1744,7 +1746,7 @@
        for (;;) {
                status = sdhc_wait_intr(hp,
                    SDHC_DMA_INTERRUPT|SDHC_TRANSFER_COMPLETE,
-                   SDHC_DMA_TIMEOUT);
+                   SDHC_DMA_TIMEOUT, false);
 
                if (status & SDHC_TRANSFER_COMPLETE) {
                        break;
@@ -1830,7 +1832,7 @@
                        } else {
                                HSET2(hp, SDHC_NINTR_SIGNAL_EN, imask);
                        }
-                       if (!sdhc_wait_intr(hp, imask, SDHC_BUFFER_TIMEOUT)) {
+                       if (!sdhc_wait_intr(hp, imask, SDHC_BUFFER_TIMEOUT, false)) {
                                DPRINTF(1,("%s: timeout\n", __func__));
                                error = ETIMEDOUT;
                                break;
@@ -1851,7 +1853,7 @@
        }
 
        if (error == 0 && !sdhc_wait_intr(hp, SDHC_TRANSFER_COMPLETE,
-           SDHC_TRANSFER_TIMEOUT)) {
+           SDHC_TRANSFER_TIMEOUT, false)) {
                DPRINTF(1,("%s: timeout for transfer\n", __func__));
                error = ETIMEDOUT;
        }
@@ -2063,7 +2065,7 @@
 }
 
 static int
-sdhc_wait_intr(struct sdhc_host *hp, int mask, int timo)
+sdhc_wait_intr(struct sdhc_host *hp, int mask, int timo, bool probing)
 {
        int status, error, nointr;
 
@@ -2110,8 +2112,14 @@
                        device_printf(hp->sc->sc_dev,"cmd end bit error\n");
                if (ISSET(error, SDHC_CMD_CRC_ERROR))
                        device_printf(hp->sc->sc_dev,"cmd crc error\n");
-               if (ISSET(error, SDHC_CMD_TIMEOUT_ERROR))
-                       device_printf(hp->sc->sc_dev,"cmd timeout error\n");
+               if (ISSET(error, SDHC_CMD_TIMEOUT_ERROR)) {
+                       if (!probing)
+                               device_printf(hp->sc->sc_dev,"cmd timeout error\n");
+#ifdef SDHC_DEBUG
+                       else if (sdhcdebug > 0)
+                               device_printf(hp->sc->sc_dev,"cmd timeout (expected)\n");
+#endif
+               }
                if ((error & ~SDHC_EINTR_STATUS_MASK) != 0)
                        device_printf(hp->sc->sc_dev,"vendor error %#x\n",
                                (error & ~SDHC_EINTR_STATUS_MASK));
diff -r d45ab48420c2 -r 0d19d7e302d9 sys/dev/sdmmc/sdmmc_io.c
--- a/sys/dev/sdmmc/sdmmc_io.c  Tue Oct 06 11:22:40 2015 +0000
+++ b/sys/dev/sdmmc/sdmmc_io.c  Tue Oct 06 14:32:51 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sdmmc_io.c,v 1.11 2015/08/05 07:34:56 mlelstv Exp $    */
+/*     $NetBSD: sdmmc_io.c,v 1.12 2015/10/06 14:32:51 mlelstv Exp $    */
 /*     $OpenBSD: sdmmc_io.c,v 1.10 2007/09/17 01:33:33 krw Exp $       */
 
 /*
@@ -20,7 +20,7 @@
 /* Routines for SD I/O cards. */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sdmmc_io.c,v 1.11 2015/08/05 07:34:56 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdmmc_io.c,v 1.12 2015/10/06 14:32:51 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -566,7 +566,7 @@
                memset(&cmd, 0, sizeof cmd);
                cmd.c_opcode = SD_IO_SEND_OP_COND;
                cmd.c_arg = ocr;
-               cmd.c_flags = SCF_CMD_BCR | SCF_RSP_R4;
+               cmd.c_flags = SCF_CMD_BCR | SCF_RSP_R4 | SCF_TOUT_OK;
 
                error = sdmmc_mmc_command(sc, &cmd);
                if (error)
diff -r d45ab48420c2 -r 0d19d7e302d9 sys/dev/sdmmc/sdmmc_mem.c
--- a/sys/dev/sdmmc/sdmmc_mem.c Tue Oct 06 11:22:40 2015 +0000
+++ b/sys/dev/sdmmc/sdmmc_mem.c Tue Oct 06 14:32:51 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sdmmc_mem.c,v 1.46 2015/08/08 10:50:55 jmcneill Exp $  */
+/*     $NetBSD: sdmmc_mem.c,v 1.47 2015/10/06 14:32:51 mlelstv 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.46 2015/08/08 10:50:55 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdmmc_mem.c,v 1.47 2015/10/06 14:32:51 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -1068,7 +1068,7 @@
        if (!ISSET(sc->sc_caps, SMC_CAPS_SPI_MODE)) {
                memset(&cmd, 0, sizeof cmd);
                cmd.c_opcode = MMC_ALL_SEND_CID;
-               cmd.c_flags = SCF_CMD_BCR | SCF_RSP_R2;
+               cmd.c_flags = SCF_CMD_BCR | SCF_RSP_R2 | SCF_TOUT_OK;
 
                error = sdmmc_mmc_command(sc, &cmd);
        } else {
diff -r d45ab48420c2 -r 0d19d7e302d9 sys/dev/sdmmc/sdmmcvar.h
--- a/sys/dev/sdmmc/sdmmcvar.h  Tue Oct 06 11:22:40 2015 +0000
+++ b/sys/dev/sdmmc/sdmmcvar.h  Tue Oct 06 14:32:51 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sdmmcvar.h,v 1.19 2015/08/09 13:18:46 mlelstv Exp $    */
+/*     $NetBSD: sdmmcvar.h,v 1.20 2015/10/06 14:32:51 mlelstv Exp $    */
 /*     $OpenBSD: sdmmcvar.h,v 1.13 2009/01/09 10:55:22 jsg Exp $       */
 
 /*
@@ -114,6 +114,8 @@
 #define SCF_RSP_SPI_S2 (1U << 11)
 #define SCF_RSP_SPI_B4 (1U << 12)
 #define SCF_RSP_SPI_BSY        (1U << 13)
+/* Probing */
+#define SCF_TOUT_OK    (1U << 14)      /* command timeout expected */
 /* response types */
 #define SCF_RSP_R0     0       /* none */
 #define SCF_RSP_R1     (SCF_RSP_PRESENT|SCF_RSP_CRC|SCF_RSP_IDX)



Home | Main Index | Thread Index | Old Index