092-01-spi-Check-to-see-if-the-device-is-processing-a-messa.patch 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. cur_msg is updated under the queue lock and holds the message we are
  6. currently processing. Since currently we only ever do removals in the
  7. pump kthread it doesn't matter in what order we do things but we want
  8. to be able to push things out from the submitting thread so pull the
  9. check to see if we're currently handling a message before we check to
  10. see if the queue is idle.
  11. Signed-off-by: Mark Brown <broonie@kernel.org>
  12. ---
  13. --- a/drivers/spi/spi.c
  14. +++ b/drivers/spi/spi.c
  15. @@ -891,8 +891,16 @@ static void spi_pump_messages(struct kth
  16. bool was_busy = false;
  17. int ret;
  18. - /* Lock queue and check for queue work */
  19. + /* Lock queue */
  20. spin_lock_irqsave(&master->queue_lock, flags);
  21. +
  22. + /* Make sure we are not already running a message */
  23. + if (master->cur_msg) {
  24. + spin_unlock_irqrestore(&master->queue_lock, flags);
  25. + return;
  26. + }
  27. +
  28. + /* Check if the queue is idle */
  29. if (list_empty(&master->queue) || !master->running) {
  30. if (!master->busy) {
  31. spin_unlock_irqrestore(&master->queue_lock, flags);
  32. @@ -916,11 +924,6 @@ static void spi_pump_messages(struct kth
  33. return;
  34. }
  35. - /* Make sure we are not already running a message */
  36. - if (master->cur_msg) {
  37. - spin_unlock_irqrestore(&master->queue_lock, flags);
  38. - return;
  39. - }
  40. /* Extract head of queue */
  41. master->cur_msg =
  42. list_first_entry(&master->queue, struct spi_message, queue);