mei_wdt.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727
  1. /*
  2. * Intel Management Engine Interface (Intel MEI) Linux driver
  3. * Copyright (c) 2015, Intel Corporation.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms and conditions of the GNU General Public License,
  7. * version 2, as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. */
  14. #include <linux/module.h>
  15. #include <linux/slab.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/debugfs.h>
  18. #include <linux/completion.h>
  19. #include <linux/watchdog.h>
  20. #include <linux/uuid.h>
  21. #include <linux/mei_cl_bus.h>
  22. /*
  23. * iAMT Watchdog Device
  24. */
  25. #define INTEL_AMT_WATCHDOG_ID "iamt_wdt"
  26. #define MEI_WDT_DEFAULT_TIMEOUT 120 /* seconds */
  27. #define MEI_WDT_MIN_TIMEOUT 120 /* seconds */
  28. #define MEI_WDT_MAX_TIMEOUT 65535 /* seconds */
  29. /* Commands */
  30. #define MEI_MANAGEMENT_CONTROL 0x02
  31. /* MEI Management Control version number */
  32. #define MEI_MC_VERSION_NUMBER 0x10
  33. /* Sub Commands */
  34. #define MEI_MC_START_WD_TIMER_REQ 0x13
  35. #define MEI_MC_START_WD_TIMER_RES 0x83
  36. #define MEI_WDT_STATUS_SUCCESS 0
  37. #define MEI_WDT_WDSTATE_NOT_REQUIRED 0x1
  38. #define MEI_MC_STOP_WD_TIMER_REQ 0x14
  39. /**
  40. * enum mei_wdt_state - internal watchdog state
  41. *
  42. * @MEI_WDT_PROBE: wd in probing stage
  43. * @MEI_WDT_IDLE: wd is idle and not opened
  44. * @MEI_WDT_START: wd was opened, start was called
  45. * @MEI_WDT_RUNNING: wd is expecting keep alive pings
  46. * @MEI_WDT_STOPPING: wd is stopping and will move to IDLE
  47. * @MEI_WDT_NOT_REQUIRED: wd device is not required
  48. */
  49. enum mei_wdt_state {
  50. MEI_WDT_PROBE,
  51. MEI_WDT_IDLE,
  52. MEI_WDT_START,
  53. MEI_WDT_RUNNING,
  54. MEI_WDT_STOPPING,
  55. MEI_WDT_NOT_REQUIRED,
  56. };
  57. static const char *mei_wdt_state_str(enum mei_wdt_state state)
  58. {
  59. switch (state) {
  60. case MEI_WDT_PROBE:
  61. return "PROBE";
  62. case MEI_WDT_IDLE:
  63. return "IDLE";
  64. case MEI_WDT_START:
  65. return "START";
  66. case MEI_WDT_RUNNING:
  67. return "RUNNING";
  68. case MEI_WDT_STOPPING:
  69. return "STOPPING";
  70. case MEI_WDT_NOT_REQUIRED:
  71. return "NOT_REQUIRED";
  72. default:
  73. return "unknown";
  74. }
  75. }
  76. /**
  77. * struct mei_wdt - mei watchdog driver
  78. * @wdd: watchdog device
  79. *
  80. * @cldev: mei watchdog client device
  81. * @state: watchdog internal state
  82. * @resp_required: ping required response
  83. * @response: ping response completion
  84. * @unregister: unregister worker
  85. * @reg_lock: watchdog device registration lock
  86. * @timeout: watchdog current timeout
  87. *
  88. * @dbgfs_dir: debugfs dir entry
  89. */
  90. struct mei_wdt {
  91. struct watchdog_device wdd;
  92. struct mei_cl_device *cldev;
  93. enum mei_wdt_state state;
  94. bool resp_required;
  95. struct completion response;
  96. struct work_struct unregister;
  97. struct mutex reg_lock;
  98. u16 timeout;
  99. #if IS_ENABLED(CONFIG_DEBUG_FS)
  100. struct dentry *dbgfs_dir;
  101. #endif /* CONFIG_DEBUG_FS */
  102. };
  103. /*
  104. * struct mei_mc_hdr - Management Control Command Header
  105. *
  106. * @command: Management Control (0x2)
  107. * @bytecount: Number of bytes in the message beyond this byte
  108. * @subcommand: Management Control Subcommand
  109. * @versionnumber: Management Control Version (0x10)
  110. */
  111. struct mei_mc_hdr {
  112. u8 command;
  113. u8 bytecount;
  114. u8 subcommand;
  115. u8 versionnumber;
  116. };
  117. /**
  118. * struct mei_wdt_start_request watchdog start/ping
  119. *
  120. * @hdr: Management Control Command Header
  121. * @timeout: timeout value
  122. * @reserved: reserved (legacy)
  123. */
  124. struct mei_wdt_start_request {
  125. struct mei_mc_hdr hdr;
  126. u16 timeout;
  127. u8 reserved[17];
  128. } __packed;
  129. /**
  130. * struct mei_wdt_start_response watchdog start/ping response
  131. *
  132. * @hdr: Management Control Command Header
  133. * @status: operation status
  134. * @wdstate: watchdog status bit mask
  135. */
  136. struct mei_wdt_start_response {
  137. struct mei_mc_hdr hdr;
  138. u8 status;
  139. u8 wdstate;
  140. } __packed;
  141. /**
  142. * struct mei_wdt_stop_request - watchdog stop
  143. *
  144. * @hdr: Management Control Command Header
  145. */
  146. struct mei_wdt_stop_request {
  147. struct mei_mc_hdr hdr;
  148. } __packed;
  149. /**
  150. * mei_wdt_ping - send wd start/ping command
  151. *
  152. * @wdt: mei watchdog device
  153. *
  154. * Return: 0 on success,
  155. * negative errno code on failure
  156. */
  157. static int mei_wdt_ping(struct mei_wdt *wdt)
  158. {
  159. struct mei_wdt_start_request req;
  160. const size_t req_len = sizeof(req);
  161. int ret;
  162. memset(&req, 0, req_len);
  163. req.hdr.command = MEI_MANAGEMENT_CONTROL;
  164. req.hdr.bytecount = req_len - offsetof(struct mei_mc_hdr, subcommand);
  165. req.hdr.subcommand = MEI_MC_START_WD_TIMER_REQ;
  166. req.hdr.versionnumber = MEI_MC_VERSION_NUMBER;
  167. req.timeout = wdt->timeout;
  168. ret = mei_cldev_send(wdt->cldev, (u8 *)&req, req_len);
  169. if (ret < 0)
  170. return ret;
  171. return 0;
  172. }
  173. /**
  174. * mei_wdt_stop - send wd stop command
  175. *
  176. * @wdt: mei watchdog device
  177. *
  178. * Return: 0 on success,
  179. * negative errno code on failure
  180. */
  181. static int mei_wdt_stop(struct mei_wdt *wdt)
  182. {
  183. struct mei_wdt_stop_request req;
  184. const size_t req_len = sizeof(req);
  185. int ret;
  186. memset(&req, 0, req_len);
  187. req.hdr.command = MEI_MANAGEMENT_CONTROL;
  188. req.hdr.bytecount = req_len - offsetof(struct mei_mc_hdr, subcommand);
  189. req.hdr.subcommand = MEI_MC_STOP_WD_TIMER_REQ;
  190. req.hdr.versionnumber = MEI_MC_VERSION_NUMBER;
  191. ret = mei_cldev_send(wdt->cldev, (u8 *)&req, req_len);
  192. if (ret < 0)
  193. return ret;
  194. return 0;
  195. }
  196. /**
  197. * mei_wdt_ops_start - wd start command from the watchdog core.
  198. *
  199. * @wdd: watchdog device
  200. *
  201. * Return: 0 on success or -ENODEV;
  202. */
  203. static int mei_wdt_ops_start(struct watchdog_device *wdd)
  204. {
  205. struct mei_wdt *wdt = watchdog_get_drvdata(wdd);
  206. wdt->state = MEI_WDT_START;
  207. wdd->timeout = wdt->timeout;
  208. return 0;
  209. }
  210. /**
  211. * mei_wdt_ops_stop - wd stop command from the watchdog core.
  212. *
  213. * @wdd: watchdog device
  214. *
  215. * Return: 0 if success, negative errno code for failure
  216. */
  217. static int mei_wdt_ops_stop(struct watchdog_device *wdd)
  218. {
  219. struct mei_wdt *wdt = watchdog_get_drvdata(wdd);
  220. int ret;
  221. if (wdt->state != MEI_WDT_RUNNING)
  222. return 0;
  223. wdt->state = MEI_WDT_STOPPING;
  224. ret = mei_wdt_stop(wdt);
  225. if (ret)
  226. return ret;
  227. wdt->state = MEI_WDT_IDLE;
  228. return 0;
  229. }
  230. /**
  231. * mei_wdt_ops_ping - wd ping command from the watchdog core.
  232. *
  233. * @wdd: watchdog device
  234. *
  235. * Return: 0 if success, negative errno code on failure
  236. */
  237. static int mei_wdt_ops_ping(struct watchdog_device *wdd)
  238. {
  239. struct mei_wdt *wdt = watchdog_get_drvdata(wdd);
  240. int ret;
  241. if (wdt->state != MEI_WDT_START && wdt->state != MEI_WDT_RUNNING)
  242. return 0;
  243. if (wdt->resp_required)
  244. init_completion(&wdt->response);
  245. wdt->state = MEI_WDT_RUNNING;
  246. ret = mei_wdt_ping(wdt);
  247. if (ret)
  248. return ret;
  249. if (wdt->resp_required)
  250. ret = wait_for_completion_killable(&wdt->response);
  251. return ret;
  252. }
  253. /**
  254. * mei_wdt_ops_set_timeout - wd set timeout command from the watchdog core.
  255. *
  256. * @wdd: watchdog device
  257. * @timeout: timeout value to set
  258. *
  259. * Return: 0 if success, negative errno code for failure
  260. */
  261. static int mei_wdt_ops_set_timeout(struct watchdog_device *wdd,
  262. unsigned int timeout)
  263. {
  264. struct mei_wdt *wdt = watchdog_get_drvdata(wdd);
  265. /* valid value is already checked by the caller */
  266. wdt->timeout = timeout;
  267. wdd->timeout = timeout;
  268. return 0;
  269. }
  270. static const struct watchdog_ops wd_ops = {
  271. .owner = THIS_MODULE,
  272. .start = mei_wdt_ops_start,
  273. .stop = mei_wdt_ops_stop,
  274. .ping = mei_wdt_ops_ping,
  275. .set_timeout = mei_wdt_ops_set_timeout,
  276. };
  277. /* not const as the firmware_version field need to be retrieved */
  278. static struct watchdog_info wd_info = {
  279. .identity = INTEL_AMT_WATCHDOG_ID,
  280. .options = WDIOF_KEEPALIVEPING |
  281. WDIOF_SETTIMEOUT |
  282. WDIOF_ALARMONLY,
  283. };
  284. /**
  285. * __mei_wdt_is_registered - check if wdt is registered
  286. *
  287. * @wdt: mei watchdog device
  288. *
  289. * Return: true if the wdt is registered with the watchdog subsystem
  290. * Locking: should be called under wdt->reg_lock
  291. */
  292. static inline bool __mei_wdt_is_registered(struct mei_wdt *wdt)
  293. {
  294. return !!watchdog_get_drvdata(&wdt->wdd);
  295. }
  296. /**
  297. * mei_wdt_unregister - unregister from the watchdog subsystem
  298. *
  299. * @wdt: mei watchdog device
  300. */
  301. static void mei_wdt_unregister(struct mei_wdt *wdt)
  302. {
  303. mutex_lock(&wdt->reg_lock);
  304. if (__mei_wdt_is_registered(wdt)) {
  305. watchdog_unregister_device(&wdt->wdd);
  306. watchdog_set_drvdata(&wdt->wdd, NULL);
  307. memset(&wdt->wdd, 0, sizeof(wdt->wdd));
  308. }
  309. mutex_unlock(&wdt->reg_lock);
  310. }
  311. /**
  312. * mei_wdt_register - register with the watchdog subsystem
  313. *
  314. * @wdt: mei watchdog device
  315. *
  316. * Return: 0 if success, negative errno code for failure
  317. */
  318. static int mei_wdt_register(struct mei_wdt *wdt)
  319. {
  320. struct device *dev;
  321. int ret;
  322. if (!wdt || !wdt->cldev)
  323. return -EINVAL;
  324. dev = &wdt->cldev->dev;
  325. mutex_lock(&wdt->reg_lock);
  326. if (__mei_wdt_is_registered(wdt)) {
  327. ret = 0;
  328. goto out;
  329. }
  330. wdt->wdd.info = &wd_info;
  331. wdt->wdd.ops = &wd_ops;
  332. wdt->wdd.parent = dev;
  333. wdt->wdd.timeout = MEI_WDT_DEFAULT_TIMEOUT;
  334. wdt->wdd.min_timeout = MEI_WDT_MIN_TIMEOUT;
  335. wdt->wdd.max_timeout = MEI_WDT_MAX_TIMEOUT;
  336. watchdog_set_drvdata(&wdt->wdd, wdt);
  337. watchdog_stop_on_reboot(&wdt->wdd);
  338. ret = watchdog_register_device(&wdt->wdd);
  339. if (ret) {
  340. dev_err(dev, "unable to register watchdog device = %d.\n", ret);
  341. watchdog_set_drvdata(&wdt->wdd, NULL);
  342. }
  343. wdt->state = MEI_WDT_IDLE;
  344. out:
  345. mutex_unlock(&wdt->reg_lock);
  346. return ret;
  347. }
  348. static void mei_wdt_unregister_work(struct work_struct *work)
  349. {
  350. struct mei_wdt *wdt = container_of(work, struct mei_wdt, unregister);
  351. mei_wdt_unregister(wdt);
  352. }
  353. /**
  354. * mei_wdt_event_rx - callback for data receive
  355. *
  356. * @cldev: bus device
  357. */
  358. static void mei_wdt_event_rx(struct mei_cl_device *cldev)
  359. {
  360. struct mei_wdt *wdt = mei_cldev_get_drvdata(cldev);
  361. struct mei_wdt_start_response res;
  362. const size_t res_len = sizeof(res);
  363. int ret;
  364. ret = mei_cldev_recv(wdt->cldev, (u8 *)&res, res_len);
  365. if (ret < 0) {
  366. dev_err(&cldev->dev, "failure in recv %d\n", ret);
  367. return;
  368. }
  369. /* Empty response can be sent on stop */
  370. if (ret == 0)
  371. return;
  372. if (ret < sizeof(struct mei_mc_hdr)) {
  373. dev_err(&cldev->dev, "recv small data %d\n", ret);
  374. return;
  375. }
  376. if (res.hdr.command != MEI_MANAGEMENT_CONTROL ||
  377. res.hdr.versionnumber != MEI_MC_VERSION_NUMBER) {
  378. dev_err(&cldev->dev, "wrong command received\n");
  379. return;
  380. }
  381. if (res.hdr.subcommand != MEI_MC_START_WD_TIMER_RES) {
  382. dev_warn(&cldev->dev, "unsupported command %d :%s[%d]\n",
  383. res.hdr.subcommand,
  384. mei_wdt_state_str(wdt->state),
  385. wdt->state);
  386. return;
  387. }
  388. /* Run the unregistration in a worker as this can be
  389. * run only after ping completion, otherwise the flow will
  390. * deadlock on watchdog core mutex.
  391. */
  392. if (wdt->state == MEI_WDT_RUNNING) {
  393. if (res.wdstate & MEI_WDT_WDSTATE_NOT_REQUIRED) {
  394. wdt->state = MEI_WDT_NOT_REQUIRED;
  395. schedule_work(&wdt->unregister);
  396. }
  397. goto out;
  398. }
  399. if (wdt->state == MEI_WDT_PROBE) {
  400. if (res.wdstate & MEI_WDT_WDSTATE_NOT_REQUIRED) {
  401. wdt->state = MEI_WDT_NOT_REQUIRED;
  402. } else {
  403. /* stop the watchdog and register watchdog device */
  404. mei_wdt_stop(wdt);
  405. mei_wdt_register(wdt);
  406. }
  407. return;
  408. }
  409. dev_warn(&cldev->dev, "not in correct state %s[%d]\n",
  410. mei_wdt_state_str(wdt->state), wdt->state);
  411. out:
  412. if (!completion_done(&wdt->response))
  413. complete(&wdt->response);
  414. }
  415. /*
  416. * mei_wdt_notify_event - callback for event notification
  417. *
  418. * @cldev: bus device
  419. */
  420. static void mei_wdt_notify_event(struct mei_cl_device *cldev)
  421. {
  422. struct mei_wdt *wdt = mei_cldev_get_drvdata(cldev);
  423. if (wdt->state != MEI_WDT_NOT_REQUIRED)
  424. return;
  425. mei_wdt_register(wdt);
  426. }
  427. /**
  428. * mei_wdt_event - callback for event receive
  429. *
  430. * @cldev: bus device
  431. * @events: event mask
  432. * @context: callback context
  433. */
  434. static void mei_wdt_event(struct mei_cl_device *cldev,
  435. u32 events, void *context)
  436. {
  437. if (events & BIT(MEI_CL_EVENT_RX))
  438. mei_wdt_event_rx(cldev);
  439. if (events & BIT(MEI_CL_EVENT_NOTIF))
  440. mei_wdt_notify_event(cldev);
  441. }
  442. #if IS_ENABLED(CONFIG_DEBUG_FS)
  443. static ssize_t mei_dbgfs_read_activation(struct file *file, char __user *ubuf,
  444. size_t cnt, loff_t *ppos)
  445. {
  446. struct mei_wdt *wdt = file->private_data;
  447. const size_t bufsz = 32;
  448. char buf[32];
  449. ssize_t pos;
  450. mutex_lock(&wdt->reg_lock);
  451. pos = scnprintf(buf, bufsz, "%s\n",
  452. __mei_wdt_is_registered(wdt) ? "activated" : "deactivated");
  453. mutex_unlock(&wdt->reg_lock);
  454. return simple_read_from_buffer(ubuf, cnt, ppos, buf, pos);
  455. }
  456. static const struct file_operations dbgfs_fops_activation = {
  457. .open = simple_open,
  458. .read = mei_dbgfs_read_activation,
  459. .llseek = generic_file_llseek,
  460. };
  461. static ssize_t mei_dbgfs_read_state(struct file *file, char __user *ubuf,
  462. size_t cnt, loff_t *ppos)
  463. {
  464. struct mei_wdt *wdt = file->private_data;
  465. const size_t bufsz = 32;
  466. char buf[bufsz];
  467. ssize_t pos;
  468. pos = scnprintf(buf, bufsz, "state: %s\n",
  469. mei_wdt_state_str(wdt->state));
  470. return simple_read_from_buffer(ubuf, cnt, ppos, buf, pos);
  471. }
  472. static const struct file_operations dbgfs_fops_state = {
  473. .open = simple_open,
  474. .read = mei_dbgfs_read_state,
  475. .llseek = generic_file_llseek,
  476. };
  477. static void dbgfs_unregister(struct mei_wdt *wdt)
  478. {
  479. debugfs_remove_recursive(wdt->dbgfs_dir);
  480. wdt->dbgfs_dir = NULL;
  481. }
  482. static int dbgfs_register(struct mei_wdt *wdt)
  483. {
  484. struct dentry *dir, *f;
  485. dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
  486. if (!dir)
  487. return -ENOMEM;
  488. wdt->dbgfs_dir = dir;
  489. f = debugfs_create_file("state", S_IRUSR, dir, wdt, &dbgfs_fops_state);
  490. if (!f)
  491. goto err;
  492. f = debugfs_create_file("activation", S_IRUSR,
  493. dir, wdt, &dbgfs_fops_activation);
  494. if (!f)
  495. goto err;
  496. return 0;
  497. err:
  498. dbgfs_unregister(wdt);
  499. return -ENODEV;
  500. }
  501. #else
  502. static inline void dbgfs_unregister(struct mei_wdt *wdt) {}
  503. static inline int dbgfs_register(struct mei_wdt *wdt)
  504. {
  505. return 0;
  506. }
  507. #endif /* CONFIG_DEBUG_FS */
  508. static int mei_wdt_probe(struct mei_cl_device *cldev,
  509. const struct mei_cl_device_id *id)
  510. {
  511. struct mei_wdt *wdt;
  512. int ret;
  513. wdt = kzalloc(sizeof(struct mei_wdt), GFP_KERNEL);
  514. if (!wdt)
  515. return -ENOMEM;
  516. wdt->timeout = MEI_WDT_DEFAULT_TIMEOUT;
  517. wdt->state = MEI_WDT_PROBE;
  518. wdt->cldev = cldev;
  519. wdt->resp_required = mei_cldev_ver(cldev) > 0x1;
  520. mutex_init(&wdt->reg_lock);
  521. init_completion(&wdt->response);
  522. INIT_WORK(&wdt->unregister, mei_wdt_unregister_work);
  523. mei_cldev_set_drvdata(cldev, wdt);
  524. ret = mei_cldev_enable(cldev);
  525. if (ret < 0) {
  526. dev_err(&cldev->dev, "Could not enable cl device\n");
  527. goto err_out;
  528. }
  529. ret = mei_cldev_register_event_cb(wdt->cldev,
  530. BIT(MEI_CL_EVENT_RX) |
  531. BIT(MEI_CL_EVENT_NOTIF),
  532. mei_wdt_event, NULL);
  533. /* on legacy devices notification is not supported
  534. * this doesn't fail the registration for RX event
  535. */
  536. if (ret && ret != -EOPNOTSUPP) {
  537. dev_err(&cldev->dev, "Could not register event ret=%d\n", ret);
  538. goto err_disable;
  539. }
  540. wd_info.firmware_version = mei_cldev_ver(cldev);
  541. if (wdt->resp_required)
  542. ret = mei_wdt_ping(wdt);
  543. else
  544. ret = mei_wdt_register(wdt);
  545. if (ret)
  546. goto err_disable;
  547. if (dbgfs_register(wdt))
  548. dev_warn(&cldev->dev, "cannot register debugfs\n");
  549. return 0;
  550. err_disable:
  551. mei_cldev_disable(cldev);
  552. err_out:
  553. kfree(wdt);
  554. return ret;
  555. }
  556. static int mei_wdt_remove(struct mei_cl_device *cldev)
  557. {
  558. struct mei_wdt *wdt = mei_cldev_get_drvdata(cldev);
  559. /* Free the caller in case of fw initiated or unexpected reset */
  560. if (!completion_done(&wdt->response))
  561. complete(&wdt->response);
  562. cancel_work_sync(&wdt->unregister);
  563. mei_wdt_unregister(wdt);
  564. mei_cldev_disable(cldev);
  565. dbgfs_unregister(wdt);
  566. kfree(wdt);
  567. return 0;
  568. }
  569. #define MEI_UUID_WD UUID_LE(0x05B79A6F, 0x4628, 0x4D7F, \
  570. 0x89, 0x9D, 0xA9, 0x15, 0x14, 0xCB, 0x32, 0xAB)
  571. static struct mei_cl_device_id mei_wdt_tbl[] = {
  572. { .uuid = MEI_UUID_WD, .version = MEI_CL_VERSION_ANY },
  573. /* required last entry */
  574. { }
  575. };
  576. MODULE_DEVICE_TABLE(mei, mei_wdt_tbl);
  577. static struct mei_cl_driver mei_wdt_driver = {
  578. .id_table = mei_wdt_tbl,
  579. .name = KBUILD_MODNAME,
  580. .probe = mei_wdt_probe,
  581. .remove = mei_wdt_remove,
  582. };
  583. static int __init mei_wdt_init(void)
  584. {
  585. int ret;
  586. ret = mei_cldev_driver_register(&mei_wdt_driver);
  587. if (ret) {
  588. pr_err(KBUILD_MODNAME ": module registration failed\n");
  589. return ret;
  590. }
  591. return 0;
  592. }
  593. static void __exit mei_wdt_exit(void)
  594. {
  595. mei_cldev_driver_unregister(&mei_wdt_driver);
  596. }
  597. module_init(mei_wdt_init);
  598. module_exit(mei_wdt_exit);
  599. MODULE_AUTHOR("Intel Corporation");
  600. MODULE_LICENSE("GPL");
  601. MODULE_DESCRIPTION("Device driver for Intel MEI iAMT watchdog");