Home | History | Annotate | Download | only in acpi
History log of /src/sys/dev/acpi/acpi_ec.c
RevisionDateAuthorComments
 1.108  18-Jul-2023  riastradh acpiec(4): One more debug message about read/write polling timeout.
 1.107  18-Jul-2023  riastradh acpiec(4): Take a lock around acpiec_cold updates.

Otherwise we race with readers -- probably harmlessly, but let's
avoid the appearance of problems.

XXX Maybe acpiec_suspend and acpiec_shutdown should interrupt
transactions and force them to fail promptly?

XXX This looks bad because acpiec_cold is global and sc->sc_mtx
doesn't look like it's global, but we expect to have only one
acpiec(4) device anyway from what I understand. Maybe we should move
acpiec_cold into the softc?
 1.106  18-Jul-2023  riastradh acpiec(4): Factor out if (state == FREE) cv_signal(sc_cv).

In principle this could have a functional change, but at worst, it is
to signal more wakeups than needed, which should always be safe.
 1.105  18-Jul-2023  riastradh acpiec(4): Pass softc, not device_t, to acpiec_space_handler.

Better to keep the device_t isolated to public interfaces. Simpler
internally this way.

No functional change intended.
 1.104  18-Jul-2023  riastradh acpiec(4): Pass softc, not device_t, to acpiec_gpe_query thread.

Simpler.

No functional change intended.
 1.103  18-Jul-2023  riastradh acpiec(4): Pass softc, not device_t, to acpiec_read/write.

Simpler, type-safer.

No functional change intended.
 1.102  18-Jul-2023  riastradh acpiec(4): Pass softc, not device_t, to acpiec_lock/unlock.

Simpler, type-safer.

No functional change intended.
 1.101  18-Jul-2023  riastradh acpiec(4): Pass softc, not device_t, to acpiec_gpe_handler.

Simpler.

No functional change intended.
 1.100  18-Jul-2023  riastradh acpiec(4): Pass softc, not device_t, to acpiec_callout.

Simpler.

No functional change intended.
 1.99  18-Jul-2023  riastradh acpiec(4): Pass softc, not device_t, to acpiec_gpe_state_machine.

Simpler, type-safer.

No functional change intended.
 1.98  18-Jul-2023  riastradh acpiec(4): Factor wait logic out.

No functional change intended.
 1.97  18-Jul-2023  riastradh acpiec(4): Merge returns in acpiec_read/write.

No functional change intended.
 1.96  18-Jul-2023  riastradh acpiec(4): Don't touch sc->sc_state outside sc->sc_mtx.
 1.95  18-Jul-2023  riastradh acpiec(4): Fix cv_timedwait abuse in acpiec_read/write.
 1.94  18-Jul-2023  riastradh acpiec(4): Fix interrupt wait loop in acpiec_gpe_query thread.
 1.93  18-Jul-2023  riastradh acpiec(4): Fix cv_wait loop around sc->sc_got_sci.

That is, make it actually loop as required, so it gracefully handles
spurious wakeups instead of barging into invalid states.
 1.92  18-Jul-2023  riastradh acpiec(4): Set sc_got_sci only when a transaction is over.

Before, when the acpiec thread noticed an SCI had been requested and
entered acpiec_gpe_state_machine to send the query command, it would
see the SCI is still requested -- because it had yet to acknowledge
it by setting the query command! -- and think the EC was asking for a
_second_ SCI.

So once the first SCI transaction was over, it would start a second
one, even though the EC hadn't asked for another -- and this would
wedge on some ECs.

Now, acpiec_gpe_state_machine waits to see what state we transition
to before taking the SCI bit to mean we need to notify the acpiec
thread to handle another query.

That way, when the acpiec thread enters acpiec_gpe_state_machine with
EC_STATE_QUERY, it can send the query command first, with the side
effect of clearing the SCI bit in subsequent reads of the status
register, and it won't think another SCI has been requested until it
returns to EC_STATE_FREE and sees the SCI bit set again in the status
register.

Possibly relevant PRs:

PR kern/53135
PR kern/52763
PR kern/57162
 1.91  18-Jul-2023  riastradh acpiec(4): Assert state is free when we start a transaction.

No functional change intended.
 1.90  18-Jul-2023  riastradh acpiec(4): Sprinkle comments.

Note where this code is abusing cv_wait and needs a loop to handle
spurious wakeups.

No functional change intended.
 1.89  18-Jul-2023  riastradh acpiec(4): Clarify lock order and sprinkle lock assertions.

No functional change intended.
 1.88  18-Jul-2023  riastradh acpiec(4): New ACPIEC_DEBUG option.

Value is bit mask of debug messages to enable.

Enable in x86/ALL kernels.

No functional change intended when the option is off.
 1.87  18-Jul-2023  riastradh acpiec(4): Record device_t self.

Not used yet, to be used soon for device_printf and to allow making
some of the internal functions a little more type-safe later.
 1.86  31-Dec-2021  riastradh branches: 1.86.4;
acpiec(4): Make sure to fully initialize an ACPI_INTEGER on read.

Write as essay about what this is supposed to do, as far as I can
tell from reading acpica and the commit history and the relevant PR.
 1.85  29-Jan-2021  thorpej Use acpi_compatible_match().
 1.84  15-Jun-2020  jdolecek branches: 1.84.2;
