1 From fdd9b8655933c3eb3154fe1ed351c17b654258bd Mon Sep 17 00:00:00 2001
2 From: Alexander Usyskin <alexander.usyskin@intel.com>
3 Date: Fri, 8 Jan 2016 00:49:21 +0200
4 Subject: mei: wd: drop the watchdog code from the core mei driver
6 Instead of integrating the iAMT watchdog in the mei core driver
7 we will create a watchdog device on the mei client bus and
8 create a driver for it.
10 This patch removes the watchdog code from the mei core driver.
12 Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
13 Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
14 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
16 drivers/misc/mei/Kconfig | 6 +-
17 drivers/misc/mei/Makefile | 1 -
18 drivers/misc/mei/client.c | 12 +-
19 drivers/misc/mei/client.h | 4 -
20 drivers/misc/mei/init.c | 10 +-
21 drivers/misc/mei/interrupt.c | 15 --
22 drivers/misc/mei/mei_dev.h | 61 +------
23 drivers/misc/mei/wd.c | 391 -------------------------------------------
24 8 files changed, 9 insertions(+), 491 deletions(-)
25 delete mode 100644 drivers/misc/mei/wd.c
27 diff --git a/drivers/misc/mei/Kconfig b/drivers/misc/mei/Kconfig
28 index d23384d..c49e1d2 100644
29 --- a/drivers/misc/mei/Kconfig
30 +++ b/drivers/misc/mei/Kconfig
33 tristate "Intel Management Engine Interface"
34 - depends on X86 && PCI && WATCHDOG_CORE
35 + depends on X86 && PCI
37 The Intel Management Engine (Intel ME) provides Manageability,
38 Security and Media services for system containing Intel chipsets.
39 @@ -12,7 +12,7 @@ config INTEL_MEI
41 tristate "ME Enabled Intel Chipsets"
43 - depends on X86 && PCI && WATCHDOG_CORE
44 + depends on X86 && PCI
46 MEI support for ME Enabled Intel chipsets.
48 @@ -37,7 +37,7 @@ config INTEL_MEI_ME
50 tristate "Intel Trusted Execution Environment with ME Interface"
52 - depends on X86 && PCI && WATCHDOG_CORE
53 + depends on X86 && PCI
55 MEI Support for Trusted Execution Environment device on Intel SoCs
57 diff --git a/drivers/misc/mei/Makefile b/drivers/misc/mei/Makefile
58 index 01447ca..59e6b0a 100644
59 --- a/drivers/misc/mei/Makefile
60 +++ b/drivers/misc/mei/Makefile
61 @@ -9,7 +9,6 @@ mei-objs += interrupt.o
67 mei-objs += bus-fixup.o
68 mei-$(CONFIG_DEBUG_FS) += debugfs.o
69 diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
70 index 72e3261..e069fca 100644
71 --- a/drivers/misc/mei/client.c
72 +++ b/drivers/misc/mei/client.c
73 @@ -648,7 +648,7 @@ int mei_cl_unlink(struct mei_cl *cl)
77 - /* wd and amthif might not be initialized */
78 + /* amthif might not be initialized */
82 @@ -679,17 +679,11 @@ void mei_host_client_init(struct work_struct *work)
84 mutex_lock(&dev->device_lock);
87 me_cl = mei_me_cl_by_uuid(dev, &mei_amthif_guid);
89 mei_amthif_host_init(dev, me_cl);
92 - me_cl = mei_me_cl_by_uuid(dev, &mei_wd_guid);
94 - mei_wd_host_init(dev, me_cl);
95 - mei_me_cl_put(me_cl);
97 dev->dev_state = MEI_DEV_ENABLED;
99 mutex_unlock(&dev->device_lock);
100 @@ -1153,7 +1147,7 @@ err:
102 * Return: 1 if mei_flow_ctrl_creds >0, 0 - otherwise.
104 -int mei_cl_flow_ctrl_creds(struct mei_cl *cl)
105 +static int mei_cl_flow_ctrl_creds(struct mei_cl *cl)
109 @@ -1186,7 +1180,7 @@ int mei_cl_flow_ctrl_creds(struct mei_cl *cl)
111 * -EINVAL when ctrl credits are <= 0
113 -int mei_cl_flow_ctrl_reduce(struct mei_cl *cl)
114 +static int mei_cl_flow_ctrl_reduce(struct mei_cl *cl)
116 if (WARN_ON(!cl || !cl->me_cl))
118 diff --git a/drivers/misc/mei/client.h b/drivers/misc/mei/client.h
119 index 04e1aa3..2e90a25 100644
120 --- a/drivers/misc/mei/client.h
121 +++ b/drivers/misc/mei/client.h
123 #define _MEI_CLIENT_H_
125 #include <linux/types.h>
126 -#include <linux/watchdog.h>
127 #include <linux/poll.h>
128 #include <linux/mei.h>
130 @@ -120,9 +119,6 @@ struct mei_cl_cb *mei_cl_alloc_cb(struct mei_cl *cl, size_t length,
131 enum mei_cb_file_ops type, struct file *fp);
132 int mei_cl_flush_queues(struct mei_cl *cl, const struct file *fp);
134 -int mei_cl_flow_ctrl_creds(struct mei_cl *cl);
136 -int mei_cl_flow_ctrl_reduce(struct mei_cl *cl);
138 * MEI input output function prototype
140 diff --git a/drivers/misc/mei/init.c b/drivers/misc/mei/init.c
141 index 3edafc8..46a4302 100644
142 --- a/drivers/misc/mei/init.c
143 +++ b/drivers/misc/mei/init.c
144 @@ -156,8 +156,7 @@ int mei_reset(struct mei_device *dev)
145 mei_cl_all_wakeup(dev);
147 /* remove entry if already in list */
148 - dev_dbg(dev->dev, "remove iamthif and wd from the file list.\n");
149 - mei_cl_unlink(&dev->wd_cl);
150 + dev_dbg(dev->dev, "remove iamthif from the file list.\n");
151 mei_cl_unlink(&dev->iamthif_cl);
152 mei_amthif_reset_params(dev);
154 @@ -165,7 +164,6 @@ int mei_reset(struct mei_device *dev)
158 - dev->wd_pending = false;
161 dev_err(dev->dev, "hw_reset failed ret = %d\n", ret);
162 @@ -335,16 +333,12 @@ void mei_stop(struct mei_device *dev)
164 mutex_lock(&dev->device_lock);
168 dev->dev_state = MEI_DEV_POWER_DOWN;
170 /* move device to disabled state unconditionally */
171 dev->dev_state = MEI_DEV_DISABLED;
173 mutex_unlock(&dev->device_lock);
175 - mei_watchdog_unregister(dev);
177 EXPORT_SYMBOL_GPL(mei_stop);
179 @@ -394,7 +388,6 @@ void mei_device_init(struct mei_device *dev,
180 init_waitqueue_head(&dev->wait_hw_ready);
181 init_waitqueue_head(&dev->wait_pg);
182 init_waitqueue_head(&dev->wait_hbm_start);
183 - init_waitqueue_head(&dev->wait_stop_wd);
184 dev->dev_state = MEI_DEV_INITIALIZING;
185 dev->reset_count = 0;
187 @@ -407,7 +400,6 @@ void mei_device_init(struct mei_device *dev,
188 INIT_WORK(&dev->init_work, mei_host_client_init);
189 INIT_WORK(&dev->reset_work, mei_reset_work);
191 - INIT_LIST_HEAD(&dev->wd_cl.link);
192 INIT_LIST_HEAD(&dev->iamthif_cl.link);
193 mei_io_list_init(&dev->amthif_cmd_list);
194 mei_io_list_init(&dev->amthif_rd_complete_list);
195 diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c
196 index 64b568a..6340dee 100644
197 --- a/drivers/misc/mei/interrupt.c
198 +++ b/drivers/misc/mei/interrupt.c
199 @@ -360,21 +360,6 @@ int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list)
200 list_move_tail(&cb->list, &cmpl_list->list);
203 - if (dev->wd_state == MEI_WD_STOPPING) {
204 - dev->wd_state = MEI_WD_IDLE;
205 - wake_up(&dev->wait_stop_wd);
208 - if (mei_cl_is_connected(&dev->wd_cl)) {
209 - if (dev->wd_pending &&
210 - mei_cl_flow_ctrl_creds(&dev->wd_cl) > 0) {
211 - ret = mei_wd_send(dev);
214 - dev->wd_pending = false;
218 /* complete control write list CB */
219 dev_dbg(dev->dev, "complete control write list cb.\n");
220 list_for_each_entry_safe(cb, next, &dev->ctrl_wr_list.list, list) {
221 diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
222 index b54d9d9..da61326 100644
223 --- a/drivers/misc/mei/mei_dev.h
224 +++ b/drivers/misc/mei/mei_dev.h
228 #include <linux/types.h>
229 -#include <linux/watchdog.h>
230 +#include <linux/cdev.h>
231 #include <linux/poll.h>
232 #include <linux/mei.h>
233 #include <linux/mei_cl_bus.h>
239 - * watch dog definition
241 -#define MEI_WD_HDR_SIZE 4
242 -#define MEI_WD_STOP_MSG_SIZE MEI_WD_HDR_SIZE
243 -#define MEI_WD_START_MSG_SIZE (MEI_WD_HDR_SIZE + 16)
245 -#define MEI_WD_DEFAULT_TIMEOUT 120 /* seconds */
246 -#define MEI_WD_MIN_TIMEOUT 120 /* seconds */
247 -#define MEI_WD_MAX_TIMEOUT 65535 /* seconds */
249 -#define MEI_WD_STOP_TIMEOUT 10 /* msecs */
251 -#define MEI_WD_STATE_INDEPENDENCE_MSG_SENT (1 << 0)
253 -#define MEI_RD_MSG_BUF_SIZE (128 * sizeof(u32))
259 extern const uuid_le mei_amthif_guid;
262 - * Watchdog Client UUID
264 -extern const uuid_le mei_wd_guid;
265 +#define MEI_RD_MSG_BUF_SIZE (128 * sizeof(u32))
268 * Number of Maximum MEI Clients
269 @@ -78,7 +58,6 @@ extern const uuid_le mei_wd_guid;
271 #define MEI_HOST_CLIENT_ID_ANY (-1)
272 #define MEI_HBM_HOST_CLIENT_ID 0 /* not used, just for documentation */
273 -#define MEI_WD_HOST_CLIENT_ID 1
274 #define MEI_IAMTHIF_HOST_CLIENT_ID 2
277 @@ -123,12 +102,6 @@ enum mei_file_transaction_states {
281 -enum mei_wd_states {
288 * enum mei_cb_file_ops - file operation associated with the callback
289 * @MEI_FOP_READ: read
290 @@ -404,7 +377,6 @@ const char *mei_pg_state_str(enum mei_pg_state state);
291 * @wait_hw_ready : wait queue for receive HW ready message form FW
292 * @wait_pg : wait queue for receive PG message from FW
293 * @wait_hbm_start : wait queue for receive HBM start message from FW
294 - * @wait_stop_wd : wait queue for receive WD stop message from FW
296 * @reset_count : number of consecutive resets
297 * @dev_state : device state
298 @@ -435,12 +407,6 @@ const char *mei_pg_state_str(enum mei_pg_state state);
300 * @allow_fixed_address: allow user space to connect a fixed client
302 - * @wd_cl : watchdog client
303 - * @wd_state : watchdog client state
304 - * @wd_pending : watchdog command is pending
305 - * @wd_timeout : watchdog expiration timeout
306 - * @wd_data : watchdog message buffer
308 * @amthif_cmd_list : amthif list for cmd waiting
309 * @amthif_rd_complete_list : amthif list for reading completed cmd data
310 * @iamthif_file_object : file for current amthif operation
311 @@ -486,7 +452,6 @@ struct mei_device {
312 wait_queue_head_t wait_hw_ready;
313 wait_queue_head_t wait_pg;
314 wait_queue_head_t wait_hbm_start;
315 - wait_queue_head_t wait_stop_wd;
319 @@ -531,13 +496,6 @@ struct mei_device {
321 bool allow_fixed_address;
323 - struct mei_cl wd_cl;
324 - enum mei_wd_states wd_state;
327 - unsigned char wd_data[MEI_WD_START_MSG_SIZE];
330 /* amthif list for cmd waiting */
331 struct mei_cl_cb amthif_cmd_list;
332 /* driver managed amthif list for reading completed amthif cmd data */
333 @@ -649,21 +607,6 @@ int mei_amthif_irq_read_msg(struct mei_cl *cl,
334 struct mei_cl_cb *complete_list);
335 int mei_amthif_irq_read(struct mei_device *dev, s32 *slots);
337 -int mei_wd_send(struct mei_device *dev);
338 -int mei_wd_stop(struct mei_device *dev);
339 -int mei_wd_host_init(struct mei_device *dev, struct mei_me_client *me_cl);
341 - * mei_watchdog_register - Registering watchdog interface
342 - * once we got connection to the WD Client
345 -int mei_watchdog_register(struct mei_device *dev);
347 - * mei_watchdog_unregister - Unregistering watchdog interface
350 -void mei_watchdog_unregister(struct mei_device *dev);
353 * Register Access Function
355 diff --git a/drivers/misc/mei/wd.c b/drivers/misc/mei/wd.c
356 deleted file mode 100644
357 index b346638..0000000
358 --- a/drivers/misc/mei/wd.c
363 - * Intel Management Engine Interface (Intel MEI) Linux driver
364 - * Copyright (c) 2003-2012, Intel Corporation.
366 - * This program is free software; you can redistribute it and/or modify it
367 - * under the terms and conditions of the GNU General Public License,
368 - * version 2, as published by the Free Software Foundation.
370 - * This program is distributed in the hope it will be useful, but WITHOUT
371 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
372 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
376 -#include <linux/kernel.h>
377 -#include <linux/module.h>
378 -#include <linux/moduleparam.h>
379 -#include <linux/device.h>
380 -#include <linux/sched.h>
381 -#include <linux/watchdog.h>
383 -#include <linux/mei.h>
385 -#include "mei_dev.h"
389 -static const u8 mei_start_wd_params[] = { 0x02, 0x12, 0x13, 0x10 };
390 -static const u8 mei_stop_wd_params[] = { 0x02, 0x02, 0x14, 0x10 };
393 - * AMT Watchdog Device
395 -#define INTEL_AMT_WATCHDOG_ID "INTCAMT"
397 -/* UUIDs for AMT F/W clients */
398 -const uuid_le mei_wd_guid = UUID_LE(0x05B79A6F, 0x4628, 0x4D7F, 0x89,
399 - 0x9D, 0xA9, 0x15, 0x14, 0xCB,
402 -static void mei_wd_set_start_timeout(struct mei_device *dev, u16 timeout)
404 - dev_dbg(dev->dev, "wd: set timeout=%d.\n", timeout);
405 - memcpy(dev->wd_data, mei_start_wd_params, MEI_WD_HDR_SIZE);
406 - memcpy(dev->wd_data + MEI_WD_HDR_SIZE, &timeout, sizeof(u16));
410 - * mei_wd_host_init - connect to the watchdog client
412 - * @dev: the device structure
413 - * @me_cl: me client
415 - * Return: -ENOTTY if wd client cannot be found
416 - * -EIO if write has failed
419 -int mei_wd_host_init(struct mei_device *dev, struct mei_me_client *me_cl)
421 - struct mei_cl *cl = &dev->wd_cl;
424 - mei_cl_init(cl, dev);
426 - dev->wd_timeout = MEI_WD_DEFAULT_TIMEOUT;
427 - dev->wd_state = MEI_WD_IDLE;
429 - ret = mei_cl_link(cl, MEI_WD_HOST_CLIENT_ID);
431 - dev_info(dev->dev, "wd: failed link client\n");
435 - ret = mei_cl_connect(cl, me_cl, NULL);
437 - dev_err(dev->dev, "wd: failed to connect = %d\n", ret);
442 - ret = mei_watchdog_register(dev);
444 - mei_cl_disconnect(cl);
451 - * mei_wd_send - sends watch dog message to fw.
453 - * @dev: the device structure
455 - * Return: 0 if success,
456 - * -EIO when message send fails
457 - * -EINVAL when invalid message is to be sent
458 - * -ENODEV on flow control failure
460 -int mei_wd_send(struct mei_device *dev)
462 - struct mei_cl *cl = &dev->wd_cl;
463 - struct mei_msg_hdr hdr;
466 - hdr.host_addr = cl->host_client_id;
467 - hdr.me_addr = mei_cl_me_id(cl);
468 - hdr.msg_complete = 1;
472 - if (!memcmp(dev->wd_data, mei_start_wd_params, MEI_WD_HDR_SIZE))
473 - hdr.length = MEI_WD_START_MSG_SIZE;
474 - else if (!memcmp(dev->wd_data, mei_stop_wd_params, MEI_WD_HDR_SIZE))
475 - hdr.length = MEI_WD_STOP_MSG_SIZE;
477 - dev_err(dev->dev, "wd: invalid message is to be sent, aborting\n");
481 - ret = mei_write_message(dev, &hdr, dev->wd_data);
483 - dev_err(dev->dev, "wd: write message failed\n");
487 - ret = mei_cl_flow_ctrl_reduce(cl);
489 - dev_err(dev->dev, "wd: flow_ctrl_reduce failed.\n");
497 - * mei_wd_stop - sends watchdog stop message to fw.
499 - * @dev: the device structure
501 - * Return: 0 if success
503 - * -EIO when message send fails
504 - * -EINVAL when invalid message is to be sent
505 - * -ETIME on message timeout
507 -int mei_wd_stop(struct mei_device *dev)
509 - struct mei_cl *cl = &dev->wd_cl;
512 - if (!mei_cl_is_connected(cl) ||
513 - dev->wd_state != MEI_WD_RUNNING)
516 - memcpy(dev->wd_data, mei_stop_wd_params, MEI_WD_STOP_MSG_SIZE);
518 - dev->wd_state = MEI_WD_STOPPING;
520 - ret = mei_cl_flow_ctrl_creds(cl);
524 - if (ret && mei_hbuf_acquire(dev)) {
525 - ret = mei_wd_send(dev);
528 - dev->wd_pending = false;
530 - dev->wd_pending = true;
533 - mutex_unlock(&dev->device_lock);
535 - ret = wait_event_timeout(dev->wait_stop_wd,
536 - dev->wd_state == MEI_WD_IDLE,
537 - msecs_to_jiffies(MEI_WD_STOP_TIMEOUT));
538 - mutex_lock(&dev->device_lock);
539 - if (dev->wd_state != MEI_WD_IDLE) {
542 - dev_warn(dev->dev, "wd: stop failed to complete ret=%d\n", ret);
545 - dev_dbg(dev->dev, "wd: stop completed after %u msec\n",
546 - MEI_WD_STOP_TIMEOUT - jiffies_to_msecs(ret));
553 - * mei_wd_ops_start - wd start command from the watchdog core.
555 - * @wd_dev: watchdog device struct
557 - * Return: 0 if success, negative errno code for failure
559 -static int mei_wd_ops_start(struct watchdog_device *wd_dev)
561 - struct mei_device *dev;
565 - dev = watchdog_get_drvdata(wd_dev);
571 - mutex_lock(&dev->device_lock);
573 - if (dev->dev_state != MEI_DEV_ENABLED) {
574 - dev_dbg(dev->dev, "wd: dev_state != MEI_DEV_ENABLED dev_state = %s\n",
575 - mei_dev_state_str(dev->dev_state));
579 - if (!mei_cl_is_connected(cl)) {
580 - cl_dbg(dev, cl, "MEI Driver is not connected to Watchdog Client\n");
584 - mei_wd_set_start_timeout(dev, dev->wd_timeout);
588 - mutex_unlock(&dev->device_lock);
593 - * mei_wd_ops_stop - wd stop command from the watchdog core.
595 - * @wd_dev: watchdog device struct
597 - * Return: 0 if success, negative errno code for failure
599 -static int mei_wd_ops_stop(struct watchdog_device *wd_dev)
601 - struct mei_device *dev;
603 - dev = watchdog_get_drvdata(wd_dev);
607 - mutex_lock(&dev->device_lock);
609 - mutex_unlock(&dev->device_lock);
615 - * mei_wd_ops_ping - wd ping command from the watchdog core.
617 - * @wd_dev: watchdog device struct
619 - * Return: 0 if success, negative errno code for failure
621 -static int mei_wd_ops_ping(struct watchdog_device *wd_dev)
623 - struct mei_device *dev;
627 - dev = watchdog_get_drvdata(wd_dev);
633 - mutex_lock(&dev->device_lock);
635 - if (!mei_cl_is_connected(cl)) {
636 - cl_err(dev, cl, "wd: not connected.\n");
641 - dev->wd_state = MEI_WD_RUNNING;
643 - ret = mei_cl_flow_ctrl_creds(cl);
647 - /* Check if we can send the ping to HW*/
648 - if (ret && mei_hbuf_acquire(dev)) {
649 - dev_dbg(dev->dev, "wd: sending ping\n");
651 - ret = mei_wd_send(dev);
654 - dev->wd_pending = false;
656 - dev->wd_pending = true;
660 - mutex_unlock(&dev->device_lock);
665 - * mei_wd_ops_set_timeout - wd set timeout command from the watchdog core.
667 - * @wd_dev: watchdog device struct
668 - * @timeout: timeout value to set
670 - * Return: 0 if success, negative errno code for failure
672 -static int mei_wd_ops_set_timeout(struct watchdog_device *wd_dev,
673 - unsigned int timeout)
675 - struct mei_device *dev;
677 - dev = watchdog_get_drvdata(wd_dev);
681 - /* Check Timeout value */
682 - if (timeout < MEI_WD_MIN_TIMEOUT || timeout > MEI_WD_MAX_TIMEOUT)
685 - mutex_lock(&dev->device_lock);
687 - dev->wd_timeout = timeout;
688 - wd_dev->timeout = timeout;
689 - mei_wd_set_start_timeout(dev, dev->wd_timeout);
691 - mutex_unlock(&dev->device_lock);
697 - * Watchdog Device structs
699 -static const struct watchdog_ops wd_ops = {
700 - .owner = THIS_MODULE,
701 - .start = mei_wd_ops_start,
702 - .stop = mei_wd_ops_stop,
703 - .ping = mei_wd_ops_ping,
704 - .set_timeout = mei_wd_ops_set_timeout,
706 -static const struct watchdog_info wd_info = {
707 - .identity = INTEL_AMT_WATCHDOG_ID,
708 - .options = WDIOF_KEEPALIVEPING |
713 -static struct watchdog_device amt_wd_dev = {
716 - .timeout = MEI_WD_DEFAULT_TIMEOUT,
717 - .min_timeout = MEI_WD_MIN_TIMEOUT,
718 - .max_timeout = MEI_WD_MAX_TIMEOUT,
722 -int mei_watchdog_register(struct mei_device *dev)
727 - amt_wd_dev.parent = dev->dev;
728 - /* unlock to perserve correct locking order */
729 - mutex_unlock(&dev->device_lock);
730 - ret = watchdog_register_device(&amt_wd_dev);
731 - mutex_lock(&dev->device_lock);
733 - dev_err(dev->dev, "wd: unable to register watchdog device = %d.\n",
738 - dev_dbg(dev->dev, "wd: successfully register watchdog interface.\n");
739 - watchdog_set_drvdata(&amt_wd_dev, dev);
743 -void mei_watchdog_unregister(struct mei_device *dev)
745 - if (watchdog_get_drvdata(&amt_wd_dev) == NULL)
748 - watchdog_set_drvdata(&amt_wd_dev, NULL);
749 - watchdog_unregister_device(&amt_wd_dev);