From owner-freebsd-arch@FreeBSD.ORG Sun Jun 17 06:37:24 2007 Return-Path: X-Original-To: freebsd-arch@freebsd.org Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id BE1D216A46B; Sun, 17 Jun 2007 06:37:24 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail31.syd.optusnet.com.au (mail31.syd.optusnet.com.au [211.29.132.102]) by mx1.freebsd.org (Postfix) with ESMTP id 5290C13C480; Sun, 17 Jun 2007 06:37:24 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from besplex.bde.org (c220-239-235-248.carlnfd3.nsw.optusnet.com.au [220.239.235.248]) by mail31.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id l5H6b8Gf022524 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 17 Jun 2007 16:37:13 +1000 Date: Sun, 17 Jun 2007 16:37:08 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Jeff Roberson In-Reply-To: <20070606152352.H606@10.0.0.1> Message-ID: <20070617153238.K21498@besplex.bde.org> References: <20070529105856.L661@10.0.0.1> <200705291456.38515.jhb@freebsd.org> <20070529121653.P661@10.0.0.1> <20070530065423.H93410@delplex.bde.org> <20070529141342.D661@10.0.0.1> <20070530125553.G12128@besplex.bde.org> <20070529201255.X661@10.0.0.1> <20070529220936.W661@10.0.0.1> <20070530201618.T13220@besplex.bde.org> <20070530115752.F661@10.0.0.1> <20070531091419.S826@besplex.bde.org> <20070531010631.N661@10.0.0.1> <20070601154833.O4207@besplex.bde.org> <20070601014601.I799@10.0.0.1> <20070601200348.G6201@delplex.bde.org> <20070601123530.B606@10.0.0.1> <20070604160036.N1084@besplex.bde.org> <46652D17.5090903@FreeBSD.org> <20070605214404.X47001@delplex.bde.org> <20070606152352.H606@10.0.0.1> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: Attilio Rao , freebsd-arch@freebsd.org Subject: Re: Updated rusage patch X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Jun 2007 06:37:24 -0000 On Wed, 6 Jun 2007, Jeff Roberson wrote: > I'd like to make a list of the remaining problems with rusage and potential > fixes. Then we can decide which ones myself and attilio will resolve > immediately to clean up some of the effect of the sched lock changes. I haven't verified which of these fixes is necessary and/or has been done yet. The list is a bit incomplete. 3 more minor problems turned up (one caused by applying one of these fixes?). (1) Results of some makeworlds run after the threead lock changes, all with fixes for pagezero (best previous result 827 seconds; results without touching pagezero ~845 seconds without PREEMPTION; ~837 seconds with PREEMPTION). Only the differences in the following results are interesting. % Sat Jun 9 03:28:33 UTC 2007: % 831.61 real 1308.57 user 184.80 sys % 1320199 voluntary context switches % 1533639 involuntary context switches % pgzero time 7 seconds Base result. % Wed Jun 13 14:52:15 UTC 2007: % 833.97 real 1291.71 user 201.64 sys % 1329247 voluntary context switches % 1518959 involuntary context switches % pgzero time 7 seconds Some change between June 9 and June 13 made a big difference to the user+sys decomposition. I think the June 9 result is more correct. % Wed Jun 13 14:52:15 UTC 2007: % Same kernel as previous with HZ = 1000 (HZ = 100 except as noted); stathz = 100 % 836.24 real 1310.22 user 191.04 sys % 1323793 voluntary context switches % 1559229 involuntary context switches % pgzero time 7 seconds The accuracy of the decomposition depends mainly on stathz (the decomposition is based on statclock tick counts, and there is a significant bias towards system time when the tick counts are all 0 -- see calcru1() -- which is reduced by increasing stathz) I forgot that stathz != HZ and tried the HZ = 1000 pessimization to fix it. This somehow gave the old decomposition. (2) By reading the code, in sched_throw() (from sched_4bsd.c; the version in sched_ule.c is identical; duplicating this is another bug): % /* % * A CPU is entering for the first time or a thread is exiting. % */ % void % sched_throw(struct thread *td) % { % /* % * Correct spinlock nesting. The idle thread context that we are % * borrowing was created so that it would start out with a single % * spin lock (sched_lock) held in fork_trampoline(). Since we've % * explicitly acquired locks in this function, the nesting count % * is now 2 rather than 1. Since we are nested, calling % * spinlock_exit() will simply adjust the counts without allowing % * spin lock using code to interrupt us. % */ % if (td == NULL) { % mtx_lock_spin(&sched_lock); % spinlock_exit(); % } else { % MPASS(td->td_lock == &sched_lock); % } Comment doesn't match code (comment only applies to td == NULL case). % mtx_assert(&sched_lock, MA_OWNED); % KASSERT(curthread->td_md.md_spinlock_count == 1, ("invalid count")); % PCPU_SET(switchtime, cpu_ticks()); % PCPU_SET(switchticks, ticks); % cpu_throw(td, choosethread()); /* doesn't return */ % } Setting switchtime, etc., here loses the delta between the current time and switchtime. Old code only sets switchtime when a CPU is entering for the first time. switchtime is normally not actually a switch time, but is set by thread_exit() just before calling here. Not much time should be lost from this, but lots seems to be in practice. According to a benchmark that does 100000 fork/wait/exits: 2.99 real 0.13 user 2.78 sys About 3% of the time is not accounted for. Interrupt and kernel thread time can only account for < 1%. Old code didn't get this nearly right either, despite my attempts to minimize the unaccounted-for time. Fixing it should be easier now. Of course, the part of the time for exiting cannot _all_ be accounted to the exiting thread. I want as much of it as possible to go there and the rest to the next thread (which might be idlethread in general, so the time would be almost invisible, but for the fork-wait-exit benchmark the fork-wait thread should always be switched to next to complete its wait()). (3) Bugs found while grepping near cpu_throw: - kern_thread.c has cpu_throw() hard-coded in 4 comments and one string, but now only calls sched_throw(). - sched_throw() is not declared as non-returning in sys/sched.h. - kern_thread.c has a bogus panic and NOTREACHED comment after sched_throw() doesn't return. Bruce From owner-freebsd-arch@FreeBSD.ORG Mon Jun 18 00:31:22 2007 Return-Path: X-Original-To: arch@freebsd.org Delivered-To: freebsd-arch@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 47F1016A41F for ; Mon, 18 Jun 2007 00:31:22 +0000 (UTC) (envelope-from nate@root.org) Received: from root.org (root.org [67.118.192.226]) by mx1.freebsd.org (Postfix) with ESMTP id 1A25B13C44B for ; Mon, 18 Jun 2007 00:31:22 +0000 (UTC) (envelope-from nate@root.org) Received: (qmail 46818 invoked from network); 17 Jun 2007 17:13:41 -0000 Received: from ppp-71-139-42-13.dsl.snfc21.pacbell.net (HELO ?10.0.0.15?) (nate-mail@71.139.42.13) by root.org with ESMTPA; 17 Jun 2007 17:13:41 -0000 Message-ID: <46756BBE.5030603@root.org> Date: Sun, 17 Jun 2007 10:13:34 -0700 From: Nate Lawson User-Agent: Thunderbird 2.0.0.0 (X11/20070511) MIME-Version: 1.0 To: current X-Enigmail-Version: 0.95.0 Content-Type: multipart/mixed; boundary="------------040100070106020900000700" Cc: acpi@freebsd.org, arch@freebsd.org Subject: patch: acpi usermode suspend API change X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jun 2007 00:31:22 -0000 This is a multi-part message in MIME format. --------------040100070106020900000700 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit This patch updates the user API for acpi suspend in a number of ways. * /etc/rc.suspend,rc.resume are always run, no matter the source of the suspend event * suspend now requires positive user acknowledgement. If a user program wants to cancel the suspend, they can. If one of the user programs hangs or doesn't respond within 10 seconds, the system suspends anyway. * /dev/apm is clonable, allowing multiple listeners for suspend events. In the future, xorg-server can use this to be informed about suspend even if there are other listeners (i.e. apmd). The API changes are intended to be MFCd and hence are minimal. * Two new ACPI ioctls: REQSLPSTATE and ACKSLPSTATE. Request begins the process of suspending by notifying all listeners. acpi is monitored by devd(8) and /dev/apm listener(s) are also counted. Users register their approval or disapproval via Ack. If anyone disapproves, suspend is vetoed. * Binary compat is preserved in that old user programs or kernel modules (yeah, right) that called the API can still do so. A message is printed once that this interface is deprecated. * acpiconf gains the -k flag to ack the suspend request. This flag is undocumented on purpose since it's only used by /etc/rc.suspend. It is not intended to be a permanent change and will be removed once a better power API is implemented. These patches have been successfully tested for about a week through suspend/resumes and various usermode programs, including patches to xorg-server. The eventual goal is to improve subr_power to be a more generic central power management interface to user and kernel providers. powerd(8) might start managing profiles similar to apmd(8). I don't know yet and there isn't time to do that. This patch provides a reasonable interface for now and eliminates some serious weaknesses, especially in that pressing a sleep button did not guarantee rc.suspend would run before sleeping. Comments welcome, patches are for 6.x and 7.x. -- Nate --------------040100070106020900000700 Content-Type: text/x-patch; name="acpi6_wakeapi.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="acpi6_wakeapi.diff" Index: etc/devd.conf =================================================================== RCS file: /home/ncvs/src/etc/devd.conf,v retrieving revision 1.26.2.5 diff -u -r1.26.2.5 devd.conf --- etc/devd.conf 24 Jul 2006 20:42:36 -0000 1.26.2.5 +++ etc/devd.conf 17 Jun 2007 16:58:35 -0000 @@ -148,6 +148,19 @@ action "logger -p kern.emerg 'WARNING: system temperature too high, shutting down soon!'"; }; +# User requested suspend, so perform preparation steps and then execute +# the actual suspend process. +notify 10 { + match "system" "ACPI"; + match "subsystem" "Suspend"; + action "/etc/rc.suspend acpi $notify"; +}; +notify 10 { + match "system" "ACPI"; + match "subsystem" "Resume"; + action "/etc/rc.resume acpi $notify"; +}; + /* EXAMPLES TO END OF FILE # The following might be an example of something that a vendor might @@ -186,6 +199,7 @@ # Button: Button pressed (0 for power, 1 for sleep) # CMBAT: ACPI battery events # Lid: Lid state (0 is closed, 1 is open) +# Suspend, Resume: Suspend and resume notification # Thermal: ACPI thermal zone events # # This example calls a script when the AC state changes, passing the Index: etc/rc.resume =================================================================== RCS file: /home/ncvs/src/etc/rc.resume,v retrieving revision 1.7 diff -u -r1.7 rc.resume --- etc/rc.resume 30 Dec 2003 17:30:39 -0000 1.7 +++ etc/rc.resume 17 Jun 2007 16:58:35 -0000 @@ -30,7 +30,7 @@ # sample run command file for APM Resume Event if [ $# -ne 2 ]; then - echo "Usage: $0 [apm|acpi] [standby,suspend|1-5]" + echo "Usage: $0 [apm|acpi] [standby,suspend|1-4]" exit 1 fi @@ -48,9 +48,13 @@ # pccardq | awk -F '~' '$5 == "inactive" \ # { printf("pccardc power %d 1", $1); }' | sh -# UHCI has trouble resuming so we just load/unload it. You -# should add any other kernel modules you want reloaded here. -# kldload usb +# If a device driver has problems resuming, try unloading it before +# suspend and reloading it on resume. Example: +# kldunload usb + +# wpa_supplicant(8) doesn't seem to reassociate during resume. Uncomment +# the following to signal it to reassociate. +# /usr/sbin/wpa_cli reassociate logger -t $subsystem resumed at `date +'%Y%m%d %H:%M:%S'` sync && sync && sync Index: etc/rc.suspend =================================================================== RCS file: /home/ncvs/src/etc/rc.suspend,v retrieving revision 1.6 diff -u -r1.6 rc.suspend --- etc/rc.suspend 21 Jan 2004 03:03:40 -0000 1.6 +++ etc/rc.suspend 17 Jun 2007 16:58:35 -0000 @@ -30,7 +30,7 @@ # sample run command file for APM Suspend Event if [ $# -ne 2 ]; then - echo "Usage: $0 [apm|acpi] [standby,suspend|1-5]" + echo "Usage: $0 [apm|acpi] [standby,suspend|1-4]" exit 1 fi @@ -48,15 +48,20 @@ # pccardq | awk -F '~' '$5 == "filled" && $4 ~ /sio/ \ # { printf("pccardc power %d 0", $1); }' | sh -# UHCI has trouble resuming so we just load/unload it. You -# should add any other kernel modules you want unloaded here. +# If a device driver has problems suspending, try unloading it before +# suspend and reloading it on resume. Example: # kldunload usb logger -t $subsystem suspend at `date +'%Y%m%d %H:%M:%S'` sync && sync && sync -[ $subsystem = "apm" ] && sleep 3 +sleep 3 rm -f /var/run/rc.suspend.pid -[ $subsystem = "apm" ] && zzz +if [ $subsystem = "apm" ]; then + /usr/sbin/zzz +else + # Notify the kernel to continue the suspend process + /usr/sbin/acpiconf -k 0 +fi exit 0 Index: sys/dev/acpica/acpi.c =================================================================== RCS file: /home/ncvs/src/sys/dev/acpica/acpi.c,v retrieving revision 1.214.2.10 diff -u -r1.214.2.10 acpi.c --- sys/dev/acpica/acpi.c 26 May 2007 00:48:55 -0000 1.214.2.10 +++ sys/dev/acpica/acpi.c 17 Jun 2007 16:58:35 -0000 @@ -136,6 +136,7 @@ static ACPI_STATUS acpi_probe_child(ACPI_HANDLE handle, UINT32 level, void *context, void **status); static BOOLEAN acpi_MatchHid(ACPI_HANDLE h, const char *hid); +static ACPI_STATUS acpi_EnterSleepState(struct acpi_softc *sc, int state); static void acpi_shutdown_final(void *arg, int howto); static void acpi_enable_fixed_events(struct acpi_softc *sc); static int acpi_wake_sleep_prep(ACPI_HANDLE handle, int sstate); @@ -414,6 +415,7 @@ sc = device_get_softc(dev); sc->acpi_dev = dev; + callout_init(&sc->susp_force_to, TRUE); /* Initialize resource manager. */ acpi_rman_io.rm_type = RMAN_ARRAY; @@ -561,7 +563,7 @@ /* Pick the first valid sleep state for the sleep button default. */ sc->acpi_sleep_button_sx = ACPI_S_STATES_MAX + 1; - for (state = ACPI_STATE_S1; state < ACPI_STATE_S5; state++) + for (state = ACPI_STATE_S1; state <= ACPI_STATE_S4; state++) if (ACPI_SUCCESS(AcpiGetSleepTypeData(state, &TypeA, &TypeB))) { sc->acpi_sleep_button_sx = state; break; @@ -2100,6 +2102,143 @@ return (acpi_SetInteger(ACPI_ROOT_OBJECT, "_PIC", model)); } +/* + * DEPRECATED. This interface has serious deficiencies and will be + * removed. + * + * Immediately enter the sleep state. In the old model, acpiconf(8) ran + * rc.suspend and rc.resume so we don't have to notify devd(8) to do this. + */ +ACPI_STATUS +acpi_SetSleepState(struct acpi_softc *sc, int state) +{ + static int once; + + if (!once) { + printf( +"warning: acpi_SetSleepState deprecated, need to update your software\n"); + once = 1; + } + return (acpi_EnterSleepState(sc, state)); +} + +static void +acpi_sleep_force(void *arg) +{ + struct acpi_softc *sc; + + printf("acpi: suspend request timed out, forcing sleep now\n"); + sc = arg; + acpi_EnterSleepState(sc, sc->acpi_next_sstate); +} + +/* + * Request that the system enter the given suspend state. All /dev/apm + * devices and devd(8) will be notified. Userland then has a chance to + * save state and acknowledge the request. The system sleeps once all + * acks are in. + */ +int +acpi_ReqSleepState(struct acpi_softc *sc, int state) +{ + struct apm_clone_data *clone; + + /* S5 (soft-off) should be entered via shutdown_nice(). */ + if (state < ACPI_STATE_S1 || state > ACPI_STATE_S4) + return (EINVAL); + + /* If a suspend request is already in progress, just return. */ + ACPI_LOCK(acpi); + if (sc->acpi_next_sstate != 0) { + ACPI_UNLOCK(acpi); + return (0); + } + + /* Record the pending state and notify all apm devices. */ + sc->acpi_next_sstate = state; + STAILQ_FOREACH(clone, &sc->apm_cdevs, entries) { +printf("considering clone of %s\n", devtoname(clone->cdev)); + clone->notify_status = APM_EV_NONE; + if ((clone->flags & ACPI_EVF_DEVD) == 0) { +printf("acpi ev got %d, waking listener %p\n", state, clone); + selwakeuppri(&clone->sel_read, PZERO); + KNOTE_UNLOCKED(&clone->sel_read.si_note, 0); + } + } + + /* Now notify devd(8) also. */ + acpi_UserNotify("Suspend", ACPI_ROOT_OBJECT, state); + + /* + * Set a timeout to fire if userland doesn't ack the suspend request + * in time. This way we still eventually go to sleep if we were + * overheating or running low on battery, even if userland is hung. + * We cancel this timeout once all userland acks are in or the + * suspend request is aborted. + */ + callout_reset(&sc->susp_force_to, 10 * hz, acpi_sleep_force, sc); + ACPI_UNLOCK(acpi); + return (0); +} + +/* + * Acknowledge (or reject) a pending sleep state. The caller has + * prepared for suspend and is now ready for it to proceed. If the + * error argument is non-zero, it indicates suspend should be cancelled + * and gives an errno value describing why. Once all votes are in, + * we suspend the system. + */ +int +acpi_AckSleepState(struct apm_clone_data *clone, int error) +{ + struct acpi_softc *sc; + int sleeping; + + /* If no pending sleep state, return an error. */ + ACPI_LOCK(acpi); + sc = clone->acpi_sc; + if (sc->acpi_next_sstate == 0) { + ACPI_UNLOCK(acpi); + return (ENXIO); + } + + /* Caller wants to abort suspend process. */ + if (error) { + sc->acpi_next_sstate = 0; + callout_stop(&sc->susp_force_to); + printf("acpi: listener on %s cancelled the pending suspend\n", + devtoname(clone->cdev)); + ACPI_UNLOCK(acpi); + return (0); + } + + /* + * Mark this device as acking the suspend request. Then, walk through + * all devices, seeing if they agree yet. We only count devices that + * are writable since read-only devices couldn't ack the request. + */ + clone->notify_status = APM_EV_ACKED; + sleeping = TRUE; + STAILQ_FOREACH(clone, &sc->apm_cdevs, entries) { + if ((clone->flags & ACPI_EVF_WRITE) != 0 && + clone->notify_status != APM_EV_ACKED) { + sleeping = FALSE; + break; + } + } + + /* If all devices have voted "yes", we will suspend now. */ + if (sleeping) { +printf("ack: all devs said yes, sleeping now\n"); + callout_stop(&sc->susp_force_to); + } + ACPI_UNLOCK(acpi); + if (sleeping) + acpi_EnterSleepState(sc, sc->acpi_next_sstate); + + return (0); +} + static void acpi_sleep_enable(void *arg) { @@ -2116,12 +2255,12 @@ }; /* - * Set the system sleep state + * Enter the desired system sleep state. * * Currently we support S1-S5 but S4 is only S4BIOS */ -ACPI_STATUS -acpi_SetSleepState(struct acpi_softc *sc, int state) +static ACPI_STATUS +acpi_EnterSleepState(struct acpi_softc *sc, int state) { ACPI_STATUS status; UINT8 TypeA; @@ -2233,6 +2372,7 @@ * Back out state according to how far along we got in the suspend * process. This handles both the error and success cases. */ + sc->acpi_next_sstate = 0; if (slp_state >= ACPI_SS_GPE_SET) { acpi_wake_prep_walk(state); sc->acpi_sstate = ACPI_STATE_S0; @@ -2246,7 +2386,10 @@ /* Allow another sleep request after a while. */ if (state != ACPI_STATE_S5) - timeout(acpi_sleep_enable, (caddr_t)sc, hz * ACPI_MINIMUM_AWAKETIME); + timeout(acpi_sleep_enable, sc, hz * ACPI_MINIMUM_AWAKETIME); + + /* Run /etc/rc.resume after we are back. */ + acpi_UserNotify("Resume", ACPI_ROOT_OBJECT, state); mtx_unlock(&Giant); return_ACPI_STATUS (status); @@ -2558,11 +2701,14 @@ static void acpi_system_eventhandler_sleep(void *arg, int state) { + int ret; ACPI_FUNCTION_TRACE_U32((char *)(uintptr_t)__func__, state); - if (state >= ACPI_STATE_S0 && state <= ACPI_S_STATES_MAX) - acpi_SetSleepState((struct acpi_softc *)arg, state); + /* Request that the system prepare to enter the given suspend state. */ + ret = acpi_ReqSleepState((struct acpi_softc *)arg, state); + if (ret != 0) + printf("acpi: request to enter state S%d failed\n", state); return_VOID; } @@ -2824,7 +2970,15 @@ /* Core system ioctls. */ switch (cmd) { - case ACPIIO_SETSLPSTATE: + case ACPIIO_REQSLPSTATE: + state = *(int *)addr; + error = acpi_ReqSleepState(sc, state); + break; + case ACPIIO_ACKSLPSTATE: + error = *(int *)addr; + error = acpi_AckSleepState(sc->acpi_clone, error); + break; + case ACPIIO_SETSLPSTATE: /* DEPRECATED */ error = EINVAL; state = *(int *)addr; if (state >= ACPI_STATE_S0 && state <= ACPI_S_STATES_MAX) Index: sys/dev/acpica/acpiio.h =================================================================== RCS file: /home/ncvs/src/sys/dev/acpica/acpiio.h,v retrieving revision 1.14.2.2 diff -u -r1.14.2.2 acpiio.h --- sys/dev/acpica/acpiio.h 5 Nov 2005 23:55:56 -0000 1.14.2.2 +++ sys/dev/acpica/acpiio.h 17 Jun 2007 16:58:35 -0000 @@ -33,7 +33,13 @@ /* * Core ACPI subsystem ioctls */ -#define ACPIIO_SETSLPSTATE _IOW('P', 3, int) +#define ACPIIO_SETSLPSTATE _IOW('P', 3, int) /* DEPRECATED */ + +/* Request S1-5 sleep state. User is notified and then sleep proceeds. */ +#define ACPIIO_REQSLPSTATE _IOW('P', 4, int) + +/* Allow suspend to continue (0) or abort it (errno). */ +#define ACPIIO_ACKSLPSTATE _IOW('P', 5, int) struct acpi_battinfo { int cap; /* percent */ Index: sys/dev/acpica/acpivar.h =================================================================== RCS file: /home/ncvs/src/sys/dev/acpica/acpivar.h,v retrieving revision 1.95.2.5 diff -u -r1.95.2.5 acpivar.h --- sys/dev/acpica/acpivar.h 23 Jan 2007 07:21:23 -0000 1.95.2.5 +++ sys/dev/acpica/acpivar.h 17 Jun 2007 16:58:35 -0000 @@ -39,12 +39,14 @@ #include #include #include +#include #include #include #include #include +struct apm_clone_data; struct acpi_softc { device_t acpi_dev; struct cdev *acpi_dev_t; @@ -76,6 +78,11 @@ bus_dmamap_t acpi_wakemap; vm_offset_t acpi_wakeaddr; vm_paddr_t acpi_wakephys; + + int acpi_next_sstate; /* Next suspend Sx state. */ + struct apm_clone_data *acpi_clone; /* Pseudo-dev for devd(8). */ + STAILQ_HEAD(,apm_clone_data) apm_cdevs; /* All apm/apmctl/acpi cdevs. */ + struct callout susp_force_to; /* Force suspend if no acks. */ }; struct acpi_device { @@ -89,6 +96,22 @@ struct resource_list ad_rl; }; +/* Track device (/dev/{apm,apmctl} and /dev/acpi) notification status. */ +struct apm_clone_data { + STAILQ_ENTRY(apm_clone_data) entries; + struct cdev *cdev; + int flags; +#define ACPI_EVF_NONE 0 /* /dev/apm semantics */ +#define ACPI_EVF_DEVD 1 /* /dev/acpi is handled via devd(8) */ +#define ACPI_EVF_WRITE 2 /* Device instance is opened writable. */ + int notify_status; +#define APM_EV_NONE 0 /* Device not yet aware of pending sleep. */ +#define APM_EV_NOTIFIED 1 /* Device saw next sleep state. */ +#define APM_EV_ACKED 2 /* Device agreed sleep can occur. */ + struct acpi_softc *acpi_sc; + struct selinfo sel_read; +}; + #define ACPI_PRW_MAX_POWERRES 8 struct acpi_prw_data { @@ -304,6 +327,8 @@ ACPI_RESOURCE *res); ACPI_STATUS acpi_OverrideInterruptLevel(UINT32 InterruptNumber); ACPI_STATUS acpi_SetIntrModel(int model); +int acpi_ReqSleepState(struct acpi_softc *sc, int state); +int acpi_AckSleepState(struct apm_clone_data *clone, int error); ACPI_STATUS acpi_SetSleepState(struct acpi_softc *sc, int state); int acpi_wake_init(device_t dev, int type); int acpi_wake_set_enable(device_t dev, int enable); Index: sys/i386/acpica/acpi_machdep.c =================================================================== RCS file: /home/ncvs/src/sys/i386/acpica/acpi_machdep.c,v retrieving revision 1.28.2.4 diff -u -r1.28.2.4 acpi_machdep.c --- sys/i386/acpica/acpi_machdep.c 2 May 2007 18:42:46 -0000 1.28.2.4 +++ sys/i386/acpica/acpi_machdep.c 17 Jun 2007 16:58:35 -0000 @@ -32,6 +32,8 @@ #include #include #include +#include +#include #include #include #include @@ -45,8 +47,6 @@ * APM driver emulation */ -#include - #include #include @@ -63,21 +63,31 @@ static int intr_model = ACPI_INTR_PIC; static int apm_active; +static struct clonedevs *apm_clones; + +MALLOC_DEFINE(M_APMDEV, "apmdev", "APM device emulation"); -static d_open_t apmopen; -static d_close_t apmclose; -static d_write_t apmwrite; -static d_ioctl_t apmioctl; -static d_poll_t apmpoll; +static d_open_t apmopen; +static d_close_t apmclose; +static d_write_t apmwrite; +static d_ioctl_t apmioctl; +static d_poll_t apmpoll; +static d_kqfilter_t apmkqfilter; +static void apmreadfiltdetach(struct knote *kn); +static int apmreadfilt(struct knote *kn, long hint); +static struct filterops apm_readfiltops = + { 1, NULL, apmreadfiltdetach, apmreadfilt }; static struct cdevsw apm_cdevsw = { .d_version = D_VERSION, + .d_flags = D_TRACKCLOSE, .d_open = apmopen, .d_close = apmclose, .d_write = apmwrite, .d_ioctl = apmioctl, .d_poll = apmpoll, .d_name = "apm", + .d_kqfilter = apmkqfilter }; static int @@ -201,44 +211,159 @@ return (0); } +/* Create single-use devices for /dev/apm and /dev/apmctl. */ +static void +apm_clone(void *arg, struct ucred *cred, char *name, int namelen, + struct cdev **dev) +{ + int ctl_dev, unit; + + if (*dev != NULL) + return; + if (strcmp(name, "apmctl") == 0) + ctl_dev = TRUE; + else if (strcmp(name, "apm") == 0) + ctl_dev = FALSE; + else + return; + + /* Always create a new device and unit number. */ + unit = -1; + if (clone_create(&apm_clones, &apm_cdevsw, &unit, dev, 0)) { + if (ctl_dev) { + *dev = make_dev(&apm_cdevsw, unit2minor(unit), + UID_ROOT, GID_OPERATOR, 0660, "apmctl%d", unit); + } else { + *dev = make_dev(&apm_cdevsw, unit2minor(unit), + UID_ROOT, GID_OPERATOR, 0664, "apm%d", unit); + } + if (*dev != NULL) { + dev_ref(*dev); + (*dev)->si_flags |= SI_CHEAPCLONE; + } + } +} + +/* Create a struct for tracking per-device suspend notification. */ +static struct apm_clone_data * +apm_create_clone(struct cdev *dev, struct acpi_softc *acpi_sc) +{ + struct apm_clone_data *clone; + + clone = malloc(sizeof(*clone), M_APMDEV, M_WAITOK); + clone->cdev = dev; + clone->acpi_sc = acpi_sc; + clone->notify_status = APM_EV_NONE; + bzero(&clone->sel_read, sizeof(clone->sel_read)); + knlist_init(&clone->sel_read.si_note, &acpi_mutex, NULL, NULL, NULL); + + /* + * The acpi device is always managed by devd(8) and is considered + * writable (i.e., ack is required to allow suspend to proceed.) + */ + if (strcmp("acpi", devtoname(dev)) == 0) + clone->flags = ACPI_EVF_DEVD | ACPI_EVF_WRITE; + else + clone->flags = ACPI_EVF_NONE; + + ACPI_LOCK(acpi); + STAILQ_INSERT_TAIL(&acpi_sc->apm_cdevs, clone, entries); + ACPI_UNLOCK(acpi); + return (clone); +} + static int apmopen(struct cdev *dev, int flag, int fmt, d_thread_t *td) { + struct acpi_softc *acpi_sc; + struct apm_clone_data *clone; + + acpi_sc = devclass_get_softc(devclass_find("acpi"), 0); + clone = apm_create_clone(dev, acpi_sc); + dev->si_drv1 = clone; + + /* If the device is opened for write, record that. */ + if ((flag & FWRITE) != 0) + clone->flags |= ACPI_EVF_WRITE; + +printf("%s opened clone %p\n", devtoname(dev), (struct apm_clone_data *)dev->si_drv1); return (0); } static int apmclose(struct cdev *dev, int flag, int fmt, d_thread_t *td) { + struct apm_clone_data *clone; + struct acpi_softc *acpi_sc; + + clone = dev->si_drv1; + acpi_sc = clone->acpi_sc; + + /* We are about to lose a reference so check if suspend should occur */ + if (acpi_sc->acpi_next_sstate != 0 && + clone->notify_status != APM_EV_ACKED) + acpi_AckSleepState(clone, 0); + + /* Remove this clone's data from the list and free it. */ + ACPI_LOCK(acpi); + STAILQ_REMOVE(&acpi_sc->apm_cdevs, clone, apm_clone_data, entries); + knlist_destroy(&clone->sel_read.si_note); +printf("%s closed clone %p\n", devtoname(dev), clone); + ACPI_UNLOCK(acpi); + free(clone, M_APMDEV); + /* XXX destroy_dev() needed */ return (0); } static int apmioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, d_thread_t *td) { - int error = 0; + int error; + struct apm_clone_data *clone; struct acpi_softc *acpi_sc; - struct apm_info info; + struct apm_info info; + struct apm_event_info *ev_info; apm_info_old_t aiop; - acpi_sc = devclass_get_softc(devclass_find("acpi"), 0); + error = 0; + clone = dev->si_drv1; + acpi_sc = clone->acpi_sc; switch (cmd) { case APMIO_SUSPEND: if ((flag & FWRITE) == 0) return (EPERM); - if (apm_active) - acpi_SetSleepState(acpi_sc, acpi_sc->acpi_suspend_sx); +printf("apm ioctl suspend\n"); + if (acpi_sc->acpi_next_sstate == 0) + acpi_ReqSleepState(acpi_sc, acpi_sc->acpi_suspend_sx); else - error = EINVAL; + acpi_AckSleepState(clone, 0); break; case APMIO_STANDBY: if ((flag & FWRITE) == 0) return (EPERM); - if (apm_active) - acpi_SetSleepState(acpi_sc, acpi_sc->acpi_standby_sx); +printf("apm ioctl standby\n"); + if (acpi_sc->acpi_next_sstate == 0) + acpi_ReqSleepState(acpi_sc, acpi_sc->acpi_standby_sx); else - error = EINVAL; + acpi_AckSleepState(clone, 0); + break; + case APMIO_NEXTEVENT: + printf("apm nextevent start\n"); + ACPI_LOCK(acpi); + if (acpi_sc->acpi_next_sstate != 0 && clone->notify_status == + APM_EV_NONE) { + ev_info = (struct apm_event_info *)addr; + if (acpi_sc->acpi_next_sstate <= ACPI_STATE_S3) + ev_info->type = PMEV_STANDBYREQ; + else + ev_info->type = PMEV_SUSPENDREQ; + ev_info->index = 0; + clone->notify_status = APM_EV_NOTIFIED; + printf("apm event returning %d\n", ev_info->type); + } else + error = EAGAIN; + ACPI_UNLOCK(acpi); break; case APMIO_GETINFO_OLD: if (acpi_capm_get_info(&info)) @@ -299,24 +424,72 @@ static int apmpoll(struct cdev *dev, int events, d_thread_t *td) { + struct apm_clone_data *clone; + int revents; + + revents = 0; + ACPI_LOCK(acpi); + clone = dev->si_drv1; + if (clone->acpi_sc->acpi_next_sstate) + revents |= events & (POLLIN | POLLRDNORM); + else + selrecord(td, &clone->sel_read); + ACPI_UNLOCK(acpi); +printf("apm poll returning %x\n", revents); + return (revents); +} + +static int +apmkqfilter(struct cdev *dev, struct knote *kn) +{ + struct apm_clone_data *clone; + + ACPI_LOCK(acpi); + clone = dev->si_drv1; + kn->kn_hook = clone; + kn->kn_fop = &apm_readfiltops; + knlist_add(&clone->sel_read.si_note, kn, 0); + ACPI_UNLOCK(acpi); return (0); } static void -acpi_capm_init(struct acpi_softc *sc) +apmreadfiltdetach(struct knote *kn) +{ + struct apm_clone_data *clone; + + ACPI_LOCK(acpi); + clone = kn->kn_hook; + knlist_remove(&clone->sel_read.si_note, kn, 0); + ACPI_UNLOCK(acpi); +} + +static int +apmreadfilt(struct knote *kn, long hint) { - make_dev(&apm_cdevsw, 0, 0, 5, 0664, "apm"); + struct apm_clone_data *clone; + int sleeping; + + ACPI_LOCK(acpi); + clone = kn->kn_hook; + sleeping = clone->acpi_sc->acpi_next_sstate ? 1 : 0; + ACPI_UNLOCK(acpi); + return (sleeping); } int acpi_machdep_init(device_t dev) { - struct acpi_softc *sc; + struct acpi_softc *acpi_sc; - sc = devclass_get_softc(devclass_find("acpi"), 0); - acpi_capm_init(sc); + acpi_sc = devclass_get_softc(devclass_find("acpi"), 0); - acpi_install_wakeup_handler(sc); + /* Create a clone for /dev/acpi also. */ + STAILQ_INIT(&acpi_sc->apm_cdevs); + acpi_sc->acpi_clone = apm_create_clone(acpi_sc->acpi_dev_t, acpi_sc); + clone_setup(&apm_clones); + EVENTHANDLER_REGISTER(dev_clone, apm_clone, 0, 1000); + acpi_install_wakeup_handler(acpi_sc); if (intr_model == ACPI_INTR_PIC) BUS_CONFIG_INTR(dev, AcpiGbl_FADT->SciInt, INTR_TRIGGER_LEVEL, @@ -324,8 +497,8 @@ else acpi_SetIntrModel(intr_model); - SYSCTL_ADD_UINT(&sc->acpi_sysctl_ctx, - SYSCTL_CHILDREN(sc->acpi_sysctl_tree), OID_AUTO, + SYSCTL_ADD_UINT(&acpi_sc->acpi_sysctl_ctx, + SYSCTL_CHILDREN(acpi_sc->acpi_sysctl_tree), OID_AUTO, "reset_video", CTLFLAG_RW, &acpi_reset_video, 0, "Call the VESA reset BIOS vector on the resume path"); Index: usr.sbin/acpi/acpiconf/acpiconf.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/acpi/acpiconf/acpiconf.c,v retrieving revision 1.22.2.1 diff -u -r1.22.2.1 acpiconf.c --- usr.sbin/acpi/acpiconf/acpiconf.c 29 Jul 2005 16:31:58 -0000 1.22.2.1 +++ usr.sbin/acpi/acpiconf/acpiconf.c 17 Jun 2007 16:58:35 -0000 @@ -40,8 +40,6 @@ #include #define ACPIDEV "/dev/acpi" -#define RC_SUSPEND_PATH "/etc/rc.suspend" -#define RC_RESUME_PATH "/etc/rc.resume" static int acpifd; @@ -55,32 +53,27 @@ err(EX_OSFILE, ACPIDEV); } -static int +/* Prepare to sleep and then wait for the signal that sleeping can occur. */ +static void acpi_sleep(int sleep_type) { - char cmd[64]; int ret; + + /* Notify OS that we want to sleep. devd(8) gets this notify. */ + ret = ioctl(acpifd, ACPIIO_REQSLPSTATE, &sleep_type); + if (ret != 0) + err(EX_IOERR, "request sleep type (%d) failed", sleep_type); +} - /* Run the suspend rc script, if available. */ - if (access(RC_SUSPEND_PATH, X_OK) == 0) { - snprintf(cmd, sizeof(cmd), "%s acpi %d", RC_SUSPEND_PATH, - sleep_type); - system(cmd); - } - - ret = ioctl(acpifd, ACPIIO_SETSLPSTATE, &sleep_type); - - /* Run the resume rc script, if available. */ - if (access(RC_RESUME_PATH, X_OK) == 0) { - snprintf(cmd, sizeof(cmd), "%s acpi %d", RC_RESUME_PATH, - sleep_type); - system(cmd); - } +/* Ack or abort a pending suspend request. */ +static void +acpi_sleep_ack(int err_val) +{ + int ret; + ret = ioctl(acpifd, ACPIIO_ACKSLPSTATE, &err_val); if (ret != 0) - err(EX_IOERR, "sleep type (%d) failed", sleep_type); - - return (0); + err(EX_IOERR, "ack sleep type failed"); } /* should be a acpi define, but doesn't appear to be */ @@ -183,7 +176,7 @@ static void usage(const char* prog) { - printf("usage: %s [-h] [-i batt] [-s 1-5]\n", prog); + printf("usage: %s [-h] [-i batt] [-k ack] [-s 1-4]\n", prog); exit(0); } @@ -200,17 +193,20 @@ sleep_type = -1; acpi_init(); - while ((c = getopt(argc, argv, "hi:s:")) != -1) { + while ((c = getopt(argc, argv, "hi:k:s:")) != -1) { switch (c) { case 'i': acpi_battinfo(atoi(optarg)); break; + case 'k': + acpi_sleep_ack(atoi(optarg)); + break; case 's': if (optarg[0] == 'S') sleep_type = optarg[1] - '0'; else sleep_type = optarg[0] - '0'; - if (sleep_type < 0 || sleep_type > 5) + if (sleep_type < 1 || sleep_type > 4) errx(EX_USAGE, "invalid sleep type (%d)", sleep_type); break; @@ -223,10 +219,8 @@ argc -= optind; argv += optind; - if (sleep_type != -1) { - sleep(1); /* wait 1 sec. for key-release event */ + if (sleep_type != -1) acpi_sleep(sleep_type); - } close(acpifd); exit (0); --------------040100070106020900000700 Content-Type: text/x-patch; name="acpi7_wakeapi.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="acpi7_wakeapi.diff" Index: etc/devd.conf =================================================================== RCS file: /home/ncvs/src/etc/devd.conf,v retrieving revision 1.37 diff -u -r1.37 devd.conf --- etc/devd.conf 8 Apr 2007 16:05:23 -0000 1.37 +++ etc/devd.conf 17 Jun 2007 16:52:50 -0000 @@ -239,6 +239,19 @@ action "logger -p kern.warn 'ZFS: checksum mismatch, zpool=$pool path=$vdev_path offset=$zio_offset size=$zio_size'"; }; +# User requested suspend, so perform preparation steps and then execute +# the actual suspend process. +notify 10 { + match "system" "ACPI"; + match "subsystem" "Suspend"; + action "/etc/rc.suspend acpi $notify"; +}; +notify 10 { + match "system" "ACPI"; + match "subsystem" "Resume"; + action "/etc/rc.resume acpi $notify"; +}; + /* EXAMPLES TO END OF FILE # The following might be an example of something that a vendor might @@ -277,6 +290,7 @@ # Button: Button pressed (0 for power, 1 for sleep) # CMBAT: ACPI battery events # Lid: Lid state (0 is closed, 1 is open) +# Suspend, Resume: Suspend and resume notification # Thermal: ACPI thermal zone events # # This example calls a script when the AC state changes, passing the Index: etc/rc.resume =================================================================== RCS file: /home/ncvs/src/etc/rc.resume,v retrieving revision 1.7 diff -u -r1.7 rc.resume --- etc/rc.resume 30 Dec 2003 17:30:39 -0000 1.7 +++ etc/rc.resume 17 Jun 2007 16:52:50 -0000 @@ -30,7 +30,7 @@ # sample run command file for APM Resume Event if [ $# -ne 2 ]; then - echo "Usage: $0 [apm|acpi] [standby,suspend|1-5]" + echo "Usage: $0 [apm|acpi] [standby,suspend|1-4]" exit 1 fi @@ -48,9 +48,13 @@ # pccardq | awk -F '~' '$5 == "inactive" \ # { printf("pccardc power %d 1", $1); }' | sh -# UHCI has trouble resuming so we just load/unload it. You -# should add any other kernel modules you want reloaded here. -# kldload usb +# If a device driver has problems resuming, try unloading it before +# suspend and reloading it on resume. Example: +# kldunload usb + +# wpa_supplicant(8) doesn't seem to reassociate during resume. Uncomment +# the following to signal it to reassociate. +# /usr/sbin/wpa_cli reassociate logger -t $subsystem resumed at `date +'%Y%m%d %H:%M:%S'` sync && sync && sync Index: etc/rc.suspend =================================================================== RCS file: /home/ncvs/src/etc/rc.suspend,v retrieving revision 1.6 diff -u -r1.6 rc.suspend --- etc/rc.suspend 21 Jan 2004 03:03:40 -0000 1.6 +++ etc/rc.suspend 17 Jun 2007 16:54:56 -0000 @@ -30,7 +30,7 @@ # sample run command file for APM Suspend Event if [ $# -ne 2 ]; then - echo "Usage: $0 [apm|acpi] [standby,suspend|1-5]" + echo "Usage: $0 [apm|acpi] [standby,suspend|1-4]" exit 1 fi @@ -48,15 +48,20 @@ # pccardq | awk -F '~' '$5 == "filled" && $4 ~ /sio/ \ # { printf("pccardc power %d 0", $1); }' | sh -# UHCI has trouble resuming so we just load/unload it. You -# should add any other kernel modules you want unloaded here. +# If a device driver has problems suspending, try unloading it before +# suspend and reloading it on resume. Example: # kldunload usb logger -t $subsystem suspend at `date +'%Y%m%d %H:%M:%S'` sync && sync && sync -[ $subsystem = "apm" ] && sleep 3 +sleep 3 rm -f /var/run/rc.suspend.pid -[ $subsystem = "apm" ] && zzz +if [ $subsystem = "apm" ]; then + /usr/sbin/zzz +else + # Notify the kernel to continue the suspend process + /usr/sbin/acpiconf -k 0 +fi exit 0 Index: sys/dev/acpica/acpi.c =================================================================== RCS file: /home/ncvs/src/sys/dev/acpica/acpi.c,v retrieving revision 1.239 diff -u -r1.239 acpi.c --- sys/dev/acpica/acpi.c 15 Jun 2007 18:02:33 -0000 1.239 +++ sys/dev/acpica/acpi.c 17 Jun 2007 16:52:50 -0000 @@ -136,6 +136,7 @@ static ACPI_STATUS acpi_probe_child(ACPI_HANDLE handle, UINT32 level, void *context, void **status); static BOOLEAN acpi_MatchHid(ACPI_HANDLE h, const char *hid); +static ACPI_STATUS acpi_EnterSleepState(struct acpi_softc *sc, int state); static void acpi_shutdown_final(void *arg, int howto); static void acpi_enable_fixed_events(struct acpi_softc *sc); static int acpi_wake_sleep_prep(ACPI_HANDLE handle, int sstate); @@ -410,6 +411,7 @@ sc = device_get_softc(dev); sc->acpi_dev = dev; + callout_init(&sc->susp_force_to, TRUE); error = ENXIO; @@ -592,7 +594,7 @@ /* Pick the first valid sleep state for the sleep button default. */ sc->acpi_sleep_button_sx = ACPI_S_STATES_MAX + 1; - for (state = ACPI_STATE_S1; state < ACPI_STATE_S5; state++) + for (state = ACPI_STATE_S1; state <= ACPI_STATE_S4; state++) if (ACPI_SUCCESS(AcpiGetSleepTypeData(state, &TypeA, &TypeB))) { sc->acpi_sleep_button_sx = state; break; @@ -2118,6 +2120,143 @@ return (acpi_SetInteger(ACPI_ROOT_OBJECT, "_PIC", model)); } +/* + * DEPRECATED. This interface has serious deficiencies and will be + * removed. + * + * Immediately enter the sleep state. In the old model, acpiconf(8) ran + * rc.suspend and rc.resume so we don't have to notify devd(8) to do this. + */ +ACPI_STATUS +acpi_SetSleepState(struct acpi_softc *sc, int state) +{ + static int once; + + if (!once) { + printf( +"warning: acpi_SetSleepState deprecated, need to update your software\n"); + once = 1; + } + return (acpi_EnterSleepState(sc, state)); +} + +static void +acpi_sleep_force(void *arg) +{ + struct acpi_softc *sc; + + printf("acpi: suspend request timed out, forcing sleep now\n"); + sc = arg; + acpi_EnterSleepState(sc, sc->acpi_next_sstate); +} + +/* + * Request that the system enter the given suspend state. All /dev/apm + * devices and devd(8) will be notified. Userland then has a chance to + * save state and acknowledge the request. The system sleeps once all + * acks are in. + */ +int +acpi_ReqSleepState(struct acpi_softc *sc, int state) +{ + struct apm_clone_data *clone; + + /* S5 (soft-off) should be entered via shutdown_nice(). */ + if (state < ACPI_STATE_S1 || state > ACPI_STATE_S4) + return (EINVAL); + + /* If a suspend request is already in progress, just return. */ + ACPI_LOCK(acpi); + if (sc->acpi_next_sstate != 0) { + ACPI_UNLOCK(acpi); + return (0); + } + + /* Record the pending state and notify all apm devices. */ + sc->acpi_next_sstate = state; + STAILQ_FOREACH(clone, &sc->apm_cdevs, entries) { +printf("considering clone of %s\n", devtoname(clone->cdev)); + clone->notify_status = APM_EV_NONE; + if ((clone->flags & ACPI_EVF_DEVD) == 0) { +printf("acpi ev got %d, waking listener %p\n", state, clone); + selwakeuppri(&clone->sel_read, PZERO); + KNOTE_UNLOCKED(&clone->sel_read.si_note, 0); + } + } + + /* Now notify devd(8) also. */ + acpi_UserNotify("Suspend", ACPI_ROOT_OBJECT, state); + + /* + * Set a timeout to fire if userland doesn't ack the suspend request + * in time. This way we still eventually go to sleep if we were + * overheating or running low on battery, even if userland is hung. + * We cancel this timeout once all userland acks are in or the + * suspend request is aborted. + */ + callout_reset(&sc->susp_force_to, 10 * hz, acpi_sleep_force, sc); + ACPI_UNLOCK(acpi); + return (0); +} + +/* + * Acknowledge (or reject) a pending sleep state. The caller has + * prepared for suspend and is now ready for it to proceed. If the + * error argument is non-zero, it indicates suspend should be cancelled + * and gives an errno value describing why. Once all votes are in, + * we suspend the system. + */ +int +acpi_AckSleepState(struct apm_clone_data *clone, int error) +{ + struct acpi_softc *sc; + int sleeping; + + /* If no pending sleep state, return an error. */ + ACPI_LOCK(acpi); + sc = clone->acpi_sc; + if (sc->acpi_next_sstate == 0) { + ACPI_UNLOCK(acpi); + return (ENXIO); + } + + /* Caller wants to abort suspend process. */ + if (error) { + sc->acpi_next_sstate = 0; + callout_stop(&sc->susp_force_to); + printf("acpi: listener on %s cancelled the pending suspend\n", + devtoname(clone->cdev)); + ACPI_UNLOCK(acpi); + return (0); + } + + /* + * Mark this device as acking the suspend request. Then, walk through + * all devices, seeing if they agree yet. We only count devices that + * are writable since read-only devices couldn't ack the request. + */ + clone->notify_status = APM_EV_ACKED; + sleeping = TRUE; + STAILQ_FOREACH(clone, &sc->apm_cdevs, entries) { + if ((clone->flags & ACPI_EVF_WRITE) != 0 && + clone->notify_status != APM_EV_ACKED) { + sleeping = FALSE; + break; + } + } + + /* If all devices have voted "yes", we will suspend now. */ + if (sleeping) { +printf("ack: all devs said yes, sleeping now\n"); + callout_stop(&sc->susp_force_to); + } + ACPI_UNLOCK(acpi); + if (sleeping) + acpi_EnterSleepState(sc, sc->acpi_next_sstate); + + return (0); +} + static void acpi_sleep_enable(void *arg) { @@ -2134,12 +2273,12 @@ }; /* - * Set the system sleep state + * Enter the desired system sleep state. * * Currently we support S1-S5 but S4 is only S4BIOS */ -ACPI_STATUS -acpi_SetSleepState(struct acpi_softc *sc, int state) +static ACPI_STATUS +acpi_EnterSleepState(struct acpi_softc *sc, int state) { ACPI_STATUS status; UINT8 TypeA; @@ -2251,6 +2390,7 @@ * Back out state according to how far along we got in the suspend * process. This handles both the error and success cases. */ + sc->acpi_next_sstate = 0; if (slp_state >= ACPI_SS_GPE_SET) { acpi_wake_prep_walk(state); sc->acpi_sstate = ACPI_STATE_S0; @@ -2264,7 +2404,10 @@ /* Allow another sleep request after a while. */ if (state != ACPI_STATE_S5) - timeout(acpi_sleep_enable, (caddr_t)sc, hz * ACPI_MINIMUM_AWAKETIME); + timeout(acpi_sleep_enable, sc, hz * ACPI_MINIMUM_AWAKETIME); + + /* Run /etc/rc.resume after we are back. */ + acpi_UserNotify("Resume", ACPI_ROOT_OBJECT, state); mtx_unlock(&Giant); return_ACPI_STATUS (status); @@ -2574,11 +2717,14 @@ static void acpi_system_eventhandler_sleep(void *arg, int state) { + int ret; ACPI_FUNCTION_TRACE_U32((char *)(uintptr_t)__func__, state); - if (state >= ACPI_STATE_S0 && state <= ACPI_S_STATES_MAX) - acpi_SetSleepState((struct acpi_softc *)arg, state); + /* Request that the system prepare to enter the given suspend state. */ + ret = acpi_ReqSleepState((struct acpi_softc *)arg, state); + if (ret != 0) + printf("acpi: request to enter state S%d failed\n", state); return_VOID; } @@ -2840,7 +2986,15 @@ /* Core system ioctls. */ switch (cmd) { - case ACPIIO_SETSLPSTATE: + case ACPIIO_REQSLPSTATE: + state = *(int *)addr; + error = acpi_ReqSleepState(sc, state); + break; + case ACPIIO_ACKSLPSTATE: + error = *(int *)addr; + error = acpi_AckSleepState(sc->acpi_clone, error); + break; + case ACPIIO_SETSLPSTATE: /* DEPRECATED */ error = EINVAL; state = *(int *)addr; if (state >= ACPI_STATE_S0 && state <= ACPI_S_STATES_MAX) Index: sys/dev/acpica/acpiio.h =================================================================== RCS file: /home/ncvs/src/sys/dev/acpica/acpiio.h,v retrieving revision 1.16 diff -u -r1.16 acpiio.h --- sys/dev/acpica/acpiio.h 23 Oct 2005 00:16:41 -0000 1.16 +++ sys/dev/acpica/acpiio.h 17 Jun 2007 16:52:50 -0000 @@ -33,7 +33,13 @@ /* * Core ACPI subsystem ioctls */ -#define ACPIIO_SETSLPSTATE _IOW('P', 3, int) +#define ACPIIO_SETSLPSTATE _IOW('P', 3, int) /* DEPRECATED */ + +/* Request S1-5 sleep state. User is notified and then sleep proceeds. */ +#define ACPIIO_REQSLPSTATE _IOW('P', 4, int) + +/* Allow suspend to continue (0) or abort it (errno). */ +#define ACPIIO_ACKSLPSTATE _IOW('P', 5, int) struct acpi_battinfo { int cap; /* percent */ Index: sys/dev/acpica/acpivar.h =================================================================== RCS file: /home/ncvs/src/sys/dev/acpica/acpivar.h,v retrieving revision 1.106 diff -u -r1.106 acpivar.h --- sys/dev/acpica/acpivar.h 15 Jun 2007 18:02:34 -0000 1.106 +++ sys/dev/acpica/acpivar.h 17 Jun 2007 16:57:25 -0000 @@ -39,12 +39,14 @@ #include #include #include +#include #include #include #include #include +struct apm_clone_data; struct acpi_softc { device_t acpi_dev; struct cdev *acpi_dev_t; @@ -76,6 +78,11 @@ bus_dmamap_t acpi_wakemap; vm_offset_t acpi_wakeaddr; vm_paddr_t acpi_wakephys; + + int acpi_next_sstate; /* Next suspend Sx state. */ + struct apm_clone_data *acpi_clone; /* Pseudo-dev for devd(8). */ + STAILQ_HEAD(,apm_clone_data) apm_cdevs; /* All apm/apmctl/acpi cdevs. */ + struct callout susp_force_to; /* Force suspend if no acks. */ }; struct acpi_device { @@ -89,6 +96,22 @@ struct resource_list ad_rl; }; +/* Track device (/dev/{apm,apmctl} and /dev/acpi) notification status. */ +struct apm_clone_data { + STAILQ_ENTRY(apm_clone_data) entries; + struct cdev *cdev; + int flags; +#define ACPI_EVF_NONE 0 /* /dev/apm semantics */ +#define ACPI_EVF_DEVD 1 /* /dev/acpi is handled via devd(8) */ +#define ACPI_EVF_WRITE 2 /* Device instance is opened writable. */ + int notify_status; +#define APM_EV_NONE 0 /* Device not yet aware of pending sleep. */ +#define APM_EV_NOTIFIED 1 /* Device saw next sleep state. */ +#define APM_EV_ACKED 2 /* Device agreed sleep can occur. */ + struct acpi_softc *acpi_sc; + struct selinfo sel_read; +}; + #define ACPI_PRW_MAX_POWERRES 8 struct acpi_prw_data { @@ -304,6 +327,8 @@ ACPI_RESOURCE *res); ACPI_STATUS acpi_OverrideInterruptLevel(UINT32 InterruptNumber); ACPI_STATUS acpi_SetIntrModel(int model); +int acpi_ReqSleepState(struct acpi_softc *sc, int state); +int acpi_AckSleepState(struct apm_clone_data *clone, int error); ACPI_STATUS acpi_SetSleepState(struct acpi_softc *sc, int state); int acpi_wake_init(device_t dev, int type); int acpi_wake_set_enable(device_t dev, int enable); Index: sys/i386/acpica/acpi_machdep.c =================================================================== RCS file: /home/ncvs/src/sys/i386/acpica/acpi_machdep.c,v retrieving revision 1.35 diff -u -r1.35 acpi_machdep.c --- sys/i386/acpica/acpi_machdep.c 31 Mar 2007 23:23:41 -0000 1.35 +++ sys/i386/acpica/acpi_machdep.c 17 Jun 2007 16:52:50 -0000 @@ -33,6 +33,8 @@ #include #include #include +#include +#include #include #include #include @@ -46,8 +48,6 @@ * APM driver emulation */ -#include - #include #include @@ -64,21 +64,31 @@ static int intr_model = ACPI_INTR_PIC; static int apm_active; +static struct clonedevs *apm_clones; + +MALLOC_DEFINE(M_APMDEV, "apmdev", "APM device emulation"); -static d_open_t apmopen; -static d_close_t apmclose; -static d_write_t apmwrite; -static d_ioctl_t apmioctl; -static d_poll_t apmpoll; +static d_open_t apmopen; +static d_close_t apmclose; +static d_write_t apmwrite; +static d_ioctl_t apmioctl; +static d_poll_t apmpoll; +static d_kqfilter_t apmkqfilter; +static void apmreadfiltdetach(struct knote *kn); +static int apmreadfilt(struct knote *kn, long hint); +static struct filterops apm_readfiltops = + { 1, NULL, apmreadfiltdetach, apmreadfilt }; static struct cdevsw apm_cdevsw = { .d_version = D_VERSION, + .d_flags = D_TRACKCLOSE, .d_open = apmopen, .d_close = apmclose, .d_write = apmwrite, .d_ioctl = apmioctl, .d_poll = apmpoll, .d_name = "apm", + .d_kqfilter = apmkqfilter }; static int @@ -202,44 +212,159 @@ return (0); } +/* Create single-use devices for /dev/apm and /dev/apmctl. */ +static void +apm_clone(void *arg, struct ucred *cred, char *name, int namelen, + struct cdev **dev) +{ + int ctl_dev, unit; + + if (*dev != NULL) + return; + if (strcmp(name, "apmctl") == 0) + ctl_dev = TRUE; + else if (strcmp(name, "apm") == 0) + ctl_dev = FALSE; + else + return; + + /* Always create a new device and unit number. */ + unit = -1; + if (clone_create(&apm_clones, &apm_cdevsw, &unit, dev, 0)) { + if (ctl_dev) { + *dev = make_dev(&apm_cdevsw, unit2minor(unit), + UID_ROOT, GID_OPERATOR, 0660, "apmctl%d", unit); + } else { + *dev = make_dev(&apm_cdevsw, unit2minor(unit), + UID_ROOT, GID_OPERATOR, 0664, "apm%d", unit); + } + if (*dev != NULL) { + dev_ref(*dev); + (*dev)->si_flags |= SI_CHEAPCLONE; + } + } +} + +/* Create a struct for tracking per-device suspend notification. */ +static struct apm_clone_data * +apm_create_clone(struct cdev *dev, struct acpi_softc *acpi_sc) +{ + struct apm_clone_data *clone; + + clone = malloc(sizeof(*clone), M_APMDEV, M_WAITOK); + clone->cdev = dev; + clone->acpi_sc = acpi_sc; + clone->notify_status = APM_EV_NONE; + bzero(&clone->sel_read, sizeof(clone->sel_read)); + knlist_init(&clone->sel_read.si_note, &acpi_mutex, NULL, NULL, NULL); + + /* + * The acpi device is always managed by devd(8) and is considered + * writable (i.e., ack is required to allow suspend to proceed.) + */ + if (strcmp("acpi", devtoname(dev)) == 0) + clone->flags = ACPI_EVF_DEVD | ACPI_EVF_WRITE; + else + clone->flags = ACPI_EVF_NONE; + + ACPI_LOCK(acpi); + STAILQ_INSERT_TAIL(&acpi_sc->apm_cdevs, clone, entries); + ACPI_UNLOCK(acpi); + return (clone); +} + static int apmopen(struct cdev *dev, int flag, int fmt, d_thread_t *td) { + struct acpi_softc *acpi_sc; + struct apm_clone_data *clone; + + acpi_sc = devclass_get_softc(devclass_find("acpi"), 0); + clone = apm_create_clone(dev, acpi_sc); + dev->si_drv1 = clone; + + /* If the device is opened for write, record that. */ + if ((flag & FWRITE) != 0) + clone->flags |= ACPI_EVF_WRITE; + +printf("%s opened clone %p\n", devtoname(dev), (struct apm_clone_data *)dev->si_drv1); return (0); } static int apmclose(struct cdev *dev, int flag, int fmt, d_thread_t *td) { + struct apm_clone_data *clone; + struct acpi_softc *acpi_sc; + + clone = dev->si_drv1; + acpi_sc = clone->acpi_sc; + + /* We are about to lose a reference so check if suspend should occur */ + if (acpi_sc->acpi_next_sstate != 0 && + clone->notify_status != APM_EV_ACKED) + acpi_AckSleepState(clone, 0); + + /* Remove this clone's data from the list and free it. */ + ACPI_LOCK(acpi); + STAILQ_REMOVE(&acpi_sc->apm_cdevs, clone, apm_clone_data, entries); + knlist_destroy(&clone->sel_read.si_note); +printf("%s closed clone %p\n", devtoname(dev), clone); + ACPI_UNLOCK(acpi); + free(clone, M_APMDEV); + /* XXX destroy_dev() needed */ return (0); } static int apmioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, d_thread_t *td) { - int error = 0; + int error; + struct apm_clone_data *clone; struct acpi_softc *acpi_sc; - struct apm_info info; + struct apm_info info; + struct apm_event_info *ev_info; apm_info_old_t aiop; - acpi_sc = devclass_get_softc(devclass_find("acpi"), 0); + error = 0; + clone = dev->si_drv1; + acpi_sc = clone->acpi_sc; switch (cmd) { case APMIO_SUSPEND: if ((flag & FWRITE) == 0) return (EPERM); - if (apm_active) - acpi_SetSleepState(acpi_sc, acpi_sc->acpi_suspend_sx); +printf("apm ioctl suspend\n"); + if (acpi_sc->acpi_next_sstate == 0) + acpi_ReqSleepState(acpi_sc, acpi_sc->acpi_suspend_sx); else - error = EINVAL; + acpi_AckSleepState(clone, 0); break; case APMIO_STANDBY: if ((flag & FWRITE) == 0) return (EPERM); - if (apm_active) - acpi_SetSleepState(acpi_sc, acpi_sc->acpi_standby_sx); +printf("apm ioctl standby\n"); + if (acpi_sc->acpi_next_sstate == 0) + acpi_ReqSleepState(acpi_sc, acpi_sc->acpi_standby_sx); else - error = EINVAL; + acpi_AckSleepState(clone, 0); + break; + case APMIO_NEXTEVENT: + printf("apm nextevent start\n"); + ACPI_LOCK(acpi); + if (acpi_sc->acpi_next_sstate != 0 && clone->notify_status == + APM_EV_NONE) { + ev_info = (struct apm_event_info *)addr; + if (acpi_sc->acpi_next_sstate <= ACPI_STATE_S3) + ev_info->type = PMEV_STANDBYREQ; + else + ev_info->type = PMEV_SUSPENDREQ; + ev_info->index = 0; + clone->notify_status = APM_EV_NOTIFIED; + printf("apm event returning %d\n", ev_info->type); + } else + error = EAGAIN; + ACPI_UNLOCK(acpi); break; case APMIO_GETINFO_OLD: if (acpi_capm_get_info(&info)) @@ -300,24 +425,72 @@ static int apmpoll(struct cdev *dev, int events, d_thread_t *td) { + struct apm_clone_data *clone; + int revents; + + revents = 0; + ACPI_LOCK(acpi); + clone = dev->si_drv1; + if (clone->acpi_sc->acpi_next_sstate) + revents |= events & (POLLIN | POLLRDNORM); + else + selrecord(td, &clone->sel_read); + ACPI_UNLOCK(acpi); +printf("apm poll returning %x\n", revents); + return (revents); +} + +static int +apmkqfilter(struct cdev *dev, struct knote *kn) +{ + struct apm_clone_data *clone; + + ACPI_LOCK(acpi); + clone = dev->si_drv1; + kn->kn_hook = clone; + kn->kn_fop = &apm_readfiltops; + knlist_add(&clone->sel_read.si_note, kn, 0); + ACPI_UNLOCK(acpi); return (0); } static void -acpi_capm_init(struct acpi_softc *sc) +apmreadfiltdetach(struct knote *kn) +{ + struct apm_clone_data *clone; + + ACPI_LOCK(acpi); + clone = kn->kn_hook; + knlist_remove(&clone->sel_read.si_note, kn, 0); + ACPI_UNLOCK(acpi); +} + +static int +apmreadfilt(struct knote *kn, long hint) { - make_dev(&apm_cdevsw, 0, 0, 5, 0664, "apm"); + struct apm_clone_data *clone; + int sleeping; + + ACPI_LOCK(acpi); + clone = kn->kn_hook; + sleeping = clone->acpi_sc->acpi_next_sstate ? 1 : 0; + ACPI_UNLOCK(acpi); + return (sleeping); } int acpi_machdep_init(device_t dev) { - struct acpi_softc *sc; + struct acpi_softc *acpi_sc; - sc = devclass_get_softc(devclass_find("acpi"), 0); - acpi_capm_init(sc); + acpi_sc = devclass_get_softc(devclass_find("acpi"), 0); - acpi_install_wakeup_handler(sc); + /* Create a clone for /dev/acpi also. */ + STAILQ_INIT(&acpi_sc->apm_cdevs); + acpi_sc->acpi_clone = apm_create_clone(acpi_sc->acpi_dev_t, acpi_sc); + clone_setup(&apm_clones); + EVENTHANDLER_REGISTER(dev_clone, apm_clone, 0, 1000); + acpi_install_wakeup_handler(acpi_sc); if (intr_model == ACPI_INTR_PIC) BUS_CONFIG_INTR(dev, AcpiGbl_FADT.SciInterrupt, @@ -325,8 +498,8 @@ else acpi_SetIntrModel(intr_model); - SYSCTL_ADD_UINT(&sc->acpi_sysctl_ctx, - SYSCTL_CHILDREN(sc->acpi_sysctl_tree), OID_AUTO, + SYSCTL_ADD_UINT(&acpi_sc->acpi_sysctl_ctx, + SYSCTL_CHILDREN(acpi_sc->acpi_sysctl_tree), OID_AUTO, "reset_video", CTLFLAG_RW, &acpi_reset_video, 0, "Call the VESA reset BIOS vector on the resume path"); Index: usr.sbin/acpi/acpiconf/acpiconf.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/acpi/acpiconf/acpiconf.c,v retrieving revision 1.25 diff -u -r1.25 acpiconf.c --- usr.sbin/acpi/acpiconf/acpiconf.c 28 Jul 2005 19:41:52 -0000 1.25 +++ usr.sbin/acpi/acpiconf/acpiconf.c 17 Jun 2007 16:52:50 -0000 @@ -40,8 +40,6 @@ #include #define ACPIDEV "/dev/acpi" -#define RC_SUSPEND_PATH "/etc/rc.suspend" -#define RC_RESUME_PATH "/etc/rc.resume" static int acpifd; @@ -55,32 +53,27 @@ err(EX_OSFILE, ACPIDEV); } -static int +/* Prepare to sleep and then wait for the signal that sleeping can occur. */ +static void acpi_sleep(int sleep_type) { - char cmd[64]; int ret; + + /* Notify OS that we want to sleep. devd(8) gets this notify. */ + ret = ioctl(acpifd, ACPIIO_REQSLPSTATE, &sleep_type); + if (ret != 0) + err(EX_IOERR, "request sleep type (%d) failed", sleep_type); +} - /* Run the suspend rc script, if available. */ - if (access(RC_SUSPEND_PATH, X_OK) == 0) { - snprintf(cmd, sizeof(cmd), "%s acpi %d", RC_SUSPEND_PATH, - sleep_type); - system(cmd); - } - - ret = ioctl(acpifd, ACPIIO_SETSLPSTATE, &sleep_type); - - /* Run the resume rc script, if available. */ - if (access(RC_RESUME_PATH, X_OK) == 0) { - snprintf(cmd, sizeof(cmd), "%s acpi %d", RC_RESUME_PATH, - sleep_type); - system(cmd); - } +/* Ack or abort a pending suspend request. */ +static void +acpi_sleep_ack(int err_val) +{ + int ret; + ret = ioctl(acpifd, ACPIIO_ACKSLPSTATE, &err_val); if (ret != 0) - err(EX_IOERR, "sleep type (%d) failed", sleep_type); - - return (0); + err(EX_IOERR, "ack sleep type failed"); } /* should be a acpi define, but doesn't appear to be */ @@ -183,7 +176,7 @@ static void usage(const char* prog) { - printf("usage: %s [-h] [-i batt] [-s 1-5]\n", prog); + printf("usage: %s [-h] [-i batt] [-k ack] [-s 1-4]\n", prog); exit(0); } @@ -200,17 +193,20 @@ sleep_type = -1; acpi_init(); - while ((c = getopt(argc, argv, "hi:s:")) != -1) { + while ((c = getopt(argc, argv, "hi:k:s:")) != -1) { switch (c) { case 'i': acpi_battinfo(atoi(optarg)); break; + case 'k': + acpi_sleep_ack(atoi(optarg)); + break; case 's': if (optarg[0] == 'S') sleep_type = optarg[1] - '0'; else sleep_type = optarg[0] - '0'; - if (sleep_type < 0 || sleep_type > 5) + if (sleep_type < 1 || sleep_type > 4) errx(EX_USAGE, "invalid sleep type (%d)", sleep_type); break; @@ -223,10 +219,8 @@ argc -= optind; argv += optind; - if (sleep_type != -1) { - sleep(1); /* wait 1 sec. for key-release event */ + if (sleep_type != -1) acpi_sleep(sleep_type); - } close(acpifd); exit (0); --------------040100070106020900000700-- From owner-freebsd-arch@FreeBSD.ORG Tue Jun 19 06:53:05 2007 Return-Path: X-Original-To: freebsd-arch@FreeBSD.org Delivered-To: freebsd-arch@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 194B316A400; Tue, 19 Jun 2007 06:53:05 +0000 (UTC) (envelope-from linimon@lonesome.com) Received: from mail.soaustin.net (mail.soaustin.net [207.200.4.66]) by mx1.freebsd.org (Postfix) with ESMTP id 020D113C469; Tue, 19 Jun 2007 06:53:04 +0000 (UTC) (envelope-from linimon@lonesome.com) Received: by mail.soaustin.net (Postfix, from userid 502) id A3EB0B42; Tue, 19 Jun 2007 01:53:04 -0500 (CDT) Date: Tue, 19 Jun 2007 01:53:04 -0500 To: freebsd-arch@FreeBSD.org Message-ID: <20070619065304.GA460@soaustin.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.9i From: linimon@lonesome.com (Mark Linimon) Cc: linimon@FreeBSD.org Subject: request: state of the art of jails X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2007 06:53:05 -0000 I have a customer who is interested in expanding jails to include multiple IP addresses. Since from my reading the Network Virtualization work isn't imminent, I'm looking to see who else has worked on this (and jails in general). There is an extant patch in kern/69064 which I'm looking at but would need refinement. Are there others? Thanks. mcl From owner-freebsd-arch@FreeBSD.ORG Tue Jun 19 10:03:36 2007 Return-Path: X-Original-To: freebsd-arch@freebsd.org Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3B51616A46B; Tue, 19 Jun 2007 10:03:36 +0000 (UTC) (envelope-from bzeeb-lists@lists.zabbadoz.net) Received: from transport.cksoft.de (transport.cksoft.de [62.111.66.27]) by mx1.freebsd.org (Postfix) with ESMTP id F2DE213C48A; Tue, 19 Jun 2007 10:03:35 +0000 (UTC) (envelope-from bzeeb-lists@lists.zabbadoz.net) Received: from transport.cksoft.de (localhost [127.0.0.1]) by transport.cksoft.de (Postfix) with ESMTP id F129E1FFAAE; Tue, 19 Jun 2007 11:31:06 +0200 (CEST) Received: by transport.cksoft.de (Postfix, from userid 66) id 2AD9F1FF92F; Tue, 19 Jun 2007 11:30:59 +0200 (CEST) Received: from maildrop.int.zabbadoz.net (maildrop.int.zabbadoz.net [10.111.66.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.int.zabbadoz.net (Postfix) with ESMTP id DD92F4448DD; Tue, 19 Jun 2007 09:27:10 +0000 (UTC) Date: Tue, 19 Jun 2007 09:27:10 +0000 (UTC) From: "Bjoern A. Zeeb" X-X-Sender: bz@maildrop.int.zabbadoz.net To: Mark Linimon In-Reply-To: <20070619065304.GA460@soaustin.net> Message-ID: <20070619092242.E98813@maildrop.int.zabbadoz.net> References: <20070619065304.GA460@soaustin.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: by AMaViS cksoft-s20020300-20031204bz on transport.cksoft.de Cc: linimon@FreeBSD.org, freebsd-arch@FreeBSD.org Subject: Re: request: state of the art of jails X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2007 10:03:36 -0000 On Tue, 19 Jun 2007, Mark Linimon wrote: Hi, > I have a customer who is interested in expanding jails to include > multiple IP addresses. Since from my reading the Network Virtualization > work isn't imminent, I'm looking to see who else has worked on this (and > jails in general). There is an extant patch in kern/69064 which I'm > looking at but would need refinement. Are there others? I have an almost HEAD version based on what pjd did some years ago. Have been running it on multiple RELENG_6 machines in production. It might need slight modifications for HEAD after rwatsons recent commits but I'll do that anyway the next days. Apart from that I've been told that andre was working on a thing that is somewhere is the middle between marco's vnet/vimage work and the multi-ip-jail patch. Last but not least there was a SoC project I think and there are "parallel" patches out there with a partly different featureset (resource limits, etc.) but I haven't looked at them in detail. /bz -- Bjoern A. Zeeb bzeeb at Zabbadoz dot NeT Software is harder than hardware so better get it right the first time. From owner-freebsd-arch@FreeBSD.ORG Tue Jun 19 10:58:44 2007 Return-Path: X-Original-To: freebsd-arch@FreeBSD.org Delivered-To: freebsd-arch@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A365216A400; Tue, 19 Jun 2007 10:58:44 +0000 (UTC) (envelope-from 000.fbsd@quip.cz) Received: from elsa.codelab.cz (elsa.codelab.cz [82.208.36.70]) by mx1.freebsd.org (Postfix) with ESMTP id 62D0713C448; Tue, 19 Jun 2007 10:58:44 +0000 (UTC) (envelope-from 000.fbsd@quip.cz) Received: from localhost (localhost.codelab.cz [127.0.0.1]) by elsa.codelab.cz (Postfix) with ESMTP id 65B7919E02A; Tue, 19 Jun 2007 12:40:19 +0200 (CEST) Received: from [192.168.1.2] (grimm.quip.cz [213.220.192.218]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by elsa.codelab.cz (Postfix) with ESMTP id 34AFC19E027; Tue, 19 Jun 2007 12:40:16 +0200 (CEST) Message-ID: <4677B2A0.2040601@quip.cz> Date: Tue, 19 Jun 2007 12:40:32 +0200 From: Miroslav Lachman <000.fbsd@quip.cz> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 X-Accept-Language: cz, cs, en, en-us MIME-Version: 1.0 To: Mark Linimon References: <20070619065304.GA460@soaustin.net> In-Reply-To: <20070619065304.GA460@soaustin.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Cc: linimon@FreeBSD.org, freebsd-arch@FreeBSD.org Subject: Re: request: state of the art of jails X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2007 10:58:44 -0000 Mark Linimon wrote: > I have a customer who is interested in expanding jails to include > multiple IP addresses. Since from my reading the Network Virtualization > work isn't imminent, I'm looking to see who else has worked on this (and > jails in general). There is an extant patch in kern/69064 which I'm > looking at but would need refinement. Are there others? For Your information - there is new mailinglist freebsd-jail@freebsd.org where things like this are discussed. PJD multiple IP patch exists for a long time and I don't understand why it is not commited. Even last year SoC project for Jail resource limits. Is there any hope that these patches will be imported in to 6-STABLE or 7.0-CURRENT? Miroslav Lachman From owner-freebsd-arch@FreeBSD.ORG Tue Jun 19 18:35:45 2007 Return-Path: X-Original-To: freebsd-arch@freebsd.org Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 2D56116A474 for ; Tue, 19 Jun 2007 18:35:45 +0000 (UTC) (envelope-from jlove@pixelfish.com) Received: from mail01.vmatrixmail.com (mail01.vmatrixmail.com [216.219.244.230]) by mx1.freebsd.org (Postfix) with ESMTP id D694813C45D for ; Tue, 19 Jun 2007 18:35:44 +0000 (UTC) (envelope-from jlove@pixelfish.com) Received: (root@mail01.vmatrixmail.com) by vmatrixmail.com id S6134233AbXFSScR for ; Tue, 19 Jun 2007 11:32:17 -0700 To: freebsd-arch@freebsd.org MIME-Version: 1.0 X-Mailer: Rich Media Mail V4. Vmatrix, (C) 2003 From: "Justin Love" Sender: "Justin Love" Message-Id: Date: Tue, 19 Jun 2007 11:32:17 -0700 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: Video Turns Software Leads Into Buyers X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: jlove@pixelfish.com List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2007 18:35:45 -0000 Greetings!

