From: "Pali Rohár" <pali.rohar@gmail.com>
To: Gabriele Mazzotta <gabriele.mzt@gmail.com>,
Darren Hart <dvhart@infradead.org>,
Alex Hung <alex.hung@canonical.com>
Cc: "D. Jared Dominguez" <Jared_Dominguez@dell.com>,
"platform-driver-x86@vger.kernel.org"
<platform-driver-x86@vger.kernel.org>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>
Subject: Re: [Bug 106031] Regression in 4.2.x: in airplane mode each time I open my laptop lid
Date: Fri, 11 Mar 2016 10:45:06 +0100 [thread overview]
Message-ID: <20160311094506.GC8413@pali> (raw)
In-Reply-To: <20160107223529.GL11364@pali>
On Thursday 07 January 2016 23:35:29 Pali Rohár wrote:
> On Tuesday 22 December 2015 01:20:30 Rafael J. Wysocki wrote:
> > On Monday, December 21, 2015 04:34:58 PM Gabriele Mazzotta wrote:
> > > 2015-12-20 17:21 GMT+01:00 Rafael J. Wysocki <rjw@rjwysocki.net>:
> > > > On Friday, December 18, 2015 04:12:08 PM Darren Hart wrote:
> > > >> On Fri, Nov 20, 2015 at 03:44:25PM +0100, Pali Rohár wrote:
> > > >> > On Friday 23 October 2015 20:03:19 Gabriele Mazzotta wrote:
> > > >> > > On 23/10/2015 13:14, Pali Rohár wrote:
> > > >> > > >On Friday 23 October 2015 11:47:25 Gabriele Mazzotta wrote:
> > > >> > > >>>In my opinion it is better to ignore user key press after resume, if it
> > > >> > > >>>fix our problem. Better as false-positive event.
> > > >> > > >>
> > > >> > > >>The following appears to work really well. The notification arrives
> > > >> > > >>before rbtn_resume() has been executed, so the extra event is ignored.
> > > >> > > >>
> > > >> > > >>diff --git a/drivers/platform/x86/dell-rbtn.c
> > > >> > > >>b/drivers/platform/x86/dell-rbtn.c
> > > >> > > >>index cd410e3..1d64b72 100644
> > > >> > > >>--- a/drivers/platform/x86/dell-rbtn.c
> > > >> > > >>+++ b/drivers/platform/x86/dell-rbtn.c
> > > >> > > >>@@ -28,6 +28,7 @@ struct rbtn_data {
> > > >> > > >> enum rbtn_type type;
> > > >> > > >> struct rfkill *rfkill;
> > > >> > > >> struct input_dev *input_dev;
> > > >> > > >>+ bool suspended;
> > > >> > > >> };
> > > >> > > >>
> > > >> > > >>
> > > >> > > >>@@ -220,9 +221,33 @@ static const struct acpi_device_id rbtn_ids[] = {
> > > >> > > >> { "", 0 },
> > > >> > > >> };
> > > >> > > >>
> > > >> > > >>+#ifdef CONFIG_PM_SLEEP
> > > >> > > >>+static int rbtn_suspend(struct device *dev)
> > > >> > > >>+{
> > > >> > > >>+ struct acpi_device *device = to_acpi_device(dev);
> > > >> > > >>+ struct rbtn_data *rbtn_data = acpi_driver_data(device);
> > > >> > > >>+
> > > >> > > >>+ rbtn_data->suspended = true;
> > > >> > > >>+
> > > >> > > >>+ return 0;
> > > >> > > >>+}
> > > >> > > >>+
> > > >> > > >>+static int rbtn_resume(struct device *dev)
> > > >> > > >>+{
> > > >> > > >>+ struct acpi_device *device = to_acpi_device(dev);
> > > >> > > >>+ struct rbtn_data *rbtn_data = acpi_driver_data(device);
> > > >> > > >>+
> > > >> > > >>+ rbtn_data->suspended = false;
> > > >> > > >>+
> > > >> > > >>+ return 0;
> > > >> > > >>+}
> > > >> > > >>+#endif
> > > >> > > >>+static SIMPLE_DEV_PM_OPS(rbtn_pm_ops, rbtn_suspend, rbtn_resume);
> > > >> > > >>+
> > > >> > > >> static struct acpi_driver rbtn_driver = {
> > > >> > > >> .name = "dell-rbtn",
> > > >> > > >> .ids = rbtn_ids,
> > > >> > > >>+ .drv.pm = &rbtn_pm_ops,
> > > >> > > >> .ops = {
> > > >> > > >> .add = rbtn_add,
> > > >> > > >> .remove = rbtn_remove,
> > > >> > > >>@@ -384,6 +409,9 @@ static void rbtn_notify(struct acpi_device *device, u32
> > > >> > > >>event)
> > > >> > > >> {
> > > >> > > >> struct rbtn_data *rbtn_data = device->driver_data;
> > > >> > > >>
> > > >> > > >>+ if (rbtn_data->suspended)
> > > >> > > >>+ return;
> > > >> > > >>+
> > > >> > > >> if (event != 0x80) {
> > > >> > > >> dev_info(&device->dev, "Received unknown event (0x%x)\n",
> > > >> > > >> event);
> > > >> > > >>
> > > >> > > >
> > > >> > > >Great, but is not there a better way to turn off .notify ACPI function
> > > >> > > >when that ACPI device is suspended?
> > > >> > > >
> > > >> > > >Is not this ACPI device driver bug that it allows to call .notify method
> > > >> > > >even if device is suspended?
> > > >> > >
> > > >> > > I was surprised this worked, I was assuming that nothing could run
> > > >> > > before the resume callback, but I was wrong. I think it makes sense to
> > > >> > > treat ACPI devices in a special way, but I really don't know, we need
> > > >> > > someone more knowledgeable to answer these questions. However, while I
> > > >> > > was trying to figure things out, I stumbled upon the following:
> > > >> > > e71eeb2a6bcc ("ACPI / button: Do not propagate wakeup-from-suspend events").
> > > >> >
> > > >> > Gabriele, are you going to send this patch?
> > > >> >
> > > >> > I think that patch should be OK as it drop events when device is in
> > > >> > suspend state (when it should not receive events)...
> > > >> >
> > > >> > Darren, what do you think about it?
> > > >> >
> > > >>
> > > >> Sorry, this one has been difficult for me to track, but it's clearly an issue,
> > > >> and new systems are experiencing it as well.
> > > >>
> > > >> I'd like to get Rafael's opinion on disabling .notify ACPI function while
> > > >> suspended.
> > > >>
> > > >> +Rafael
> > > >
> > > > This by far wouldn't be enough, because drivers may install ACPI notify
> > > > handlers by themselves and those are hooked up directly into the ACPICA
> > > > code.
> > > >
> > > > Besides, some drivers may actually want to receive those events while
> > > > the system is suspending or resuming, so I think this has to be addressed
> > > > on a per-driver basis.
> > >
> > > Hi,
> > >
> > > sorry, but I'm not sure I understood everything, so I'll try to
> > > briefly describe the problem and its current solution.
> > >
> > > Currently dell-rbtn listens for the notifications sent to an ACPI
> > > device and for notification sends an input event to userspace.
> > >
> > > The problem we have is that some BIOSes send an extra notification
> > > on resume and therefore we send an extra input event.
> > >
> > > What we want to do is to ignore this ACPI notification without
> > > affecting the systems whose BIOS does not send this extra
> > > notification. We know that not all of them send this notification.
> > >
> > > What I noticed is that the extra notification is issued by the _WAK
> > > method and always arrives before dell-rbtn has been resumed, so
> > > what I did is to add a flag that is set by the suspend and resume
> > > callbacks of the device driver.
> >
> > ACPI notifications are delivered asynchronously to drivers, so you'd
> > need to flush kacpi_notify_wq in .resume(). That would make the driver
> > wait for things it really doesn't need to wait for, so it would not be
> > super-optimal.
> >
> > > What we were wondering is whether this would be enough or we
> > > need to do something different, e.g. ignore all the notifications that
> > > arrived X seconds after the execution of the resume callback.
> >
> > I'd try something like setting the flag from .suspend() and then adding
> > a work item to clear it to kacpi_notify_wq from .resume(). Then you'll
> > know that all of the pending notifications have been processed before
> > your flag is cleared.
> >
> > That would require a new helper for adding work items to kacpi_notify_wq
> > from drivers, but it shouldn't be too difficult to create one.
> >
> > Thanks,
> > Rafael
> >
>
> Hi all! Is there any progress or new version of this patch?
>
Gabriele, Darren, Alex... was this problem fixed? Or what is current state?
--
Pali Rohár
pali.rohar@gmail.com
next prev parent reply other threads:[~2016-03-11 9:45 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <bug-106031-5380@https.bugzilla.kernel.org/>
[not found] ` <bug-106031-5380-zVXKHiyrZU@https.bugzilla.kernel.org/>
2015-10-21 8:57 ` [Bug 106031] Regression in 4.2.x: in airplane mode each time I open my laptop lid Darren Hart
2015-10-21 9:19 ` Pali Rohár
2015-10-21 11:00 ` Pali Rohár
2015-10-21 11:12 ` Darren Hart
2015-10-21 11:42 ` Gabriele Mazzotta
2015-10-21 18:53 ` Gabriele Mazzotta
2015-10-22 7:49 ` Darren Hart
2015-10-22 8:26 ` Gabriele Mazzotta
2015-10-22 8:51 ` Pali Rohár
2015-10-22 10:44 ` Gabriele Mazzotta
2015-10-22 10:50 ` Pali Rohár
2015-10-22 10:54 ` Gabriele Mazzotta
2015-10-22 13:02 ` Darren Hart
2015-10-22 13:43 ` Gabriele Mazzotta
2015-10-22 14:17 ` Pali Rohár
2015-10-22 23:29 ` Gabriele Mazzotta
2015-10-23 9:00 ` Pali Rohár
2015-10-23 9:47 ` Gabriele Mazzotta
2015-10-23 11:14 ` Pali Rohár
2015-10-23 18:03 ` Gabriele Mazzotta
2015-10-26 14:38 ` Darren Hart
2015-10-26 14:58 ` Pali Rohár
2015-11-20 14:44 ` Pali Rohár
2015-12-19 0:12 ` Darren Hart
2015-12-20 16:21 ` Rafael J. Wysocki
2015-12-21 15:34 ` Gabriele Mazzotta
2015-12-22 0:20 ` Rafael J. Wysocki
2016-01-07 22:35 ` Pali Rohár
2016-03-11 9:45 ` Pali Rohár [this message]
2016-03-11 23:30 ` Gabriele Mazzotta
2016-03-14 11:29 ` Pali Rohár
2015-12-22 9:03 ` Alex Hung
2015-10-22 8:17 ` Darren Hart
2015-10-22 8:27 ` Pali Rohár
2015-10-22 8:53 ` Darren Hart
2015-10-22 8:28 ` Gabriele Mazzotta
2015-10-22 8:35 ` Darren Hart
[not found] <bug-106031-215701@https.bugzilla.kernel.org/>
2022-02-21 21:19 ` bugzilla-daemon
2022-02-21 21:19 ` bugzilla-daemon
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=20160311094506.GC8413@pali \
--to=pali.rohar@gmail.com \
--cc=Jared_Dominguez@dell.com \
--cc=alex.hung@canonical.com \
--cc=dvhart@infradead.org \
--cc=gabriele.mzt@gmail.com \
--cc=platform-driver-x86@vger.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