From nobody Thu Oct 12 15:32:18 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4S5ttC2Q2Yz4wWjZ; Thu, 12 Oct 2023 15:32:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4S5ttC14Ltz4dT3; Thu, 12 Oct 2023 15:32:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697124739; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JZw/NRNJDaGsDA70PC8/W1TCj7FDKSb87cMMP6y0hv0=; b=r/SEKLBuhAe4rpNkgNUF24N+tnxUCYDppLd43tiCxIZTehjwb01njXoRqvfNDPUh6z0BCS Ov3yg4GjFtmfl7JyLp1a4cNrNvl0neSPNy8HAriP8ZcvrFDBWgquOqeDagpq4jQWE4Zugg kzLejuDJ8OIO0838aPOmdUJwZa3+xP3FwHy1qMusBX1oXNqT2cwhfexIXMTA5WOCUpk07G 60x1R0eMyTm7/fQkD9x+BzlTS6egUMC/AXo/rtMLesd8dydgVKRq4XbrcYTvklyFTkfKlf MdQLX25jAPSqamaJliPkxm3IijghXU95rFP8h5vV9uzM3BnA9CzjHT4G8cB9Cw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1697124739; a=rsa-sha256; cv=none; b=AVtX6YmMMryFA9hDYXLdTDA+9EyyJLhN6t/GuScexVgKBgCrp4QA/D1I2LcqnRVRHu+aAU 6OTpQu9gmWQBgrzNkjkFGC2OYdUvOGDWmpbvBmtPErPyIKkalZXZjlhNPo2zFtaX+O3jLn WClhseN6qf8vRyQ4KJ57A2i9JWcQ1KGPLm3B+CivLFGfnmWRGjLC+KO/NVy2tHzEuso+jc EacIr1dwTeVFj3QixAsFCEqpEEKcWeK/bf3AVte8WIgtHJXX5L9maRW3YvVBHXw2f8+Y++ Cz0FFPfqOUPSZ9rD+EYpadTX3TsOdVkkmEEf3O4U+Ig/9jIjYcH3wrw0jTLVYg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697124739; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JZw/NRNJDaGsDA70PC8/W1TCj7FDKSb87cMMP6y0hv0=; b=W89miTySVPI7jIdUWd/QysGAn4KpzMo3P3dssQ+GyM66xr8BzvKZcm9D76jI9b7gAqO/gN 4Jh+8yLmlgnzvFxojJpekDmtTrhnMMupIS/aI+30KEsStDhw8DP9l9Bc2yMw/qyLUXt2mk Z/xYw73PlwqCJWjTohdX3swwMX07q6XifSY0zNkzmCsyUDm9Z96IAVQcXqXGpf27zyVEUO Lr080Ggg5GRPDFzBAqQ4yluK0sgTthqNZKHe5RBToE2UXRX7J9sZsAfLiA/9Jfu5MxntCl GTqjJ5KukTL3nNbBOar8FFuCh/vZ0QWCutwMWKj1r3082sIV2wfkcKE+FG8rwQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4S5ttC08BCz18sl; Thu, 12 Oct 2023 15:32:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 39CFWI0X006703; Thu, 12 Oct 2023 15:32:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39CFWI2J006700; Thu, 12 Oct 2023 15:32:18 GMT (envelope-from git) Date: Thu, 12 Oct 2023 15:32:18 GMT Message-Id: <202310121532.39CFWI2J006700@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Gallatin Subject: git: be91b4797e2c - main - acpi_ged: Handle events directly List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gallatin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: be91b4797e2c8f3440f6fe3aac7e246886f9ebca Auto-Submitted: auto-generated The branch main has been updated by gallatin: URL: https://cgit.FreeBSD.org/src/commit/?id=be91b4797e2c8f3440f6fe3aac7e246886f9ebca commit be91b4797e2c8f3440f6fe3aac7e246886f9ebca Author: Andrew Gallatin AuthorDate: 2023-10-12 15:15:06 +0000 Commit: Andrew Gallatin CommitDate: 2023-10-12 15:27:44 +0000 acpi_ged: Handle events directly Handle ged interrupts directly from the interrupt handler, while the interrupt source is masked, so as to conform with the acpi spec, and avoid spurious interrupts and lockups on boot. When an acpi ged interrupt is encountered, the spec requires the os (as stated in 5.6.4: General Purpose Event Handling) to leave the interrupt source masked until it runs the EOI handler. This is not a good fit for our method of queuing the work (including the EOI ack of the interrupt), via the AcpiOsExecute() taskqueue mechanism. Note this fixes a bug where an arm64 server could lock up if it encountered a ged interrupt at boot. The lockup was due to running on a single core (due to arm64 not using EARLY_AP_STARTUP), and due to that core encountering a new interrupt each time the interrupt handler unmasked the interrupt source, and having the EOI queued on a taskqueue which never got a chance to run. This is also possible on any platform when using just a single processor. The symptom of this is a lockup at boot, with: "AcpiOsExecute: failed to enqueue task, consider increasing the debug.acpi.max_tasks tunable" scrolling on console. Similarly, spurious interrupts would occur when running with multiple cores, because it was likely that the interrupt would fire again immediately, before the ged task could be run, and before an EOI could be sent to lower the interrupt line. I would typically see 3-5 copies of every ged event due to this issue. This adds a tunable, debug.acpi.ged_defer, which can be set to 1 to restore the old behavior. This was done because acpi is a complex system, and it may be theoretically possible something the ged handler does may sleep (though I cannot easily find anthing by inspection). MFC after: 1 month Reviewed by: andrew, jhb, imp Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D42158 --- sys/dev/acpica/acpi_ged.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sys/dev/acpica/acpi_ged.c b/sys/dev/acpica/acpi_ged.c index e7dcc1ffb0ac..23e125f277c5 100644 --- a/sys/dev/acpica/acpi_ged.c +++ b/sys/dev/acpica/acpi_ged.c @@ -81,6 +81,11 @@ static driver_t acpi_ged_driver = { DRIVER_MODULE(acpi_ged, acpi, acpi_ged_driver, 0, 0); MODULE_DEPEND(acpi_ged, acpi, 1, 1, 1); +static int acpi_ged_defer; +SYSCTL_INT(_debug_acpi, OID_AUTO, ged_defer, CTLFLAG_RWTUN, + &acpi_ged_defer, 0, + "Handle ACPI GED via a task, rather than in the ISR"); + static void acpi_ged_evt(void *arg) { @@ -92,7 +97,12 @@ acpi_ged_evt(void *arg) static void acpi_ged_intr(void *arg) { - AcpiOsExecute(OSL_GPE_HANDLER, acpi_ged_evt, arg); + struct acpi_ged_event *evt = arg; + + if (acpi_ged_defer) + AcpiOsExecute(OSL_GPE_HANDLER, acpi_ged_evt, arg); + else + AcpiEvaluateObject(evt->ah, NULL, &evt->args, NULL); } static int acpi_ged_probe(device_t dev)