summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/os/linux/sysfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/os/linux/sysfs.c')
-rw-r--r--drivers/gpu/nvgpu/os/linux/sysfs.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/drivers/gpu/nvgpu/os/linux/sysfs.c b/drivers/gpu/nvgpu/os/linux/sysfs.c
index e5995bb8..1b84e2e2 100644
--- a/drivers/gpu/nvgpu/os/linux/sysfs.c
+++ b/drivers/gpu/nvgpu/os/linux/sysfs.c
@@ -305,16 +305,17 @@ static ssize_t railgate_enable_store(struct device *dev,
305 unsigned long railgate_enable = 0; 305 unsigned long railgate_enable = 0;
306 /* dev is guaranteed to be valid here. Ok to de-reference */ 306 /* dev is guaranteed to be valid here. Ok to de-reference */
307 struct gk20a *g = get_gk20a(dev); 307 struct gk20a *g = get_gk20a(dev);
308 bool enabled = nvgpu_is_enabled(g, NVGPU_CAN_RAILGATE);
308 int err; 309 int err;
309 310
310 if (kstrtoul(buf, 10, &railgate_enable) < 0) 311 if (kstrtoul(buf, 10, &railgate_enable) < 0)
311 return -EINVAL; 312 return -EINVAL;
312 313
313 if (railgate_enable && !g->can_railgate) { 314 if (railgate_enable && !enabled) {
314 g->can_railgate = true; 315 __nvgpu_set_enabled(g, NVGPU_CAN_RAILGATE, true);
315 pm_runtime_set_autosuspend_delay(dev, g->railgate_delay); 316 pm_runtime_set_autosuspend_delay(dev, g->railgate_delay);
316 } else if (railgate_enable == 0 && g->can_railgate) { 317 } else if (railgate_enable == 0 && enabled) {
317 g->can_railgate = false; 318 __nvgpu_set_enabled(g, NVGPU_CAN_RAILGATE, false);
318 pm_runtime_set_autosuspend_delay(dev, -1); 319 pm_runtime_set_autosuspend_delay(dev, -1);
319 } 320 }
320 /* wake-up system to make rail-gating setting effective */ 321 /* wake-up system to make rail-gating setting effective */
@@ -323,8 +324,9 @@ static ssize_t railgate_enable_store(struct device *dev,
323 return err; 324 return err;
324 gk20a_idle(g); 325 gk20a_idle(g);
325 326
326 nvgpu_info(g, "railgate is %s.", g->can_railgate ? 327 nvgpu_info(g, "railgate is %s.",
327 "enabled" : "disabled"); 328 nvgpu_is_enabled(g, NVGPU_CAN_RAILGATE) ?
329 "enabled" : "disabled");
328 330
329 return count; 331 return count;
330} 332}
@@ -334,7 +336,8 @@ static ssize_t railgate_enable_read(struct device *dev,
334{ 336{
335 struct gk20a *g = get_gk20a(dev); 337 struct gk20a *g = get_gk20a(dev);
336 338
337 return snprintf(buf, PAGE_SIZE, "%d\n", g->can_railgate ? 1 : 0); 339 return snprintf(buf, PAGE_SIZE, "%d\n",
340 nvgpu_is_enabled(g, NVGPU_CAN_RAILGATE) ? 1 : 0);
338} 341}
339 342
340static DEVICE_ATTR(railgate_enable, ROOTRW, railgate_enable_read, 343static DEVICE_ATTR(railgate_enable, ROOTRW, railgate_enable_read,
@@ -349,7 +352,7 @@ static ssize_t railgate_delay_store(struct device *dev,
349 struct gk20a *g = get_gk20a(dev); 352 struct gk20a *g = get_gk20a(dev);
350 int err; 353 int err;
351 354
352 if (!g->can_railgate) { 355 if (!nvgpu_is_enabled(g, NVGPU_CAN_RAILGATE)) {
353 nvgpu_info(g, "does not support power-gating"); 356 nvgpu_info(g, "does not support power-gating");
354 return count; 357 return count;
355 } 358 }