Skip to content

Commit 06bf78f

Browse files
committed
ACPI: bus: Rework printing debug messages on _OSC errors
Instead of using one function, acpi_print_osc_error(), for printing a debug message and dumping the _OSC request data in one go, use acpi_handle_debug() directly for printing messages and a separate function called acpi_dump_osc_data() for dumping the _OSC request data before printing one or more of them. This avoids * dumping _OSC request data multiple times when there are multiple error bits set in the return buffer, * wrapping message lines on terminals with 80 character line width, * mixing up unrelated messages by printing full lines only, and generally helps to make the messages easier to parse. Also, use %pUL for UUID printing instead of printing UUIDs as strings and include the revision number into the dumped _OSC request data. This is how the debug printout looks like when the OSC_REQUEST_ERROR and OSC_INVALID_REVISION_ERROR bits are set in the return buffer before the change: ACPI: \_SB_: ACPI: (0811B06E-4A27-44F9-8D60-3CBBC22E7B48): _OSC request failed ACPI: _OSC request data: ACPI: 1 ACPI: 2e7eff ACPI: ACPI: \_SB_: ACPI: (0811B06E-4A27-44F9-8D60-3CBBC22E7B48): _OSC invalid revision ACPI: _OSC request data: ACPI: 1 ACPI: 2e7eff ACPI: and this is how it is going to look like afterward: ACPI: \_SB_: ACPI: _OSC: UUID: 0811B06E-4A27-44F9-8D60-3CBBC22E7B48, rev: 1 ACPI: \_SB_: ACPI: _OSC: capabilities DWORD 0: [00000001] ACPI: \_SB_: ACPI: _OSC: capabilities DWORD 1: [002e7eff] ACPI: \_SB_: ACPI: _OSC: request failed ACPI: \_SB_: ACPI: _OSC: invalid revision Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Link: https://patch.msgid.link/10794028.nUPlyArG6x@rafael.j.wysocki
1 parent bb203a6 commit 06bf78f

1 file changed

Lines changed: 16 additions & 19 deletions

File tree

drivers/acpi/bus.c

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -180,18 +180,16 @@ void acpi_bus_detach_private_data(acpi_handle handle)
180180
}
181181
EXPORT_SYMBOL_GPL(acpi_bus_detach_private_data);
182182

183-
static void acpi_print_osc_error(acpi_handle handle,
184-
struct acpi_osc_context *context, char *error)
183+
static void acpi_dump_osc_data(acpi_handle handle, const guid_t *guid, int rev,
184+
struct acpi_buffer *cap)
185185
{
186+
u32 *capbuf = cap->pointer;
186187
int i;
187188

188-
acpi_handle_debug(handle, "(%s): %s\n", context->uuid_str, error);
189-
190-
pr_debug("_OSC request data:");
191-
for (i = 0; i < context->cap.length; i += sizeof(u32))
192-
pr_debug(" %x", *((u32 *)(context->cap.pointer + i)));
193-
194-
pr_debug("\n");
189+
acpi_handle_debug(handle, "_OSC: UUID: %pUL, rev: %d\n", guid, rev);
190+
for (i = 0; i < cap->length / sizeof(u32); i++)
191+
acpi_handle_debug(handle, "_OSC: capabilities DWORD %i: [%08x]\n",
192+
i, capbuf[i]);
195193
}
196194

197195
#define OSC_ERROR_MASK (OSC_REQUEST_ERROR | OSC_INVALID_UUID_ERROR | \
@@ -239,8 +237,8 @@ acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context)
239237
out_obj = output.pointer;
240238
if (out_obj->type != ACPI_TYPE_BUFFER
241239
|| out_obj->buffer.length != context->cap.length) {
242-
acpi_print_osc_error(handle, context,
243-
"_OSC evaluation returned wrong type");
240+
acpi_dump_osc_data(handle, &guid, context->rev, &context->cap);
241+
acpi_handle_debug(handle, "_OSC: evaluation returned wrong type");
244242
status = AE_TYPE;
245243
goto out_kfree;
246244
}
@@ -261,9 +259,9 @@ acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context)
261259
*/
262260
bool fail = !!(capbuf[OSC_QUERY_DWORD] & OSC_QUERY_ENABLE);
263261

262+
acpi_dump_osc_data(handle, &guid, context->rev, &context->cap);
264263
if (errors & OSC_INVALID_UUID_ERROR) {
265-
acpi_print_osc_error(handle, context,
266-
"_OSC invalid UUID");
264+
acpi_handle_debug(handle, "_OSC: invalid UUID");
267265
/*
268266
* Always fail if this bit is set because it means that
269267
* the request could not be processed.
@@ -272,14 +270,13 @@ acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context)
272270
goto out_kfree;
273271
}
274272
if (errors & OSC_REQUEST_ERROR)
275-
acpi_print_osc_error(handle, context,
276-
"_OSC request failed");
273+
acpi_handle_debug(handle, "_OSC: request failed");
274+
277275
if (errors & OSC_INVALID_REVISION_ERROR)
278-
acpi_print_osc_error(handle, context,
279-
"_OSC invalid revision");
276+
acpi_handle_debug(handle, "_OSC: invalid revision");
277+
280278
if (errors & OSC_CAPABILITIES_MASK_ERROR)
281-
acpi_print_osc_error(handle, context,
282-
"_OSC capability bits masked");
279+
acpi_handle_debug(handle, "_OSC: capability bits masked");
283280

284281
if (fail) {
285282
status = AE_ERROR;

0 commit comments

Comments
 (0)