Skip to contentSkip to conversation

mmc/sdio: add a quirk for broken SDIO_CCCR_INTx polling

PATCH Superseded Bing Zhao 2 participants 3 messages Nov 25, 2013 – Nov 26, 2013 MMC, SD and SDIO

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Bing Zhao

author
#0 lore raw

PATCH 1/1 mmc/sdio: add a quirk for broken SDIO_CCCR_INTx polling

Polling SDIO_CCCR_INTx could create a fake interrupt with Marvell SD8797 card. Add a quirk to handle this case. The fixup here is to issue a dummy CMD52 read to function 0 register 0xff, and this dummy read must be right after SDIO_CCCR_INTx is read.

Patch has been verified on a dw_mmc controller (Samsung Chromebook) with MMC_CAP_SDIO_IRQ disabled.

---
 drivers/mmc/core/quirks.c   | 21 +++++++++++++++++++++
 drivers/mmc/core/sdio_irq.c |  5 +++++
 include/linux/mmc/card.h    |  4 +++-
 3 files changed, 29 insertions(+), 1 deletion(-)
drivers/mmc/core/quirks.c +21 -0
index 06ee1ae..870bcc3 100644
@@ -13,6 +13,9 @@
 #include <linux/kernel.h>
 #include <linux/export.h>
 #include <linux/mmc/card.h>
+#include <linux/mmc/sdio_ids.h>
+
+#include "sdio_ops.h"
 
 #ifndef SDIO_VENDOR_ID_TI
 #define SDIO_VENDOR_ID_TI		0x0097
@@ -30,6 +33,10 @@
 #define SDIO_DEVICE_ID_STE_CW1200	0x2280
 #endif
 
+#ifndef SDIO_DEVICE_ID_MARVELL_8797_F0
+#define SDIO_DEVICE_ID_MARVELL_8797_F0	0x9128
+#endif
+
 /*
  * This hook just adds a quirk for all sdio devices
  */
@@ -58,6 +65,9 @@ static const struct mmc_fixup mmc_fixup_methods[] = {
 	SDIO_FIXUP(SDIO_VENDOR_ID_STE, SDIO_DEVICE_ID_STE_CW1200,
 		   add_quirk, MMC_QUIRK_BROKEN_BYTE_MODE_512),
 
+	SDIO_FIXUP(SDIO_VENDOR_ID_MARVELL, SDIO_DEVICE_ID_MARVELL_8797_F0,
+		   add_quirk, MMC_QUIRK_BROKEN_IRQ_POLLING),
+
 	END_FIXUP
 };
 
@@ -89,3 +99,14 @@ void mmc_fixup_device(struct mmc_card *card, const struct mmc_fixup *table)
 	}
 }
 EXPORT_SYMBOL(mmc_fixup_device);
+
+void mmc_fixup_broken_irq_polling(struct mmc_card *card)
+{
+	unsigned char dummy;
+
+	/* A fake interrupt could be created when we poll SDIO_CCCR_INTx
+	 * register with a Marvell SD8797 card. A dummy CMD52 read to
+	 * function 0 register 0xff can aviod this.
+	 */
+	mmc_io_rw_direct(card, 0, 0, 0xff, 0, &dummy);
+}
drivers/mmc/core/sdio_irq.c +5 -0
index 3d8ceb4..afb00e1 100644
@@ -47,6 +47,11 @@ static int process_sdio_pending_irqs(struct mmc_host *host)
 	}
 
 	ret = mmc_io_rw_direct(card, 0, 0, SDIO_CCCR_INTx, 0, &pending);
