svn commit: r281747 - head/sys/dev/acpica

Adrian Chadd adrian at FreeBSD.org
Sun Apr 19 17:15:56 UTC 2015


Author: adrian
Date: Sun Apr 19 17:15:55 2015
New Revision: 281747
URL: https://svnweb.freebsd.org/changeset/base/281747

Log:
  Refactor out the _PXM -> VM domain lookup done in ACPI, in preparation for
  its use in upcoming code.
  
  This is inspired by something in jhb's NUMA IRQ allocation patchset.
  
  However, the tricky bit here is that the PXM lookup for a node may
  fail, requiring a lookup on the parent node.  So if it doesn't
  exist, don't fail - just go up to the parent.  Only error out of the
  lookup is the ACPI lookup returns an error.
  
  Sponsored by:	Norse Corp, Inc.

Modified:
  head/sys/dev/acpica/acpi.c
  head/sys/dev/acpica/acpivar.h

Modified: head/sys/dev/acpica/acpi.c
==============================================================================
--- head/sys/dev/acpica/acpi.c	Sun Apr 19 17:07:51 2015	(r281746)
+++ head/sys/dev/acpica/acpi.c	Sun Apr 19 17:15:55 2015	(r281747)
@@ -1071,30 +1071,53 @@ acpi_hint_device_unit(device_t acdev, de
 }
 
 /*
- * Fetch the NUMA domain for the given device.
- *
- * If a device has a _PXM method, map that to a NUMA domain.
+ * Fetch the VM domain for the given device 'dev'.
  *
- * If none is found, then it'll call the parent method.
- * If there's no domain, return ENOENT.
+ * Return 1 + domain if there's a domain, 0 if not found;
+ * -1 upon an error.
  */
 int
-acpi_get_domain(device_t dev, device_t child, int *domain)
+acpi_parse_pxm(device_t dev, int *domain)
 {
 #if MAXMEMDOM > 1
 	ACPI_HANDLE h;
 	int d, pxm;
 
-	h = acpi_get_handle(child);
+	h = acpi_get_handle(dev);
 	if ((h != NULL) &&
 	    ACPI_SUCCESS(acpi_GetInteger(h, "_PXM", &pxm))) {
 		d = acpi_map_pxm_to_vm_domainid(pxm);
 		if (d < 0)
-			return (ENOENT);
+			return (-1);
 		*domain = d;
-		return (0);
+		return (1);
 	}
 #endif
+
+	return (0);
+}
+
+/*
+ * Fetch the NUMA domain for the given device.
+ *
+ * If a device has a _PXM method, map that to a NUMA domain.
+ *
+ * If none is found, then it'll call the parent method.
+ * If there's no domain, return ENOENT.
+ */
+int
+acpi_get_domain(device_t dev, device_t child, int *domain)
+{
+	int ret;
+
+	ret = acpi_parse_pxm(child, domain);
+	/* Error */
+	if (ret == -1)
+		return (ENOENT);
+	/* Found */
+	if (ret == 1)
+		return (0);
+
 	/* No _PXM node; go up a level */
 	return (bus_generic_get_domain(dev, child, domain));
 }

Modified: head/sys/dev/acpica/acpivar.h
==============================================================================
--- head/sys/dev/acpica/acpivar.h	Sun Apr 19 17:07:51 2015	(r281746)
+++ head/sys/dev/acpica/acpivar.h	Sun Apr 19 17:15:55 2015	(r281747)
@@ -500,8 +500,8 @@ SYSCTL_DECL(_debug_acpi);
 #if MAXMEMDOM > 1
 extern	int acpi_map_pxm_to_vm_domainid(int pxm);
 #endif
-
 extern	int acpi_get_domain(device_t dev, device_t child, int *domain);
+extern	int acpi_parse_pxm(device_t dev, int *domain);
 
 #endif /* _KERNEL */
 #endif /* !_ACPIVAR_H_ */


More information about the svn-src-head mailing list