drivers/ata/ahci.c
Source file repositories/reference/linux-study-clean/drivers/ata/ahci.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/ata/ahci.c- Extension
.c- Size
- 79664 bytes
- Lines
- 3124
- Domain
- Driver Families
- Bucket
- drivers/ata
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/module.hlinux/pci.hlinux/blkdev.hlinux/delay.hlinux/interrupt.hlinux/dma-mapping.hlinux/device.hlinux/dmi.hlinux/gfp.hscsi/scsi_host.hscsi/scsi_cmnd.hlinux/libata.hlinux/ahci-remap.hlinux/io-64-nonatomic-lo-hi.hahci.h
Detected Declarations
enum board_idsfunction ahci_port_maskfunction ahci_get_port_maskfunction ahci_pci_save_initial_configfunction ahci_pci_reset_controllerfunction ahci_pci_init_controllerfunction ahci_vt8251_hardresetfunction ahci_p5wdh_hardresetfunction recoveredfunction ahci_pci_disable_interruptsfunction ahci_pci_device_runtime_suspendfunction ahci_pci_device_runtime_resumefunction ahci_pci_device_suspendfunction ahci_pci_device_resumefunction ahci_configure_dma_masksfunction ahci_pci_print_infofunction devicefunction ahci_mcp89_apple_enablefunction is_mcp89_applefunction ahci_sb600_enable_64bitfunction ahci_broken_system_powerofffunction ahci_broken_suspendfunction ahci_broken_lpmfunction ahci_broken_onlinefunction ahci_gtf_filter_workaroundfunction ahci_gtf_filter_workaroundfunction ahci_thunderx_irq_handlerfunction ahci_remap_checkfunction ahci_get_irq_vectorfunction ahci_init_irqfunction ahci_mark_external_portfunction ahci_update_initial_lpm_policyfunction ahci_intel_pcs_quirkfunction remapped_nvme_showfunction ahci_validate_bar_sizefunction ahci_init_onefunction ahci_shutdown_onefunction ahci_remove_one
Annotated Snippet
static struct pci_driver ahci_pci_driver = {
.name = DRV_NAME,
.id_table = ahci_pci_tbl,
.probe = ahci_init_one,
.remove = ahci_remove_one,
.shutdown = ahci_shutdown_one,
.driver = {
.pm = &ahci_pci_pm_ops,
},
};
#if IS_ENABLED(CONFIG_PATA_MARVELL)
static int marvell_enable;
#else
static int marvell_enable = 1;
#endif
module_param(marvell_enable, int, 0644);
MODULE_PARM_DESC(marvell_enable, "Marvell SATA via AHCI (1 = enabled)");
static int mobile_lpm_policy = -1;
module_param(mobile_lpm_policy, int, 0644);
MODULE_PARM_DESC(mobile_lpm_policy,
"Default LPM policy. Despite its name, this parameter applies "
"to all chipsets, including desktop and server chipsets");
static char *ahci_mask_port_map;
module_param_named(mask_port_map, ahci_mask_port_map, charp, 0444);
MODULE_PARM_DESC(mask_port_map,
"32-bits port map masks to ignore controllers ports. "
"Valid values are: "
"\"<mask>\" to apply the same mask to all AHCI controller "
"devices, and \"<pci_dev>=<mask>,<pci_dev>=<mask>,...\" to "
"specify different masks for the controllers specified, "
"where <pci_dev> is the PCI ID of an AHCI controller in the "
"form \"domain:bus:dev.func\"");
static char *ahci_mask_port_ext;
module_param_named(mask_port_ext, ahci_mask_port_ext, charp, 0444);
MODULE_PARM_DESC(mask_port_ext,
"32-bits mask to ignore the external/hotplug capability of ports. "
"Valid values are: "
"\"<mask>\" to apply the same mask to all AHCI controller "
"devices, and \"<pci_dev>=<mask>,<pci_dev>=<mask>,...\" to "
"specify different masks for the controllers specified, "
"where <pci_dev> is the PCI ID of an AHCI controller in the "
"form \"domain:bus:dev.func\"");
static u32 ahci_port_mask(struct device *dev, char *mask_s)
{
unsigned int mask;
if (kstrtouint(mask_s, 0, &mask)) {
dev_err(dev, "Invalid port map mask\n");
return 0;
}
return mask;
}
static u32 ahci_get_port_mask(struct device *dev, char *mask_p)
{
char *param, *end, *str, *mask_s;
char *name;
u32 mask = 0;
if (!mask_p || !strlen(mask_p))
return 0;
str = kstrdup(mask_p, GFP_KERNEL);
if (!str)
return 0;
/* Handle single mask case */
if (!strchr(str, '=')) {
mask = ahci_port_mask(dev, str);
goto free;
}
/*
* Mask list case: parse the parameter to get the mask only if
* the device name matches.
*/
param = str;
end = param + strlen(param);
while (param && param < end && *param) {
name = param;
param = strchr(name, '=');
if (!param)
break;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/pci.h`, `linux/blkdev.h`, `linux/delay.h`, `linux/interrupt.h`, `linux/dma-mapping.h`, `linux/device.h`.
- Detected declarations: `enum board_ids`, `function ahci_port_mask`, `function ahci_get_port_mask`, `function ahci_pci_save_initial_config`, `function ahci_pci_reset_controller`, `function ahci_pci_init_controller`, `function ahci_vt8251_hardreset`, `function ahci_p5wdh_hardreset`, `function recovered`, `function ahci_pci_disable_interrupts`.
- Atlas domain: Driver Families / drivers/ata.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.