From 7831c0b624cf6dcb4d860dd2452faed6c32e42d2 Mon Sep 17 00:00:00 2001 From: Ulf Hansson Date: Tue, 15 Nov 2011 16:39:54 +0100 Subject: mmc: Minimize resume-time by deferring resume Typically an sd/mmc card takes around 200 - 1100 ms to initialize when the power to the card has been cut, which is what happens during a suspend/resume sequence. All device's resume time adds up to the total kernel resume time. Some use cases requires the kernel to be resumed fast, to be able to meet deadlines. One use case example is WLAN SOFT_AP, but there are certainly more. This patch schedules a delayed work to do a deferred resume of the mmc host, if the bus holds a card of SD or MMC type. The reason for not supporting SDIO and SDcombo cards at this stage, is because the SDIO API is synchronus, which complicates request locking mechanism when waiting for a deferred resume to be completed. While waiting for a deferred resume to be completed, detect works are prevented from doing a new rescan. If a mmcblk request arrives, the deferred resume will be synced immediately. The deferred resume is scheduled 3000 ms after the resume request arrived. The idea behind this timer value is to let the mmc host being able to accept a new suspend request before it has been deferred resumed and thus not increase the resume to suspend time if not really needed. Change-Id: I7e97e59c8709cf5d8e3c76478771ddf6062a54ec Signed-off-by: Ulf Hansson Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/39692 --- include/linux/mmc/host.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'include') diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index cbde4b7e675..015eb334ce5 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -292,6 +292,11 @@ struct mmc_host { int detect_change; /* card detect flag */ struct mmc_hotplug hotplug; + struct delayed_work resume; /* deferred resume work */ + unsigned int pm_state; /* used for deferred resume */ +#define MMC_HOST_DEFERRED_RESUME (1 << 0) +#define MMC_HOST_NEEDS_RESUME (1 << 1) + const struct mmc_bus_ops *bus_ops; /* current bus driver */ unsigned int bus_refs; /* reference counter */ @@ -340,6 +345,7 @@ static inline void *mmc_priv(struct mmc_host *host) extern int mmc_suspend_host(struct mmc_host *); extern int mmc_resume_host(struct mmc_host *); +extern void mmc_resume_host_sync(struct mmc_host *); extern int mmc_power_save_host(struct mmc_host *host); extern int mmc_power_restore_host(struct mmc_host *host); @@ -429,4 +435,15 @@ static inline unsigned int mmc_host_clk_rate(struct mmc_host *host) return host->ios.clock; } #endif + +static inline int mmc_host_deferred_resume(struct mmc_host *host) +{ + return host->pm_state & MMC_HOST_DEFERRED_RESUME; +} + +static inline int mmc_host_needs_resume(struct mmc_host *host) +{ + return host->pm_state & MMC_HOST_NEEDS_RESUME; +} + #endif /* LINUX_MMC_HOST_H */ -- cgit v1.2.3