only install space handler and enable interrupt for EC if ACPI
claims the device is actually present, it's not enough when there
is entry for it in the ACPI tables

fixes interrupt storm triggered on Dell PowerEdge R220 by enabling
GPE interrupt on a non-enabled EC (for which _REG call later
fails), reported and fix tested by Dima Veselov:
http://mail-index.netbsd.org/netbsd-users/2020/03/02/msg024166.html

XXX pullup netbsd-9
 1.83  04-May-2020  jdolecek constify
 1.82  28-Apr-2020  jmcneill kern/55206: acpibat reporting broken by acpi_ec.c r1.81

Assume byte instead of qword alignment of the buffer passed to the EC
space handler.
 1.81  12-Apr-2020  riastradh Reject overly large widths, from mlelstv.

We are returning an ACPI_INTEGER (= uint64_t), so it doesn't make
sense to handle more than 64 bits.

Apparently there are some ACPIs out there that ask for unreasonably
large widths here. Just reject those requests, rather than writing
past the caller's stack buffer.

Previously we attempted to fix this by copying byte by byte as large
as the caller asked, in order to avoid the undefined behaviour of
shifting past the size of ACPI_INTEGER, but that just turned a shift
(which might have been harmless on real machines) into a stack buffer
overflow (!).

ok msaitoh
 1.80  12-Apr-2020  riastradh KNF
 1.79  12-Apr-2020  riastradh Revert acpi_ec.c 1.76.

We will do this another way, and separate KNF fixes from the critical
functional change.

ok msaitoh
 1.78  12-Apr-2020  riastradh Revert acpi_ec.c 1.77.

We will do this another way.

ok msaitoh
 1.77  06-Aug-2019  msaitoh branches: 1.77.6;
- Make the case that width < 8 behave as the same as before. Pointed out by
Joerg.
- Change "switch" to "if" for simplify.
 1.76  05-Aug-2019  msaitoh - Fix a bug that acpiec_space_handler() doesn't access more than 64bit
correctly. Found by kUBSan on Thinkpad X220. acpiec0 accessed 128bits from
address 0xa0. The error message was:

UBSan: Undefined Behavior in ../../../../dev/acpi/acpi_ec.c:672:32, shift exponent 64 is too large for 64-bit type 'long unsigned int'

- KNF.
The error message was:
 1.75  11-Mar-2017  tsutsui branches: 1.75.6; 1.75.14; 1.75.20;
Remove extra newline during attach.

> acpiec0 at acpi0 (EC, PNP0C09)
> : io 0x62,0x66
> acpiec0: using global ACPI lock

acpi_resource_parse() with &acpi_resource_parse_ops_default prints
resouce info and newline. Found and tested on ThinkPad X21.
 1.74  08-Dec-2014  msaitoh branches: 1.74.2; 1.74.4;
Add missing newlines...
 1.73  06-Jul-2014  riastradh branches: 1.73.2; 1.73.4;
Register a null power handler if acpiec fails to attach.

On one of my machines, there's no _GPE method, so
acpiec_parse_gpe_package fails, and the only function acpiec(4)
serves is to inhibit suspend/resume.

XXX We should really put the power handlers in the cfattach so that
it's not necessary to register a null power handler in every error
branch of every device's attach routine...
 1.72  16-Oct-2013  christos branches: 1.72.2;
remove unused variable
 1.71  24-Jul-2011  jakllsch branches: 1.71.2; 1.71.8; 1.71.12; 1.71.16;
Fix off-by-one in validation of EmbeddedControl OperationRegion handler.
 1.70  19-Feb-2011  jruoho After the GPE handler has finished, inform ACPICA that the interrupt has
been handled and it is safe to re-enable the GPE. Should fix all problems
introduced during the merge of ACPICA 20110211.
 1.69  17-Feb-2011  jruoho ACPICA 20101209:

Completed the major overhaul of the GPE support code that was begun in July
2010. Major features include: removal of _PRW execution in ACPICA (host
executes _PRWs anyway), cleanup of "wake" GPE interfaces and processing,
changes to existing interfaces, simplification of GPE handler operation, and
a handful of new interfaces:

AcpiUpdateAllGpes
AcpiFinishGpe
AcpiSetupGpeForWake
AcpiSetGpeWakeMask

ACPICA 20100702:

Implemented several updates to the recently added GPE reference count
support. The model for "wake" GPEs is changing to give the host OS complete
control of these GPEs. Eventually, the ACPICA core will not execute any _PRW
methods, since the host already must execute them. Also, additional changes
were made to help ensure that the reference counts are kept in proper
synchronization with reality. Rafael J. Wysocki.

1) Ensure that GPEs are not enabled twice during initialization.
2) Ensure that GPE enable masks stay in sync with the reference count.
3) Do not inadvertently enable GPEs when writing GPE registers.
4) Remove the internal wake reference counter and add new AcpiGpeWakeup
interface. This interface will set or clear individual GPEs for wakeup.
5) Remove GpeType argument from AcpiEnable and AcpiDisable. These interfaces
are now used for "runtime" GPEs only.
 1.68  07-Jan-2011  cegger branches: 1.68.2; 1.68.4;
use aprint_error_dev
 1.67  06-Jun-2010  jruoho We can no longer explicitly clear a GPE by calling AcpiClearGpe() in the
