From owner-svn-src-user@FreeBSD.ORG Mon Jan 5 10:41:55 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1F15B106564A; Mon, 5 Jan 2009 10:41:55 +0000 (UTC) (envelope-from dfr@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0DDD78FC1E; Mon, 5 Jan 2009 10:41:55 +0000 (UTC) (envelope-from dfr@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n05AfsmN093722; Mon, 5 Jan 2009 10:41:54 GMT (envelope-from dfr@svn.freebsd.org) Received: (from dfr@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n05Afsup093721; Mon, 5 Jan 2009 10:41:54 GMT (envelope-from dfr@svn.freebsd.org) Message-Id: <200901051041.n05Afsup093721@svn.freebsd.org> From: Doug Rabson Date: Mon, 5 Jan 2009 10:41:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186766 - user/dfr/xenhvm/6/sys/dev/xen/xenpci X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Jan 2009 10:41:55 -0000 Author: dfr Date: Mon Jan 5 10:41:54 2009 New Revision: 186766 URL: http://svn.freebsd.org/changeset/base/186766 Log: Tidy this up and remove all the #if 0 dead code. Add a suitable copyright. Modified: user/dfr/xenhvm/6/sys/dev/xen/xenpci/machine_reboot.c Modified: user/dfr/xenhvm/6/sys/dev/xen/xenpci/machine_reboot.c ============================================================================== --- user/dfr/xenhvm/6/sys/dev/xen/xenpci/machine_reboot.c Mon Jan 5 10:40:19 2009 (r186765) +++ user/dfr/xenhvm/6/sys/dev/xen/xenpci/machine_reboot.c Mon Jan 5 10:41:54 2009 (r186766) @@ -1,125 +1,79 @@ +/*- + * Copyright (c) 2008 Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + #include __FBSDID("$FreeBSD$"); #include -#include #include -#include #include -#include -#include -#include #include -#include #include -#include #include #include -#include -#include #include -struct ap_suspend_info { - int do_spin; - atomic_t nr_spinning; -}; - -#ifdef CONFIG_SMP - -/* - * Spinning prevents, for example, APs touching grant table entries while - * the shared grant table is not mapped into the address space imemdiately - * after resume. - */ -static void ap_suspend(void *_info) -{ - struct ap_suspend_info *info = _info; - - BUG_ON(!irqs_disabled()); - - atomic_inc(&info->nr_spinning); - mb(); - - while (info->do_spin) - cpu_relax(); - - mb(); - atomic_dec(&info->nr_spinning); -} - -#define initiate_ap_suspend(i) smp_call_function(ap_suspend, i, 0, 0) - -#else /* !defined(CONFIG_SMP) */ - -#define initiate_ap_suspend(i) 0 - -#endif - -static int bp_suspend(void) -{ - int suspend_cancelled; - - suspend_cancelled = HYPERVISOR_suspend(0); - if (!suspend_cancelled) - xenpci_resume(); - - return suspend_cancelled; -} - void xen_suspend() { int suspend_cancelled; - //struct ap_suspend_info info; if (DEVICE_SUSPEND(root_bus)) { printf("xen_suspend: device_suspend failed\n"); return; } + /* + * Make sure we don't change cpus or switch to some other + * thread. for the duration. + */ critical_enter(); - /* Prevent any races with evtchn_interrupt() handler. */ + /* + * Prevent any races with evtchn_interrupt() handler. + */ irq_suspend(); - -#if 0 - info.do_spin = 1; - atomic_set(&info.nr_spinning, 0); - smp_mb(); - - nr_cpus = num_online_cpus() - 1; - - err = initiate_ap_suspend(&info); - if (err < 0) { - critical_exit(); - //xenbus_suspend_cancel(); - return err; - } - - while (atomic_read(&info.nr_spinning) != nr_cpus) - cpu_relax(); -#endif - disable_intr(); - suspend_cancelled = bp_suspend(); - //resume_notifier(suspend_cancelled); - enable_intr(); -#if 0 - smp_mb(); - info.do_spin = 0; - while (atomic_read(&info.nr_spinning) != 0) - cpu_relax(); -#endif + suspend_cancelled = HYPERVISOR_suspend(0); + if (!suspend_cancelled) + xenpci_resume(); + /* + * Re-enable interrupts and put the scheduler back to normal. + */ + enable_intr(); critical_exit(); + /* + * FreeBSD really needs to add DEVICE_SUSPEND_CANCEL or + * similar. + */ if (!suspend_cancelled) DEVICE_RESUME(root_bus); -#if 0 - else - xenbus_suspend_cancel(); -#endif }