From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: "Zheng, Lv" <lv.zheng@intel.com>
Cc: Linux ACPI <linux-acpi@vger.kernel.org>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
Linux PCI <linux-pci@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
"Moore, Robert" <robert.moore@intel.com>
Subject: Re: [PATCH 1/3] ACPICA: Dispatch active GPEs at init time
Date: Fri, 11 Aug 2017 14:23:00 +0200 [thread overview]
Message-ID: <3677056.OS19FbOdkF@aspire.rjw.lan> (raw)
In-Reply-To: <1AE640813FDE7649BE1B193DEA596E886CF09085@SHSMSX101.ccr.corp.intel.com>
On Friday, August 11, 2017 7:40:56 AM CEST Zheng, Lv wrote:
> Hi, Rafael
>
> > From: Rafael J. Wysocki [mailto:rjw@rjwysocki.net]
> > Subject: Re: [PATCH 1/3] ACPICA: Dispatch active GPEs at init time
> >
> > On Thursday, August 10, 2017 3:48:58 AM CEST Zheng, Lv wrote:
> > > Hi, Rafael
> > >
> > > > From: Rafael J. Wysocki [mailto:rjw@rjwysocki.net]
> > > > Subject: [PATCH 1/3] ACPICA: Dispatch active GPEs at init time
> > > >
> > > > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > > >
> > > > In some cases GPEs are already active when they are enabled by
> > > > acpi_ev_initialize_gpe_block() and whatever happens next may depend
> > > > on the result of handling the events signaled by them, so the
> > > > events should not be discarded (which is what happens currently) and
> > > > they should be handled as soon as reasonably possible.
> > > >
> > > > For this reason, modify acpi_ev_initialize_gpe_block() to
> > > > dispatch GPEs with the status flag set in-band right after
> > > > enabling them.
> > >
> > > In fact, what we need seems to be invoking acpi_ev_gpe_dispatch()
> > > right after enabling an GPE. So there are 2 conditions related:
> > > 1. GPE is enabled for the first time.
> > > 2. GPE is initialized.
> > >
> > > And we need to make sure that before acpi_update_all_gpes() is invoked,
> > > all GPE EN bits are actually disabled.
> >
> > But we don't do it today, do we?
>
> We don't do that.
>
> >
> > And still calling _dispatch() should not be incorrect even if the GPE
> > has been enabled already at this point. Worst case it just will
> > queue up the execution of _Lxx/_Exx which may or may not do anything
> > useful.
> >
> > And BTW this is all done under acpi_gbl_gpe_lock so acpi_ev_gpe_detect()
> > will block on it if run concurrently and we've checked the status, so
> > we know that the GPE *should* be dispatched, so I sort of fail to see
> > the problem.
>
> There is another problem related:
> ACPICA clears GPEs before enabling it.
> This is proven to be wrong, and we have to fix it:
> https://bugzilla.kernel.org/show_bug.cgi?id=196249
>
> without fixing this issue, in this solution, we surely need to save the
> GPE STS bit before incrementing GPE reference count, and poll it according
> to the saved STS bit. Because if we poll it after enabling, STS bit will
> be wrongly cleared.
I'm not sure if I understand you correctly, but why would we poll it?
In the $subject patch the status is checked and then
acpi_ev_add_gpe_reference() is called to add a reference to the GPE.
If this is the first reference (which will be the case in the majority
of cases), acpi_ev_enable_gpe() will be called and that will clear the
status.
Then, acpi_ev_gpe_dispatch() is called if the status was set and that
itself doesn't check the status. It disables the GPE upfront (so the
status doesn't matter from now on until the GPE is enabled again) and
clears the status unconditionally if the GPE is edge-triggered. This
means that for edge-triggered GPEs the clearing of the status by
acpi_ev_enable_gpe() doesn't matter here.
For level-triggered GPEs the status is not cleared by acpi_ev_gpe_dispatch()
itself, but _Lxx is executed (again, without checking the status) and
finally the status is cleared by acpi_ev_finish_gpe() anyway, so we
end up with cleared status no matter what (and that before re-enabling
the GPE). End even if _Lxx itself checked the status (but honestly why
would it?), then this is a level-triggered GPE, so it will re-trigger
anyway if not handled this time.
So it looks like the fact that acpi_ev_enable_gpe() clears the status before
enabling the GPE doesn't matter for this patch, although it may matter in
general, but that is a different (and somewhat related) issue.
Thanks,
Rafael
next prev parent reply other threads:[~2017-08-11 12:23 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-09 22:29 [PATCH 0/3] ACPI: Initialize GPEs before the initial namespace scan Rafael J. Wysocki
2017-08-09 22:30 ` [PATCH 1/3] ACPICA: Dispatch active GPEs at init time Rafael J. Wysocki
2017-08-10 1:48 ` Zheng, Lv
2017-08-10 16:06 ` Rafael J. Wysocki
2017-08-11 5:40 ` Zheng, Lv
2017-08-11 12:23 ` Rafael J. Wysocki [this message]
2017-08-15 9:59 ` Zheng, Lv
2017-08-15 12:21 ` Rafael J. Wysocki
2017-08-17 2:24 ` Zheng, Lv
2017-08-09 22:31 ` [PATCH 2/3] ACPICA: Make it possible to enable runtime GPEs earlier Rafael J. Wysocki
2017-08-10 1:52 ` Zheng, Lv
2017-08-10 16:07 ` Rafael J. Wysocki
2017-08-11 6:13 ` Zheng, Lv
2017-08-09 22:34 ` [PATCH 3/3] ACPI / scan: Enable GPEs before scanning the namespace Rafael J. Wysocki
2017-08-10 1:54 ` Zheng, Lv
2017-08-10 5:10 ` Lukas Wunner
2017-08-10 7:45 ` Zheng, Lv
2017-08-10 8:23 ` Mika Westerberg
2017-08-15 2:12 ` Zheng, Lv
2017-08-15 12:22 ` Rafael J. Wysocki
2017-08-17 2:25 ` Zheng, Lv
2017-08-10 9:34 ` [PATCH 0/3] ACPI: Initialize GPEs before the initial namespace scan Mika Westerberg
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=3677056.OS19FbOdkF@aspire.rjw.lan \
--to=rjw@rjwysocki.net \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lv.zheng@intel.com \
--cc=mika.westerberg@linux.intel.com \
--cc=robert.moore@intel.com \
--cc=srinivas.pandruvada@linux.intel.com \
/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