linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V4 0/4] HW Command Queue support for Tegra SDMMC
@ 2018-12-19 23:42 Sowjanya Komatineni
  2018-12-19 23:42 ` [PATCH V4 1/4] mmc: sdhci: Fix sdhci_do_enable_v4_mode Sowjanya Komatineni
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Sowjanya Komatineni @ 2018-12-19 23:42 UTC (permalink / raw)
  To: robh+dt, mark.rutland, mperttunen, thierry.reding, jonathanh,
	adrian.hunter, ulf.hansson
  Cc: devicetree, linux-tegra, linux-kernel, linux-mmc, Sowjanya Komatineni

This patch series is for HW Command Queue support for Tegra SDMMC.

Patch[4] adds HW Command Queue support for Tegra SDMMC and has
dependencies on other patches in this series as explained below.

Patch[3] SDMMC address range:
This patch defines exact register space for all the SDMMC
Controllers. Controllers supporting command queue are having
CQHCI register space from offset 0xF000.
Patch[4] uses address range of sdmmc controllers to identify command
queue supported controllers

Patch[2] DMA Configuration prior to CQE:
As per eMMC5.1 Spec Section 6.6.39.1, Block size should be set to 512 B
before enabling command queue.
Tegra SDHCI Host design strictly follows this and prevents write access
to SDHCI_BLOCK_SIZE when CQE is set in CQHCI_CFG and results in access
failure and crashes for any write access to SDHCI_BLOCK_SIZE while CQE
is set.

Patch[1] Fix V4 Mode enable:
V4 Mode need to be enabled to select Host Version 4.0 mode for HW Command
queue support with Tegra SDHCI.

Sowjanya Komatineni (4):
  mmc: sdhci: Fix sdhci_do_enable_v4_mode
  mmc: cqhci: DMA Configuration prior to CQE
  arm64: dtsi: Fix SDMMC address range
  mmc: tegra: HW Command Queue Support for Tegra SDMMC

 arch/arm64/boot/dts/nvidia/tegra186.dtsi |  6 +--
 arch/arm64/boot/dts/nvidia/tegra194.dtsi |  4 +-
 drivers/mmc/host/Kconfig                 |  1 +
 drivers/mmc/host/cqhci.c                 | 18 +++++--
 drivers/mmc/host/sdhci-tegra.c           | 89 +++++++++++++++++++++++++++++++-
 drivers/mmc/host/sdhci.c                 |  7 +--
 6 files changed, 113 insertions(+), 12 deletions(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH V4 1/4] mmc: sdhci: Fix sdhci_do_enable_v4_mode
  2018-12-19 23:42 [PATCH V4 0/4] HW Command Queue support for Tegra SDMMC Sowjanya Komatineni
@ 2018-12-19 23:42 ` Sowjanya Komatineni
  2018-12-19 23:42 ` [PATCH V4 2/4] mmc: cqhci: DMA Configuration prior to CQE Sowjanya Komatineni
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Sowjanya Komatineni @ 2018-12-19 23:42 UTC (permalink / raw)
  To: robh+dt, mark.rutland, mperttunen, thierry.reding, jonathanh,
	adrian.hunter, ulf.hansson
  Cc: devicetree, linux-tegra, linux-kernel, linux-mmc, Sowjanya Komatineni

V4_MODE is Bit-15 of SDHCI_HOST_CONTROL2 register.
Need to perform word access to this register.

Signed-off-by: Sowjanya Komatineni <skomatineni@nvidia.com>
---
 drivers/mmc/host/sdhci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 99bdae53fa2e..fde984d10619 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -127,12 +127,12 @@ static void sdhci_do_enable_v4_mode(struct sdhci_host *host)
 {
 	u16 ctrl2;
 
-	ctrl2 = sdhci_readb(host, SDHCI_HOST_CONTROL2);
+	ctrl2 = sdhci_readw(host, SDHCI_HOST_CONTROL2);
 	if (ctrl2 & SDHCI_CTRL_V4_MODE)
 		return;
 
 	ctrl2 |= SDHCI_CTRL_V4_MODE;
-	sdhci_writeb(host, ctrl2, SDHCI_HOST_CONTROL);
+	sdhci_writew(host, ctrl2, SDHCI_HOST_CONTROL2);
 }
 
 /*
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH V4 2/4] mmc: cqhci: DMA Configuration prior to CQE
  2018-12-19 23:42 [PATCH V4 0/4] HW Command Queue support for Tegra SDMMC Sowjanya Komatineni
  2018-12-19 23:42 ` [PATCH V4 1/4] mmc: sdhci: Fix sdhci_do_enable_v4_mode Sowjanya Komatineni
