Bug 186221

Summary: pcieport takes more than 1 second to suspend and more than 1 second to resume - Macbook Pro 2015
Product: Drivers Reporter: Zhang Rui (rui.zhang)
Component: PCIAssignee: Chen Yu (yu.c.chen)
Status: REOPENED ---    
Severity: normal CC: lv.zheng, szg00000
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 4.8 Subsystem:
Regression: No Bisected commit-id:
Bug Depends on:    
Bug Blocks: 178231    
Attachments: acpidump output
the opcode log during resumed invoking _PS0

Description Zhang Rui 2016-11-01 07:31:29 UTC
During suspend to mem/freeze, pcieport either take more than 1 second to suspend, or more than 1 second to resume, or even both.
analyze_suspend shows that most of the time is spent in acpi_ps_parse_aml.
Comment 1 Zhang Rui 2016-11-01 07:32:04 UTC
Created attachment 243421 [details]
acpidump output
Comment 2 Zhang Rui 2016-11-29 08:06:38 UTC
Hi, Yu,
please confirm if the problem is gone with boot option pcie_ports=compat
Comment 3 Chen Yu 2016-12-01 00:21:27 UTC
tested on top of 4.9-rc7, with pcie_ports=compat, the resume time for pcieport(0000:00:1c.5) has not dropped, it's 1131ms.
Comment 4 Zhang Rui 2016-12-01 02:01:01 UTC
so this is not a duplicate of bug #99751
Comment 5 Chen Yu 2017-02-06 09:16:14 UTC
According to suspenresume result based on ftrace, it tooks more than 1 second to finish the following process on device:
# cat /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:66/path
\_SB_.PCI0.RP06
# cat /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:66/adr
0x001c0005


pci_pm_resume_noirq->acpi_device_set_power, thus _PS0 under this device has taken more than 1 second to finish.

Method (_PS0, 0, Serialized)  // _PS0: Power State 0
                {
                    If (((OSDW () && NVME) == 0x00))
                    {
                        GD56 = 0x01
                        PSTA = 0x00
                        Local0 = 0x00
                        While ((\_SB.PCI0.RP06.PSTA != 0x00))
                        {
                            If ((Local0 > 0x1388))
                            {
                                Break
                            }

                            Sleep (0x01)
                            Local0++
                        }

                        Sleep (0x46)
                        L23D = 0x01
                        Sleep (0x01)
                        Local0 = 0x00
                        While (L23D)
                        {
                            If ((Local0 > 0x04))
                            {
                                Break
                            }

                            Sleep (0x01)
                            Local0++
                        }

                        LEDM = 0x00
                        Local0 = (Timer + 0x00989680)
                        While ((Timer <= Local0))
                        {
                            If (((LACT == 0x01) && (\_SB.PCI0.RP06.SSD0.CLAS == 0x01)))
                            {
                                Break
                            }

                            Sleep (0x0A)
                        }
                    }
                }



Furthermore, according to acpi tracer result by appending:
 acpi.trace_method_name=_SB.PCI0.RP06._PS0 acpi.trace_state=opcode
it shows that the third while loop is always running until time out,
that is to say, the condition of
(LACT == 0x01) && (\_SB.PCI0.RP06.SSD0.CLAS == 0x01)
is never met.

While LACT and _SB.PCI-.RP06.SSD0.CLAS is located in pci config space,
I'd rather regard this issue as a firmware problem.
Comment 6 Chen Yu 2017-02-06 09:19:52 UTC
Created attachment 254211 [details]
the opcode log during resumed invoking  _PS0