clock: introduce non interruptible timeout
is_timeout call poller_call if the timeout is >= 100us but on 1-wire bus we need to wait 500us and not more than 930us for the bus reset. So if the poller_call is caller we can not guarantee it. So for this introduce is_non_interruptible_timeout than we only wait. Use it for ndelay too. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
72703410fe
commit
cf1670486b
|
@ -135,15 +135,21 @@ uint32_t clocksource_hz2mult(uint32_t hz, uint32_t shift_constant)
|
||||||
return (uint32_t)tmp;
|
return (uint32_t)tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int is_timeout_non_interruptible(uint64_t start_ns, uint64_t time_offset_ns)
|
||||||
|
{
|
||||||
|
if ((int64_t)(start_ns + time_offset_ns - get_time_ns()) < 0)
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(is_timeout_non_interruptible);
|
||||||
|
|
||||||
int is_timeout(uint64_t start_ns, uint64_t time_offset_ns)
|
int is_timeout(uint64_t start_ns, uint64_t time_offset_ns)
|
||||||
{
|
{
|
||||||
if (time_offset_ns >= 100 * USECOND)
|
if (time_offset_ns >= 100 * USECOND)
|
||||||
poller_call();
|
poller_call();
|
||||||
|
|
||||||
if ((int64_t)(start_ns + time_offset_ns - get_time_ns()) < 0)
|
return is_timeout_non_interruptible(start_ns, time_offset_ns);
|
||||||
return 1;
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(is_timeout);
|
EXPORT_SYMBOL(is_timeout);
|
||||||
|
|
||||||
|
@ -151,7 +157,7 @@ void ndelay(unsigned long nsecs)
|
||||||
{
|
{
|
||||||
uint64_t start = get_time_ns();
|
uint64_t start = get_time_ns();
|
||||||
|
|
||||||
while(!is_timeout(start, nsecs));
|
while(!is_timeout_non_interruptible(start, nsecs));
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(ndelay);
|
EXPORT_SYMBOL(ndelay);
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ void clocks_calc_mult_shift(uint32_t *mult, uint32_t *shift, uint32_t from, uint
|
||||||
uint32_t clocksource_hz2mult(uint32_t hz, uint32_t shift_constant);
|
uint32_t clocksource_hz2mult(uint32_t hz, uint32_t shift_constant);
|
||||||
|
|
||||||
int is_timeout(uint64_t start_ns, uint64_t time_offset_ns);
|
int is_timeout(uint64_t start_ns, uint64_t time_offset_ns);
|
||||||
|
int is_timeout_non_interruptible(uint64_t start_ns, uint64_t time_offset_ns);
|
||||||
|
|
||||||
// void udelay(unsigned long usecs);
|
// void udelay(unsigned long usecs);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue