Home | History | Annotate | Download | only in acpi
History log of /src/sys/dev/acpi/thinkpad_acpi.c
RevisionDateAuthorComments
 1.57  27-Apr-2024  christos Expose a sysctl interface hw.acpi.thinkpad<M>.bat[<N>].<behavior> to control
some aspects of battery charging behavior on supported systems:

charge_start
threshold below which to start charging (in %, 0-99)

charge_stop
threshold above which to stop charging (in %, 1-100)

force_discharge
discharge while on AC power, e.g., for calibration

charge_inhibit
inhibit charging while on AC power

From Malte Dehling
 1.56  27-Apr-2024  christos thinkpad cosmetic patches (Malte Dehling)
 1.55  12-Aug-2022  riastradh thinkpad(4): Don't detach on shutdown.

There's no important state that needs to be recorded, or resources
that need to be relinquished, so detach-on-shutdown isn't necessary.

At the moment, detach-on-shutdown is actually harmful here: if
shutdown is triggered by a sysmon power switch event, then
config_detach will be called from the sysmon taskqueue, but
thinkpad_detach has to wait for ACPI notifiers to finish running
which means waiting for the sysmon taskqueue -> deadlock or crash.

We should maybe arrange to do config_detach from a thread other than
the sysmon taskqueue thread to avoid this class of problems -- but
for now, thinkpad(4) has no reason to detach on shutdown anyway, so
let's take the easy path.

Note: There are many drivers that set DVF_DETACH_SHUTDOWN which
probably shouldn't; the flag means the kernel _will_ detach on
shutdown, not that it _may_. Even those that do need to record state
or relinquish resources might be better served by pmf shutdown hooks
which can skip freeing software resources for faster shutdown.
 1.54  31-Dec-2021  riastradh thinkpad(4): Omit workaround for acpiec_bus_read.

acpiec_bus_read now initializes the whole ACPI_INTEGER like its
signature suggests, so we don't need to pick out the low bits of the
result or carefully avoid undefined behaviour from uninitialized
stack garbage.
 1.53  30-May-2021  riastradh thinkpad(4): Fix evaluation of MHKA on version 2 devices.

Need to pass an argument.
 1.52  29-May-2021  riastradh Add some more Thinkpad hotkeys.
 1.51  29-May-2021  riastradh thinkpad(4): Add dtrace probe for hotkey events.
 1.50  29-May-2021  riastradh thinkpad(4): Attach at LEN0268 with v2 Thinkpad hotkeys too.
 1.49  29-Jan-2021  thorpej branches: 1.49.4; 1.49.6;
Use acpi_compatible_match().
 1.48  17-May-2020  mlelstv branches: 1.48.2;
With the recent change of the EC address space handler, we no longer get
an ACPI_INTEGER in host byte order but a byte sized buffer with little
endian data.

Extract only the low 8 bits from buffer to get the fan speed again.
 1.47  05-Aug-2019  msaitoh Fix undefined behavior in thinkpad_mask_init(). Found by kUBSan.
 1.46  03-Apr-2016  mlelstv branches: 1.46.18; 1.46.24;
Split toggles for bluetooth and wwan and use specific ACPI objects
where present.
Also make driver detach on shutdown.
 1.45  23-Apr-2015  pgoyette Update module dependencies for all the existing modules that depend on sysmon components.
 1.44  30-Mar-2013  christos branches: 1.44.12;
reverse the polarity of the extra key option, always enabling them.
 1.43  30-Mar-2013  christos Define THINKPAD_EXTENDED_HOTKEYS to enable more hotkeys on ThinkPads.
This has only been tested on a T61.
XXX: Should we put THINKPAD_EXTENDED_HOTKEYS into a opt_*.h include
(defflag) or just always enable it?
 1.42  24-Nov-2012  riastradh Match LEN0068 in thinkpad(4) too, as newer Thinkpads report.

