diff options
author | David Nieto <dmartineznie@nvidia.com> | 2017-03-13 21:45:37 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-03-24 00:05:35 -0400 |
commit | 2a502bdd5f3c93b87286456ca901ad43b0f14906 (patch) | |
tree | aba5c18b07b393e0306588d9ba4707a6c272ae6b /drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c | |
parent | a84f601fbaf6b40e14a321eda1e83d93e55cebba (diff) |
gpu: nvgpu: pass gk20a struct to gk20a_busy
After driver remove, the device structure passed in gk20a_busy can be
invalid. To solve this the prototype of the function is modified to pass
the gk20a struct instead of the device pointer.
bug 200277762
JIRA: EVLR-1023
Change-Id: I08eb74bd3578834d45115098ed9936ebbb436fdf
Signed-off-by: David Nieto <dmartineznie@nvidia.com>
Reviewed-on: http://git-master/r/1320194
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com>
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
GVS: Gerrit_Virtual_Submit
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c b/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c index 6611b120..2ab15357 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c | |||
@@ -48,7 +48,7 @@ static ssize_t elcg_enable_store(struct device *dev, | |||
48 | if (kstrtoul(buf, 10, &val) < 0) | 48 | if (kstrtoul(buf, 10, &val) < 0) |
49 | return -EINVAL; | 49 | return -EINVAL; |
50 | 50 | ||
51 | err = gk20a_busy(g->dev); | 51 | err = gk20a_busy(g); |
52 | if (err) | 52 | if (err) |
53 | return err; | 53 | return err; |
54 | 54 | ||
@@ -60,7 +60,7 @@ static ssize_t elcg_enable_store(struct device *dev, | |||
60 | gr_gk20a_init_cg_mode(g, ELCG_MODE, ELCG_RUN); | 60 | gr_gk20a_init_cg_mode(g, ELCG_MODE, ELCG_RUN); |
61 | } | 61 | } |
62 | 62 | ||
63 | gk20a_idle(g->dev); | 63 | gk20a_idle(g); |
64 | 64 | ||
65 | dev_info(dev, "ELCG is %s.\n", g->elcg_enabled ? "enabled" : | 65 | dev_info(dev, "ELCG is %s.\n", g->elcg_enabled ? "enabled" : |
66 | "disabled"); | 66 | "disabled"); |
@@ -93,7 +93,7 @@ static ssize_t blcg_enable_store(struct device *dev, | |||
93 | else | 93 | else |
94 | g->blcg_enabled = false; | 94 | g->blcg_enabled = false; |
95 | 95 | ||
96 | err = gk20a_busy(g->dev); | 96 | err = gk20a_busy(g); |
97 | if (err) | 97 | if (err) |
98 | return err; | 98 | return err; |
99 | 99 | ||
@@ -117,7 +117,7 @@ static ssize_t blcg_enable_store(struct device *dev, | |||
117 | if (g->ops.clock_gating.blcg_xbar_load_gating_prod) | 117 | if (g->ops.clock_gating.blcg_xbar_load_gating_prod) |
118 | g->ops.clock_gating.blcg_xbar_load_gating_prod(g, | 118 | g->ops.clock_gating.blcg_xbar_load_gating_prod(g, |
119 | g->blcg_enabled); | 119 | g->blcg_enabled); |
120 | gk20a_idle(g->dev); | 120 | gk20a_idle(g); |
121 | 121 | ||
122 | dev_info(dev, "BLCG is %s.\n", g->blcg_enabled ? "enabled" : | 122 | dev_info(dev, "BLCG is %s.\n", g->blcg_enabled ? "enabled" : |
123 | "disabled"); | 123 | "disabled"); |
@@ -156,7 +156,7 @@ static ssize_t slcg_enable_store(struct device *dev, | |||
156 | * init. Therefore, it would be incongruous to add it here. Once | 156 | * init. Therefore, it would be incongruous to add it here. Once |
157 | * it is added to init, we should add it here too. | 157 | * it is added to init, we should add it here too. |
158 | */ | 158 | */ |
159 | err = gk20a_busy(g->dev); | 159 | err = gk20a_busy(g); |
160 | if (err) | 160 | if (err) |
161 | return err; | 161 | return err; |
162 | 162 | ||
@@ -184,7 +184,7 @@ static ssize_t slcg_enable_store(struct device *dev, | |||
184 | g->ops.clock_gating.slcg_pmu_load_gating_prod(g, g->slcg_enabled); | 184 | g->ops.clock_gating.slcg_pmu_load_gating_prod(g, g->slcg_enabled); |
185 | if (g->ops.clock_gating.slcg_xbar_load_gating_prod) | 185 | if (g->ops.clock_gating.slcg_xbar_load_gating_prod) |
186 | g->ops.clock_gating.slcg_xbar_load_gating_prod(g, g->slcg_enabled); | 186 | g->ops.clock_gating.slcg_xbar_load_gating_prod(g, g->slcg_enabled); |
187 | gk20a_idle(g->dev); | 187 | gk20a_idle(g); |
188 | 188 | ||
189 | dev_info(dev, "SLCG is %s.\n", g->slcg_enabled ? "enabled" : | 189 | dev_info(dev, "SLCG is %s.\n", g->slcg_enabled ? "enabled" : |
190 | "disabled"); | 190 | "disabled"); |
@@ -289,6 +289,8 @@ static ssize_t railgate_enable_store(struct device *dev, | |||
289 | { | 289 | { |
290 | struct gk20a_platform *platform = dev_get_drvdata(dev); | 290 | struct gk20a_platform *platform = dev_get_drvdata(dev); |
291 | unsigned long railgate_enable = 0; | 291 | unsigned long railgate_enable = 0; |
292 | /* dev is guaranteed to be valid here. Ok to de-reference */ | ||
293 | struct gk20a *g = get_gk20a(dev); | ||
292 | int err = 0; | 294 | int err = 0; |
293 | 295 | ||
294 | if (kstrtoul(buf, 10, &railgate_enable) < 0) | 296 | if (kstrtoul(buf, 10, &railgate_enable) < 0) |
@@ -296,12 +298,12 @@ static ssize_t railgate_enable_store(struct device *dev, | |||
296 | 298 | ||
297 | if (railgate_enable && !platform->can_railgate) { | 299 | if (railgate_enable && !platform->can_railgate) { |
298 | /* release extra ref count */ | 300 | /* release extra ref count */ |
299 | gk20a_idle(dev); | 301 | gk20a_idle(g); |
300 | platform->can_railgate = true; | 302 | platform->can_railgate = true; |
301 | platform->user_railgate_disabled = false; | 303 | platform->user_railgate_disabled = false; |
302 | } else if (railgate_enable == 0 && platform->can_railgate) { | 304 | } else if (railgate_enable == 0 && platform->can_railgate) { |
303 | /* take extra ref count */ | 305 | /* take extra ref count */ |
304 | err = gk20a_busy(dev); | 306 | err = gk20a_busy(g); |
305 | if (err) | 307 | if (err) |
306 | return err; | 308 | return err; |
307 | platform->can_railgate = false; | 309 | platform->can_railgate = false; |
@@ -348,10 +350,10 @@ static ssize_t railgate_delay_store(struct device *dev, | |||
348 | dev_err(dev, "Invalid powergate delay\n"); | 350 | dev_err(dev, "Invalid powergate delay\n"); |
349 | 351 | ||
350 | /* wake-up system to make rail-gating delay effective immediately */ | 352 | /* wake-up system to make rail-gating delay effective immediately */ |
351 | err = gk20a_busy(g->dev); | 353 | err = gk20a_busy(g); |
352 | if (err) | 354 | if (err) |
353 | return err; | 355 | return err; |
354 | gk20a_idle(g->dev); | 356 | gk20a_idle(g); |
355 | 357 | ||
356 | return count; | 358 | return count; |
357 | } | 359 | } |
@@ -417,13 +419,13 @@ static ssize_t gk20a_load_show(struct device *dev, | |||
417 | if (!g->power_on) { | 419 | if (!g->power_on) { |
418 | busy_time = 0; | 420 | busy_time = 0; |
419 | } else { | 421 | } else { |
420 | err = gk20a_busy(g->dev); | 422 | err = gk20a_busy(g); |
421 | if (err) | 423 | if (err) |
422 | return err; | 424 | return err; |
423 | 425 | ||
424 | gk20a_pmu_load_update(g); | 426 | gk20a_pmu_load_update(g); |
425 | gk20a_pmu_load_norm(g, &busy_time); | 427 | gk20a_pmu_load_norm(g, &busy_time); |
426 | gk20a_idle(g->dev); | 428 | gk20a_idle(g); |
427 | } | 429 | } |
428 | 430 | ||
429 | res = snprintf(buf, PAGE_SIZE, "%u\n", busy_time); | 431 | res = snprintf(buf, PAGE_SIZE, "%u\n", busy_time); |
@@ -445,7 +447,7 @@ static ssize_t elpg_enable_store(struct device *dev, | |||
445 | if (!g->power_on) { | 447 | if (!g->power_on) { |
446 | g->elpg_enabled = val ? true : false; | 448 | g->elpg_enabled = val ? true : false; |
447 | } else { | 449 | } else { |
448 | err = gk20a_busy(g->dev); | 450 | err = gk20a_busy(g); |
449 | if (err) | 451 | if (err) |
450 | return -EAGAIN; | 452 | return -EAGAIN; |
451 | /* | 453 | /* |
@@ -468,7 +470,7 @@ static ssize_t elpg_enable_store(struct device *dev, | |||
468 | gk20a_pmu_pg_global_enable(g, false); | 470 | gk20a_pmu_pg_global_enable(g, false); |
469 | } | 471 | } |
470 | } | 472 | } |
471 | gk20a_idle(g->dev); | 473 | gk20a_idle(g); |
472 | } | 474 | } |
473 | dev_info(dev, "ELPG is %s.\n", g->elpg_enabled ? "enabled" : | 475 | dev_info(dev, "ELPG is %s.\n", g->elpg_enabled ? "enabled" : |
474 | "disabled"); | 476 | "disabled"); |
@@ -500,7 +502,7 @@ static ssize_t mscg_enable_store(struct device *dev, | |||
500 | if (!g->power_on) { | 502 | if (!g->power_on) { |
501 | g->mscg_enabled = val ? true : false; | 503 | g->mscg_enabled = val ? true : false; |
502 | } else { | 504 | } else { |
503 | err = gk20a_busy(g->dev); | 505 | err = gk20a_busy(g); |
504 | if (err) | 506 | if (err) |
505 | return -EAGAIN; | 507 | return -EAGAIN; |
506 | /* | 508 | /* |
@@ -532,7 +534,7 @@ static ssize_t mscg_enable_store(struct device *dev, | |||
532 | } | 534 | } |
533 | g->mscg_enabled = false; | 535 | g->mscg_enabled = false; |
534 | } | 536 | } |
535 | gk20a_idle(g->dev); | 537 | gk20a_idle(g); |
536 | } | 538 | } |
537 | dev_info(dev, "MSCG is %s.\n", g->mscg_enabled ? "enabled" : | 539 | dev_info(dev, "MSCG is %s.\n", g->mscg_enabled ? "enabled" : |
538 | "disabled"); | 540 | "disabled"); |
@@ -617,7 +619,7 @@ static ssize_t aelpg_enable_store(struct device *dev, | |||
617 | if (kstrtoul(buf, 10, &val) < 0) | 619 | if (kstrtoul(buf, 10, &val) < 0) |
618 | return -EINVAL; | 620 | return -EINVAL; |
619 | 621 | ||
620 | err = gk20a_busy(g->dev); | 622 | err = gk20a_busy(g); |
621 | if (err) | 623 | if (err) |
622 | return err; | 624 | return err; |
623 | 625 | ||
@@ -636,7 +638,7 @@ static ssize_t aelpg_enable_store(struct device *dev, | |||
636 | } else { | 638 | } else { |
637 | dev_info(dev, "PMU is not ready, AELPG request failed\n"); | 639 | dev_info(dev, "PMU is not ready, AELPG request failed\n"); |
638 | } | 640 | } |
639 | gk20a_idle(g->dev); | 641 | gk20a_idle(g); |
640 | 642 | ||
641 | dev_info(dev, "AELPG is %s.\n", g->aelpg_enabled ? "enabled" : | 643 | dev_info(dev, "AELPG is %s.\n", g->aelpg_enabled ? "enabled" : |
642 | "disabled"); | 644 | "disabled"); |
@@ -674,9 +676,9 @@ static ssize_t allow_all_enable_store(struct device *dev, | |||
674 | if (kstrtoul(buf, 10, &val) < 0) | 676 | if (kstrtoul(buf, 10, &val) < 0) |
675 | return -EINVAL; | 677 | return -EINVAL; |
676 | 678 | ||
677 | err = gk20a_busy(g->dev); | 679 | err = gk20a_busy(g); |
678 | g->allow_all = (val ? true : false); | 680 | g->allow_all = (val ? true : false); |
679 | gk20a_idle(g->dev); | 681 | gk20a_idle(g); |
680 | 682 | ||
681 | return count; | 683 | return count; |
682 | } | 684 | } |
@@ -811,7 +813,7 @@ static ssize_t tpc_fs_mask_read(struct device *dev, | |||
811 | u32 tpc_fs_mask = 0; | 813 | u32 tpc_fs_mask = 0; |
812 | int err = 0; | 814 | int err = 0; |
813 | 815 | ||
814 | err = gk20a_busy(g->dev); | 816 | err = gk20a_busy(g); |
815 | if (err) | 817 | if (err) |
816 | return err; | 818 | return err; |
817 | 819 | ||
@@ -822,7 +824,7 @@ static ssize_t tpc_fs_mask_read(struct device *dev, | |||
822 | (gr->max_tpc_per_gpc_count * gpc_index); | 824 | (gr->max_tpc_per_gpc_count * gpc_index); |
823 | } | 825 | } |
824 | 826 | ||
825 | gk20a_idle(g->dev); | 827 | gk20a_idle(g); |
826 | 828 | ||
827 | return snprintf(buf, PAGE_SIZE, "0x%x\n", tpc_fs_mask); | 829 | return snprintf(buf, PAGE_SIZE, "0x%x\n", tpc_fs_mask); |
828 | } | 830 | } |