Module Name:    src
Committed By:   mlelstv
Date:           Tue Oct  6 14:32:51 UTC 2015

Modified Files:
        src/sys/dev/sdmmc: sdhc.c sdmmc_io.c sdmmc_mem.c sdmmcvar.h

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


To generate a diff of this commit:
cvs rdiff -u -r1.87 -r1.88 src/sys/dev/sdmmc/sdhc.c
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/sdmmc/sdmmc_io.c
cvs rdiff -u -r1.46 -r1.47 src/sys/dev/sdmmc/sdmmc_mem.c
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/sdmmc/sdmmcvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/sdmmc/sdhc.c
diff -u src/sys/dev/sdmmc/sdhc.c:1.87 src/sys/dev/sdmmc/sdhc.c:1.88
--- src/sys/dev/sdmmc/sdhc.c:1.87	Wed Sep  9 08:09:28 2015
+++ src/sys/dev/sdmmc/sdhc.c	Tue Oct  6 14:32:51 2015
@@ -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 void	sdhc_tuning_timer(void *);
 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 @@ sdhc_execute_tuning1(struct sdhc_host *h
 			break;
 
 		if (!sdhc_wait_intr(hp, SDHC_BUFFER_READ_READY,
-		    SDHC_TUNING_TIMEOUT)) {
+		    SDHC_TUNING_TIMEOUT, false)) {
 			break;
 		}
 
@@ -1409,6 +1409,7 @@ sdhc_exec_command(sdmmc_chipset_handle_t
 {
 	struct sdhc_host *hp = (struct sdhc_host *)sch;
 	int error;
+	bool probing;
 
 	mutex_enter(&hp->intr_lock);
 
@@ -1451,7 +1452,8 @@ sdhc_exec_command(sdmmc_chipset_handle_t
 	 * 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 @@ sdhc_exec_command(sdmmc_chipset_handle_t
 	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 @@ sdhc_transfer_data(struct sdhc_host *hp,
 		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 @@ sdhc_transfer_data_dma(struct sdhc_host 
 	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 @@ sdhc_transfer_data_pio(struct sdhc_host 
 			} 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 @@ sdhc_transfer_data_pio(struct sdhc_host 
 	}
 
 	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 @@ sdhc_soft_reset(struct sdhc_host *hp, in
 }
 
 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 @@ sdhc_wait_intr(struct sdhc_host *hp, int
 			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));

Index: src/sys/dev/sdmmc/sdmmc_io.c
diff -u src/sys/dev/sdmmc/sdmmc_io.c:1.11 src/sys/dev/sdmmc/sdmmc_io.c:1.12
--- src/sys/dev/sdmmc/sdmmc_io.c:1.11	Wed Aug  5 07:34:56 2015
+++ src/sys/dev/sdmmc/sdmmc_io.c	Tue Oct  6 14:32:51 2015
@@ -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 @@ sdmmc_io_send_op_cond(struct sdmmc_softc
 		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)

Index: src/sys/dev/sdmmc/sdmmc_mem.c
diff -u src/sys/dev/sdmmc/sdmmc_mem.c:1.46 src/sys/dev/sdmmc/sdmmc_mem.c:1.47
--- src/sys/dev/sdmmc/sdmmc_mem.c:1.46	Sat Aug  8 10:50:55 2015
+++ src/sys/dev/sdmmc/sdmmc_mem.c	Tue Oct  6 14:32:51 2015
@@ -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 @@ sdmmc_mem_send_cid(struct sdmmc_softc *s
 	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 {

Index: src/sys/dev/sdmmc/sdmmcvar.h
diff -u src/sys/dev/sdmmc/sdmmcvar.h:1.19 src/sys/dev/sdmmc/sdmmcvar.h:1.20
--- src/sys/dev/sdmmc/sdmmcvar.h:1.19	Sun Aug  9 13:18:46 2015
+++ src/sys/dev/sdmmc/sdmmcvar.h	Tue Oct  6 14:32:51 2015
@@ -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 @@ struct sdmmc_command {
 #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)

Reply via email to