Tested on a W530. Lots of stuff is missing, though.
 1.41  14-Aug-2012  jruoho branches: 1.41.2;
Collect rnd(9) entropy from coretemp(4), acpibat(4), aibs(4), hpacel(4),
thinkpad(4), and aps(4).
 1.40  15-Jul-2012  spz add function switch to switch on/off "wireless WAN", aka GSM et al modem
not tested to actually work, extensively tested not to do any harm if you
don't have a wwan
 1.39  20-Jun-2011  pgoyette branches: 1.39.2; 1.39.8;
Initialize sensor state before trying to register.
 1.38  06-Jun-2011  pgoyette Don't update the value_{min,max} - these fields are not {low,high}-water
marks, and setting them without also updating the ENVSYS_FVALID_{MIN,MAX}
flags is quite pointless.
 1.37  14-Apr-2011  jruoho branches: 1.37.2;
Simplify a little. No functional change.
 1.36  14-Apr-2011  jruoho Use the common power resource code. Also add a comment explaining
what can happen if we do not power on the resource upon resume from S3.
 1.35  27-Mar-2011  mlelstv Use wireless function key to toggle not only bluetooth but also
telephony (GPRS/UMTS/..) like other operating systems.
 1.34  16-Feb-2011  jruoho Use ioconf for the module declarations.
 1.33  18-Jan-2011  jmcneill branches: 1.33.2;
Use AcpiOsReadPort/AcpiOsWritePort instead of inb/outb so I can get rid of
of the i386 and x86_64 ifdefs.
 1.32  31-Dec-2010  jruoho branches: 1.32.2;
Use "temperature #" and "fan speed #" rather than "TMP#" and "FAN#" for the
sensor names. Remove white space. No functional change.
 1.31  25-Oct-2010  jruoho Bump WARNS to 4.
 1.30  15-Apr-2010  jruoho As discussed with jmcneill@, install a global "bus notification handler"
that receives all notifications and deliver notifications to drivers via it.
 1.29  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.28  05-Mar-2010  jruoho branches: 1.28.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.27  28-Feb-2010  jruoho Introduce support for ACPI kernel modules.

Tested on couple of laptops.
 1.26  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.25  31-Jan-2010  jruoho branches: 1.25.2;
Add a detachment routine. While here, clarify the initialization of sensors.
 1.24  30-Jan-2010  jruoho Add the _COMPONENT definition for ACPI_DEBUG.
 1.23  18-Jan-2010  jruoho Add definitions for volume keys.

ok jmcneill@
 1.22  08-Jan-2010  dyoung Expand PMF_FN_* macros.
 1.21  29-Nov-2009  cegger Introduce acpi_eval_set_integer().
Use it in various acpi drivers to simplify code.
Patch presented on tech-kern@:
http://mail-index.netbsd.org/tech-kern/2009/11/28/msg006552.html

No comments.

XXX Is there an acpi(9) manpage?
 1.20  25-Sep-2009  dyoung Use deviter_first()/deviter_next() instead of accessing alldevs
directly. Compile-tested, only.
 1.19  12-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.18  17-Feb-2009  jmcneill Use aprint_debug
 1.17  01-Nov-2008  hans branches: 1.17.4;
Make the driver work (except for setting display brightness) on older
machines by removing the check for the CMOS method from thinkpad_match.
OK by jmcneill.
 1.16  18-Oct-2008  jmcneill branches: 1.16.2; 1.16.4;
Add fan sensor support, from Thomas E. Spanjaard
 1.15  05-May-2008  jmcneill branches: 1.15.6;
Use 2-clause license.
 1.14  01-May-2008  simonb Be consistent with #define<space-or-tab>.
 1.13  26-Apr-2008  jmcneill branches: 1.13.2;
Use isareg constants in thinkpad_brightness_read where possible
 1.12  29-Feb-2008  dyoung branches: 1.12.2;
Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.11  28-Jan-2008  jmcneill branches: 1.11.2; 1.11.6;
The Thinkpad T61/x61 family powers off the USB power resource on resume
from S3 sleep. Until we get proper ACPI power resource support, simply
call \\_SB.PCI0.LPC.EC.PUBS._ON() on resume if the method exists.

Fixes kern/37279 by Steven M Bellovin.
 1.10  09-Jan-2008  xtraeme branches: 1.10.2;
Remove useless returns at the end of void functions.
 1.9  22-Dec-2007  jmcneill branches: 1.9.2; 1.9.4; 1.9.6; 1.9.8;
Move display switching out of the kernel; deliver this (and other) events
to sysmon so a powerd script can handle them.
 1.8  22-Dec-2007  jmcneill Add experimental display switching support.
 1.7  22-Dec-2007  jmcneill Only toggle bluetooth when the wireless button is pressed, simplifies
things and it seems I forgot that my laptop has a separate wifi switch.
 1.6  21-Dec-2007  jmcneill Add support for the WLAN / Bluetooth switch.
 1.5  21-Dec-2007  jmcneill Hook Thinkpad temperature sensors into envsys:

$ envstat -d thinkpad0
TMP0: 46.000 degC
TMP1: 39.000 degC
TMP2: 32.000 degC
TMP3: N/A
TMP4: 50.000 degC
TMP5: N/A
TMP6: 29.000 degC
TMP7: N/A
 1.4  21-Dec-2007  jmcneill Handle notifications in a separate thread, and ensure that the BIOS doesn't
try to play trick with us when we are trying to manage the brightness
keys.
 1.3  21-Dec-2007  jmcneill Typo in previous.
 1.2  21-Dec-2007  jmcneill Handle key repeat, and only match if MHKV returns an HKEY version we have
a chance of supporting.
 1.1  21-Dec-2007  jmcneill Add Thinkpad ACPI driver, for controlling hotkeys and display brightness.
 1.9.8.3  23-Mar-2008  matt sync with HEAD
 1.9.8.2  09-Jan-2008  matt sync with HEAD
 1.9.8.1  22-Dec-2007  matt file thinkpad_acpi.c was added on branch matt-armv6 on 2008-01-09 01:52:21 +0000
 1.9.6.3  10-Jan-2008  bouyer Sync with HEAD
 1.9.6.2  02-Jan-2008  bouyer Sync with HEAD
 1.9.6.1  22-Dec-2007  bouyer file thinkpad_acpi.c was added on branch bouyer-xeni386 on 2008-01-02 21:53:52 +0000
 1.9.4.2  26-Dec-2007  ad Sync with head.
 1.9.4.1  22-Dec-2007  ad file thinkpad_acpi.c was added on branch vmlocking2 on 2007-12-26 19:17:19 +0000
 1.9.2.2  18-Feb-2008  mjf Sync with HEAD.
 1.9.2.1  22-Dec-2007  mjf file thinkpad_acpi.c was added on branch mjf-devfs on 2008-02-18 21:05:36 +0000
 1.10.2.4  17-Mar-2008  yamt sync with head.
 1.10.2.3  04-Feb-2008  yamt sync with head.
 1.10.2.2  21-Jan-2008  yamt sync with head
 1.10.2.1  09-Jan-2008  yamt file thinkpad_acpi.c was added on branch yamt-lazymbuf on 2008-01-21 09:42:34 +0000
 1.11.6.3  17-Jan-2009  mjf Sync with HEAD.
 1.11.6.2  02-Jun-2008  mjf Sync with HEAD.
 1.11.6.1  03-Apr-2008  mjf Sync with HEAD.
 1.11.2.1  24-Mar-2008  keiichi sync with head.
 1.12.2.1  18-May-2008  yamt sync with head.
 1.13.2.5  11-Aug-2010  yamt sync with head.
 1.13.2.4  11-Mar-2010  yamt sync with head
 1.13.2.3  16-May-2009  yamt sync with head
 1.13.2.2  04-May-2009  yamt sync with head.
 1.13.2.1  16-May-2008  yamt sync with head.
 1.15.6.2  13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.15.6.1  19-Oct-2008  haad Sync with HEAD.
 1.16.4.1  20-Nov-2008  snj Pull up following revision(s) (requested by hans in ticket #90):
sys/dev/acpi/thinkpad_acpi.c: revision 1.17
Make the driver work (except for setting display brightness) on older
machines by removing the check for the CMOS method from thinkpad_match.
OK by jmcneill.
 1.16.2.2  03-Mar-2009  skrll Sync with HEAD.
 1.16.2.1  19-Jan-2009  skrll Sync with HEAD.
 1.17.4.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.25.2.2  06-Nov-2010  uebayasi Sync with HEAD.
 1.25.2.1  30-Apr-2010  uebayasi Sync with HEAD.
 1.28.2.4  12-Jun-2011  rmind sync with head
 1.28.2.3  21-Apr-2011  rmind sync with head
 1.28.2.2  05-Mar-2011  rmind sync with head
 1.28.2.1  30-May-2010  rmind sync with head
 1.32.2.1  06-Jun-2011  jruoho Sync with HEAD.
 1.33.2.1  17-Feb-2011  bouyer Sync with HEAD
 1.37.2.1  23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.39.8.1  11-Apr-2014  msaitoh Pull up following revision(s) (requested by riastradh in ticket #1039):
sys/dev/acpi/thinkpad_acpi.c: revision 1.42
Match LEN0068 in thinkpad(4) too, as newer Thinkpads report.
Tested on a W530. Lots of stuff is missing, though.
 1.39.2.3  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.39.2.2  16-Jan-2013  yamt sync with (a bit old) head
 1.39.2.1  30-Oct-2012  yamt sync with head
 1.41.2.3  03-Dec-2017  jdolecek update from HEAD
 1.41.2.2  23-Jun-2013  tls resync from head
 1.41.2.1  25-Feb-2013  tls resync with head
 1.44.12.2  22-Apr-2016  skrll Sync with HEAD
 1.44.12.1  06-Jun-2015  skrll Sync with HEAD
 1.46.24.2  03-Aug-2022  martin Pull up following revision(s) (requested by riastradh in ticket #1490):

sys/dev/acpi/thinkpad_acpi.c: revision 1.48

With the recent change of the EC address space handler, we no longer get
an ACPI_INTEGER in host byte order but a byte sized buffer with little
endian data.

Extract only the low 8 bits from buffer to get the fan speed again.
 1.46.24.1  31-Jan-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #672):

sys/dev/ic/tulip.c: revision 1.198
sys/dev/pci/if_jme.c: revision 1.45
sys/dev/pci/agp.c: revision 1.86
sys/dev/pci/if_lii.c: revision 1.27
sys/dev/acpi/thinkpad_acpi.c: revision 1.47
sys/dev/scsipi/scsipi_base.c: revision 1.183
sys/dev/ic/aic6915reg.h: revision 1.6

Fix undefined behavior in thinkpad_mask_init(). Found by kUBSan.

Use unsigned when initialize the transmit completion ring to avoid undefined
behavior. Found by kUBSan.

Avoid undefined behavior when setting multicast address. found by kUBSan.

Use unsigned to avoid undefined behavior in agpattach(). Found by kUBSan.

Avoid undefined behavior in jme_mii_write(). Found by kUBSan.

Use unsigned to avoid undefined behavior in lii_setmulti().

Use unsigned to avoid undefined behavior in scsipi_{get,put}_tag().

Found by kUBSan.
 1.46.18.1  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.48.2.1  03-Apr-2021  thorpej Sync with HEAD.
 1.49.6.1  31-May-2021  cjep sync with head
 1.49.4.1  17-Jun-2021  thorpej Sync w/ HEAD.

RSS XML Feed