drivers/pci/pci.c

Source file repositories/reference/linux-study-clean/drivers/pci/pci.c

File Facts

System
Linux kernel
Corpus path
drivers/pci/pci.c
Extension
.c
Size
183956 bytes
Lines
6801
Domain
Representative Device Path
Bucket
PCIe NVMe Storage Path
Inferred role
Representative Device Path: operation-table or driver-model contract
Status
pattern implementation candidate

Why This File Exists

Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.

Dependency Surface

Detected Declarations

Annotated Snippet

static ssize_t resource_alignment_show(const struct bus_type *bus, char *buf)
{
	size_t count = 0;

	spin_lock(&resource_alignment_lock);
	if (resource_alignment_param)
		count = sysfs_emit(buf, "%s\n", resource_alignment_param);
	spin_unlock(&resource_alignment_lock);

	return count;
}

static ssize_t resource_alignment_store(const struct bus_type *bus,
					const char *buf, size_t count)
{
	char *param, *old, *end;

	if (count >= (PAGE_SIZE - 1))
		return -EINVAL;

	param = kstrndup(buf, count, GFP_KERNEL);
	if (!param)
		return -ENOMEM;

	end = strchr(param, '\n');
	if (end)
		*end = '\0';

	spin_lock(&resource_alignment_lock);
	old = resource_alignment_param;
	if (strlen(param)) {
		resource_alignment_param = param;
	} else {
		kfree(param);
		resource_alignment_param = NULL;
	}
	spin_unlock(&resource_alignment_lock);

	kfree(old);

	return count;
}

static BUS_ATTR_RW(resource_alignment);

static int __init pci_resource_alignment_sysfs_init(void)
{
	return bus_create_file(&pci_bus_type,
					&bus_attr_resource_alignment);
}
late_initcall(pci_resource_alignment_sysfs_init);

static void pci_no_domains(void)
{
#ifdef CONFIG_PCI_DOMAINS
	pci_domains_supported = 0;
#endif
}

#ifdef CONFIG_PCI_DOMAINS
static DEFINE_IDA(pci_domain_nr_dynamic_ida);

/**
 * pci_bus_find_emul_domain_nr() - allocate a PCI domain number per constraints
 * @hint: desired domain, 0 if any ID in the range of @min to @max is acceptable
 * @min: minimum allowable domain
 * @max: maximum allowable domain, no IDs higher than INT_MAX will be returned
 */
int pci_bus_find_emul_domain_nr(u32 hint, u32 min, u32 max)
{
	return ida_alloc_range(&pci_domain_nr_dynamic_ida, max(hint, min), max,
			       GFP_KERNEL);
}
EXPORT_SYMBOL_GPL(pci_bus_find_emul_domain_nr);

void pci_bus_release_emul_domain_nr(int domain_nr)
{
	ida_free(&pci_domain_nr_dynamic_ida, domain_nr);
}
EXPORT_SYMBOL_GPL(pci_bus_release_emul_domain_nr);
#endif

#ifdef CONFIG_PCI_DOMAINS_GENERIC
static DEFINE_IDA(pci_domain_nr_static_ida);

static void of_pci_reserve_static_domain_nr(void)
{
	struct device_node *np;
	int domain_nr;

Annotation

Implementation Notes