Bug 231713 - mmc_calculate_clock() does not work properly for cards with bus_timing_normal only
Summary: mmc_calculate_clock() does not work properly for cards with bus_timing_normal...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Marius Strobl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-09-25 12:35 UTC by sebastian.huber
Modified: 2019-04-11 16:50 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description sebastian.huber 2018-09-25 12:35:17 UTC
We have

static int
mmc_calculate_clock(struct mmc_softc *sc)
{
...
	/*
	 * HS400 must be tuned in HS200 mode, so in case of HS400 we begin
	 * with HS200 following the sequence as described in "6.6.2.2 HS200
	 * timing mode selection" of the eMMC specification v5.1, too, and
	 * switch to max_timing later.  HS400ES requires no tuning and, thus,
	 * can be switch to directly, but requires the same detour via high
	 * speed mode as does HS400 (see mmc_switch_to_hs400()).
	 */
	hs400 = max_timing == bus_timing_mmc_hs400;
	timing = hs400 == true ? bus_timing_mmc_hs200 : max_timing;
	for (i = 0; i < sc->child_count; i++) {
		ivar = device_get_ivars(sc->child_list[i]);
		if ((ivar->timings & ~(1 << bus_timing_normal)) == 0)
			continue;
...
		/* Set clock (must be done before initial tuning). */
		mmcbr_set_clock(dev, max_dtr);
		mmcbr_update_ios(dev);
...
	}
	(void)mmc_select_card(sc, 0);
	return (max_dtr);
}

So, for cards with ivar->timings == bus_timing_normal the mmcbr_set_clock(dev, max_dtr) is not called. This way the clock stays at SD_MMC_CARD_ID_FREQUENCY == 400kHz. I think this problem was introduced with:

commit 398d5fc6afb7ce20f0cf9ecc4fe286e72afdbf29
Author: marius <marius@FreeBSD.org>
Date:   Sun Jul 23 16:11:47 2017 +0000

    o Add support for eMMC HS200 and HS400 bus speed modes at 200 MHz to
      sdhci(4), mmc(4) and mmcsd(4). For the most part, this consists of:
Comment 1 commit-hook freebsd_committer freebsd_triage 2018-11-17 17:22:12 UTC
A commit references this bug:

Author: marius
Date: Sat Nov 17 17:21:36 UTC 2018
New revision: 340495
URL: https://svnweb.freebsd.org/changeset/base/340495

Log:
  - Restore setting the clock for devices which support the default/legacy
    transfer mode only (lost with r321385). [1]
  - Similarly, don't try to set the power class on MMC devices that comply
    to version 4.0 of the system specification but are operated in default/
    legacy transfer or 1-bit bus mode as no power class is specified for
    these cases. Trying to set a power class nevertheless resulted in an -
    albeit harmless - error message.

  PR:	231713 [1]

Changes:
  head/sys/dev/mmc/mmc.c
Comment 2 commit-hook freebsd_committer freebsd_triage 2018-11-21 18:53:21 UTC
A commit references this bug:

Author: marius
Date: Wed Nov 21 18:53:14 UTC 2018
New revision: 340739
URL: https://svnweb.freebsd.org/changeset/base/340739

Log:
  MFC: r340495

  - Restore setting the clock for devices which support the default/legacy
    transfer mode only (lost with r321385). [1]
  - Similarly, don't try to set the power class on MMC devices that comply
    to version 4.0 of the system specification but are operated in default/
    legacy transfer or 1-bit bus mode as no power class is specified for
    these cases. Trying to set a power class nevertheless resulted in an -
    albeit harmless - error message.

  PR:	231713 [1]

Changes:
_U  stable/12/
  stable/12/sys/dev/mmc/mmc.c
Comment 3 commit-hook freebsd_committer freebsd_triage 2018-11-21 18:54:24 UTC
A commit references this bug:

Author: marius
Date: Wed Nov 21 18:53:30 UTC 2018
New revision: 340740
URL: https://svnweb.freebsd.org/changeset/base/340740

Log:
  MFC: r340495

  - Restore setting the clock for devices which support the default/legacy
    transfer mode only (lost with r321385). [1]
  - Similarly, don't try to set the power class on MMC devices that comply
    to version 4.0 of the system specification but are operated in default/
    legacy transfer or 1-bit bus mode as no power class is specified for
    these cases. Trying to set a power class nevertheless resulted in an -
    albeit harmless - error message.

  PR:	231713 [1]

Changes:
_U  stable/11/
  stable/11/sys/dev/mmc/mmc.c
Comment 4 commit-hook freebsd_committer freebsd_triage 2018-11-21 18:55:27 UTC
A commit references this bug:

Author: marius
Date: Wed Nov 21 18:54:38 UTC 2018
New revision: 340741
URL: https://svnweb.freebsd.org/changeset/base/340741

Log:
  MFC: r340495

  - Restore setting the clock for devices which support the default/legacy
    transfer mode only (lost with r321385). [1]
  - Similarly, don't try to set the power class on MMC devices that comply
    to version 4.0 of the system specification but are operated in default/
    legacy transfer or 1-bit bus mode as no power class is specified for
    these cases. Trying to set a power class nevertheless resulted in an -
    albeit harmless - error message.

  PR:	231713 [1]

Changes:
_U  stable/10/
  stable/10/sys/dev/mmc/mmc.c
Comment 5 commit-hook freebsd_committer freebsd_triage 2018-11-21 19:50:16 UTC
A commit references this bug:

Author: marius
Date: Wed Nov 21 19:49:22 UTC 2018
New revision: 340743
URL: https://svnweb.freebsd.org/changeset/base/340743

Log:
  MFC: r340495, MF12: r340739

  - Restore setting the clock for devices which support the default/legacy
    transfer mode only (lost with r321385). [1]
  - Similarly, don't try to set the power class on MMC devices that comply
    to version 4.0 of the system specification but are operated in default/
    legacy transfer or 1-bit bus mode as no power class is specified for
    these cases. Trying to set a power class nevertheless resulted in an -
    albeit harmless - error message.

  PR:		231713 [1]
  Approved by:	re (gjb)

Changes:
_U  releng/12.0/
  releng/12.0/sys/dev/mmc/mmc.c