linux-tegra.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v12 0/6] mmc: sdhci: Add Tegra234 support
@ 2022-12-02 15:26 Thierry Reding
  2022-12-02 15:26 ` [PATCH v12 1/6] iommu: Add note about struct iommu_fwspec usage Thierry Reding
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Thierry Reding @ 2022-12-02 15:26 UTC (permalink / raw)
  To: Joerg Roedel, Ulf Hansson, Robin Murphy
  Cc: Adrian Hunter, Jonathan Hunter, Prathamesh Shete, Will Deacon,
	iommu, linux-mmc, linux-tegra

From: Thierry Reding <treding@nvidia.com>

Hi,

This is an updated version of v11 that I sent out a few weeks ago:

    https://lore.kernel.org/all/20221117182720.2290761-1-thierry.reding@gmail.com/

All remaining comments should now be addressed. I've left in the include
reordering and dropped the bitfield.h include that Adrian had noticed. I
also left the new helper as it was and will leave it up to Joerg and
Robin to decide if they want me to split off an extra !IOMMU_API stub.

It'd be great to see this go in for v6.2 and we're getting quite close
to the merge window now. As far as I can tell, the only remaining thing
is an Acked-by on the new Tegra-specific helper from Joerg and/or Robin
so that Ulf can pick this up.

Thanks,
Thierry

Prathamesh Shete (3):
  mmc: sdhci-tegra: Separate Tegra194 and Tegra234 SoC data
  mmc: sdhci-tegra: Add support to program MC stream ID
  mmc: sdhci-tegra: Issue CMD and DAT resets together

Thierry Reding (3):
  iommu: Add note about struct iommu_fwspec usage
  iommu/tegra: Add tegra_dev_iommu_get_stream_id() helper
  mmc: sdhci-tegra: Sort includes alphabetically

 drivers/mmc/host/sdhci-tegra.c | 69 ++++++++++++++++++++++++++++------
 drivers/mmc/host/sdhci.c       |  5 +++
 drivers/mmc/host/sdhci.h       |  2 +
 include/linux/iommu.h          | 25 ++++++++++++
 4 files changed, 89 insertions(+), 12 deletions(-)

-- 
2.38.1


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

* [PATCH v12 1/6] iommu: Add note about struct iommu_fwspec usage
  2022-12-02 15:26 [PATCH v12 0/6] mmc: sdhci: Add Tegra234 support Thierry Reding
@ 2022-12-02 15:26 ` Thierry Reding
  2022-12-02 15:26 ` [PATCH v12 2/6] iommu/tegra: Add tegra_dev_iommu_get_stream_id() helper Thierry Reding
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Thierry Reding @ 2022-12-02 15:26 UTC (permalink / raw)
  To: Joerg Roedel, Ulf Hansson, Robin Murphy
  Cc: Adrian Hunter, Jonathan Hunter, Prathamesh Shete, Will Deacon,
	iommu, linux-mmc, linux-tegra, Joerg Roedel

From: Thierry Reding <treding@nvidia.com>

This structure is to be considered private to the IOMMU API. Except for
very few exceptions, IOMMU consumer drivers should treat this as opaque
data.

Acked-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 include/linux/iommu.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index 1690c334e516..dc5e6f5c14fc 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -641,6 +641,10 @@ struct iommu_group *fsl_mc_device_group(struct device *dev);
  * @flags: IOMMU_FWSPEC_* flags
  * @num_ids: number of associated device IDs
  * @ids: IDs which this device may present to the IOMMU
+ *
+ * Note that the IDs (and any other information, really) stored in this structure should be
+ * considered private to the IOMMU device driver and are not to be used directly by IOMMU
+ * consumers.
  */
 struct iommu_fwspec {
 	const struct iommu_ops	*ops;
-- 
2.38.1


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

* [PATCH v12 2/6] iommu/tegra: Add tegra_dev_iommu_get_stream_id() helper
  2022-12-02 15:26 [PATCH v12 0/6] mmc: sdhci: Add Tegra234 support Thierry Reding
  2022-12-02 15:26 ` [PATCH v12 1/6] iommu: Add note about struct iommu_fwspec usage Thierry Reding
