mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-24 02:22:34 +03:00
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>
This commit is contained in:
committed by
mobile promotions
parent
bb1b3218c6
commit
10b3b5b1d5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011-2018, NVIDIA CORPORATION. All rights reserved.
|
||||
* Copyright (c) 2011-2019, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
@@ -266,6 +266,13 @@ static ssize_t railgate_enable_store(struct device *dev,
|
||||
if (kstrtoul(buf, 10, &railgate_enable) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
/* convert to boolean */
|
||||
railgate_enable = !!railgate_enable;
|
||||
|
||||
/* writing same value should be treated as nop and successful */
|
||||
if (railgate_enable == enabled)
|
||||
goto out;
|
||||
|
||||
if (!platform->can_railgate_init) {
|
||||
nvgpu_err(g, "Railgating is not supported");
|
||||
return -EINVAL;
|
||||
@@ -274,7 +281,7 @@ static ssize_t railgate_enable_store(struct device *dev,
|
||||
if (railgate_enable) {
|
||||
__nvgpu_set_enabled(g, NVGPU_CAN_RAILGATE, true);
|
||||
pm_runtime_set_autosuspend_delay(dev, g->railgate_delay);
|
||||
} else if (railgate_enable == 0 && enabled) {
|
||||
} else {
|
||||
__nvgpu_set_enabled(g, NVGPU_CAN_RAILGATE, false);
|
||||
pm_runtime_set_autosuspend_delay(dev, -1);
|
||||
}
|
||||
@@ -284,6 +291,7 @@ static ssize_t railgate_enable_store(struct device *dev,
|
||||
return err;
|
||||
gk20a_idle(g);
|
||||
|
||||
out:
|
||||
nvgpu_info(g, "railgate is %s.",
|
||||
nvgpu_is_enabled(g, NVGPU_CAN_RAILGATE) ?
|
||||
"enabled" : "disabled");
|
||||
|
||||
Reference in New Issue
Block a user