Bug 219296

Summary: libahci driver and power switching HDD on newer kernels
Product: SCSI Drivers Reporter: linuxcdeveloper
Component: OtherAssignee: scsi_drivers-other
Status: RESOLVED CODE_FIX    
Severity: normal CC: aros, dlemoal
Priority: P3    
Hardware: Intel   
OS: Linux   
Kernel Version: 6.6.0-rc3+ Subsystem:
Regression: Yes Bisected commit-id: aa3998dbeb3abce63653b7f6d4542e7dcd022590
Bug Depends on: 218038    
Bug Blocks:    
Attachments: dmesg from first bad commit aa3998dbeb3abce63653b7f6d4542e7dcd022590
dmesg from last good commit 3cc2ffe5c16dc65dfac354bc5b5bc98d3b397567

Description linuxcdeveloper 2024-09-21 06:29:14 UTC
Hi,

I've got some problems with newer kernels during hibernation and
waking up from hibernation.
The symptom of the issue is that there is HDD power switching executed
after I run pm-hibernate command and the same HDD power switching
during the wake up process from hibernation.

As the HDD power switch process I mean: powering off my HDD and
immediately after that powering on the HDD. This process in my case
takes about 1 second.

Here there are more details about both operations: hibernation and waking up:

Hibernation process:
1. in shell I type: "pm-hibernate"
2. kernel is preparing system to hibernation
3. hdd is powered off and immediately powered on - it takes about one
second or less to do the power switch
4. kernel is saving mem image to swap partition with printing progress
in percentage
5. PC and HDD are powered off

Waking up process:
1. my PC and HDD are powered off, I'm pressing any key on my keyboard
so it is powering up my PC
2. kernel is starting, recognizes that there is mem image on swap and
starting to load it - printing progress percentage
3. hdd is powered off and immediately powered on - it takes about one
second or less to do the power switch
4. system is ready to use and working fine

So to sum up - in both processes described above the problematic step
is the step 3.

I noticed some errors in dmesg coming from ahci driver like these:
Sep 11 15:49:30 localhost kernel: ahci 0000:00:17.0: port does not
support device sleep

and ACPI BIOS errors like these:
Sep 11 15:49:30 localhost kernel: ACPI BIOS Error (bug): Could not
resolve symbol [\_SB.PCI0.SAT0.PRT0._GTF.DSSP], AE_NOT_FOUND
(20240322/psargs-330)

The mainboard I use is: Gigabyte Z370 HD3P with the newest available
BIOS update F14.

I bisected this git repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
and here is the log from bisection:

git bisect start
# status: waiting for both good and bad commits
# good: [05d8970cca014b96c06c3730ae084f08087f13dd] Linux 6.4.12
git bisect good 05d8970cca014b96c06c3730ae084f08087f13dd
# status: waiting for bad commit, 1 good commit known
# bad: [004dcea13dc10acaf1486d9939be4c793834c13c] Linux 6.7.5
git bisect bad 004dcea13dc10acaf1486d9939be4c793834c13c
# good: [6995e2de6891c724bfeb2db33d7b87775f913ad1] Linux 6.4
git bisect good 6995e2de6891c724bfeb2db33d7b87775f913ad1
# good: [b84acc11b1c9552c9ca3a099b1610a6018619332] Merge tag 'fbdev-for-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/linux-fbdev
git bisect good b84acc11b1c9552c9ca3a099b1610a6018619332
# bad: [8bc9e6515183935fa0cccaf67455c439afe4982b] Merge tag 'devicetree-for-6.7' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux
git bisect bad 8bc9e6515183935fa0cccaf67455c439afe4982b
# bad: [1002f8171d966f73e3d97b05fc0178e115fb5dca] wifi: ray_cs: Remove unnecessary (void*) conversions
git bisect bad 1002f8171d966f73e3d97b05fc0178e115fb5dca
# good: [535a265d7f0dd50d8c3a4f8b4f3a452d56bd160f] Merge tag 'perf-tools-for-v6.6-1-2023-09-05' of git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools
git bisect good 535a265d7f0dd50d8c3a4f8b4f3a452d56bd160f
# bad: [e8c127b0576660da9195504fe8393fe9da3de9ce] Merge tag 'net-6.6-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
git bisect bad e8c127b0576660da9195504fe8393fe9da3de9ce
# good: [c7bd8a1f45bada7725d11266df7fd5cb549b3098] iommu/apple-dart: Handle DMA_FQ domains in attach_dev()
git bisect good c7bd8a1f45bada7725d11266df7fd5cb549b3098
# bad: [cb84fb87f325ecd46be586b62623db5b2c0a792e] Merge tag 'integrity-v6.6-fix' of git://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity
git bisect bad cb84fb87f325ecd46be586b62623db5b2c0a792e
# bad: [ba77f7a63f4e4d4ffa5ad8c6665a104822992538] Merge tag '6.6-rc3-smb3-client-fix' of git://git.samba.org/sfrench/cifs-2.6
git bisect bad ba77f7a63f4e4d4ffa5ad8c6665a104822992538
# good: [b02afe1df518369dd322f48b49e50efc49250575] Merge tag 'xtensa-20230928' of https://github.com/jcmvbkbc/linux-xtensa
git bisect good b02afe1df518369dd322f48b49e50efc49250575
# good: [6edc84bc3f8aceae74eb63684d53c17553382ec0] Merge tag 'drm-fixes-2023-09-29' of git://anongit.freedesktop.org/drm/drm
git bisect good 6edc84bc3f8aceae74eb63684d53c17553382ec0
# bad: [95289e49f0a05f729a9ff86243c9aff4f34d4041] Merge tag 'ata-6.6-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata
git bisect bad 95289e49f0a05f729a9ff86243c9aff4f34d4041
# bad: [75e2bd5f1ede42a2bc88aa34b431e1ace8e0bea0] ata: libata-core: Do not register PM operations for SAS ports
git bisect bad 75e2bd5f1ede42a2bc88aa34b431e1ace8e0bea0
# good: [84d76529c650f887f1e18caee72d6f0589e1baf9] ata: libata-core: Fix port and device removal
git bisect good 84d76529c650f887f1e18caee72d6f0589e1baf9
# bad: [aa3998dbeb3abce63653b7f6d4542e7dcd022590] ata: libata-scsi: Disable scsi device manage_system_start_stop
git bisect bad aa3998dbeb3abce63653b7f6d4542e7dcd022590
# good: [3cc2ffe5c16dc65dfac354bc5b5bc98d3b397567] scsi: sd: Differentiate system and runtime start/stop management
git bisect good 3cc2ffe5c16dc65dfac354bc5b5bc98d3b397567
# first bad commit: [aa3998dbeb3abce63653b7f6d4542e7dcd022590] ata: libata-scsi: Disable scsi device manage_system_start_stop
Comment 1 linuxcdeveloper 2024-09-21 06:30:18 UTC
Created attachment 306906 [details]
dmesg from first bad commit aa3998dbeb3abce63653b7f6d4542e7dcd022590
Comment 2 linuxcdeveloper 2024-09-21 06:31:30 UTC
Created attachment 306907 [details]
dmesg from last good commit 3cc2ffe5c16dc65dfac354bc5b5bc98d3b397567
Comment 3 linuxcdeveloper 2024-09-21 06:35:31 UTC
I attached 2 dmesg logs:

1. https://bugzilla.kernel.org/attachment.cgi?id=306906
2. https://bugzilla.kernel.org/attachment.cgi?id=306907

and the first one is the dmesg from first bad commit and the second one is the last good commit I found after git bisect.

As "bad commit" I mean the commit on which the issue with power cycling of HDD occurs and "good commit" is the commit on which this issue doesn't appear.
Comment 4 Artem S. Tashkinov 2024-09-21 08:44:39 UTC
Damien,

Please take a look.

There's also bug 218038 which is a fallout from this patch.
Comment 5 Artem S. Tashkinov 2024-09-21 08:46:57 UTC
Bug 218038 was solved ages ago.

Could you try something more recent, e.g. Linux 6.10.11 or 6.11? Or even 6.6.52?
Comment 6 linuxcdeveloper 2024-09-21 10:36:03 UTC
@Artem: Oops, I forgot to mention in previous comments that I've already tried also 6.10 but still the issue occurs.

Today I tried also some newer ones:
- 6.11.0 (sha: 98f7e32f20d28ec452afb208f9cffc08448a2652)
- master (sha: de848da12f752170c2ebe114804a985314fd5a6a)

but unfortunately the HDD power cycle is happening.