@ 2022-12-02 15:26 ` Thierry Reding
  2022-12-05 19:03   ` Robin Murphy
  2022-12-02 15:26 ` [PATCH v12 3/6] mmc: sdhci-tegra: Sort includes alphabetically Thierry Reding
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 9+ messages in thread
From: Thierry Reding @ 2022-12-02 15:26 UTC (permalink / raw)
  To: Joerg Roedel, Ulf Hansson, Robin Murphy
  Cc: Adrian Hunter, Jonathan Hunter, Prathamesh Shete, Will Deacon,
	iommu, linux-mmc, linux-tegra

From: Thierry Reding <treding@nvidia.com>

Access to the internals of struct iommu_fwspec by non-IOMMU drivers is
discouraged. Many drivers for Tegra SoCs, however, need access to their
IOMMU stream IDs so that they can be programmed into various hardware
registers.

Formalize this access into a common helper to make it easier to audit
and maintain.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 include/linux/iommu.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index dc5e6f5c14fc..f0d72acad7db 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -1186,4 +1186,25 @@ static inline u32 iommu_sva_get_pasid(struct iommu_sva *handle)
 }
 #endif /* CONFIG_IOMMU_SVA */
 
+/*
+ * Newer generations of Tegra SoCs require devices' stream IDs to be directly programmed into
+ * some registers. These are always paired with a Tegra SMMU or ARM SMMU, for which the contents
+ * of the struct iommu_fwspec are known. Use this helper to formalize access to these internals.
+ */
+#define TEGRA_STREAM_ID_BYPASS 0x7f
+
+static inline bool tegra_dev_iommu_get_stream_id(struct device *dev, u32 *stream_id)
+{
+#ifdef CONFIG_IOMMU_API
+	struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
+
+	if (fwspec && fwspec->num_ids == 1) {
+		*stream_id = fwspec->ids[0] & 0xffff;
+		return true;
+	}
+#endif
+
+	return false;
+}
+
 #endif /* __LINUX_IOMMU_H */
-- 
2.38.1


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

* [PATCH v12 3/6] mmc: sdhci-tegra: Sort includes alphabetically
  2022-12-02 15:26 [PATCH v12 0/6] mmc: sdhci: Add Tegra234 support Thierry Reding
  2022-12-02 15:26 ` [PATCH v12 1/6] iommu: Add note about struct iommu_fwspec usage Thierry Reding
  2022-12-02 15:26 ` [PATCH v12 2/6] iommu/tegra: Add tegra_dev_iommu_get_stream_id() helper Thierry Reding
@ 2022-12-02 15:26 ` Thierry Reding
  2022-12-02 15:26 ` [PATCH v12 4/6] mmc: sdhci-tegra: Separate Tegra194 and Tegra234 SoC data Thierry Reding
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Thierry Reding @ 2022-12-02 15:26 UTC (permalink / raw)
  To: Joerg Roedel, Ulf Hansson, Robin Murphy
  Cc: Adrian Hunter, Jonathan Hunter, Prathamesh Shete, Will Deacon,
	iommu, linux-mmc, linux-tegra

From: Thierry Reding <treding@nvidia.com>

Sort includes alphabetically to make it easier to add new ones
subsequently.

Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/mmc/host/sdhci-tegra.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c
index 9fc8a61eca54..afa9cbf9cb6f 100644
--- a/drivers/mmc/host/sdhci-tegra.c
+++ b/drivers/mmc/host/sdhci-tegra.c
@@ -3,28 +3,28 @@
  * Copyright (C) 2010 Google, Inc.
  */
 
+#include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
 #include <linux/err.h>
-#include <linux/module.h>
+#include <linux/gpio/consumer.h>
 #include <linux/init.h>
-#include <linux/iopoll.h>
-#include <linux/platform_device.h>
-#include <linux/clk.h>
 #include <linux/io.h>
-#include <linux/of.h>
+#include <linux/iopoll.h>
+#include <linux/ktime.h>
+#include <linux/mmc/card.h>
+#include <linux/mmc/host.h>
+#include <linux/mmc/mmc.h>
+#include <linux/mmc/slot-gpio.h>
+#include <linux/module.h>
 #include <linux/of_device.h>
+#include <linux/of.h>
 #include <linux/pinctrl/consumer.h>
+#include <linux/platform_device.h>
 #include <linux/pm_opp.h>
 #include <linux/pm_runtime.h>
 #include <linux/regulator/consumer.h>
 #include <linux/reset.h>
-#include <linux/mmc/card.h>
-#include <linux/mmc/host.h>
-#include <linux/mmc/mmc.h>
-#include <linux/mmc/slot-gpio.h>
-#include <linux/gpio/consumer.h>
-#include <linux/ktime.h>
 
 #include <soc/tegra/common.h>
 
-- 
2.38.1


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

* [PATCH v12 4/6] mmc: sdhci-tegra: Separate Tegra194 and Tegra234 SoC data
  2022-12-02 15:26 [PATCH v12 0/6] mmc: sdhci: Add Tegra234 support Thierry Reding
                   ` (2 preceding siblings ...)
  2022-12-02 15:26 ` [PATCH v12 3/6] mmc: sdhci-tegra: Sort includes alphabetically Thierry Reding
@ 2022-12-02 15:26 ` Thierry Reding
  2022-12-02 15:26 ` [PATCH v12 5/6] mmc: sdhci-tegra: Add support to program MC stream ID Thierry Reding
  2022-12-02 15:26 ` [PATCH v12 6/6] mmc: sdhci-tegra: Issue CMD and DAT resets together Thierry Reding
  5 siblings, 0 replies; 9+ messages in thread
