From 78f8baa866a9e5ca35475343f55325e5073376de Mon Sep 17 00:00:00 2001 From: Marius Strobl Date: Sat, 13 Jan 2018 16:21:13 +0000 Subject: [PATCH] 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. --- sys/dev/sdhci/sdhci.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sys/dev/sdhci/sdhci.c b/sys/dev/sdhci/sdhci.c index c55fe4eb959a..ed1870546cbf 100644 --- a/sys/dev/sdhci/sdhci.c +++ b/sys/dev/sdhci/sdhci.c @@ -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 |