From: Sarthak Garg <sarthak.garg@oss.qualcomm.com>
To: Bjorn Andersson <andersson@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>,
Ulf Hansson <ulf.hansson@linaro.org>,
linux-mmc@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-kernel@vger.kernel.org, quic_nguyenb@quicinc.com,
quic_rampraka@quicinc.com, quic_pragalla@quicinc.com,
quic_sayalil@quicinc.com, quic_nitirawa@quicinc.com,
quic_bhaskarv@quicinc.com, kernel@oss.qualcomm.com
Subject: Re: [PATCH V1] mmc: sdhci-msm: Avoid early clock doubling during HS400 transition
Date: Fri, 14 Nov 2025 14:02:55 +0530 [thread overview]
Message-ID: <5dcd735d-31bf-4c7f-bf12-89a5cae0d628@oss.qualcomm.com> (raw)
In-Reply-To: <wshfjbdjmoe5hfsmh2rrwxiy67wo4k6i7bzap4hz4n5j22uiol@xz7wfxaw4bve>
On 11/10/2025 8:09 PM, Bjorn Andersson wrote:
> On Mon, Nov 10, 2025 at 12:08:01PM +0530, Sarthak Garg wrote:
>> According to the hardware programming guide, the clock frequency must
>> remain below 52MHz during the transition to HS400 mode.
>>
>> However,in the current implementation, the timing is set to HS400 (a
>> DDR mode) before adjusting the clock. This causes the clock to double
>> prematurely to 104MHz during the transition phase, violating the
>> specification and potentially resulting in CRC errors or CMD timeouts.
>>
>> This change ensures that clock doubling is avoided during intermediate
>> transitions and is applied only when the card requires a 200MHz clock
>> for HS400 operation.
>>
>> Signed-off-by: Sarthak Garg <sarthak.garg@oss.qualcomm.com>
>> ---
>> drivers/mmc/host/sdhci-msm.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
>> index 4e5edbf2fc9b..eca6a09a4547 100644
>> --- a/drivers/mmc/host/sdhci-msm.c
>> +++ b/drivers/mmc/host/sdhci-msm.c
>> @@ -355,7 +355,8 @@ static unsigned int msm_get_clock_mult_for_bus_mode(struct sdhci_host *host)
>> */
>> if (ios.timing == MMC_TIMING_UHS_DDR50 ||
>> ios.timing == MMC_TIMING_MMC_DDR52 ||
>> - ios.timing == MMC_TIMING_MMC_HS400 ||
>> + (ios.timing == MMC_TIMING_MMC_HS400 &&
>> + ios.clock == MMC_HS200_MAX_DTR) ||
> It's a bit ugly that sdhci_msm_execute_tuning() passes ios.clock as an
> argument to msm_set_clock_rate_for_bus_mode(), which then calls
> msm_get_clock_mult_for_bus_mode() where you reach back into ios.clock.
>
> In fact, having msm_get_clock_mult_for_bus_mode() reach into
> host->mmc->ios to get ios.timing, seems a violation of the original
> intent of the prototype.
>
>
> How about cleaning this up and passing "timing" as an argument to
> msm_set_clock_rate_for_bus_mode(), and then pass host, clock, and timing
> to msm_get_clock_mult_for_bus_mode()?
>
> That way we avoid this mix of passing parameters to the functions in
> both arguments and in state at the same time.
>
> Regards,
> Bjorn
Sure will update in V2.
Regards,
Sarthak
>> host->flags & SDHCI_HS400_TUNING)
>> return 2;
>> return 1;
>> --
>> 2.34.1
>>
>>
prev parent reply other threads:[~2025-11-14 8:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-10 6:38 [PATCH V1] mmc: sdhci-msm: Avoid early clock doubling during HS400 transition Sarthak Garg
2025-11-10 14:39 ` Bjorn Andersson
2025-11-14 8:32 ` Sarthak Garg [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5dcd735d-31bf-4c7f-bf12-89a5cae0d628@oss.qualcomm.com \
--to=sarthak.garg@oss.qualcomm.com \
--cc=adrian.hunter@intel.com \
--cc=andersson@kernel.org \
--cc=kernel@oss.qualcomm.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=quic_bhaskarv@quicinc.com \
--cc=quic_nguyenb@quicinc.com \
--cc=quic_nitirawa@quicinc.com \
--cc=quic_pragalla@quicinc.com \
--cc=quic_rampraka@quicinc.com \
--cc=quic_sayalil@quicinc.com \
--cc=ulf.hansson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox