Bug#1029046: Wayland session doesn't get back to life post-suspend

2023-01-21 Thread Didier 'OdyX' Raboud
Control: tags -1 +patch -help
Control: clone -1 -2
Control: retitle -2 Thinkpad AMD: amd_pmc module is required for correct s0ix 
(Windows mode) suspend
Control: severity -2 important

Hello there, 

My understanding is that there are two distinct bugs here; hereby splitting 
to make this clearer.

* Original bug, as retitled by Salvatore; S3 suspend is broken on some AMD
  Ryzens. This is fixed by this patch queue, also attached.
https://gitlab.freedesktop.org/superm1/linux/-/commits/mlimonci/rhbz-2162013-gitlab-2357-v4/

  In the BIOS, "S3" is "Linux mode" for suspend.

* While investigating this; it turns out modern kernels can also suspend
  on s0ix "Windows mode", but this _requires_ the `amd_pmc` module, which
  is not loaded automatically, but it really should. This doesn't look
  like an upstream bug, but rather a Debian one.

  As this only shows on Laptops with a "Windows mode" BIOS configuration
  (in a box that also shows "Linux mode"), I think it's reasonable to see
  this as a bug of only "important" level (even though not resuming from
  suspend is _bad_).

  I don't think we have seen a patch to fix this one yet though.

Best,

OdyX
Index: linux/drivers/gpio/gpiolib-acpi.c
===
--- linux.orig/drivers/gpio/gpiolib-acpi.c
+++ linux/drivers/gpio/gpiolib-acpi.c
@@ -361,7 +361,7 @@ err:
 }
 
 static bool acpi_gpio_irq_is_wake(struct device *parent,
-  struct acpi_resource_gpio *agpio)
+  const struct acpi_resource_gpio *agpio)
 {
 	unsigned int pin = agpio->pin_table[0];
 
@@ -754,7 +754,7 @@ static int acpi_populate_gpio_lookup(str
 		lookup->info.pin_config = agpio->pin_config;
 		lookup->info.debounce = agpio->debounce_timeout;
 		lookup->info.gpioint = gpioint;
-		lookup->info.wake_capable = agpio->wake_capable == ACPI_WAKE_CAPABLE;
+		lookup->info.wake_capable = acpi_gpio_irq_is_wake(>info.adev->dev, agpio);
 
 		/*
 		 * Polarity and triggering are only specified for GpioInt
@@ -1080,7 +1080,7 @@ int acpi_dev_gpio_irq_wake_get_by(struct
 dev_dbg(>dev, "IRQ %d already in use\n", irq);
 			}
 
-			if (wake_capable)
+			if (wake_capable && acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0)
 *wake_capable = info.wake_capable;
 
 			return irq;
@@ -1599,6 +1599,19 @@ static const struct dmi_system_id gpioli
 			.ignore_interrupt = "AMDI0030:00@18",
 		},
 	},
+	{
+		/*
+		 * Spurious wakeups from TP_ATTN# pin
+		 * Found in BIOS 1.7.8
+		 * https://gitlab.freedesktop.org/drm/amd/-/issues/1722#note_1720627
+		 */
+		.matches = {
+			DMI_MATCH(DMI_BOARD_NAME, "NL5xRU"),
+		},
+		.driver_data = &(struct acpi_gpiolib_dmi_quirk) {
+			.ignore_wake = "ELAN0415:00@9",
+		},
+	},
 	{} /* Terminating entry */
 };
 
Index: linux/drivers/pinctrl/pinctrl-amd.c
===
--- linux.orig/drivers/pinctrl/pinctrl-amd.c
+++ linux/drivers/pinctrl/pinctrl-amd.c
@@ -365,6 +365,7 @@ static void amd_gpio_dbg_show(struct seq
 
 			} else {
 debounce_enable = "  ∅";
+time = 0;
 			}
 			snprintf(debounce_value, sizeof(debounce_value), "%u", time * unit);
 			seq_printf(s, "debounce %s ( %sus)| ", debounce_enable, debounce_value);


signature.asc
Description: This is a digitally signed message part.


Bug#1029046: Wayland session doesn't get back to life post-suspend

2023-01-18 Thread Diederik de Haas
Control: tag -1 help

Hi,

