Date: Thu, 30 Nov 2000 10:53:29 +0100 From: "Jose M. Alcaide" <jose@we.lc.ehu.es> To: vladimir@math.uic.edu Cc: freebsd-stable@FreeBSD.ORG Subject: Re: Dell laptop and APM Message-ID: <3A262399.B37E9143@we.lc.ehu.es> References: <20001130045229.26450.qmail@math.uic.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------CD66A4288BC817CE5D58A36D
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
vladimir@math.uic.edu wrote:
>
> I just bought a Dell-Latitude laptop. I have problems with APM on that
> machine. Whe I type 'zzz', the monitor becomes black, then the screen
> comes on again. The logs say:
>
> Nov 29 19:18:40 d50-38c9 /kernel: resumed from suspended mode (slept 00:00:00)
> Nov 29 19:18:40 d50-38c9 /kernel: ata0: resetting devices .. done
>
> APM is enabled in the kernel:
> device apm0 at nexus? flags 0x0020 # Advanced Power Management
> (I've also tried
> device apm0 at nexus? flags 0x20 # Advanced Power Management
> ).
>
Apply the patchset attached, rebuild the kernel and please tell me
if your problem goes away or not. The patches apply cleanly on 4.2-RELEASE
and 4.2-STABLE, and they also should apply to 4.1-R and 4.1.1-R.
In addition, your /etc/rc.conf should define
apm_enable="YES"
apmd_enable="YES"
Cheers,
-- JMA
****** Jose M. Alcaide // jose@we.lc.ehu.es // jmas@FreeBSD.org ******
** "Beware of Programmers who carry screwdrivers" -- Leonard Brandwein **
--------------CD66A4288BC817CE5D58A36D
Content-Type: text/plain; charset=us-ascii;
name="statclock.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="statclock.patch"
--- sys/i386/isa/clock.c.orig Tue Jan 4 23:24:59 2000
+++ sys/i386/isa/clock.c Thu May 25 23:23:57 2000
@@ -132,7 +132,6 @@
int clkintr_pending;
int disable_rtc_set; /* disable resettodr() if != 0 */
volatile u_int idelayed;
-int statclock_disable;
u_int stat_imask = SWI_CLOCK_MASK;
#ifndef TIMER_FREQ
#define TIMER_FREQ 1193182
@@ -828,6 +827,27 @@
}
/*
+ * The following two functions are called from apm.c for stopping and
+ * restarting the statclock interrupts from the RTC, if the apm's
+ * broken_statclock flag is set (some laptops don't enter suspend mode
+ * while the RTC is generating interrupts).
+ */
+void
+statclock_stop(void)
+{
+ /* disable RTC interrupts and clear any pending one */
+ writertc(RTC_STATUSB, RTCSB_24HR);
+ rtcin(RTC_INTR);
+}
+
+void
+statclock_restart(void)
+{
+ /* re-enable the RTC interrupts */
+ writertc(RTC_STATUSB, rtc_statusb);
+}
+
+/*
* Initialize the time of day register, based on the time base which is, e.g.
* from a filesystem.
*/
@@ -975,20 +995,9 @@
struct intrec *clkdesc;
#endif /* APIC_IO */
- if (statclock_disable) {
- /*
- * The stat interrupt mask is different without the
- * statistics clock. Also, don't set the interrupt
- * flag which would normally cause the RTC to generate
- * interrupts.
- */
- stat_imask = HWI_MASK | SWI_MASK;
- rtc_statusb = RTCSB_24HR;
- } else {
- /* Setting stathz to nonzero early helps avoid races. */
- stathz = RTC_NOPROFRATE;
- profhz = RTC_PROFRATE;
- }
+ /* Setting stathz to nonzero early helps avoid races. */
+ stathz = RTC_NOPROFRATE;
+ profhz = RTC_PROFRATE;
/* Finish initializing 8253 timer 0. */
#ifdef APIC_IO
@@ -1022,10 +1031,8 @@
/* Initialize RTC. */
writertc(RTC_STATUSA, rtc_statusa);
writertc(RTC_STATUSB, RTCSB_24HR);
+ rtcin(RTC_INTR); /* clear any pending interrupt */
- /* Don't bother enabling the statistics clock. */
- if (statclock_disable)
- return;
diag = rtcin(RTC_DIAG);
if (diag != 0)
printf("RTC BIOS diagnostic error %b\n", diag, RTCDG_BITS);
--- sys/i386/include/clock.h.orig Wed Dec 29 05:32:58 1999
+++ sys/i386/include/clock.h Thu May 25 23:26:45 2000
@@ -16,7 +16,6 @@
*/
extern int adjkerntz;
extern int disable_rtc_set;
-extern int statclock_disable;
extern u_int timer_freq;
extern int timer0_max_count;
extern u_int tsc_freq;
@@ -45,6 +44,8 @@
#endif
int sysbeep __P((int pitch, int period));
void i8254_restore __P((void));
+void statclock_stop __P((void));
+void statclock_restart __P((void));
#endif /* _KERNEL */
--- sys/i386/apm/apm.c.orig Sun Feb 6 15:57:05 2000
+++ sys/i386/apm/apm.c Thu May 25 23:39:03 2000
@@ -101,6 +101,8 @@
/* bmaj */ -1
};
+static int broken_statclock = 0;
+
static int apm_suspend_delay = 1;
static int apm_standby_delay = 1;
@@ -404,6 +406,8 @@
/* modified for adjkerntz */
pl = splsoftclock();
+ if (broken_statclock) /* restart statclock if broken */
+ statclock_restart();
i8254_restore(); /* restore timer_freq and hz */
inittodr(0); /* adjust time to RTC */
microtime(&resume_time);
@@ -450,6 +454,8 @@
inittodr(0);
microtime(&suspend_time);
timevalsub(&diff_time, &suspend_time);
+ if (broken_statclock) /* stop statclock if broken */
+ statclock_stop();
splx(pl);
return 0;
}
@@ -1003,7 +1009,7 @@
flags = 0;
if (flags & 0x20)
- statclock_disable = 1;
+ broken_statclock = 1;
sc->initialized = 0;
--------------CD66A4288BC817CE5D58A36D--
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3A262399.B37E9143>
