arch/x86/kernel/io_delay.c
Source file repositories/reference/linux-study-clean/arch/x86/kernel/io_delay.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/kernel/io_delay.c- Extension
.c- Size
- 3491 bytes
- Lines
- 149
- Domain
- Architecture Layer
- Bucket
- arch/x86
- Inferred role
- Architecture Layer: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/export.hlinux/delay.hlinux/init.hlinux/dmi.hlinux/io.h
Detected Declarations
function native_io_delayfunction dmi_io_delay_0xed_portfunction io_delay_initfunction io_delay_paramexport native_io_delay
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* I/O delay strategies for inb_p/outb_p
*
* Allow for a DMI based override of port 0x80, needed for certain HP laptops
* and possibly other systems. Also allow for the gradual elimination of
* outb_p/inb_p API uses.
*/
#include <linux/kernel.h>
#include <linux/export.h>
#include <linux/delay.h>
#include <linux/init.h>
#include <linux/dmi.h>
#include <linux/io.h>
#define IO_DELAY_TYPE_0X80 0
#define IO_DELAY_TYPE_0XED 1
#define IO_DELAY_TYPE_UDELAY 2
#define IO_DELAY_TYPE_NONE 3
#if defined(CONFIG_IO_DELAY_0X80)
#define DEFAULT_IO_DELAY_TYPE IO_DELAY_TYPE_0X80
#elif defined(CONFIG_IO_DELAY_0XED)
#define DEFAULT_IO_DELAY_TYPE IO_DELAY_TYPE_0XED
#elif defined(CONFIG_IO_DELAY_UDELAY)
#define DEFAULT_IO_DELAY_TYPE IO_DELAY_TYPE_UDELAY
#elif defined(CONFIG_IO_DELAY_NONE)
#define DEFAULT_IO_DELAY_TYPE IO_DELAY_TYPE_NONE
#endif
int io_delay_type __read_mostly = DEFAULT_IO_DELAY_TYPE;
static int __initdata io_delay_override;
/*
* Paravirt wants native_io_delay to be a constant.
*/
void native_io_delay(void)
{
switch (io_delay_type) {
default:
case IO_DELAY_TYPE_0X80:
asm volatile ("outb %al, $0x80");
break;
case IO_DELAY_TYPE_0XED:
asm volatile ("outb %al, $0xed");
break;
case IO_DELAY_TYPE_UDELAY:
/*
* 2 usecs is an upper-bound for the outb delay but
* note that udelay doesn't have the bus-level
* side-effects that outb does, nor does udelay() have
* precise timings during very early bootup (the delays
* are shorter until calibrated):
*/
udelay(2);
break;
case IO_DELAY_TYPE_NONE:
break;
}
}
EXPORT_SYMBOL(native_io_delay);
static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
{
if (io_delay_type == IO_DELAY_TYPE_0X80) {
pr_notice("%s: using 0xed I/O delay port\n", id->ident);
io_delay_type = IO_DELAY_TYPE_0XED;
}
return 0;
}
/*
* Quirk table for systems that misbehave (lock up, etc.) if port
* 0x80 is used:
*/
static const struct dmi_system_id io_delay_0xed_port_dmi_table[] __initconst = {
{
.callback = dmi_io_delay_0xed_port,
.ident = "Compaq Presario V6000",
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, "Quanta"),
DMI_MATCH(DMI_BOARD_NAME, "30B7")
}
},
{
.callback = dmi_io_delay_0xed_port,
.ident = "HP Pavilion dv9000z",
.matches = {
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/export.h`, `linux/delay.h`, `linux/init.h`, `linux/dmi.h`, `linux/io.h`.
- Detected declarations: `function native_io_delay`, `function dmi_io_delay_0xed_port`, `function io_delay_init`, `function io_delay_param`, `export native_io_delay`.
- Atlas domain: Architecture Layer / arch/x86.
- Implementation status: integration 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.