From: Thierry Reding @ 2022-12-02 15:26 UTC (permalink / raw)
  To: Joerg Roedel, Ulf Hansson, Robin Murphy
  Cc: Adrian Hunter, Jonathan Hunter, Prathamesh Shete, Will Deacon,
	iommu, linux-mmc, linux-tegra, Thierry Reding

From: Prathamesh Shete <pshete@nvidia.com>

Create new SoC data structure for Tegra234 platforms. Additional
features, tap value configurations are added/updated for Tegra234
platform hence separate Tegra194 and Tegra234 SoC data.

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>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/mmc/host/sdhci-tegra.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c
index afa9cbf9cb6f..f3f5a4abcafb 100644
--- a/drivers/mmc/host/sdhci-tegra.c
+++ b/drivers/mmc/host/sdhci-tegra.c
@@ -1553,7 +1553,21 @@ static const struct sdhci_tegra_soc_data soc_data_tegra194 = {
 	.max_tap_delay = 139,
 };
 
+static const struct sdhci_tegra_soc_data soc_data_tegra234 = {
+	.pdata = &sdhci_tegra186_pdata,
+	.dma_mask = DMA_BIT_MASK(39),
+	.nvquirks = NVQUIRK_NEEDS_PAD_CONTROL |
+		    NVQUIRK_HAS_PADCALIB |
+		    NVQUIRK_DIS_CARD_CLK_CONFIG_TAP |
+		    NVQUIRK_ENABLE_SDR50 |
+		    NVQUIRK_ENABLE_SDR104 |
+		    NVQUIRK_HAS_TMCLK,
+	.min_tap_delay = 95,
+	.max_tap_delay = 111,
+};
+
 static const struct of_device_id sdhci_tegra_dt_match[] = {
+	{ .compatible = "nvidia,tegra234-sdhci", .data = &soc_data_tegra234 },
 	{ .compatible = "nvidia,tegra194-sdhci", .data = &soc_data_tegra194 },
 	{ .compatible = "nvidia,tegra186-sdhci", .data = &soc_data_tegra186 },
 	{ .compatible = "nvidia,tegra210-sdhci", .data = &soc_data_tegra210 },
-- 
2.38.1


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

* [PATCH v12 5/6] mmc: sdhci-tegra: Add support to program MC stream ID
  2022-12-02 15:26 [PATCH v12 0/6] mmc: sdhci: Add Tegra234 support Thierry Reding
                   ` (3 preceding siblings ...)
  2022-12-02 15:26 ` [PATCH v12 4/6] mmc: sdhci-tegra: Separate Tegra194 and Tegra234 SoC data Thierry Reding
@ 2022-12-02 15:26 ` Thierry Reding
  2022-12-02 15:26 ` [PATCH v12 6/6] mmc: sdhci-tegra: Issue CMD and DAT resets together Thierry Reding
  5 siblings, 0 replies; 9+ messages in thread
From: Thierry Reding @ 2022-12-02 15:26 UTC (permalink / raw)
  To: Joerg Roedel, Ulf Hansson, Robin Murphy
  Cc: Adrian Hunter, Jonathan Hunter, Prathamesh Shete, Will Deacon,
	iommu, linux-mmc, linux-tegra, Thierry Reding

From: Prathamesh Shete <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>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/mmc/host/sdhci-tegra.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c
index f3f5a4abcafb..c17700fa9899 100644
--- a/drivers/mmc/host/sdhci-tegra.c
+++ b/drivers/mmc/host/sdhci-tegra.c
@@ -3,6 +3,7 @@
  * Copyright (C) 2010 Google, Inc.
  */
 
+#include <linux/bitops.h>
 #include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
@@ -10,6 +11,7 @@
 #include <linux/gpio/consumer.h>
 #include <linux/init.h>
 #include <linux/io.h>
+#include <linux/iommu.h>
 #include <linux/iopoll.h>
 #include <linux/ktime.h>
 #include <linux/mmc/card.h>
@@ -95,6 +97,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)
@@ -122,6 +126,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
@@ -178,6 +183,7 @@ struct sdhci_tegra {
 	bool enable_hwcq;
 	unsigned long curr_clk_rate;
 	u8 tuned_tap_delay;
+	u32 stream_id;
 };
 
 static u16 tegra_sdhci_readw(struct sdhci_host *host, int reg)