@ 2018-12-19 23:42 ` Sowjanya Komatineni
  2018-12-20 12:37   ` Adrian Hunter
  2018-12-19 23:42 ` [PATCH V4 3/4] arm64: dtsi: Fix SDMMC address range Sowjanya Komatineni
  2018-12-19 23:42 ` [PATCH V4 4/4] mmc: tegra: HW Command Queue Support for Tegra SDMMC Sowjanya Komatineni
  3 siblings, 1 reply; 8+ messages in thread
From: Sowjanya Komatineni @ 2018-12-19 23:42 UTC (permalink / raw)
  To: robh+dt, mark.rutland, mperttunen, thierry.reding, jonathanh,
	adrian.hunter, ulf.hansson
  Cc: devicetree, linux-tegra, linux-kernel, linux-mmc, Sowjanya Komatineni

eMMC-5.1 JESD84-B51 Spec (Section 6.6.39.1), mentions "Prior to
enabling command queuing, the block size shall be set to 512 B.
Device may respond with an error to CMD46/CMD47 if block size
is not 512 B".

This patch fixes the sequence to follow exact as per the spec.

Signed-off-by: Sowjanya Komatineni <skomatineni@nvidia.com>
---
 drivers/mmc/host/cqhci.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/cqhci.c b/drivers/mmc/host/cqhci.c
index 159270e947cf..f701342e7212 100644
--- a/drivers/mmc/host/cqhci.c
+++ b/drivers/mmc/host/cqhci.c
@@ -248,6 +248,9 @@ static void __cqhci_enable(struct cqhci_host *cq_host)
 		cqhci_writel(cq_host, cqcfg, CQHCI_CFG);
 	}
 
+	if (cq_host->ops->enable)
+		cq_host->ops->enable(mmc);
+
 	cqcfg &= ~(CQHCI_DCMD | CQHCI_TASK_DESC_SZ);
 
 	if (mmc->caps2 & MMC_CAP2_CQE_DCMD)
@@ -273,9 +276,6 @@ static void __cqhci_enable(struct cqhci_host *cq_host)
 
 	mmc->cqe_on = true;
 
-	if (cq_host->ops->enable)
-		cq_host->ops->enable(mmc);
-
 	/* Ensure all writes are done before interrupts are enabled */
 	wmb();
 
@@ -561,6 +561,7 @@ static int cqhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
 	int tag = cqhci_tag(mrq);
 	struct cqhci_host *cq_host = mmc->cqe_private;
 	unsigned long flags;
+	u32 cqcfg = 0;
 
 	if (!cq_host->enabled) {
 		pr_err("%s: cqhci: not enabled\n", mmc_hostname(mmc));
@@ -579,8 +580,19 @@ static int cqhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
 			pr_err("%s: cqhci: CQE failed to exit halt state\n",
 			       mmc_hostname(mmc));
 		}
+		/* Configuration must not be changed while enabled */
+		cqcfg = cqhci_readl(cq_host, CQHCI_CFG);
+		if (cqcfg & CQHCI_ENABLE) {
+			cqcfg &= ~CQHCI_ENABLE;
+			cqhci_writel(cq_host, cqcfg, CQHCI_CFG);
+		}
+
 		if (cq_host->ops->enable)
 			cq_host->ops->enable(mmc);