On Wednesday, 18 January 2023 09:22:03 CET Didier 'OdyX' Raboud wrote:
> Control: retitle -1 Thinkpad: amd_pmc module required for on 6.1 for correct 
> suspend
> Le mardi, 17 janvier 2023, 22.53:54 h CET Didier 'OdyX' Raboud a écrit :
> > Le mardi, 17 janvier 2023, 15.32:37 h CET Diederik de Haas a écrit :
> > > On Monday, 16 January 2023 22:33:05 CET Didier 'OdyX' Raboud wrote:
> > > > This is on 6.1.4-1a~test, patched against the "2nd DisplayPort doesn't
> > > > light up", so feel free to close the bug; I'll test if I get the same
> > > > symptoms on an unpatched kernel anyway :-)
> > > 
> > > If that issue doesn't occur with the unpatched kernel, could you add
> > > your finding to that upstream/forwarded issue?
> > ...
> > 
> > All three 6.1 kernels (whether patched or not) don't bring the laptop to
> > the suspended state (power led 'breathing', fans off), but it's kept in
> > an "on" state (power led on, fans on), from which I found that I *can*
> > wake the laptop up by short-pressing the power button; the screens gets
> > back to life and show my lockscreen. But from there, I can't move the
> > mouse nor do anything else. Alt-SysRq-r + ctrl-alt-f2 give me a tty, but
> > any comeback to tty1 only blank (not even a blank screen, just a freeze).
> > 
> > This seems to point to a quite severe regression in amdgpu or other amd-
> > related code; I can't suspend-and-resume the laptop anymore on any 6.1
> > kernel, on battery, without anything attached to it.
> > 
> > I'll forward the above findings to the bug you pointed to, hoping it could
> > help upstream too!
> 
> OK. I've gone and done this:
> https://gitlab.freedesktop.org/drm/amd/-/issues/2171#note_1727281

Awesome, thanks.

> It turns out to get suspend to work, the `amd_pmc` module needs to be
> enabled (_AND_ the BIOS needs to have the "Sleep State" toggled to Windows
> (from Linux).
> 
> I _think_ Debian should make sure amd_pmc is loaded on (all?) modern AMD
> laptops. I have no idea (yet) what the mechanism to make this happen is
> though.

Due to https://bugs.debian.org/992832 the AMD_PMC module got enabled and
I and IIUC you too, verified that it is present in the kernel.

I agree it should be auto-loaded, but I don't know why that didn't happen.
Tagging this bug with 'help' to request the help from ppl who know more
about this then I do.

Cheers,
  Diederik

signature.asc
Description: This is a digitally signed message part.


Bug#1029046: Wayland session doesn't get back to life post-suspend

2023-01-18 Thread Didier 'OdyX' Raboud
Control: retitle -1 Thinkpad: amd_pmc module required for on 6.1 for correct 
suspend

Le mardi, 17 janvier 2023, 22.53:54 h CET Didier 'OdyX' Raboud a écrit :
> Le mardi, 17 janvier 2023, 15.32:37 h CET Diederik de Haas a écrit :
> > On Monday, 16 January 2023 22:33:05 CET Didier 'OdyX' Raboud wrote:
> > > This is on 6.1.4-1a~test, patched against the "2nd DisplayPort doesn't
> > > light up", so feel free to close the bug; I'll test if I get the same
> > > symptoms on an unpatched kernel anyway :-)
> > 
> > If this issue doesn't occur with the unpatched kernel, that would be VERY
> > important extra information!
> > https://gitlab.freedesktop.org/drm/amd/-/issues/2171#note_1724186 may be
> > the same or similar finding?
> > 
> > If that issue doesn't occur with the unpatched kernel, could you add your
> > finding to that upstream/forwarded issue?
> 
> Now that I got my kernel build in place; I can actually confirm that:
> 
> On my Thinkpad X13 Gen 2a, without any dongle, hub or docking station (on
> battery), with a KDE Plasma Wayland session:
> 
> * 6.0.0-6-amd64 (6.0.12-1)
>   suspends and resumes correctly
> * 6.1.0-1-amd64 (6.1.4-1, unpatched)
>   doesn't finish suspending
> * 6.1.0-2-amd64 (6.1.6-1, from the 'sid' branch on salsa, not patched)
>   doesn't finish suspending
> * 6.1.0-2-amd64 (6.1.6-1, from the 'sid' branch on salsa, patched),
>   doesn't finish suspending
> 
> All three 6.1 kernels (whether patched or not) don't bring the laptop to the
> suspended state (power led 'breathing', fans off), but it's kept in an "on"
> state (power led on, fans on), from which I found that I *can* wake the
> laptop up by short-pressing the power button; the screens gets back to life
> and show my lockscreen. But from there, I can't move the mouse nor do
> anything else. Alt-SysRq-r + ctrl-alt-f2 give me a tty, but any comeback to
> tty1 only blank (not even a blank screen, just a freeze).
> 
> This seems to point to a quite severe regression in amdgpu or other amd-
> related code; I can't suspend-and-resume the laptop anymore on any 6.1
> kernel, on battery, without anything attached to it.
> 
> I'll forward the above findings to the bug you pointed to, hoping it could
> help upstream too!

OK. I've gone and done this: 
https://gitlab.freedesktop.org/drm/amd/-/issues/2171#note_1727281

