Skip to contentSkip to conversation

mmc: cmdq: support for command queue enabled host

PATCH In review Asutosh Das 2 participants 2 messages Dec 2, 2014 – Dec 9, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 4/5 mmc: cmdq: support for command queue enabled host

This patch adds CMDQ support for command-queue compatible hosts.

Command-queue is added in eMMC-5.1 specification. This enables the controller to process upto 32 requests at a time.

---
 drivers/mmc/host/Kconfig     |  13 +
 drivers/mmc/host/Makefile    |   1 +
 drivers/mmc/host/cmdq_hci.c  | 663 +++++++++++++++++++++++++++++++++++++++++++
 include/linux/mmc/cmdq_hci.h | 171 +++++++++++
 4 files changed, 848 insertions(+)
 create mode 100644 drivers/mmc/host/cmdq_hci.c
 create mode 100644 include/linux/mmc/cmdq_hci.h
drivers/mmc/host/Kconfig +13 -0
index 779368b..87c3c20 100644
@@ -708,3 +708,16 @@ config MMC_SUNXI
 	help
 	  This selects support for the SD/MMC Host Controller on
 	  Allwinner sunxi SoCs.
+
+config MMC_CQ_HCI
+	tristate "Command Queue Support"
+	depends on HAS_DMA
+	help
+	  This selects the Command Queue Host Controller Interface (CQHCI)
+	  support present in host controllers of Qualcomm Technologies, Inc
+	  amongst others.
+	  This controller supports eMMC devices with command queue support.
+
+	  If you have a controller with this interface, say Y or M here.
+
+	  If unsure, say N.
drivers/mmc/host/Makefile +1 -0
index 61cbc24..5a23f9e 100644
@@ -66,6 +66,7 @@ obj-$(CONFIG_MMC_SDHCI_OF_HLWD)		+= sdhci-of-hlwd.o
 obj-$(CONFIG_MMC_SDHCI_BCM_KONA)	+= sdhci-bcm-kona.o
 obj-$(CONFIG_MMC_SDHCI_BCM2835)		+= sdhci-bcm2835.o
 obj-$(CONFIG_MMC_SDHCI_MSM)		+= sdhci-msm.o
+obj-$(CONFIG_MMC_CQ_HCI)		+= cmdq_hci.o
 
 ifeq ($(CONFIG_CB710_DEBUG),y)
 	CFLAGS-cb710-mmc	+= -DDEBUG
drivers/mmc/host/cmdq_hci.c new file +663 -0

663 lines not on this page · raw message

include/linux/mmc/cmdq_hci.h new file +171 -0

171 lines not on this page · raw message

Signature · 4 lines
1.8.2.1

The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#1 lore raw

Hi Asutosh,

drivers/mmc/host/cmdq_hci.c line 549

Quoted 11 lines · Asutosh Das <asutoshd <at> codeaurora.org> writes:
drivers/mmc/host/cmdq_hci.c new file +11 -0
+	} else if (status & CQIS_TCC) {
+		/* read QCTCN and complete the request */
+		comp_status = cmdq_readl(cq_host, CQTCN);
+		if (!comp_status) {
+			pr_err("%s: bogus comp-stat\n", __func__);
+			cmdq_dumpregs(cq_host);
+			WARN_ON(1);
+		}
+		for_each_set_bit(tag, &comp_status, cq_host->num_slots) {
+			/* complete the corresponding mrq */
+			cmdq_finish_data(mmc, tag);

According to eMMC 5.1 spec: CQE shall set bit n of QCTCN when a task execution is completed (with success or error).

Assume an error and an data completion both occur at the same time, then two bits of CQTCN register will be set. One bit presents the completion. The other one indicates the error slot.

Based on your implementation, host will handle the error with cmdq_finish_data. Later, mrq->data->error/mrq->cmd->error are used to check error status. However, there is no cmdq code to set those two error flags.
They are supposed to be setup in legacy eMMC irq handling, which is replaced by your cmdq irq handling. Thus actually host will receive the error request with no error flag. As a result, host will treat the error request as a successful one.

Thus there will be no error handling. Or the error handling will be executed after the error request has been finished as a successful completion.

drivers/mmc/host/cmdq_hci.c line 557

Quoted 8 lines
drivers/mmc/host/cmdq_hci.c new file +8 -0
+			/* complete DCMD on tag 31 */
+		}
+		cmdq_writel(cq_host, comp_status, CQTCN);
+	} else if (status & CQIS_RED) {
+		/* task response has an error */
+		pr_err("%s: RED error %d !!!\n", mmc_hostname(mmc), status);
+		cmdq_dumpregs(cq_host);
+		BUG_ON(1);

Please check my comments.
Thank you.

Best regards,
Hu Ziji