Author: marius
Date: Sat Jan 13 16:21:13 2018
New Revision: 327924
URL: https://svnweb.freebsd.org/changeset/base/327924

Log:
  Fix a bug introduced in r327339; at the point in time re-tuning is
  executed, the interrupt aggregation code might have disabled the
  SDHCI_INT_DMA_END and/or SDHCI_INT_RESPONSE bits in slot->intmask
  and the SDHCI_SIGNAL_ENABLE register respectively. So when restoring
  the interrupt masks based on the previous contents of slot->intmask
  in sdhci_exec_tuning(), ensure that the SDHCI_INT_ENABLE register
  doesn't lose these two bits.
  While at it and in the spirit of r327339, let sdhci_tuning_intmask()
  set the tuning error and re-tuning interrupt bits based on the
  SDHCI_TUNING_ENABLED rather than the SDHCI_TUNING_SUPPORTED flag
  being set, i. e. only when (re-)tuning is actually used. Currently,
  this changes makes no net difference, though.

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

Modified: head/sys/dev/sdhci/sdhci.c
==============================================================================
--- head/sys/dev/sdhci/sdhci.c  Sat Jan 13 14:14:50 2018        (r327923)
+++ head/sys/dev/sdhci/sdhci.c  Sat Jan 13 16:21:13 2018        (r327924)
@@ -273,7 +273,7 @@ sdhci_tuning_intmask(struct sdhci_slot *slot)
        uint32_t intmask;
 
        intmask = 0;
-       if (slot->opt & SDHCI_TUNING_SUPPORTED) {
+       if (slot->opt & SDHCI_TUNING_ENABLED) {
                intmask |= SDHCI_INT_TUNEERR;
                if (slot->retune_mode == SDHCI_RETUNE_MODE_2 ||
                    slot->retune_mode == SDHCI_RETUNE_MODE_3)
@@ -1439,9 +1439,17 @@ sdhci_exec_tuning(struct sdhci_slot *slot, bool reset)
                        DELAY(1000);
        }
 
+       /*
+        * Restore DMA usage and interrupts.
+        * Note that the interrupt aggregation code might have cleared
+        * SDHCI_INT_DMA_END and/or SDHCI_INT_RESPONSE in slot->intmask
+        * and SDHCI_SIGNAL_ENABLE respectively so ensure SDHCI_INT_ENABLE
+        * doesn't lose these.
+        */
        slot->opt = opt;
        slot->intmask = intmask;
-       WR4(slot, SDHCI_INT_ENABLE, intmask);
+       WR4(slot, SDHCI_INT_ENABLE, intmask | SDHCI_INT_DMA_END |
+           SDHCI_INT_RESPONSE);
        WR4(slot, SDHCI_SIGNAL_ENABLE, intmask);
 
        if ((hostctrl2 & (SDHCI_CTRL2_EXEC_TUNING |
_______________________________________________
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