aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Reding <treding@nvidia.com>2019-02-01 08:28:36 -0500
committerThierry Reding <treding@nvidia.com>2019-02-07 12:29:01 -0500
commitf3779cb190a5a12d2e26fd5af724fb1384a9144f (patch)
tree4e8e5ac72c7d1ca5fbbe54c6d86a630e46db7741
parent3ff41673d5c6842e6668f95b0a14e5f6a74d043f (diff)
drm/tegra: vic: Support stream ID register programming
The version of VIC found in Tegra186 and later incorporates improvements with regards to context isolation. As part of those improvements, stream ID registers were added that allow to specify separate stream IDs for the Falcon microcontroller and the VIC memory interface. While it is possible to also set the stream ID dynamically at runtime to allow userspace contexts to be completely separated, this commit doesn't implement that yet. Instead, the static VIC stream ID is programmed when the Falcon is booted. This ensures that memory accesses by the Falcon or the VIC are properly translated via the SMMU. Signed-off-by: Thierry Reding <treding@nvidia.com>
-rw-r--r--drivers/gpu/drm/tegra/vic.c21
-rw-r--r--drivers/gpu/drm/tegra/vic.h9
2 files changed, 30 insertions, 0 deletions
diff --git a/drivers/gpu/drm/tegra/vic.c b/drivers/gpu/drm/tegra/vic.c
index 55a8cc162e9d..39bfed9623de 100644
--- a/drivers/gpu/drm/tegra/vic.c
+++ b/drivers/gpu/drm/tegra/vic.c
@@ -26,6 +26,7 @@
26struct vic_config { 26struct vic_config {
27 const char *firmware; 27 const char *firmware;
28 unsigned int version; 28 unsigned int version;
29 bool supports_sid;
29}; 30};
30 31
31struct vic { 32struct vic {
@@ -105,6 +106,22 @@ static int vic_boot(struct vic *vic)
105 if (vic->booted) 106 if (vic->booted)
106 return 0; 107 return 0;
107 108
109 if (vic->config->supports_sid) {
110 struct iommu_fwspec *spec = dev_iommu_fwspec_get(vic->dev);
111 u32 value;
112
113 value = TRANSCFG_ATT(1, TRANSCFG_SID_FALCON) |
114 TRANSCFG_ATT(0, TRANSCFG_SID_HW);
115 vic_writel(vic, value, VIC_TFBIF_TRANSCFG);
116
117 if (spec && spec->num_ids > 0) {
118 value = spec->ids[0] & 0xffff;
119
120 vic_writel(vic, value, VIC_THI_STREAMID0);
121 vic_writel(vic, value, VIC_THI_STREAMID1);
122 }
123 }
124
108 /* setup clockgating registers */ 125 /* setup clockgating registers */
109 vic_writel(vic, CG_IDLE_CG_DLY_CNT(4) | 126 vic_writel(vic, CG_IDLE_CG_DLY_CNT(4) |
110 CG_IDLE_CG_EN | 127 CG_IDLE_CG_EN |
@@ -314,6 +331,7 @@ static const struct tegra_drm_client_ops vic_ops = {
314static const struct vic_config vic_t124_config = { 331static const struct vic_config vic_t124_config = {
315 .firmware = NVIDIA_TEGRA_124_VIC_FIRMWARE, 332 .firmware = NVIDIA_TEGRA_124_VIC_FIRMWARE,
316 .version = 0x40, 333 .version = 0x40,
334 .supports_sid = false,
317}; 335};
318 336
319#define NVIDIA_TEGRA_210_VIC_FIRMWARE "nvidia/tegra210/vic04_ucode.bin" 337#define NVIDIA_TEGRA_210_VIC_FIRMWARE "nvidia/tegra210/vic04_ucode.bin"
@@ -321,6 +339,7 @@ static const struct vic_config vic_t124_config = {
321static const struct vic_config vic_t210_config = { 339static const struct vic_config vic_t210_config = {
322 .firmware = NVIDIA_TEGRA_210_VIC_FIRMWARE, 340 .firmware = NVIDIA_TEGRA_210_VIC_FIRMWARE,
323 .version = 0x21, 341 .version = 0x21,
342 .supports_sid = false,
324}; 343};
325 344
326#define NVIDIA_TEGRA_186_VIC_FIRMWARE "nvidia/tegra186/vic04_ucode.bin" 345#define NVIDIA_TEGRA_186_VIC_FIRMWARE "nvidia/tegra186/vic04_ucode.bin"
@@ -328,6 +347,7 @@ static const struct vic_config vic_t210_config = {
328static const struct vic_config vic_t186_config = { 347static const struct vic_config vic_t186_config = {
329 .firmware = NVIDIA_TEGRA_186_VIC_FIRMWARE, 348 .firmware = NVIDIA_TEGRA_186_VIC_FIRMWARE,
330 .version = 0x18, 349 .version = 0x18,
350 .supports_sid = true,
331}; 351};
332 352
333#define NVIDIA_TEGRA_194_VIC_FIRMWARE "nvidia/tegra194/vic.bin" 353#define NVIDIA_TEGRA_194_VIC_FIRMWARE "nvidia/tegra194/vic.bin"
@@ -335,6 +355,7 @@ static const struct vic_config vic_t186_config = {
335static const struct vic_config vic_t194_config = { 355static const struct vic_config vic_t194_config = {
336 .firmware = NVIDIA_TEGRA_194_VIC_FIRMWARE, 356 .firmware = NVIDIA_TEGRA_194_VIC_FIRMWARE,
337 .version = 0x19, 357 .version = 0x19,
358 .supports_sid = true,
338}; 359};
339 360
340static const struct of_device_id vic_match[] = { 361static const struct of_device_id vic_match[] = {
diff --git a/drivers/gpu/drm/tegra/vic.h b/drivers/gpu/drm/tegra/vic.h
index 21844817a7e1..017584340dd6 100644
--- a/drivers/gpu/drm/tegra/vic.h
+++ b/drivers/gpu/drm/tegra/vic.h
@@ -17,11 +17,20 @@
17 17
18/* VIC registers */ 18/* VIC registers */
19 19
20#define VIC_THI_STREAMID0 0x00000030
21#define VIC_THI_STREAMID1 0x00000034
22
20#define NV_PVIC_MISC_PRI_VIC_CG 0x000016d0 23#define NV_PVIC_MISC_PRI_VIC_CG 0x000016d0
21#define CG_IDLE_CG_DLY_CNT(val) ((val & 0x3f) << 0) 24#define CG_IDLE_CG_DLY_CNT(val) ((val & 0x3f) << 0)
22#define CG_IDLE_CG_EN (1 << 6) 25#define CG_IDLE_CG_EN (1 << 6)
23#define CG_WAKEUP_DLY_CNT(val) ((val & 0xf) << 16) 26#define CG_WAKEUP_DLY_CNT(val) ((val & 0xf) << 16)
24 27
28#define VIC_TFBIF_TRANSCFG 0x00002044
29#define TRANSCFG_ATT(i, v) (((v) & 0x3) << (i * 4))
30#define TRANSCFG_SID_HW 0
31#define TRANSCFG_SID_PHY 1
32#define TRANSCFG_SID_FALCON 2
33
25/* Firmware offsets */ 34/* Firmware offsets */
26 35
27#define VIC_UCODE_FCE_HEADER_OFFSET (6*4) 36#define VIC_UCODE_FCE_HEADER_OFFSET (6*4)