drivers/acpi/numa/srat.c

Source file repositories/reference/linux-study-clean/drivers/acpi/numa/srat.c

File Facts

System
Linux kernel
Corpus path
drivers/acpi/numa/srat.c
Extension
.c
Size
18520 bytes
Lines
704
Domain
Driver Families
Bucket
drivers/acpi
Inferred role
Driver Families: exported/initcall integration point
Status
integration 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

if (node_to_pxm_map[i] != PXM_INVAL) {
			for (j = 0; j <= max_nid; j++) {
				if ((emu_nid_to_phys[j] == i) &&
				    WARN(node_to_pxm_map_copy[j] != PXM_INVAL,
					 "Node %d is already binded to PXM %d\n",
					 j, node_to_pxm_map_copy[j]))
					return -1;
				if (emu_nid_to_phys[j] == i) {
					node_to_pxm_map_copy[j] =
						node_to_pxm_map[i];
					if (j > index)
						index = j;
					count++;
				}
			}
		}
	}
	if (index == -1) {
		pr_debug("No node/PXM mapping has been set\n");
		/* nothing more to be done */
		return 0;
	}
	if (WARN(index != max_nid, "%d max nid  when expected %d\n",
		      index, max_nid))
		return -1;

	nodes_clear(nodes_to_enable);

	/* map phys nodes not used for fake nodes */
	for (i = 0; i < MAX_NUMNODES; i++) {
		if (node_to_pxm_map[i] != PXM_INVAL) {
			for (j = 0; j <= max_nid; j++)
				if (emu_nid_to_phys[j] == i)
					break;
			/* fake nodes PXM mapping has been done */
			if (j <= max_nid)
				continue;
			/* find first hole */
			for (j = 0;
			     j < MAX_NUMNODES &&
				 node_to_pxm_map_copy[j] != PXM_INVAL;
			     j++)
			;
			if (WARN(j == MAX_NUMNODES,
			    "Number of nodes exceeds MAX_NUMNODES\n"))
				return -1;
			node_to_pxm_map_copy[j] = node_to_pxm_map[i];
			node_set(j, nodes_to_enable);
			count++;
		}
	}

	/* creating reverse mapping in pxm_to_node_map[] */
	for (i = 0; i < MAX_NUMNODES; i++)
		if (node_to_pxm_map_copy[i] != PXM_INVAL &&
		    pxm_to_node_map_copy[node_to_pxm_map_copy[i]] == NUMA_NO_NODE)
			pxm_to_node_map_copy[node_to_pxm_map_copy[i]] = i;

	/* overwrite with new mapping */
	for (i = 0; i < MAX_NUMNODES; i++) {
		node_to_pxm_map[i] = node_to_pxm_map_copy[i];
		pxm_to_node_map[i] = pxm_to_node_map_copy[i];
	}

	/* enable other nodes found in PXM for hotplug */
	nodes_or(numa_nodes_parsed, nodes_to_enable, numa_nodes_parsed);

	pr_debug("found %d total number of nodes\n", count);
	return 0;
}
#endif

static void __init
acpi_table_print_srat_entry(struct acpi_subtable_header *header)
{
	switch (header->type) {
	case ACPI_SRAT_TYPE_CPU_AFFINITY:
		{
			struct acpi_srat_cpu_affinity *p =
			    (struct acpi_srat_cpu_affinity *)header;
			pr_debug("SRAT Processor (id[0x%02x] eid[0x%02x]) in proximity domain %d %s\n",
				 p->apic_id, p->local_sapic_eid,
				 p->proximity_domain_lo,
				 str_enabled_disabled(p->flags & ACPI_SRAT_CPU_ENABLED));
		}
		break;

	case ACPI_SRAT_TYPE_MEMORY_AFFINITY:
		{
			struct acpi_srat_mem_affinity *p =

Annotation

Implementation Notes