Skip to content

Commit

Permalink
mei: fix deadlock on mei reset
Browse files Browse the repository at this point in the history
This patch fixes 'mei: synchronize irq before initiating a reset'
The patch had introduced a deadlock between irq thread and mei_reset()
as they are both holding the same device lock.

---> device_lock:
	mei_reset()
                        <---- interrupt thread
	                        device_lock
---> synchornize_irq()
       wait on interrupt thread == (dead lock)

The fix is to call synchronize_irq
prior to call locked mei_reset function.

Cc: <[email protected]> #4.10+
Fixes: f302bb0de6ac (mei: synchronize irq before initiating a reset)
Signed-off-by: Tomas Winkler <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
tomasbw authored and gregkh committed Mar 16, 2017
1 parent 603980c commit a733ded
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/misc/mei/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ int mei_reset(struct mei_device *dev)

mei_clear_interrupts(dev);

mei_synchronize_irq(dev);

/* we're already in reset, cancel the init timer
* if the reset was called due the hbm protocol error
* we need to call it before hw start
Expand Down Expand Up @@ -304,6 +302,9 @@ static void mei_reset_work(struct work_struct *work)
container_of(work, struct mei_device, reset_work);
int ret;

mei_clear_interrupts(dev);
mei_synchronize_irq(dev);

mutex_lock(&dev->device_lock);

ret = mei_reset(dev);
Expand All @@ -328,6 +329,9 @@ void mei_stop(struct mei_device *dev)

mei_cancel_work(dev);

mei_clear_interrupts(dev);
mei_synchronize_irq(dev);

mutex_lock(&dev->device_lock);

dev->dev_state = MEI_DEV_POWER_DOWN;
Expand Down

0 comments on commit a733ded

Please sign in to comment.