diff --git a/drivers/gpu/nvgpu/os/linux/sysfs.c b/drivers/gpu/nvgpu/os/linux/sysfs.c index 83afb091d..1f93b974d 100644 --- a/drivers/gpu/nvgpu/os/linux/sysfs.c +++ b/drivers/gpu/nvgpu/os/linux/sysfs.c @@ -279,6 +279,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; @@ -287,7 +294,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); } @@ -298,6 +305,7 @@ static ssize_t railgate_enable_store(struct device *dev, } gk20a_idle(g); +out: nvgpu_info(g, "railgate is %s.", nvgpu_is_enabled(g, NVGPU_CAN_RAILGATE) ? "enabled" : "disabled");