Skip to content

Commit 57617ea

Browse files
rvosktobydox
authored andcommitted
mmc: sdhci: Use "mmc" directly rather than "host->mmc"
Clean up the code to use the "mmc" directly instead of "host->mmc". If the code sits in hot code path, this clean up also brings trvial performance improvement. Take the sdhci_post_req() for example: before the patch: ... 8d0: a9be7bfd stp x29, x30, [sp, #-32]! 8d4: 910003fd mov x29, sp 8d8: f9000bf3 str x19, [sp, gregkh#16] 8dc: f9400833 ldr x19, [x1, gregkh#16] 8e0: b9404261 ldr w1, [x19, #64] 8e4: 34000161 cbz w1, 910 <sdhci_post_req+0x50> 8e8: f9424400 ldr x0, [x0, #1160] 8ec: d2800004 mov x4, #0x0 // #0 8f0: b9401a61 ldr w1, [x19, #24] 8f4: b9403262 ldr w2, [x19, #48] 8f8: f9400000 ldr x0, [x0] 8fc: f278003f tst x1, #0x100 900: f9401e61 ldr x1, [x19, #56] 904: 1a9f17e3 cset w3, eq // eq = none 908: 11000463 add w3, w3, #0x1 90c: 94000000 bl 0 <dma_unmap_sg_attrs> ... After the patch: ... 8d0: a9be7bfd stp x29, x30, [sp, #-32]! 8d4: 910003fd mov x29, sp 8d8: f9000bf3 str x19, [sp, gregkh#16] 8dc: f9400833 ldr x19, [x1, gregkh#16] 8e0: b9404261 ldr w1, [x19, #64] 8e4: 34000141 cbz w1, 90c <sdhci_post_req+0x4c> 8e8: b9401a61 ldr w1, [x19, #24] 8ec: d2800004 mov x4, #0x0 // #0 8f0: b9403262 ldr w2, [x19, #48] 8f4: f9400000 ldr x0, [x0] 8f8: f278003f tst x1, #0x100 8fc: f9401e61 ldr x1, [x19, #56] 900: 1a9f17e3 cset w3, eq // eq = none 904: 11000463 add w3, w3, #0x1 908: 94000000 bl 0 <dma_unmap_sg_attrs> ... We saved one ldr instruction: "ldr x0, [x0, #1160]" Signed-off-by: Jisheng Zhang <[email protected]> Acked-by: Adrian Hunter <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ulf Hansson <[email protected]> (cherry picked from commit d2f025b)
1 parent 824bd9b commit 57617ea

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

drivers/mmc/host/sdhci.c

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ static void sdhci_calc_sw_timeout(struct sdhci_host *host,
900900

901901
if (data) {
902902
blksz = data->blksz;
903-
freq = host->mmc->actual_clock ? : host->clock;
903+
freq = mmc->actual_clock ? : host->clock;
904904
transfer_time = (u64)blksz * NSEC_PER_SEC * (8 / bus_width);
905905
do_div(transfer_time, freq);
906906
/* multiply by '2' to account for any unknowns */
@@ -2186,14 +2186,14 @@ void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
21862186

21872187
if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK &&
21882188
host->clock) {
2189-
host->timeout_clk = host->mmc->actual_clock ?
2190-
host->mmc->actual_clock / 1000 :
2189+
host->timeout_clk = mmc->actual_clock ?
2190+
mmc->actual_clock / 1000 :
21912191
host->clock / 1000;
2192-
host->mmc->max_busy_timeout =
2192+
mmc->max_busy_timeout =
21932193
host->ops->get_max_timeout_count ?
21942194
host->ops->get_max_timeout_count(host) :
21952195
1 << 27;
2196-
host->mmc->max_busy_timeout /= host->timeout_clk;
2196+
mmc->max_busy_timeout /= host->timeout_clk;
21972197
}
21982198
}
21992199

@@ -2323,7 +2323,7 @@ static int sdhci_get_cd(struct mmc_host *mmc)
23232323
return 0;
23242324

23252325
/* If nonremovable, assume that the card is always present. */
2326-
if (!mmc_card_is_removable(host->mmc))
2326+
if (!mmc_card_is_removable(mmc))
23272327
return 1;
23282328

23292329
/*
@@ -2416,14 +2416,14 @@ void sdhci_enable_sdio_irq(struct mmc_host *mmc, int enable)
24162416
unsigned long flags;
24172417

24182418
if (enable)
2419-
pm_runtime_get_noresume(host->mmc->parent);
2419+
pm_runtime_get_noresume(mmc->parent);
24202420

24212421
spin_lock_irqsave(&host->lock, flags);
24222422
sdhci_enable_sdio_irq_nolock(host, enable);
24232423
spin_unlock_irqrestore(&host->lock, flags);
24242424

24252425
if (!enable)
2426-
pm_runtime_put_noidle(host->mmc->parent);
2426+
pm_runtime_put_noidle(mmc->parent);
24272427
}
24282428
EXPORT_SYMBOL_GPL(sdhci_enable_sdio_irq);
24292429

@@ -2760,7 +2760,7 @@ int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode)
27602760
goto out;
27612761
}
27622762

2763-
host->mmc->retune_period = tuning_count;
2763+
mmc->retune_period = tuning_count;
27642764

27652765
if (host->tuning_delay < 0)
27662766
host->tuning_delay = opcode == MMC_SEND_TUNING_BLOCK;
@@ -2809,11 +2809,10 @@ static void sdhci_enable_preset_value(struct sdhci_host *host, bool enable)
28092809
static void sdhci_post_req(struct mmc_host *mmc, struct mmc_request *mrq,
28102810
int err)
28112811
{
2812-
struct sdhci_host *host = mmc_priv(mmc);
28132812
struct mmc_data *data = mrq->data;
28142813

28152814
if (data->host_cookie != COOKIE_UNMAPPED)
2816-
dma_unmap_sg(mmc_dev(host->mmc), data->sg, data->sg_len,
2815+
dma_unmap_sg(mmc_dev(mmc), data->sg, data->sg_len,
28172816
mmc_get_dma_dir(data));
28182817

28192818
data->host_cookie = COOKIE_UNMAPPED;
@@ -2864,9 +2863,9 @@ static void sdhci_card_event(struct mmc_host *mmc)
28642863
/* Check sdhci_has_requests() first in case we are runtime suspended */
28652864
if (sdhci_has_requests(host) && !present) {
28662865
pr_err("%s: Card removed during transfer!\n",
2867-
mmc_hostname(host->mmc));
2866+
mmc_hostname(mmc));
28682867
pr_err("%s: Resetting controller.\n",
2869-
mmc_hostname(host->mmc));
2868+
mmc_hostname(mmc));
28702869