You have a state-of-the-art software application, but do your customers know it?

Bridge the gap between your latest software solutions and the end user with video.

PixelFish is a video production company that excels at producing high-quality videos that sell. Our talented and accomplished crew starts with a focused and innovative script to match your messaging needs. We then hand off the approved script to our team of videographers who coordinate each and every detail to get the best footage. Experienced and savvy editors complete the final stages to produce the marketing or educational video that keeps you at the cutting edge of software development.

I have embedded a few samples of our work to the right. Click on the videos to see what we can do. We digitize our videos for optimal distribution over the web, via e-mail, CD-ROM and other popular media platforms. We also provide the right tools for measuring the positive impact of each video investment instantly and around the clock.

Whether you are looking to train your customers on your latest application, promote your software, or simply create a software demonstration guide, PixelFish is your one-stop-shop for affordable video solutions for all types of purposes. Call us today to begin the planning process of your video or to gather more information. You can reach us at 800.503.3020 or on our website at www.pixelfish.com.

We’d love to work with you to help turn your software leads into sales.

Sincerely,

Justin Love
PixelFish, Inc.
800.503.3020 x7109
jlove@pixelfish.com
http://www.pixelfish.com
Certiport
Quadrant
InvesTools
------------------------------------------------ Unsubscribe to safely remove yourself from this email list, please send email to info@pixelfish.com. Powered by Pixelfish http://www.pixelfish.com From owner-freebsd-arch@FreeBSD.ORG Thu Jun 21 16:13:04 2007 Return-Path: X-Original-To: arch@freebsd.org Delivered-To: freebsd-arch@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3226216A469; Thu, 21 Jun 2007 16:13:04 +0000 (UTC) (envelope-from lars@e.0x20.net) Received: from mail.0x20.net (mail.0x20.net [217.69.67.217]) by mx1.freebsd.org (Postfix) with ESMTP id 0FCFC13C468; Thu, 21 Jun 2007 16:13:03 +0000 (UTC) (envelope-from lars@e.0x20.net) Received: by mail.0x20.net (Postfix, from userid 1002) id D48F739E28; Thu, 21 Jun 2007 17:50:44 +0200 (CEST) Date: Thu, 21 Jun 2007 17:50:44 +0200 From: Lars Engels To: Nate Lawson Message-ID: <20070621155044.GD17194@e.0x20.net> References: <46756BBE.5030603@root.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="IrhDeMKUP4DT/M7F" Content-Disposition: inline In-Reply-To: <46756BBE.5030603@root.org> X-Editor: VIM - Vi IMproved 7.0 X-Operation-System: FreeBSD 5.5-RELEASE User-Agent: mutt-ng/devel-r804 (FreeBSD) Cc: acpi@freebsd.org, arch@freebsd.org, current Subject: Re: patch: acpi usermode suspend API change X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2007 16:13:04 -0000 --IrhDeMKUP4DT/M7F Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Jun 17, 2007 at 10:13:34AM -0700, Nate Lawson wrote: > This patch updates the user API for acpi suspend in a number of ways. >=20 > * /etc/rc.suspend,rc.resume are always run, no matter the source of the > suspend event > * suspend now requires positive user acknowledgement. If a user program > wants to cancel the suspend, they can. If one of the user programs > hangs or doesn't respond within 10 seconds, the system suspends anyway. > * /dev/apm is clonable, allowing multiple listeners for suspend events. > In the future, xorg-server can use this to be informed about suspend > even if there are other listeners (i.e. apmd). >=20 > The API changes are intended to be MFCd and hence are minimal. >=20 > * Two new ACPI ioctls: REQSLPSTATE and ACKSLPSTATE. Request begins the > process of suspending by notifying all listeners. acpi is monitored by > devd(8) and /dev/apm listener(s) are also counted. Users register their > approval or disapproval via Ack. If anyone disapproves, suspend is vetoe= d. >=20 > * Binary compat is preserved in that old user programs or kernel modules > (yeah, right) that called the API can still do so. A message is printed > once that this interface is deprecated. >=20 > * acpiconf gains the -k flag to ack the suspend request. This flag is > undocumented on purpose since it's only used by /etc/rc.suspend. It is > not intended to be a permanent change and will be removed once a better > power API is implemented. >=20 > These patches have been successfully tested for about a week through > suspend/resumes and various usermode programs, including patches to > xorg-server. >=20 > The eventual goal is to improve subr_power to be a more generic central > power management interface to user and kernel providers. powerd(8) > might start managing profiles similar to apmd(8). I don't know yet and > there isn't time to do that. This patch provides a reasonable interface > for now and eliminates some serious weaknesses, especially in that > pressing a sleep button did not guarantee rc.suspend would run before > sleeping. >=20 > Comments welcome, patches are for 6.x and 7.x. >=20 > --=20 > Nate Nate,=20 thanks for your patch.=20 But after applying it on a recent -Current I get a lot of kernel messages like these: Jun 21 17:48:27 maggie kernel: apm34 opened clone 0xc457fd00 Jun 21 17:48:27 maggie kernel: apm34 closed clone 0xc457fd00 Jun 21 17:48:32 maggie kernel: apm35 opened clone 0xc457ee40 Jun 21 17:48:32 maggie kernel: apm35 closed clone 0xc457ee40 Jun 21 17:48:37 maggie kernel: apm36 opened clone 0xc457ec40 Jun 21 17:48:37 maggie kernel: apm36 closed clone 0xc457ec40 Jun 21 17:48:42 maggie kernel: apm37 opened clone 0xc457fc40 Jun 21 17:48:42 maggie kernel: apm37 closed clone 0xc457fc40 Jun 21 17:48:47 maggie kernel: apm38 opened clone 0xc433b6c0 Jun 21 17:48:47 maggie kernel: apm38 closed clone 0xc433b6c0 Jun 21 17:48:52 maggie kernel: apm39 opened clone 0xc433b240 Additionally, pressing the power button only generates this: Jun 21 17:50:03 maggie kernel: acpi: request to enter state S5 failed I need to run 'shutdown -p ' to power the system down. Lars --IrhDeMKUP4DT/M7F Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (FreeBSD) iD8DBQFGep5UKc512sD3afgRAuIOAKCe7fX+8Rq9yxYfyHEr7zpc8DIgGQCfQx1h IQDhkaFIK/F19KqAjJzz5LA= =KqZc -----END PGP SIGNATURE----- --IrhDeMKUP4DT/M7F-- From owner-freebsd-arch@FreeBSD.ORG Thu Jun 21 16:13:05 2007 Return-Path: X-Original-To: arch@freebsd.org Delivered-To: freebsd-arch@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7EE6B16A46C; Thu, 21 Jun 2007 16:13:05 +0000 (UTC) (envelope-from lars@e.0x20.net) Received: from mail.0x20.net (mail.0x20.net [217.69.67.217]) by mx1.freebsd.org (Postfix) with ESMTP id 408BA13C46E; Thu, 21 Jun 2007 16:13:05 +0000 (UTC) (envelope-from lars@e.0x20.net) Received: by mail.0x20.net (Postfix, from userid 1002) id E425B39E2B; Thu, 21 Jun 2007 17:53:30 +0200 (CEST) Date: Thu, 21 Jun 2007 17:53:30 +0200 From: Lars Engels To: Nate Lawson Message-ID: <20070621155330.GE17194@e.0x20.net> References: <46756BBE.5030603@root.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="gr/z0/N6AeWAPJVB" Content-Disposition: inline In-Reply-To: <46756BBE.5030603@root.org> X-Editor: VIM - Vi IMproved 7.0 X-Operation-System: FreeBSD 5.5-RELEASE User-Agent: mutt-ng/devel-r804 (FreeBSD) Cc: acpi@freebsd.org, arch@freebsd.org, current Subject: Re: patch: acpi usermode suspend API change X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2007 16:13:05 -0000 --gr/z0/N6AeWAPJVB Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable And I just saw that every 5 second a new apm device is created!=20 # ls /dev acd0 apm12 apm3 apm47 apm8 = =20 acpi apm13 apm30 apm48 apm9 = =20 ad0 apm14 apm31 apm49 ata = =20 ad0.journal apm15 apm32 apm5 atkbd0 = =20 ad0.journals1 apm16 apm33 apm50 bpf0 = =20 ad0.journals2 apm17 apm34 apm51 bpf1 = =20 ad0.journals3 apm18 apm35 apm52 bpsm0 = =20 ad0.journals4 apm19 apm36 apm53 cardbus0.cis ad0.journals4a apm2 apm37 apm54 cd0 = =20 ad0.journals4b apm20 apm38 apm55 cdrom@ = =20 ad0.journals4c apm21 apm39 apm56 console = =20 ad0.journals4d apm22 apm4 apm57 consolectl = =20 ad0.journals4e apm23 apm40 apm58 ctty = =20 ad0.journals4f apm24 apm41 apm59 cuad0 = =20 agpgart apm25 apm42 apm6 cuad0.init = =20 apm0 apm26 apm43 apm60 cuad0.lock = =20 apm1 apm27 apm44 apm61 devctl = =20 apm10 apm28 apm45 apm62 devstat = =20 apm11 apm29 apm46 apm7 dri/ = =20 [...] --gr/z0/N6AeWAPJVB Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (FreeBSD) iD8DBQFGep76Kc512sD3afgRAmPQAJ0d4hnL6NlemJsT6uXypwilOicqcwCeKF7T 5b53jvz+X/izVPVOtI7endM= =uK7K -----END PGP SIGNATURE----- --gr/z0/N6AeWAPJVB-- From owner-freebsd-arch@FreeBSD.ORG Thu Jun 21 17:24:29 2007 Return-Path: X-Original-To: arch@freebsd.org Delivered-To: freebsd-arch@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7336116A468 for ; Thu, 21 Jun 2007 17:24:29 +0000 (UTC) (envelope-from grafan@gmail.com) Received: from ik-out-1112.google.com (ik-out-1112.google.com [66.249.90.179]) by mx1.freebsd.org (Postfix) with ESMTP id 0DCBF13C457 for ; Thu, 21 Jun 2007 17:24:28 +0000 (UTC) (envelope-from grafan@gmail.com) Received: by ik-out-1112.google.com with SMTP id c21so584228ika for ; Thu, 21 Jun 2007 10:24:28 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=Th95G7IXDBNg7UkYMY6LsE6YQoIRl8ApLa66GbRgKqdzqOZYa3oF5BZzMMtUFhhRBRmAg3yB1uvUW2pEutASDjRnQNOum23x43IiBSnlIUN8T7PV4i/0+oCwUkhQxxncnH9F3Etzol7CHlFBo/M+qgJu0hzwYBrTlFdad84el5c= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=f5BOVT1E0o9Kepjxt9T/fjZJVSY4Mzc/EnYEGhwXD54CXyF6MHZr4v2ZmZwJZsTUBAAJP8lX3KUayNzvHmy4Bt/XbA8c3dxqej5e8he4+O2ePP2LYQ8l1u0ODUJBpLk0dF5ojxS3NOSnYpIhT8zTg2a0nBNFiwcNFtfTksEVANg= Received: by 10.65.231.12 with SMTP id i12mr13454877qbr.1182445097962; Thu, 21 Jun 2007 09:58:17 -0700 (PDT) Received: by 10.64.196.20 with HTTP; Thu, 21 Jun 2007 09:58:17 -0700 (PDT) Message-ID: <6eb82e0706210958u72559a19ha5135806b115c939@mail.gmail.com> Date: Fri, 22 Jun 2007 00:58:17 +0800 From: "Rong-en Fan" To: arch@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Cc: Subject: RFC: remove UMAPFS X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2007 17:24:29 -0000 The UMAPFS was disconnected from build 3 years ago. It is seriously broken and no one is going to work on it. Therefore, I think we should remove UMAPFS from cvs and put in in Attic. Any objections? Regards, Rong-En Fan From owner-freebsd-arch@FreeBSD.ORG Thu Jun 21 17:42:32 2007 Return-Path: X-Original-To: arch@freebsd.org Delivered-To: freebsd-arch@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 18CA016A41F for ; Thu, 21 Jun 2007 17:42:32 +0000 (UTC) (envelope-from rink@thunderstone.rink.nu) Received: from mx1.rink.nu (thunderstone.rink.nu [80.112.228.34]) by mx1.freebsd.org (Postfix) with ESMTP id CE92913C480 for ; Thu, 21 Jun 2007 17:42:31 +0000 (UTC) (envelope-from rink@thunderstone.rink.nu) Received: from localhost (localhost [127.0.0.1]) by mx1.rink.nu (Postfix) with ESMTP id 18A0D6D455; Thu, 21 Jun 2007 19:42:30 +0200 (CEST) X-Virus-Scanned: amavisd-new at rink.nu Received: from mx1.rink.nu ([127.0.0.1]) by localhost (thunderstone.rink.nu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BM8k7jpxGwnR; Thu, 21 Jun 2007 19:42:25 +0200 (CEST) Received: from thunderstone.rink.nu (localhost [127.0.0.1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.rink.nu (Postfix) with ESMTP id 3757C6D452; Thu, 21 Jun 2007 19:42:25 +0200 (CEST) Received: (from rink@localhost) by thunderstone.rink.nu (8.13.8/8.13.8/Submit) id l5LHgODY021631; Thu, 21 Jun 2007 19:42:24 +0200 (CEST) (envelope-from rink) Date: Thu, 21 Jun 2007 19:42:24 +0200 From: Rink Springer To: Rong-en Fan Message-ID: <20070621174224.GA97487@rink.nu> References: <6eb82e0706210958u72559a19ha5135806b115c939@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6eb82e0706210958u72559a19ha5135806b115c939@mail.gmail.com> User-Agent: Mutt/1.5.13 (2006-08-11) Cc: arch@freebsd.org Subject: Re: RFC: remove UMAPFS X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2007 17:42:32 -0000 Hi Rong-en, On Fri, Jun 22, 2007 at 12:58:17AM +0800, Rong-en Fan wrote: > The UMAPFS was disconnected from build 3 years ago. > It is seriously broken and no one is going to work on it. > Therefore, I think we should remove UMAPFS from > cvs and put in in Attic. Any objections? None from me. If someone really cares about it, they are always welcome to bring it back from the dead. -- Rink P.W. Springer - http://rink.nu "root is always right" -- the kernel From owner-freebsd-arch@FreeBSD.ORG Thu Jun 21 17:46:05 2007 Return-Path: X-Original-To: arch@FreeBSD.ORG Delivered-To: freebsd-arch@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1796216A400 for ; Thu, 21 Jun 2007 17:46:05 +0000 (UTC) (envelope-from delphij@delphij.net) Received: from tarsier.geekcn.org (tarsier.geekcn.org [210.51.165.229]) by mx1.freebsd.org (Postfix) with ESMTP id C6D6413C4C1 for ; Thu, 21 Jun 2007 17:46:04 +0000 (UTC) (envelope-from delphij@delphij.net) Received: from localhost (tarsier.geekcn.org [210.51.165.229]) by tarsier.geekcn.org (Postfix) with ESMTP id E1424EB1F46; Fri, 22 Jun 2007 01:30:39 +0800 (CST) X-Virus-Scanned: amavisd-new at geekcn.org Received: from tarsier.geekcn.org ([210.51.165.229]) by localhost (mail.geekcn.org [210.51.165.229]) (amavisd-new, port 10024) with ESMTP id Oy1IXD7KU1nz; Fri, 22 Jun 2007 01:30:37 +0800 (CST) Received: from charlie.delphij.net (unknown [221.216.244.238]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by tarsier.geekcn.org (Postfix) with ESMTP id B64D5EB1F40; Fri, 22 Jun 2007 01:30:37 +0800 (CST) DomainKey-Signature: a=rsa-sha1; s=default; d=delphij.net; c=nofws; q=dns; h=message-id:date:from:user-agent:mime-version:to:cc:subject: references:in-reply-to:x-enigmail-version:openpgp:content-type:content-transfer-encoding; b=hQKrZ/FniErRLDqvK2sGU+H0GfeGRJLjGznxTVpqrrdERj4bXVLBRKWFL+jFHBpz+ /J+R46w8IEsrUHreJinmw== Message-ID: <467AB5BD.1030506@delphij.net> Date: Fri, 22 Jun 2007 01:30:37 +0800 From: Xin LI User-Agent: Thunderbird 2.0.0.4 (X11/20070615) MIME-Version: 1.0 To: Rong-en Fan References: <6eb82e0706210958u72559a19ha5135806b115c939@mail.gmail.com> In-Reply-To: <6eb82e0706210958u72559a19ha5135806b115c939@mail.gmail.com> X-Enigmail-Version: 0.95.1 OpenPGP: url=http://www.delphij.net/delphij.asc Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: arch@FreeBSD.ORG Subject: Re: RFC: remove UMAPFS X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2007 17:46:05 -0000 Rong-en Fan wrote: > The UMAPFS was disconnected from build 3 years ago. > It is seriously broken and no one is going to work on it. > Therefore, I think we should remove UMAPFS from > cvs and put in in Attic. Any objections? Given that it's not available on 6.x I assume that nobody would complain about its removal. I think you can just go ahead and axe it if re@ agrees. Cheers, From owner-freebsd-arch@FreeBSD.ORG Thu Jun 21 19:51:48 2007 Return-Path: X-Original-To: arch@freebsd.org Delivered-To: freebsd-arch@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D0B8016A46B for ; Thu, 21 Jun 2007 19:51:48 +0000 (UTC) (envelope-from nate@root.org) Received: from root.org (root.org [67.118.192.226]) by mx1.freebsd.org (Postfix) with ESMTP id B5F9813C4B9 for ; Thu, 21 Jun 2007 19:51:48 +0000 (UTC) (envelope-from nate@root.org) Received: (qmail 16654 invoked from network); 21 Jun 2007 16:26:53 -0000 Received: from ppp-71-139-42-13.dsl.snfc21.pacbell.net (HELO ?10.0.0.15?) (nate-mail@71.139.42.13) by root.org with ESMTPA; 21 Jun 2007 16:26:53 -0000 Message-ID: <467AA6C6.8090607@root.org> Date: Thu, 21 Jun 2007 09:26:46 -0700 From: Nate Lawson User-Agent: Thunderbird 2.0.0.0 (X11/20070511) MIME-Version: 1.0 To: Lars Engels References: <46756BBE.5030603@root.org> <20070621155044.GD17194@e.0x20.net> In-Reply-To: <20070621155044.GD17194@e.0x20.net> X-Enigmail-Version: 0.95.0 Content-Type: multipart/mixed; boundary="------------000609030506070203020900" Cc: acpi@freebsd.org, arch@freebsd.org, current Subject: Re: patch: acpi usermode suspend API change X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2007 19:51:49 -0000 This is a multi-part message in MIME format. --------------000609030506070203020900 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Lars Engels wrote: > On Sun, Jun 17, 2007 at 10:13:34AM -0700, Nate Lawson wrote: >> This patch updates the user API for acpi suspend in a number of ways. >> >> * /etc/rc.suspend,rc.resume are always run, no matter the source of the >> suspend event >> * suspend now requires positive user acknowledgement. If a user program >> wants to cancel the suspend, they can. If one of the user programs >> hangs or doesn't respond within 10 seconds, the system suspends anyway. >> * /dev/apm is clonable, allowing multiple listeners for suspend events. >> In the future, xorg-server can use this to be informed about suspend >> even if there are other listeners (i.e. apmd). >> >> The API changes are intended to be MFCd and hence are minimal. >> >> * Two new ACPI ioctls: REQSLPSTATE and ACKSLPSTATE. Request begins the >> process of suspending by notifying all listeners. acpi is monitored by >> devd(8) and /dev/apm listener(s) are also counted. Users register their >> approval or disapproval via Ack. If anyone disapproves, suspend is vetoed. >> >> * Binary compat is preserved in that old user programs or kernel modules >> (yeah, right) that called the API can still do so. A message is printed >> once that this interface is deprecated. >> >> * acpiconf gains the -k flag to ack the suspend request. This flag is >> undocumented on purpose since it's only used by /etc/rc.suspend. It is >> not intended to be a permanent change and will be removed once a better >> power API is implemented. >> >> These patches have been successfully tested for about a week through >> suspend/resumes and various usermode programs, including patches to >> xorg-server. >> >> The eventual goal is to improve subr_power to be a more generic central >> power management interface to user and kernel providers. powerd(8) >> might start managing profiles similar to apmd(8). I don't know yet and >> there isn't time to do that. This patch provides a reasonable interface >> for now and eliminates some serious weaknesses, especially in that >> pressing a sleep button did not guarantee rc.suspend would run before >> sleeping. >> >> Comments welcome, patches are for 6.x and 7.x. >> >> -- >> Nate > > Nate, > > thanks for your patch. > But after applying it on a recent -Current I get a lot of kernel messages > like these: > Jun 21 17:48:27 maggie kernel: apm34 opened clone 0xc457fd00 > Jun 21 17:48:27 maggie kernel: apm34 closed clone 0xc457fd00 > Jun 21 17:48:32 maggie kernel: apm35 opened clone 0xc457ee40 > Jun 21 17:48:32 maggie kernel: apm35 closed clone 0xc457ee40 > Jun 21 17:48:37 maggie kernel: apm36 opened clone 0xc457ec40 > Jun 21 17:48:37 maggie kernel: apm36 closed clone 0xc457ec40 > Jun 21 17:48:42 maggie kernel: apm37 opened clone 0xc457fc40 > Jun 21 17:48:42 maggie kernel: apm37 closed clone 0xc457fc40 > Jun 21 17:48:47 maggie kernel: apm38 opened clone 0xc433b6c0 > Jun 21 17:48:47 maggie kernel: apm38 closed clone 0xc433b6c0 > Jun 21 17:48:52 maggie kernel: apm39 opened clone 0xc433b240 Thanks for testing! Those were there to assist in debugging if people had any problems. > Additionally, pressing the power button only generates this: > Jun 21 17:50:03 maggie kernel: acpi: request to enter state S5 failed > > I need to run 'shutdown -p ' to power the system down. This was already fixed in the updated patch that I plan to commit today. It's attached or you can just wait for the commit to get it. -- Nate --------------000609030506070203020900 Content-Type: text/x-patch; name="acpi7_wakeapi.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="acpi7_wakeapi.diff" Index: etc/devd.conf =================================================================== RCS file: /home/ncvs/src/etc/devd.conf,v retrieving revision 1.37 diff -u -r1.37 devd.conf --- etc/devd.conf 8 Apr 2007 16:05:23 -0000 1.37 +++ etc/devd.conf 17 Jun 2007 16:52:50 -0000 @@ -239,6 +239,19 @@ action "logger -p kern.warn 'ZFS: checksum mismatch, zpool=$pool path=$vdev_path offset=$zio_offset size=$zio_size'"; }; +# User requested suspend, so perform preparation steps and then execute +# the actual suspend process. +notify 10 { + match "system" "ACPI"; + match "subsystem" "Suspend"; + action "/etc/rc.suspend acpi $notify"; +}; +notify 10 { + match "system" "ACPI"; + match "subsystem" "Resume"; + action "/etc/rc.resume acpi $notify"; +}; + /* EXAMPLES TO END OF FILE # The following might be an example of something that a vendor might @@ -277,6 +290,7 @@ # Button: Button pressed (0 for power, 1 for sleep) # CMBAT: ACPI battery events # Lid: Lid state (0 is closed, 1 is open) +# Suspend, Resume: Suspend and resume notification # Thermal: ACPI thermal zone events # # This example calls a script when the AC state changes, passing the Index: etc/rc.resume =================================================================== RCS file: /home/ncvs/src/etc/rc.resume,v retrieving revision 1.7 diff -u -r1.7 rc.resume --- etc/rc.resume 30 Dec 2003 17:30:39 -0000 1.7 +++ etc/rc.resume 17 Jun 2007 16:52:50 -0000 @@ -30,7 +30,7 @@ # sample run command file for APM Resume Event if [ $# -ne 2 ]; then - echo "Usage: $0 [apm|acpi] [standby,suspend|1-5]" + echo "Usage: $0 [apm|acpi] [standby,suspend|1-4]" exit 1 fi @@ -48,9 +48,13 @@ # pccardq | awk -F '~' '$5 == "inactive" \ # { printf("pccardc power %d 1", $1); }' | sh -# UHCI has trouble resuming so we just load/unload it. You -# should add any other kernel modules you want reloaded here. -# kldload usb +# If a device driver has problems resuming, try unloading it before +# suspend and reloading it on resume. Example: +# kldunload usb + +# wpa_supplicant(8) doesn't seem to reassociate during resume. Uncomment +# the following to signal it to reassociate. +# /usr/sbin/wpa_cli reassociate logger -t $subsystem resumed at `date +'%Y%m%d %H:%M:%S'` sync && sync && sync Index: etc/rc.suspend =================================================================== RCS file: /home/ncvs/src/etc/rc.suspend,v retrieving revision 1.6 diff -u -r1.6 rc.suspend --- etc/rc.suspend 21 Jan 2004 03:03:40 -0000 1.6 +++ etc/rc.suspend 17 Jun 2007 16:54:56 -0000 @@ -30,7 +30,7 @@ # sample run command file for APM Suspend Event if [ $# -ne 2 ]; then - echo "Usage: $0 [apm|acpi] [standby,suspend|1-5]" + echo "Usage: $0 [apm|acpi] [standby,suspend|1-4]" exit 1 fi @@ -48,15 +48,20 @@ # pccardq | awk -F '~' '$5 == "filled" && $4 ~ /sio/ \ # { printf("pccardc power %d 0", $1); }' | sh -# UHCI has trouble resuming so we just load/unload it. You -# should add any other kernel modules you want unloaded here. +# If a device driver has problems suspending, try unloading it before +# suspend and reloading it on resume. Example: # kldunload usb logger -t $subsystem suspend at `date +'%Y%m%d %H:%M:%S'` sync && sync && sync -[ $subsystem = "apm" ] && sleep 3 +sleep 3 rm -f /var/run/rc.suspend.pid -[ $subsystem = "apm" ] && zzz +if [ $subsystem = "apm" ]; then + /usr/sbin/zzz +else + # Notify the kernel to continue the suspend process + /usr/sbin/acpiconf -k 0 +fi exit 0 Index: sys/dev/acpica/acpi.c =================================================================== RCS file: /home/ncvs/src/sys/dev/acpica/acpi.c,v retrieving revision 1.239 diff -u -r1.239 acpi.c --- sys/dev/acpica/acpi.c 15 Jun 2007 18:02:33 -0000 1.239 +++ sys/dev/acpica/acpi.c 19 Jun 2007 21:42:04 -0000 @@ -136,6 +136,7 @@ static ACPI_STATUS acpi_probe_child(ACPI_HANDLE handle, UINT32 level, void *context, void **status); static BOOLEAN acpi_MatchHid(ACPI_HANDLE h, const char *hid); +static ACPI_STATUS acpi_EnterSleepState(struct acpi_softc *sc, int state); static void acpi_shutdown_final(void *arg, int howto); static void acpi_enable_fixed_events(struct acpi_softc *sc); static int acpi_wake_sleep_prep(ACPI_HANDLE handle, int sstate); @@ -410,6 +411,7 @@ sc = device_get_softc(dev); sc->acpi_dev = dev; + callout_init(&sc->susp_force_to, TRUE); error = ENXIO; @@ -592,7 +594,7 @@ /* Pick the first valid sleep state for the sleep button default. */ sc->acpi_sleep_button_sx = ACPI_S_STATES_MAX + 1; - for (state = ACPI_STATE_S1; state < ACPI_STATE_S5; state++) + for (state = ACPI_STATE_S1; state <= ACPI_STATE_S4; state++) if (ACPI_SUCCESS(AcpiGetSleepTypeData(state, &TypeA, &TypeB))) { sc->acpi_sleep_button_sx = state; break; @@ -2118,6 +2120,150 @@ return (acpi_SetInteger(ACPI_ROOT_OBJECT, "_PIC", model)); } +/* + * DEPRECATED. This interface has serious deficiencies and will be + * removed. + * + * Immediately enter the sleep state. In the old model, acpiconf(8) ran + * rc.suspend and rc.resume so we don't have to notify devd(8) to do this. + */ +ACPI_STATUS +acpi_SetSleepState(struct acpi_softc *sc, int state) +{ + static int once; + + if (!once) { + printf( +"warning: acpi_SetSleepState() deprecated, need to update your software\n"); + once = 1; + } + return (acpi_EnterSleepState(sc, state)); +} + +static void +acpi_sleep_force(void *arg) +{ + struct acpi_softc *sc; + + printf("acpi: suspend request timed out, forcing sleep now\n"); + sc = arg; + if (ACPI_FAILURE(acpi_EnterSleepState(sc, sc->acpi_next_sstate))) + printf("acpi: force sleep state S%d failed\n", sc->acpi_next_sstate); +} + +/* + * Request that the system enter the given suspend state. All /dev/apm + * devices and devd(8) will be notified. Userland then has a chance to + * save state and acknowledge the request. The system sleeps once all + * acks are in. + */ +int +acpi_ReqSleepState(struct acpi_softc *sc, int state) +{ + struct apm_clone_data *clone; + + if (state < ACPI_STATE_S1 || state > ACPI_STATE_S5) + return (EINVAL); + + /* S5 (soft-off) should be entered directly with no waiting. */ + if (state == ACPI_STATE_S5) { + if (ACPI_SUCCESS(acpi_EnterSleepState(sc, state))) + return (0); + else + return (ENXIO); + } + + /* If a suspend request is already in progress, just return. */ + ACPI_LOCK(acpi); + if (sc->acpi_next_sstate != 0) { + ACPI_UNLOCK(acpi); + return (0); + } + + /* Record the pending state and notify all apm devices. */ + sc->acpi_next_sstate = state; + STAILQ_FOREACH(clone, &sc->apm_cdevs, entries) { + clone->notify_status = APM_EV_NONE; + if ((clone->flags & ACPI_EVF_DEVD) == 0) { + selwakeuppri(&clone->sel_read, PZERO); + KNOTE_UNLOCKED(&clone->sel_read.si_note, 0); + } + } + + /* Now notify devd(8) also. */ + acpi_UserNotify("Suspend", ACPI_ROOT_OBJECT, state); + + /* + * Set a timeout to fire if userland doesn't ack the suspend request + * in time. This way we still eventually go to sleep if we were + * overheating or running low on battery, even if userland is hung. + * We cancel this timeout once all userland acks are in or the + * suspend request is aborted. + */ + callout_reset(&sc->susp_force_to, 10 * hz, acpi_sleep_force, sc); + ACPI_UNLOCK(acpi); + return (0); +} + +/* + * Acknowledge (or reject) a pending sleep state. The caller has + * prepared for suspend and is now ready for it to proceed. If the + * error argument is non-zero, it indicates suspend should be cancelled + * and gives an errno value describing why. Once all votes are in, + * we suspend the system. + */ +int +acpi_AckSleepState(struct apm_clone_data *clone, int error) +{ + struct acpi_softc *sc; + int ret, sleeping; + + /* If no pending sleep state, return an error. */ + ACPI_LOCK(acpi); + sc = clone->acpi_sc; + if (sc->acpi_next_sstate == 0) { + ACPI_UNLOCK(acpi); + return (ENXIO); + } + + /* Caller wants to abort suspend process. */ + if (error) { + sc->acpi_next_sstate = 0; + callout_stop(&sc->susp_force_to); + printf("acpi: listener on %s cancelled the pending suspend\n", + devtoname(clone->cdev)); + ACPI_UNLOCK(acpi); + return (0); + } + + /* + * Mark this device as acking the suspend request. Then, walk through + * all devices, seeing if they agree yet. We only count devices that + * are writable since read-only devices couldn't ack the request. + */ + clone->notify_status = APM_EV_ACKED; + sleeping = TRUE; + STAILQ_FOREACH(clone, &sc->apm_cdevs, entries) { + if ((clone->flags & ACPI_EVF_WRITE) != 0 && + clone->notify_status != APM_EV_ACKED) { + sleeping = FALSE; + break; + } + } + + /* If all devices have voted "yes", we will suspend now. */ + if (sleeping) + callout_stop(&sc->susp_force_to); + ACPI_UNLOCK(acpi); + ret = 0; + if (sleeping) { + if (ACPI_FAILURE(acpi_EnterSleepState(sc, sc->acpi_next_sstate))) + ret = ENODEV; + } + + return (ret); +} + static void acpi_sleep_enable(void *arg) { @@ -2134,12 +2280,12 @@ }; /* - * Set the system sleep state + * Enter the desired system sleep state. * * Currently we support S1-S5 but S4 is only S4BIOS */ -ACPI_STATUS -acpi_SetSleepState(struct acpi_softc *sc, int state) +static ACPI_STATUS +acpi_EnterSleepState(struct acpi_softc *sc, int state) { ACPI_STATUS status; UINT8 TypeA; @@ -2148,14 +2294,13 @@ ACPI_FUNCTION_TRACE_U32((char *)(uintptr_t)__func__, state); + /* Re-entry once we're suspending is not allowed. */ status = AE_OK; ACPI_LOCK(acpi); if (sc->acpi_sleep_disabled) { - if (sc->acpi_sstate != ACPI_STATE_S0) - status = AE_ERROR; ACPI_UNLOCK(acpi); printf("acpi: suspend request ignored (not ready yet)\n"); - return (status); + return (AE_ERROR); } sc->acpi_sleep_disabled = 1; ACPI_UNLOCK(acpi); @@ -2251,6 +2396,7 @@ * Back out state according to how far along we got in the suspend * process. This handles both the error and success cases. */ + sc->acpi_next_sstate = 0; if (slp_state >= ACPI_SS_GPE_SET) { acpi_wake_prep_walk(state); sc->acpi_sstate = ACPI_STATE_S0; @@ -2264,7 +2410,10 @@ /* Allow another sleep request after a while. */ if (state != ACPI_STATE_S5) - timeout(acpi_sleep_enable, (caddr_t)sc, hz * ACPI_MINIMUM_AWAKETIME); + timeout(acpi_sleep_enable, sc, hz * ACPI_MINIMUM_AWAKETIME); + + /* Run /etc/rc.resume after we are back. */ + acpi_UserNotify("Resume", ACPI_ROOT_OBJECT, state); mtx_unlock(&Giant); return_ACPI_STATUS (status); @@ -2574,11 +2723,15 @@ static void acpi_system_eventhandler_sleep(void *arg, int state) { + int ret; ACPI_FUNCTION_TRACE_U32((char *)(uintptr_t)__func__, state); - if (state >= ACPI_STATE_S0 && state <= ACPI_S_STATES_MAX) - acpi_SetSleepState((struct acpi_softc *)arg, state); + /* Request that the system prepare to enter the given suspend state. */ + ret = acpi_ReqSleepState((struct acpi_softc *)arg, state); + if (ret != 0) + printf("acpi: request to enter state S%d failed (err %d)\n", + state, ret); return_VOID; } @@ -2840,7 +2993,20 @@ /* Core system ioctls. */ switch (cmd) { - case ACPIIO_SETSLPSTATE: + case ACPIIO_REQSLPSTATE: + state = *(int *)addr; + if (state != ACPI_STATE_S5) + error = acpi_ReqSleepState(sc, state); + else { + printf("power off via acpi ioctl not supported\n"); + error = ENXIO; + } + break; + case ACPIIO_ACKSLPSTATE: + error = *(int *)addr; + error = acpi_AckSleepState(sc->acpi_clone, error); + break; + case ACPIIO_SETSLPSTATE: /* DEPRECATED */ error = EINVAL; state = *(int *)addr; if (state >= ACPI_STATE_S0 && state <= ACPI_S_STATES_MAX) @@ -3171,7 +3337,8 @@ goto out; } - acpi_SetSleepState(sc, acpi_state); + if (ACPI_FAILURE(acpi_EnterSleepState(sc, acpi_state))) + error = ENXIO; break; default: error = EINVAL; Index: sys/dev/acpica/acpiio.h =================================================================== RCS file: /home/ncvs/src/sys/dev/acpica/acpiio.h,v retrieving revision 1.16 diff -u -r1.16 acpiio.h --- sys/dev/acpica/acpiio.h 23 Oct 2005 00:16:41 -0000 1.16 +++ sys/dev/acpica/acpiio.h 17 Jun 2007 16:52:50 -0000 @@ -33,7 +33,13 @@ /* * Core ACPI subsystem ioctls */ -#define ACPIIO_SETSLPSTATE _IOW('P', 3, int) +#define ACPIIO_SETSLPSTATE _IOW('P', 3, int) /* DEPRECATED */ + +/* Request S1-5 sleep state. User is notified and then sleep proceeds. */ +#define ACPIIO_REQSLPSTATE _IOW('P', 4, int) + +/* Allow suspend to continue (0) or abort it (errno). */ +#define ACPIIO_ACKSLPSTATE _IOW('P', 5, int) struct acpi_battinfo { int cap; /* percent */ Index: sys/dev/acpica/acpivar.h =================================================================== RCS file: /home/ncvs/src/sys/dev/acpica/acpivar.h,v retrieving revision 1.106 diff -u -r1.106 acpivar.h --- sys/dev/acpica/acpivar.h 15 Jun 2007 18:02:34 -0000 1.106 +++ sys/dev/acpica/acpivar.h 17 Jun 2007 16:57:25 -0000 @@ -39,12 +39,14 @@ #include #include #include +#include #include #include #include #include +struct apm_clone_data; struct acpi_softc { device_t acpi_dev; struct cdev *acpi_dev_t; @@ -76,6 +78,11 @@ bus_dmamap_t acpi_wakemap; vm_offset_t acpi_wakeaddr; vm_paddr_t acpi_wakephys; + + int acpi_next_sstate; /* Next suspend Sx state. */ + struct apm_clone_data *acpi_clone; /* Pseudo-dev for devd(8). */ + STAILQ_HEAD(,apm_clone_data) apm_cdevs; /* All apm/apmctl/acpi cdevs. */ + struct callout susp_force_to; /* Force suspend if no acks. */ }; struct acpi_device { @@ -89,6 +96,22 @@ struct resource_list ad_rl; }; +/* Track device (/dev/{apm,apmctl} and /dev/acpi) notification status. */ +struct apm_clone_data { + STAILQ_ENTRY(apm_clone_data) entries; + struct cdev *cdev; + int flags; +#define ACPI_EVF_NONE 0 /* /dev/apm semantics */ +#define ACPI_EVF_DEVD 1 /* /dev/acpi is handled via devd(8) */ +#define ACPI_EVF_WRITE 2 /* Device instance is opened writable. */ + int notify_status; +#define APM_EV_NONE 0 /* Device not yet aware of pending sleep. */ +#define APM_EV_NOTIFIED 1 /* Device saw next sleep state. */ +#define APM_EV_ACKED 2 /* Device agreed sleep can occur. */ + struct acpi_softc *acpi_sc; + struct selinfo sel_read; +}; + #define ACPI_PRW_MAX_POWERRES 8 struct acpi_prw_data { @@ -304,6 +327,8 @@ ACPI_RESOURCE *res); ACPI_STATUS acpi_OverrideInterruptLevel(UINT32 InterruptNumber); ACPI_STATUS acpi_SetIntrModel(int model); +int acpi_ReqSleepState(struct acpi_softc *sc, int state); +int acpi_AckSleepState(struct apm_clone_data *clone, int error); ACPI_STATUS acpi_SetSleepState(struct acpi_softc *sc, int state); int acpi_wake_init(device_t dev, int type); int acpi_wake_set_enable(device_t dev, int enable); Index: sys/i386/acpica/acpi_machdep.c =================================================================== RCS file: /home/ncvs/src/sys/i386/acpica/acpi_machdep.c,v retrieving revision 1.35 diff -u -r1.35 acpi_machdep.c --- sys/i386/acpica/acpi_machdep.c 31 Mar 2007 23:23:41 -0000 1.35 +++ sys/i386/acpica/acpi_machdep.c 19 Jun 2007 21:42:33 -0000 @@ -33,6 +33,8 @@ #include #include #include +#include +#include #include #include #include @@ -46,8 +48,6 @@ * APM driver emulation */ -#include - #include #include @@ -64,21 +64,31 @@ static int intr_model = ACPI_INTR_PIC; static int apm_active; +static struct clonedevs *apm_clones; + +MALLOC_DEFINE(M_APMDEV, "apmdev", "APM device emulation"); -static d_open_t apmopen; -static d_close_t apmclose; -static d_write_t apmwrite; -static d_ioctl_t apmioctl; -static d_poll_t apmpoll; +static d_open_t apmopen; +static d_close_t apmclose; +static d_write_t apmwrite; +static d_ioctl_t apmioctl; +static d_poll_t apmpoll; +static d_kqfilter_t apmkqfilter; +static void apmreadfiltdetach(struct knote *kn); +static int apmreadfilt(struct knote *kn, long hint); +static struct filterops apm_readfiltops = + { 1, NULL, apmreadfiltdetach, apmreadfilt }; static struct cdevsw apm_cdevsw = { .d_version = D_VERSION, + .d_flags = D_TRACKCLOSE, .d_open = apmopen, .d_close = apmclose, .d_write = apmwrite, .d_ioctl = apmioctl, .d_poll = apmpoll, .d_name = "apm", + .d_kqfilter = apmkqfilter }; static int @@ -202,44 +212,169 @@ return (0); } +/* Create single-use devices for /dev/apm and /dev/apmctl. */ +static void +apm_clone(void *arg, struct ucred *cred, char *name, int namelen, + struct cdev **dev) +{ + int ctl_dev, unit; + + if (*dev != NULL) + return; + if (strcmp(name, "apmctl") == 0) + ctl_dev = TRUE; + else if (strcmp(name, "apm") == 0) + ctl_dev = FALSE; + else + return; + + /* Always create a new device and unit number. */ + unit = -1; + if (clone_create(&apm_clones, &apm_cdevsw, &unit, dev, 0)) { + if (ctl_dev) { + *dev = make_dev(&apm_cdevsw, unit2minor(unit), + UID_ROOT, GID_OPERATOR, 0660, "apmctl%d", unit); + } else { + *dev = make_dev(&apm_cdevsw, unit2minor(unit), + UID_ROOT, GID_OPERATOR, 0664, "apm%d", unit); + } + if (*dev != NULL) { + dev_ref(*dev); + (*dev)->si_flags |= SI_CHEAPCLONE; + } + } +} + +/* Create a struct for tracking per-device suspend notification. */ +static struct apm_clone_data * +apm_create_clone(struct cdev *dev, struct acpi_softc *acpi_sc) +{ + struct apm_clone_data *clone; + + clone = malloc(sizeof(*clone), M_APMDEV, M_WAITOK); + clone->cdev = dev; + clone->acpi_sc = acpi_sc; + clone->notify_status = APM_EV_NONE; + bzero(&clone->sel_read, sizeof(clone->sel_read)); + knlist_init(&clone->sel_read.si_note, &acpi_mutex, NULL, NULL, NULL); + + /* + * The acpi device is always managed by devd(8) and is considered + * writable (i.e., ack is required to allow suspend to proceed.) + */ + if (strcmp("acpi", devtoname(dev)) == 0) + clone->flags = ACPI_EVF_DEVD | ACPI_EVF_WRITE; + else + clone->flags = ACPI_EVF_NONE; + + ACPI_LOCK(acpi); + STAILQ_INSERT_TAIL(&acpi_sc->apm_cdevs, clone, entries); + ACPI_UNLOCK(acpi); + return (clone); +} + static int apmopen(struct cdev *dev, int flag, int fmt, d_thread_t *td) { + struct acpi_softc *acpi_sc; + struct apm_clone_data *clone; + + acpi_sc = devclass_get_softc(devclass_find("acpi"), 0); + clone = apm_create_clone(dev, acpi_sc); + dev->si_drv1 = clone; + + /* If the device is opened for write, record that. */ + if ((flag & FWRITE) != 0) + clone->flags |= ACPI_EVF_WRITE; + return (0); } static int apmclose(struct cdev *dev, int flag, int fmt, d_thread_t *td) { + struct apm_clone_data *clone; + struct acpi_softc *acpi_sc; + + clone = dev->si_drv1; + acpi_sc = clone->acpi_sc; + + /* We are about to lose a reference so check if suspend should occur */ + if (acpi_sc->acpi_next_sstate != 0 && + clone->notify_status != APM_EV_ACKED) + acpi_AckSleepState(clone, 0); + + /* Remove this clone's data from the list and free it. */ + ACPI_LOCK(acpi); + STAILQ_REMOVE(&acpi_sc->apm_cdevs, clone, apm_clone_data, entries); + knlist_destroy(&clone->sel_read.si_note); + ACPI_UNLOCK(acpi); + free(clone, M_APMDEV); + /* XXX destroy_dev() needed */ return (0); } static int apmioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, d_thread_t *td) { - int error = 0; + int error; + struct apm_clone_data *clone; struct acpi_softc *acpi_sc; - struct apm_info info; + struct apm_info info; + struct apm_event_info *ev_info; apm_info_old_t aiop; - acpi_sc = devclass_get_softc(devclass_find("acpi"), 0); + error = 0; + clone = dev->si_drv1; + acpi_sc = clone->acpi_sc; switch (cmd) { case APMIO_SUSPEND: if ((flag & FWRITE) == 0) return (EPERM); - if (apm_active) - acpi_SetSleepState(acpi_sc, acpi_sc->acpi_suspend_sx); - else - error = EINVAL; + if (acpi_sc->acpi_next_sstate == 0) { + if (acpi_sc->acpi_suspend_sx != ACPI_STATE_S5) { + error = acpi_ReqSleepState(acpi_sc, + acpi_sc->acpi_suspend_sx); + } else { + printf( + "power off via apm suspend not supported\n"); + error = ENXIO; + } + } else + error = acpi_AckSleepState(clone, 0); break; case APMIO_STANDBY: if ((flag & FWRITE) == 0) return (EPERM); - if (apm_active) - acpi_SetSleepState(acpi_sc, acpi_sc->acpi_standby_sx); - else - error = EINVAL; + if (acpi_sc->acpi_next_sstate == 0) { + if (acpi_sc->acpi_standby_sx != ACPI_STATE_S5) { + error = acpi_ReqSleepState(acpi_sc, + acpi_sc->acpi_standby_sx); + } else { + printf( + "power off via apm standby not supported\n"); + error = ENXIO; + } + } else + error = acpi_AckSleepState(clone, 0); + break; + case APMIO_NEXTEVENT: + printf("apm nextevent start\n"); + ACPI_LOCK(acpi); + if (acpi_sc->acpi_next_sstate != 0 && clone->notify_status == + APM_EV_NONE) { + ev_info = (struct apm_event_info *)addr; + if (acpi_sc->acpi_next_sstate <= ACPI_STATE_S3) + ev_info->type = PMEV_STANDBYREQ; + else + ev_info->type = PMEV_SUSPENDREQ; + ev_info->index = 0; + clone->notify_status = APM_EV_NOTIFIED; + printf("apm event returning %d\n", ev_info->type); + } else + error = EAGAIN; + ACPI_UNLOCK(acpi); break; case APMIO_GETINFO_OLD: if (acpi_capm_get_info(&info)) @@ -300,24 +435,71 @@ static int apmpoll(struct cdev *dev, int events, d_thread_t *td) { + struct apm_clone_data *clone; + int revents; + + revents = 0; + ACPI_LOCK(acpi); + clone = dev->si_drv1; + if (clone->acpi_sc->acpi_next_sstate) + revents |= events & (POLLIN | POLLRDNORM); + else + selrecord(td, &clone->sel_read); + ACPI_UNLOCK(acpi); + return (revents); +} + +static int +apmkqfilter(struct cdev *dev, struct knote *kn) +{ + struct apm_clone_data *clone; + + ACPI_LOCK(acpi); + clone = dev->si_drv1; + kn->kn_hook = clone; + kn->kn_fop = &apm_readfiltops; + knlist_add(&clone->sel_read.si_note, kn, 0); + ACPI_UNLOCK(acpi); return (0); } static void -acpi_capm_init(struct acpi_softc *sc) +apmreadfiltdetach(struct knote *kn) +{ + struct apm_clone_data *clone; + + ACPI_LOCK(acpi); + clone = kn->kn_hook; + knlist_remove(&clone->sel_read.si_note, kn, 0); + ACPI_UNLOCK(acpi); +} + +static int +apmreadfilt(struct knote *kn, long hint) { - make_dev(&apm_cdevsw, 0, 0, 5, 0664, "apm"); + struct apm_clone_data *clone; + int sleeping; + + ACPI_LOCK(acpi); + clone = kn->kn_hook; + sleeping = clone->acpi_sc->acpi_next_sstate ? 1 : 0; + ACPI_UNLOCK(acpi); + return (sleeping); } int acpi_machdep_init(device_t dev) { - struct acpi_softc *sc; + struct acpi_softc *acpi_sc; - sc = devclass_get_softc(devclass_find("acpi"), 0); - acpi_capm_init(sc); + acpi_sc = devclass_get_softc(devclass_find("acpi"), 0); - acpi_install_wakeup_handler(sc); + /* Create a clone for /dev/acpi also. */ + STAILQ_INIT(&acpi_sc->apm_cdevs); + acpi_sc->acpi_clone = apm_create_clone(acpi_sc->acpi_dev_t, acpi_sc); + clone_setup(&apm_clones); + EVENTHANDLER_REGISTER(dev_clone, apm_clone, 0, 1000); + acpi_install_wakeup_handler(acpi_sc); if (intr_model == ACPI_INTR_PIC) BUS_CONFIG_INTR(dev, AcpiGbl_FADT.SciInterrupt, @@ -325,8 +507,8 @@ else acpi_SetIntrModel(intr_model); - SYSCTL_ADD_UINT(&sc->acpi_sysctl_ctx, - SYSCTL_CHILDREN(sc->acpi_sysctl_tree), OID_AUTO, + SYSCTL_ADD_UINT(&acpi_sc->acpi_sysctl_ctx, + SYSCTL_CHILDREN(acpi_sc->acpi_sysctl_tree), OID_AUTO, "reset_video", CTLFLAG_RW, &acpi_reset_video, 0, "Call the VESA reset BIOS vector on the resume path"); Index: usr.sbin/acpi/acpiconf/acpiconf.8 =================================================================== RCS file: /home/ncvs/src/usr.sbin/acpi/acpiconf/acpiconf.8,v retrieving revision 1.15 diff -u -r1.15 acpiconf.8 --- usr.sbin/acpi/acpiconf/acpiconf.8 9 Feb 2005 18:04:39 -0000 1.15 +++ usr.sbin/acpi/acpiconf/acpiconf.8 19 Jun 2007 20:46:44 -0000 @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 16, 2004 +.Dd June 19, 2007 .Dt ACPICONF 8 .Os .Sh NAME @@ -57,13 +57,21 @@ .Cm 2 (not implemented on most systems but similar to S1), .Cm 3 -(the CPU context is lost and memory context is preserved), -.Cm 4 -(the CPU context is lost and memory context is stored to disk) +(suspend to RAM) and +.Cm 4 +(suspend to disk) +.Nm +does not support .Cm 5 -(soft off). -Sleep states may also be given as S1, S2, etc. +(power off). +Power-off is instead activated with the +.Fl p +flag of +.Xr shutdown 8 +or +.Xr halt 8 . +Sleep states may also be given as strings (i.e., S1, S2, etc.) The supported states depend on BIOS implementation, including ACPI byte code (AML). If the @@ -76,7 +84,9 @@ .Sh SEE ALSO .Xr acpi 4 , .Xr acpidump 8 , -.Xr apm 8 +.Xr apm 8 , +.Xr halt 8 , +.Xr shutdown 8 .Sh HISTORY The .Nm Index: usr.sbin/acpi/acpiconf/acpiconf.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/acpi/acpiconf/acpiconf.c,v retrieving revision 1.25 diff -u -r1.25 acpiconf.c --- usr.sbin/acpi/acpiconf/acpiconf.c 28 Jul 2005 19:41:52 -0000 1.25 +++ usr.sbin/acpi/acpiconf/acpiconf.c 17 Jun 2007 16:52:50 -0000 @@ -40,8 +40,6 @@ #include #define ACPIDEV "/dev/acpi" -#define RC_SUSPEND_PATH "/etc/rc.suspend" -#define RC_RESUME_PATH "/etc/rc.resume" static int acpifd; @@ -55,32 +53,27 @@ err(EX_OSFILE, ACPIDEV); } -static int +/* Prepare to sleep and then wait for the signal that sleeping can occur. */ +static void acpi_sleep(int sleep_type) { - char cmd[64]; int ret; + + /* Notify OS that we want to sleep. devd(8) gets this notify. */ + ret = ioctl(acpifd, ACPIIO_REQSLPSTATE, &sleep_type); + if (ret != 0) + err(EX_IOERR, "request sleep type (%d) failed", sleep_type); +} - /* Run the suspend rc script, if available. */ - if (access(RC_SUSPEND_PATH, X_OK) == 0) { - snprintf(cmd, sizeof(cmd), "%s acpi %d", RC_SUSPEND_PATH, - sleep_type); - system(cmd); - } - - ret = ioctl(acpifd, ACPIIO_SETSLPSTATE, &sleep_type); - - /* Run the resume rc script, if available. */ - if (access(RC_RESUME_PATH, X_OK) == 0) { - snprintf(cmd, sizeof(cmd), "%s acpi %d", RC_RESUME_PATH, - sleep_type); - system(cmd); - } +/* Ack or abort a pending suspend request. */ +static void +acpi_sleep_ack(int err_val) +{ + int ret; + ret = ioctl(acpifd, ACPIIO_ACKSLPSTATE, &err_val); if (ret != 0) - err(EX_IOERR, "sleep type (%d) failed", sleep_type); - - return (0); + err(EX_IOERR, "ack sleep type failed"); } /* should be a acpi define, but doesn't appear to be */ @@ -183,7 +176,7 @@ static void usage(const char* prog) { - printf("usage: %s [-h] [-i batt] [-s 1-5]\n", prog); + printf("usage: %s [-h] [-i batt] [-k ack] [-s 1-4]\n", prog); exit(0); } @@ -200,17 +193,20 @@ sleep_type = -1; acpi_init(); - while ((c = getopt(argc, argv, "hi:s:")) != -1) { + while ((c = getopt(argc, argv, "hi:k:s:")) != -1) { switch (c) { case 'i': acpi_battinfo(atoi(optarg)); break; + case 'k': + acpi_sleep_ack(atoi(optarg)); + break; case 's': if (optarg[0] == 'S') sleep_type = optarg[1] - '0'; else sleep_type = optarg[0] - '0'; - if (sleep_type < 0 || sleep_type > 5) + if (sleep_type < 1 || sleep_type > 4) errx(EX_USAGE, "invalid sleep type (%d)", sleep_type); break; @@ -223,10 +219,8 @@ argc -= optind; argv += optind; - if (sleep_type != -1) { - sleep(1); /* wait 1 sec. for key-release event */ + if (sleep_type != -1) acpi_sleep(sleep_type); - } close(acpifd); exit (0); --------------000609030506070203020900-- From owner-freebsd-arch@FreeBSD.ORG Thu Jun 21 19:52:51 2007 Return-Path: X-Original-To: arch@freebsd.org Delivered-To: freebsd-arch@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 82CB716A468 for ; Thu, 21 Jun 2007 19:52:51 +0000 (UTC) (envelope-from nate@root.org) Received: from root.org (root.org [67.118.192.226]) by mx1.freebsd.org (Postfix) with ESMTP id 6A4BE13C455 for ; Thu, 21 Jun 2007 19:52:51 +0000 (UTC) (envelope-from nate@root.org) Received: (qmail 17034 invoked from network); 21 Jun 2007 16:29:35 -0000 Received: from ppp-71-139-42-13.dsl.snfc21.pacbell.net (HELO ?10.0.0.15?) (nate-mail@71.139.42.13) by root.org with ESMTPA; 21 Jun 2007 16:29:35 -0000 Message-ID: <467AA768.60306@root.org> Date: Thu, 21 Jun 2007 09:29:28 -0700 From: Nate Lawson User-Agent: Thunderbird 2.0.0.0 (X11/20070511) MIME-Version: 1.0 To: Lars Engels References: <46756BBE.5030603@root.org> <20070621155330.GE17194@e.0x20.net> In-Reply-To: <20070621155330.GE17194@e.0x20.net> X-Enigmail-Version: 0.95.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: acpi@freebsd.org, arch@freebsd.org, current Subject: Re: patch: acpi usermode suspend API change X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2007 19:52:51 -0000 Lars Engels wrote: > And I just saw that every 5 second a new apm device is created! > > # ls /dev > acd0 apm12 apm3 apm47 apm8 > acpi apm13 apm30 apm48 apm9 > ad0 apm14 apm31 apm49 ata > ad0.journal apm15 apm32 apm5 atkbd0 > ad0.journals1 apm16 apm33 apm50 bpf0 > ad0.journals2 apm17 apm34 apm51 bpf1 > ad0.journals3 apm18 apm35 apm52 bpsm0 > ad0.journals4 apm19 apm36 apm53 cardbus0.cis > ad0.journals4a apm2 apm37 apm54 cd0 > ad0.journals4b apm20 apm38 apm55 cdrom@ > ad0.journals4c apm21 apm39 apm56 console > ad0.journals4d apm22 apm4 apm57 consolectl > ad0.journals4e apm23 apm40 apm58 ctty > ad0.journals4f apm24 apm41 apm59 cuad0 > agpgart apm25 apm42 apm6 cuad0.init > apm0 apm26 apm43 apm60 cuad0.lock > apm1 apm27 apm44 apm61 devctl > apm10 apm28 apm45 apm62 devstat > apm11 apm29 apm46 apm7 dri/ > > [...] What are you running that opens /dev/apm? Maybe powerd? I have a patch that handles reaping these devices, unfortunately it is pending completion of another patch that allows devfs_destroy() from a close() routine. That part is a core problem in FreeBSD, and it isn't really something in acpi. -- Nate From owner-freebsd-arch@FreeBSD.ORG Thu Jun 21 22:26:05 2007 Return-Path: X-Original-To: arch@freebsd.org Delivered-To: freebsd-arch@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 07BEA16A469; Thu, 21 Jun 2007 22:26:05 +0000 (UTC) (envelope-from lars@e.0x20.net) Received: from mail.0x20.net (mail.0x20.net [217.69.67.217]) by mx1.freebsd.org (Postfix) with ESMTP id BCB0113C480; Thu, 21 Jun 2007 22:26:04 +0000 (UTC) (envelope-from lars@e.0x20.net) Received: by mail.0x20.net (Postfix, from userid 1002) id 992DB39E2B; Fri, 22 Jun 2007 00:26:03 +0200 (CEST) Date: Fri, 22 Jun 2007 00:26:03 +0200 From: Lars Engels To: Nate Lawson Message-ID: <20070621222603.GB16887@e.0x20.net> References: <46756BBE.5030603@root.org> <20070621155330.GE17194@e.0x20.net> <467AA768.60306@root.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="s/l3CgOIzMHHjg/5" Content-Disposition: inline In-Reply-To: <467AA768.60306@root.org> X-Editor: VIM - Vi IMproved 7.0 X-Operation-System: FreeBSD 5.5-RELEASE User-Agent: mutt-ng/devel-r804 (FreeBSD) Cc: acpi@freebsd.org, arch@freebsd.org, current Subject: Re: patch: acpi usermode suspend API change X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2007 22:26:05 -0000 --s/l3CgOIzMHHjg/5 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jun 21, 2007 at 09:29:28AM -0700, Nate Lawson wrote: > Lars Engels wrote: > > And I just saw that every 5 second a new apm device is created!=20 > >=20 > > # ls /dev > > acd0 apm12 apm3 apm47 apm8 = =20 > > acpi apm13 apm30 apm48 apm9 = =20 > > ad0 apm14 apm31 apm49 ata = =20 > > ad0.journal apm15 apm32 apm5 atkbd0 = =20 > > ad0.journals1 apm16 apm33 apm50 bpf0 = =20 > > ad0.journals2 apm17 apm34 apm51 bpf1 = =20 > > ad0.journals3 apm18 apm35 apm52 bpsm0 = =20 > > ad0.journals4 apm19 apm36 apm53 cardbus= 0.cis > > ad0.journals4a apm2 apm37 apm54 cd0 = =20 > > ad0.journals4b apm20 apm38 apm55 cdrom@ = =20 > > ad0.journals4c apm21 apm39 apm56 console= =20 > > ad0.journals4d apm22 apm4 apm57 console= ctl =20 > > ad0.journals4e apm23 apm40 apm58 ctty = =20 > > ad0.journals4f apm24 apm41 apm59 cuad0 = =20 > > agpgart apm25 apm42 apm6 cuad0.i= nit =20 > > apm0 apm26 apm43 apm60 cuad0.l= ock =20 > > apm1 apm27 apm44 apm61 devctl = =20 > > apm10 apm28 apm45 apm62 devstat= =20 > > apm11 apm29 apm46 apm7 dri/ = =20 > >=20 > > [...] >=20 > What are you running that opens /dev/apm? Maybe powerd? >=20 > I have a patch that handles reaping these devices, unfortunately it is > pending completion of another patch that allows devfs_destroy() from a > close() routine. That part is a core problem in FreeBSD, and it isn't > really something in acpi. Yes, powerd is running. Do you need additional system info? --s/l3CgOIzMHHjg/5 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (FreeBSD) iD8DBQFGevr7Kc512sD3afgRAq0vAKCWrXA4rudrFiI02IYWkTX+MBCkSQCeO5tL huV7ActDHmjtQauOH62MfPU= =AKUg -----END PGP SIGNATURE----- --s/l3CgOIzMHHjg/5-- From owner-freebsd-arch@FreeBSD.ORG Thu Jun 21 22:28:37 2007 Return-Path: X-Original-To: arch@freebsd.org Delivered-To: freebsd-arch@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 2AB1116A46C; Thu, 21 Jun 2007 22:28:37 +0000 (UTC) (envelope-from lars@e.0x20.net) Received: from mail.0x20.net (mail.0x20.net [217.69.67.217]) by mx1.freebsd.org (Postfix) with ESMTP id D0C9F13C4DA; Thu, 21 Jun 2007 22:28:36 +0000 (UTC) (envelope-from lars@e.0x20.net) Received: by mail.0x20.net (Postfix, from userid 1002) id 246EC39E2D; Fri, 22 Jun 2007 00:28:36 +0200 (CEST) Date: Fri, 22 Jun 2007 00:28:36 +0200 From: Lars Engels To: Nate Lawson Message-ID: <20070621222836.GC16887@e.0x20.net> References: <46756BBE.5030603@root.org> <20070621155044.GD17194@e.0x20.net> <467AA6C6.8090607@root.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="E/DnYTRukya0zdZ1" Content-Disposition: inline In-Reply-To: <467AA6C6.8090607@root.org> X-Editor: VIM - Vi IMproved 7.0 X-Operation-System: FreeBSD 5.5-RELEASE User-Agent: mutt-ng/devel-r804 (FreeBSD) Cc: acpi@freebsd.org, arch@freebsd.org, current Subject: Re: patch: acpi usermode suspend API change X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2007 22:28:37 -0000 --E/DnYTRukya0zdZ1 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jun 21, 2007 at 09:26:46AM -0700, Nate Lawson wrote: > Lars Engels wrote: > >=20 > > Nate,=20 > >=20 > > thanks for your patch.=20 > > But after applying it on a recent -Current I get a lot of kernel messag= es > > like these: > > Jun 21 17:48:27 maggie kernel: apm34 opened clone 0xc457fd00 > > Jun 21 17:48:27 maggie kernel: apm34 closed clone 0xc457fd00 > > Jun 21 17:48:32 maggie kernel: apm35 opened clone 0xc457ee40 > > Jun 21 17:48:32 maggie kernel: apm35 closed clone 0xc457ee40 > > Jun 21 17:48:37 maggie kernel: apm36 opened clone 0xc457ec40 > > Jun 21 17:48:37 maggie kernel: apm36 closed clone 0xc457ec40 > > Jun 21 17:48:42 maggie kernel: apm37 opened clone 0xc457fc40 > > Jun 21 17:48:42 maggie kernel: apm37 closed clone 0xc457fc40 > > Jun 21 17:48:47 maggie kernel: apm38 opened clone 0xc433b6c0 > > Jun 21 17:48:47 maggie kernel: apm38 closed clone 0xc433b6c0 > > Jun 21 17:48:52 maggie kernel: apm39 opened clone 0xc433b240 >=20 > Thanks for testing! Those were there to assist in debugging if people > had any problems. >=20 > > Additionally, pressing the power button only generates this: > > Jun 21 17:50:03 maggie kernel: acpi: request to enter state S5 failed > >=20 > > I need to run 'shutdown -p ' to power the system down. >=20 > This was already fixed in the updated patch that I plan to commit today. > It's attached or you can just wait for the commit to get it. Okay, I cannot test this today, so I will take your committed version tomorrow. Lars --E/DnYTRukya0zdZ1 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (FreeBSD) iD8DBQFGevuUKc512sD3afgRAgLCAKDGQl2xjbBWhffsECdV+1+MzxT2DwCff8ml bOMOlF+TCLahlf1o8cbNZ3Q= =/z5M -----END PGP SIGNATURE----- --E/DnYTRukya0zdZ1-- From owner-freebsd-arch@FreeBSD.ORG Thu Jun 21 23:33:39 2007 Return-Path: X-Original-To: arch@freebsd.org Delivered-To: freebsd-arch@FreeBSD.ORG Received: from misaki (localhost [127.0.0.1]) by hub.freebsd.org (Postfix) with SMTP id 0F47F16A473; Thu, 21 Jun 2007 23:33:37 +0000 (UTC) (envelope-from ariff@FreeBSD.org) Date: Fri, 22 Jun 2007 07:33:22 +0800 From: Ariff Abdullah To: Nate Lawson Message-Id: <20070622073322.3054360b.ariff@FreeBSD.org> In-Reply-To: <467AA768.60306@root.org> References: <46756BBE.5030603@root.org> <20070621155330.GE17194@e.0x20.net> <467AA768.60306@root.org> Organization: FreeBSD X-Mailer: /usr/local/lib/ruby/1.8/net/smtp.rb Mime-Version: 1.0 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg="PGP-SHA1"; boundary="Signature=_Fri__22_Jun_2007_07_33_22_+0800_yRoGAbpaDpb4XnBS" Cc: acpi@freebsd.org, arch@freebsd.org, lars.engels@0x20.net, current@freebsd.org Subject: Re: patch: acpi usermode suspend API change X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2007 23:33:39 -0000 --Signature=_Fri__22_Jun_2007_07_33_22_+0800_yRoGAbpaDpb4XnBS Content-Type: text/plain; charset=US-ASCII Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, 21 Jun 2007 09:29:28 -0700 Nate Lawson wrote: > Lars Engels wrote: > > And I just saw that every 5 second a new apm device is created!=20 [...] > >=20 > > [...] >=20 > What are you running that opens /dev/apm? Maybe powerd? >=20 > I have a patch that handles reaping these devices, unfortunately it > is pending completion of another patch that allows devfs_destroy() > from a close() routine. That part is a core problem in FreeBSD, and > it isn't really something in acpi. >=20 Same issue with sound devices as well, but I've managed to solve it by implementing own clone manager which require tiny hook into open() and close() along with garbage collector and ability to handle various abusive behaviour (while : ; ls /dev/xxx ; done, etc). See sys/dev/sound/clone.* . It should be generic enough. -- Ariff Abdullah FreeBSD ... Recording in stereo is obviously too advanced and confusing for us idiot ***** users :P ........ --Signature=_Fri__22_Jun_2007_07_33_22_+0800_yRoGAbpaDpb4XnBS Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (FreeBSD) iD8DBQFGewrClr+deMUwTNoRAglqAJwLOBnXpZpr8C4tGOYXzFfpnt3iQgCggmaI 538OwsFjKgNtm+9WnZb9WgY= =BSeB -----END PGP SIGNATURE----- --Signature=_Fri__22_Jun_2007_07_33_22_+0800_yRoGAbpaDpb4XnBS-- From owner-freebsd-arch@FreeBSD.ORG Fri Jun 22 01:27:40 2007 Return-Path: X-Original-To: arch@freebsd.org Delivered-To: freebsd-arch@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DCDFA16A468 for ; Fri, 22 Jun 2007 01:27:40 +0000 (UTC) (envelope-from nate@root.org) Received: from root.org (root.org [67.118.192.226]) by mx1.freebsd.org (Postfix) with ESMTP id C376013C457 for ; Fri, 22 Jun 2007 01:27:40 +0000 (UTC) (envelope-from nate@root.org) Received: (qmail 55368 invoked from network); 21 Jun 2007 22:29:01 -0000 Received: from ppp-71-139-42-13.dsl.snfc21.pacbell.net (HELO ?10.0.0.15?) (nate-mail@71.139.42.13) by root.org with ESMTPA; 21 Jun 2007 22:29:01 -0000 Message-ID: <467AFBA5.6040309@root.org> Date: Thu, 21 Jun 2007 15:28:53 -0700 From: Nate Lawson User-Agent: Thunderbird 2.0.0.0 (X11/20070511) MIME-Version: 1.0 To: Lars Engels References: <46756BBE.5030603@root.org> <20070621155330.GE17194@e.0x20.net> <467AA768.60306@root.org> <20070621222603.GB16887@e.0x20.net> In-Reply-To: <20070621222603.GB16887@e.0x20.net> X-Enigmail-Version: 0.95.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: acpi@freebsd.org, arch@freebsd.org, current Subject: Re: patch: acpi usermode suspend API change X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2007 01:27:40 -0000 Lars Engels wrote: > On Thu, Jun 21, 2007 at 09:29:28AM -0700, Nate Lawson wrote: >> Lars Engels wrote: >>> And I just saw that every 5 second a new apm device is created! >>> >>> # ls /dev >>> acd0 apm12 apm3 apm47 apm8 >>> acpi apm13 apm30 apm48 apm9 >>> ad0 apm14 apm31 apm49 ata >>> ad0.journal apm15 apm32 apm5 atkbd0 >>> ad0.journals1 apm16 apm33 apm50 bpf0 >>> ad0.journals2 apm17 apm34 apm51 bpf1 >>> ad0.journals3 apm18 apm35 apm52 bpsm0 >>> ad0.journals4 apm19 apm36 apm53 cardbus0.cis >>> ad0.journals4a apm2 apm37 apm54 cd0 >>> ad0.journals4b apm20 apm38 apm55 cdrom@ >>> ad0.journals4c apm21 apm39 apm56 console >>> ad0.journals4d apm22 apm4 apm57 consolectl >>> ad0.journals4e apm23 apm40 apm58 ctty >>> ad0.journals4f apm24 apm41 apm59 cuad0 >>> agpgart apm25 apm42 apm6 cuad0.init >>> apm0 apm26 apm43 apm60 cuad0.lock >>> apm1 apm27 apm44 apm61 devctl >>> apm10 apm28 apm45 apm62 devstat >>> apm11 apm29 apm46 apm7 dri/ >>> >>> [...] >> What are you running that opens /dev/apm? Maybe powerd? >> >> I have a patch that handles reaping these devices, unfortunately it is >> pending completion of another patch that allows devfs_destroy() from a >> close() routine. That part is a core problem in FreeBSD, and it isn't >> really something in acpi. > > Yes, powerd is running. Do you need additional system info? No, I'm just going to work around this and re-test the patch before committing. -- Nate From owner-freebsd-arch@FreeBSD.ORG Fri Jun 22 02:14:15 2007 Return-Path: X-Original-To: arch@freebsd.org Delivered-To: freebsd-arch@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7508616A46B for ; Fri, 22 Jun 2007 02:14:15 +0000 (UTC) (envelope-from nate@root.org) Received: from root.org (root.org [67.118.192.226]) by mx1.freebsd.org (Postfix) with ESMTP id 5AC5813C45E for ; Fri, 22 Jun 2007 02:14:15 +0000 (UTC) (envelope-from nate@root.org) Received: (qmail 61038 invoked from network); 21 Jun 2007 23:26:31 -0000 Received: from ppp-71-139-42-13.dsl.snfc21.pacbell.net (HELO ?10.0.0.15?) (nate-mail@71.139.42.13) by root.org with ESMTPA; 21 Jun 2007 23:26:31 -0000 Message-ID: <467B091F.6070008@root.org> Date: Thu, 21 Jun 2007 16:26:23 -0700 From: Nate Lawson User-Agent: Thunderbird 2.0.0.0 (X11/20070511) MIME-Version: 1.0 To: Lars Engels References: <46756BBE.5030603@root.org> <20070621155044.GD17194@e.0x20.net> <467AA6C6.8090607@root.org> <20070621222836.GC16887@e.0x20.net> In-Reply-To: <20070621222836.GC16887@e.0x20.net> X-Enigmail-Version: 0.95.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: acpi@freebsd.org, arch@freebsd.org, current Subject: Re: patch: acpi usermode suspend API change X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2007 02:14:15 -0000 Lars Engels wrote: > On Thu, Jun 21, 2007 at 09:26:46AM -0700, Nate Lawson wrote: >> Lars Engels wrote: >>> Nate, >>> >>> thanks for your patch. >>> But after applying it on a recent -Current I get a lot of kernel messages >>> like these: >>> Jun 21 17:48:27 maggie kernel: apm34 opened clone 0xc457fd00 >>> Jun 21 17:48:27 maggie kernel: apm34 closed clone 0xc457fd00 >>> Jun 21 17:48:32 maggie kernel: apm35 opened clone 0xc457ee40 >>> Jun 21 17:48:32 maggie kernel: apm35 closed clone 0xc457ee40 >>> Jun 21 17:48:37 maggie kernel: apm36 opened clone 0xc457ec40 >>> Jun 21 17:48:37 maggie kernel: apm36 closed clone 0xc457ec40 >>> Jun 21 17:48:42 maggie kernel: apm37 opened clone 0xc457fc40 >>> Jun 21 17:48:42 maggie kernel: apm37 closed clone 0xc457fc40 >>> Jun 21 17:48:47 maggie kernel: apm38 opened clone 0xc433b6c0 >>> Jun 21 17:48:47 maggie kernel: apm38 closed clone 0xc433b6c0 >>> Jun 21 17:48:52 maggie kernel: apm39 opened clone 0xc433b240 >> Thanks for testing! Those were there to assist in debugging if people >> had any problems. >> >>> Additionally, pressing the power button only generates this: >>> Jun 21 17:50:03 maggie kernel: acpi: request to enter state S5 failed >>> >>> I need to run 'shutdown -p ' to power the system down. >> This was already fixed in the updated patch that I plan to commit today. >> It's attached or you can just wait for the commit to get it. > > Okay, I cannot test this today, so I will take your committed version > tomorrow. Patch has been committed, along with an addition to use a taskq to clean up the extra devices. You should find that all this works fine and /dev/apm is cleaned up. To upgrade, you should install the /etc/ scripts, acpiconf, and the acpi kernel module. Installworld/mergemaster take care of this. Old binaries of acpiconf will continue to work fine with just a message printed once on console that the old API is deprecated. -- Nate From owner-freebsd-arch@FreeBSD.ORG Fri Jun 22 08:58:53 2007 Return-Path: X-Original-To: arch@freebsd.org Delivered-To: freebsd-arch@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 92BE616A400; Fri, 22 Jun 2007 08:58:53 +0000 (UTC) (envelope-from avg@icyb.net.ua) Received: from gateway.cybervisiontech.com.ua (gateway.cybervisiontech.com.ua [88.81.251.18]) by mx1.freebsd.org (Postfix) with ESMTP id 45E9B13C483; Fri, 22 Jun 2007 08:58:53 +0000 (UTC) (envelope-from avg@icyb.net.ua) Received: from localhost (hq.cybervisiontech.com [127.0.0.1]) by gateway.cybervisiontech.com.ua (Postfix) with ESMTP id 8584BED5694; Fri, 22 Jun 2007 11:23:19 +0300 (EEST) X-Virus-Scanned: amavisd-new at cybervisiontech.com Received: from gateway.cybervisiontech.com.ua ([127.0.0.1]) by localhost (hq.cybervisiontech.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id v7w2G-ozdlq0; Fri, 22 Jun 2007 11:23:17 +0300 (EEST) Received: from [10.2.1.87] (rein.cybervisiontech.com.ua [10.2.1.87]) by gateway.cybervisiontech.com.ua (Postfix) with ESMTP id 0D177ED567D; Fri, 22 Jun 2007 11:23:17 +0300 (EEST) Message-ID: <467B8732.60503@icyb.net.ua> Date: Fri, 22 Jun 2007 11:24:18 +0300 From: Andriy Gapon User-Agent: Thunderbird 2.0.0.4 (X11/20070618) MIME-Version: 1.0 To: Ariff Abdullah References: <1182140582.00760687.1182127202@10.7.7.3> <1182453789.00762635.1182442802@10.7.7.3> <1182468188.00762718.1182456601@10.7.7.3> <1182482583.00762779.1182469202@10.7.7.3> In-Reply-To: <1182482583.00762779.1182469202@10.7.7.3> Content-Type: text/plain; charset=KOI8-U Content-Transfer-Encoding: 7bit Cc: arch@freebsd.org, lars.engels@0x20.net, Nate Lawson Subject: Re: patch: acpi usermode suspend API change X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2007 08:58:53 -0000 on 22/06/2007 02:33 Ariff Abdullah said the following: > Same issue with sound devices as well, but I've managed to solve it by > implementing own clone manager which require tiny hook into open() and > close() along with garbage collector and ability to handle various > abusive behaviour (while : ; ls /dev/xxx ; done, etc). See > sys/dev/sound/clone.* . It should be generic enough. Maybe I'll say something stupid - I haven't looked at any code nor I have any patches of my own, but wouldn't it be possible to manage cloned devices similarly to how file descriptors are managed ? That is, don't leave unused devices behind, re-use lowest available device id, etc. I think that this would be a right thing. -- Andriy Gapon From owner-freebsd-arch@FreeBSD.ORG Fri Jun 22 11:54:41 2007 Return-Path: X-Original-To: arch@freebsd.org Delivered-To: freebsd-arch@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7565016A46B for ; Fri, 22 Jun 2007 11:54:41 +0000 (UTC) (envelope-from grafan@gmail.com) Received: from py-out-1112.google.com (py-out-1112.google.com [64.233.166.178]) by mx1.freebsd.org (Postfix) with ESMTP id 37B3913C46A for ; Fri, 22 Jun 2007 11:54:41 +0000 (UTC) (envelope-from grafan@gmail.com) Received: by py-out-1112.google.com with SMTP id u77so271811pyb for ; Fri, 22 Jun 2007 04:54:40 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=N0kwyygtCe6QT1J0JADT51ue5m5DJLiGCBjNOp8MY29ByFFPfB0cHTiSbfebWL/IEc9Jt1eM5gfebQ9jviW67KWpO7zBihDaevX4KfcrUJWakFB8CpDIDyNCcoMzGgRYdBUDyX6stsfhlrKswYe//LqU8yqtH21epf3WeNqq3V8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=GcG64Q42Dk5BU4c4HYrIvnWBE7aeHmDgZLGkY8wWHjWSlRWrix9zMdnnSy/6PimUAIAiKcc7ZVU8dDaWXElAccsxZ4bhFELCEV80Pz/MtWsZpniyFxSJFXLLbrqFoqaGj4QL84itz83IuBMGvcFUJyCFYS/VJh1+Qkpp70RZkv4= Received: by 10.65.150.18 with SMTP id c18mr5473216qbo.1182513280521; Fri, 22 Jun 2007 04:54:40 -0700 (PDT) Received: by 10.64.196.20 with HTTP; Fri, 22 Jun 2007 04:54:40 -0700 (PDT) Message-ID: <6eb82e0706220454l71d81004ka4422abca895c171@mail.gmail.com> Date: Fri, 22 Jun 2007 19:54:40 +0800 From: "Rong-en Fan" To: arch@freebsd.org In-Reply-To: <20070621174224.GA97487@rink.nu> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <6eb82e0706210958u72559a19ha5135806b115c939@mail.gmail.com> <20070621174224.GA97487@rink.nu> Cc: rink@freebsd.org, delphij@freebsd.org Subject: Re: RFC: remove UMAPFS X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2007 11:54:41 -0000 On 6/22/07, Rink Springer wrote: > Hi Rong-en, > > On Fri, Jun 22, 2007 at 12:58:17AM +0800, Rong-en Fan wrote: > > The UMAPFS was disconnected from build 3 years ago. > > It is seriously broken and no one is going to work on it. > > Therefore, I think we should remove UMAPFS from > > cvs and put in in Attic. Any objections? > > None from me. If someone really cares about it, they are always welcome > to bring it back from the dead. So, here is the patch http://people.freebsd.org/~rafan/remove-umapfs.diff If no one objects, I'm going to commit it later this weekend. Regards, Rong-En Fan From owner-freebsd-arch@FreeBSD.ORG Fri Jun 22 19:36:01 2007 Return-Path: X-Original-To: arch@freebsd.org Delivered-To: freebsd-arch@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DA28D16A469 for ; Fri, 22 Jun 2007 19:36:01 +0000 (UTC) (envelope-from nate@root.org) Received: from root.org (root.org [67.118.192.226]) by mx1.freebsd.org (Postfix) with ESMTP id A977C13C45E for ; Fri, 22 Jun 2007 19:36:01 +0000 (UTC) (envelope-from nate@root.org) Received: (qmail 54454 invoked from network); 22 Jun 2007 15:20:05 -0000 Received: from ppp-71-139-42-13.dsl.snfc21.pacbell.net (HELO ?10.0.0.15?) (nate-mail@71.139.42.13) by root.org with ESMTPA; 22 Jun 2007 15:20:05 -0000 Message-ID: <467BE89F.9090302@root.org> Date: Fri, 22 Jun 2007 08:19:59 -0700 From: Nate Lawson User-Agent: Thunderbird 2.0.0.0 (X11/20070511) MIME-Version: 1.0 To: Andriy Gapon References: <1182140582.00760687.1182127202@10.7.7.3> <1182453789.00762635.1182442802@10.7.7.3> <1182468188.00762718.1182456601@10.7.7.3> <1182482583.00762779.1182469202@10.7.7.3> <467B8732.60503@icyb.net.ua> In-Reply-To: <467B8732.60503@icyb.net.ua> X-Enigmail-Version: 0.95.0 Content-Type: text/plain; charset=KOI8-U Content-Transfer-Encoding: 7bit Cc: arch@freebsd.org, lars.engels@0x20.net, Ariff Abdullah Subject: Re: patch: acpi usermode suspend API change X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2007 19:36:01 -0000 Andriy Gapon wrote: > on 22/06/2007 02:33 Ariff Abdullah said the following: >> Same issue with sound devices as well, but I've managed to solve it by >> implementing own clone manager which require tiny hook into open() and >> close() along with garbage collector and ability to handle various >> abusive behaviour (while : ; ls /dev/xxx ; done, etc). See >> sys/dev/sound/clone.* . It should be generic enough. > > Maybe I'll say something stupid - I haven't looked at any code nor I > have any patches of my own, but wouldn't it be possible to manage cloned > devices similarly to how file descriptors are managed ? That is, don't > leave unused devices behind, re-use lowest available device id, etc. > I think that this would be a right thing. There are still resource exhaustion issues with that simple approach. Since each copy of my device is single-open, I can refuse the 2nd and future processes that try to open the same device. -- Nate From owner-freebsd-arch@FreeBSD.ORG Fri Jun 22 21:23:44 2007 Return-Path: X-Original-To: arch@freebsd.org Delivered-To: freebsd-arch@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id EA95116A41F; Fri, 22 Jun 2007 21:23:44 +0000 (UTC) (envelope-from lars@e.0x20.net) Received: from mail.0x20.net (mail.0x20.net [217.69.67.217]) by mx1.freebsd.org (Postfix) with ESMTP id ADB3713C447; Fri, 22 Jun 2007 21:23:44 +0000 (UTC) (envelope-from lars@e.0x20.net) Received: by mail.0x20.net (Postfix, from userid 1002) id 1891639E2C; Fri, 22 Jun 2007 23:23:43 +0200 (CEST) Date: Fri, 22 Jun 2007 23:23:43 +0200 From: Lars Engels To: Nate Lawson Message-ID: <20070622212342.GG16887@e.0x20.net> References: <46756BBE.5030603@root.org> <20070621155330.GE17194@e.0x20.net> <467AA768.60306@root.org> <20070621222603.GB16887@e.0x20.net> <467AFBA5.6040309@root.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="SNIs70sCzqvszXB4" Content-Disposition: inline In-Reply-To: <467AFBA5.6040309@root.org> X-Editor: VIM - Vi IMproved 7.0 X-Operation-System: FreeBSD 5.5-RELEASE User-Agent: mutt-ng/devel-r804 (FreeBSD) Cc: acpi@freebsd.org, arch@freebsd.org, current Subject: Re: patch: acpi usermode suspend API change X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2007 21:23:45 -0000 --SNIs70sCzqvszXB4 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jun 21, 2007 at 03:28:53PM -0700, Nate Lawson wrote: > Lars Engels wrote: > > On Thu, Jun 21, 2007 at 09:29:28AM -0700, Nate Lawson wrote: > >> Lars Engels wrote: > >>> And I just saw that every 5 second a new apm device is created!=20 > >>> > >>> # ls /dev > >>> acd0 apm12 apm3 apm47 apm8 = =20 > >>> acpi apm13 apm30 apm48 apm9 = =20 > >>> ad0 apm14 apm31 apm49 ata = =20 > >>> ad0.journal apm15 apm32 apm5 atkbd= 0 =20 > >>> ad0.journals1 apm16 apm33 apm50 bpf0 = =20 > >>> ad0.journals2 apm17 apm34 apm51 bpf1 = =20 > >>> ad0.journals3 apm18 apm35 apm52 bpsm0= =20 > >>> ad0.journals4 apm19 apm36 apm53 cardb= us0.cis > >>> ad0.journals4a apm2 apm37 apm54 cd0 = =20 > >>> ad0.journals4b apm20 apm38 apm55 cdrom= @ =20 > >>> ad0.journals4c apm21 apm39 apm56 conso= le =20 > >>> ad0.journals4d apm22 apm4 apm57 conso= lectl =20 > >>> ad0.journals4e apm23 apm40 apm58 ctty = =20 > >>> ad0.journals4f apm24 apm41 apm59 cuad0= =20 > >>> agpgart apm25 apm42 apm6 cuad0= =2Einit =20 > >>> apm0 apm26 apm43 apm60 cuad0= =2Elock =20 > >>> apm1 apm27 apm44 apm61 devct= l =20 > >>> apm10 apm28 apm45 apm62 devst= at =20 > >>> apm11 apm29 apm46 apm7 dri/ = =20 > >>> > >>> [...] > >> What are you running that opens /dev/apm? Maybe powerd? > >> > >> I have a patch that handles reaping these devices, unfortunately it is > >> pending completion of another patch that allows devfs_destroy() from a > >> close() routine. That part is a core problem in FreeBSD, and it isn't > >> really something in acpi. > >=20 > > Yes, powerd is running. Do you need additional system info? >=20 > No, I'm just going to work around this and re-test the patch before > committing. With your committed code, everything is working fine now. The power button sets the system to S5, no apm[0-9] devices, and no more apm cloning messages on the console. Thanks, Nate!=20 Lars --SNIs70sCzqvszXB4 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (FreeBSD) iD8DBQFGfD3eKc512sD3afgRAlRaAJ9a9HFAx1Di5ZEW3abHAJz4w7cbmACgj91P +nkhx/g5uODHG6esuyWGtMk= =OHC2 -----END PGP SIGNATURE----- --SNIs70sCzqvszXB4--