+
+	if (pending && (card->quirks & MMC_QUIRK_BROKEN_IRQ_POLLING) &&
+	    !(host->caps & MMC_CAP_SDIO_IRQ))
+		mmc_fixup_broken_irq_polling(card);
+
 	if (ret) {
 		pr_debug("%s: error %d reading SDIO_CCCR_INTx\n",
 		       mmc_card_id(card), ret);
include/linux/mmc/card.h +3 -1
index 176fdf8..08a065b 100644
@@ -271,9 +271,10 @@ struct mmc_card {
 #define MMC_QUIRK_INAND_CMD38	(1<<6)		/* iNAND devices have broken CMD38 */
 #define MMC_QUIRK_BLK_NO_CMD23	(1<<7)		/* Avoid CMD23 for regular multiblock */
 #define MMC_QUIRK_BROKEN_BYTE_MODE_512 (1<<8)	/* Avoid sending 512 bytes in */
+						/* byte mode */
 #define MMC_QUIRK_LONG_READ_TIME (1<<9)		/* Data read time > CSD says */
 #define MMC_QUIRK_SEC_ERASE_TRIM_BROKEN (1<<10)	/* Skip secure for erase/trim */
-						/* byte mode */
+#define MMC_QUIRK_BROKEN_IRQ_POLLING	(1<<11)	/* Polling SDIO_CCCR_INTx could create a fake interrupt */
 
 	unsigned int		erase_size;	/* erase size in sectors */
  	unsigned int		erase_shift;	/* if erase unit is power 2 */
@@ -531,5 +532,6 @@ extern void mmc_unregister_driver(struct mmc_driver *);
 
 extern void mmc_fixup_device(struct mmc_card *card,
 			     const struct mmc_fixup *table);
+extern void mmc_fixup_broken_irq_polling(struct mmc_card *card);
 
 #endif /* LINUX_MMC_CARD_H */
Signature · 1 line
1.8.0
#1 lore raw
Quoted 57 lines · Bing Zhao

Polling SDIO_CCCR_INTx could create a fake interrupt with Marvell SD8797 card. Add a quirk to handle this case. The fixup here is to issue a dummy CMD52 read to function 0 register 0xff, and this dummy read must be right after SDIO_CCCR_INTx is read.

Patch has been verified on a dw_mmc controller (Samsung Chromebook) with MMC_CAP_SDIO_IRQ disabled.

---
 drivers/mmc/core/quirks.c   | 21 +++++++++++++++++++++
 drivers/mmc/core/sdio_irq.c |  5 +++++
 include/linux/mmc/card.h    |  4 +++-
 3 files changed, 29 insertions(+), 1 deletion(-)
drivers/mmc/core/quirks.c +11 -0
index 06ee1ae..870bcc3 100644
@@ -13,6 +13,9 @@
 #include <linux/kernel.h>
 #include <linux/export.h>
 #include <linux/mmc/card.h>
+#include <linux/mmc/sdio_ids.h>
+
+#include "sdio_ops.h"
 
 #ifndef SDIO_VENDOR_ID_TI
 #define SDIO_VENDOR_ID_TI              0x0097
@@ -30,6 +33,10 @@
 #define SDIO_DEVICE_ID_STE_CW1200      0x2280
 #endif
 
+#ifndef SDIO_DEVICE_ID_MARVELL_8797_F0
+#define SDIO_DEVICE_ID_MARVELL_8797_F0 0x9128
+#endif
+
 /*
  * This hook just adds a quirk for all sdio devices
  */
@@ -58,6 +65,9 @@ static const struct mmc_fixup mmc_fixup_methods[] = {
        SDIO_FIXUP(SDIO_VENDOR_ID_STE, SDIO_DEVICE_ID_STE_CW1200,
                   add_quirk, MMC_QUIRK_BROKEN_BYTE_MODE_512),
 
+       SDIO_FIXUP(SDIO_VENDOR_ID_MARVELL, SDIO_DEVICE_ID_MARVELL_8797_F0,
+                  add_quirk, MMC_QUIRK_BROKEN_IRQ_POLLING),
+
        END_FIXUP
 };
 
@@ -89,3 +99,14 @@ void mmc_fixup_device(struct mmc_card *card, const struct mmc_fixup *table)
        }
 }
 EXPORT_SYMBOL(mmc_fixup_device);
+

drivers/mmc/core/quirks.c void mmc_fixup_device(struct mmc_card *card, const struct mmc_fixup *table) · line 112

Quoted 10 lines
drivers/mmc/core/quirks.c +10 -0
+void mmc_fixup_broken_irq_polling(struct mmc_card *card)
+{
+       unsigned char dummy;
+
+       /* A fake interrupt could be created when we poll SDIO_CCCR_INTx
+        * register with a Marvell SD8797 card. A dummy CMD52 read to
+        * function 0 register 0xff can aviod this.
+        */
+       mmc_io_rw_direct(card, 0, 0, 0xff, 0, &dummy);
+}

I would suggest you follow how the other quirks has been implemented, thus I don't think you need a separate function just for invoking an extra mmc_io_rw_direct, do directly in sdio_irq.c instead.

drivers/mmc/core/sdio_irq.c static int process_sdio_pending_irqs(struct mmc_host *host) · line 51

Quoted 10 lines
drivers/mmc/core/sdio_irq.c +2 -0
index 3d8ceb4..afb00e1 100644
@@ -47,6 +47,11 @@ static int process_sdio_pending_irqs(struct mmc_host *host)
        }
 
        ret = mmc_io_rw_direct(card, 0, 0, SDIO_CCCR_INTx, 0, &pending);