28712870
sdhci_do_reset(host, SDHCI_RESET_CMD);
28722871
sdhci_do_reset(host, SDHCI_RESET_DATA);
@@ -3582,7 +3581,7 @@ int sdhci_resume_host(struct sdhci_host *host)
35823581
host->ops->enable_dma(host);
35833582
}
35843583

3585-
if ((host->mmc->pm_flags & MMC_PM_KEEP_POWER) &&
3584+
if ((mmc->pm_flags & MMC_PM_KEEP_POWER) &&
35863585
(host->quirks2 & SDHCI_QUIRK2_HOST_OFF_CARD_ON)) {
35873586
/* Card keeps power but host controller does not */
35883587
sdhci_init(host, 0);
@@ -3591,15 +3590,15 @@ int sdhci_resume_host(struct sdhci_host *host)
35913590
host->reinit_uhs = true;
35923591
mmc->ops->set_ios(mmc, &mmc->ios);
35933592
} else {
3594-
sdhci_init(host, (host->mmc->pm_flags & MMC_PM_KEEP_POWER));
3593+
sdhci_init(host, (mmc->pm_flags & MMC_PM_KEEP_POWER));
35953594
}
35963595

35973596
if (host->irq_wake_enabled) {
35983597
sdhci_disable_irq_wakeups(host);
35993598
} else {
36003599
ret = request_threaded_irq(host->irq, sdhci_irq,
36013600
sdhci_thread_irq, IRQF_SHARED,
3602-
mmc_hostname(host->mmc), host);
3601+
mmc_hostname(mmc), host);
36033602
if (ret)
36043603
return ret;
36053604
}
@@ -4297,7 +4296,7 @@ int sdhci_setup_host(struct sdhci_host *host)
42974296

42984297
if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) &&
42994298
mmc_card_is_removable(mmc) &&
4300-
mmc_gpio_get_cd(host->mmc) < 0)
4299+
mmc_gpio_get_cd(mmc) < 0)
43014300
mmc->caps |= MMC_CAP_NEEDS_POLL;
43024301

43034302
if (!IS_ERR(mmc->supply.vqmmc)) {

0 commit comments

Comments
 (0)