+
+		cqcfg |= CQHCI_ENABLE;
+		cqhci_writel(cq_host, cqcfg, CQHCI_CFG);
+
 	}
 
 	if (mrq->data) {
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH V4 3/4] arm64: dtsi: Fix SDMMC address range
  2018-12-19 23:42 [PATCH V4 0/4] HW Command Queue support for Tegra SDMMC Sowjanya Komatineni
  2018-12-19 23:42 ` [PATCH V4 1/4] mmc: sdhci: Fix sdhci_do_enable_v4_mode Sowjanya Komatineni
  2018-12-19 23:42 ` [PATCH V4 2/4] mmc: cqhci: DMA Configuration prior to CQE Sowjanya Komatineni
@ 2018-12-19 23:42 ` Sowjanya Komatineni
  2018-12-19 23:42 ` [PATCH V4 4/4] mmc: tegra: HW Command Queue Support for Tegra SDMMC Sowjanya Komatineni
  3 siblings, 0 replies; 8+ messages in thread
From: Sowjanya Komatineni @ 2018-12-19 23:42 UTC (permalink / raw)
  To: robh+dt, mark.rutland, mperttunen, thierry.reding, jonathanh,
	adrian.hunter, ulf.hansson
  Cc: devicetree, linux-tegra, linux-kernel, linux-mmc, Sowjanya Komatineni

This patch fixes the SDMMC Controllers address space to be exact
defined register address range as per the design.

SDMMC Controller supporting Command Queue has CQHCI registers at
offset 0xF000.

This fix helps to identify the Tegra SDMMC Controllers supporting
Command Queue based on the size of address space.

Signed-off-by: Sowjanya Komatineni <skomatineni@nvidia.com>
---
 arch/arm64/boot/dts/nvidia/tegra186.dtsi | 6 +++---
 arch/arm64/boot/dts/nvidia/tegra194.dtsi | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/arm64/boot/dts/nvidia/tegra186.dtsi b/arch/arm64/boot/dts/nvidia/tegra186.dtsi
