Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Mar 2018 22:58:34 +0000 (UTC)
From:      Marius Strobl <marius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r331035 - stable/10/sys/dev/sdhci
Message-ID:  <201803152258.w2FMwYP7072040@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: marius
Date: Thu Mar 15 22:58:34 2018
New Revision: 331035
URL: https://svnweb.freebsd.org/changeset/base/331035

Log:
  MFC: r327339, r327924
  
  - There is no need to keep the tuning error and re-tuning interrupts
    enabled (though, no interrupt generation enabled for them) all the
    time as soon as (re-)tuning is supported; only enable them and let
    them generate interrupts when actually using (re-)tuning.
  - Also disable all interrupts except SDHCI_INT_DATA_AVAIL ones while
    executing tuning and not just their signaling.
  - Set the tuning error and re-tuning interrupt enable bits based on
    the SDHCI_TUNING_ENABLED rather than the SDHCI_TUNING_SUPPORTED flag,
    i. e. only when (re-)tuning is actually used. Currently, this change
    makes no net difference, though.

Modified:
  stable/10/sys/dev/sdhci/sdhci.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/sdhci/sdhci.c
==============================================================================
--- stable/10/sys/dev/sdhci/sdhci.c	Thu Mar 15 22:58:31 2018	(r331034)
+++ stable/10/sys/dev/sdhci/sdhci.c	Thu Mar 15 22:58:34 2018	(r331035)
@@ -254,7 +254,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)
@@ -282,7 +282,7 @@ sdhci_init(struct sdhci_slot *slot)
 		slot->intmask |= SDHCI_INT_CARD_REMOVE | SDHCI_INT_CARD_INSERT;
 	}
 
-	WR4(slot, SDHCI_INT_ENABLE, slot->intmask | sdhci_tuning_intmask(slot));
+	WR4(slot, SDHCI_INT_ENABLE, slot->intmask);
 	WR4(slot, SDHCI_SIGNAL_ENABLE, slot->intmask);
 }
 
@@ -574,6 +574,7 @@ sdhci_card_task(void *arg, int pending __unused)
 			d = slot->dev;
 			slot->dev = NULL;
 			slot->intmask &= ~sdhci_tuning_intmask(slot);
+			WR4(slot, SDHCI_INT_ENABLE, slot->intmask);
 			WR4(slot, SDHCI_SIGNAL_ENABLE, slot->intmask);
 			slot->opt &= ~SDHCI_TUNING_ENABLED;
 			SDHCI_UNLOCK(slot);
@@ -1250,6 +1251,7 @@ sdhci_generic_tune(device_t brdev __unused, device_t r
 	if (err == 0) {
 		slot->opt |= SDHCI_TUNING_ENABLED;
 		slot->intmask |= sdhci_tuning_intmask(slot);
+		WR4(slot, SDHCI_INT_ENABLE, slot->intmask);
 		WR4(slot, SDHCI_SIGNAL_ENABLE, slot->intmask);
 		if (slot->retune_ticks) {
 			callout_reset(&slot->retune_callout, slot->retune_ticks,
@@ -1318,6 +1320,7 @@ sdhci_exec_tuning(struct sdhci_slot *slot, bool reset)
 	 */
 	intmask = slot->intmask;
 	slot->intmask = SDHCI_INT_DATA_AVAIL;
+	WR4(slot, SDHCI_INT_ENABLE, SDHCI_INT_DATA_AVAIL);
 	WR4(slot, SDHCI_SIGNAL_ENABLE, SDHCI_INT_DATA_AVAIL);
 
 	hostctrl2 = RD2(slot, SDHCI_HOST_CONTROL2);
@@ -1348,8 +1351,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 | SDHCI_INT_DMA_END |
+	    SDHCI_INT_RESPONSE);
 	WR4(slot, SDHCI_SIGNAL_ENABLE, intmask);
 
 	if ((hostctrl2 & (SDHCI_CTRL2_EXEC_TUNING |



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201803152258.w2FMwYP7072040>