diff options
author | Peter Daifuku <pdaifuku@nvidia.com> | 2017-10-13 20:06:30 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-10-25 23:24:10 -0400 |
commit | 6bf40e523740279761f3fdc3d84000acc2f62aba (patch) | |
tree | bf56295c292b5ee9bee232141bc0ebd262f02225 /drivers/gpu/nvgpu/vgpu/css_vgpu.c | |
parent | 0dcf0ede812aa55aa106a5e6c2f86216fcbfd5e0 (diff) |
gpu: nvgpu: add max_css_buffer_size characteristic
Add max_css_buffer_size to gpu characteristics. In the virtual
case, the size of the cycle stats snapshot buffer is constrained
by the size of the mempool shared between the guest OS and the
RM server, so tools need to find out what is the maximum size
allowed.
In the native case, we return 0xffffffff to indicate
that the buffer size is unbounded (subject to memory availability),
in the virtual case we return the size of the mempool.
Also collapse native init_cyclestats functions to a single version,
as each chip had identical versions of the code.
JIRA ESRM-54
Bug 200296210
Change-Id: I71764d32c6e71a0d101bd40f274eaa4bea3e5b11
Signed-off-by: Peter Daifuku <pdaifuku@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1578930
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/vgpu/css_vgpu.c')
-rw-r--r-- | drivers/gpu/nvgpu/vgpu/css_vgpu.c | 71 |
1 files changed, 52 insertions, 19 deletions
diff --git a/drivers/gpu/nvgpu/vgpu/css_vgpu.c b/drivers/gpu/nvgpu/vgpu/css_vgpu.c index bcb01fac..266ce871 100644 --- a/drivers/gpu/nvgpu/vgpu/css_vgpu.c +++ b/drivers/gpu/nvgpu/vgpu/css_vgpu.c | |||
@@ -33,39 +33,71 @@ | |||
33 | 33 | ||
34 | static struct tegra_hv_ivm_cookie *css_cookie; | 34 | static struct tegra_hv_ivm_cookie *css_cookie; |
35 | 35 | ||
36 | static int vgpu_css_init_snapshot_buffer(struct gr_gk20a *gr) | 36 | static struct tegra_hv_ivm_cookie *vgpu_css_reserve_mempool(struct gk20a *g) |
37 | { | 37 | { |
38 | struct gk20a *g = gr->g; | ||
39 | struct device *dev = dev_from_gk20a(g); | 38 | struct device *dev = dev_from_gk20a(g); |
40 | struct gk20a_cs_snapshot *data = gr->cs_data; | ||
41 | struct device_node *np = dev->of_node; | 39 | struct device_node *np = dev->of_node; |
42 | struct of_phandle_args args; | 40 | struct of_phandle_args args; |
43 | struct device_node *hv_np; | 41 | struct device_node *hv_np; |
44 | void *buf = NULL; | 42 | struct tegra_hv_ivm_cookie *cookie; |
45 | u32 mempool; | 43 | u32 mempool; |
46 | int err; | 44 | int err; |
47 | 45 | ||
48 | gk20a_dbg_fn(""); | ||
49 | |||
50 | if (data->hw_snapshot) | ||
51 | return 0; | ||
52 | |||
53 | err = of_parse_phandle_with_fixed_args(np, | 46 | err = of_parse_phandle_with_fixed_args(np, |
54 | "mempool-css", 1, 0, &args); | 47 | "mempool-css", 1, 0, &args); |
55 | if (err) { | 48 | if (err) { |
56 | nvgpu_info(g, "dt missing mempool-css"); | 49 | nvgpu_err(g, "dt missing mempool-css"); |
57 | goto fail; | 50 | return ERR_PTR(err); |
58 | } | 51 | } |
59 | 52 | ||
60 | hv_np = args.np; | 53 | hv_np = args.np; |
61 | mempool = args.args[0]; | 54 | mempool = args.args[0]; |
62 | css_cookie = tegra_hv_mempool_reserve(hv_np, mempool); | 55 | cookie = tegra_hv_mempool_reserve(hv_np, mempool); |
63 | if (IS_ERR(css_cookie)) { | 56 | if (IS_ERR_OR_NULL(cookie)) { |
64 | nvgpu_info(g, | 57 | nvgpu_err(g, "mempool %u reserve failed", mempool); |
65 | "mempool %u reserve failed", mempool); | 58 | return ERR_PTR(-EINVAL); |
66 | err = -EINVAL; | ||
67 | goto fail; | ||
68 | } | 59 | } |
60 | return cookie; | ||
61 | } | ||
62 | |||
63 | u32 vgpu_css_get_buffer_size(struct gk20a *g) | ||
64 | { | ||
65 | struct tegra_hv_ivm_cookie *cookie; | ||
66 | u32 size; | ||
67 | |||
68 | nvgpu_log_fn(g, " "); | ||
69 | |||
70 | if (css_cookie) { | ||
71 | nvgpu_log_info(g, "buffer size = %llu", css_cookie->size); | ||
72 | return (u32)css_cookie->size; | ||
73 | } | ||
74 | |||
75 | cookie = vgpu_css_reserve_mempool(g); | ||
76 | if (IS_ERR(css_cookie)) | ||
77 | return 0; | ||
78 | |||
79 | size = cookie->size; | ||
80 | |||
81 | tegra_hv_mempool_unreserve(cookie); | ||
82 | nvgpu_log_info(g, "buffer size = %u", size); | ||
83 | return size; | ||
84 | } | ||
85 | |||
86 | static int vgpu_css_init_snapshot_buffer(struct gr_gk20a *gr) | ||
87 | { | ||
88 | struct gk20a *g = gr->g; | ||
89 | struct gk20a_cs_snapshot *data = gr->cs_data; | ||
90 | void *buf = NULL; | ||
91 | int err; | ||
92 | |||
93 | gk20a_dbg_fn(""); | ||
94 | |||
95 | if (data->hw_snapshot) | ||
96 | return 0; | ||
97 | |||
98 | css_cookie = vgpu_css_reserve_mempool(g); | ||
99 | if (IS_ERR(css_cookie)) | ||
100 | return PTR_ERR(css_cookie); | ||
69 | 101 | ||
70 | /* Make sure buffer size is large enough */ | 102 | /* Make sure buffer size is large enough */ |
71 | if (css_cookie->size < CSS_MIN_HW_SNAPSHOT_SIZE) { | 103 | if (css_cookie->size < CSS_MIN_HW_SNAPSHOT_SIZE) { |
@@ -89,8 +121,8 @@ static int vgpu_css_init_snapshot_buffer(struct gr_gk20a *gr) | |||
89 | memset(data->hw_snapshot, 0xff, css_cookie->size); | 121 | memset(data->hw_snapshot, 0xff, css_cookie->size); |
90 | return 0; | 122 | return 0; |
91 | fail: | 123 | fail: |
92 | if (!IS_ERR_OR_NULL(css_cookie)) | 124 | tegra_hv_mempool_unreserve(css_cookie); |
93 | tegra_hv_mempool_unreserve(css_cookie); | 125 | css_cookie = NULL; |
94 | return err; | 126 | return err; |
95 | } | 127 | } |
96 | 128 | ||
@@ -105,6 +137,7 @@ void vgpu_css_release_snapshot_buffer(struct gr_gk20a *gr) | |||
105 | data->hw_snapshot = NULL; | 137 | data->hw_snapshot = NULL; |
106 | 138 | ||
107 | tegra_hv_mempool_unreserve(css_cookie); | 139 | tegra_hv_mempool_unreserve(css_cookie); |
140 | css_cookie = NULL; | ||
108 | 141 | ||
109 | gk20a_dbg_info("cyclestats(vgpu): buffer for snapshots released\n"); | 142 | gk20a_dbg_info("cyclestats(vgpu): buffer for snapshots released\n"); |
110 | } | 143 | } |