浏览代码

spi: Check to see if the device is processing a message before we idle

cur_msg is updated under the queue lock and holds the message we are
currently processing. Since currently we only ever do removals in the
pump kthread it doesn't matter in what order we do things but we want
to be able to push things out from the submitting thread so pull the
check to see if we're currently handling a message before we check to
see if the queue is idle.

Signed-off-by: Mark Brown <broonie@kernel.org>
Mark Brown 11 年之前
父节点
当前提交
983aee5d70
共有 1 个文件被更改,包括 9 次插入6 次删除
  1. 9 6
      drivers/spi/spi.c

+ 9 - 6
drivers/spi/spi.c

@@ -891,8 +891,16 @@ static void spi_pump_messages(struct kthread_work *work)
 	bool was_busy = false;
 	bool was_busy = false;
 	int ret;
 	int ret;
 
 
-	/* Lock queue and check for queue work */
+	/* Lock queue */
 	spin_lock_irqsave(&master->queue_lock, flags);
 	spin_lock_irqsave(&master->queue_lock, flags);
+
+	/* Make sure we are not already running a message */
+	if (master->cur_msg) {
+		spin_unlock_irqrestore(&master->queue_lock, flags);
+		return;
+	}
+
+	/* Check if the queue is idle */
 	if (list_empty(&master->queue) || !master->running) {
 	if (list_empty(&master->queue) || !master->running) {
 		if (!master->busy) {
 		if (!master->busy) {
 			spin_unlock_irqrestore(&master->queue_lock, flags);
 			spin_unlock_irqrestore(&master->queue_lock, flags);
@@ -916,11 +924,6 @@ static void spi_pump_messages(struct kthread_work *work)
 		return;
 		return;
 	}
 	}
 
 
-	/* Make sure we are not already running a message */
-	if (master->cur_msg) {
-		spin_unlock_irqrestore(&master->queue_lock, flags);
-		return;
-	}
 	/* Extract head of queue */
 	/* Extract head of queue */
 	master->cur_msg =
 	master->cur_msg =
 		list_first_entry(&master->queue, struct spi_message, queue);
 		list_first_entry(&master->queue, struct spi_message, queue);