Commit 3d7b5eb9 authored by Tomas Winkler's avatar Tomas Winkler Committed by Ben Hutchings

mei: limit the number of consecutive resets

commit 6adb8efb upstream.

give up reseting after 3 unsuccessful tries

[Backported to 3.2: files were moved]
Signed-off-by: default avatarTomas Winkler <tomas.winkler@intel.com>
Signed-off-by: default avatarAlexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 7250ff7d
...@@ -132,6 +132,7 @@ struct mei_device *mei_device_init(struct pci_dev *pdev) ...@@ -132,6 +132,7 @@ struct mei_device *mei_device_init(struct pci_dev *pdev)
init_waitqueue_head(&dev->wait_recvd_msg); init_waitqueue_head(&dev->wait_recvd_msg);
init_waitqueue_head(&dev->wait_stop_wd); init_waitqueue_head(&dev->wait_stop_wd);
dev->mei_state = MEI_INITIALIZING; dev->mei_state = MEI_INITIALIZING;
dev->reset_count = 0;
dev->iamthif_state = MEI_IAMTHIF_IDLE; dev->iamthif_state = MEI_IAMTHIF_IDLE;
dev->wd_interface_reg = false; dev->wd_interface_reg = false;
...@@ -290,6 +291,14 @@ void mei_reset(struct mei_device *dev, int interrupts_enabled) ...@@ -290,6 +291,14 @@ void mei_reset(struct mei_device *dev, int interrupts_enabled)
dev->need_reset = false; dev->need_reset = false;
dev->reset_count++;
if (dev->reset_count > MEI_MAX_CONSEC_RESET) {
dev_err(&dev->pdev->dev, "reset: reached maximal consecutive resets: disabling the device\n");
dev->mei_state = MEI_DISABLED;
return;
}
if (dev->mei_state != MEI_INITIALIZING) { if (dev->mei_state != MEI_INITIALIZING) {
if (dev->mei_state != MEI_DISABLED && if (dev->mei_state != MEI_DISABLED &&
dev->mei_state != MEI_POWER_DOWN) dev->mei_state != MEI_POWER_DOWN)
......
...@@ -770,6 +770,7 @@ static void mei_irq_thread_read_bus_message(struct mei_device *dev, ...@@ -770,6 +770,7 @@ static void mei_irq_thread_read_bus_message(struct mei_device *dev,
*/ */
bitmap_set(dev->host_clients_map, 0, 3); bitmap_set(dev->host_clients_map, 0, 3);
dev->mei_state = MEI_ENABLED; dev->mei_state = MEI_ENABLED;
dev->reset_count = 0;
/* if wd initialization fails, initialization the AMTHI client, /* if wd initialization fails, initialization the AMTHI client,
* otherwise the AMTHI client will be initialized after the WD client connect response * otherwise the AMTHI client will be initialized after the WD client connect response
...@@ -1527,7 +1528,8 @@ void mei_timer(struct work_struct *work) ...@@ -1527,7 +1528,8 @@ void mei_timer(struct work_struct *work)
} }
} }
out: out:
schedule_delayed_work(&dev->timer_work, 2 * HZ); if (dev->mei_state != MEI_DISABLED)
schedule_delayed_work(&dev->timer_work, 2 * HZ);
mutex_unlock(&dev->device_lock); mutex_unlock(&dev->device_lock);
} }
......
...@@ -63,6 +63,11 @@ extern const uuid_le mei_wd_guid; ...@@ -63,6 +63,11 @@ extern const uuid_le mei_wd_guid;
*/ */
extern const u8 mei_wd_state_independence_msg[3][4]; extern const u8 mei_wd_state_independence_msg[3][4];
/*
* maximum number of consecutive resets
*/
#define MEI_MAX_CONSEC_RESET 3
/* /*
* Number of File descriptors/handles * Number of File descriptors/handles
* that can be opened to the driver. * that can be opened to the driver.
...@@ -178,7 +183,11 @@ struct mei_io_list { ...@@ -178,7 +183,11 @@ struct mei_io_list {
int status; int status;
}; };
/* MEI private device struct */ /**
* mei_device - MEI private device struct
*
* @reset_count - limits the number of consecutive resets
*/
struct mei_device { struct mei_device {
struct pci_dev *pdev; /* pointer to pci device struct */ struct pci_dev *pdev; /* pointer to pci device struct */
/* /*
...@@ -225,6 +234,7 @@ struct mei_device { ...@@ -225,6 +234,7 @@ struct mei_device {
/* /*
* mei device states * mei device states
*/ */
unsigned long reset_count;
enum mei_states mei_state; enum mei_states mei_state;
enum mei_init_clients_states init_clients_state; enum mei_init_clients_states init_clients_state;
u16 init_clients_timer; u16 init_clients_timer;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment