From: Jonathan Cameron <jonathan.cameron@huawei.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
Linux ACPI <linux-acpi@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Cc: 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: Re: [PATCH v2.1 3/8] ACPI: bus: Split _OSC evaluation out of acpi_run_osc()
Date: Tue, 23 Dec 2025 11:18:13 +0000 [thread overview]
Message-ID: <20251223111813.00000d67@huawei.com> (raw)
In-Reply-To: <22963770.EfDdHjke4D@rafael.j.wysocki>
On Mon, 22 Dec 2025 20:14:16 +0100
"Rafael J. Wysocki" <rafael@kernel.org> wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> Split a function for evaluating _OSC called acpi_eval_osc() out of
> acpi_run_osc() to facilitate subsequent changes and add some more
> parameters sanity checks to the latter.
>
> No intentional functional impact.
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Hi Rafael,
There is a little bit of reformatting / whitespace cleanup in here
that makes it a tiny bit harder to review than if that had been
done separately. Not worth a respin though.
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
> ---
>
> v1 -> v2.1:
> * Fix typo in the changelog (Jonathan).
> * Use at_least to enforce compiler checking of in_params[] size instead of
> using "static" directly (Jonathan).
>
> ---
> drivers/acpi/bus.c | 91 ++++++++++++++++++++++++++++++-----------------------
> 1 file changed, 53 insertions(+), 38 deletions(-)
>
> --- a/drivers/acpi/bus.c
> +++ b/drivers/acpi/bus.c
> @@ -196,52 +196,67 @@ static void acpi_dump_osc_data(acpi_hand
> OSC_INVALID_REVISION_ERROR | \
> OSC_CAPABILITIES_MASK_ERROR)
>
> -acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context)
> +static int acpi_eval_osc(acpi_handle handle, guid_t *guid, int rev,
> + struct acpi_buffer *cap,
> + union acpi_object in_params[at_least 4],
> + struct acpi_buffer *output)
> {
> - u32 errors, *capbuf = context->cap.pointer;
> - acpi_status status;
> struct acpi_object_list input;
> - union acpi_object in_params[4];
> union acpi_object *out_obj;
> - guid_t guid;
> - struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL};
> -
> - if (!context)
> - return AE_ERROR;
> - if (guid_parse(context->uuid_str, &guid))
> - return AE_ERROR;
> - context->ret.length = ACPI_ALLOCATE_BUFFER;
> - context->ret.pointer = NULL;
> + acpi_status status;
>
> - /* Setting up input parameters */
> - input.count = 4;
> + in_params[0].type = ACPI_TYPE_BUFFER;
> + in_params[0].buffer.length = sizeof(*guid);
> + in_params[0].buffer.pointer = (u8 *)guid;
> + in_params[1].type = ACPI_TYPE_INTEGER;
> + in_params[1].integer.value = rev;
> + in_params[2].type = ACPI_TYPE_INTEGER;
> + in_params[2].integer.value = cap->length / sizeof(u32);
> + in_params[3].type = ACPI_TYPE_BUFFER;
> + in_params[3].buffer.length = cap->length;
> + in_params[3].buffer.pointer = cap->pointer;
> input.pointer = in_params;
> - in_params[0].type = ACPI_TYPE_BUFFER;
> - in_params[0].buffer.length = 16;
> - in_params[0].buffer.pointer = (u8 *)&guid;
> - in_params[1].type = ACPI_TYPE_INTEGER;
> - in_params[1].integer.value = context->rev;
> - in_params[2].type = ACPI_TYPE_INTEGER;
> - in_params[2].integer.value = context->cap.length/sizeof(u32);
> - in_params[3].type = ACPI_TYPE_BUFFER;
> - in_params[3].buffer.length = context->cap.length;
> - in_params[3].buffer.pointer = context->cap.pointer;
Not sure I'd have made this formatting change in here because it
'might' have hidden real functional changes from reviewers.
> -
> - status = acpi_evaluate_object(handle, "_OSC", &input, &output);
> - if (ACPI_FAILURE(status))
> - return status;
> + input.count = 4;
>
> - if (!output.length)
> - return AE_NULL_OBJECT;
> + output->length = ACPI_ALLOCATE_BUFFER;
> + output->pointer = NULL;
>
> - out_obj = output.pointer;
> - if (out_obj->type != ACPI_TYPE_BUFFER
> - || out_obj->buffer.length != context->cap.length) {
> - acpi_dump_osc_data(handle, &guid, context->rev, &context->cap);
> - acpi_handle_debug(handle, "_OSC: evaluation returned wrong type");
> - status = AE_TYPE;
> - goto out_kfree;
> + status = acpi_evaluate_object(handle, "_OSC", &input, output);
> + if (ACPI_FAILURE(status) || !output->length)
> + return -ENODATA;
> +
> + out_obj = output->pointer;
> + if (out_obj->type != ACPI_TYPE_BUFFER ||
> + out_obj->buffer.length != cap->length) {
> + acpi_handle_debug(handle, "Invalid _OSC return buffer\n");
> + acpi_dump_osc_data(handle, guid, rev, cap);
> + ACPI_FREE(out_obj);
> + return -ENODATA;
> }
> +
> + return 0;
> +}
next prev parent reply other threads:[~2025-12-23 11:18 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 [this message]
2025-12-22 19:17 ` [PATCH v2.1 4/8] ACPI: bus: Split _OSC error processing " Rafael J. Wysocki
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=20251223111813.00000d67@huawei.com \
--to=jonathan.cameron@huawei.com \
--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=rafael@kernel.org \
--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