Commit Graph

944 Commits

Author SHA1 Message Date
Jung-uk Kim
709fac0616 Merge ACPICA 20100806. 2010-08-06 23:11:19 +00:00
John Baldwin
7d23a9b3d5 - Retire acpi_pcib_resume(). It is has just been an alias for
bus_generic_resume() since the pci_link(4) driver was added.
- Change the ACPI PCI-PCI bridge driver to inherit most of its methods
  from the generic PCI-PCI bridge driver.  In particular, this will now
  restore PCI config registers for ACPI PCI-PCI bridges.

Tested by:	Oleg Sharoyko  osharoiko of gmail
2010-08-05 16:10:12 +00:00
Alexander Motin
599cf0f197 Fix several un-/signedness bugs of r210290 and r210293. Add one more check. 2010-07-20 15:48:29 +00:00
Alexander Motin
51636352b6 Extend timer driver API to report also minimal and maximal supported period
lengths. Make MI wrapper code to validate periods in request. Make kernel
clock management code to honor these hardware limitations while choosing hz,
stathz and profhz values.
2010-07-20 10:58:56 +00:00
Jung-uk Kim
69496408a5 Simplify AcpiOsReadPort() and AcpiOsWritePort() with iodev_read_*() and
iodev_write_*().  This removes unnecessary uses of temporary macros as well.
There is no functional change after this (verified with md5(1) on amd64).
2010-07-16 04:27:38 +00:00
Jung-uk Kim
aa353b1b6b Use pmap_mapdev()/pmap_unmapdev() to map device memory instead of using
AcpiOsMapMemory()/AcpiOsUnmapMemory() (-> pmap_mapbios()/pmap_unmapbios())
for AcpiOsReadMemory() and AcpiOsWriteMemory().  Although they do not sound
too obvious, these functions are exclusively used to access memory mapped
IO in ACPICA.
2010-07-16 03:59:50 +00:00
Jung-uk Kim
337744d9a6 If there is any pending sleep request, disallow entering S5 state.
Otherwise, bad things may happen. ;-)
2010-07-15 23:24:06 +00:00
Jung-uk Kim
6e7661023a - AcpiOsReadPciConfiguration() needs similar fixes as r209965 and r210129.
According to ACPICA User Guide and Programmer Reference, the read data must
be zero extended to fill the 64-bit return value even if the bit width of
the location is less than 64.
- Return error when 64-bit access is requested as we do not support 64-bit
PCI register access (yet).  XXX We may have to split it up into two 32-bit
accesses if it is really required.
2010-07-15 19:52:54 +00:00
Jung-uk Kim
89339b38d8 - AcpiOsReadMemory() needs similar fixes as r209965. [1]
According to ACPICA User Guide and Programmer Reference, the read data must
be zero extended to fill the 32-bit return value even if the bit width of
the port is less than 32.
- Remove 64-bit read/write from AcpiOsReadMemory() and AcpiOsWriteMemory().
These functions do not support 64-bit access (yet).  Clean up style nits
and unnecessary bit masking while I am here.

Reported by:	Liu, Jinsong (jinsong dot liu at intel dot com) via
		Lin Ming (ming dot m dot lin at intel dot com) [1]
2010-07-15 17:11:49 +00:00
Jung-uk Kim
36a483bbcd Make SMP code path conditional at run-time. 2010-07-13 16:35:41 +00:00
Alexander Motin
8a6870808d Rise knowledge about curthread->td_intr_frame by one step. Make timer
callback argument really opaque. Not repeat interrupt handler's problem
in case somebody will ever need to have both argument and frame.
2010-07-13 12:46:06 +00:00
Jung-uk Kim
31bc79db46 Fix white spaces. 2010-07-13 02:48:42 +00:00
Jung-uk Kim
502e578cde According to ACPICA User Guide and Programmer Reference, the read data must
be zero extended to fill the 32-bit return value even if the bit width of
the port is less than 32.
2010-07-13 02:45:44 +00:00
Jung-uk Kim
3664686221 Fix mis-merges in the previous commit. 2010-07-06 21:41:08 +00:00
Jung-uk Kim
a88e22b7ad Merge ACPICA 20100702. 2010-07-06 20:57:28 +00:00
Alexander Motin
49ed68bbf3 Add "legacy route" support to HPET driver. When enabled, this mode makes
HPET to steal IRQ0 from i8254 and IRQ8 from RTC timers. It can be suitable
for HPETs without FSB interrupts support, as it gives them two unshared
IRQs. It allows them to provide one per-CPU event timer on dual-CPU system,
that should be suitable for further tickless kernels.