@@ -1561,6 +1567,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,
@@ -1627,6 +1634,19 @@ static int sdhci_tegra_add_host(struct sdhci_host *host)
 	return ret;
 }
 
+/* Program MC streamID for DMA transfers */
+static void sdhci_tegra_program_stream_id(struct sdhci_host *host)
+{
+	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+	struct sdhci_tegra *tegra_host = sdhci_pltfm_priv(pltfm_host);
+
+	if (tegra_host->soc_data->nvquirks & NVQUIRK_PROGRAM_STREAMID) {
+		tegra_sdhci_writel(host, FIELD_PREP(GENMASK(15, 8), tegra_host->stream_id) |
+					 FIELD_PREP(GENMASK( 7, 0), tegra_host->stream_id),
+					 SDHCI_TEGRA_CIF2AXI_CTRL_0);
+	}
+}
+
 static int sdhci_tegra_probe(struct platform_device *pdev)
 {
 	const struct sdhci_tegra_soc_data *soc_data;
@@ -1687,6 +1707,12 @@ static int sdhci_tegra_probe(struct platform_device *pdev)
 
 	tegra_sdhci_parse_dt(host);
 
+	if (tegra_host->soc_data->nvquirks & NVQUIRK_PROGRAM_STREAMID &&
+	    !tegra_dev_iommu_get_stream_id(&pdev->dev, &tegra_host->stream_id)) {
+		dev_warn(mmc_dev(host->mmc), "missing IOMMU stream ID\n");
+		tegra_host->stream_id = 0x7f;
+	}
+
 	tegra_host->power_gpio = devm_gpiod_get_optional(&pdev->dev, "power",
 							 GPIOD_OUT_HIGH);
 	if (IS_ERR(tegra_host->power_gpio)) {
@@ -1772,6 +1798,8 @@ static int sdhci_tegra_probe(struct platform_device *pdev)
 	if (rc)
 		goto err_add_host;
 
+	sdhci_tegra_program_stream_id(host);
+
 	return 0;
 
 err_add_host:
@@ -1868,6 +1896,8 @@ static int sdhci_tegra_resume(struct device *dev)
 	if (ret)
 		return ret;
 
+	sdhci_tegra_program_stream_id(host);
+
 	ret = sdhci_resume_host(host);
 	if (ret)
 		goto disable_clk;
-- 
2.38.1


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

* [PATCH v12 6/6] mmc: sdhci-tegra: Issue CMD and DAT resets together
  2022-12-02 15:26 [PATCH v12 0/6] mmc: sdhci: Add Tegra234 support Thierry Reding
                   ` (4 preceding siblings ...)
  2022-12-02 15:26 ` [PATCH v12 5/6] mmc: sdhci-tegra: Add support to program MC stream ID Thierry Reding
@ 2022-12-02 15:26 ` Thierry Reding
  5 siblings, 0 replies; 9+ messages in thread
From: Thierry Reding @ 2022-12-02 15:26 UTC (permalink / raw)
  To: Joerg Roedel, Ulf Hansson, Robin Murphy
  Cc: Adrian Hunter, Jonathan Hunter, Prathamesh Shete, Will Deacon,
	iommu, linux-mmc, linux-tegra, Thierry Reding

From: Prathamesh Shete <pshete@nvidia.com>

In case of error condition to avoid system crash Tegra SDMMC controller
requires CMD and DAT resets issued together. SDHCI controller FSM goes
into bad state due to rapid SD card hot-plug event. Issuing reset on the
CMD FSM before DATA FSM results in kernel panic, hence add support to
issue CMD and DAT resets together.

This is applicable to Tegra186 and later chips.

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>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/mmc/host/sdhci-tegra.c | 3 ++-
 drivers/mmc/host/sdhci.c       | 5 +++++
 drivers/mmc/host/sdhci.h       | 2 ++
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c
index c17700fa9899..49f60e292551 100644
--- a/drivers/mmc/host/sdhci-tegra.c
+++ b/drivers/mmc/host/sdhci-tegra.c
@@ -1528,7 +1528,8 @@ static const struct sdhci_pltfm_data sdhci_tegra186_pdata = {
 		  SDHCI_QUIRK_NO_HISPD_BIT |
 		  SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC |
 		  SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN,
-	.quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN,
+	.quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN |
+		   SDHCI_QUIRK2_ISSUE_CMD_DAT_RESET_TOGETHER,
 	.ops  = &tegra186_sdhci_ops,
 };
 
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index df1c1d10a338..81f4fed11629 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -270,6 +270,11 @@ enum sdhci_reset_reason {
 
 static void sdhci_reset_for_reason(struct sdhci_host *host, enum sdhci_reset_reason reason)
 {
+	if (host->quirks2 & SDHCI_QUIRK2_ISSUE_CMD_DAT_RESET_TOGETHER) {
+		sdhci_do_reset(host, SDHCI_RESET_CMD | SDHCI_RESET_DATA);
+		return;
+	}
+
 	switch (reason) {
 	case SDHCI_RESET_FOR_INIT:
 		sdhci_do_reset(host, SDHCI_RESET_CMD | SDHCI_RESET_DATA);
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index b6f31a7d6152..605eaee805f7 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -478,6 +478,8 @@ struct sdhci_host {
  * block count.
  */
 #define SDHCI_QUIRK2_USE_32BIT_BLK_CNT			(1<<18)
+/* Issue CMD and DATA reset together */
+#define SDHCI_QUIRK2_ISSUE_CMD_DAT_RESET_TOGETHER	(1<<19)
 
 	int irq;		/* Device IRQ */
 	void __iomem *ioaddr;	/* Mapped address */
-- 
2.38.1


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

* Re: [PATCH v12 2/6] iommu/tegra: Add tegra_dev_iommu_get_stream_id() helper
  2022-12-02 15:26 ` [PATCH v12 2/6] iommu/tegra: Add tegra_dev_iommu_get_stream_id() helper Thierry Reding
@ 2022-12-05 19:03   ` Robin Murphy
  2022-12-06 16:49     ` Thierry Reding
  0 siblings, 1 reply; 9+ messages in thread
From: Robin Murphy @ 2022-12-05 19:03 UTC (permalink / raw)
  To: Thierry Reding, Joerg Roedel, Ulf Hansson
  Cc: Adrian Hunter, Jonathan Hunter, Prathamesh Shete, Will Deacon,
	iommu, linux-mmc, linux-tegra

On 2022-12-02 15:26, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> Access to the internals of struct iommu_fwspec by non-IOMMU drivers is
> discouraged. Many drivers for Tegra SoCs, however, need access to their
> IOMMU stream IDs so that they can be programmed into various hardware
> registers.
> 
> Formalize this access into a common helper to make it easier to audit
> and maintain.

In many ways I'd be happier if this could go somewhere in 
include/soc/tegra/ rather than the generic IOMMU API header, but I see 
the argument for keeping fwspec usage close to home as well, so no 
overwhelming preference one way or the other. Mostly I'd just like to 
get something landed so that all those other drivers can be cleaned up 
as well, and I reckon this counts as good enough.

Unless Joerg has a stronger opinion,

Acked-by: Robin Murphy <robin.murphy@arm.com>

> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>   include/linux/iommu.h | 21 +++++++++++++++++++++
>   1 file changed, 21 insertions(+)
> 
> diff --git a/include/linux/iommu.h b/include/linux/iommu.h
> index dc5e6f5c14fc..f0d72acad7db 100644
> --- a/include/linux/iommu.h
> +++ b/include/linux/iommu.h
> @@ -1186,4 +1186,25 @@ static inline u32 iommu_sva_get_pasid(struct iommu_sva *handle)
>   }
>   #endif /* CONFIG_IOMMU_SVA */
>   
> +/*
> + * Newer generations of Tegra SoCs require devices' stream IDs to be directly programmed into
> + * some registers. These are always paired with a Tegra SMMU or ARM SMMU, for which the contents
> + * of the struct iommu_fwspec are known. Use this helper to formalize access to these internals.
> + */
> +#define TEGRA_STREAM_ID_BYPASS 0x7f
> +
> +static inline bool tegra_dev_iommu_get_stream_id(struct device *dev, u32 *stream_id)
> +{
> +#ifdef CONFIG_IOMMU_API
> +	struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
> +
> +	if (fwspec && fwspec->num_ids == 1) {
> +		*stream_id = fwspec->ids[0] & 0xffff;
> +		return true;
> +	}
> +#endif
> +
> +	return false;
> +}
> +
>   #endif /* __LINUX_IOMMU_H */

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

* Re: [PATCH v12 2/6] iommu/tegra: Add tegra_dev_iommu_get_stream_id() helper
  2022-12-05 19:03   ` Robin Murphy
@ 2022-12-06 16:49     ` Thierry Reding
  0 siblings, 0 replies; 9+ messages in thread
From: Thierry Reding @ 2022-12-06 16:49 UTC (permalink / raw)
  To: Robin Murphy
  Cc: Joerg Roedel, Ulf Hansson, Adrian Hunter, Jonathan Hunter,
	Prathamesh Shete, Will Deacon, iommu, linux-mmc, linux-tegra

[-- Attachment #1: Type: text/plain, Size: 1222 bytes --]

On Mon, Dec 05, 2022 at 07:03:09PM +0000, Robin Murphy wrote:
> On 2022-12-02 15:26, Thierry Reding wrote:
> > From: Thierry Reding <treding@nvidia.com>
> > 
> > Access to the internals of struct iommu_fwspec by non-IOMMU drivers is
> > discouraged. Many drivers for Tegra SoCs, however, need access to their
> > IOMMU stream IDs so that they can be programmed into various hardware
> > registers.
> > 
> > Formalize this access into a common helper to make it easier to audit
> > and maintain.
> 
> In many ways I'd be happier if this could go somewhere in include/soc/tegra/
> rather than the generic IOMMU API header, but I see the argument for keeping
> fwspec usage close to home as well, so no overwhelming preference one way or
> the other. Mostly I'd just like to get something landed so that all those
> other drivers can be cleaned up as well, and I reckon this counts as good
> enough.

Yeah, given Joerg's comment about potentially hiding struct iommu_fwspec
better from others at some point in the future, I figured it'd be better
to have this in a more central location.

> Unless Joerg has a stronger opinion,
> 
> Acked-by: Robin Murphy <robin.murphy@arm.com>

Thanks,
Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2022-12-06 16:50 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-02 15:26 [PATCH v12 0/6] mmc: sdhci: Add Tegra234 support Thierry Reding
2022-12-02 15:26 ` [PATCH v12 1/6] iommu: Add note about struct iommu_fwspec usage Thierry Reding
2022-12-02 15:26 ` [PATCH v12 2/6] iommu/tegra: Add tegra_dev_iommu_get_stream_id() helper Thierry Reding
2022-12-05 19:03   ` Robin Murphy
2022-12-06 16:49     ` Thierry Reding
2022-12-02 15:26 ` [PATCH v12 3/6] mmc: sdhci-tegra: Sort includes alphabetically Thierry Reding
2022-12-02 15:26 ` [PATCH v12 4/6] mmc: sdhci-tegra: Separate Tegra194 and Tegra234 SoC data Thierry Reding
2022-12-02 15:26 ` [PATCH v12 5/6] mmc: sdhci-tegra: Add support to program MC stream ID Thierry Reding
2022-12-02 15:26 ` [PATCH v12 6/6] mmc: sdhci-tegra: Issue CMD and DAT resets together Thierry Reding

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).