From nobody Thu Nov 05 14:51:13 2026 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 4jL4xt2nYKz706YP for ; Thu, 05 Nov 2026 14:51:14 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jL4xs6S1bz3Dhv for ; Thu, 05 Nov 2026 14:51:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793890273; 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=uoZ4d8LGgw1M/FIQDJ32yEyB7241Q6lgTNiDryUsykA=; b=stGAsMx4rbCCoSrNAsoD5skkrya0WQnvRRu0bZpjtd9rajVjpfSZmzhanxGPt0xIFvs6JO xDNigELaNjWiYmKFaGdnetyrBJ6JrTDNz+4dG9ql6NuDLIZAwEKSpMa/KJ/GGGvlZOZmCi gEiyNBMJyeG6Zhfyi5GutMlrXrnAyZsiZRCncuzF/MPWt5WRdcS0lpbGAvGTYzgTsiE9xX XdBo2xFtP/Cq3L+FmTiSCY0CmErSOXcxQIYJlgYVBcV5gaQXV64Ta+93k43tY5Hydkhvp8 pKkGqqBgRJJcYyCsHNgIh5n429kmq9hMg1z8F7+XR8zkeG255FfpeQzsCu1ZKQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1793890273; b=gdVgJH/zRUy/eHjnEIi1eEUpcYxPEDPbt6Rsc2jZI2hPTF9cnMUKNjCVGVjFbJ43fy868B /RWqAhrszbX5JwlWHtIQsvQ//VDVw5be9gaQZXSvEhM0ghbYcyWD/BlHItqP/FLunm4VM3 ADO37Ld48Hh4o6lgaARh4LiIZRClEQgHxBuq9R+6ZXQe6TtnOazBQUSUgRj/YUUfdLzj65 AMhLbHv5T3gVDjKy3rxVT0XF2dFEoxsSyyh5y17NYx0Kba2MYwGN1wFmAzwfWCBKVQDrDh k35Qc6s+271yG/nxNmHCqo5vuanirp8QCLqobX70NdTOlLm57YTWofCa7CsQ/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793890273; 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=uoZ4d8LGgw1M/FIQDJ32yEyB7241Q6lgTNiDryUsykA=; b=c2n/YDoMwpZwi2PwP3gXiFthxnI+U4I/a9PxpEIxkRFsO5vhMx/rJrUH9G8/CjEFY75RVy VloGIlUR0SRWuVxniUJgwTSwSe0WMPtY87ss56L2cXCzkkQcnyAkCSvb9BGS6yKrGxexo/ G2IOu/JfuXSyBcD+ahDI5Rm6b2qW6y/2AmDGPynqCqllAu4ORGasdRRd4WhS5mG5OD68tw N2YbRQXWF+Su67Cvq8m98tr6fAaAbXFN9UxnKpjd4WpSWuM8oKeesUB5KGAB1byDGz9cTa dQr1Aid5v6SS+/YYVMvhXflxBGoawO7//tQlJlJvx6Mrj/SmbuA7nGxuGabnfQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jL4xs5tN4zv6x for ; Thu, 05 Nov 2026 14:51:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 213fb by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 05 Nov 2026 14:51:13 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Emmanuel Vadot Subject: git: 3e9ff26d2ac7 - main - sdhci: Do not reprogram an unchanged clock List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3e9ff26d2ac7979ab840b9efcf3fdebec1a289db Auto-Submitted: auto-generated Date: Thu, 05 Nov 2026 14:51:13 +0000 Message-Id: <6aec97e1.213fb.593de12e@gitrepo.freebsd.org> The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=3e9ff26d2ac7979ab840b9efcf3fdebec1a289db commit 3e9ff26d2ac7979ab840b9efcf3fdebec1a289db Author: Emmanuel Vadot AuthorDate: 2026-10-27 06:41:57 +0000 Commit: Emmanuel Vadot CommitDate: 2026-11-05 14:50:42 +0000 sdhci: Do not reprogram an unchanged clock sdhci_set_clock() compared the requested clock with slot->clock, which holds the rate that the host driver actually applied. Some drivers do not apply the requested rate: the RK3568 one maps the 400kHz identification frequency to 375kHz. The two values then never match and every update_ios call goes through SDHCI_SET_CLOCK() again, even when the clock did not change. That ends in clk_set_freq(), which takes a sleepable lock, from the done context of the mmc probe with the CAM locks held. With another thread holding the clock topology lock this panics with "sleeping thread holds CAM device lock". Remember the last requested clock in a new field and compare against it. Clear it wherever slot->clock is cleared so that a reset still forces an update. Tested on a Quartz64 Model A with an NVMe drive on the PCIe slot, where the panic was seen: 5 cold boots out of 5 attached everything. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D61012 --- sys/dev/sdhci/sdhci.c | 5 ++++- sys/dev/sdhci/sdhci.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/dev/sdhci/sdhci.c b/sys/dev/sdhci/sdhci.c index 88e790ad882a..5e2e868ccd7a 100644 --- a/sys/dev/sdhci/sdhci.c +++ b/sys/dev/sdhci/sdhci.c @@ -416,8 +416,9 @@ sdhci_set_clock(struct sdhci_slot *slot, uint32_t clock) uint16_t div; int timeout; - if (clock == slot->clock) + if (clock == slot->req_clock) return; + slot->req_clock = clock; clock = SDHCI_SET_CLOCK(slot->bus, slot, clock); slot->clock = clock; @@ -1275,11 +1276,13 @@ sdhci_generic_reset(device_t brdev __unused, struct sdhci_slot *slot, /* This is to force an update */ clock = slot->clock; slot->clock = 0; + slot->req_clock = 0; sdhci_set_clock(slot, clock); } if (mask & SDHCI_RESET_ALL) { slot->clock = 0; + slot->req_clock = 0; slot->power = 0; } diff --git a/sys/dev/sdhci/sdhci.h b/sys/dev/sdhci/sdhci.h index 423e2d642149..0ce67bfad208 100644 --- a/sys/dev/sdhci/sdhci.h +++ b/sys/dev/sdhci/sdhci.h @@ -392,6 +392,7 @@ struct sdhci_slot { uint32_t retune_ticks; /* Re-tuning callout ticks [hz] */ uint32_t intmask; /* Current interrupt mask */ uint32_t clock; /* Current clock freq. */ + uint32_t req_clock; /* Last requested clock freq. */ size_t offset; /* Data buffer offset */ uint8_t hostctrl; /* Current host control register */ uint8_t retune_count; /* Controller re-tuning count [s] */