Created attachment 167301 [details] Impl. of ACPI RTC/CMOS interface. FreeBSD base system does not provide an ACPI handler for the PC/AT RTC/CMOS device with PnP ID PNP0B00; on recent HP Envy laptops, the absence of this handler causes suspend/resume and poweroff(8) to hang/fail, emitting e.g. ACPI Error: No handler for Region [RCM0] (0xfffff80005796480) [SystemCMOS] (20150818/evregion-176) ACPI Error: Region SystemCMOS (ID=5) has no handler (20150818/exfldio-317) These HP laptops have BIOSes which attempt to query the RTC date/time registers via ACPI before suspending/powering off. ACPI-5.0 specification section 9.15 describes the ACPI interface to the RTC/CMOS device (atrtc(4) in FreeBSD). I have implemented this ACPI handler; adding this allows poweroff and suspend/resume to occur. At a FreeBSD committer's request, I've also implemented the same patch with additional changes to atrtc(4) to separate the bus functionality from the core functionality.
Created attachment 167302 [details] Impl. of ACPI RTC/CMOS interface with bus/core separation. This version of the patch was requested by a FreeBSD committer. I personally prefer the previous patch to this one; instead the separation should be performed as a new bug.
Please note the upstream received a CMOS handler implementation and the patch was posted here: https://lists.acpica.org/pipermail/devel/2015-May/000698.html Unfortunately, it is still not resolved. https://lists.acpica.org/pipermail/devel/2016-February/000872.html https://lists.acpica.org/pipermail/devel/2016-February/000873.html https://lists.acpica.org/pipermail/devel/2016-February/000874.html If possible, please participate in the discussion.
The upstream thread actually mirrors the evolution of my OSPM patch. I first tried adding code to the ACPICA code, then, based on some helpful suggestions from acpi@, moved it to the atrtc(4) driver. I agree with the last thread post (https://lists.acpica.org/pipermail/devel/2016-February/000874.html) - that support for RTC/CMOS devices belongs in the OSPM, not in the ACPICA. If you look closely at the OP's proposed ACPICA patch, the AcpiOs(Read|Write)Cmos() handlers are no-ops (Read returns 0, Write does nothing). I mean I can toss my $0.02 into the thread, but it'll be little more than "I agree this shouldn't be added to ACPICA"...
(In reply to Anthony Jenkins from comment #3) > If you look closely at the OP's proposed ACPICA patch, the > AcpiOs(Read|Write)Cmos() handlers are no-ops (Read returns 0, Write does > nothing). Actually, those are stubs for userland tools, i.e., acpiexec. FYI, OSPM must provide AcpiOsReadCmos() and AcpiOsWriteCmos(). See sys/dev/acpica/Osd/OsdMemory.c, for example.
BTW, these functions must be MD. So, it should be placed in sys/x86/acpica (please see OsdEnvironment.c) and/or sys/x86/isa/atrtc.c. If the upstream does not want them as official API, then your patch is good. FYI, the official ACPICA API is documented here: https://acpica.org/sites/acpica/files/acpica-reference_17.pdf
(In reply to Anthony Jenkins from comment #1) FYI, the separation is important because ACPI is not mandatory for i386.
(In reply to Jung-uk Kim from comment #6) Ahh, okay I think that makes sense; seemed an arbitrary request before. My bus-separation patch could probably use some work, but it builds and works on my amd64.
I just assumed this was dropped for lack of interest. What are my next steps?
https://reviews.freebsd.org/D19314
A commit references this bug: Author: wulf Date: Sun Mar 10 20:19:44 UTC 2019 New revision: 344982 URL: https://svnweb.freebsd.org/changeset/base/344982 Log: atrtc(4): install ACPI RTC/CMOS operation region handler FreeBSD base system does not provide an ACPI handler for the PC/AT RTC/CMOS device with PnP ID PNP0B00; on some HP laptops, the absence of this handler causes suspend/resume and poweroff(8) to hang or fail [1], [2]. On these laptops EC _REG method queries the RTC date/time registers via ACPI before suspending/powering off. The handler should be registered before acpi_ec driver is loaded. This change adds handler to access CMOS RTC operation region described in section 9.15 of ACPI-6.2 specification [3]. It is installed only for ACPI version of atrtc(4) so it should not affect old ACPI-less i386 systems. It is possible to disable the handler with loader tunable: debug.acpi.disabled=atrtc Informational debugging printf can be enabled by setting hw.acpi.verbose=1 in loader.conf [1] https://wiki.freebsd.org/Laptops/HP_Envy_6Z-1100 [2] https://wiki.freebsd.org/Laptops/HP_Notebook_15-af104ur [3] https://uefi.org/sites/default/files/resources/ACPI_6_2.pdf PR: 207419, 213039 Submitted by: Anthony Jenkins <Scoobi_doo@yahoo.com> Reviewed by: ian Discussed on: acpi@, 2013-2015, several threads MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D19314 Changes: head/sys/x86/isa/atrtc.c
A commit references this bug: Author: wulf Date: Wed Mar 27 19:16:04 UTC 2019 New revision: 345589 URL: https://svnweb.freebsd.org/changeset/base/345589 Log: MFC: r344982, r345022 atrtc(4): install ACPI RTC/CMOS operation region handler FreeBSD base system does not provide an ACPI handler for the PC/AT RTC/CMOS device with PnP ID PNP0B00; on some HP laptops, the absence of this handler causes suspend/resume and poweroff(8) to hang or fail [1], [2]. On these laptops EC _REG method queries the RTC date/time registers via ACPI before suspending/powering off. The handler should be registered before acpi_ec driver is loaded. This change adds handler to access CMOS RTC operation region described in section 9.15 of ACPI-6.2 specification [3]. It is installed only for ACPI version of atrtc(4) so it should not affect old ACPI-less i386 systems. It is possible to disable the handler with loader tunable: debug.acpi.disabled=atrtc Informational debugging printf can be enabled by setting hw.acpi.verbose=1 in loader.conf [1] https://wiki.freebsd.org/Laptops/HP_Envy_6Z-1100 [2] https://wiki.freebsd.org/Laptops/HP_Notebook_15-af104ur [3] https://uefi.org/sites/default/files/resources/ACPI_6_2.pdf PR: 207419, 213039 Submitted by: Anthony Jenkins <Scoobi_doo@yahoo.com> Reviewed by: ian Discussed on: acpi@, 2013-2015, several threads Differential Revision: https://reviews.freebsd.org/D19314 Changes: _U stable/12/ stable/12/sys/x86/isa/atrtc.c
A commit references this bug: Author: wulf Date: Wed Mar 27 19:17:43 UTC 2019 New revision: 345590 URL: https://svnweb.freebsd.org/changeset/base/345590 Log: MFC: r344982, r345022 atrtc(4): install ACPI RTC/CMOS operation region handler FreeBSD base system does not provide an ACPI handler for the PC/AT RTC/CMOS device with PnP ID PNP0B00; on some HP laptops, the absence of this handler causes suspend/resume and poweroff(8) to hang or fail [1], [2]. On these laptops EC _REG method queries the RTC date/time registers via ACPI before suspending/powering off. The handler should be registered before acpi_ec driver is loaded. This change adds handler to access CMOS RTC operation region described in section 9.15 of ACPI-6.2 specification [3]. It is installed only for ACPI version of atrtc(4) so it should not affect old ACPI-less i386 systems. It is possible to disable the handler with loader tunable: debug.acpi.disabled=atrtc Informational debugging printf can be enabled by setting hw.acpi.verbose=1 in loader.conf [1] https://wiki.freebsd.org/Laptops/HP_Envy_6Z-1100 [2] https://wiki.freebsd.org/Laptops/HP_Notebook_15-af104ur [3] https://uefi.org/sites/default/files/resources/ACPI_6_2.pdf PR: 207419, 213039 Submitted by: Anthony Jenkins <Scoobi_doo@yahoo.com> Reviewed by: ian Discussed on: acpi@, 2013-2015, several threads Differential Revision: https://reviews.freebsd.org/D19314 Changes: _U stable/11/ stable/11/sys/x86/isa/atrtc.c
Committed, thanks!