mcdi_mon.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  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_siena_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_SIENA_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_siena_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_siena_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_siena_mcdi_rpc(efx, MC_CMD_SENSOR_INFO, inbuf,
  281. sizeof(inbuf), outbuf, sizeof(outbuf),
  282. &outlen);
  283. if (rc)
  284. return rc;
  285. if (outlen < MC_CMD_SENSOR_INFO_OUT_LENMIN)
  286. return -EIO;
  287. mask = MCDI_DWORD(outbuf, SENSOR_INFO_OUT_MASK);
  288. n_sensors += hweight32(mask & ~(1 << MC_CMD_SENSOR_PAGE0_NEXT));
  289. ++page;
  290. } while (mask & (1 << MC_CMD_SENSOR_PAGE0_NEXT));
  291. n_pages = page;
  292. /* Don't create a device if there are none */
  293. if (n_sensors == 0)
  294. return 0;
  295. rc = efx_siena_alloc_buffer(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 = kzalloc_objs(*hwmon->attrs, n_attrs);
  308. if (!hwmon->attrs) {
  309. rc = -ENOMEM;
  310. goto fail;
  311. }
  312. hwmon->group.attrs = kzalloc_objs(struct attribute *, n_attrs + 1);
  313. if (!hwmon->group.attrs) {
  314. rc = -ENOMEM;
  315. goto fail;
  316. }
  317. for (i = 0, j = -1, type = -1; ; i++) {
  318. enum efx_hwmon_type hwmon_type;
  319. const char *hwmon_prefix;
  320. unsigned hwmon_index;
  321. u16 min1, max1, min2, max2;
  322. /* Find next sensor type or exit if there is none */
  323. do {
  324. type++;
  325. if ((type % 32) == 0) {
  326. page = type / 32;
  327. j = -1;
  328. if (page == n_pages)
  329. goto hwmon_register;
  330. MCDI_SET_DWORD(inbuf, SENSOR_INFO_EXT_IN_PAGE,
  331. page);
  332. rc = efx_siena_mcdi_rpc(efx, MC_CMD_SENSOR_INFO,
  333. inbuf, sizeof(inbuf),
  334. outbuf, sizeof(outbuf),
  335. &outlen);
  336. if (rc)
  337. goto fail;
  338. if (outlen < MC_CMD_SENSOR_INFO_OUT_LENMIN) {
  339. rc = -EIO;
  340. goto fail;
  341. }
  342. mask = (MCDI_DWORD(outbuf,
  343. SENSOR_INFO_OUT_MASK) &
  344. ~(1 << MC_CMD_SENSOR_PAGE0_NEXT));
  345. /* Check again for short response */
  346. if (outlen <
  347. MC_CMD_SENSOR_INFO_OUT_LEN(hweight32(mask))) {
  348. rc = -EIO;
  349. goto fail;
  350. }
  351. }
  352. } while (!(mask & (1 << type % 32)));
  353. j++;
  354. if (type < ARRAY_SIZE(efx_mcdi_sensor_type)) {
  355. hwmon_type = efx_mcdi_sensor_type[type].hwmon_type;
  356. /* Skip sensors specific to a different port */
  357. if (hwmon_type != EFX_HWMON_UNKNOWN &&
  358. efx_mcdi_sensor_type[type].port >= 0 &&
  359. efx_mcdi_sensor_type[type].port !=
  360. efx_port_num(efx))
  361. continue;
  362. } else {
  363. hwmon_type = EFX_HWMON_UNKNOWN;
  364. }
  365. switch (hwmon_type) {
  366. case EFX_HWMON_TEMP:
  367. hwmon_prefix = "temp";
  368. hwmon_index = ++n_temp; /* 1-based */
  369. break;
  370. case EFX_HWMON_COOL:
  371. /* This is likely to be a heatsink, but there
  372. * is no convention for representing cooling
  373. * devices other than fans.
  374. */
  375. hwmon_prefix = "fan";
  376. hwmon_index = ++n_cool; /* 1-based */
  377. break;
  378. default:
  379. hwmon_prefix = "in";
  380. hwmon_index = n_in++; /* 0-based */
  381. break;
  382. case EFX_HWMON_CURR:
  383. hwmon_prefix = "curr";
  384. hwmon_index = ++n_curr; /* 1-based */
  385. break;
  386. case EFX_HWMON_POWER:
  387. hwmon_prefix = "power";
  388. hwmon_index = ++n_power; /* 1-based */
  389. break;
  390. }
  391. min1 = MCDI_ARRAY_FIELD(outbuf, SENSOR_ENTRY,
  392. SENSOR_INFO_ENTRY, j, MIN1);
  393. max1 = MCDI_ARRAY_FIELD(outbuf, SENSOR_ENTRY,
  394. SENSOR_INFO_ENTRY, j, MAX1);
  395. min2 = MCDI_ARRAY_FIELD(outbuf, SENSOR_ENTRY,
  396. SENSOR_INFO_ENTRY, j, MIN2);
  397. max2 = MCDI_ARRAY_FIELD(outbuf, SENSOR_ENTRY,
  398. SENSOR_INFO_ENTRY, j, MAX2);
  399. if (min1 != max1) {
  400. snprintf(name, sizeof(name), "%s%u_input",
  401. hwmon_prefix, hwmon_index);
  402. efx_mcdi_mon_add_attr(
  403. efx, name, efx_mcdi_mon_show_value, i, type, 0);
  404. if (hwmon_type != EFX_HWMON_POWER) {
  405. snprintf(name, sizeof(name), "%s%u_min",
  406. hwmon_prefix, hwmon_index);
  407. efx_mcdi_mon_add_attr(
  408. efx, name, efx_mcdi_mon_show_limit,
  409. i, type, min1);
  410. }
  411. snprintf(name, sizeof(name), "%s%u_max",
  412. hwmon_prefix, hwmon_index);
  413. efx_mcdi_mon_add_attr(
  414. efx, name, efx_mcdi_mon_show_limit,
  415. i, type, max1);
  416. if (min2 != max2) {
  417. /* Assume max2 is critical value.
  418. * But we have no good way to expose min2.
  419. */
  420. snprintf(name, sizeof(name), "%s%u_crit",
  421. hwmon_prefix, hwmon_index);
  422. efx_mcdi_mon_add_attr(
  423. efx, name, efx_mcdi_mon_show_limit,
  424. i, type, max2);
  425. }
  426. }
  427. snprintf(name, sizeof(name), "%s%u_alarm",
  428. hwmon_prefix, hwmon_index);
  429. efx_mcdi_mon_add_attr(
  430. efx, name, efx_mcdi_mon_show_alarm, i, type, 0);
  431. if (type < ARRAY_SIZE(efx_mcdi_sensor_type) &&
  432. efx_mcdi_sensor_type[type].label) {
  433. snprintf(name, sizeof(name), "%s%u_label",
  434. hwmon_prefix, hwmon_index);
  435. efx_mcdi_mon_add_attr(
  436. efx, name, efx_mcdi_mon_show_label, i, type, 0);
  437. }
  438. }
  439. hwmon_register:
  440. hwmon->groups[0] = &hwmon->group;
  441. hwmon->device = hwmon_device_register_with_groups(&efx->pci_dev->dev,
  442. KBUILD_MODNAME, NULL,
  443. hwmon->groups);
  444. if (IS_ERR(hwmon->device)) {
  445. rc = PTR_ERR(hwmon->device);
  446. goto fail;
  447. }
  448. return 0;
  449. fail:
  450. efx_siena_mcdi_mon_remove(efx);
  451. return rc;
  452. }
  453. void efx_siena_mcdi_mon_remove(struct efx_nic *efx)
  454. {
  455. struct efx_mcdi_mon *hwmon = efx_mcdi_mon(efx);
  456. if (hwmon->device)
  457. hwmon_device_unregister(hwmon->device);
  458. kfree(hwmon->attrs);
  459. kfree(hwmon->group.attrs);
  460. efx_siena_free_buffer(efx, &hwmon->dma_buf);
  461. }
  462. #endif /* CONFIG_SFC_SIENA_MCDI_MON */