+
+       if (pending && (card->quirks & MMC_QUIRK_BROKEN_IRQ_POLLING) &&

Suggest you add an mmc_card_broken_irq_poll(), in card.h. Like the other quirks are handled.

Quoted 30 lines
drivers/mmc/core/sdio_irq.c +3 -0
+           !(host->caps & MMC_CAP_SDIO_IRQ))
+               mmc_fixup_broken_irq_polling(card);
+
        if (ret) {
                pr_debug("%s: error %d reading SDIO_CCCR_INTx\n",
                       mmc_card_id(card), ret);
include/linux/mmc/card.h +3 -2
index 176fdf8..08a065b 100644
@@ -271,9 +271,10 @@ struct mmc_card {
 #define MMC_QUIRK_INAND_CMD38  (1<<6)          /* iNAND devices have broken CMD38 */
 #define MMC_QUIRK_BLK_NO_CMD23 (1<<7)          /* Avoid CMD23 for regular multiblock */
 #define MMC_QUIRK_BROKEN_BYTE_MODE_512 (1<<8)  /* Avoid sending 512 bytes in */
+                                               /* byte mode */
 #define MMC_QUIRK_LONG_READ_TIME (1<<9)                /* Data read time > CSD says */
 #define MMC_QUIRK_SEC_ERASE_TRIM_BROKEN (1<<10)        /* Skip secure for erase/trim */
-                                               /* byte mode */
+#define MMC_QUIRK_BROKEN_IRQ_POLLING   (1<<11) /* Polling SDIO_CCCR_INTx could create a fake interrupt */
 
        unsigned int            erase_size;     /* erase size in sectors */
        unsigned int            erase_shift;    /* if erase unit is power 2 */
@@ -531,5 +532,6 @@ extern void mmc_unregister_driver(struct mmc_driver *);
 
 extern void mmc_fixup_device(struct mmc_card *card,
                             const struct mmc_fixup *table);
+extern void mmc_fixup_broken_irq_polling(struct mmc_card *card);
 
 #endif /* LINUX_MMC_CARD_H */
--
Quoted 2 lines

1.8.0

Otherwise, looks fine!

Kind regards
Ulf Hansson

Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#2 lore raw

Hi Ulf,

Thanks for your comments.

Quoted 11 lines
Quoted 11 lines
drivers/mmc/core/quirks.c +7 -0
@@ -89,3 +99,14 @@ void mmc_fixup_device(struct mmc_card *card, const struct mmc_fixup *table)
        }
 }
 EXPORT_SYMBOL(mmc_fixup_device);
+
+void mmc_fixup_broken_irq_polling(struct mmc_card *card)
+{
+       unsigned char dummy;
+
+       /* A fake interrupt could be created when we poll SDIO_CCCR_INTx
+        * register with a Marvell SD8797 card. A dummy CMD52 read to
Quoted 8 lines

drivers/mmc/core/quirks.c void mmc_fixup_device(struct mmc_card *card, const struct mmc_fixup *table) · line 112

Quoted 4 lines
drivers/mmc/core/quirks.c +4 -0
+        * function 0 register 0xff can aviod this.
+        */
+       mmc_io_rw_direct(card, 0, 0, 0xff, 0, &dummy);
+}

I would suggest you follow how the other quirks has been implemented, thus I don't think you need a separate function just for invoking an extra mmc_io_rw_direct, do directly in sdio_irq.c instead.

Will make this change in v2.

Quoted 9 lines

drivers/mmc/core/sdio_irq.c static int process_sdio_pending_irqs(struct mmc_host *host) · line 51

Quoted 6 lines
drivers/mmc/core/sdio_irq.c +2 -0
@@ -47,6 +47,11 @@ static int process_sdio_pending_irqs(struct mmc_host *host)
        }
 
        ret = mmc_io_rw_direct(card, 0, 0, SDIO_CCCR_INTx, 0, &pending);
+
+       if (pending && (card->quirks & MMC_QUIRK_BROKEN_IRQ_POLLING) &&

Suggest you add an mmc_card_broken_irq_poll(), in card.h. Like the other quirks are handled.

Sure.

Quoted 9 lines
Quoted 9 lines
drivers/mmc/core/sdio_irq.c +3 -0
+           !(host->caps & MMC_CAP_SDIO_IRQ))
+               mmc_fixup_broken_irq_polling(card);
+
        if (ret) {
                pr_debug("%s: error %d reading SDIO_CCCR_INTx\n",
                       mmc_card_id(card), ret);
                return ret;
        }

I will also move the quirk handling down here (after the 'ret' validation).

Thanks,
Bing