It turns out to get suspend to work, the `amd_pmc` module needs to be enabled
(_AND_ the BIOS needs to have the "Sleep State" toggled to Windows (from
Linux).

I _think_ Debian should make sure amd_pmc is loaded on (all?) modern AMD
laptops. I have no idea (yet) what the mechanism to make this happen is though.

-- 
OdyX



Bug#1029046: Wayland session doesn't get back to life post-suspend

2023-01-17 Thread Didier 'OdyX' Raboud
Control: found -1 6.1.6-1
Control: found -1 6.1.4-1
Control: severity -1 serious

Hello there,

Le mardi, 17 janvier 2023, 15.32:37 h CET Diederik de Haas a écrit :
> On Monday, 16 January 2023 22:33:05 CET Didier 'OdyX' Raboud wrote:
> > This is on 6.1.4-1a~test, patched against the "2nd DisplayPort doesn't
> > light up", so feel free to close the bug; I'll test if I get the same
> > symptoms on an unpatched kernel anyway :-)
> 
> If this issue doesn't occur with the unpatched kernel, that would be VERY
> important extra information!
> https://gitlab.freedesktop.org/drm/amd/-/issues/2171#note_1724186 may be the
> same or similar finding?
> 
> If that issue doesn't occur with the unpatched kernel, could you add your
> finding to that upstream/forwarded issue?

Now that I got my kernel build in place; I can actually confirm that:

On my Thinkpad X13 Gen 2a, without any dongle, hub or docking station (on 
battery), with a KDE Plasma Wayland session:

* 6.0.0-6-amd64 (6.0.12-1)
  suspends and resumes correctly
* 6.1.0-1-amd64 (6.1.4-1, unpatched)
  doesn't finish suspending
* 6.1.0-2-amd64 (6.1.6-1, from the 'sid' branch on salsa, not patched)
  doesn't finish suspending
* 6.1.0-2-amd64 (6.1.6-1, from the 'sid' branch on salsa, patched),
  doesn't finish suspending

All three 6.1 kernels (whether patched or not) don't bring the laptop to the 
suspended state (power led 'breathing', fans off), but it's kept in an "on" 
state (power led on, fans on), from which I found that I *can* wake the laptop 
up by short-pressing the power button; the screens gets back to life and show 
my lockscreen. But from there, I can't move the mouse nor do anything else. 
Alt-SysRq-r + ctrl-alt-f2 give me a tty, but any comeback to tty1 only blank 
(not even a blank screen, just a freeze).

This seems to point to a quite severe regression in amdgpu or other amd-
related code; I can't suspend-and-resume the laptop anymore on any 6.1 kernel, 
on battery, without anything attached to it.

I'll forward the above findings to the bug you pointed to, hoping it could 
help upstream too!

Best,

OdyX



Bug#1029046: Wayland session doesn't get back to life post-suspend

2023-01-17 Thread Diederik de Haas
Hi OdyX,

On Monday, 16 January 2023 22:33:05 CET Didier 'OdyX' Raboud wrote:
> This is on 6.1.4-1a~test, patched against the "2nd DisplayPort doesn't
> light up", so feel free to close the bug; I'll test if I get the same
> symptoms on an unpatched kernel anyway :-)

If this issue doesn't occur with the unpatched kernel, that would be VERY 
important extra information!
https://gitlab.freedesktop.org/drm/amd/-/issues/2171#note_1724186 may be the 
same or similar finding?

If that issue doesn't occur with the unpatched kernel, could you add your 
finding to that upstream/forwarded issue?

Thanks!

signature.asc
Description: This is a digitally signed message part.


Bug#1029046: Wayland session doesn't get back to life post-suspend

2023-01-16 Thread Didier 'OdyX' Raboud
Package: linux-image-6.1.0-1-amd64
Version: 6.1.4-1
Severity: important

Hello there,

this is a regression from 6.0.0 too; after post-suspend wakeup, my
plasma wayland session stays frozen; the two DisplayPort screens light
up, backgrounds are shown, but the mouse doesn't move, nothing works.

I'm reportbug'ging this from a SysRQ-R, Ctrl-Alt-F2 text tty.

>From cursory dmesg reading, it seems amdgpu has an "IB test failed"
_before_ kernel suspend.

This is on 6.1.4-1a~test, patched against the "2nd DisplayPort doesn't
light up", so feel free to close the bug; I'll test if I get the same
symptoms on an unpatched kernel anyway :-)

Best,

OdyX


-- System Information:
Debian Release: bookworm/sid
  APT prefers buildd-unstable
  APT policy: (500, 'buildd-unstable'), (500, 'unstable'), (500, 'testing'), 
(1, 'buildd-experimental'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 6.1.0-1-amd64 (SMP w/16 CPU threads; PREEMPT)
Kernel taint flags: TAINT_UNSIGNED_MODULE
Locale: LANG=fr_CH.UTF-8, LC_CTYPE=fr_CH.UTF-8 (charmap=UTF-8), 
LANGUAGE=fr_CH:fr
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages linux-image-6.1.0-1-amd64 depends on:
ii  initramfs-tools [linux-initramfs-tool]  0.142
ii  kmod30+20221128-1
ii  linux-base  4.9

Versions of packages linux-image-6.1.0-1-amd64 recommends:
ii  apparmor 3.0.8-1
ii  firmware-linux-free  20200122-1

Versions of packages linux-image-6.1.0-1-amd64 suggests:
pn  debian-kernel-handbook  
ii  extlinux3:6.04~git20190206.bf6db5b4+dfsg1-3+b1
ii  grub-efi-amd64  2.06-7
pn  linux-doc-6.1