X86 platform drivers
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 6.16 04/85] platform/x86/amd: pmc: Add Lenovo Yoga 6 13ALC6 to pmc quirk list
       [not found] <20250804002335.3613254-1-sashal@kernel.org>
@ 2025-08-04  0:22 ` Sasha Levin
  2025-08-04  0:23 ` [PATCH AUTOSEL 6.16 78/85] platform/x86: thinkpad_acpi: Handle KCOV __init vs inline mismatches Sasha Levin
  1 sibling, 0 replies; 2+ messages in thread
From: Sasha Levin @ 2025-08-04  0:22 UTC (permalink / raw)
  To: patches, stable
  Cc: Mario Limonciello, Adam Berglund, Hans de Goede,
	Ilpo Järvinen, Sasha Levin, Shyam-sundar.S-k,
	platform-driver-x86

From: Mario Limonciello <mario.limonciello@amd.com>

[ Upstream commit 4ff3aeb664f7dfe824ba91ffb0b203397a8d431e ]

The Lenovo Yoga 6 13ACL6 82ND has a similar BIOS problem as other Lenovo
laptops from that vintage that causes a rather long resume from suspend.

Add it to the quirk list that manipulates the scratch register to avoid
the issue.

Reported-by: Adam Berglund <adam.f.berglund@hotmail.com>
Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/4434
Tested-by: Adam Berglund <adam.f.berglund@hotmail.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Reviewed-by: Hans de Goede <hansg@kernel.org>
Link: https://lore.kernel.org/r/20250718172307.1928744-1-superm1@kernel.org
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---

LLM Generated explanations, may be completely bogus:

**YES**

This commit should be backported to stable kernel trees. Here's my
extensive analysis:

## Backport Justification

1. **Fixes a real user-impacting bug**: The commit addresses a BIOS
   firmware bug that causes "rather long resume from suspend" on the
   Lenovo Yoga 6 13ALC6 laptop. This is a significant usability issue
   that affects users of this specific hardware model during
   suspend/resume operations.

2. **Minimal and contained change**: The patch simply adds 8 lines to an
   existing DMI quirk table (lines 193-201 in the diff). It adds one new
   entry:
  ```c
  {
  .ident = "Lenovo Yoga 6 13ALC6",
  .driver_data = &quirk_s2idle_bug,
  .matches = {
  DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"),
  DMI_MATCH(DMI_PRODUCT_NAME, "82ND"),
  }
  },
  ```

3. **Follows established pattern**: The fix uses the exact same
   mechanism (`quirk_s2idle_bug`) that's already applied to 20+ other
   Lenovo laptops in the same file. The workaround manipulates a scratch
   register (FCH_PM_SCRATCH) to skip a problematic SMI handler during
   suspend-to-idle resume, as documented in the comment at lines
   241-248.

4. **No architectural changes**: This is purely a device-specific quirk
   addition to an existing quirk framework. No new functionality is
   introduced, no APIs are changed, and no kernel subsystem architecture
   is modified.

5. **Low regression risk**: The change only affects systems that match
   the specific DMI strings (LENOVO board vendor + 82ND product name).
   It cannot affect any other hardware.

6. **Tested by reporter**: The commit message indicates "Tested-by: Adam
   Berglund" who was also the reporter of the issue, confirming the fix
   works on the affected hardware.

7. **Follows stable tree rules**: This is exactly the type of commit
   that stable trees want:
   - Fixes a real bug (long resume times)
   - Minimal change (8 lines)
   - Hardware-specific fix with no broader impact
   - Already tested on affected hardware

The issue being fixed is documented at
https://gitlab.freedesktop.org/drm/amd/-/issues/4434, and the workaround
applies the same proven fix that's been working for numerous other
Lenovo models with similar BIOS issues related to suspend-to-idle resume
performance when IOMMU is enabled for NVMe devices.

 drivers/platform/x86/amd/pmc/pmc-quirks.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/platform/x86/amd/pmc/pmc-quirks.c b/drivers/platform/x86/amd/pmc/pmc-quirks.c
index 131f10b68308..ded4c84f5ed1 100644
--- a/drivers/platform/x86/amd/pmc/pmc-quirks.c
+++ b/drivers/platform/x86/amd/pmc/pmc-quirks.c
@@ -190,6 +190,15 @@ static const struct dmi_system_id fwbug_list[] = {
 			DMI_MATCH(DMI_PRODUCT_NAME, "82XQ"),
 		}
 	},
+	/* https://gitlab.freedesktop.org/drm/amd/-/issues/4434 */
+	{
+		.ident = "Lenovo Yoga 6 13ALC6",
+		.driver_data = &quirk_s2idle_bug,
+		.matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "82ND"),
+		}
+	},
 	/* https://gitlab.freedesktop.org/drm/amd/-/issues/2684 */
 	{
 		.ident = "HP Laptop 15s-eq2xxx",
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH AUTOSEL 6.16 78/85] platform/x86: thinkpad_acpi: Handle KCOV __init vs inline mismatches
       [not found] <20250804002335.3613254-1-sashal@kernel.org>
  2025-08-04  0:22 ` [PATCH AUTOSEL 6.16 04/85] platform/x86/amd: pmc: Add Lenovo Yoga 6 13ALC6 to pmc quirk list Sasha Levin
@ 2025-08-04  0:23 ` Sasha Levin
  1 sibling, 0 replies; 2+ messages in thread
From: Sasha Levin @ 2025-08-04  0:23 UTC (permalink / raw)
  To: patches, stable
  Cc: Kees Cook, Ilpo Järvinen, Sasha Levin, hansg,
	platform-driver-x86

From: Kees Cook <kees@kernel.org>

[ Upstream commit 6418a8504187dc7f5b6f9d0649c03e362cb0664b ]

When KCOV is enabled all functions get instrumented, unless the
__no_sanitize_coverage attribute is used. To prepare for
__no_sanitize_coverage being applied to __init functions[1], we have
to handle differences in how GCC's inline optimizations get resolved.
For thinkpad_acpi routines, this means forcing two functions to be
inline with __always_inline.

Link: https://lore.kernel.org/lkml/20250523043935.2009972-11-kees@kernel.org/ [1]
Signed-off-by: Kees Cook <kees@kernel.org>
Link: https://lore.kernel.org/r/20250529181831.work.439-kees@kernel.org
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---

LLM Generated explanations, may be completely bogus:

**YES**

This commit should be backported to stable kernel trees. Here's my
extensive analysis:

## Detailed Analysis

### Nature of the Change
The commit modifies two functions in
`drivers/platform/x86/lenovo/thinkpad_acpi.c`:
- `tpacpi_is_lenovo()`: Changed from `static inline` to `static
  __always_inline`
- `tpacpi_is_ibm()`: Changed from `static inline` to `static
  __always_inline`

Both functions are marked with `__init` and are simple one-line
functions that check the vendor ID.

### Root Cause
This is a build fix addressing a subtle interaction between:
1. KCOV kernel coverage instrumentation
2. GCC's inline optimization heuristics
3. Linux kernel's __init section handling

When KCOV is enabled, all functions get instrumented unless marked with
`__no_sanitize_coverage`. The commit message indicates this is
preparation for applying `__no_sanitize_coverage` to `__init` functions.
The problem occurs because:

1. With KCOV instrumentation, GCC may inline these functions into
   `__init` callers
2. Without KCOV instrumentation (when `__no_sanitize_coverage` is
   applied), GCC's heuristics change and it may decide NOT to inline
   them
3. This creates a section mismatch where `__init` code calls
   non-`__init` functions, causing build warnings/errors

### Why This Qualifies for Stable Backport

1. **Fixes a Real Bug**: This addresses legitimate build failures when
   `CONFIG_KCOV=y` is enabled, which affects:
   - Kernel developers doing coverage testing
   - CI/CD systems running kernel tests
   - Distribution builders enabling KCOV for testing

2. **Minimal Risk**: The change is extremely conservative:
   - Only changes inline hints from `inline` to `__always_inline`
   - No functional changes whatsoever
   - Affects only two simple getter functions
   - Cannot introduce runtime regressions

3. **Small and Contained**: The patch touches only 2 lines in a single
   file, making it easy to review and backport

4. **Part of Broader Fix**: This is part of a kernel-wide effort to fix
   KCOV-related build issues, with similar fixes across multiple
   architectures and subsystems

5. **Build Infrastructure**: Stable kernels need to maintain
   buildability with various configurations, including KCOV-enabled
   builds for testing

### Specific Code Impact
Looking at the changed functions:
```c
-static inline bool __pure __init tpacpi_is_lenovo(void)
+static __always_inline bool __pure __init tpacpi_is_lenovo(void)
 {
        return thinkpad_id.vendor == PCI_VENDOR_ID_LENOVO;
 }

-static inline bool __pure __init tpacpi_is_ibm(void)
+static __always_inline bool __pure __init tpacpi_is_ibm(void)
 {
        return thinkpad_id.vendor == PCI_VENDOR_ID_IBM;
 }
```

These are trivial getter functions that absolutely should be inlined.
Using `__always_inline` ensures consistent behavior regardless of KCOV
configuration, preventing section mismatch warnings.

### Conclusion
This is a textbook example of a stable-appropriate fix: it solves a real
build problem, has zero functional impact, is minimal in scope, and has
essentially no risk of causing regressions. It should be backported to
stable kernels that support KCOV (4.6+) to maintain build compatibility
with coverage testing configurations.

 drivers/platform/x86/thinkpad_acpi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index b59b4d90b0c7..afb83b3f4826 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -559,12 +559,12 @@ static unsigned long __init tpacpi_check_quirks(
 	return 0;
 }
 
-static inline bool __pure __init tpacpi_is_lenovo(void)
+static __always_inline bool __pure __init tpacpi_is_lenovo(void)
 {
 	return thinkpad_id.vendor == PCI_VENDOR_ID_LENOVO;
 }
 
-static inline bool __pure __init tpacpi_is_ibm(void)
+static __always_inline bool __pure __init tpacpi_is_ibm(void)
 {
 	return thinkpad_id.vendor == PCI_VENDOR_ID_IBM;
 }
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-08-04  0:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20250804002335.3613254-1-sashal@kernel.org>
2025-08-04  0:22 ` [PATCH AUTOSEL 6.16 04/85] platform/x86/amd: pmc: Add Lenovo Yoga 6 13ALC6 to pmc quirk list Sasha Levin
2025-08-04  0:23 ` [PATCH AUTOSEL 6.16 78/85] platform/x86: thinkpad_acpi: Handle KCOV __init vs inline mismatches Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox