From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Linux ACPI <linux-acpi@vger.kernel.org>,
Jonathan Cameron <jonathan.cameron@huawei.com>
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 v2.1 4/8] ACPI: bus: Split _OSC error processing out of acpi_run_osc()
Date: Mon, 22 Dec 2025 20:17:29 +0100 [thread overview]
Message-ID: <6135328.MhkbZ0Pkbq@rafael.j.wysocki> (raw)
In-Reply-To: <2413407.ElGaqSPkdT@rafael.j.wysocki>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Split a function for processing _OSC errors called acpi_osc_error_check()
out of acpi_run_osc() to facilitate subsequent changes.
No intentional functional impact.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
---
v1 -> v2.1:
* Rebase on the modified first patch.
* Fix typo in the changelog (Jonathan).
* Expand the comment regarding ignoring OSC_CAPABILITIES_MASK_ERROR
when OSC_QUERY_DWORD is set (Jonathan).
* Add R-by from Jonathan.
---
drivers/acpi/bus.c | 95 +++++++++++++++++++++++++++++------------------------
1 file changed, 53 insertions(+), 42 deletions(-)
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -237,13 +237,60 @@ static int acpi_eval_osc(acpi_handle han
return 0;
}
+static bool acpi_osc_error_check(acpi_handle handle, guid_t *guid, int rev,
+ struct acpi_buffer *cap, u32 *retbuf)
+{
+ /* Only take defined error bits into account. */
+ u32 errors = retbuf[OSC_QUERY_DWORD] & OSC_ERROR_MASK;
+ u32 *capbuf = cap->pointer;
+ bool fail;
+
+ /*
+ * If OSC_QUERY_ENABLE is set, ignore the "capabilities masked"
+ * bit because it merely means that some features have not been
+ * acknowledged which is not unexpected.
+ */
+ if (capbuf[OSC_QUERY_DWORD] & OSC_QUERY_ENABLE)
+ errors &= ~OSC_CAPABILITIES_MASK_ERROR;
+
+ if (!errors)
+ return false;
+
+ acpi_dump_osc_data(handle, guid, rev, cap);
+ /*
+ * As a rule, fail only if OSC_QUERY_ENABLE is set because otherwise the
+ * acknowledged features need to be controlled.
+ */
+ fail = !!(capbuf[OSC_QUERY_DWORD] & OSC_QUERY_ENABLE);
+
+ if (errors & OSC_REQUEST_ERROR)
+ acpi_handle_debug(handle, "_OSC: request failed\n");
+
+ if (errors & OSC_INVALID_UUID_ERROR) {
+ acpi_handle_debug(handle, "_OSC: invalid UUID\n");
+ /*
+ * Always fail if this bit is set because it means that the
+ * request could not be processed.
+ */
+ fail = true;
+ }
+
+ if (errors & OSC_INVALID_REVISION_ERROR)
+ acpi_handle_debug(handle, "_OSC: invalid revision\n");
+
+ if (errors & OSC_CAPABILITIES_MASK_ERROR)
+ acpi_handle_debug(handle, "_OSC: capability bits masked\n");
+
+ return fail;
+}
+
acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context)
{
- u32 errors, *capbuf = context->cap.pointer;
union acpi_object in_params[4], *out_obj;
struct acpi_buffer output;
acpi_status status = AE_OK;
guid_t guid;
+ u32 *retbuf;
int ret;
if (!context || !context->cap.pointer ||
@@ -257,51 +304,15 @@ acpi_status acpi_run_osc(acpi_handle han
return AE_ERROR;
out_obj = output.pointer;
- /* 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 because it merely means that some features have not been
- * acknowledged which is not unexpected.
- */
- if (capbuf[OSC_QUERY_DWORD] & OSC_QUERY_ENABLE)
- errors &= ~OSC_CAPABILITIES_MASK_ERROR;
+ retbuf = (u32 *)out_obj->buffer.pointer;
- if (errors) {
- /*
- * As a rule, fail only if OSC_QUERY_ENABLE is set because
- * otherwise the acknowledged features need to be controlled.
- */
- bool fail = !!(capbuf[OSC_QUERY_DWORD] & OSC_QUERY_ENABLE);
-
- acpi_dump_osc_data(handle, &guid, context->rev, &context->cap);
- if (errors & OSC_INVALID_UUID_ERROR) {
- acpi_handle_debug(handle, "_OSC: invalid UUID");
- /*
- * Always fail if this bit is set because it means that
- * the request could not be processed.
- */
- fail = true;
- goto out_kfree;
- }
- if (errors & OSC_REQUEST_ERROR)
- acpi_handle_debug(handle, "_OSC: request failed");
-
- if (errors & OSC_INVALID_REVISION_ERROR)
- acpi_handle_debug(handle, "_OSC: invalid revision");
-
- if (errors & OSC_CAPABILITIES_MASK_ERROR)
- acpi_handle_debug(handle, "_OSC: capability bits masked");
-
- if (fail) {
- status = AE_ERROR;
- goto out_kfree;
- }
+ if (acpi_osc_error_check(handle, &guid, context->rev, &context->cap, retbuf)) {
+ status = AE_ERROR;
+ goto out_kfree;
}
context->ret.length = out_obj->buffer.length;
- context->ret.pointer = kmemdup(out_obj->buffer.pointer,
- context->ret.length, GFP_KERNEL);
+ context->ret.pointer = kmemdup(retbuf, context->ret.length, GFP_KERNEL);
if (!context->ret.pointer) {
status = AE_NO_MEMORY;
goto out_kfree;
next prev parent reply other threads:[~2025-12-22 19:27 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-22 18:58 [PATCH v2.1 0/8] ACPI: bus: Rework of the \_SB._OSC handling Rafael J. Wysocki
2025-12-22 19:05 ` [PATCH v2.1 1/8] ACPI: bus: Fix handling of _OSC errors in acpi_run_osc() Rafael J. Wysocki
2025-12-23 11:12 ` Jonathan Cameron
2025-12-23 16:13 ` Rafael J. Wysocki
2025-12-22 19:11 ` [PATCH v2.1 2/8] ACPI: bus: Rework printing debug messages on _OSC errors Rafael J. Wysocki
2025-12-23 11:13 ` Jonathan Cameron
2025-12-22 19:14 ` [PATCH v2.1 3/8] ACPI: bus: Split _OSC evaluation out of acpi_run_osc() Rafael J. Wysocki
2025-12-23 11:18 ` Jonathan Cameron
2025-12-22 19:17 ` Rafael J. Wysocki [this message]
2025-12-22 19:18 ` [PATCH v2.1 5/8] ACPI: bus: Rename label and use ACPI_FREE() in acpi_run_osc() Rafael J. Wysocki
2025-12-22 19:21 ` [PATCH v2.1 6/8] ACPI: bus: Rework the handling of \_SB._OSC platform features Rafael J. Wysocki
2025-12-23 11:25 ` Jonathan Cameron
2025-12-22 19:23 ` [PATCH v2.1 7/8] ACPI: bus: Adjust feature mask creation for \_SB._OSC Rafael J. Wysocki
2025-12-23 11:26 ` Jonathan Cameron
2025-12-22 19:26 ` [PATCH v2.1 8/8] ACPI: bus: Rework the handling of \_SB._OSC USB4 features Rafael J. Wysocki
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=6135328.MhkbZ0Pkbq@rafael.j.wysocki \
--to=rafael@kernel.org \
--cc=hansg@kernel.org \
--cc=helgaas@kernel.org \
--cc=jonathan.cameron@huawei.com \
--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