📄 acpi-debug.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta name="generator" content="HTML Tidy, see www.w3.org" /><title>Using and Debugging FreeBSD ACPI</title><meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.7" /><link rel="HOME" title="FreeBSD Handbook" href="index.html" /><link rel="UP" title="Configuration and Tuning" href="config-tuning.html" /><link rel="PREVIOUS" title="Power and Resource Management" href="acpi-overview.html" /><link rel="NEXT" title="The FreeBSD Booting Process" href="boot.html" /><link rel="STYLESHEET" type="text/css" href="docbook.css" /></head><body class="SECT1" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#840084"alink="#0000FF"><div class="NAVHEADER"><table summary="Header navigation table" width="100%" border="0" cellpadding="0"cellspacing="0"><tr><th colspan="3" align="center">FreeBSD Handbook</th></tr><tr><td width="10%" align="left" valign="bottom"><a href="acpi-overview.html"accesskey="P">Prev</a></td><td width="80%" align="center" valign="bottom">Chapter 11 Configuration and Tuning</td><td width="10%" align="right" valign="bottom"><a href="boot.html"accesskey="N">Next</a></td></tr></table><hr align="LEFT" width="100%" /></div><div class="SECT1"><h1 class="SECT1"><a id="ACPI-DEBUG" name="ACPI-DEBUG">11.16 Using and Debugging FreeBSD<acronym class="ACRONYM">ACPI</acronym></a></h1><i class="AUTHORGROUP"><span class="CONTRIB">Written by</span> Nate Lawson.</i> <iclass="AUTHORGROUP"><span class="CONTRIB">With contributions from</span> Peter Schultzand Tom Rhodes.</i> <p><acronym class="ACRONYM">ACPI</acronym> is a fundamentally new way of discoveringdevices, managing power usage, and providing standardized access to various hardwarepreviously managed by the <acronym class="ACRONYM">BIOS</acronym>. Progress is being madetoward <acronym class="ACRONYM">ACPI</acronym> working on all systems, but bugs in somemotherboards' <i class="FIRSTTERM"><acronym class="ACRONYM">ACPI</acronym> MachineLanguage</i> (<acronym class="ACRONYM">AML</acronym>) bytecode, incompleteness inFreeBSD's kernel subsystems, and bugs in the <span class="TRADEMARK">Intel</span>®<acronym class="ACRONYM">ACPI-CA</acronym> interpreter continue to appear.</p><p>This document is intended to help you assist the FreeBSD <acronymclass="ACRONYM">ACPI</acronym> maintainers in identifying the root cause of problems youobserve and debugging and developing a solution. Thanks for reading this and we hope wecan solve your system's problems.</p><div class="SECT2"><h2 class="SECT2"><a id="ACPI-SUBMITDEBUG" name="ACPI-SUBMITDEBUG">11.16.1 SubmittingDebugging Information</a></h2><div class="NOTE"><blockquote class="NOTE"><p><b>Note:</b> Before submitting a problem, be sure you are running the latest <acronymclass="ACRONYM">BIOS</acronym> version and, if available, embedded controller firmwareversion.</p></blockquote></div><p>For those of you that want to submit a problem right away, please send the followinginformation to <a href="mailto:freebsd-acpi@FreeBSD.org"target="_top">freebsd-acpi@FreeBSD.org</a>:</p><ul><li><p>Description of the buggy behavior, including system type and model and anything thatcauses the bug to appear. Also, please note as accurately as possible when the bug beganoccurring if it is new for you.</p></li><li><p>The <a href="http://www.FreeBSD.org/cgi/man.cgi?query=dmesg&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">dmesg</span>(8)</span></a> output after``boot <var class="OPTION">-v</var>'', including any error messages generated by youexercising the bug.</p></li><li><p>The <a href="http://www.FreeBSD.org/cgi/man.cgi?query=dmesg&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">dmesg</span>(8)</span></a> output from``boot <var class="OPTION">-v</var>'' with <acronym class="ACRONYM">ACPI</acronym>disabled, if disabling it helps fix the problem.</p></li><li><p>Output from ``sysctl hw.acpi''. This is also a good way of figuring out what featuresyour system offers.</p></li><li><p><acronym class="ACRONYM">URL</acronym> where your <i class="FIRSTTERM"><acronymclass="ACRONYM">ACPI</acronym> Source Language</i> (<acronymclass="ACRONYM">ASL</acronym>) can be found. Do <span class="emphasis"><iclass="EMPHASIS">not</i></span> send the <acronym class="ACRONYM">ASL</acronym> directlyto the list as it can be very large. Generate a copy of your <acronymclass="ACRONYM">ASL</acronym> by running this command:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">acpidump -t -d > <varclass="REPLACEABLE">name</var>-<var class="REPLACEABLE">system</var>.asl</kbd></pre><p>(Substitute your login name for <var class="REPLACEABLE">name</var> andmanufacturer/model for <var class="REPLACEABLE">system</var>. Example: <ttclass="FILENAME">njl-FooCo6000.asl</tt>)</p></li></ul><p>Most of the developers watch the <ahref="http://lists.FreeBSD.org/mailman/listinfo/freebsd-current"target="_top">FreeBSD-CURRENT mailing list</a> but please submit problems to <ahref="http://lists.FreeBSD.org/mailman/listinfo/freebsd-acpi"target="_top">freebsd-acpi</a> to be sure it is seen. Please be patient, all of us havefull-time jobs elsewhere. If your bug is not immediately apparent, we will probably askyou to submit a <acronym class="ACRONYM">PR</acronym> via <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=send-pr&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">send-pr</span>(1)</span></a>. Whenentering a <acronym class="ACRONYM">PR</acronym>, please include the same information asrequested above. This will help us track the problem and resolve it. Do not send a<acronym class="ACRONYM">PR</acronym> without emailing <ahref="http://lists.FreeBSD.org/mailman/listinfo/freebsd-acpi"target="_top">freebsd-acpi</a> first as we use <acronym class="ACRONYM">PR</acronym>s asreminders of existing problems, not a reporting mechanism. It is likely that your problemhas been reported by someone before.</p></div><div class="SECT2"><h2 class="SECT2"><a id="ACPI-BACKGROUND" name="ACPI-BACKGROUND">11.16.2Background</a></h2><p><acronym class="ACRONYM">ACPI</acronym> is present in all modern computers thatconform to the ia32 (x86), ia64 (Itanium), and amd64 (AMD) architectures. The fullstandard has many features including <acronym class="ACRONYM">CPU</acronym> performancemanagement, power planes control, thermal zones, various battery systems, embeddedcontrollers, and bus enumeration. Most systems implement less than the full standard. Forinstance, a desktop system usually only implements the bus enumeration parts while alaptop might have cooling and battery management support as well. Laptops also havesuspend and resume, with their own associated complexity.</p><p>An <acronym class="ACRONYM">ACPI</acronym>-compliant system has various components.The <acronym class="ACRONYM">BIOS</acronym> and chipset vendors provide various fixedtables (e.g., <acronym class="ACRONYM">FADT</acronym>) in memory that specify things likethe <acronym class="ACRONYM">APIC</acronym> map (used for <acronymclass="ACRONYM">SMP</acronym>), config registers, and simple configuration values.Additionally, a table of bytecode (the <i class="FIRSTTERM">Differentiated SystemDescription Table</i> <acronym class="ACRONYM">DSDT</acronym>) is provided that specifiesa tree-like name space of devices and methods.</p><p>The <acronym class="ACRONYM">ACPI</acronym> driver must parse the fixed tables,implement an interpreter for the bytecode, and modify device drivers and the kernel toaccept information from the <acronym class="ACRONYM">ACPI</acronym> subsystem. ForFreeBSD, <span class="TRADEMARK">Intel</span> has provided an interpreter (<acronymclass="ACRONYM">ACPI-CA</acronym>) that is shared with Linux and NetBSD. The path to the<acronym class="ACRONYM">ACPI-CA</acronym> source code is <ttclass="FILENAME">src/sys/contrib/dev/acpica</tt>. The glue code that allows <acronymclass="ACRONYM">ACPI-CA</acronym> to work on FreeBSD is in <ttclass="FILENAME">src/sys/dev/acpica/Osd</tt>. Finally, drivers that implement various<acronym class="ACRONYM">ACPI</acronym> devices are found in <ttclass="FILENAME">src/sys/dev/acpica</tt>.</p></div><div class="SECT2"><h2 class="SECT2"><a id="ACPI-COMPROB" name="ACPI-COMPROB">11.16.3 CommonProblems</a></h2><p>For <acronym class="ACRONYM">ACPI</acronym> to work correctly, all the parts have towork correctly. Here are some common problems, in order of frequency of appearance, andsome possible workarounds or fixes.</p><div class="SECT3"><h3 class="SECT3"><a id="AEN17104" name="AEN17104">11.16.3.1 Suspend/Resume</a></h3><p><acronym class="ACRONYM">ACPI</acronym> has three suspend to <acronymclass="ACRONYM">RAM</acronym> (<acronym class="ACRONYM">STR</acronym>) states, <varclass="LITERAL">S1</var>-<var class="LITERAL">S3</var>, and one suspend to disk state(<var class="LITERAL">STD</var>), called <var class="LITERAL">S4</var>. <varclass="LITERAL">S5</var> is ``soft off'' and is the normal state your system is in whenplugged in but not powered up. <var class="LITERAL">S4</var> can actually be implementedtwo separate ways. <var class="LITERAL">S4</var><acronym class="ACRONYM">BIOS</acronym>is a <acronym class="ACRONYM">BIOS</acronym>-assisted suspend to disk. <varclass="LITERAL">S4</var><acronym class="ACRONYM">OS</acronym> is implemented entirely bythe operating system.</p><p>Start by checking <tt class="COMMAND">sysctl</tt> <var class="OPTION">hw.acpi</var>for the suspend-related items. Here are the results for my Thinkpad:</p><pre class="SCREEN">hw.acpi.supported_sleep_state: S3 S4 S5</pre><pre class="SCREEN">hw.acpi.s4bios: 0</pre><p>This means that I can use <tt class="COMMAND">acpiconf -s</tt> to test <varclass="LITERAL">S3</var>, <var class="LITERAL">S4</var><acronymclass="ACRONYM">OS</acronym>, and <var class="LITERAL">S5</var>. If <varclass="OPTION">s4bios</var> was one (<var class="LITERAL">1</var>), I would have <varclass="LITERAL">S4</var><acronym class="ACRONYM">BIOS</acronym> support instead of <varclass="LITERAL">S4</var> <acronym class="ACRONYM">OS</acronym>.</p><p>When testing suspend/resume, start with <var class="LITERAL">S1</var>, if supported.This state is most likely to work since it doesn't require much driver support. No onehas implemented <var class="LITERAL">S2</var> but if you have it, it's similar to <varclass="LITERAL">S1</var>. The next thing to try is <var class="LITERAL">S3</var>. This isthe deepest <acronym class="ACRONYM">STR</acronym> state and requires a lot of driversupport to properly reinitialize your hardware. If you have problems resuming, feel freeto email the <a href="http://lists.FreeBSD.org/mailman/listinfo/freebsd-acpi"target="_top">freebsd-acpi</a> list but do not expect the problem to be resolved sincethere are a lot of drivers/hardware that need more testing and work.</p><p>To help isolate the problem, remove as many drivers from your kernel as possible. Ifit works, you can narrow down which driver is the problem by loading drivers until itfails again. Typically binary drivers like <tt class="FILENAME">nvidia.ko</tt>, <bclass="APPLICATION">X11</b> display drivers, and <acronym class="ACRONYM">USB</acronym>will have the most problems while Ethernet interfaces usually work fine. If you canload/unload the drivers ok, you can automate this by putting the appropriate commands in<tt class="FILENAME">/etc/rc.suspend</tt> and <tt class="FILENAME">/etc/rc.resume</tt>.There is a commented-out example for unloading and loading a driver. Try setting <varclass="OPTION">hw.acpi.reset_video</var> to zero (0) if your display is messed up afterresume. Try setting longer or shorter values for <varclass="OPTION">hw.acpi.sleep_delay</var> to see if that helps.</p><p>Another thing to try is load a recent Linux distribution with <acronymclass="ACRONYM">ACPI</acronym> support and test their suspend/resume support on the samehardware. If it works on Linux, it's likely a FreeBSD driver problem and narrowing downwhich driver causes the problems will help us fix the problem. Note that the <acronymclass="ACRONYM">ACPI</acronym> maintainers do not usually maintain other drivers (e.gsound, <acronym class="ACRONYM">ATA</acronym>, etc.) so any work done on tracking down adriver problem should probably eventually be posted to the <ahref="http://lists.FreeBSD.org/mailman/listinfo/freebsd-current"target="_top">freebsd-current</a> list and mailed to the driver maintainer. If you arefeeling adventurous, go ahead and start putting some debugging <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=printf&sektion=3"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">printf</span>(3)</span></a>s in aproblematic driver to track down where in its resume function it hangs.</p><p>Finally, try disabling <acronym class="ACRONYM">ACPI</acronym> and enabling <acronymclass="ACRONYM">APM</acronym> instead. If suspend/resume works with <acronymclass="ACRONYM">APM</acronym>, you may be better off sticking with <acronymclass="ACRONYM">APM</acronym>, especially on older hardware (pre-2000). It took vendors awhile to get <acronym class="ACRONYM">ACPI</acronym> support correct and older hardwareis more likely to have <acronym class="ACRONYM">BIOS</acronym> problems with <acronymclass="ACRONYM">ACPI</acronym>.</p></div><div class="SECT3"><h3 class="SECT3"><a id="AEN17170" name="AEN17170">11.16.3.2 System Hangs (temporary orpermanent)</a></h3><p>Most system hangs are a result of lost interrupts or an interrupt storm. Chipsets havea lot of problems based on how the <acronym class="ACRONYM">BIOS</acronym> configuresinterrupts before boot, correctness of the <acronym class="ACRONYM">APIC</acronym>(<acronym class="ACRONYM">MADT</acronym>) table, and routing of the <iclass="FIRSTTERM">System Control Interrupt</i> (<acronymclass="ACRONYM">SCI</acronym>).</p><p>Interrupt storms can be distinguished from lost interrupts by checking the output of<tt class="COMMAND">vmstat -i</tt> and looking at the line that has <varclass="LITERAL">acpi0</var>. If the counter is increasing at more than a couple persecond, you have an interrupt storm. If the system appears hung, try breaking to <acronymclass="ACRONYM">DDB</acronym> (<b class="KEYCAP">CTRL</b>+<b class="KEYCAP">ALT</b>+<bclass="KEYCAP">ESC</b> on console) and type <var class="OPTION">showinterrupts</var>.</p><p>Your best hope when dealing with interrupt problems is to try disabling <acronymclass="ACRONYM">APIC</acronym> support with <varclass="LITERAL">hint.apic.0.disabled="1"</var> in <ttclass="FILENAME">loader.conf</tt>.</p></div><div class="SECT3"><h3 class="SECT3"><a id="AEN17191" name="AEN17191">11.16.3.3 Panics</a></h3><p>Panics are relatively rare for <acronym class="ACRONYM">ACPI</acronym> and are the toppriority to be fixed. The first step is to isolate the steps to reproduce the panic (ifpossible) and get a backtrace. Follow the advice for enabling <var class="OPTION">optionsDDB</var> and setting up a serial console (see <ahref="serialconsole-setup.html#SERIALCONSOLE-DDB">Section 20.6.5.3</a>) or setting up a<a href="http://www.FreeBSD.org/cgi/man.cgi?query=dump&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">dump</span>(8)</span></a> partition. Youcan get a backtrace in <acronym class="ACRONYM">DDB</acronym> with <varclass="OPTION">tr</var>. If you have to handwrite the backtrace, be sure to at least get
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -