diff mbox

[v4,1/2] mmc: Move mmc_delay() to include/linux/mmc/core.h

Message ID 1356082080-7756-1-git-send-email-Chunhe.Lan@freescale.com (mailing list archive)
State New, archived
Headers show

Commit Message

Chunhe Lan Dec. 21, 2012, 9:27 a.m. UTC
Move mmc_delay() from drivers/mmc/core/core.h to
include/linux/mmc/core.h. So when other functions
call it with include syntax using <linux/mmc/core.h>
of absolute path rather than "../core/core.h" of
relative path.

At the same time, change code, so schedule subsystem
has more chances to call other threads.

Signed-off-by: Chunhe Lan <Chunhe.Lan@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Chris Ball <cjb@laptop.org>
---
 drivers/mmc/core/core.h  |   12 ------------
 include/linux/mmc/core.h |   17 +++++++++++++++++
 2 files changed, 17 insertions(+), 12 deletions(-)

Comments

Arnd Bergmann Dec. 21, 2012, 7:39 p.m. UTC | #1
On Friday 21 December 2012, Chunhe Lan wrote:
> 
> +static inline void mmc_delay(unsigned int ms)
> +{
> +       ktime_t end = ktime_add_us(ktime_get(), ms * 1000);
> +
> +       while (1) {
> +               s64 remaining;
> +
> +               cond_resched();
> +               remaining = ktime_to_us(ktime_sub(end, ktime_get()));
> +               if (remaining < 0)
> +                       break;
> +
> +               udelay(min_t(u32, remaining, 100));
> +       }
> +}

The new logic is more accurate than the old one, but it still wastes
a lot of energy and CPU cycles. Could you perhaps use an hrtimer to
set the exact timeout and actually sleep?

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Lan Chunhe Dec. 25, 2012, 8:13 a.m. UTC | #2
On 12/22/2012 03:39 AM, Arnd Bergmann wrote:
> On Friday 21 December 2012, Chunhe Lan wrote:
>> +static inline void mmc_delay(unsigned int ms)
>> +{
>> +       ktime_t end = ktime_add_us(ktime_get(), ms * 1000);
>> +
>> +       while (1) {
>> +               s64 remaining;
>> +
>> +               cond_resched();
>> +               remaining = ktime_to_us(ktime_sub(end, ktime_get()));
>> +               if (remaining < 0)
>> +                       break;
>> +
>> +               udelay(min_t(u32, remaining, 100));
>> +       }
>> +}
> The new logic is more accurate than the old one, but it still wastes
> a lot of energy and CPU cycles. Could you perhaps use an hrtimer to
> set the exact timeout and actually sleep?
     I think that does not have to use hrtimer, and it makes a fuss.
     And mmc structure has not included the hrtimer variable.

Thanks,
Chunhe
>
> 	Arnd
>



--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h
index 3bdafbc..5f63d00 100644
--- a/drivers/mmc/core/core.h
+++ b/drivers/mmc/core/core.h
@@ -11,8 +11,6 @@ 
 #ifndef _MMC_CORE_CORE_H
 #define _MMC_CORE_CORE_H
 
-#include <linux/delay.h>
-
 #define MMC_CMD_RETRIES        3
 
 struct mmc_bus_ops {
@@ -46,16 +44,6 @@  void mmc_set_timing(struct mmc_host *host, unsigned int timing);
 void mmc_set_driver_type(struct mmc_host *host, unsigned int drv_type);
 void mmc_power_off(struct mmc_host *host);
 
-static inline void mmc_delay(unsigned int ms)
-{
-	if (ms < 1000 / HZ) {
-		cond_resched();
-		mdelay(ms);
-	} else {
-		msleep(ms);
-	}
-}
-
 void mmc_rescan(struct work_struct *work);
 void mmc_start_host(struct mmc_host *host);
 void mmc_stop_host(struct mmc_host *host);
diff --git a/include/linux/mmc/core.h b/include/linux/mmc/core.h
index 5bf7c22..e051c5b 100644
--- a/include/linux/mmc/core.h
+++ b/include/linux/mmc/core.h
@@ -10,6 +10,7 @@ 
 
 #include <linux/interrupt.h>
 #include <linux/completion.h>
+#include <linux/delay.h>
 
 struct request;
 struct mmc_data;
@@ -198,6 +199,22 @@  static inline void mmc_claim_host(struct mmc_host *host)
 	__mmc_claim_host(host, NULL);
 }
 
+static inline void mmc_delay(unsigned int ms)
+{
+	ktime_t end = ktime_add_us(ktime_get(), ms * 1000);
+
+	while (1) {
+		s64 remaining;
+
+		cond_resched();
+		remaining = ktime_to_us(ktime_sub(end, ktime_get()));
+		if (remaining < 0)
+			break;
+
+		udelay(min_t(u32, remaining, 100));
+	}
+}
+
 extern u32 mmc_vddrange_to_ocrmask(int vdd_min, int vdd_max);
 
 #endif /* LINUX_MMC_CORE_H */