To enable it, such lines may be added to /boot/loader.conf:
hint.atrtc.0.clock=0
hint.attimer.0.clock=0
hint.hpet.0.legacy_route=1
2010-06-22 19:42:27 +00:00
Alexander Motin
e723056a58 Do not set level-triggered interrupt mode if we are not going to use it.
This fixes QEMU crash due to unsupported level-triggered HPET interrupts.

Reported by:	kib@
2010-06-22 16:10:48 +00:00
Alexander Motin
7ea5021353 Fix ia64 build broken by r209371.
ia64, same as amd64 has ACPI and always has APIC.

Submitted by:	jhb@
2010-06-21 20:27:32 +00:00
Alexander Motin
875b8844be Implement new event timers infrastructure. It provides unified APIs for
writing event timer drivers, for choosing best possible drivers by machine
independent code and for operating them to supply kernel with hardclock(),
statclock() and profclock() events in unified fashion on various hardware.

Infrastructure provides support for both per-CPU (independent for every CPU
core) and global timers in periodic and one-shot modes. MI management code
at this moment uses only periodic mode, but one-shot mode use planned for
later, as part of tickless kernel project.

For this moment infrastructure used on i386 and amd64 architectures. Other
archs are welcome to follow, while their current operation should not be
affected.

This patch updates existing drivers (i8254, RTC and LAPIC) for the new
order, and adds event timers support into the HPET driver. These drivers
have different capabilities:
 LAPIC - per-CPU timer, supports periodic and one-shot operation, may
freeze in C3 state, calibrated on first use, so may be not exactly precise.
 HPET - depending on hardware can work as per-CPU or global, supports
periodic and one-shot operation, usually provides several event timers.
 i8254 - global, limited to periodic mode, because same hardware used also
as time counter.
 RTC - global, supports only periodic mode, set of frequencies in Hz
limited by powers of 2.

Depending on hardware capabilities, drivers preferred in following orders,
either LAPIC, HPETs, i8254, RTC or HPETs, LAPIC, i8254, RTC.
User may explicitly specify wanted timers via loader tunables or sysctls:
kern.eventtimer.timer1 and kern.eventtimer.timer2.
If requested driver is unavailable or unoperational, system will try to
replace it. If no more timers available or "NONE" specified for second,
system will operate using only one timer, multiplying it's frequency by few
times and uing respective dividers to honor hz, stathz and profhz values,
set during initial setup.
2010-06-20 21:33:29 +00:00
Alexander Motin
3a18e1b6d7 Oops! Add " / hz" missed in r209328. Assume interrupt rate hz/2, not 1/2. 2010-06-19 08:46:17 +00:00
Alexander Motin
7150e67191 While we indeed can't precisely measure time spent in C1, we can consider
measured interval as upper bound. It should be more precise then just
assuming hz/2. For idle CPU it should be quite precise, for busy - not
worse then before.
2010-06-19 08:36:12 +00:00
John Baldwin
42040ff081 When updating individual CPU's lowest Cx state to use, never set it to a
state lower than the lowest one supported by the current CPU.  This closes
some races with changes to the hw.acpi.cpu_cx_lowest sysctl while Cx
states for individual CPUs were changing (e.g. unplugging the AC adapter
of a laptop) that could result in panics.

