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.

Dependency Surface

Detected Declarations

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

Implementation Notes