arch/powerpc/include/asm/delay.h
Source file repositories/reference/linux-study-clean/arch/powerpc/include/asm/delay.h
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/include/asm/delay.h- Extension
.h- Size
- 3297 bytes
- Lines
- 77
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
Dependency Surface
linux/processor.hasm/time.h
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
#ifndef _ASM_POWERPC_DELAY_H
#define _ASM_POWERPC_DELAY_H
#ifdef __KERNEL__
#include <linux/processor.h>
#include <asm/time.h>
/*
* Copyright 1996, Paul Mackerras.
* Copyright (C) 2009 Freescale Semiconductor, Inc. All rights reserved.
*
* PPC64 Support added by Dave Engebretsen, Todd Inglett, Mike Corrigan,
* Anton Blanchard.
*/
extern void __delay(unsigned long loops);
extern void udelay(unsigned long usecs);
/*
* On shared processor machines the generic implementation of mdelay can
* result in large errors. While each iteration of the loop inside mdelay
* is supposed to take 1ms, the hypervisor could sleep our partition for
* longer (eg 10ms). With the right timing these errors can add up.
*
* Since there is no 32bit overflow issue on 64bit kernels, just call
* udelay directly.
*/
#ifdef CONFIG_PPC64
#define mdelay(n) udelay((n) * 1000)
#endif
/**
* spin_event_timeout - spin until a condition gets true or a timeout elapses
* @condition: a C expression to evalate
* @timeout: timeout, in microseconds
* @delay: the number of microseconds to delay between each evaluation of
* @condition
*
* The process spins until the condition evaluates to true (non-zero) or the
* timeout elapses. The return value of this macro is the value of
* @condition when the loop terminates. This allows you to determine the cause
* of the loop terminates. If the return value is zero, then you know a
* timeout has occurred.
*
* This primary purpose of this macro is to poll on a hardware register
* until a status bit changes. The timeout ensures that the loop still
* terminates even if the bit never changes. The delay is for devices that
* need a delay in between successive reads.
*
* gcc will optimize out the if-statement if @delay is a constant.
*/
#define spin_event_timeout(condition, timeout, delay) \
({ \
typeof(condition) __ret; \
unsigned long __loops = tb_ticks_per_usec * timeout; \
unsigned long __start = mftb(); \
\
if (delay) { \
while (!(__ret = (condition)) && \
(tb_ticks_since(__start) <= __loops)) \
udelay(delay); \
} else { \
spin_begin(); \
while (!(__ret = (condition)) && \
(tb_ticks_since(__start) <= __loops)) \
spin_cpu_relax(); \
spin_end(); \
} \
if (!__ret) \
__ret = (condition); \
__ret; \
})
#endif /* __KERNEL__ */
#endif /* _ASM_POWERPC_DELAY_H */
Annotation
- Immediate include surface: `linux/processor.h`, `asm/time.h`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.