Submitted by:	Giovanni Trematerra
Tested by:	David Demelier  demelier dot david of gmail
MFC after:	3 days
2010-06-15 19:14:39 +00:00
Jung-uk Kim
2e1bf57ca8 Simplify a function for getting brightness levels. 2010-06-11 19:58:41 +00:00
Jung-uk Kim
30363a9a9e Remove unused assignment.
Found by:	clang static analyzer
Found by:	Coverity Prevent[tm] (CID 4537, 4538, 4539)
2010-06-11 19:53:42 +00:00
Andriy Gapon
1bdfff2252 fix a few cases where a string is passed via format argument instead of
via %s

Most of the cases looked harmless, but this is done for the sake of
correctness.  In one case it even allowed to drop an intermediate buffer.

Found by:	clang
MFC after:	2 week
2010-06-11 19:27:21 +00:00
John Baldwin
3aa6d94e0c Update several places that iterate over CPUs to use CPU_FOREACH(). 2010-06-11 18:46:34 +00:00
John Baldwin
374d9c4d18 The lock associated with the /dev/apm knote is already held, so use
KNOTE_LOCKED() instead of KNOTE_UNLOCKED().

Reported by:	mav
MFC after:	3 days
2010-06-08 21:27:05 +00:00
Jung-uk Kim
e115a49ff3 Remove unnecessary pointer type castings, shift operations and dead code. 2010-06-01 21:15:05 +00:00
Alexander Motin
b169c85e20 Oops, HPET ID optionally stored in _UID, not in _ADR. 2010-05-23 08:31:15 +00:00
Alexander Motin
3c4c08dce7 Make table-based HPET identification more clever. Before creating fake
device, make sure we have no real HPET device entry with same ID.
As side effect, it potentially allows several HPETs to be attached.
Use first of them for timecounting, rest (if ever present) could later
be used as event sources.
2010-05-23 07:53:22 +00:00
Jung-uk Kim
3f5e024c14 Merge ACPICA 20100428. 2010-04-28 22:25:27 +00:00
Jung-uk Kim
8c8be05f00 Merge ACPICA 20100331 (and four additional upstream patches). 2010-04-02 23:04:31 +00:00
Jung-uk Kim
9c98a9acdd Fix white spaces. 2010-03-10 18:30:55 +00:00
Jung-uk Kim
2a18c71d03 - Allow users to enable dumping Debug objects without ACPI debugger.
Setting the new sysctl MIB "debug.acpi.enable_debug_objects" to a non-zero
value enables us to print Debug object when something is written to it.
- Allow users to disable interpreter slack mode.  Setting the new tunable
"debug.acpi.interpreter_slack" to zero disables some workarounds for common
BIOS mistakes and enables strict ACPI implementations by the specification.
2010-03-09 19:02:02 +00:00
Jung-uk Kim
ca3cf4fa2c Merge ACPICA 20100304. 2010-03-05 21:39:16 +00:00
Jung-uk Kim
463537a097 Rename some macros to clarify their intentions and fix style nits. 2010-02-15 20:46:01 +00:00
Jung-uk Kim
aba311e1d4 Add support for cycle' and zero' events for LCD brightness control.
Submitted by:	Daniel Walter (d dot walter at 0x90 dot at) (intial version)
2010-02-15 19:30:28 +00:00
Jung-uk Kim
f29d6f75fa Make sanity check slightly more useful and tweak an error message. 2010-02-13 05:38:21 +00:00
Jung-uk Kim
35dd1ef75c Implement LCD brightness control notify handler.
Submitted by:	Daniel Walter(d dot walter at 0x90 dot at) (intial version)
2010-02-13 02:24:23 +00:00
Andriy Gapon
0430ba9e55 acpi: drop the second bus_generic_attach pass
It is belived that that pass s not needed anymore.
Specifically it is not required now for the reasons that were given
in the removed comment.

