diff options
author | Terje Bergstrom <tbergstrom@nvidia.com> | 2016-03-29 19:02:34 -0400 |
---|---|---|
committer | Terje Bergstrom <tbergstrom@nvidia.com> | 2016-04-08 12:42:41 -0400 |
commit | e8bac374c0ed24f05bf389e1e8b5aca47f61bd3a (patch) | |
tree | 36b6e111f8706c0560ee552bc9d6e15b87fc9621 /drivers/gpu/nvgpu/gk20a/gk20a_scale.c | |
parent | 2382a8433fddaee3baecff6ae941944850787ab7 (diff) |
gpu: nvgpu: Use device instead of platform_device
Use struct device instead of struct platform_device wherever
possible. This allows adding other bus types later.
Change-Id: I1657287a68d85a542cdbdd8a00d1902c3d6e00ed
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/1120466
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/gk20a_scale.c')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/gk20a_scale.c | 84 |
1 files changed, 41 insertions, 43 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a_scale.c b/drivers/gpu/nvgpu/gk20a/gk20a_scale.c index 65772d3b..e5c93db5 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a_scale.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a_scale.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * gk20a clock scaling profile | 2 | * gk20a clock scaling profile |
3 | * | 3 | * |
4 | * Copyright (c) 2013-2015, NVIDIA Corporation. All rights reserved. | 4 | * Copyright (c) 2013-2016, NVIDIA Corporation. All rights reserved. |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify it | 6 | * This program is free software; you can redistribute it and/or modify it |
7 | * under the terms and conditions of the GNU General Public License, | 7 | * under the terms and conditions of the GNU General Public License, |
@@ -47,8 +47,8 @@ static int gk20a_scale_qos_notify(struct notifier_block *nb, | |||
47 | struct gk20a_scale_profile *profile = | 47 | struct gk20a_scale_profile *profile = |
48 | container_of(nb, struct gk20a_scale_profile, | 48 | container_of(nb, struct gk20a_scale_profile, |
49 | qos_notify_block); | 49 | qos_notify_block); |
50 | struct gk20a_platform *platform = platform_get_drvdata(profile->pdev); | 50 | struct gk20a_platform *platform = dev_get_drvdata(profile->dev); |
51 | struct gk20a *g = get_gk20a(profile->pdev); | 51 | struct gk20a *g = get_gk20a(profile->dev); |
52 | unsigned long freq; | 52 | unsigned long freq; |
53 | 53 | ||
54 | if (!platform->postscale) | 54 | if (!platform->postscale) |
@@ -56,7 +56,7 @@ static int gk20a_scale_qos_notify(struct notifier_block *nb, | |||
56 | 56 | ||
57 | /* get the frequency requirement. if devfreq is enabled, check if it | 57 | /* get the frequency requirement. if devfreq is enabled, check if it |
58 | * has higher demand than qos */ | 58 | * has higher demand than qos */ |
59 | freq = platform->clk_round_rate(profile->pdev, | 59 | freq = platform->clk_round_rate(profile->dev, |
60 | pm_qos_request(platform->qos_id)); | 60 | pm_qos_request(platform->qos_id)); |
61 | if (g->devfreq) | 61 | if (g->devfreq) |
62 | freq = max(g->devfreq->previous_freq, freq); | 62 | freq = max(g->devfreq->previous_freq, freq); |
@@ -64,7 +64,7 @@ static int gk20a_scale_qos_notify(struct notifier_block *nb, | |||
64 | /* Update gpu load because we may scale the emc target | 64 | /* Update gpu load because we may scale the emc target |
65 | * if the gpu load changed. */ | 65 | * if the gpu load changed. */ |
66 | gk20a_pmu_load_update(g); | 66 | gk20a_pmu_load_update(g); |
67 | platform->postscale(profile->pdev, freq); | 67 | platform->postscale(profile->dev, freq); |
68 | 68 | ||
69 | return NOTIFY_OK; | 69 | return NOTIFY_OK; |
70 | } | 70 | } |
@@ -77,12 +77,12 @@ static int gk20a_scale_qos_notify(struct notifier_block *nb, | |||
77 | 77 | ||
78 | static int gk20a_scale_make_freq_table(struct gk20a_scale_profile *profile) | 78 | static int gk20a_scale_make_freq_table(struct gk20a_scale_profile *profile) |
79 | { | 79 | { |
80 | struct gk20a_platform *platform = platform_get_drvdata(profile->pdev); | 80 | struct gk20a_platform *platform = dev_get_drvdata(profile->dev); |
81 | int num_freqs, err; | 81 | int num_freqs, err; |
82 | unsigned long *freqs; | 82 | unsigned long *freqs; |
83 | 83 | ||
84 | /* get gpu frequency table */ | 84 | /* get gpu frequency table */ |
85 | err = platform->get_clk_freqs(profile->pdev, &freqs, | 85 | err = platform->get_clk_freqs(profile->dev, &freqs, |
86 | &num_freqs); | 86 | &num_freqs); |
87 | if (err) | 87 | if (err) |
88 | return -ENOSYS; | 88 | return -ENOSYS; |
@@ -103,22 +103,21 @@ static int gk20a_scale_target(struct device *dev, unsigned long *freq, | |||
103 | u32 flags) | 103 | u32 flags) |
104 | { | 104 | { |
105 | struct gk20a_platform *platform = dev_get_drvdata(dev); | 105 | struct gk20a_platform *platform = dev_get_drvdata(dev); |
106 | struct platform_device *pdev = to_platform_device(dev); | ||
107 | unsigned long rounded_rate = | 106 | unsigned long rounded_rate = |
108 | platform->clk_round_rate(pdev, *freq); | 107 | platform->clk_round_rate(dev, *freq); |
109 | 108 | ||
110 | if (platform->clk_get_rate(pdev) == rounded_rate) | 109 | if (platform->clk_get_rate(dev) == rounded_rate) |
111 | *freq = rounded_rate; | 110 | *freq = rounded_rate; |
112 | else { | 111 | else { |
113 | platform->clk_set_rate(pdev, rounded_rate); | 112 | platform->clk_set_rate(dev, rounded_rate); |
114 | *freq = platform->clk_get_rate(pdev); | 113 | *freq = platform->clk_get_rate(dev); |
115 | } | 114 | } |
116 | 115 | ||
117 | /* postscale will only scale emc (dram clock) if evaluating | 116 | /* postscale will only scale emc (dram clock) if evaluating |
118 | * gk20a_tegra_get_emc_rate() produces a new or different emc | 117 | * gk20a_tegra_get_emc_rate() produces a new or different emc |
119 | * target because the load or_and gpufreq has changed */ | 118 | * target because the load or_and gpufreq has changed */ |
120 | if (platform->postscale) | 119 | if (platform->postscale) |
121 | platform->postscale(pdev, rounded_rate); | 120 | platform->postscale(dev, rounded_rate); |
122 | 121 | ||
123 | return 0; | 122 | return 0; |
124 | } | 123 | } |
@@ -130,9 +129,9 @@ static int gk20a_scale_target(struct device *dev, unsigned long *freq, | |||
130 | * based on the time it was asked last time. | 129 | * based on the time it was asked last time. |
131 | */ | 130 | */ |
132 | 131 | ||
133 | static void update_load_estimate_gpmu(struct platform_device *pdev) | 132 | static void update_load_estimate_gpmu(struct device *dev) |
134 | { | 133 | { |
135 | struct gk20a *g = get_gk20a(pdev); | 134 | struct gk20a *g = get_gk20a(dev); |
136 | struct gk20a_scale_profile *profile = g->scale_profile; | 135 | struct gk20a_scale_profile *profile = g->scale_profile; |
137 | unsigned long dt; | 136 | unsigned long dt; |
138 | u32 busy_time; | 137 | u32 busy_time; |
@@ -148,14 +147,14 @@ static void update_load_estimate_gpmu(struct platform_device *pdev) | |||
148 | } | 147 | } |
149 | 148 | ||
150 | /* | 149 | /* |
151 | * gk20a_scale_suspend(pdev) | 150 | * gk20a_scale_suspend(dev) |
152 | * | 151 | * |
153 | * This function informs devfreq of suspend | 152 | * This function informs devfreq of suspend |
154 | */ | 153 | */ |
155 | 154 | ||
156 | void gk20a_scale_suspend(struct platform_device *pdev) | 155 | void gk20a_scale_suspend(struct device *dev) |
157 | { | 156 | { |
158 | struct gk20a *g = get_gk20a(pdev); | 157 | struct gk20a *g = get_gk20a(dev); |
159 | struct devfreq *devfreq = g->devfreq; | 158 | struct devfreq *devfreq = g->devfreq; |
160 | 159 | ||
161 | if (!devfreq) | 160 | if (!devfreq) |
@@ -165,14 +164,14 @@ void gk20a_scale_suspend(struct platform_device *pdev) | |||
165 | } | 164 | } |
166 | 165 | ||
167 | /* | 166 | /* |
168 | * gk20a_scale_resume(pdev) | 167 | * gk20a_scale_resume(dev) |
169 | * | 168 | * |
170 | * This functions informs devfreq of resume | 169 | * This functions informs devfreq of resume |
171 | */ | 170 | */ |
172 | 171 | ||
173 | void gk20a_scale_resume(struct platform_device *pdev) | 172 | void gk20a_scale_resume(struct device *dev) |
174 | { | 173 | { |
175 | struct gk20a *g = get_gk20a(pdev); | 174 | struct gk20a *g = get_gk20a(dev); |
176 | struct devfreq *devfreq = g->devfreq; | 175 | struct devfreq *devfreq = g->devfreq; |
177 | 176 | ||
178 | if (!devfreq) | 177 | if (!devfreq) |
@@ -182,15 +181,15 @@ void gk20a_scale_resume(struct platform_device *pdev) | |||
182 | } | 181 | } |
183 | 182 | ||
184 | /* | 183 | /* |
185 | * gk20a_scale_notify(pdev, busy) | 184 | * gk20a_scale_notify(dev, busy) |
186 | * | 185 | * |
187 | * Calling this function informs that the device is idling (..or busy). This | 186 | * Calling this function informs that the device is idling (..or busy). This |
188 | * data is used to estimate the current load | 187 | * data is used to estimate the current load |
189 | */ | 188 | */ |
190 | 189 | ||
191 | static void gk20a_scale_notify(struct platform_device *pdev, bool busy) | 190 | static void gk20a_scale_notify(struct device *dev, bool busy) |
192 | { | 191 | { |
193 | struct gk20a *g = get_gk20a(pdev); | 192 | struct gk20a *g = get_gk20a(dev); |
194 | struct gk20a_scale_profile *profile = g->scale_profile; | 193 | struct gk20a_scale_profile *profile = g->scale_profile; |
195 | struct devfreq *devfreq = g->devfreq; | 194 | struct devfreq *devfreq = g->devfreq; |
196 | 195 | ||
@@ -204,15 +203,15 @@ static void gk20a_scale_notify(struct platform_device *pdev, bool busy) | |||
204 | mutex_unlock(&devfreq->lock); | 203 | mutex_unlock(&devfreq->lock); |
205 | } | 204 | } |
206 | 205 | ||
207 | void gk20a_scale_notify_idle(struct platform_device *pdev) | 206 | void gk20a_scale_notify_idle(struct device *dev) |
208 | { | 207 | { |
209 | gk20a_scale_notify(pdev, false); | 208 | gk20a_scale_notify(dev, false); |
210 | 209 | ||
211 | } | 210 | } |
212 | 211 | ||
213 | void gk20a_scale_notify_busy(struct platform_device *pdev) | 212 | void gk20a_scale_notify_busy(struct device *dev) |
214 | { | 213 | { |
215 | gk20a_scale_notify(pdev, true); | 214 | gk20a_scale_notify(dev, true); |
216 | } | 215 | } |
217 | 216 | ||
218 | /* | 217 | /* |
@@ -224,24 +223,23 @@ void gk20a_scale_notify_busy(struct platform_device *pdev) | |||
224 | static int gk20a_scale_get_dev_status(struct device *dev, | 223 | static int gk20a_scale_get_dev_status(struct device *dev, |
225 | struct devfreq_dev_status *stat) | 224 | struct devfreq_dev_status *stat) |
226 | { | 225 | { |
227 | struct gk20a *g = get_gk20a(to_platform_device(dev)); | 226 | struct gk20a *g = get_gk20a(dev); |
228 | struct gk20a_scale_profile *profile = g->scale_profile; | 227 | struct gk20a_scale_profile *profile = g->scale_profile; |
229 | struct platform_device *pdev = to_platform_device(dev); | 228 | struct gk20a_platform *platform = dev_get_drvdata(dev); |
230 | struct gk20a_platform *platform = platform_get_drvdata(pdev); | ||
231 | 229 | ||
232 | /* update the software shadow */ | 230 | /* update the software shadow */ |
233 | gk20a_pmu_load_update(g); | 231 | gk20a_pmu_load_update(g); |
234 | 232 | ||
235 | /* inform edp about new constraint */ | 233 | /* inform edp about new constraint */ |
236 | if (platform->prescale) | 234 | if (platform->prescale) |
237 | platform->prescale(pdev); | 235 | platform->prescale(dev); |
238 | 236 | ||
239 | /* Make sure there are correct values for the current frequency */ | 237 | /* Make sure there are correct values for the current frequency */ |
240 | profile->dev_stat.current_frequency = | 238 | profile->dev_stat.current_frequency = |
241 | platform->clk_get_rate(profile->pdev); | 239 | platform->clk_get_rate(profile->dev); |
242 | 240 | ||
243 | /* Update load estimate */ | 241 | /* Update load estimate */ |
244 | update_load_estimate_gpmu(to_platform_device(dev)); | 242 | update_load_estimate_gpmu(dev); |
245 | 243 | ||
246 | /* Copy the contents of the current device status */ | 244 | /* Copy the contents of the current device status */ |
247 | *stat = profile->dev_stat; | 245 | *stat = profile->dev_stat; |
@@ -254,12 +252,12 @@ static int gk20a_scale_get_dev_status(struct device *dev, | |||
254 | } | 252 | } |
255 | 253 | ||
256 | /* | 254 | /* |
257 | * gk20a_scale_init(pdev) | 255 | * gk20a_scale_init(dev) |
258 | */ | 256 | */ |
259 | 257 | ||
260 | void gk20a_scale_init(struct platform_device *pdev) | 258 | void gk20a_scale_init(struct device *dev) |
261 | { | 259 | { |
262 | struct gk20a_platform *platform = platform_get_drvdata(pdev); | 260 | struct gk20a_platform *platform = dev_get_drvdata(dev); |
263 | struct gk20a *g = platform->g; | 261 | struct gk20a *g = platform->g; |
264 | struct gk20a_scale_profile *profile; | 262 | struct gk20a_scale_profile *profile; |
265 | int err; | 263 | int err; |
@@ -269,7 +267,7 @@ void gk20a_scale_init(struct platform_device *pdev) | |||
269 | 267 | ||
270 | profile = kzalloc(sizeof(*profile), GFP_KERNEL); | 268 | profile = kzalloc(sizeof(*profile), GFP_KERNEL); |
271 | 269 | ||
272 | profile->pdev = pdev; | 270 | profile->dev = dev; |
273 | profile->dev_stat.busy = false; | 271 | profile->dev_stat.busy = false; |
274 | 272 | ||
275 | /* Create frequency table */ | 273 | /* Create frequency table */ |
@@ -290,7 +288,7 @@ void gk20a_scale_init(struct platform_device *pdev) | |||
290 | profile->devfreq_profile.get_dev_status = | 288 | profile->devfreq_profile.get_dev_status = |
291 | gk20a_scale_get_dev_status; | 289 | gk20a_scale_get_dev_status; |
292 | 290 | ||
293 | devfreq = devfreq_add_device(&pdev->dev, | 291 | devfreq = devfreq_add_device(dev, |
294 | &profile->devfreq_profile, | 292 | &profile->devfreq_profile, |
295 | platform->devfreq_governor, NULL); | 293 | platform->devfreq_governor, NULL); |
296 | 294 | ||
@@ -316,9 +314,9 @@ err_get_freqs: | |||
316 | kfree(profile); | 314 | kfree(profile); |
317 | } | 315 | } |
318 | 316 | ||
319 | void gk20a_scale_exit(struct platform_device *pdev) | 317 | void gk20a_scale_exit(struct device *dev) |
320 | { | 318 | { |
321 | struct gk20a_platform *platform = platform_get_drvdata(pdev); | 319 | struct gk20a_platform *platform = dev_get_drvdata(dev); |
322 | struct gk20a *g = platform->g; | 320 | struct gk20a *g = platform->g; |
323 | int err; | 321 | int err; |
324 | 322 | ||
@@ -344,9 +342,9 @@ void gk20a_scale_exit(struct platform_device *pdev) | |||
344 | * Initialize hardware portion of the device | 342 | * Initialize hardware portion of the device |
345 | */ | 343 | */ |
346 | 344 | ||
347 | void gk20a_scale_hw_init(struct platform_device *pdev) | 345 | void gk20a_scale_hw_init(struct device *dev) |
348 | { | 346 | { |
349 | struct gk20a_platform *platform = platform_get_drvdata(pdev); | 347 | struct gk20a_platform *platform = dev_get_drvdata(dev); |
350 | struct gk20a_scale_profile *profile = platform->g->scale_profile; | 348 | struct gk20a_scale_profile *profile = platform->g->scale_profile; |
351 | 349 | ||
352 | /* make sure that scaling has bee initialised */ | 350 | /* make sure that scaling has bee initialised */ |