From owner-svn-src-all@FreeBSD.ORG Sun Apr 19 17:15:56 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 469EE474; Sun, 19 Apr 2015 17:15:56 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 27F56330; Sun, 19 Apr 2015 17:15:56 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t3JHFuOe068376; Sun, 19 Apr 2015 17:15:56 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t3JHFtGh068372; Sun, 19 Apr 2015 17:15:55 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201504191715.t3JHFtGh068372@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Sun, 19 Apr 2015 17:15:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r281747 - head/sys/dev/acpica X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Apr 2015 17:15:56 -0000 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_ */