platform/x86: intel-vbtn: 14c200b7ca46 breaks suspend on Thinkpad X1 Tablet Gen2
Subsystems (2)
Hi Hans, all,
after upgrading to 6.7.1 or 6.6.13 (LTS), my Thinkpad X1 Tablet doesn't suspend anymore. Or, rather, it suspends, but wakes again immediately. This happens regardless of whether the keyboard is attached or not, with all ACPI wakeup triggers disabled according to /proc/acpi/wakeup. I could identify the following commit as the culprit:
14c200b7ca46b9a9f4af9e81d258a58274320b6f platform/x86: intel-vbtn: Fix missing tablet-mode-switch events
First, it's a suspiciously related patch going into both kernel versions. Second, unloading intel-vbtn resolves the problem; machine suspends as usual. Third, I tried modifying the patch. Commenting out the newly introduced
/* Some devices need this to report further events */ acpi_evaluate_object(handle, "VBDL", NULL, NULL);
resolves the problem on my machine.
I understand that the change was in for a reason, but the deeper meaning of that statement eludes me; is it possible that my model is quirky for that one?
FWIW:
- SW_TABLET_MODE is properly updated about half a second after I attach/detach/fold the keyboard during suspend with that statement commented out (but attaching/detaching/folding all wake the device, unless I also echo Y > /sys/module/acpi/parameters/ec_no_wakeup - but then I can't wake the tablet at all anymore).
- Folding the keyboard to the back of the device disables the keyboard.
With that statement in (as in 6.7.1 upstream), SW_TABLET_MODE is set to 1 (correct), but reverts to 0 again after about a second (incorrect); the keyboard remains disabled.
Without the statement, SW_TABLET_MODE remains on 1 until I flip back the keyboard to normal (expected behavior).
On a side note, I initially thought that detect_tablet_mode() in resume() is the culprit. intel_vbtn_pm_resume() is also included in the thaw callback (and I usually use hybrid suspend) and, after the patch, augmented with the detect_tablet_mode() routine.
If I understand correctly the description in [1], thaw is not really resume-/restore-like except perhaps for the corner case of failed hibernation image creation. Turns out it doesn't seem to cause the harm, but still: is intel_vbtn_pm_resume() on thaw really intended? The description says it's used to undo the changes made by the preceding freeze (including prepare), but this rather seems to match intel_vbtn_pm_complete()'s definition than intel_vbtn_pm_resume()'s...
[1] https://www.kernel.org/doc/html/v4.12/driver-api/pm/types.html
Of course, I stand available for any debugging or further investigations; happy to do some work myself if someone can guide me through.
Cheers,
Alex
P.S.: I completely failed to find any explanation/definition of "VBDL" or "VGBS". If someone could point me to that, I might be able to experiment more on my own.
If I understand correctly, the purpose of acpi_evaluate_object(handle, "VBDL", NULL, NULL) is to evaluate the SW_TABLET_MODE state and to perform some kind of reset for devices that don't update the state otherwise after resume. Calling detect_table_mode() instead seems to satisfy at least the first purpose, and remedies the problem for me - but I guess that's not a full solution?
Cheers,
Alex
Quoted 37 lines · Alexander Kobel
Hi Hans, all,
after upgrading to 6.7.1 or 6.6.13 (LTS), my Thinkpad X1 Tablet doesn't suspend anymore. Or, rather, it suspends, but wakes again immediately. This happens regardless of whether the keyboard is attached or not, with all ACPI wakeup triggers disabled according to
/proc/acpi/wakeup. I could identify the following commit as the culprit:14c200b7ca46b9a9f4af9e81d258a58274320b6f platform/x86: intel-vbtn: Fix missing tablet-mode-switch eventsFirst, it's a suspiciously related patch going into both kernel versions. Second, unloading intel-vbtn resolves the problem; machine suspends as usual. Third, I tried modifying the patch. Commenting out the newly introduced
/* Some devices need this to report further events */ acpi_evaluate_object(handle, "VBDL", NULL, NULL);resolves the problem on my machine.
I understand that the change was in for a reason, but the deeper meaning of that statement eludes me; is it possible that my model is quirky for that one?
FWIW:
-SW_TABLET_MODEis properly updated about half a second after I attach/detach/fold the keyboard during suspend with that statement commented out (but attaching/detaching/folding all wake the device, unless I alsoecho Y > /sys/module/acpi/parameters/ec_no_wakeup- but then I can't wake the tablet at all anymore).
- Folding the keyboard to the back of the device disables the keyboard.
With that statement in (as in 6.7.1 upstream),SW_TABLET_MODEis set to 1 (correct), but reverts to 0 again after about a second (incorrect); the keyboard remains disabled.
Without the statement,SW_TABLET_MODEremains on 1 until I flip back the keyboard to normal (expected behavior).On a side note, I initially thought that
detect_tablet_mode()inresume()is the culprit.intel_vbtn_pm_resume()is also included in the thaw callback (and I usually use hybrid suspend) and, after the patch, augmented with thedetect_tablet_mode()routine.
If I understand correctly the description in [1], thaw is not really resume-/restore-like except perhaps for the corner case of failed hibernation image creation. Turns out it doesn't seem to cause the harm, but still: isintel_vbtn_pm_resume()on thaw really intended? The description says it's used to undo the changes made by the preceding freeze (including prepare), but this rather seems to match intel_vbtn_pm_complete()'s definition than intel_vbtn_pm_resume()'s...[1] https://www.kernel.org/doc/html/v4.12/driver-api/pm/types.html
Of course, I stand available for any debugging or further investigations; happy to do some work myself if someone can guide me through.
Cheers,
Alex
Hi Alexander,
Quoted 8 lines · Alexander Kobel
Hi Hans, all,
after upgrading to 6.7.1 or 6.6.13 (LTS), my Thinkpad X1 Tablet doesn't suspend anymore. Or, rather, it suspends, but wakes again immediately. This happens regardless of whether the keyboard is attached or not, with all ACPI wakeup triggers disabled according to
/proc/acpi/wakeup. I could identify the following commit as the culprit:14c200b7ca46b9a9f4af9e81d258a58274320b6f platform/x86: intel-vbtn: Fix missing tablet-mode-switch events
Quoted 8 lines
First, it's a suspiciously related patch going into both kernel versions. Second, unloading intel-vbtn resolves the problem; machine suspends as usual. Third, I tried modifying the patch. Commenting out the newly introduced
/* Some devices need this to report further events */ acpi_evaluate_object(handle, "VBDL", NULL, NULL);resolves the problem on my machine.
Thank you for reporting this and sorry about the regression.
Also great that you've already pinpointed which exact patch and which part of the patch is causing this problem.
Quoted 3 lines
I understand that the change was in for a reason, but the deeper meaning of that statement eludes me; is it possible that my model is quirky for that one? FWIW:
-SW_TABLET_MODEis properly updated about half a second after I attach/detach/fold the keyboard during suspend with that statement commented out
Which input device is generating "SW_TABLET_MODE" events ? Are these coming from a "Intel Virtual Switches" input device, or are these generated by some other input device ?
And I assume that you also have an "Intel Virtual Buttons" input device ?
Quoted 1 line
(but attaching/detaching/folding all wake the device, unless I also
echo Y > /sys/module/acpi/parameters/ec_no_wakeup- but then I can't wake the tablet at all anymore).
I assume that this changing the mode wakes up the 2-in-1 is a pre-existing problem which also happens with older kernels ?
Quoted 3 lines
- Folding the keyboard to the back of the device disables the keyboard.
With that statement in (as in 6.7.1 upstream),SW_TABLET_MODEis set to 1 (correct), but reverts to 0 again after about a second (incorrect); the keyboard remains disabled. Without the statement,SW_TABLET_MODEremains on 1 until I flip back the keyboard to normal (expected behavior).
Just to make sure that I understand things correctly, commenting out the new:
/* Some devices need this to report further events */ acpi_evaluate_object(handle, "VBDL", NULL, NULL);
Call not only fixes suspend/resume mode but also fixes SW_TABLET_MODE reverting to 0 after about 1 second while it should stay 1 ?
I guess this also answers my question from above if SW_TABLET_MODE is reported by a "Intel Virtual Switches" device and the answer to that would be yes, right ?
I have the feeling that we are just going to need to revert the addition of this call then IOW your solution of commenting it out is the right solution.
Quoted 2 lines
P.S.: I completely failed to find any explanation/definition of "VBDL" or "VGBS". If someone could point me to that, I might be able to experiment more on my own.
The Intel VBTN interface is not documented anywhere AFAIK, so the below is based on my understanding of things:
"VBDL" is a method called to let the firmware know that the OS has a vbtn driver and that it can start delivering events. I have the feeling that on your X1 Tablet Gen2 it works as a sort of init() function and it probably causes at least 1 event (current tablet-mode event?) to be reported which is causing the wakeup /me thinks.
"VGBS" is used to ask the firmware for the initial status (tablet or laptop mode) on initialization. The driver also uses the presence of the "VGBS" method to determine if the device supports tablet-mode-sw reporting or not.
So the idea behind the patch causing your regression was that maybe on some hw we need to call "VBDL" which enables event reporting after every event to fix event reporting sometimes stopping by re-enabling event reporting after every event. This assumes that calling "VBDL" more then once does not have any side effects, where in your case it clearly seems to have several undesirable side-effects.
So again the fix probably is to simply just drop the newly added "VBDL" call.
Regards,
Hans
Hi Hans,
Quoted 18 lines · Hans de Goede
Hi Alexander,
Quoted 15 lines · Alexander Kobel
Hi Hans, all,
after upgrading to 6.7.1 or 6.6.13 (LTS), my Thinkpad X1 Tablet doesn't suspend anymore. Or, rather, it suspends, but wakes again immediately. This happens regardless of whether the keyboard is attached or not, with all ACPI wakeup triggers disabled according to
/proc/acpi/wakeup. I could identify the following commit as the culprit:14c200b7ca46b9a9f4af9e81d258a58274320b6f platform/x86: intel-vbtn: Fix missing tablet-mode-switch eventsFirst, it's a suspiciously related patch going into both kernel versions. Second, unloading intel-vbtn resolves the problem; machine suspends as usual. Third, I tried modifying the patch. Commenting out the newly introduced
/* Some devices need this to report further events */ acpi_evaluate_object(handle, "VBDL", NULL, NULL);
Quoted 6 lines
Quoted 1 line
resolves the problem on my machine.
Thank you for reporting this and sorry about the regression.
Also great that you've already pinpointed which exact patch and which part of the patch is causing this problem.
No worries, thanks for the swift reply.
Quoted 10 lines
Quoted 3 lines
I understand that the change was in for a reason, but the deeper meaning of that statement eludes me; is it possible that my model is quirky for that one? FWIW:
-SW_TABLET_MODEis properly updated about half a second after I attach/detach/fold the keyboard during suspend with that statement commented outWhich input device is generating "
SW_TABLET_MODE" events ? Are these coming from a "Intel Virtual Switches" input device, or are these generated by some other input device ?And I assume that you also have an "Intel Virtual Buttons" input device ?
Correct:
% libinput list-devices | grep Intel
Device: Intel Virtual Buttons Device: Intel Virtual Switches Device: Intel HID events Device: Intel HID 5 button array
Quoted 4 lines
Quoted 1 line
(but attaching/detaching/folding all wake the device, unless I also
echo Y > /sys/module/acpi/parameters/ec_no_wakeup- but then I can't wake the tablet at all anymore).I assume that this changing the mode wakes up the 2-in-1 is a pre-existing problem which also happens with older kernels ?
Correct.
Quoted 11 lines
Quoted 3 lines
- Folding the keyboard to the back of the device disables the keyboard.
With that statement in (as in 6.7.1 upstream),SW_TABLET_MODEis set to 1 (correct), but reverts to 0 again after about a second (incorrect); the keyboard remains disabled. Without the statement,SW_TABLET_MODEremains on 1 until I flip back the keyboard to normal (expected behavior).Just to make sure that I understand things correctly, commenting out the new:
(quoted diff) +0
-0/* Some devices need this to report further events */ acpi_evaluate_object(handle, "VBDL", NULL, NULL);Call not only fixes suspend/resume mode but also fixes
SW_TABLET_MODEreverting to 0 after about 1 second while it should stay 1 ?
Correct.
N.B.: It still triggers wakeup when I flip or detach the keyboard. In order to prevent that, I have to both unload intel-vbtn entirely *and* disable the XHC wake-up trigger, if I didn't miss anything.
Quoted 3 lines
I guess this also answers my question from above if
SW_TABLET_MODEis reported by a "Intel Virtual Switches" device and the answer to that would be yes, right ?
Correct.
Quoted 30 lines
I have the feeling that we are just going to need to revert the addition of this call then IOW your solution of commenting it out is the right solution.
Quoted 2 lines
P.S.: I completely failed to find any explanation/definition of "VBDL" or "VGBS". If someone could point me to that, I might be able to experiment more on my own.The Intel VBTN interface is not documented anywhere AFAIK, so the below is based on my understanding of things:
"VBDL" is a method called to let the firmware know that the OS has a vbtn driver and that it can start delivering events. I have the feeling that on your X1 Tablet Gen2 it works as a sort of
init()function and it probably causes at least 1 event (current tablet-mode event?) to be reported which is causing the wakeup /me thinks."VGBS" is used to ask the firmware for the initial status (tablet or laptop mode) on initialization. The driver also uses the presence of the "VGBS" method to determine if the device supports tablet-mode-sw reporting or not.
So the idea behind the patch causing your regression was that maybe on some hw we need to call "VBDL" which enables event reporting after every event to fix event reporting sometimes stopping by re-enabling event reporting after every event. This assumes that calling "VBDL" more then once does not have any side effects, where in your case it clearly seems to have several undesirable side-effects.
Quoted 2 lines
So again the fix probably is to simply just drop the newly added "VBDL" call.
Thanks for taking the time for an explanation. Sounds like *not* needing the VBDL call should be default, and that rather the devices that need it are quirky. Although that doesn't mean that the X1 Tablet is fine, because the side effect of immediately resuming also seems rare; otherwise it'd have been spotted and reported earlier by others, I suppose. And, apparently, calling VBDL makes the X1 Tablet misreport the tablet mode state. Hm. Perhaps introducing a special handling of the Inspiron 7352 would be the way to go then?
FWIW, I previously dumped a DSDT (for entirely unrelated reasons): https://raw.githubusercontent.com/akobel/linux-thinkpad-x1-tablet/main/x1-tablet-gen2/DSDT/dsl/dsdt.dsl
Just in case it's useful in further investigation/comparison to the Dell...
Quoted 3 lines
Regards,
Hans
Cheers,
Alex
Hi Alexander,
Quoted 3 lines · Alexander Kobel
Hi Hans,
On 14/02/2024 11.54, Hans de Goede wrote:
<snip>
Quoted 8 lines
Quoted 8 lines
So the idea behind the patch causing your regression was that maybe on some hw we need to call "VBDL" which enables event reporting after every event to fix event reporting sometimes stopping by re-enabling event reporting after every event. This assumes that calling "VBDL" more then once does not have any side effects, where in your case it clearly seems to have several undesirable side-effects.
Quoted 4 lines
Quoted 2 lines
So again the fix probably is to simply just drop the newly added "VBDL" call.
Thanks for taking the time for an explanation. Sounds like *not* needing the VBDL call should be default, and that rather the devices that need it are quirky.
Ack, I completely agree.
It never became entirely clear if this call is even necessary to fix the issue of missing tablet-mode-switch events on the Dell Inspiron 7352.
So for now I'm just going to drop the "VBDL" ACPI method call again to fix the 2 issues this is causing on the ThinkPad X1 Tablet Gen2.
Regards,
Hans
Quoted 7 lines · Alexander Kobel
after upgrading to 6.7.1 or 6.6.13 (LTS), my Thinkpad X1 Tablet doesn't suspend anymore. Or, rather, it suspends, but wakes again immediately. This happens regardless of whether the keyboard is attached or not, with all ACPI wakeup triggers disabled according to
/proc/acpi/wakeup. I could identify the following commit as the culprit:14c200b7ca46b9a9f4af9e81d258a58274320b6f platform/x86: intel-vbtn: Fix missing tablet-mode-switch events
To be sure the issue doesn't fall through the cracks unnoticed, I'm adding it to regzbot, the Linux kernel regression tracking bot:
#regzbot ^introduced 14c200b7ca46b9a9f4af9e81d258a5827432 #regzbot title platform/x86: intel-vbtn: suspend broken on Thinkpad X1 Tablet Gen2
#regzbot ignore-activity
Ciao, Thorsten (wearing his 'the Linux kernel's regression tracker' hat) --
Everything you wanna know about Linux kernel regression tracking:
https://linux-regtracking.leemhuis.info/about/#tldr
That page also explains what to do if mails like this annoy you.