mcdi_mon.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /****************************************************************************
  3. * Driver for Solarflare network controllers and boards
  4. * Copyright 2011-2013 Solarflare Communications Inc.
  5. */
  6. #include <linux/bitops.h>
  7. #include <linux/slab.h>
  8. #include <linux/hwmon.h>
  9. #include <linux/stat.h>
  10. #include "net_driver.h"
  11. #include "mcdi.h"
  12. #include "mcdi_pcol.h"
  13. #include "nic.h"
  14. enum efx_hwmon_type {
  15. EFX_HWMON_UNKNOWN,
  16. EFX_HWMON_TEMP, /* temperature */
  17. EFX_HWMON_COOL, /* cooling device, probably a heatsink */
  18. EFX_HWMON_IN, /* voltage */
  19. EFX_HWMON_CURR, /* current */
  20. EFX_HWMON_POWER, /* power */
  21. EFX_HWMON_TYPES_COUNT
  22. };
  23. static const char *const efx_hwmon_unit[EFX_HWMON_TYPES_COUNT] = {
  24. [EFX_HWMON_TEMP] = " degC",
  25. [EFX_HWMON_COOL] = " rpm", /* though nonsense for a heatsink */
  26. [EFX_HWMON_IN] = " mV",
  27. [EFX_HWMON_CURR] = " mA",
  28. [EFX_HWMON_POWER] = " W",
  29. };
  30. static const struct {
  31. const char *label;
  32. enum efx_hwmon_type hwmon_type;
  33. int port;
  34. } efx_mcdi_sensor_type[] = {
  35. #define SENSOR(name, label, hwmon_type, port) \
  36. [MC_CMD_SENSOR_##name] = { label, EFX_HWMON_ ## hwmon_type, port }
  37. SENSOR(CONTROLLER_TEMP, "Controller board temp.", TEMP, -1),
  38. SENSOR(PHY_COMMON_TEMP, "PHY temp.", TEMP, -1),
  39. SENSOR(CONTROLLER_COOLING, "Controller heat sink", COOL, -1),
  40. SENSOR(PHY0_TEMP, "PHY temp.", TEMP, 0),
  41. SENSOR(PHY0_COOLING, "PHY heat sink", COOL, 0),
  42. SENSOR(PHY1_TEMP, "PHY temp.", TEMP, 1),
  43. SENSOR(PHY1_COOLING, "PHY heat sink", COOL, 1),
  44. SENSOR(IN_1V0, "1.0V supply", IN, -1),
  45. SENSOR(IN_1V2, "1.2V supply", IN, -1),
  46. SENSOR(IN_1V8, "1.8V supply", IN, -1),
  47. SENSOR(IN_2V5, "2.5V supply", IN, -1),
  48. SENSOR(IN_3V3, "3.3V supply", IN, -1),
  49. SENSOR(IN_12V0, "12.0V supply", IN, -1),
  50. SENSOR(IN_1V2A, "1.2V analogue supply", IN, -1),
  51. SENSOR(IN_VREF, "Ref. voltage", IN, -1),
  52. SENSOR(OUT_VAOE, "AOE FPGA supply", IN, -1),
  53. SENSOR(AOE_TEMP, "AOE FPGA temp.", TEMP, -1),
  54. SENSOR(PSU_AOE_TEMP, "AOE regulator temp.", TEMP, -1),
  55. SENSOR(PSU_TEMP, "Controller regulator temp.",
  56. TEMP, -1),
  57. SENSOR(FAN_0, "Fan 0", COOL, -1),
  58. SENSOR(FAN_1, "Fan 1", COOL, -1),
  59. SENSOR(FAN_2, "Fan 2", COOL, -1),
  60. SENSOR(FAN_3, "Fan 3", COOL, -1),
  61. SENSOR(FAN_4, "Fan 4", COOL, -1),
  62. SENSOR(IN_VAOE, "AOE input supply", IN, -1),
  63. SENSOR(OUT_IAOE, "AOE output current", CURR, -1),
  64. SENSOR(IN_IAOE, "AOE input current", CURR, -1),
  65. SENSOR(NIC_POWER, "Board power use", POWER, -1),
  66. SENSOR(IN_0V9, "0.9V supply", IN, -1),
  67. SENSOR(IN_I0V9, "0.9V supply current", CURR, -1),
  68. SENSOR(IN_I1V2, "1.2V supply current", CURR, -1),
  69. SENSOR(IN_0V9_ADC, "0.9V supply (ext. ADC)", IN, -1),
  70. SENSOR(CONTROLLER_2_TEMP, "Controller board temp. 2", TEMP, -1),
  71. SENSOR(VREG_INTERNAL_TEMP, "Regulator die temp.", TEMP, -1),
  72. SENSOR(VREG_0V9_TEMP, "0.9V regulator temp.", TEMP, -1),
  73. SENSOR(VREG_1V2_TEMP, "1.2V regulator temp.", TEMP, -1),
  74. SENSOR(CONTROLLER_VPTAT,
  75. "Controller PTAT voltage (int. ADC)", IN, -1),
  76. SENSOR(CONTROLLER_INTERNAL_TEMP,
  77. "Controller die temp. (int. ADC)", TEMP, -1),
  78. SENSOR(CONTROLLER_VPTAT_EXTADC,
  79. "Controller PTAT voltage (ext. ADC)", IN, -1),
  80. SENSOR(CONTROLLER_INTERNAL_TEMP_EXTADC,
  81. "Controller die temp. (ext. ADC)", TEMP, -1),
  82. SENSOR(AMBIENT_TEMP, "Ambient temp.", TEMP, -1),
  83. SENSOR(AIRFLOW, "Air flow raw", IN, -1),
  84. SENSOR(VDD08D_VSS08D_CSR, "0.9V die (int. ADC)", IN, -1),
  85. SENSOR(VDD08D_VSS08D_CSR_EXTADC, "0.9V die (ext. ADC)", IN, -1),
  86. SENSOR(HOTPOINT_TEMP, "Controller board temp. (hotpoint)", TEMP, -1),
  87. #undef SENSOR
  88. };
  89. static const char *const sensor_status_names[] = {
  90. [MC_CMD_SENSOR_STATE_OK] = "OK",
  91. [MC_CMD_SENSOR_STATE_WARNING] = "Warning",
  92. [MC_CMD_SENSOR_STATE_FATAL] = "Fatal",
  93. [MC_CMD_SENSOR_STATE_BROKEN] = "Device failure",
  94. [MC_CMD_SENSOR_STATE_NO_READING] = "No reading",
  95. };
  96. void efx_mcdi_sensor_event(struct efx_nic *efx, efx_qword_t *ev)
  97. {
  98. unsigned int type, state, value;
  99. enum efx_hwmon_type hwmon_type = EFX_HWMON_UNKNOWN;
  100. const char *name = NULL, *state_txt, *unit;
  101. type = EFX_QWORD_FIELD(*ev, MCDI_EVENT_SENSOREVT_MONITOR);
  102. state = EFX_QWORD_FIELD(*ev, MCDI_EVENT_SENSOREVT_STATE);
  103. value = EFX_QWORD_FIELD(*ev, MCDI_EVENT_SENSOREVT_VALUE);
  104. /* Deal gracefully with the board having more drivers than we
  105. * know about, but do not expect new sensor states. */
  106. if (type < ARRAY_SIZE(efx_mcdi_sensor_type)) {
  107. name = efx_mcdi_sensor_type[type].label;
  108. hwmon_type = efx_mcdi_sensor_type[type].hwmon_type;
  109. }
  110. if (!name)
  111. name = "No sensor name available";
  112. EFX_WARN_ON_PARANOID(state >= ARRAY_SIZE(sensor_status_names));
  113. state_txt = sensor_status_names[state];
  114. EFX_WARN_ON_PARANOID(hwmon_type >= EFX_HWMON_TYPES_COUNT);
  115. unit = efx_hwmon_unit[hwmon_type];
  116. if (!unit)
  117. unit = "";
  118. netif_err(efx, hw, efx->net_dev,
  119. "Sensor %d (%s) reports condition '%s' for value %d%s\n",
  120. type, name, state_txt, value, unit);
  121. }
  122. #ifdef CONFIG_SFC_MCDI_MON
  123. struct efx_mcdi_mon_attribute {
  124. struct device_attribute dev_attr;
  125. unsigned int index;
  126. unsigned int type;
  127. enum efx_hwmon_type hwmon_type;
  128. unsigned int limit_value;
  129. char name[12];
  130. };
  131. static int efx_mcdi_mon_update(struct efx_nic *efx)
  132. {
  133. struct efx_mcdi_mon *hwmon = efx_mcdi_mon(efx);
  134. MCDI_DECLARE_BUF(inbuf, MC_CMD_READ_SENSORS_EXT_IN_LEN);
  135. int rc;
  136. MCDI_SET_QWORD(inbuf, READ_SENSORS_EXT_IN_DMA_ADDR,
  137. hwmon->dma_buf.dma_addr);
  138. MCDI_SET_DWORD(inbuf, READ_SENSORS_EXT_IN_LENGTH, hwmon->dma_buf.len);
  139. rc = efx_mcdi_rpc(efx, MC_CMD_READ_SENSORS,
  140. inbuf, sizeof(inbuf), NULL, 0, NULL);
  141. if (rc == 0)
  142. hwmon->last_update = jiffies;
  143. return rc;
  144. }
  145. static int efx_mcdi_mon_get_entry(struct device *dev, unsigned int index,
  146. efx_dword_t *entry)
  147. {
  148. struct efx_nic *efx = dev_get_drvdata(dev->parent);
  149. struct efx_mcdi_mon *hwmon = efx_mcdi_mon(efx);
  150. int rc;
  151. BUILD_BUG_ON(MC_CMD_READ_SENSORS_OUT_LEN != 0);
  152. mutex_lock(&hwmon->update_lock);
  153. /* Use cached value if last update was < 1 s ago */
  154. if (time_before(jiffies, hwmon->last_update + HZ))
  155. rc = 0;
  156. else
  157. rc = efx_mcdi_mon_update(efx);
  158. /* Copy out the requested entry */
  159. *entry = ((efx_dword_t *)hwmon->dma_buf.addr)[index];
  160. mutex_unlock(&hwmon->update_lock);
  161. return rc;
  162. }
  163. static ssize_t efx_mcdi_mon_show_value(struct device *dev,
  164. struct device_attribute *attr,
  165. char *buf)
  166. {
  167. struct efx_mcdi_mon_attribute *mon_attr =
  168. container_of(attr, struct efx_mcdi_mon_attribute, dev_attr);
  169. efx_dword_t entry;
  170. unsigned int value, state;
  171. int rc;
  172. rc = efx_mcdi_mon_get_entry(dev, mon_attr->index, &entry);
  173. if (rc)
  174. return rc;
  175. state = EFX_DWORD_FIELD(entry, MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_STATE);
  176. if (state == MC_CMD_SENSOR_STATE_NO_READING)
  177. return -EBUSY;
  178. value = EFX_DWORD_FIELD(entry, MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_VALUE);
  179. switch (mon_attr->hwmon_type) {
  180. case EFX_HWMON_TEMP:
  181. /* Convert temperature from degrees to milli-degrees Celsius */
  182. value *= 1000;
  183. break;
  184. case EFX_HWMON_POWER:
  185. /* Convert power from watts to microwatts */
  186. value *= 1000000;
  187. break;
  188. default:
  189. /* No conversion needed */
  190. break;
  191. }
  192. return sprintf(buf, "%u\n", value);
  193. }
  194. static ssize_t efx_mcdi_mon_show_limit(struct device *dev,
  195. struct device_attribute *attr,
  196. char *buf)
  197. {
  198. struct efx_mcdi_mon_attribute *mon_attr =
  199. container_of(attr, struct efx_mcdi_mon_attribute, dev_attr);
  200. unsigned int value;
  201. value = mon_attr->limit_value;
  202. switch (mon_attr->hwmon_type) {
  203. case EFX_HWMON_TEMP:
  204. /* Convert temperature from degrees to milli-degrees Celsius */
  205. value *= 1000;
  206. break;
  207. case EFX_HWMON_POWER:
  208. /* Convert power from watts to microwatts */
  209. value *= 1000000;
  210. break;
  211. default:
  212. /* No conversion needed */
  213. break;
  214. }
  215. return sprintf(buf, "%u\n", value);
  216. }
  217. static ssize_t efx_mcdi_mon_show_alarm(struct device *dev,
  218. struct device_attribute *attr,
  219. char *buf)
  220. {
  221. struct efx_mcdi_mon_attribute *mon_attr =
  222. container_of(attr, struct efx_mcdi_mon_attribute, dev_attr);
  223. efx_dword_t entry;
  224. int state;
  225. int rc;
  226. rc = efx_mcdi_mon_get_entry(dev, mon_attr->index, &entry);
  227. if (rc)
  228. return rc;
  229. state = EFX_DWORD_FIELD(entry, MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_STATE);
  230. return sprintf(buf, "%d\n", state != MC_CMD_SENSOR_STATE_OK);
  231. }
  232. static ssize_t efx_mcdi_mon_show_label(struct device *dev,
  233. struct device_attribute *attr,
  234. char *buf)
  235. {
  236. struct efx_mcdi_mon_attribute *mon_attr =
  237. container_of(attr, struct efx_mcdi_mon_attribute, dev_attr);
  238. return sprintf(buf, "%s\n",
  239. efx_mcdi_sensor_type[mon_attr->type].label);
  240. }
  241. static void
  242. efx_mcdi_mon_add_attr(struct efx_nic *efx, const char *name,
  243. ssize_t (*reader)(struct device *,
  244. struct device_attribute *, char *),
  245. unsigned int index, unsigned int type,
  246. unsigned int limit_value)
  247. {
  248. struct efx_mcdi_mon *hwmon = efx_mcdi_mon(efx);
  249. struct efx_mcdi_mon_attribute *attr = &hwmon->attrs[hwmon->n_attrs];
  250. strscpy(attr->name, name, sizeof(attr->name));
  251. attr->index = index;
  252. attr->type = type;
  253. if (type < ARRAY_SIZE(efx_mcdi_sensor_type))
  254. attr->hwmon_type = efx_mcdi_sensor_type[type].hwmon_type;
  255. else
  256. attr->hwmon_type = EFX_HWMON_UNKNOWN;
  257. attr->limit_value = limit_value;
  258. sysfs_attr_init(&attr->dev_attr.attr);
  259. attr->dev_attr.attr.name = attr->name;
  260. attr->dev_attr.attr.mode = 0444;
  261. attr->dev_attr.show = reader;
  262. hwmon->group.attrs[hwmon->n_attrs++] = &attr->dev_attr.attr;
  263. }
  264. int efx_mcdi_mon_probe(struct efx_nic *efx)
  265. {
  266. unsigned int n_temp = 0, n_cool = 0, n_in = 0, n_curr = 0, n_power = 0;
  267. struct efx_mcdi_mon *hwmon = efx_mcdi_mon(efx);
  268. MCDI_DECLARE_BUF(inbuf, MC_CMD_SENSOR_INFO_EXT_IN_LEN);
  269. MCDI_DECLARE_BUF(outbuf, MC_CMD_SENSOR_INFO_OUT_LENMAX);
  270. unsigned int n_pages, n_sensors, n_attrs, page;
  271. size_t outlen;
  272. char name[12];
  273. u32 mask;
  274. int rc, i, j, type;
  275. /* Find out how many sensors are present */
  276. n_sensors = 0;
  277. page = 0;
  278. do {
  279. MCDI_SET_DWORD(inbuf, SENSOR_INFO_EXT_IN_PAGE, page);
  280. rc = efx_mcdi_rpc(efx, MC_CMD_SENSOR_INFO, inbuf, sizeof(inbuf),
  281. outbuf, sizeof(outbuf), &outlen);
  282. if (rc)
  283. return rc;
  284. if (outlen < MC_CMD_SENSOR_INFO_OUT_LENMIN)
  285. return -EIO;
  286. mask = MCDI_DWORD(outbuf, SENSOR_INFO_OUT_MASK);
  287. n_sensors += hweight32(mask & ~(1 << MC_CMD_SENSOR_PAGE0_NEXT));
  288. ++page;
  289. } while (mask & (1 << MC_CMD_SENSOR_PAGE0_NEXT));
  290. n_pages = page;
  291. /* Don't create a device if there are none */
  292. if (n_sensors == 0)
  293. return 0;
  294. rc = efx_nic_alloc_buffer(
  295. efx, &hwmon->dma_buf,
  296. n_sensors * MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_LEN,
  297. GFP_KERNEL);
  298. if (rc)
  299. return rc;
  300. mutex_init(&hwmon->update_lock);
  301. efx_mcdi_mon_update(efx);
  302. /* Allocate space for the maximum possible number of
  303. * attributes for this set of sensors:
  304. * value, min, max, crit, alarm and label for each sensor.
  305. */
  306. n_attrs = 6 * n_sensors;
  307. hwmon->attrs = kcalloc(n_attrs, sizeof(*hwmon->attrs), GFP_KERNEL);
  308. if (!hwmon->attrs) {
  309. rc = -ENOMEM;
  310. goto fail;
  311. }
  312. hwmon->group.attrs = kcalloc(n_attrs + 1, sizeof(struct attribute *),
  313. GFP_KERNEL);
  314. if (!hwmon->group.attrs) {
  315. rc = -ENOMEM;
  316. goto fail;
  317. }
  318. for (i = 0, j = -1, type = -1; ; i++) {
  319. enum efx_hwmon_type hwmon_type;
  320. const char *hwmon_prefix;
  321. unsigned hwmon_index;
  322. u16 min1, max1, min2, max2;
  323. /* Find next sensor type or exit if there is none */
  324. do {
  325. type++;
  326. if ((type % 32) == 0) {
  327. page = type / 32;
  328. j = -1;
  329. if (page == n_pages)
  330. goto hwmon_register;
  331. MCDI_SET_DWORD(inbuf, SENSOR_INFO_EXT_IN_PAGE,
  332. page);
  333. rc = efx_mcdi_rpc(efx, MC_CMD_SENSOR_INFO,
  334. inbuf, sizeof(inbuf),
  335. outbuf, sizeof(outbuf),
  336. &outlen);
  337. if (rc)
  338. goto fail;
  339. if (outlen < MC_CMD_SENSOR_INFO_OUT_LENMIN) {
  340. rc = -EIO;
  341. goto fail;
  342. }
  343. mask = (MCDI_DWORD(outbuf,
  344. SENSOR_INFO_OUT_MASK) &
  345. ~(1 << MC_CMD_SENSOR_PAGE0_NEXT));
  346. /* Check again for short response */
  347. if (outlen <
  348. MC_CMD_SENSOR_INFO_OUT_LEN(hweight32(mask))) {
  349. rc = -EIO;
  350. goto fail;
  351. }
  352. }
  353. } while (!(mask & (1 << type % 32)));
  354. j++;
  355. if (type < ARRAY_SIZE(efx_mcdi_sensor_type)) {
  356. hwmon_type = efx_mcdi_sensor_type[type].hwmon_type;
  357. /* Skip sensors specific to a different port */
  358. if (hwmon_type != EFX_HWMON_UNKNOWN &&
  359. efx_mcdi_sensor_type[type].port >= 0 &&
  360. efx_mcdi_sensor_type[type].port !=
  361. efx_port_num(efx))
  362. continue;
  363. } else {
  364. hwmon_type = EFX_HWMON_UNKNOWN;
  365. }
  366. switch (hwmon_type) {
  367. case EFX_HWMON_TEMP:
  368. hwmon_prefix = "temp";
  369. hwmon_index = ++n_temp; /* 1-based */
  370. break;
  371. case EFX_HWMON_COOL:
  372. /* This is likely to be a heatsink, but there
  373. * is no convention for representing cooling
  374. * devices other than fans.
  375. */
  376. hwmon_prefix = "fan";
  377. hwmon_index = ++n_cool; /* 1-based */
  378. break;
  379. default:
  380. hwmon_prefix = "in";
  381. hwmon_index = n_in++; /* 0-based */
  382. break;
  383. case EFX_HWMON_CURR:
  384. hwmon_prefix = "curr";
  385. hwmon_index = ++n_curr; /* 1-based */
  386. break;
  387. case EFX_HWMON_POWER:
  388. hwmon_prefix = "power";
  389. hwmon_index = ++n_power; /* 1-based */
  390. break;
  391. }
  392. min1 = MCDI_ARRAY_FIELD(outbuf, SENSOR_ENTRY,
  393. SENSOR_INFO_ENTRY, j, MIN1);
  394. max1 = MCDI_ARRAY_FIELD(outbuf, SENSOR_ENTRY,
  395. SENSOR_INFO_ENTRY, j, MAX1);
  396. min2 = MCDI_ARRAY_FIELD(outbuf, SENSOR_ENTRY,
  397. SENSOR_INFO_ENTRY, j, MIN2);
  398. max2 = MCDI_ARRAY_FIELD(outbuf, SENSOR_ENTRY,
  399. SENSOR_INFO_ENTRY, j, MAX2);
  400. if (min1 != max1) {
  401. snprintf(name, sizeof(name), "%s%u_input",
  402. hwmon_prefix, hwmon_index);
  403. efx_mcdi_mon_add_attr(
  404. efx, name, efx_mcdi_mon_show_value, i, type, 0);
  405. if (hwmon_type != EFX_HWMON_POWER) {
  406. snprintf(name, sizeof(name), "%s%u_min",
  407. hwmon_prefix, hwmon_index);
  408. efx_mcdi_mon_add_attr(
  409. efx, name, efx_mcdi_mon_show_limit,
  410. i, type, min1);
  411. }
  412. snprintf(name, sizeof(name), "%s%u_max",
  413. hwmon_prefix, hwmon_index);
  414. efx_mcdi_mon_add_attr(
  415. efx, name, efx_mcdi_mon_show_limit,
  416. i, type, max1);
  417. if (min2 != max2) {
  418. /* Assume max2 is critical value.
  419. * But we have no good way to expose min2.
  420. */
  421. snprintf(name, sizeof(name), "%s%u_crit",
  422. hwmon_prefix, hwmon_index);
  423. efx_mcdi_mon_add_attr(
  424. efx, name, efx_mcdi_mon_show_limit,
  425. i, type, max2);
  426. }
  427. }
  428. snprintf(name, sizeof(name), "%s%u_alarm",
  429. hwmon_prefix, hwmon_index);
  430. efx_mcdi_mon_add_attr(
  431. efx, name, efx_mcdi_mon_show_alarm, i, type, 0);
  432. if (type < ARRAY_SIZE(efx_mcdi_sensor_type) &&
  433. efx_mcdi_sensor_type[type].label) {
  434. snprintf(name, sizeof(name), "%s%u_label",
  435. hwmon_prefix, hwmon_index);
  436. efx_mcdi_mon_add_attr(
  437. efx, name, efx_mcdi_mon_show_label, i, type, 0);
  438. }
  439. }
  440. hwmon_register:
  441. hwmon->groups[0] = &hwmon->group;
  442. hwmon->device = hwmon_device_register_with_groups(&efx->pci_dev->dev,
  443. KBUILD_MODNAME, NULL,
  444. hwmon->groups);
  445. if (IS_ERR(hwmon->device)) {
  446. rc = PTR_ERR(hwmon->device);
  447. goto fail;
  448. }
  449. return 0;
  450. fail:
  451. efx_mcdi_mon_remove(efx);
  452. return rc;
  453. }
  454. void efx_mcdi_mon_remove(struct efx_nic *efx)
  455. {
  456. struct efx_mcdi_mon *hwmon = efx_mcdi_mon(efx);
  457. if (hwmon->device)
  458. hwmon_device_unregister(hwmon->device);
  459. kfree(hwmon->attrs);
  460. kfree(hwmon->group.attrs);
  461. efx_nic_free_buffer(efx, &hwmon->dma_buf);
  462. }
  463. #endif /* CONFIG_SFC_MCDI_MON */