interrupt handler. However, all edge-triggered GPEs should already be
cleared before our GPE handler has a chance to run.

The reason can be found from the changes in the locking primitives of
ACPICA. All GPE operations now use a spin mutex on AcpiGbl_GpeLock, acquired
via AcpiOsAcquireLock(). This same lock is now acquired unconditionally in
the AcpiClearGpe() function. This causes a deadlock of the following form:

...

AcpiEvGpeDetect() : acquire AcpiGbl_GpeLock;

-> AcpiEvGpeDispatch();

-> acpiec_gpe_handler();

-> AcpiClearGpe() : acquire AcpiGbl_GpeLock;

-> panic.
 1.66  06-Jun-2010  jruoho ACPICA 20100331:

Completed a major update for the GPE support in order to improve
support for shared GPEs and to simplify both host OS and ACPICA
code. Added a reference count mechanism to support shared GPEs that
require multiple device drivers. Several external interfaces have
changed. One external interface has been removed. One new external
interface was added. Most of the GPE external interfaces now use the
GPE spinlock instead of the events mutex (and the Flags parameter
for many GPE interfaces has been removed.) See the updated ACPICA
Programmer Reference for details. Matthew Garrett, Bob Moore, Rafael
Wysocki. ACPICA BZ 831.

Changed:
AcpiEnableGpe, AcpiDisableGpe, AcpiClearGpe, AcpiGetGpeStatus
Removed:
AcpiSetGpeType
New:
AcpiSetGpe
 1.65  14-Apr-2010  jruoho No need to spread the ACPICA type system any more than is necessary:

UINT8 -> uint8_t and UINT32 -> uint32_t.
 1.64  29-Mar-2010  dyoung Attach acpiecdt with acpibus_attach_args. Sverre Froyen reports that
this helps his Thinkpad boot again.
 1.63  24-Mar-2010  dyoung Do not use unitialized bus_space_tag_t's. Use the tag(s) from the
attachment arguments.
 1.62  05-Mar-2010  jruoho branches: 1.62.2;
Remove <dev/acpi/acpica.h> from all files. It is included from
<dev/acpi/acpivar.h>. Ditto for <dev/sysmon/sysmonvar.h>, <sys/bus.h>,
<dev/pci/pcivar.h>, and <dev/isa/isavar.h>.

Also nuke a lot of unused and invalid headers. Some of these are audibly
provided by standard headers (namely <sys/param.h> and <sys/device.h>), some
have nothing to do with ACPI devices (e.g. <sys/syslog.h>), and some are
nonexistent local includes (e.g. "mpu_ym.h"). Moreoever, try to group the
includes into their respective blocks.

Tested with GENERIC and ALL (i386). No functional change.
 1.61  02-Mar-2010  jruoho Format string cosmetics (mainly from %d to %u).
 1.60  24-Feb-2010  dyoung A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.59  18-Jan-2010  jruoho branches: 1.59.2;
Use acpi_eval_reference_handle() to simplify code. No functional change.

ok jmcneill@, pgoyette@
 1.58  08-Jan-2010  dyoung Expand PMF_FN_* macros.
 1.57  16-Sep-2009  mlelstv Allow for 'options ACPI_DEBUG' by providing module declarations
and using memory allocation macros instead of calling AcpiOs* stubs
directly.
 1.56  06-Jul-2009  alc Add a pmf(9) shutdown hook to acpiec(4) to use polling on shutdown.

This fixes DIAGNOSTIC's assertion failure:

cpu_switchto(): switching above IPL_SCHED

during ACPI shutdown.

OK'd by joerg@
 1.55  12-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.54  28-Feb-2009  jmcneill Change a confusing attach message; if the embedded controller was attached
via ECDT, we would print:
acpiec0 at acpi0 (EC, PHP0C09-0): ACPI Embedded Controller (disabled)
The embedded controller isn't actually disabled, but instead this driver
instance, so change the message to read:
acpiec0 at acpi0 (EC, PHP0C09-0): using acpiecdt0
 1.53  17-Feb-2009  jmcneill Cut the amount of spam from acpi devices in roughly half by printing
resources on the same line as autoconf messages. Things like:
pcppi1 at acpi0 (SPKR, PNP0800)
pcppi1: io 0x61
become:
pcppi1 at acpi0 (SPKR, PNP0800): io 0x61
 1.52  03-Jun-2008  joerg branches: 1.52.6; 1.52.8; 1.52.12; 1.52.16;
Before 1.46, the EC driver would try to send a command again to the EC
after a timeout. This was removed, but the loops remained, so fix them
up as well.
 1.51  29-Feb-2008  dyoung branches: 1.51.2; 1.51.4; 1.51.6;
Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.50  18-Jan-2008  jmcneill branches: 1.50.2; 1.50.6;
Don't be so aggressive in polling the EC when cold, port-i386/37790.
 1.49  18-Jan-2008  jmcneill If we are in polling mode, do not try to spin forever in the state machine
waiting for a read or write to complete. Workaround an issue on my VAIO,
but we really need to figure out why it is failing in the first place.
 1.48  21-Dec-2007  jmcneill Add acpiec_bus_{read,write} and acpiec_get_handle, for use in other
device drivers.
 1.47  19-Dec-2007  joerg It seems like ACPICA can't deal with GPEs being handled before the GPE
