Mario Limonciello
2022-Aug-19 14:25 UTC
[Nouveau] [RFC 0/2] Stop the abuse of Linux-* _OSI strings
3 _OSI strings were introduced in recent years that were intended to workaround very specific problems found on specific systems. The idea was supposed to be that these quirks were only used on those systems, but this proved to be a bad assumption. I've found at least one system in the wild where the vendor using the _OSI string doesn't match the _OSI string and the neither does the use. So this brings a good time to review keeping those strings in the kernel. There are 3 strings that were introduced: Linux-Dell-Video -> Intended for systems with NVIDIA cards that didn't support RTD3 Linux-Lenovo-NV-HDMI-Audio -> Intended for powering on NVIDIA HDMI device Linux-HPI-Hybrid-Graphics -> Intended for changing dGPU output AFAIK the first string is no longer relevant as nouveau now supports RTD3. If that's wrong, this can be changed for the series. The second two strings appear to be non-scalable workarounds. For accomplishing these tasks, registers can be written from kernel drivers or custom ASL can be put behind a _DSM. By forcing either of these two solutions it will better let the Linux kernel control the behavior. Based on the above this series drops the first string and marks the second two strings to only apply to older systems. Link: https://lore.kernel.org/all/54add026bb6f45fd94a2dc2bae4adf9f at AUSX13MPC101.AMER.DELL.COM/T/ Mario Limonciello (2): ACPI: OSI: Remove Linux-Dell-Video _OSI string ACPI: OSI: Deprecate some abused _OSI strings Documentation/firmware-guide/acpi/osi.rst | 24 ++++++++---------- drivers/acpi/osi.c | 31 ++++++++++++----------- 2 files changed, 26 insertions(+), 29 deletions(-) -- 2.34.1
Mario Limonciello
2022-Aug-19 14:25 UTC
[Nouveau] [RFC 1/2] ACPI: OSI: Remove Linux-Dell-Video _OSI string
This string was introduced because drivers for NVIDIA hardware didn't support RTD3 in the past. This is no longer the case, and so vendors shouldn't be using this string to modify ASL anymore. Signed-off-by: Mario Limonciello <mario.limonciello at amd.com> --- drivers/acpi/osi.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/acpi/osi.c b/drivers/acpi/osi.c index 9f6853809138..c2f6b2f553d9 100644 --- a/drivers/acpi/osi.c +++ b/drivers/acpi/osi.c @@ -44,15 +44,6 @@ osi_setup_entries[OSI_STRING_ENTRIES_MAX] __initdata = { {"Processor Device", true}, {"3.0 _SCP Extensions", true}, {"Processor Aggregator Device", true}, - /* - * Linux-Dell-Video is used by BIOS to disable RTD3 for NVidia graphics - * cards as RTD3 is not supported by drivers now. Systems with NVidia - * cards will hang without RTD3 disabled. - * - * Once NVidia drivers officially support RTD3, this _OSI strings can - * be removed if both new and old graphics cards are supported. - */ - {"Linux-Dell-Video", true}, /* * Linux-Lenovo-NV-HDMI-Audio is used by BIOS to power on NVidia's HDMI * audio device which is turned off for power-saving in Windows OS. -- 2.34.1
Mario Limonciello
2022-Aug-19 14:25 UTC
[Nouveau] [RFC 2/2] ACPI: OSI: Deprecate some abused _OSI strings
The Linux-Lenovo-NV-HDMI-Audio and Linux-HPI-Hybrid-Graphics have been seen in the wild being abused by other vendors. If these use cases are still needed for modern laptops, they should be done via kernel drivers instead. As we can't have nice things, mark these strings to only be applied to laptops from 2022 or earlier. This should avoid breaking any older laptops. In the future if the kernel drivers need to call Linux-only ASL for any reason, it could be a custom _DSM used only for Linux or something similar. This approach allows kernel developers to control whether to stop calling the ASL when the deficiency by the kernel is resolved. Signed-off-by: Mario Limonciello <mario.limonciello at amd.com> --- Documentation/firmware-guide/acpi/osi.rst | 24 ++++++++++------------- drivers/acpi/osi.c | 22 +++++++++++++++------ 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/Documentation/firmware-guide/acpi/osi.rst b/Documentation/firmware-guide/acpi/osi.rst index 05869c0045d7..392b982741fe 100644 --- a/Documentation/firmware-guide/acpi/osi.rst +++ b/Documentation/firmware-guide/acpi/osi.rst @@ -41,26 +41,22 @@ But it is likely that they will all eventually be added. What should an OEM do if they want to support Linux and Windows using the same BIOS image? Often they need to do something different for Linux to deal with how Linux is different from Windows. -Here the BIOS should ask exactly what it wants to know: +In this case, the OEM should create custom ASL to be executed by the +Linux kernel and changes to Linux kernel drivers to execute this custom +ASL. The easiest way to accomplish this is to introduce a device specific +method (_DSM) that is called from the Linux kernel. + +In the past the kernel used to support something like: _OSI("Linux-OEM-my_interface_name") where 'OEM' is needed if this is an OEM-specific hook, and 'my_interface_name' describes the hook, which could be a quirk, a bug, or a bug-fix. -In addition, the OEM should send a patch to upstream Linux -via the linux-acpi at vger.kernel.org mailing list. When that patch -is checked into Linux, the OS will answer "YES" when the BIOS -on the OEM's system uses _OSI to ask if the interface is supported -by the OS. Linux distributors can back-port that patch for Linux -pre-installs, and it will be included by all distributions that -re-base to upstream. If the distribution can not update the kernel binary, -they can also add an acpi_osi=Linux-OEM-my_interface_name -cmdline parameter to the boot loader, as needed. - -If the string refers to a feature where the upstream kernel -eventually grows support, a patch should be sent to remove -the string when that support is added to the kernel. +However this was discovered to be abused by other BIOS vendors to change +completely unrelated code on completely unrelated systems. As such it's +been deprecated and any old hooks will not be activated on systems from +2023 or later. That was easy. Read on, to find out how to do it wrong. diff --git a/drivers/acpi/osi.c b/drivers/acpi/osi.c index c2f6b2f553d9..18c339c3f277 100644 --- a/drivers/acpi/osi.c +++ b/drivers/acpi/osi.c @@ -25,6 +25,7 @@ struct acpi_osi_entry { char string[OSI_STRING_LENGTH_MAX]; bool enable; + unsigned int max_bios_year; }; static struct acpi_osi_config { @@ -40,25 +41,29 @@ static struct acpi_osi_config { static struct acpi_osi_config osi_config; static struct acpi_osi_entry osi_setup_entries[OSI_STRING_ENTRIES_MAX] __initdata = { - {"Module Device", true}, - {"Processor Device", true}, - {"3.0 _SCP Extensions", true}, - {"Processor Aggregator Device", true}, + {"Module Device", true, 0}, + {"Processor Device", true, 0}, + {"3.0 _SCP Extensions", true, 0}, + {"Processor Aggregator Device", true, 0}, /* * Linux-Lenovo-NV-HDMI-Audio is used by BIOS to power on NVidia's HDMI * audio device which is turned off for power-saving in Windows OS. * This power management feature observed on some Lenovo Thinkpad * systems which will not be able to output audio via HDMI without * a BIOS workaround. + * + * This _OSI string is only applied to systems from 2022 or earlier. */ - {"Linux-Lenovo-NV-HDMI-Audio", true}, + {"Linux-Lenovo-NV-HDMI-Audio", true, 2022}, /* * Linux-HPI-Hybrid-Graphics is used by BIOS to enable dGPU to * output video directly to external monitors on HP Inc. mobile * workstations as Nvidia and AMD VGA drivers provide limited * hybrid graphics supports. + * + * This _OSI string is only applied to systems from 2022 or earlier. */ - {"Linux-HPI-Hybrid-Graphics", true}, + {"Linux-HPI-Hybrid-Graphics", true, 2022}, }; static u32 acpi_osi_handler(acpi_string interface, u32 supported) @@ -122,9 +127,11 @@ void __init acpi_osi_setup(char *str) osi = &osi_setup_entries[i]; if (!strcmp(osi->string, str)) { osi->enable = enable; + osi->max_bios_year = 0; break; } else if (osi->string[0] == '\0') { osi->enable = enable; + osi->max_bios_year = 0; strncpy(osi->string, str, OSI_STRING_LENGTH_MAX); break; } @@ -225,6 +232,9 @@ static void __init acpi_osi_setup_late(void) str = osi->string; if (*str == '\0') break; + if (osi->max_bios_year && + dmi_get_bios_year() > osi->max_bios_year) + continue; if (osi->enable) { status = acpi_install_interface(str); if (ACPI_SUCCESS(status)) -- 2.34.1
Karol Herbst
2022-Aug-19 15:44 UTC
[Nouveau] [RFC 0/2] Stop the abuse of Linux-* _OSI strings
On Fri, Aug 19, 2022 at 4:25 PM Mario Limonciello <mario.limonciello at amd.com> wrote:> > 3 _OSI strings were introduced in recent years that were intended > to workaround very specific problems found on specific systems. > > The idea was supposed to be that these quirks were only used on > those systems, but this proved to be a bad assumption. I've found > at least one system in the wild where the vendor using the _OSI > string doesn't match the _OSI string and the neither does the use. > > So this brings a good time to review keeping those strings in the kernel. > There are 3 strings that were introduced: > > Linux-Dell-Video > -> Intended for systems with NVIDIA cards that didn't support RTD3 > Linux-Lenovo-NV-HDMI-Audio > -> Intended for powering on NVIDIA HDMI device > Linux-HPI-Hybrid-Graphics > -> Intended for changing dGPU output > > AFAIK the first string is no longer relevant as nouveau now supports > RTD3. If that's wrong, this can be changed for the series. >Nouveau always supported RTD3, because that's mainly a kernel feature. When those were introduced we simply had a bug only hit on a few systems. And instead of helping us to debug this, this workaround was added :( We were not even asked about this. I am a bit curious about the other two though as I am not even sure they are needed at all as we put other work arounds in place. @Lyude Paul might know more about these.