Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 4 Aug 2014 09:05:29 +0000 (UTC)
From:      Roger Pau Monné <royger@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r269515 - in head/sys: dev/acpica x86/include x86/xen
Message-ID:  <53df4cd9.5042.238e5275@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: royger
Date: Mon Aug  4 09:05:28 2014
New Revision: 269515
URL: http://svnweb.freebsd.org/changeset/base/269515

Log:
  xen: add ACPI bus to xen_nexus when running as Dom0
  
  Also disable a couple of ACPI devices that are not usable under Dom0.
  To this end a couple of booleans are added that allow disabling ACPI
  specific devices.
  
  Sponsored by: Citrix Systems R&D
  Reviewed by: jhb
  
  x86/xen/xen_nexus.c:
   - Return BUS_PROBE_SPECIFIC in the Xen Nexus attachement routine to
     force the usage of the Xen Nexus.
   - Attach the ACPI bus when running as Dom0.
  
  dev/acpica/acpi_cpu.c:
  dev/acpica/acpi_hpet.c:
  dev/acpica/acpi_timer.c
   - Add a variable that gates the addition of the devices.
  
  x86/include/init.h:
   - Declare variables that control the attachment of ACPI cpu, hpet and
     timer devices.

Modified:
  head/sys/dev/acpica/acpi_cpu.c
  head/sys/dev/acpica/acpi_hpet.c
  head/sys/dev/acpica/acpi_timer.c
  head/sys/x86/include/init.h
  head/sys/x86/xen/xen_nexus.c

Modified: head/sys/dev/acpica/acpi_cpu.c
==============================================================================
--- head/sys/dev/acpica/acpi_cpu.c	Mon Aug  4 09:02:49 2014	(r269514)
+++ head/sys/dev/acpica/acpi_cpu.c	Mon Aug  4 09:05:28 2014	(r269515)
@@ -133,6 +133,9 @@ SYSCTL_INT(_debug_acpi, OID_AUTO, cpu_un
     &cpu_unordered, 0,
     "Do not use the MADT to match ACPI Processor objects to CPUs.");
 
+/* Knob to disable acpi_cpu devices */
+bool acpi_cpu_disabled = false;
+
 /* Platform hardware resource information. */
 static uint32_t		 cpu_smi_cmd;	/* Value to write to SMI_CMD. */
 static uint8_t		 cpu_cst_cnt;	/* Indicate we are _CST aware. */
@@ -220,7 +223,8 @@ acpi_cpu_probe(device_t dev)
     ACPI_OBJECT		   *obj;
     ACPI_STATUS		   status;
 
-    if (acpi_disabled("cpu") || acpi_get_type(dev) != ACPI_TYPE_PROCESSOR)
+    if (acpi_disabled("cpu") || acpi_get_type(dev) != ACPI_TYPE_PROCESSOR ||
+	    acpi_cpu_disabled)
 	return (ENXIO);
 
     handle = acpi_get_handle(dev);

Modified: head/sys/dev/acpica/acpi_hpet.c
==============================================================================
--- head/sys/dev/acpica/acpi_hpet.c	Mon Aug  4 09:02:49 2014	(r269514)
+++ head/sys/dev/acpica/acpi_hpet.c	Mon Aug  4 09:05:28 2014	(r269515)
@@ -113,6 +113,9 @@ static void hpet_test(struct hpet_softc 
 
 static char *hpet_ids[] = { "PNP0103", NULL };
 
+/* Knob to disable acpi_hpet device */
+bool acpi_hpet_disabled = false;
+
 static u_int
 hpet_get_timecount(struct timecounter *tc)
 {
@@ -360,7 +363,7 @@ hpet_probe(device_t dev)
 {
 	ACPI_FUNCTION_TRACE((char *)(uintptr_t) __func__);
 
-	if (acpi_disabled("hpet"))
+	if (acpi_disabled("hpet") || acpi_hpet_disabled)
 		return (ENXIO);
 	if (acpi_get_handle(dev) != NULL &&
 	    ACPI_ID_PROBE(device_get_parent(dev), dev, hpet_ids) == NULL)

Modified: head/sys/dev/acpica/acpi_timer.c
==============================================================================
--- head/sys/dev/acpica/acpi_timer.c	Mon Aug  4 09:02:49 2014	(r269514)
+++ head/sys/dev/acpica/acpi_timer.c	Mon Aug  4 09:05:28 2014	(r269515)
@@ -65,6 +65,9 @@ static eventhandler_tag		acpi_timer_eh;
 
 static u_int	acpi_timer_frequency = 14318182 / 4;
 
+/* Knob to disable acpi_timer device */
+bool acpi_timer_disabled = false;
+
 static void	acpi_timer_identify(driver_t *driver, device_t parent);
 static int	acpi_timer_probe(device_t dev);
 static int	acpi_timer_attach(device_t dev);
@@ -125,7 +128,7 @@ acpi_timer_identify(driver_t *driver, de
     ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
 
     if (acpi_disabled("timer") || (acpi_quirks & ACPI_Q_TIMER) ||
-	acpi_timer_dev)
+	acpi_timer_dev || acpi_timer_disabled)
 	return_VOID;
 
     if ((dev = BUS_ADD_CHILD(parent, 2, "acpi_timer", 0)) == NULL) {

Modified: head/sys/x86/include/init.h
==============================================================================
--- head/sys/x86/include/init.h	Mon Aug  4 09:02:49 2014	(r269514)
+++ head/sys/x86/include/init.h	Mon Aug  4 09:05:28 2014	(r269515)
@@ -45,4 +45,13 @@ struct init_ops {
 
 extern struct init_ops init_ops;
 
+/* Knob to disable acpi_cpu devices */
+extern bool acpi_cpu_disabled;
+
+/* Knob to disable acpi_hpet device */
+extern bool acpi_hpet_disabled;
+
+/* Knob to disable acpi_timer device */
+extern bool acpi_timer_disabled;
+
 #endif /* __X86_INIT_H__ */

Modified: head/sys/x86/xen/xen_nexus.c
==============================================================================
--- head/sys/x86/xen/xen_nexus.c	Mon Aug  4 09:02:49 2014	(r269514)
+++ head/sys/x86/xen/xen_nexus.c	Mon Aug  4 09:05:28 2014	(r269515)
@@ -35,6 +35,11 @@ __FBSDID("$FreeBSD$");
 #include <sys/systm.h>
 #include <sys/smp.h>
 
+#include <contrib/dev/acpica/include/acpi.h>
+
+#include <dev/acpica/acpivar.h>
+
+#include <x86/init.h>
 #include <machine/nexusvar.h>
 #include <machine/intr_machdep.h>
 
@@ -51,18 +56,40 @@ nexus_xen_probe(device_t dev)
 	if (!xen_pv_domain())
 		return (ENXIO);
 
-	return (BUS_PROBE_DEFAULT);
+	return (BUS_PROBE_SPECIFIC);
 }
 
 static int
 nexus_xen_attach(device_t dev)
 {
+	int error;
+#ifndef XEN
+	device_t acpi_dev;
+#endif
 
 	nexus_init_resources();
 	bus_generic_probe(dev);
-	bus_generic_attach(dev);
 
-	return (0);
+#ifndef XEN
+	if (xen_initial_domain()) {
+		/* Disable some ACPI devices that are not usable by Dom0 */
+		acpi_cpu_disabled = true;
+		acpi_hpet_disabled = true;
+		acpi_timer_disabled = true;
+
+		acpi_dev = BUS_ADD_CHILD(dev, 10, "acpi", 0);
+		if (acpi_dev == NULL)
+			panic("Unable to add ACPI bus to Xen Dom0");
+	}
+#endif
+
+	error = bus_generic_attach(dev);
+#ifndef XEN
+	if (xen_initial_domain() && (error == 0))
+		acpi_install_wakeup_handler(device_get_softc(acpi_dev));
+#endif
+
+	return (error);
 }
 
 static int



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?53df4cd9.5042.238e5275>