mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-27 03:10:12 +00:00
![Tong Zhang](/assets/img/avatar_default.png)
when acpi=off is provided in bootarg, kernel crash with [ 1.252739] BUG: kernel NULL pointer dereference, address: 0000000000000018 [ 1.258308] Call Trace: [ 1.258490] ? acpi_walk_namespace+0x147/0x147 [ 1.258770] acpi_get_devices+0xe4/0x137 [ 1.258921] ? drm_core_init+0xc0/0xc0 [drm] [ 1.259108] detect_thinkpad_privacy_screen+0x5e/0xa8 [drm] [ 1.259337] drm_privacy_screen_lookup_init+0xe/0xe85 [drm] The reason is that acpi_walk_namespace expects acpi related stuff initialized but in fact it wouldn't when acpi is set to off. In this case we should honor acpi=off in detect_thinkpad_privacy_screen(). Signed-off-by: Tong Zhang <ztong0001@gmail.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20220123091004.763775-1-ztong0001@gmail.com
89 lines
2.1 KiB
C
89 lines
2.1 KiB
C
// SPDX-License-Identifier: MIT
|
|
/*
|
|
* Copyright (C) 2020 Red Hat, Inc.
|
|
*
|
|
* Authors:
|
|
* Hans de Goede <hdegoede@redhat.com>
|
|
*/
|
|
|
|
#include <linux/acpi.h>
|
|
#include <drm/drm_privacy_screen_machine.h>
|
|
|
|
#ifdef CONFIG_X86
|
|
static struct drm_privacy_screen_lookup arch_lookup;
|
|
|
|
struct arch_init_data {
|
|
struct drm_privacy_screen_lookup lookup;
|
|
bool (*detect)(void);
|
|
};
|
|
|
|
#if IS_ENABLED(CONFIG_THINKPAD_ACPI)
|
|
static acpi_status __init acpi_set_handle(acpi_handle handle, u32 level,
|
|
void *context, void **return_value)
|
|
{
|
|
*(acpi_handle *)return_value = handle;
|
|
return AE_CTRL_TERMINATE;
|
|
}
|
|
|
|
static bool __init detect_thinkpad_privacy_screen(void)
|
|
{
|
|
union acpi_object obj = { .type = ACPI_TYPE_INTEGER };
|
|
struct acpi_object_list args = { .count = 1, .pointer = &obj, };
|
|
acpi_handle ec_handle = NULL;
|
|
unsigned long long output;
|
|
acpi_status status;
|
|
|
|
if (acpi_disabled)
|
|
return false;
|
|
|
|
/* Get embedded-controller handle */
|
|
status = acpi_get_devices("PNP0C09", acpi_set_handle, NULL, &ec_handle);
|
|
if (ACPI_FAILURE(status) || !ec_handle)
|
|
return false;
|
|
|
|
/* And call the privacy-screen get-status method */
|
|
status = acpi_evaluate_integer(ec_handle, "HKEY.GSSS", &args, &output);
|
|
if (ACPI_FAILURE(status))
|
|
return false;
|
|
|
|
return (output & 0x10000) ? true : false;
|
|
}
|
|
#endif
|
|
|
|
static const struct arch_init_data arch_init_data[] __initconst = {
|
|
#if IS_ENABLED(CONFIG_THINKPAD_ACPI)
|
|
{
|
|
.lookup = {
|
|
.dev_id = NULL,
|
|
.con_id = NULL,
|
|
.provider = "privacy_screen-thinkpad_acpi",
|
|
},
|
|
.detect = detect_thinkpad_privacy_screen,
|
|
},
|
|
#endif
|
|
};
|
|
|
|
void __init drm_privacy_screen_lookup_init(void)
|
|
{
|
|
int i;
|
|
|
|
for (i = 0; i < ARRAY_SIZE(arch_init_data); i++) {
|
|
if (!arch_init_data[i].detect())
|
|
continue;
|
|
|
|
pr_info("Found '%s' privacy-screen provider\n",
|
|
arch_init_data[i].lookup.provider);
|
|
|
|
/* Make a copy because arch_init_data is __initconst */
|
|
arch_lookup = arch_init_data[i].lookup;
|
|
drm_privacy_screen_lookup_add(&arch_lookup);
|
|
break;
|
|
}
|
|
}
|
|
|
|
void drm_privacy_screen_lookup_exit(void)
|
|
{
|
|
if (arch_lookup.provider)
|
|
drm_privacy_screen_lookup_remove(&arch_lookup);
|
|
}
|
|
#endif /* ifdef CONFIG_X86 */
|