Skip to content

Commit fe56a12

Browse files
Scott8440facebook-github-bot
authored andcommitted
Remove AccessMethod option from watchdog thrift interface
Summary: The BSP API specification is clear that watchdogs must be accessed via the chardev interface: https://www.internalfb.com/code/fbsource/[e4f6abca5b20ff588ff625c57d8425c2cb42d19f]/fbcode/fboss/docs/bsp_api_specification.md#2-2-7-fan-watchdog-watch meaning all watchdogs will be accessed with sysfs paths. No need to have the `AccessMethod` for watchdog in the fan_service thrift interface. Reviewed By: somasun Differential Revision: D68866366 fbshipit-source-id: d37e1db5e4135f41ac0f54d874add72a84c8b16d
1 parent 3478aad commit fe56a12

File tree

4 files changed

+13
-27
lines changed

4 files changed

+13
-27
lines changed

fboss/platform/configs/montblanc/fan_service.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
"pwmLowerThreshold": 25,
88
"pwmUpperThreshold": 70,
99
"watchdog": {
10-
"access": {
11-
"accessType": "ACCESS_TYPE_SYSFS",
12-
"path": "/run/devmap/watchdogs/FAN_WATCHDOG"
13-
},
10+
"sysfsPath": "/run/devmap/watchdogs/FAN_WATCHDOG",
1411
"value": 0
1512
},
1613
"controlInterval": {

fboss/platform/fan_service/Bsp.cpp

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -126,30 +126,20 @@ void Bsp::closeWatchdog() {
126126
}
127127

128128
bool Bsp::writeToWatchdog(const std::string& value) {
129-
int rc = true;
130129
std::string cmdLine;
131130
if (!config_.watchdog().has_value()) {
132-
return rc;
131+
return false;
133132
}
134-
AccessMethod access = *config_.watchdog()->access();
135-
if (*access.accessType() == constants::ACCESS_TYPE_UTIL()) {
136-
cmdLine = fmt::format("{} {}", *access.path(), value);
137-
auto [exitStatus, standardOut] = PlatformUtils().execCommand(cmdLine);
138-
rc = exitStatus;
139-
} else if (*access.accessType() == constants::ACCESS_TYPE_SYSFS()) {
140-
try {
141-
if (!watchdogFd_.has_value()) {
142-
watchdogFd_ = open(access.path()->c_str(), O_WRONLY);
143-
}
144-
rc = writeFd(watchdogFd_.value(), value);
145-
} catch (std::exception& e) {
146-
XLOG(ERR) << "Could not write to watchdog: " << e.what();
147-
return false;
133+
try {
134+
auto sysfsPath = config_.watchdog()->sysfsPath()->c_str();
135+
if (!watchdogFd_.has_value()) {
136+
watchdogFd_ = open(sysfsPath, O_WRONLY);
148137
}
149-
} else {
150-
throw facebook::fboss::FbossError("Invalid watchdog access type!");
138+
return writeFd(watchdogFd_.value(), value);
139+
} catch (std::exception& e) {
140+
XLOG(ERR) << "Could not write to watchdog: " << e.what();
141+
return false;
151142
}
152-
return rc;
153143
}
154144

155145
std::vector<std::pair<std::string, float>> Bsp::processOpticEntries(

fboss/platform/fan_service/ConfigValidator.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,8 @@ bool ConfigValidator::isValid(const FanServiceConfig& config) {
6666
}
6767

6868
if (config.watchdog()) {
69-
if (!accessMethodTypes.count(*config.watchdog()->access()->accessType())) {
70-
XLOG(ERR) << "Invalid access method for watchdog config: "
71-
<< *config.watchdog()->access()->accessType();
69+
if (!config.watchdog()->sysfsPath()->c_str()) {
70+
XLOG(ERR) << "Watchdog sysfs path must have a non-empty value";
7271
return false;
7372
}
7473
}

fboss/platform/fan_service/if/fan_service_config.thrift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ struct Fan {
8383
}
8484

8585
struct Watchdog {
86-
1: AccessMethod access;
86+
1: string sysfsPath;
8787
2: i32 value;
8888
}
8989

0 commit comments

Comments
 (0)