handler is called, so clear the GPE bit in the callout as well.
This fixes the EC issues on T42 models.
 1.46  15-Dec-2007  joerg Don't retry to post a command if the EC doesn't answer for a second.
It seems to create more issues than it fixes. Try to defend against
lost/late GPEs by using a callout to kick the state machine regulary.
Add some notes about the purpose and working of the driver.
 1.45  12-Dec-2007  jmcneill Rename acpiec_gpe_state_maschine -> acpiec_gpe_state_machine
 1.44  09-Dec-2007  jmcneill branches: 1.44.2;
Merge jmcneill-pm branch.
 1.43  05-Dec-2007  ad branches: 1.43.2;
lockmgr -> mutex
 1.42  19-Oct-2007  ad branches: 1.42.2; 1.42.4;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.41  26-Jun-2007  jmcneill branches: 1.41.6; 1.41.8; 1.41.12;
Don't be quite so aggressive in EcWaitEvent; makes acpiec work on the
Sony VAIO VGN-N250E, and possibly others.
 1.40  16-Nov-2006  christos branches: 1.40.8; 1.40.10;
__unused removal on arguments; approved by core.
 1.39  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.38  14-May-2006  dogcow branches: 1.38.8; 1.38.10;
gcc4: 'Data' may be used uninitialized in this function
 1.37  20-Feb-2006  kochi branches: 1.37.2; 1.37.6;
use aprint_*
 1.36  16-Feb-2006  kochi prototypes don't need argument names
 1.35  24-Dec-2005  perry branches: 1.35.2; 1.35.4; 1.35.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.34  11-Dec-2005  christos merge ktrace-lwp.
 1.33  02-May-2005  kochi branches: 1.33.2;
Merge changes for ACPI-CA 20050408
 1.32  25-Jun-2004  yamt don't rely on the value of hz.
 1.31  01-May-2004  kochi specify static where appropriate.
 1.30  24-Apr-2004  yamt EcGpeHandler: in the case that the ec is EcLock'ed, always set
EC_F_PENDQUERY flag so that AcpiClearGpe() will be called later.
 1.29  22-Apr-2004  itojun sprintf -> snprintf
 1.28  11-Apr-2004  kochi - don't evaluate _UID, reuse ACPI_DEVINFO
- move acpi_resources from acpi_ec_softc to stack
 1.27  11-Apr-2004  kochi Clean up memory allocated during autoconfiguration
 1.26  11-Apr-2004  kochi change acpi_resource_parse API to support _PRS parsing as well as _CRS
 1.25  11-Apr-2004  kochi return (x) -> return x
use consitent variable name for ACPI_STATUS
 1.24  10-Apr-2004  kochi whitespace nit
 1.23  30-Mar-2004  kochi Add ACPI ECDT (Embedded Controller Description Table) support.
This will enable usage of EC in early stage of ACPI initialization.
 1.22  24-Mar-2004  kanaoka branches: 1.22.2;
Set sc->sc_glk,if acpi_eval_integer() evaluate _GLK in acpiec_attach.
 1.21  24-Mar-2004  kanaoka Make it compile (int -> ACPI_INTEGER)
 1.20  12-Nov-2003  yamt - fix deadlocks due to using lock_status() from interrupt context.
- process pending queries in EcUnlock() to close a race window.
now there's no need to do polling for EcQuery().
- reorder inline functions and other prototypes so that
the formers can get needed prototypes.
- add missing prototypes.
 1.19  12-Nov-2003  yamt use snprintf("%X") instead of "%x" + strupr().
 1.18  03-Nov-2003  mycroft More cleanup:
* Use ACPI_FAILURE() and ACPI_SUCCESS().
* Output exception strings in a few more places.
 1.17  03-Nov-2003  mycroft Fix locking protocol, and use _GLK appropriately. From kochi, with some
modifications.
 1.16  03-Nov-2003  kochi * now the size of ACPI_DEVICE_INFO is variable:
it can now accomodate multiple _CIDs
sizeof(ACPI_DEVICE_INFO) should not be used
* make ad_devinfo member in acpi_devnode a pointer
* implement acpi_match_hid() to simplify matching devices;
_CIDs are also taken into account now as well as _HID
 1.15  01-Nov-2003  mycroft sc_lockhandle is garbage.
 1.14  01-Nov-2003  mycroft Remove an unnecessary call to AcpiGlearGpe().
 1.13  01-Nov-2003  mycroft Correct arguments to AcpiClearGpe().
 1.12  01-Nov-2003  mycroft Correct arguments to AcpiInstallGpeHandler, as per Linux and FreeBSD.
 1.11  31-Oct-2003  mycroft Catch up with ABI changes in ACPI-CA. Some additional changes to acpi_bat to
set the VALID bits correctly, so we don't report garbage for missing batteries.
 1.10  03-Aug-2003  kochi Fix a wrong handling of clearing a flag
 1.9  14-Feb-2003  tshiozak branches: 1.9.2;
- add acpi_acquire_global_lock()/acpi_release_global_lock()/
acpi_is_global_locked() functions.
AcpiGlobalLock() API should be used to acquire lock between BIOS and OS.
This API cannot be used to lock between threads of the OS side,
because this function immediately returns if the lock is already acquired
by the OS. c.f. AcpiEvAcquireGlobalLock()@evmisc.c

- make sure that acpiec driver uses above functions.