index 2f3c8e29520d..6fda3d6a7f3d 100644
--- a/arch/arm64/boot/dts/nvidia/tegra186.dtsi
+++ b/arch/arm64/boot/dts/nvidia/tegra186.dtsi
@@ -231,7 +231,7 @@
 
 	sdmmc1: sdhci@3400000 {
 		compatible = "nvidia,tegra186-sdhci";
-		reg = <0x0 0x03400000 0x0 0x10000>;
+		reg = <0x0 0x03400000 0x0 0x220>;
 		interrupts = <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>;
 		clocks = <&bpmp TEGRA186_CLK_SDMMC1>;
 		clock-names = "sdhci";
@@ -256,7 +256,7 @@
 
 	sdmmc2: sdhci@3420000 {
 		compatible = "nvidia,tegra186-sdhci";
-		reg = <0x0 0x03420000 0x0 0x10000>;
+		reg = <0x0 0x03420000 0x0 0x220>;
 		interrupts = <GIC_SPI 63 IRQ_TYPE_LEVEL_HIGH>;
 		clocks = <&bpmp TEGRA186_CLK_SDMMC2>;
 		clock-names = "sdhci";
@@ -276,7 +276,7 @@
 
 	sdmmc3: sdhci@3440000 {
 		compatible = "nvidia,tegra186-sdhci";
-		reg = <0x0 0x03440000 0x0 0x10000>;
+		reg = <0x0 0x03440000 0x0 0x220>;
 		interrupts = <GIC_SPI 64 IRQ_TYPE_LEVEL_HIGH>;
 		clocks = <&bpmp TEGRA186_CLK_SDMMC3>;
 		clock-names = "sdhci";
diff --git a/arch/arm64/boot/dts/nvidia/tegra194.dtsi b/arch/arm64/boot/dts/nvidia/tegra194.dtsi
index c2091bb16546..6510ef6492b1 100644
--- a/arch/arm64/boot/dts/nvidia/tegra194.dtsi
+++ b/arch/arm64/boot/dts/nvidia/tegra194.dtsi
@@ -295,7 +295,7 @@
 
 		sdmmc1: sdhci@3400000 {
 			compatible = "nvidia,tegra194-sdhci", "nvidia,tegra186-sdhci";
-			reg = <0x03400000 0x10000>;
+			reg = <0x03400000 0x220>;
 			interrupts = <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>;
 			clocks = <&bpmp TEGRA194_CLK_SDMMC1>;
 			clock-names = "sdhci";
@@ -306,7 +306,7 @@
 
 		sdmmc3: sdhci@3440000 {
 			compatible = "nvidia,tegra194-sdhci", "nvidia,tegra186-sdhci";
-			reg = <0x03440000 0x10000>;
+			reg = <0x03440000 0x220>;
 			interrupts = <GIC_SPI 64 IRQ_TYPE_LEVEL_HIGH>;
 			clocks = <&bpmp TEGRA194_CLK_SDMMC3>;
 			clock-names = "sdhci";
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH V4 4/4] mmc: tegra: HW Command Queue Support for Tegra SDMMC
  2018-12-19 23:42 [PATCH V4 0/4] HW Command Queue support for Tegra SDMMC Sowjanya Komatineni
                   ` (2 preceding siblings ...)
  2018-12-19 23:42 ` [PATCH V4 3/4] arm64: dtsi: Fix SDMMC address range Sowjanya Komatineni
@ 2018-12-19 23:42 ` Sowjanya Komatineni
  3 siblings, 0 replies; 8+ messages in thread
From: Sowjanya Komatineni @ 2018-12-19 23:42 UTC (permalink / raw)
  To: robh+dt, mark.rutland, mperttunen, thierry.reding, jonathanh,
	adrian.hunter, ulf.hansson
  Cc: devicetree, linux-tegra, linux-kernel, linux-mmc, Sowjanya Komatineni

This patch adds HW Command Queue for supported Tegra SDMMC
controllers.

Tegra SDHCI with Quirk SDHCI_QUIRK2_BROKEN_64_BIT_DMA disables the
use of 64_BIT DMA to disable 64-bit addressing mode access to the
system memory and sdhci_cqe_enable using flag SDHCI_USE_64_BIT_DMA
for ADMA32/ADMA2 Vs ADMA64/ADMA3 DMA selection.

CQE need to use ADMA3 as it need to fetch task descriptor along
with transfer descriptor, so this patch forces DMA Select to be
ADMA3 for CQE.

Signed-off-by: Sowjanya Komatineni <skomatineni@nvidia.com>
---
 drivers/mmc/host/Kconfig       |  1 +
 drivers/mmc/host/sdhci-tegra.c | 89 +++++++++++++++++++++++++++++++++++++++++-
 drivers/mmc/host/sdhci.c       |  3 +-
 3 files changed, 91 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
index 1b58739d9744..5aa2de2c7609 100644
--- a/drivers/mmc/host/Kconfig
+++ b/drivers/mmc/host/Kconfig
@@ -250,6 +250,7 @@ config MMC_SDHCI_TEGRA
 	depends on ARCH_TEGRA
 	depends on MMC_SDHCI_PLTFM
 	select MMC_SDHCI_IO_ACCESSORS
+	select MMC_CQHCI
 	help
 	  This selects the Tegra SD/MMC controller. If you have a Tegra
 	  platform with SD or MMC devices, say Y or M here.
diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c
index 7b95d088fdef..ba8bd72ec59a 100644
--- a/drivers/mmc/host/sdhci-tegra.c
+++ b/drivers/mmc/host/sdhci-tegra.c
@@ -33,6 +33,7 @@
 #include <linux/ktime.h>
 
 #include "sdhci-pltfm.h"
+#include "cqhci.h"
 
 /* Tegra SDHOST controller vendor register definitions */
 #define SDHCI_TEGRA_VENDOR_CLOCK_CTRL			0x100
@@ -89,6 +90,10 @@
 #define NVQUIRK_NEEDS_PAD_CONTROL			BIT(7)
 #define NVQUIRK_DIS_CARD_CLK_CONFIG_TAP			BIT(8)
 
+/* SDMMC CQE Base Address for Tegra Host Ver 4.1 and Higher */
+#define SDHCI_TEGRA_CQE_BASE_ADDR			0xF000
+
+
 struct sdhci_tegra_soc_data {
 	const struct sdhci_pltfm_data *pdata;
 	u32 nvquirks;
@@ -128,6 +133,7 @@ struct sdhci_tegra {
 	u32 default_tap;
 	u32 default_trim;
 	u32 dqs_trim;
+	bool enable_hwcq;
 };
 
 static u16 tegra_sdhci_readw(struct sdhci_host *host, int reg)
@@ -836,6 +842,30 @@ static void tegra_sdhci_voltage_switch(struct sdhci_host *host)
 		tegra_host->pad_calib_required = true;
 }
 
+static void sdhci_tegra_dumpregs(struct mmc_host *mmc)
+{
+	sdhci_dumpregs(mmc_priv(mmc));
+}
+
+static u32 sdhci_tegra_cqhci_irq(struct sdhci_host *host, u32 intmask)
+{
+	int cmd_error = 0;
+	int data_error = 0;
+
+	if (!sdhci_cqe_irq(host, intmask, &cmd_error, &data_error))
+		return intmask;
+
+	cqhci_irq(host->mmc, intmask, cmd_error, data_error);
+
+	return 0;
+}
+
+static const struct cqhci_host_ops sdhci_tegra_cqhci_ops = {
+	.enable	= sdhci_cqe_enable,
+	.disable = sdhci_cqe_disable,
+	.dumpregs = sdhci_tegra_dumpregs,
+};
+
 static const struct sdhci_ops tegra_sdhci_ops = {
 	.get_ro     = tegra_sdhci_get_ro,
 	.read_w     = tegra_sdhci_readw,
@@ -989,6 +1019,7 @@ static const struct sdhci_ops tegra186_sdhci_ops = {
 	.set_uhs_signaling = tegra_sdhci_set_uhs_signaling,
 	.voltage_switch = tegra_sdhci_voltage_switch,
 	.get_max_clock = tegra_sdhci_get_max_clock,
+	.irq = sdhci_tegra_cqhci_irq,
 };
 
 static const struct sdhci_pltfm_data sdhci_tegra186_pdata = {
@@ -1030,6 +1061,55 @@ static const struct of_device_id sdhci_tegra_dt_match[] = {
 };
 MODULE_DEVICE_TABLE(of, sdhci_tegra_dt_match);
 
+static int sdhci_tegra_add_host(struct sdhci_host *host)
+{
+	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+	struct sdhci_tegra *tegra_host = sdhci_pltfm_priv(pltfm_host);
+	struct cqhci_host *cq_host;
+	bool dma64;
+	int ret;
+
+	if (!tegra_host->enable_hwcq)
+		return sdhci_add_host(host);
+
+	host->v4_mode = true;
+
+	ret = sdhci_setup_host(host);
+	if (ret)
+		return ret;
+
+	host->mmc->caps2 |= MMC_CAP2_CQE | MMC_CAP2_CQE_DCMD;
+
+	cq_host = devm_kzalloc(host->mmc->parent,
+				sizeof(*cq_host), GFP_KERNEL);
+	if (!cq_host) {
+		ret = -ENOMEM;
+		goto cleanup;
+	}
+
+	cq_host->mmio = host->ioaddr + SDHCI_TEGRA_CQE_BASE_ADDR;
+	cq_host->ops = &sdhci_tegra_cqhci_ops;
+
+	dma64 = host->flags & SDHCI_USE_64_BIT_DMA;
+	if (dma64)
+		cq_host->caps |= CQHCI_TASK_DESC_SZ_128;
+
+	ret = cqhci_init(cq_host, host->mmc, dma64);
+	if (ret)
+		goto cleanup;
+
+	ret = __sdhci_add_host(host);
+	if (ret)
+		goto cleanup;
+
+	return 0;
+
+cleanup:
+	sdhci_cleanup_host(host);
+	return ret;
+
+}
+
 static int sdhci_tegra_probe(struct platform_device *pdev)
 {
 	const struct of_device_id *match;
@@ -1039,6 +1119,7 @@ static int sdhci_tegra_probe(struct platform_device *pdev)
 	struct sdhci_tegra *tegra_host;
 	struct clk *clk;
 	int rc;
+	struct resource *iomem;
 
 	match = of_match_device(sdhci_tegra_dt_match, &pdev->dev);
 	if (!match)
@@ -1056,6 +1137,12 @@ static int sdhci_tegra_probe(struct platform_device *pdev)
 	tegra_host->pad_control_available = false;
 	tegra_host->soc_data = soc_data;
 
+	iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (resource_size(iomem) > SDHCI_TEGRA_CQE_BASE_ADDR)
+		tegra_host->enable_hwcq = true;
+	else
+		tegra_host->enable_hwcq = false;
+
 	if (soc_data->nvquirks & NVQUIRK_NEEDS_PAD_CONTROL) {
 		rc = tegra_sdhci_init_pinctrl_info(&pdev->dev, tegra_host);
 		if (rc == 0)
@@ -1117,7 +1204,7 @@ static int sdhci_tegra_probe(struct platform_device *pdev)
 
 	usleep_range(2000, 4000);
 
-	rc = sdhci_add_host(host);
+	rc = sdhci_tegra_add_host(host);
 	if (rc)
 		goto err_add_host;
 
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index fde984d10619..ce3acbd35639 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -3308,7 +3308,8 @@ void sdhci_cqe_enable(struct mmc_host *mmc)
 
 	ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
 	ctrl &= ~SDHCI_CTRL_DMA_MASK;
-	if (host->flags & SDHCI_USE_64_BIT_DMA)
+	if ((host->flags & SDHCI_USE_64_BIT_DMA) ||
+			(host->quirks2 & SDHCI_QUIRK2_BROKEN_64_BIT_DMA))
 		ctrl |= SDHCI_CTRL_ADMA64;
 	else
 		ctrl |= SDHCI_CTRL_ADMA32;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH V4 2/4] mmc: cqhci: DMA Configuration prior to CQE
  2018-12-19 23:42 ` [PATCH V4 2/4] mmc: cqhci: DMA Configuration prior to CQE Sowjanya Komatineni
@ 2018-12-20 12:37   ` Adrian Hunter
  2018-12-20 21:01     ` Sowjanya Komatineni
  0 siblings, 1 reply; 8+ messages in thread
From: Adrian Hunter @ 2018-12-20 12:37 UTC (permalink / raw)
  To: Sowjanya Komatineni, robh+dt, mark.rutland, mperttunen,
	thierry.reding, jonathanh, ulf.hansson
  Cc: devicetree, linux-tegra, linux-kernel, linux-mmc

On 20/12/18 1:42 AM, Sowjanya Komatineni wrote:
> eMMC-5.1 JESD84-B51 Spec (Section 6.6.39.1), mentions "Prior to
> enabling command queuing, the block size shall be set to 512 B.
> Device may respond with an error to CMD46/CMD47 if block size
> is not 512 B".

This doesn't seem to relate to the host controller implementation.  "The
device" means the eMMC.

We don't want to disable and re-enable in the request function, so that
change is not good for controllers that don't have your problem.  Another
thing to consider is that the block size register may not need to be changed
- for example when cqhci is halted to allow a manual discard, the block size
register is not updated, so I would expect its value to be unchanged.

There are ways you can solve this in your driver.  You could look at using
SDHCI I/O accessors, and/or implement your own ->enable() instead of calling
sdhci_cqe_enable() directly.  Would that be feasible?

> 
> This patch fixes the sequence to follow exact as per the spec.
> 
> Signed-off-by: Sowjanya Komatineni <skomatineni@nvidia.com>
> ---
>  drivers/mmc/host/cqhci.c | 18 +++++++++++++++---
>  1 file changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mmc/host/cqhci.c b/drivers/mmc/host/cqhci.c
> index 159270e947cf..f701342e7212 100644
> --- a/drivers/mmc/host/cqhci.c
> +++ b/drivers/mmc/host/cqhci.c
> @@ -248,6 +248,9 @@ static void __cqhci_enable(struct cqhci_host *cq_host)
>  		cqhci_writel(cq_host, cqcfg, CQHCI_CFG);
>  	}
>  
> +	if (cq_host->ops->enable)
> +		cq_host->ops->enable(mmc);
> +
>  	cqcfg &= ~(CQHCI_DCMD | CQHCI_TASK_DESC_SZ);
>  
>  	if (mmc->caps2 & MMC_CAP2_CQE_DCMD)
> @@ -273,9 +276,6 @@ static void __cqhci_enable(struct cqhci_host *cq_host)
>  
>  	mmc->cqe_on = true;
>  
> -	if (cq_host->ops->enable)
> -		cq_host->ops->enable(mmc);
> -
>  	/* Ensure all writes are done before interrupts are enabled */
>  	wmb();
>  
> @@ -561,6 +561,7 @@ static int cqhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
>  	int tag = cqhci_tag(mrq);
>  	struct cqhci_host *cq_host = mmc->cqe_private;
>  	unsigned long flags;
> +	u32 cqcfg = 0;
>  
>  	if (!cq_host->enabled) {
>  		pr_err("%s: cqhci: not enabled\n", mmc_hostname(mmc));
> @@ -579,8 +580,19 @@ static int cqhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
>  			pr_err("%s: cqhci: CQE failed to exit halt state\n",
>  			       mmc_hostname(mmc));
>  		}
> +		/* Configuration must not be changed while enabled */
> +		cqcfg = cqhci_readl(cq_host, CQHCI_CFG);
> +		if (cqcfg & CQHCI_ENABLE) {
> +			cqcfg &= ~CQHCI_ENABLE;
> +			cqhci_writel(cq_host, cqcfg, CQHCI_CFG);
> +		}
> +
>  		if (cq_host->ops->enable)
>  			cq_host->ops->enable(mmc);
> +
> +		cqcfg |= CQHCI_ENABLE;
> +		cqhci_writel(cq_host, cqcfg, CQHCI_CFG);
> +
>  	}
>  
>  	if (mrq->data) {
> 


^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH V4 2/4] mmc: cqhci: DMA Configuration prior to CQE
  2018-12-20 12:37   ` Adrian Hunter
@ 2018-12-20 21:01     ` Sowjanya Komatineni
  2018-12-21  7:41       ` Adrian Hunter
  0 siblings, 1 reply; 8+ messages in thread
From: Sowjanya Komatineni @ 2018-12-20 21:01 UTC (permalink / raw)
  To: Adrian Hunter, robh+dt, mark.rutland, Mikko Perttunen,
	thierry.reding, Jonathan Hunter, ulf.hansson
  Cc: devicetree, linux-tegra, linux-kernel, linux-mmc

Hi Adrian,

Thank you for the feedback.

> This doesn't seem to relate to the host controller implementation.  
> "The device" means the eMMC.

Yes, setting block size of 512B before enabling command queue is a device specific 
requirement not host specific. So thought to update in cqhci driver to follow this 
device specific sequence requirement. This also serves tegra sdhci host strictly
following this device specific requirement.

> We don't want to disable and re-enable in the request function,
> so that change is not good for controllers that don't have your problem.
> Another thing to consider is that the block size register may not need to be changed
> - for example when cqhci is halted to allow a manual discard, the block size register is
> not updated, so I would expect its value to be unchanged.

Once block size is set prior to enabling CQE, it stays same till command queue is 
disabled and I don’t think it needs reconfiguration.

> There are ways you can solve this in your driver.  
> You could look at using SDHCI I/O accessors, and/or implement your own ->enable() 
> instead of calling sdhci_cqe_enable() directly.  Would that be feasible?

Sure, will provide updated patch that takes care of this inside tegra sdhci host once you 
confirm that we don’t plan to fix this device specific sequence requirement in cqhci driver.

-Sowjanya
 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH V4 2/4] mmc: cqhci: DMA Configuration prior to CQE
  2018-12-20 21:01     ` Sowjanya Komatineni
@ 2018-12-21  7:41       ` Adrian Hunter
  0 siblings, 0 replies; 8+ messages in thread
From: Adrian Hunter @ 2018-12-21  7:41 UTC (permalink / raw)
  To: Sowjanya Komatineni, robh+dt, mark.rutland, Mikko Perttunen,
	thierry.reding, Jonathan Hunter, ulf.hansson
  Cc: devicetree, linux-tegra, linux-kernel, linux-mmc

On 20/12/18 11:01 PM, Sowjanya Komatineni wrote:
> Hi Adrian,
> 
> Thank you for the feedback.
> 
>> This doesn't seem to relate to the host controller implementation.  
>> "The device" means the eMMC.
> 
> Yes, setting block size of 512B before enabling command queue is a device specific 
> requirement not host specific. So thought to update in cqhci driver to follow this 
> device specific sequence requirement. This also serves tegra sdhci host strictly
> following this device specific requirement.

Not sure what you mean.  The eMMC block size is set by CMD16.  In fact CMD16
is not used because 512B is the default so it never needs to be changed.

> 
>> We don't want to disable and re-enable in the request function,
>> so that change is not good for controllers that don't have your problem.
>> Another thing to consider is that the block size register may not need to be changed
>> - for example when cqhci is halted to allow a manual discard, the block size register is
>> not updated, so I would expect its value to be unchanged.
> 
> Once block size is set prior to enabling CQE, it stays same till command queue is 
> disabled and I don’t think it needs reconfiguration.
> 
>> There are ways you can solve this in your driver.  
>> You could look at using SDHCI I/O accessors, and/or implement your own ->enable() 
>> instead of calling sdhci_cqe_enable() directly.  Would that be feasible?
> 
> Sure, will provide updated patch that takes care of this inside tegra sdhci host once you 
> confirm that we don’t plan to fix this device specific sequence requirement in cqhci driver.
> 
> -Sowjanya
>  
> 


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-12-21  7:43 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-19 23:42 [PATCH V4 0/4] HW Command Queue support for Tegra SDMMC Sowjanya Komatineni
2018-12-19 23:42 ` [PATCH V4 1/4] mmc: sdhci: Fix sdhci_do_enable_v4_mode Sowjanya Komatineni
2018-12-19 23:42 ` [PATCH V4 2/4] mmc: cqhci: DMA Configuration prior to CQE Sowjanya Komatineni
2018-12-20 12:37   ` Adrian Hunter
2018-12-20 21:01     ` Sowjanya Komatineni
2018-12-21  7:41       ` Adrian Hunter
2018-12-19 23:42 ` [PATCH V4 3/4] arm64: dtsi: Fix SDMMC address range Sowjanya Komatineni
2018-12-19 23:42 ` [PATCH V4 4/4] mmc: tegra: HW Command Queue Support for Tegra SDMMC Sowjanya Komatineni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).