ramips: fix cd-poll sd card remove randomly
[openwrt/openwrt.git] / target / linux / generic / patches-3.18 / 092-01-spi-Check-to-see-if-the-device-is-processing-a-messa.patch
1 From: Mark Brown <broonie@kernel.org>
2 Date: Tue, 9 Dec 2014 19:46:56 +0000
3 Subject: [PATCH] spi: Check to see if the device is processing a message
4 before we idle
5
6 cur_msg is updated under the queue lock and holds the message we are
7 currently processing. Since currently we only ever do removals in the
8 pump kthread it doesn't matter in what order we do things but we want
9 to be able to push things out from the submitting thread so pull the
10 check to see if we're currently handling a message before we check to
11 see if the queue is idle.
12
13 Signed-off-by: Mark Brown <broonie@kernel.org>
14 ---
15
16 --- a/drivers/spi/spi.c
17 +++ b/drivers/spi/spi.c
18 @@ -891,8 +891,16 @@ static void spi_pump_messages(struct kth
19 bool was_busy = false;
20 int ret;
21
22 - /* Lock queue and check for queue work */
23 + /* Lock queue */
24 spin_lock_irqsave(&master->queue_lock, flags);
25 +
26 + /* Make sure we are not already running a message */
27 + if (master->cur_msg) {
28 + spin_unlock_irqrestore(&master->queue_lock, flags);
29 + return;
30 + }
31 +
32 + /* Check if the queue is idle */
33 if (list_empty(&master->queue) || !master->running) {
34 if (!master->busy) {
35 spin_unlock_irqrestore(&master->queue_lock, flags);
36 @@ -916,11 +924,6 @@ static void spi_pump_messages(struct kth
37 return;
38 }
39
40 - /* Make sure we are not already running a message */
41 - if (master->cur_msg) {
42 - spin_unlock_irqrestore(&master->queue_lock, flags);
43 - return;
44 - }
45 /* Extract head of queue */
46 master->cur_msg =
47 list_first_entry(&master->queue, struct spi_message, queue);