- use ACPI_ALLOCATE_BUFFER instead of twice calls of AcpiEvaluateObject(),
in acpi_eval_string()/acpi_eval_struct().
Twice AcpiEvaluateObject() calls may cause twice side effects
to ACPI machine / hardware and this may be wrong in some cases.
 1.8  15-Oct-2002  tshiozak fix a simple, but wicked bug in EcSpaceHandler().
this bug causes EcWrite via EcSpaceHandler to always write 0 as the data byte.
 1.7  02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.6  30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.5  27-Sep-2002  thorpej Declare all cfattach structures const.
 1.4  15-Jun-2002  thorpej Update for acpica-unix-20020612. From Takayoshi Kochi.
 1.3  13-Nov-2001  lukem branches: 1.3.2; 1.3.10;
add RCSID
 1.2  12-Oct-2001  enami Fix printf format.
 1.1  29-Sep-2001  thorpej branches: 1.1.2; 1.1.4;
ACPI Embedded Controller driver.
 1.1.4.6  18-Oct-2002  nathanw Catch up to -current.
 1.1.4.5  20-Jun-2002  nathanw Catch up to -current.
 1.1.4.4  14-Nov-2001  nathanw Catch up to -current.
 1.1.4.3  22-Oct-2001  nathanw Catch up to -current.
 1.1.4.2  08-Oct-2001  nathanw Catch up to -current.
 1.1.4.1  29-Sep-2001  nathanw file acpi_ec.c was added on branch nathanw_sa on 2001-10-08 21:18:05 +0000
 1.1.2.2  01-Oct-2001  fvdl Catch up with -current.
 1.1.2.1  29-Sep-2001  fvdl file acpi_ec.c was added on branch thorpej-devvp on 2001-10-01 12:44:15 +0000
 1.3.10.1  20-Jun-2002  gehenna catch up with -current.
 1.3.2.4  10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.3.2.3  23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.2.2  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.2.1  13-Nov-2001  thorpej file acpi_ec.c was added on branch kqueue on 2002-01-10 19:52:52 +0000
 1.9.2.4  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.9.2.3  21-Sep-2004  skrll Fix the sync with head I botched.
 1.9.2.2  18-Sep-2004  skrll Sync with HEAD.
 1.9.2.1  03-Aug-2004  skrll Sync with HEAD
 1.22.2.2  29-Apr-2004  jmc Pullup rev 1.30 (requested by yamt in ticket #221)

EcGpeHandler: in the case that the ec is EcLock'ed, always set
EC_F_PENDQUERY flag so that AcpiClearGpe() will be called later.
 1.22.2.1  28-Apr-2004  jmc Pullup rev 1.23 (requested by kochi in ticket #191)

Add ACPI ECDT (Embedded Controller Description Table) support.
This will enable usage of EC in early stage of ACPI initialization.
 1.33.2.7  17-Mar-2008  yamt sync with head.
 1.33.2.6  21-Jan-2008  yamt sync with head
 1.33.2.5  07-Dec-2007  yamt sync with head
 1.33.2.4  27-Oct-2007  yamt sync with head.
 1.33.2.3  03-Sep-2007  yamt sync with head.
 1.33.2.2  30-Dec-2006  yamt sync with head.
 1.33.2.1  21-Jun-2006  yamt sync with head.
 1.35.6.2  01-Jun-2006  kardel Sync with head.
 1.35.6.1  22-Apr-2006  simonb Sync with head.
 1.35.4.1  09-Sep-2006  rpaulo sync with head
 1.35.2.2  01-Mar-2006  yamt sync with head.
 1.35.2.1  18-Feb-2006  yamt sync with head.
 1.37.6.1  24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.37.2.1  24-May-2006  yamt sync with head.
 1.38.10.2  10-Dec-2006  yamt sync with head.
 1.38.10.1  22-Oct-2006  yamt sync with head
 1.38.8.1  18-Nov-2006  ad Sync with head.
 1.40.10.1  11-Jul-2007  mjf Sync with head.
 1.40.8.2  23-Oct-2007  ad Sync with head.
 1.40.8.1  15-Jul-2007  ad Sync with head.
 1.41.12.1  25-Oct-2007  bouyer Sync with HEAD.
 1.41.8.3  23-Mar-2008  matt sync with HEAD
 1.41.8.2  09-Jan-2008  matt sync with HEAD
 1.41.8.1  06-Nov-2007  matt sync with HEAD
 1.41.6.14  09-Dec-2007  jmcneill Sync with HEAD.
 1.41.6.13  08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.41.6.12  06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.41.6.11  26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.41.6.10  04-Oct-2007  joerg When failing to acquire or release the global lock, print the error
message.
 1.41.6.9  04-Oct-2007  joerg Fix thinko: if acpiec_cold is set, the device is in D3, not D0.
This fixes the timeouts on resume.
 1.41.6.8  04-Oct-2007  joerg Explicitly initialise variable written to via or.
 1.41.6.7  04-Oct-2007  joerg Random undocumented fact #741:
The ACPI Embedded Controller will generally only except new commands if
the input buffer is not full.

Push the command write into acpiec_gpe_state_machine and start the
processing with a few busy iterations in
acpiec_write/acpiec_read/acpiec_gpe_query. Also move the read of data
into the state machine to keep all register access in one place.

This fixes random read/write errors that occured with a chance of 10% or
so. It is unclear why the old code didn't hit it more often.
 1.41.6.6  02-Oct-2007  jmcneill Update to ACPI-CA 20070320
 1.41.6.5  02-Oct-2007  joerg Rewrite the ACPI Embedded Controller handler to use pure event driven
operation. On suspend a special flag is set to force explicit polling
as AcpiLeaveSleep accesses the interrupt before GPE handling is
restored. The driver uses a kernel thread to handle GPE queries and
mutex/condvar for synchronisation.

Split the ACPI EC into two drivers, one that is attached directly by
acpi.c for the ECDT driven attachment and the normal acpiec for late
attachment. Share almost all code between this two drivers. If acpiecdt
is attached, acpiec is returning. This was discussed with cube@ and is
the best solution so far.
 1.41.6.4  26-Sep-2007  joerg Merge EcWaitEvent and EcWaitEventIntr. I don't see a good reason to wait
0.99s for the EC, just use 1sec.
 1.41.6.3  26-Sep-2007  joerg Reorder slightly to make clear that EcRead and EcWrite are used only by
EcTransaction.
 1.41.6.2  05-Aug-2007  jmcneill Certain devices either don't require a power handler, or are restored
on resume outside of the pnp power management framework. For such devices,
introduce the null power handler, pnp_generic_power.
 1.41.6.1  03-Aug-2007  jmcneill Pull in power management changes from private branch.
 1.42.4.2  26-Dec-2007  ad Sync with head.
 1.42.4.1  08-Dec-2007  ad Sync with head.
 1.42.2.3  18-Feb-2008  mjf Sync with HEAD.
 1.42.2.2  27-Dec-2007  mjf Sync with HEAD.
 1.42.2.1  08-Dec-2007  mjf Sync with HEAD.
 1.43.2.2  13-Dec-2007  yamt sync with head.
 1.43.2.1  11-Dec-2007  yamt sync with head.
 1.44.2.3  19-Jan-2008  bouyer Sync with HEAD
 1.44.2.2  02-Jan-2008  bouyer Sync with HEAD
 1.44.2.1  13-Dec-2007  bouyer Sync with HEAD
 1.50.6.2  05-Jun-2008  mjf Sync with HEAD.

Also fix build.
 1.50.6.1  03-Apr-2008  mjf Sync with HEAD.
 1.50.2.1  24-Mar-2008  keiichi sync with head.
 1.51.6.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.51.4.5  11-Aug-2010  yamt sync with head.
 1.51.4.4  11-Mar-2010  yamt sync with head
 1.51.4.3  18-Jul-2009  yamt sync with head.
 1.51.4.2  16-May-2009  yamt sync with head
 1.51.4.1  04-May-2009  yamt sync with head.
 1.51.2.1  04-Jun-2008  yamt sync with head
 1.52.16.1  21-Apr-2010  matt sync to netbsd-5
 1.52.12.2  23-Jul-2009  jym Sync with HEAD.
 1.52.12.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.52.8.2  01-May-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #535):
sys/dev/acpi/acpi_ec.c: revision 1.54
Change a confusing attach message; if the embedded controller was attached
via ECDT, we would print:
acpiec0 at acpi0 (EC, PHP0C09-0): ACPI Embedded Controller (disabled)
The embedded controller isn't actually disabled, but instead this driver
instance, so change the message to read:
acpiec0 at acpi0 (EC, PHP0C09-0): using acpiecdt0
 1.52.8.1  01-May-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #498):
sys/dev/acpi/acpi_ec.c: revision 1.53
sys/dev/acpi/acpi_resource.c: revision 1.27
sys/dev/acpi/atppc_acpi.c: revision 1.16
sys/dev/acpi/attimer_acpi.c: revision 1.12
sys/dev/acpi/com_acpi.c: revision 1.28
sys/dev/acpi/fdc_acpi.c: revision 1.35
sys/dev/acpi/hpet_acpi.c: revision 1.4
sys/dev/acpi/joy_acpi.c: revision 1.9
sys/dev/acpi/lpt_acpi.c: revision 1.18
sys/dev/acpi/mpu_acpi.c: revision 1.9
sys/dev/acpi/pckbc_acpi.c: revision 1.31
sys/dev/acpi/pcppi_acpi.c: revision 1.11
sys/dev/acpi/ug_acpi.c: revision 1.5
sys/dev/acpi/wss_acpi.c: revision 1.20
sys/dev/acpi/ym_acpi.c: revision 1.6
Cut the amount of spam from acpi devices in roughly half by printing
resources on the same line as autoconf messages. Things like:
pcppi1 at acpi0 (SPKR, PNP0800)
pcppi1: io 0x61
become:
pcppi1 at acpi0 (SPKR, PNP0800): io 0x61
 1.52.6.1  03-Mar-2009  skrll Sync with HEAD.
 1.59.2.2  17-Aug-2010  uebayasi Sync with HEAD.
 1.59.2.1  30-Apr-2010  uebayasi Sync with HEAD.
 1.62.2.3  05-Mar-2011  rmind sync with head
 1.62.2.2  03-Jul-2010  rmind sync with head
 1.62.2.1  30-May-2010  rmind sync with head
 1.68.4.2  05-Mar-2011  bouyer Sync with HEAD
 1.68.4.1  17-Feb-2011  bouyer Sync with HEAD
 1.68.2.1  06-Jun-2011  jruoho Sync with HEAD.
 1.71.16.1  18-May-2014  rmind sync with head
 1.71.12.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.71.8.1  29-Sep-2014  msaitoh Pull up following revision(s) (requested by riastradh in ticket #1122):
sys/dev/acpi/acpi_ec.c: revision 1.73
Register a null power handler if acpiec fails to attach.
On one of my machines, there's no _GPE method, so
acpiec_parse_gpe_package fails, and the only function acpiec(4)
serves is to inhibit suspend/resume.
XXX We should really put the power handlers in the cfattach so that
it's not necessary to register a null power handler in every error
branch of every device's attach routine...
 1.71.2.1  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.72.2.1  10-Aug-2014  tls Rebase.
 1.73.4.2  28-Aug-2017  skrll Sync with HEAD
 1.73.4.1  06-Apr-2015  skrll Sync with HEAD
 1.73.2.1  08-Jan-2015  martin Pull up following revision(s) (requested by msaitoh in ticket #392):
sys/dev/acpi/acpi_ec.c: revision 1.74
sys/dev/isa/pcppi.c: revision 1.43
Add missing newlines...
 1.74.4.1  21-Apr-2017  bouyer Sync with HEAD
 1.74.2.1  20-Mar-2017  pgoyette Sync with HEAD
 1.75.20.4  20-Jun-2020  martin Pull up following revision(s) (requested by jdolecek in ticket #959):

sys/dev/acpi/acpi_ec.c: revision 1.84

only install space handler and enable interrupt for EC if ACPI

claims the device is actually present, it's not enough when there
is entry for it in the ACPI tables
fixes interrupt storm triggered on Dell PowerEdge R220 by enabling
GPE interrupt on a non-enabled EC (for which _REG call later
fails), reported and fix tested by Dima Veselov:
http://mail-index.netbsd.org/netbsd-users/2020/03/02/msg024166.html

XXX pullup netbsd-9
 1.75.20.3  29-Apr-2020  martin Pull up following revision(s) (requested by jmcneill in ticket #866):

sys/dev/acpi/acpi_ec.c: revision 1.82

kern/55206: acpibat reporting broken by acpi_ec.c r1.81

Assume byte instead of qword alignment of the buffer passed to the EC
space handler.
 1.75.20.2  12-Apr-2020  martin Pull up following revision(s) (requested by riastradh in ticket #829):

sys/dev/acpi/acpi_ec.c: revision 1.78
sys/dev/acpi/acpi_ec.c: revision 1.79
sys/dev/acpi/acpi_ec.c: revision 1.80
sys/dev/acpi/acpi_ec.c: revision 1.81

Revert acpi_ec.c 1.77.
We will do this another way.
ok msaitoh

Revert acpi_ec.c 1.76.
We will do this another way, and separate KNF fixes from the critical
functional change.
ok msaitoh

KNF

Reject overly large widths, from mlelstv.
We are returning an ACPI_INTEGER (= uint64_t), so it doesn't make
sense to handle more than 64 bits.

Apparently there are some ACPIs out there that ask for unreasonably
large widths here. Just reject those requests, rather than writing
past the caller's stack buffer.

Previously we attempted to fix this by copying byte by byte as large
as the caller asked, in order to avoid the undefined behaviour of
shifting past the size of ACPI_INTEGER, but that just turned a shift
(which might have been harmless on real machines) into a stack buffer
overflow (!).

ok msaitoh
 1.75.20.1  09-Aug-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #38):

sys/dev/acpi/acpi_ec.c: revision 1.76
sys/dev/acpi/acpi_ec.c: revision 1.77

- Fix a bug that acpiec_space_handler() doesn't access more than 64bit
correctly. Found by kUBSan on Thinkpad X220. acpiec0 accessed 128bits from
address 0xa0. The error message was:
UBSan: Undefined Behavior in ../../../../dev/acpi/acpi_ec.c:672:32, shift exponent 64 is too large for 64-bit type 'long unsigned int'

- KNF.

- Make the case that width < 8 behave as the same as before. Pointed out by
Joerg.

- Change "switch" to "if" for simplify.
 1.75.14.2  21-Apr-2020  martin Sync with HEAD
 1.75.14.1  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.75.6.1  16-Aug-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1337):

sys/dev/acpi/acpi_ec.c: revision 1.76
sys/dev/acpi/acpi_ec.c: revision 1.77

- Fix a bug that acpiec_space_handler() doesn't access more than 64bit
correctly. Found by kUBSan on Thinkpad X220. acpiec0 accessed 128bits from
address 0xa0. The error message was:
UBSan: Undefined Behavior in ../../../../dev/acpi/acpi_ec.c:672:32, shift exponent 64 is too large for 64-bit type 'long unsigned int'
- KNF.
- Make the case that width < 8 behave as the same as before. Pointed out by
Joerg.
- Change "switch" to "if" for simplify.
 1.77.6.1  20-Apr-2020  bouyer Sync with HEAD
 1.84.2.1  03-Apr-2021  thorpej Sync with HEAD.
 1.86.4.1  30-Jul-2023  martin Pull up following revision(s) (requested by riastradh in ticket #259):

sys/dev/acpi/acpi_ec.c: revision 1.102
sys/dev/acpi/acpi_ec.c: revision 1.103
sys/dev/acpi/acpi_ec.c: revision 1.104
sys/dev/acpi/acpi_ec.c: revision 1.105
sys/dev/acpi/acpi_ec.c: revision 1.106
sys/dev/acpi/acpi_ec.c: revision 1.107
sys/dev/acpi/acpi_ec.c: revision 1.108
sys/dev/acpi/acpi_ec.c: revision 1.90
sys/dev/acpi/acpi_ec.c: revision 1.91
sys/dev/acpi/acpi_ec.c: revision 1.92
sys/dev/acpi/acpi_ec.c: revision 1.93
sys/dev/acpi/acpi_ec.c: revision 1.94
sys/dev/acpi/files.acpi: revision 1.128
sys/dev/acpi/acpi_ec.c: revision 1.95
sys/dev/acpi/acpi_ec.c: revision 1.96
sys/dev/acpi/acpi_ec.c: revision 1.97
sys/arch/amd64/conf/ALL: revision 1.179
sys/dev/acpi/acpi_ec.c: revision 1.98
sys/dev/acpi/acpi_ec.c: revision 1.99
sys/dev/acpi/acpi_ec.c: revision 1.87
sys/dev/acpi/acpi_ec.c: revision 1.88
sys/dev/acpi/acpi_ec.c: revision 1.89
sys/arch/i386/conf/ALL: revision 1.511
sys/dev/acpi/acpi_ec.c: revision 1.100
sys/dev/acpi/acpi_ec.c: revision 1.101

acpiec(4): Record device_t self.

Not used yet, to be used soon for device_printf and to allow making
some of the internal functions a little more type-safe later.
acpiec(4): New ACPIEC_DEBUG option.

Value is bit mask of debug messages to enable.

Enable in x86/ALL kernels.

No functional change intended when the option is off.

acpiec(4): Clarify lock order and sprinkle lock assertions.
No functional change intended.

acpiec(4): Sprinkle comments.
Note where this code is abusing cv_wait and needs a loop to handle
spurious wakeups.
No functional change intended.

acpiec(4): Assert state is free when we start a transaction.
No functional change intended.

acpiec(4): Set sc_got_sci only when a transaction is over.

Before, when the acpiec thread noticed an SCI had been requested and
entered acpiec_gpe_state_machine to send the query command, it would
see the SCI is still requested -- because it had yet to acknowledge
it by setting the query command! -- and think the EC was asking for a
_second_ SCI.

So once the first SCI transaction was over, it would start a second
one, even though the EC hadn't asked for another -- and this would
wedge on some ECs.

Now, acpiec_gpe_state_machine waits to see what state we transition
to before taking the SCI bit to mean we need to notify the acpiec
thread to handle another query.

That way, when the acpiec thread enters acpiec_gpe_state_machine with
EC_STATE_QUERY, it can send the query command first, with the side
effect of clearing the SCI bit in subsequent reads of the status
register, and it won't think another SCI has been requested until it
returns to EC_STATE_FREE and sees the SCI bit set again in the status
register.

Possibly relevant PRs:
PR kern/53135
PR kern/52763
PR kern/57162

acpiec(4): Fix cv_wait loop around sc->sc_got_sci.

That is, make it actually loop as required, so it gracefully handles
spurious wakeups instead of barging into invalid states.

acpiec(4): Fix interrupt wait loop in acpiec_gpe_query thread.

acpiec(4): Fix cv_timedwait abuse in acpiec_read/write.

acpiec(4): Don't touch sc->sc_state outside sc->sc_mtx.

acpiec(4): Merge returns in acpiec_read/write.
No functional change intended.

acpiec(4): Factor wait logic out.
No functional change intended.

acpiec(4): Pass softc, not device_t, to acpiec_gpe_state_machine.
Simpler, type-safer.
No functional change intended.

acpiec(4): Pass softc, not device_t, to acpiec_callout.
Simpler.
No functional change intended.

acpiec(4): Pass softc, not device_t, to acpiec_gpe_handler.
Simpler.
No functional change intended.

acpiec(4): Pass softc, not device_t, to acpiec_lock/unlock.
Simpler, type-safer.
No functional change intended.

acpiec(4): Pass softc, not device_t, to acpiec_read/write.
Simpler, type-safer.
No functional change intended.

acpiec(4): Pass softc, not device_t, to acpiec_gpe_query thread.
Simpler.
No functional change intended.

acpiec(4): Pass softc, not device_t, to acpiec_space_handler.
Better to keep the device_t isolated to public interfaces. Simpler
internally this way.
No functional change intended.

acpiec(4): Factor out if (state == FREE) cv_signal(sc_cv).

In principle this could have a functional change, but at worst, it is
to signal more wakeups than needed, which should always be safe.
acpiec(4): Take a lock around acpiec_cold updates.

Otherwise we race with readers -- probably harmlessly, but let's
avoid the appearance of problems.
XXX Maybe acpiec_suspend and acpiec_shutdown should interrupt
transactions and force them to fail promptly?
XXX This looks bad because acpiec_cold is global and sc->sc_mtx
doesn't look like it's global, but we expect to have only one
acpiec(4) device anyway from what I understand. Maybe we should move
acpiec_cold into the softc?

acpiec(4): One more debug message about read/write polling timeout.

RSS XML Feed