diff options
author | Leon Yu <leoyu@nvidia.com> | 2019-10-24 22:15:57 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2019-10-25 13:10:30 -0400 |
commit | 10b3b5b1d58cbade2c8d973f80291e012efd1ad3 (patch) | |
tree | e156d8dcc691b652cfef4d7f5c42e8d5e27fba43 /drivers/gpu/nvgpu/os/linux | |
parent | bb1b3218c6e301b422b426a9c646fc9ece6fe0e2 (diff) |
nvgpu: fix railgate_enable_store
Writing same value to railgate_enable_store should be treated as nop
and made successfully. Doing so is not only an optimization for the
operation but also convention that users expect for "settings". This
change is primary for fixing a peculiar situation in the driver:
root@localhost:/sys/devices/17000000.gp10b# cat railgate_enable
0
root@localhost:/sys/devices/17000000.gp10b# echo 0 > railgate_enable
bash: echo: write error: Invalid argument
Attempt to disable railgating on a platform where railgating isn't
supported shouldn't be treated as 'invalid'. It's disabled after all.
Bug 200562094
Change-Id: I3c04934bdbaf337c33d7de9cac6d53c96b4dacae
Signed-off-by: Leon Yu <leoyu@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2225476
Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Debarshi Dutta <ddutta@nvidia.com>
Reviewed-by: Bibek Basu <bbasu@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/os/linux')
-rw-r--r-- | drivers/gpu/nvgpu/os/linux/sysfs.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/gpu/nvgpu/os/linux/sysfs.c b/drivers/gpu/nvgpu/os/linux/sysfs.c index 84a311de..221ea0ce 100644 --- a/drivers/gpu/nvgpu/os/linux/sysfs.c +++ b/drivers/gpu/nvgpu/os/linux/sysfs.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2011-2018, NVIDIA CORPORATION. All rights reserved. | 2 | * Copyright (c) 2011-2019, NVIDIA CORPORATION. All rights reserved. |
3 | * | 3 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 4 | * This program is free software; you can redistribute it and/or modify it |
5 | * under the terms and conditions of the GNU General Public License, | 5 | * under the terms and conditions of the GNU General Public License, |
@@ -266,6 +266,13 @@ static ssize_t railgate_enable_store(struct device *dev, | |||
266 | if (kstrtoul(buf, 10, &railgate_enable) < 0) | 266 | if (kstrtoul(buf, 10, &railgate_enable) < 0) |
267 | return -EINVAL; | 267 | return -EINVAL; |
268 | 268 | ||
269 | /* convert to boolean */ | ||
270 | railgate_enable = !!railgate_enable; | ||
271 | |||
272 | /* writing same value should be treated as nop and successful */ | ||
273 | if (railgate_enable == enabled) | ||
274 | goto out; | ||
275 | |||
269 | if (!platform->can_railgate_init) { | 276 | if (!platform->can_railgate_init) { |
270 | nvgpu_err(g, "Railgating is not supported"); | 277 | nvgpu_err(g, "Railgating is not supported"); |
271 | return -EINVAL; | 278 | return -EINVAL; |
@@ -274,7 +281,7 @@ static ssize_t railgate_enable_store(struct device *dev, | |||
274 | if (railgate_enable) { | 281 | if (railgate_enable) { |
275 | __nvgpu_set_enabled(g, NVGPU_CAN_RAILGATE, true); | 282 | __nvgpu_set_enabled(g, NVGPU_CAN_RAILGATE, true); |
276 | pm_runtime_set_autosuspend_delay(dev, g->railgate_delay); | 283 | pm_runtime_set_autosuspend_delay(dev, g->railgate_delay); |
277 | } else if (railgate_enable == 0 && enabled) { | 284 | } else { |
278 | __nvgpu_set_enabled(g, NVGPU_CAN_RAILGATE, false); | 285 | __nvgpu_set_enabled(g, NVGPU_CAN_RAILGATE, false); |
279 | pm_runtime_set_autosuspend_delay(dev, -1); | 286 | pm_runtime_set_autosuspend_delay(dev, -1); |
280 | } | 287 | } |
@@ -284,6 +291,7 @@ static ssize_t railgate_enable_store(struct device *dev, | |||
284 | return err; | 291 | return err; |
285 | gk20a_idle(g); | 292 | gk20a_idle(g); |
286 | 293 | ||
294 | out: | ||
287 | nvgpu_info(g, "railgate is %s.", | 295 | nvgpu_info(g, "railgate is %s.", |
288 | nvgpu_is_enabled(g, NVGPU_CAN_RAILGATE) ? | 296 | nvgpu_is_enabled(g, NVGPU_CAN_RAILGATE) ? |
289 | "enabled" : "disabled"); | 297 | "enabled" : "disabled"); |