~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/powerpc/include/asm/delay.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0-or-later */
  2 #ifndef _ASM_POWERPC_DELAY_H
  3 #define _ASM_POWERPC_DELAY_H
  4 #ifdef __KERNEL__
  5 
  6 #include <linux/processor.h>
  7 #include <asm/time.h>
  8 
  9 /*
 10  * Copyright 1996, Paul Mackerras.
 11  * Copyright (C) 2009 Freescale Semiconductor, Inc. All rights reserved.
 12  *
 13  * PPC64 Support added by Dave Engebretsen, Todd Inglett, Mike Corrigan,
 14  * Anton Blanchard.
 15  */
 16 
 17 extern void __delay(unsigned long loops);
 18 extern void udelay(unsigned long usecs);
 19 
 20 /*
 21  * On shared processor machines the generic implementation of mdelay can
 22  * result in large errors. While each iteration of the loop inside mdelay
 23  * is supposed to take 1ms, the hypervisor could sleep our partition for
 24  * longer (eg 10ms). With the right timing these errors can add up.
 25  *
 26  * Since there is no 32bit overflow issue on 64bit kernels, just call
 27  * udelay directly.
 28  */
 29 #ifdef CONFIG_PPC64
 30 #define mdelay(n)       udelay((n) * 1000)
 31 #endif
 32 
 33 /**
 34  * spin_event_timeout - spin until a condition gets true or a timeout elapses
 35  * @condition: a C expression to evalate
 36  * @timeout: timeout, in microseconds
 37  * @delay: the number of microseconds to delay between each evaluation of
 38  *         @condition
 39  *
 40  * The process spins until the condition evaluates to true (non-zero) or the
 41  * timeout elapses.  The return value of this macro is the value of
 42  * @condition when the loop terminates. This allows you to determine the cause
 43  * of the loop terminates.  If the return value is zero, then you know a
 44  * timeout has occurred.
 45  *
 46  * This primary purpose of this macro is to poll on a hardware register
 47  * until a status bit changes.  The timeout ensures that the loop still
 48  * terminates even if the bit never changes.  The delay is for devices that
 49  * need a delay in between successive reads.
 50  *
 51  * gcc will optimize out the if-statement if @delay is a constant.
 52  */
 53 #define spin_event_timeout(condition, timeout, delay)                          \
 54 ({                                                                             \
 55         typeof(condition) __ret;                                               \
 56         unsigned long __loops = tb_ticks_per_usec * timeout;                   \
 57         unsigned long __start = mftb();                                     \
 58                                                                                \
 59         if (delay) {                                                           \
 60                 while (!(__ret = (condition)) &&                               \
 61                                 (tb_ticks_since(__start) <= __loops))          \
 62                         udelay(delay);                                         \
 63         } else {                                                               \
 64                 spin_begin();                                                  \
 65                 while (!(__ret = (condition)) &&                               \
 66                                 (tb_ticks_since(__start) <= __loops))          \
 67                         spin_cpu_relax();                                      \
 68                 spin_end();                                                    \
 69         }                                                                      \
 70         if (!__ret)                                                            \
 71                 __ret = (condition);                                           \
 72         __ret;                                                                 \
 73 })
 74 
 75 #endif /* __KERNEL__ */
 76 #endif /* _ASM_POWERPC_DELAY_H */
 77 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php