linux-tegra.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Prathamesh Shete <pshete@nvidia.com>
To: <adrian.hunter@intel.com>, <ulf.hansson@linaro.org>,
	<thierry.reding@gmail.com>, <jonathanh@nvidia.com>,
	<p.zabel@pengutronix.de>, <linux-mmc@vger.kernel.org>,
	<linux-tegra@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: <anrao@nvidia.com>, <smangipudi@nvidia.com>, <pshete@nvidia.com>,
	<kyarlagadda@nvidia.com>
Subject: [PATCH v8 2/3] mmc: sdhci-tegra: Add support to program MC stream ID
Date: Fri, 14 Oct 2022 12:54:55 +0530	[thread overview]
Message-ID: <20221014072456.28953-2-pshete@nvidia.com> (raw)
In-Reply-To: <20221014072456.28953-1-pshete@nvidia.com>

SMMU clients are supposed to program stream ID from
their respective address spaces instead of MC override.
Define NVQUIRK_PROGRAM_STREAMID and use it to program
SMMU stream ID from the SDMMC client address space.

Signed-off-by: Aniruddha TVS Rao <anrao@nvidia.com>
Signed-off-by: Prathamesh Shete <pshete@nvidia.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Thierry Reding <treding@nvidia.com>
---
 drivers/mmc/host/sdhci-tegra.c | 42 ++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c
index a6c5bbae77b4..0cd7c3f7e6f4 100644
--- a/drivers/mmc/host/sdhci-tegra.c
+++ b/drivers/mmc/host/sdhci-tegra.c
@@ -25,6 +25,10 @@
 #include <linux/mmc/slot-gpio.h>
 #include <linux/gpio/consumer.h>
 #include <linux/ktime.h>
+#ifdef CONFIG_IOMMU_API
+#include <linux/iommu.h>
+#include <linux/bitops.h>
+#endif
 
 #include <soc/tegra/common.h>
 
@@ -94,6 +98,8 @@
 #define SDHCI_TEGRA_AUTO_CAL_STATUS			0x1ec
 #define SDHCI_TEGRA_AUTO_CAL_ACTIVE			BIT(31)
 
+#define SDHCI_TEGRA_CIF2AXI_CTRL_0			0x1fc
+
 #define NVQUIRK_FORCE_SDHCI_SPEC_200			BIT(0)
 #define NVQUIRK_ENABLE_BLOCK_GAP_DET			BIT(1)
 #define NVQUIRK_ENABLE_SDHCI_SPEC_300			BIT(2)
@@ -121,6 +127,7 @@
 #define NVQUIRK_HAS_TMCLK				BIT(10)
 
 #define NVQUIRK_HAS_ANDROID_GPT_SECTOR			BIT(11)
+#define NVQUIRK_PROGRAM_STREAMID			BIT(12)
 
 /* SDMMC CQE Base Address for Tegra Host Ver 4.1 and Higher */
 #define SDHCI_TEGRA_CQE_BASE_ADDR			0xF000
@@ -177,6 +184,9 @@ struct sdhci_tegra {
 	bool enable_hwcq;
 	unsigned long curr_clk_rate;
 	u8 tuned_tap_delay;
+#ifdef CONFIG_IOMMU_API
+	u32 streamid;
+#endif
 };
 
 static u16 tegra_sdhci_readw(struct sdhci_host *host, int reg)
@@ -1564,6 +1574,7 @@ static const struct sdhci_tegra_soc_data soc_data_tegra234 = {
 		    NVQUIRK_DIS_CARD_CLK_CONFIG_TAP |
 		    NVQUIRK_ENABLE_SDR50 |
 		    NVQUIRK_ENABLE_SDR104 |
+		    NVQUIRK_PROGRAM_STREAMID |
 		    NVQUIRK_HAS_TMCLK,
 	.min_tap_delay = 95,
 	.max_tap_delay = 111,
@@ -1630,6 +1641,33 @@ static int sdhci_tegra_add_host(struct sdhci_host *host)
 	return ret;
 }
 
+/* Program MC streamID for DMA transfers */
+#ifdef CONFIG_IOMMU_API
+static void program_stream_id(struct device *dev)
+{
+	struct sdhci_host *host = dev_get_drvdata(dev);
+	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+	struct sdhci_tegra *tegra_host = sdhci_pltfm_priv(pltfm_host);
+	struct iommu_fwspec *fwspec;
+
+	if (tegra_host->soc_data->nvquirks & NVQUIRK_PROGRAM_STREAMID) {
+		fwspec = dev_iommu_fwspec_get(dev);
+		if (!fwspec) {
+			dev_warn(mmc_dev(host->mmc),
+				"iommu fwspec is NULL, continue without stream ID\n");
+		} else {
+			tegra_host->streamid = fwspec->ids[0] & 0xff;
+			tegra_sdhci_writel(host, tegra_host->streamid |
+						FIELD_PREP(GENMASK(15, 8),
+						tegra_host->streamid),
+						SDHCI_TEGRA_CIF2AXI_CTRL_0);
+		}
+	}
+}
+#else
+static void program_stream_id(struct device *dev) { }
+#endif
+
 static int sdhci_tegra_probe(struct platform_device *pdev)
 {
 	const struct sdhci_tegra_soc_data *soc_data;
@@ -1775,6 +1813,8 @@ static int sdhci_tegra_probe(struct platform_device *pdev)
 	if (rc)
 		goto err_add_host;
 
+	program_stream_id(&pdev->dev);
+
 	return 0;
 
 err_add_host:
@@ -1871,6 +1911,8 @@ static int sdhci_tegra_resume(struct device *dev)
 	if (ret)
 		return ret;
 
+	program_stream_id(dev);
+
 	ret = sdhci_resume_host(host);
 	if (ret)
 		goto disable_clk;
-- 
2.17.1


  reply	other threads:[~2022-10-14  7:25 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-26  9:49 [PATCH v3 1/4] mmc: sdhci-tegra: Separate Tegra194 and Tegra234 SoC data Prathamesh Shete
2022-09-26  9:49 ` [PATCH v3 2/4] mmc: sdhci-tegra: Add support to program MC stream ID Prathamesh Shete
2022-09-26  9:49 ` [PATCH v3 3/4] mmc: sdhci-tegra: Issue CMD and DAT resets together Prathamesh Shete
2022-09-26 19:26   ` Adrian Hunter
2022-09-27 10:09     ` [PATCH v4 1/4] mmc: sdhci-tegra: Separate Tegra194 and Tegra234 SoC data Prathamesh Shete
2022-09-27 10:09       ` [PATCH v4 2/4] mmc: sdhci-tegra: Add support to program MC stream ID Prathamesh Shete
2022-09-27 10:09       ` [PATCH v4 3/4] mmc: sdhci-tegra: Issue CMD and DAT resets together Prathamesh Shete
2022-09-27 10:23         ` Adrian Hunter
2022-09-27 11:13           ` [PATCH v5 1/3] mmc: sdhci-tegra: Separate Tegra194 and Tegra234 SoC data Prathamesh Shete
2022-09-27 11:13             ` [PATCH v5 2/3] mmc: sdhci-tegra: Add support to program MC stream ID Prathamesh Shete
2022-09-27 12:45               ` Adrian Hunter
2022-09-28 12:56                 ` [PATCH v6 1/4] mmc: sdhci-tegra: Separate Tegra194 and Tegra234 SoC data Prathamesh Shete
2022-09-28 12:56                   ` [PATCH v6 2/4] mmc: sdhci-tegra: Add support to program MC stream ID Prathamesh Shete
2022-09-28 14:18                     ` Adrian Hunter
2022-10-06 10:52                       ` Thierry Reding
2022-10-06 13:06                         ` [PATCH v7 1/4] mmc: sdhci-tegra: Separate Tegra194 and Tegra234 SoC data Prathamesh Shete
2022-10-06 13:06                           ` [PATCH v7 2/4] mmc: sdhci-tegra: Add support to program MC stream ID Prathamesh Shete
2022-10-11  9:58                             ` Ulf Hansson
2022-10-11 11:44                               ` Prathamesh Shete
2022-10-11 12:33                                 ` Ulf Hansson
2022-10-13  6:33                                   ` Prathamesh Shete
2022-10-13 13:43                                     ` Ulf Hansson
2022-10-14  7:24                                       ` [PATCH v8 1/3] mmc: sdhci-tegra: Separate Tegra194 and Tegra234 SoC data Prathamesh Shete
2022-10-14  7:24                                         ` Prathamesh Shete [this message]
2022-10-14 13:38                                           ` [PATCH v8 2/3] mmc: sdhci-tegra: Add support to program MC stream ID Ulf Hansson
2022-10-14  7:24                                         ` [PATCH v8 3/3] mmc: sdhci-tegra: Issue CMD and DAT resets together Prathamesh Shete
2022-10-14  7:28                                           ` Prathamesh Shete
2022-10-17 14:11                                       ` [PATCH v7 2/4] mmc: sdhci-tegra: Add support to program MC stream ID Thierry Reding
2022-10-18 10:10                                         ` Ulf Hansson
2022-10-06 13:06                           ` [PATCH v7 3/4] mmc: sdhci-tegra: Issue CMD and DAT resets together Prathamesh Shete
2022-10-06 13:06                           ` [PATCH v7 4/4] mmc: sdhci-tegra: Use actual clock rate for SW tuning correction Prathamesh Shete
2022-10-07  9:04                             ` Ulf Hansson
2022-09-28 12:56                   ` [PATCH v6 3/4] mmc: sdhci-tegra: Issue CMD and DAT resets together Prathamesh Shete
2022-09-28 12:56                   ` [PATCH v6 4/4] mmc: sdhci-tegra: Use actual clock rate for SW tuning correction Prathamesh Shete
2022-09-27 11:13             ` [PATCH v5 3/3] mmc: sdhci-tegra: Issue CMD and DAT resets together Prathamesh Shete
2022-09-27 12:49               ` Adrian Hunter
2022-09-27 11:13             ` [PATCH v5 4/4] mmc: sdhci-tegra: Use actual clock rate for SW tuning correction Prathamesh Shete
2022-09-27 10:09       ` [PATCH v4 " Prathamesh Shete
2022-09-26  9:49 ` [PATCH v3 " Prathamesh Shete

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221014072456.28953-2-pshete@nvidia.com \
    --to=pshete@nvidia.com \
    --cc=adrian.hunter@intel.com \
    --cc=anrao@nvidia.com \
    --cc=jonathanh@nvidia.com \
    --cc=kyarlagadda@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=smangipudi@nvidia.com \
    --cc=thierry.reding@gmail.com \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).