Discussed with:	jhb
MFC after:	4 weeks
2010-02-11 18:24:00 +00:00
Andriy Gapon
aa83516001 acpi cpu: probe+attach before all other enumerated children on acpi bus
Some current systems dynamically load SSDT(s) when _PDC/_OSC method
of Processor is evaluated.  Other devices in ACPI namespace may access
objects defined in the dynamic SSDT.  Drivers for such devices might
have to have a rather high priority, because of other dependencies.
Good example is acpi_ec driver for EC.
Thus we attach to Processors as early as possible to load the SSDTs
before any other drivers may try to evaluate control methods.
It also seems to be a natural order for a processor in a device
hierarchy.

On the other hand, some child devices on acpi cpu bus need to access
other system resources like PCI configuration space of chipset devices,
so they need to be probed and attached rather late.
For this reason we probe and attach the cpu bus at
SI_SUB_CONFIGURE:SI_ORDER_MIDDLE SYSINIT level.
In the future this could be done more elegantly via multipass.

Please note that acpi drivers that might access ACPI namespace from
device_identify will do that before _PDC/_OSC of Processors are evaluated.

Legacy cpu driver is not affected by this change.

PR:		kern/142561 (in part)
Reviewed by:	jhb
Silence from:	acpi@
MFC after:	5 weeks
2010-02-11 08:50:21 +00:00
Andriy Gapon
f4ab0cccce acpi_cpu: prefer _OSC over _PDC, just in case
_PDC was deprecated in favor of _OSC long time ago, but it
seems that they still peacefully coexist and in some case
only _PDC is present.
Still _OSC provides a reacher interface and is capable to
report back its status.
If the status is non-zero, then report it, we may find
it useful to understand what firmware expects from OS.
Also clean up some comments that became less useful over time.

Reviewed by:	njl, jhb, rpaulo
MFC after:	3 weeks
2010-02-06 12:48:06 +00:00
Andriy Gapon
877a6d9994 acpi_cpu: correct capabilities arguments for Processor _OSC evaluation
Populate capabilities buffer according to
Intel Processor Vendor-Specific ACPI Interface Specification.

MFC after:	2 weeks
2010-02-03 14:35:33 +00:00
Andriy Gapon
9a6a6ecb3a acpi_hpet: correctly get number of timers/comparators in a timer block
Also, account for a quirk of AMD/ATI HPET which reports number of timers
instead of id of the last timer as manadated by the specification.
Currently this has no effect on functionality but in the future we may
make actual use of the HPET timers, not only of its timecounter.

MFC after:	2 weeks
2010-01-27 10:17:28 +00:00
Jung-uk Kim
9a179dd8be Merge ACPICA 20100121. 2010-01-21 21:14:28 +00:00
Andriy Gapon
bfd1961beb acpi_ec: remove redundant acpi_disabled check in probe method
MFC after:	4 days
2010-01-18 11:33:58 +00:00
Andriy Gapon
943124d3f0 acpi_ec: clean up 'private' ivar when freeing memory to which it points
This is not only a prudent thing to do, but also makes sure that probe
method is not confused by non-NULL 'private', if the previous attach
attempt fails for any reason.

PR:		kern/142561
Tested by:	Alex Goncharov <alex-goncharov@comcast.net>
MFC after:	4 days
2010-01-18 10:30:11 +00:00
Jung-uk Kim
2272d05019 Merge ACPICA 20091112. 2009-11-16 21:47:12 +00:00
Andriy Gapon
f6eb382c79 acpi: remove 'magic' ivar
o acpi_hpet: auto-added 'wildcard' devices can be identified by
  non-NULL handle attribute.
o acpi_ec: auto-add 'wildcard' devices can be identified by
  unset (NULL) private attribute.
o acpi_cpu: use private instead of magic to store cpu id.

Reviewed by:	jhb
Silence from:	acpi@
MFC after:	2 weeks
X-MFC-Note:	perhaps the ivar should stay for ABI stability
2009-11-07 11:46:38 +00:00
John Baldwin
146672474f Do not hold the ACPI A/C adapter lock when changing the power profile.
MFC after:	2 weeks
2009-09-30 17:07:49 +00:00