linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kai-Heng Feng <kai.heng.feng@canonical.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Rafael Wysocki <rafael.j.wysocki@intel.com>,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	Hans de Goede <hdegoede@redhat.com>,
	Bjorn Helgaas <bhelgaas@google.com>,
	ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
	Linux PCI <linux-pci@vger.kernel.org>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Len Brown <lenb@kernel.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] ACPI: PM: Re-enable ACPI GPE if it's already enabled
Date: Wed, 25 Nov 2020 01:31:56 +0800	[thread overview]
Message-ID: <90E54BA3-FC3A-4538-ACD0-4C4DDF570C7C@canonical.com> (raw)
In-Reply-To: <CAJZ5v0iJ_x5oXL9gG_TvCriNnPwzZYvGkkEK6_HWrH4fmCqBxQ@mail.gmail.com>



> On Nov 24, 2020, at 22:00, Rafael J. Wysocki <rafael@kernel.org> wrote:
> 
> On Tue, Nov 24, 2020 at 8:36 AM Kai-Heng Feng
> <kai.heng.feng@canonical.com> wrote:
>> 
>> Dell Precision 5550 fails to detect Thunderbolt device hotplug events,
>> once the Thunderbolt device and its root port are runtime-suspended to
>> D3cold.
>> 
>> While putting the entire hierarchy to D3cold, the root port ACPI GPE is
>> enabled via acpi_pci_propagate_wakeup() when suspending Thunderbolt
>> bridges/switches. So when putting the root port to D3cold as last step,
>> ACPI GPE is untouched as it's already enabled.
>> 
>> However, platform may need PCI devices to be in D3hot or PME enabled
>> prior enabling GPE to make it work.
> 
> What platforms and why.

Dell Precision 5550. Its thunderbolt port can't detect newly plugged thunderbolt devices.

> 
>> So re-enable ACPI GPE to address this.
>> 
>> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
>> ---
>> drivers/acpi/device_pm.c | 13 ++++++-------
>> 1 file changed, 6 insertions(+), 7 deletions(-)
>> 
>> diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
>> index 94d91c67aeae..dc25d9d204ae 100644
>> --- a/drivers/acpi/device_pm.c
>> +++ b/drivers/acpi/device_pm.c
>> @@ -757,11 +757,10 @@ static int __acpi_device_wakeup_enable(struct acpi_device *adev,
>> 
>>        mutex_lock(&acpi_wakeup_lock);
>> 
>> -       if (wakeup->enable_count >= max_count)
>> -               goto out;
>> -
>> -       if (wakeup->enable_count > 0)
>> -               goto inc;
>> +       if (wakeup->enable_count > 0) {
>> +               acpi_disable_gpe(wakeup->gpe_device, wakeup->gpe_number);
>> +               acpi_disable_wakeup_device_power(adev);
>> +       }
> 
> An event occurring at this point may be lost after this patch.

Yes, so this approach is not optimal.

> 
> It looks like you are trying to work around a hardware issue.  

Windows doesn't have this issue. So I don't think it's hardware issue.

> Can you
> please describe that issue in detail?

The GPE used by Thunderbolt root port, was previously enabled by Thunderbolt switches/bridges.
So when the GPE is already enabled when Thunderbolt root port is suspended.
However, the GPE needs to be enabled after root port is suspended, and that's the approach this patch takes.

Is there any actual hardware benefits from acpi_pci_propagate_wakeup()?
If there's no actual device benefits from it, we can remove it and only enable GPE for the root port.
Otherwise we need to quirk off Thunderbolt bridges/switches, since their native PME just work without the need to enable root port GPE.

Kai-Heng

> 
>> 
>>        error = acpi_enable_wakeup_device_power(adev, target_state);
>>        if (error)
>> @@ -777,8 +776,8 @@ static int __acpi_device_wakeup_enable(struct acpi_device *adev,
>>        acpi_handle_debug(adev->handle, "GPE%2X enabled for wakeup\n",
>>                          (unsigned int)wakeup->gpe_number);
>> 
>> -inc:
>> -       wakeup->enable_count++;
>> +       if (wakeup->enable_count < max_count)
>> +               wakeup->enable_count++;
>> 
>> out:
>>        mutex_unlock(&acpi_wakeup_lock);
>> --
>> 2.29.2


  reply	other threads:[~2020-11-24 17:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-24  7:36 [PATCH] ACPI: PM: Re-enable ACPI GPE if it's already enabled Kai-Heng Feng
2020-11-24 14:00 ` Rafael J. Wysocki
2020-11-24 17:31   ` Kai-Heng Feng [this message]
2020-11-24 17:48     ` Rafael J. Wysocki
2020-11-24 18:12       ` Kai-Heng Feng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=90E54BA3-FC3A-4538-ACD0-4C4DDF570C7C@canonical.com \
    --to=kai.heng.feng@canonical.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=bhelgaas@google.com \
    --cc=hdegoede@redhat.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=rafael@kernel.org \
    --cc=rjw@rjwysocki.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).