Author: ian
Date: Mon Jan  9 17:10:50 2017
New Revision: 311797
URL: https://svnweb.freebsd.org/changeset/base/311797

Log:
  Add sdhci_handle_card_present_locked() that can be called from the interrupt
  handler which already holds the mutex, and have sdhci_handle_card_present()
  be just a tiny wrapper that does the locking for external callers.
  
  This should fix the recursive locking panics seen on rpi3.
  
  Reported by:  Shawn Webb

Modified:
  head/sys/dev/sdhci/sdhci.c

Modified: head/sys/dev/sdhci/sdhci.c
==============================================================================
--- head/sys/dev/sdhci/sdhci.c  Mon Jan  9 17:09:53 2017        (r311796)
+++ head/sys/dev/sdhci/sdhci.c  Mon Jan  9 17:10:50 2017        (r311797)
@@ -521,8 +521,8 @@ sdhci_card_task(void *arg, int pending)
        }
 }
 
-void
-sdhci_handle_card_present(struct sdhci_slot *slot, bool is_present)
+static void
+sdhci_handle_card_present_locked(struct sdhci_slot *slot, bool is_present)
 {
        bool was_present;
 
@@ -537,7 +537,6 @@ sdhci_handle_card_present(struct sdhci_s
         * because once power is removed, a full card re-init is needed, and
         * that happens by deleting and recreating the child device.
         */
-       SDHCI_LOCK(slot);
        was_present = slot->dev != NULL;
        if (!was_present && is_present) {
                taskqueue_enqueue_timeout(taskqueue_swi_giant,
@@ -545,6 +544,14 @@ sdhci_handle_card_present(struct sdhci_s
        } else if (was_present && !is_present) {
                taskqueue_enqueue(taskqueue_swi_giant, &slot->card_task);
        }
+}
+
+void
+sdhci_handle_card_present(struct sdhci_slot *slot, bool is_present)
+{
+
+       SDHCI_LOCK(slot);
+       sdhci_handle_card_present_locked(slot, is_present);
        SDHCI_UNLOCK(slot);
 }
 
@@ -1402,7 +1409,7 @@ sdhci_generic_intr(struct sdhci_slot *sl
                WR4(slot, SDHCI_SIGNAL_ENABLE, slot->intmask);
                WR4(slot, SDHCI_INT_STATUS, intmask & 
                    (SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE));
-               sdhci_handle_card_present(slot, present);
+               sdhci_handle_card_present_locked(slot, present);
                intmask &= ~(SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE);
        }
        /* Handle command interrupts. */
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to