Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mmc: core: limit probe clock frequency to configured f_max

Currently MMC core disregards host->f_max during card initialization
phase. Obey upper boundary for the clock frequency and skip faster
speeds when they are above the limit.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Link: https://lore.kernel.org/r/f471bceaf237d582d746bd289c4c4f3639cb7b45.1577962382.git.mirq-linux@rere.qmqm.pl
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Michał Mirosław and committed by
Ulf Hansson
661cf2d8 557c0315

+8 -2
+8 -2
drivers/mmc/core/core.c
··· 2330 2330 } 2331 2331 2332 2332 for (i = 0; i < ARRAY_SIZE(freqs); i++) { 2333 - if (!mmc_rescan_try_freq(host, max(freqs[i], host->f_min))) 2333 + unsigned int freq = freqs[i]; 2334 + if (freq > host->f_max) { 2335 + if (i + 1 < ARRAY_SIZE(freqs)) 2336 + continue; 2337 + freq = host->f_max; 2338 + } 2339 + if (!mmc_rescan_try_freq(host, max(freq, host->f_min))) 2334 2340 break; 2335 2341 if (freqs[i] <= host->f_min) 2336 2342 break; ··· 2350 2344 2351 2345 void mmc_start_host(struct mmc_host *host) 2352 2346 { 2353 - host->f_init = max(freqs[0], host->f_min); 2347 + host->f_init = max(min(freqs[0], host->f_max), host->f_min); 2354 2348 host->rescan_disable = 0; 2355 2349 host->ios.power_mode = MMC_POWER_UNDEFINED; 2356 2350