From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Linux ACPI <linux-acpi@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Linux PCI <linux-pci@vger.kernel.org>,
Bjorn Helgaas <helgaas@kernel.org>,
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
Hans de Goede <hansg@kernel.org>,
Mario Limonciello <mario.limonciello@amd.com>
Subject: [PATCH v1 1/8] ACPI: bus: Fix handling of _OSC errors in acpi_run_osc()
Date: Thu, 18 Dec 2025 21:34:26 +0100 [thread overview]
Message-ID: <2261695.irdbgypaU6@rafael.j.wysocki> (raw)
In-Reply-To: <5049211.GXAFRqVoOG@rafael.j.wysocki>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
The handling of _OSC errors in acpi_run_osc() is inconsistent.
For example, if OSC_CAPABILITIES_MASK_ERROR is set in the return buffer
and OSC_QUERY_ENABLE is set in the capabilities buffer, all of the
_OSC errors will be ignored even though some of them indicate that
_OSC evaluation has failed. However, if OSC_QUERY_ENABLE is not set in
the capabilities buffer, all _OSC errors will be reported, but the error
value returned by acpi_run_osc() depends on whether or not
OSC_CAPABILITIES_MASK_ERROR is set in the return buffer.
Adress this by making acpi_run_osc() clear OSC_CAPABILITIES_MASK_ERROR
in the return buffer if OSC_QUERY_ENABLE is set in the capabilities
buffer and then check if any other _OSC errors have been returned. Also
make it use the same error return value for all _OSC errors and print
a message for OSC_CAPABILITIES_MASK_ERROR like for the other error
types.
Moreover, make acpi_run_osc() only take the defined _OSC error bits into
account when checking _OSC errors.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/acpi/bus.c | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -194,6 +194,10 @@ static void acpi_print_osc_error(acpi_ha
pr_debug("\n");
}
+#define OSC_ERROR_MASK (OSC_REQUEST_ERROR | OSC_INVALID_UUID_ERROR | \
+ OSC_INVALID_REVISION_ERROR | \
+ OSC_CAPABILITIES_MASK_ERROR)
+
acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context)
{
acpi_status status;
@@ -240,8 +244,12 @@ acpi_status acpi_run_osc(acpi_handle han
status = AE_TYPE;
goto out_kfree;
}
- /* Need to ignore the bit0 in result code */
- errors = *((u32 *)out_obj->buffer.pointer) & ~(1 << 0);
+ /* Only take defined error bits into account. */
+ errors = *((u32 *)out_obj->buffer.pointer) & OSC_ERROR_MASK;
+ /* If OSC_QUERY_ENABLE is set, ignore the "capabilities masked" bit. */
+ if (((u32 *)context->cap.pointer)[OSC_QUERY_DWORD] & OSC_QUERY_ENABLE)
+ errors &= ~OSC_CAPABILITIES_MASK_ERROR;
+
if (errors) {
if (errors & OSC_REQUEST_ERROR)
acpi_print_osc_error(handle, context,
@@ -252,17 +260,14 @@ acpi_status acpi_run_osc(acpi_handle han
if (errors & OSC_INVALID_REVISION_ERROR)
acpi_print_osc_error(handle, context,
"_OSC invalid revision");
- if (errors & OSC_CAPABILITIES_MASK_ERROR) {
- if (((u32 *)context->cap.pointer)[OSC_QUERY_DWORD]
- & OSC_QUERY_ENABLE)
- goto out_success;
- status = AE_SUPPORT;
- goto out_kfree;
- }
+ if (errors & OSC_CAPABILITIES_MASK_ERROR)
+ acpi_print_osc_error(handle, context,
+ "_OSC capability bits masked");
+
status = AE_ERROR;
goto out_kfree;
}
-out_success:
+
context->ret.length = out_obj->buffer.length;
context->ret.pointer = kmemdup(out_obj->buffer.pointer,
context->ret.length, GFP_KERNEL);
next prev parent reply other threads:[~2025-12-18 20:43 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-18 20:29 [PATCH v1 0/8] ACPI: bus: Rework of the \_SB._OSC handling Rafael J. Wysocki
2025-12-18 20:34 ` Rafael J. Wysocki [this message]
2025-12-19 12:26 ` [PATCH v1 1/8] ACPI: bus: Fix handling of _OSC errors in acpi_run_osc() Jonathan Cameron
2025-12-19 20:38 ` Rafael J. Wysocki
2025-12-19 21:28 ` [PATCH v2] " Rafael J. Wysocki
2025-12-22 11:18 ` Jonathan Cameron
2025-12-22 17:57 ` Rafael J. Wysocki
2025-12-18 20:35 ` [PATCH v1 2/8] ACPI: bus: Rework printing debug messages on _OSC errors Rafael J. Wysocki
2025-12-19 12:33 ` Jonathan Cameron
2025-12-19 17:20 ` Rafael J. Wysocki
2025-12-18 20:36 ` [PATCH v1 3/8] ACPI: bus: Split _OSC evaluation out of acpi_run_osc() Rafael J. Wysocki
2025-12-19 12:44 ` Jonathan Cameron
2025-12-19 17:22 ` Rafael J. Wysocki
2025-12-18 20:36 ` [PATCH v1 4/8] ACPI: bus: Split _OSC error processing " Rafael J. Wysocki
2025-12-19 12:46 ` Jonathan Cameron
2025-12-19 17:24 ` Rafael J. Wysocki
2025-12-18 20:37 ` [PATCH v1 5/8] ACPI: bus: Rename label and use ACPI_FREE() in acpi_run_osc() Rafael J. Wysocki
2025-12-19 12:47 ` Jonathan Cameron
2025-12-18 20:39 ` [PATCH v1 6/8] ACPI: bus: Rework the handling of \_SB._OSC platform features Rafael J. Wysocki
2025-12-19 12:56 ` Jonathan Cameron
2025-12-19 17:48 ` Rafael J. Wysocki
2025-12-18 20:41 ` [PATCH v1 7/8] ACPI: bus: Adjust feature mask creation for \_SB._OSC Rafael J. Wysocki
2025-12-19 12:58 ` Jonathan Cameron
2025-12-18 20:42 ` [PATCH v1 8/8] ACPI: bus: Rework the handling of \_SB._OSC USB4 features Rafael J. Wysocki
2025-12-19 12:59 ` Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2261695.irdbgypaU6@rafael.j.wysocki \
--to=rafael@kernel.org \
--cc=hansg@kernel.org \
--cc=helgaas@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=srinivas.pandruvada@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox