From nobody Tue Apr 18 17:17:42 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Q19bV6N2Wz45NXs; Tue, 18 Apr 2023 17:17:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Q19bV5psCz3vgm; Tue, 18 Apr 2023 17:17:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681838262; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Wh3olQa5Ds4HLOZ4g+V9X+FI3zvXc7MHl3C1upbL0JY=; b=FAeu738MTWGK9ywIpK3QMG3t/pYxmU0Anw9k052FOqo1mHHr9+r+g4s+kEMan9R8nz5auI zC5ZXI68fBvz9tHQynJbQERUta+qyipKsmZFiEFyJh9hNgXITpG7gVWMDJ6I0iu/COmld9 ESJD9L7fPOQ98iJZwM6p2JG4LU2l2sjKBsXss3PmkstEhoXN1P3ZwlpSbIRkXaIojIIqkS GR9lNvvNKjluelvX/1HHrDHVejy3cTnyEvj0VY4ElG0imuCmwRpd6AgLD+q+C/iNkyaYXT J839WolyOtl/yHkwYbX/y/0Wjh5S3XvWyT/6kvk0ZVsqT85XAqcoiOqa9puJdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681838262; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Wh3olQa5Ds4HLOZ4g+V9X+FI3zvXc7MHl3C1upbL0JY=; b=NT3y00223Q9Jal8JV9mD7QM4G8pwfFD7+KtL0+g+3PQvLnkEG6vg8HfkH7b5Y3I8WY0Alf +jJSBmrdAcYBiH+IDAIvrWnv/VWWsGBfMi+fOwcBz+bKZaQqG91BPTyrBcmM1sCgZ/kWuM X8sr0xH6x6R3VF18YV4BNp13hdKAHo/SAw4UtBFuYElFvMxn9ApvexG1XoRFVt3PxhHxWL 9+NhJ0GFwDJzrbi2siHGB6rR80Eo2IPOi0tS0nW3L90/z3O+EOXC21vqKSAkSkfsK7uJXB 6F8finylQot5LLa/OpgHdroKM2r84UuIF3eYER4UaqfAV+uJitZK1f39KSaEYw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1681838262; a=rsa-sha256; cv=none; b=gn3D8HRSCUF4uXjb0PkcgbzzOyUna1gO88VCqoam8+/IHBVRvtl/GGjY0L+BgWiu/NKk4q 0Kj6rul6xlnKxsCihe7bEy8BOJF5mQSamJeLlQTl6dLANgZuh3hlGef5QkiYAXmgIAZYUh PMtKHbI16YpfWO1GcrpDYRXBhnunjh3rbUs/4zLRpqdHh28bPByDcXlcOKoWklRUedpqRO 73KT7bIvAK4noSztGVrWDwq4r2i+ll66VkGLmesiuiupRb4fOa0Df3OeoH5Frv3AQ9MsVB wAiSorguKAIKz4LmHv46+8ofBhCKpAGGtEHYBUA8kDeYCvclkZ2xiqOruAvgyA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Q19bV4vMkzKql; Tue, 18 Apr 2023 17:17:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 33IHHg60093913; Tue, 18 Apr 2023 17:17:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 33IHHgMx093912; Tue, 18 Apr 2023 17:17:42 GMT (envelope-from git) Date: Tue, 18 Apr 2023 17:17:42 GMT Message-Id: <202304181717.33IHHgMx093912@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Marius Strobl Subject: git: bd15d31cef50 - main - mmc(4): Don't call bridge driver for timings not requiring tuning List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: marius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: bd15d31cef50060d90356384ba7b878d398fc9f3 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by marius: URL: https://cgit.FreeBSD.org/src/commit/?id=bd15d31cef50060d90356384ba7b878d398fc9f3 commit bd15d31cef50060d90356384ba7b878d398fc9f3 Author: Marius Strobl AuthorDate: 2023-04-12 21:46:02 +0000 Commit: Marius Strobl CommitDate: 2023-04-18 17:17:24 +0000 mmc(4): Don't call bridge driver for timings not requiring tuning The original idea behind calling into the bridge driver was to have the logic deciding whether tuning is actually required for a particular bus timing in a given slot as well as doing the sanity checking only on the controller layer which also generally is better suited for these due to say SDHCI_SDR50_NEEDS_TUNING. On another thought, not every such driver should need to check whether tuning is required at all, though, and not everything is SDHCI in the first place. Adjust sdhci{,_fsl_fdt}(4) accordingly, but keep sdhci_generic_tune() a bit cautious still. --- sys/dev/mmc/mmc.c | 9 +++++++++ sys/dev/sdhci/sdhci.c | 6 ++++-- sys/dev/sdhci/sdhci_fsl_fdt.c | 17 +++-------------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/sys/dev/mmc/mmc.c b/sys/dev/mmc/mmc.c index 5fce6cbf47a1..54caadb2b3c7 100644 --- a/sys/dev/mmc/mmc.c +++ b/sys/dev/mmc/mmc.c @@ -2237,6 +2237,15 @@ clock: mmcbr_set_clock(dev, max_dtr); mmcbr_update_ios(dev); + /* + * Don't call into the bridge driver for timings definitely + * not requiring tuning. Note that it's up to the upper + * layer to actually execute tuning otherwise. + */ + if (timing <= bus_timing_uhs_sdr25 || + timing == bus_timing_mmc_ddr52) + goto power_class; + if (mmcbr_tune(dev, hs400) != 0) { device_printf(dev, "Card at relative address %d " "failed to execute initial tuning\n", rca); diff --git a/sys/dev/sdhci/sdhci.c b/sys/dev/sdhci/sdhci.c index a7283e66df31..69dbd3d7ffd7 100644 --- a/sys/dev/sdhci/sdhci.c +++ b/sys/dev/sdhci/sdhci.c @@ -1492,10 +1492,12 @@ sdhci_generic_tune(device_t brdev __unused, device_t reqdev, bool hs400) case bus_timing_uhs_sdr50: if (slot->opt & SDHCI_SDR50_NEEDS_TUNING) break; - /* FALLTHROUGH */ - default: SDHCI_UNLOCK(slot); return (0); + default: + slot_printf(slot, "Tuning requested but not required.\n"); + SDHCI_UNLOCK(slot); + return (EINVAL); } tune_cmd = slot->tune_cmd; diff --git a/sys/dev/sdhci/sdhci_fsl_fdt.c b/sys/dev/sdhci/sdhci_fsl_fdt.c index 470cbd169303..2c600e1291fe 100644 --- a/sys/dev/sdhci/sdhci_fsl_fdt.c +++ b/sys/dev/sdhci/sdhci_fsl_fdt.c @@ -1199,22 +1199,10 @@ sdhci_fsl_fdt_tune(device_t bus, device_t child, bool hs400) sc = device_get_softc(bus); slot = device_get_ivars(child); - error = 0; - clk_divider = sc->baseclk_hz / slot->clock; - switch (sc->slot.host.ios.timing) { - case bus_timing_mmc_hs400: - return (EINVAL); - case bus_timing_mmc_hs200: - case bus_timing_uhs_ddr50: - case bus_timing_uhs_sdr104: - break; - case bus_timing_uhs_sdr50: - if (slot->opt & SDHCI_SDR50_NEEDS_TUNING) - break; - default: + if (sc->slot.host.ios.timing == bus_timing_uhs_sdr50 && + !(slot->opt & SDHCI_SDR50_NEEDS_TUNING)) return (0); - } /* * For tuning mode SD clock divider must be within 3 to 16. @@ -1222,6 +1210,7 @@ sdhci_fsl_fdt_tune(device_t bus, device_t child, bool hs400) * For that reason we're just bailing if the dividers don't match * that requirement. */ + clk_divider = sc->baseclk_hz / slot->clock; if (clk_divider < 3 || clk_divider > 16) return (ENXIO);