From owner-svn-src-stable-11@freebsd.org Thu Mar 15 22:58:31 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A3EDAF5BA3E; Thu, 15 Mar 2018 22:58:31 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 56E047DCBC; Thu, 15 Mar 2018 22:58:31 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 51A191C2CC; Thu, 15 Mar 2018 22:58:31 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w2FMwVwO071991; Thu, 15 Mar 2018 22:58:31 GMT (envelope-from marius@FreeBSD.org) Received: (from marius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w2FMwVms071990; Thu, 15 Mar 2018 22:58:31 GMT (envelope-from marius@FreeBSD.org) Message-Id: <201803152258.w2FMwVms071990@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: marius set sender to marius@FreeBSD.org using -f From: Marius Strobl Date: Thu, 15 Mar 2018 22:58:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r331034 - stable/11/sys/dev/sdhci X-SVN-Group: stable-11 X-SVN-Commit-Author: marius X-SVN-Commit-Paths: stable/11/sys/dev/sdhci X-SVN-Commit-Revision: 331034 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Mar 2018 22:58:31 -0000 Author: marius Date: Thu Mar 15 22:58:31 2018 New Revision: 331034 URL: https://svnweb.freebsd.org/changeset/base/331034 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/11/sys/dev/sdhci/sdhci.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/sdhci/sdhci.c ============================================================================== --- stable/11/sys/dev/sdhci/sdhci.c Thu Mar 15 22:51:13 2018 (r331033) +++ stable/11/sys/dev/sdhci/sdhci.c Thu Mar 15 22:58:31 2018 (r331034) @@ -255,7 +255,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) @@ -283,7 +283,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); } @@ -575,6 +575,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); @@ -1251,6 +1252,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, @@ -1319,6 +1321,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); @@ -1349,8 +1352,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 |