diff options
author | Richard Zhao <rizhao@nvidia.com> | 2018-01-26 20:56:34 -0500 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2018-02-27 17:29:58 -0500 |
commit | 5025350b80f4ded30d6ab2ed3590c6a61937eef7 (patch) | |
tree | 22194fe37aa96d9c003a3a5bdc995ab280e2df58 /drivers/gpu/nvgpu/common/linux/vgpu/css_vgpu.c | |
parent | 649ba2a4b3fcbea2135ce4d0d00feb7563b14270 (diff) |
gpu: nvgpu: vgpu: add ivm wrappers
Added vgpu_ivm_*() functions to be used by os agnostic code.
Jira EVLR-2364
Change-Id: I4a2baebcff9723950c4fba99d0879a0c61e3e3a2
Signed-off-by: Richard Zhao <rizhao@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1649935
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux/vgpu/css_vgpu.c')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/vgpu/css_vgpu.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/vgpu/css_vgpu.c b/drivers/gpu/nvgpu/common/linux/vgpu/css_vgpu.c index ba13c54e..e0798475 100644 --- a/drivers/gpu/nvgpu/common/linux/vgpu/css_vgpu.c +++ b/drivers/gpu/nvgpu/common/linux/vgpu/css_vgpu.c | |||
@@ -15,7 +15,7 @@ | |||
15 | */ | 15 | */ |
16 | #if defined(CONFIG_GK20A_CYCLE_STATS) | 16 | #if defined(CONFIG_GK20A_CYCLE_STATS) |
17 | 17 | ||
18 | #include <linux/tegra-ivc.h> | 18 | #include <nvgpu/vgpu/vgpu_ivm.h> |
19 | #include <linux/tegra_vgpu.h> | 19 | #include <linux/tegra_vgpu.h> |
20 | #include <uapi/linux/nvgpu.h> | 20 | #include <uapi/linux/nvgpu.h> |
21 | 21 | ||
@@ -45,7 +45,7 @@ static struct tegra_hv_ivm_cookie *vgpu_css_reserve_mempool(struct gk20a *g) | |||
45 | } | 45 | } |
46 | 46 | ||
47 | mempool = args.args[0]; | 47 | mempool = args.args[0]; |
48 | cookie = tegra_hv_mempool_reserve(mempool); | 48 | cookie = vgpu_ivm_mempool_reserve(mempool); |
49 | if (IS_ERR_OR_NULL(cookie)) { | 49 | if (IS_ERR_OR_NULL(cookie)) { |
50 | nvgpu_err(g, "mempool %u reserve failed", mempool); | 50 | nvgpu_err(g, "mempool %u reserve failed", mempool); |
51 | return ERR_PTR(-EINVAL); | 51 | return ERR_PTR(-EINVAL); |
@@ -61,18 +61,19 @@ u32 vgpu_css_get_buffer_size(struct gk20a *g) | |||
61 | nvgpu_log_fn(g, " "); | 61 | nvgpu_log_fn(g, " "); |
62 | 62 | ||
63 | if (css_cookie) { | 63 | if (css_cookie) { |
64 | nvgpu_log_info(g, "buffer size = %llu", css_cookie->size); | 64 | size = (u32)vgpu_ivm_get_size(css_cookie); |
65 | return (u32)css_cookie->size; | 65 | nvgpu_log_info(g, "buffer size = 0x%08x", size); |
66 | return size; | ||
66 | } | 67 | } |
67 | 68 | ||
68 | cookie = vgpu_css_reserve_mempool(g); | 69 | cookie = vgpu_css_reserve_mempool(g); |
69 | if (IS_ERR(cookie)) | 70 | if (IS_ERR(cookie)) |
70 | return 0; | 71 | return 0; |
71 | 72 | ||
72 | size = cookie->size; | 73 | size = vgpu_ivm_get_size(cookie); |
73 | 74 | ||
74 | tegra_hv_mempool_unreserve(cookie); | 75 | vgpu_ivm_mempool_unreserve(cookie); |
75 | nvgpu_log_info(g, "buffer size = %u", size); | 76 | nvgpu_log_info(g, "buffer size = 0x%08x", size); |
76 | return size; | 77 | return size; |
77 | } | 78 | } |
78 | 79 | ||
@@ -82,6 +83,7 @@ static int vgpu_css_init_snapshot_buffer(struct gr_gk20a *gr) | |||
82 | struct gk20a_cs_snapshot *data = gr->cs_data; | 83 | struct gk20a_cs_snapshot *data = gr->cs_data; |
83 | void *buf = NULL; | 84 | void *buf = NULL; |
84 | int err; | 85 | int err; |
86 | u64 size; | ||
85 | 87 | ||
86 | gk20a_dbg_fn(""); | 88 | gk20a_dbg_fn(""); |
87 | 89 | ||
@@ -92,15 +94,15 @@ static int vgpu_css_init_snapshot_buffer(struct gr_gk20a *gr) | |||
92 | if (IS_ERR(css_cookie)) | 94 | if (IS_ERR(css_cookie)) |
93 | return PTR_ERR(css_cookie); | 95 | return PTR_ERR(css_cookie); |
94 | 96 | ||
97 | size = vgpu_ivm_get_size(css_cookie); | ||
95 | /* Make sure buffer size is large enough */ | 98 | /* Make sure buffer size is large enough */ |
96 | if (css_cookie->size < CSS_MIN_HW_SNAPSHOT_SIZE) { | 99 | if (size < CSS_MIN_HW_SNAPSHOT_SIZE) { |
97 | nvgpu_info(g, "mempool size %lld too small", | 100 | nvgpu_info(g, "mempool size 0x%llx too small", size); |
98 | css_cookie->size); | ||
99 | err = -ENOMEM; | 101 | err = -ENOMEM; |
100 | goto fail; | 102 | goto fail; |
101 | } | 103 | } |
102 | 104 | ||
103 | buf = ioremap_cache(css_cookie->ipa, css_cookie->size); | 105 | buf = ioremap_cache(vgpu_ivm_get_ipa(css_cookie), size); |
104 | if (!buf) { | 106 | if (!buf) { |
105 | nvgpu_info(g, "ioremap_cache failed"); | 107 | nvgpu_info(g, "ioremap_cache failed"); |
106 | err = -EINVAL; | 108 | err = -EINVAL; |
@@ -109,12 +111,12 @@ static int vgpu_css_init_snapshot_buffer(struct gr_gk20a *gr) | |||
109 | 111 | ||
110 | data->hw_snapshot = buf; | 112 | data->hw_snapshot = buf; |
111 | data->hw_end = data->hw_snapshot + | 113 | data->hw_end = data->hw_snapshot + |
112 | css_cookie->size / sizeof(struct gk20a_cs_snapshot_fifo_entry); | 114 | size / sizeof(struct gk20a_cs_snapshot_fifo_entry); |
113 | data->hw_get = data->hw_snapshot; | 115 | data->hw_get = data->hw_snapshot; |
114 | memset(data->hw_snapshot, 0xff, css_cookie->size); | 116 | memset(data->hw_snapshot, 0xff, size); |
115 | return 0; | 117 | return 0; |
116 | fail: | 118 | fail: |
117 | tegra_hv_mempool_unreserve(css_cookie); | 119 | vgpu_ivm_mempool_unreserve(css_cookie); |
118 | css_cookie = NULL; | 120 | css_cookie = NULL; |
119 | return err; | 121 | return err; |
120 | } | 122 | } |
@@ -129,7 +131,7 @@ void vgpu_css_release_snapshot_buffer(struct gr_gk20a *gr) | |||
129 | iounmap(data->hw_snapshot); | 131 | iounmap(data->hw_snapshot); |
130 | data->hw_snapshot = NULL; | 132 | data->hw_snapshot = NULL; |
131 | 133 | ||
132 | tegra_hv_mempool_unreserve(css_cookie); | 134 | vgpu_ivm_mempool_unreserve(css_cookie); |
133 | css_cookie = NULL; | 135 | css_cookie = NULL; |
134 | 136 | ||
135 | gk20a_dbg_info("cyclestats(vgpu): buffer for snapshots released\n"); | 137 | gk20a_dbg_info("cyclestats(vgpu): buffer for snapshots released\n"); |