diff mbox

[Bug,106031] Regression in 4.2.x: in airplane mode each time I open my laptop lid

Message ID 562A022D.1020302@gmail.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Gabriele Mazzotta Oct. 23, 2015, 9:47 a.m. UTC
On 23/10/2015 11:00, Pali Rohár wrote:
> On Friday 23 October 2015 01:29:12 Gabriele Mazzotta wrote:
>> On 22/10/2015 16:17, Pali Rohár wrote:
>>> On Thursday 22 October 2015 15:43:46 Gabriele Mazzotta wrote:
>>>> It's the F2 key. Depending on the value passed to the RBTN, it acts as
>>>> hw slider or sw toggle.
>>>
>>> Ok, we have differences in terminology and everybody understood this
>>> problem differently.
>>>
>>>
>>> To correct this situation, first define about what we are talking about:
>>>
>>> * HW slider: It is hardware slider switch which as two positions ON and
>>>               OFF. Position exactly defines hardware state of wireless
>>>               radio devices. Not possible (or should not) to remap.
>>>
>>> * SW hotkey toggle button: It is button or key, act in same way as any
>>>                             other key on keyboard, controlled by SW
>>>                             (if all drivers are installed, etc).
>>
>> Sorry for the confusion, I know I've been using "HW slider" improperly,
>> but I thought it was clear. Although it's a button, the BIOS makes it
>> behave like an hardware slider when configured to behave as such
>> through RBTN. The state of radio devices is changed by the BIOS when
>> the function key is pressed, this state is never changed until the user
>> presses the function key again (at least if we ignore the fact that we
>> can perform some special SMI calls), this state is saved in the EC and
>> both userspace and the kernel don't receive any event other than rfkill
>> events (if we don't consider the WMI events ignored by dell-wmi).
>>
>> I think this behavior is closer to the one of an hardware slider
>> rather than the one of a software hotkey, which I can still request
>> through the RBTN method.
>>
>>> Next I think that this hypothesis is truth:
>>>
>>> * Every machine on which is binded ACPI dell-rbtn.ko driver has either
>>>    HW slider or SW toggle. Not both!
>>>
>>> Correct?
>>
>> It depends on how you classify my laptop. The behavior changes
>> completely depending on the value passed to RBTN.
>>
>> Obviously it can behave either as HW slider (again, not an actual
>> slider) or SW toggle, but I can choose between the two.
>>
>
> If it has keyboard button and not switch with visible two positions, it
> is "toggle button" (from HW perspective).

Yes, sorry for the confusion.

>>> Then follows my expected behaviour for HW slider:
>>>
>>> * State of HW slider position is exported by kernel as rfkill device.
>>>
>>> * In any case HW slider position (ON/OFF) match hard rfkill state device
>>>    (rfkill device state is correct also after resume, wake from hibernate).
>>>
>>> * Immediately after user change position of HW slider, rfkill device
>>>    reflect it.
>>>
>>>
>>> And then expected behaviour for SW toggle button:
>>>
>>> * Every time when user press it, kernel just send input event "wireless
>>>    key pressed" to userspace.
>>>
>>> * Kernel does not send event "wireless key pressed" when user did not
>>>    pressed it (e.g. after resuming from suspend, waking from hibernate).
>>
>> Yes, but we don't know exactly when the user pressed the button. As I
>> said, the BIOS might send an event that triggers an input event even if
>> the user didn't press anything.
>>
>
> Ok. This is strange if BIOS send event "changed" even if it was not
> really changed.
>
> Is BIOS sending this incorrect event only after waking from suspend? Or
> it is also randomly at any time?

I looked at the ACPI table. It happens only on resume (or when the user
presses the function key).

> If we know that it send incorrectly only after suspend, we can drop this
> event. But if it is completely randomly, we probably cannot do anything
> (and just do not use driver in this case).
>
>>> * Kernel should provide rfkill devices to "soft" block appropriate
>>>    wireless cards.
>>>
>>> * Make sure that BIOS/firmware in any case does not change radio rfkill
>>>    state of any wireless card and wireless cards stay in same state as
>>>    before (no enable/disable or changing hard/soft rfkill state).
>>
>> This is the problem. We can't differentiate notifications sent to
>> DELLABCE/DELLRBTN by the BIOS because it felt like it was right to do so
>> (e.g. after resuming) or because the user pressed the function key.
>>
>
> 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.

  			 event);

>>> If last sentence is not truth, then kernel must not send "wireless key
>>> pressed" event to userspace and act like "no key was pressed".
>>>
>>>
>>> Make this sense? Or are there any objections about this behaviour?
>>>
>
> So if you are OK with above my description (from previous email), then
> we should fix dell-rbtn to act as it (if it is not implemented already
> and correctly).
>
> So my next question is: Does dell-rbtn behave like my description? If
> not what are differences and what needs to be fixed?

Everything works as expected. We only have to deal with this extra
notification.
--
To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Pali Rohár Oct. 23, 2015, 11:14 a.m. UTC | #1
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?
Gabriele Mazzotta Oct. 23, 2015, 6:03 p.m. UTC | #2
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").
--
To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Darren Hart Oct. 26, 2015, 2:38 p.m. UTC | #3
On Fri, Oct 23, 2015 at 08:03:19PM +0200, 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").
> 

My understanding here though is that laptops with a Fn+RBTN key which changes
the state of the radio in firmware should be handled via the rfkill interface
rather than the inpu interface - so while this patch may appear to work, it's
using the input interface to copy the rfkill interface/state.

The proper solution, if I'm understanding this correctly - and apologies if not,
some of this is new territory for me as well - would be for this device to be
detected as firmware controlled (what we refer to as a SLIDER in the code -
which needs to be renamed IMHO).

Let's sort out this point, then we can pull in Rafael to make sure this is how
to best deal with the spurious event on resume.
Pali Rohár Oct. 26, 2015, 2:58 p.m. UTC | #4
On Monday 26 October 2015 23:38:13 Darren Hart wrote:
> My understanding here though is that laptops with a Fn+RBTN key which changes
> the state of the radio in firmware should be handled via the rfkill interface
> rather than the inpu interface - so while this patch may appear to work, it's
> using the input interface to copy the rfkill interface/state.
> 

Here is problem: ACPI device ABCE/RBTN (handled by dell-rbtn.ko) just
receive events. It cannot set or change wireless state.

For changing rfkill/wireless state is there Dell SMBIOS api and it is
implemented in dell-laptop.ko. But due to bugs in that module, it is
disabled for XPS machines.

And problem is that on machines without HW switch you do not know if
wifi switch is in ON or OFF mode. ACPI tell you just "key pressed". So
for this reason Alex decided to export that event via input layer,
because it is really just key press, not changing state.

> The proper solution, if I'm understanding this correctly - and apologies if not,
> some of this is new territory for me as well - would be for this device to be
> detected as firmware controlled (what we refer to as a SLIDER in the code -
> which needs to be renamed IMHO).
> 

I understood that if you blacklist dell-rbtn.ko on that XPS machine,
then firmware takes control and automatically turn ON/OFF wifi card.

> Let's sort out this point, then we can pull in Rafael to make sure this is how
> to best deal with the spurious event on resume.
> 

For me solution (=ignore events when ACPI device is suspended) sounds
good. I do not know if there is better way to implement it, maybe
general linux device model should provide function "am_i_suspended?"
instead tracking "suspend" state internally in each driver. But if such
support in linux device or acpi model is not implemented, I'm fine with
provided patch if it really works.
Pali Rohár Nov. 20, 2015, 2:44 p.m. UTC | #5
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?
Darren Hart Dec. 19, 2015, 12:12 a.m. UTC | #6
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

Has Dell been involved here?

+Jared
Rafael J. Wysocki Dec. 20, 2015, 4:21 p.m. UTC | #7
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.

> Has Dell been involved here?

Not that I know of.

Thanks,
Rafael

--
To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Gabriele Mazzotta Dec. 21, 2015, 3:34 p.m. UTC | #8
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.

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.

Thanks,
Gabriele

>> Has Dell been involved here?
>
> Not that I know of.
>
> Thanks,
> Rafael
>
--
To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Rafael J. Wysocki Dec. 22, 2015, 12:20 a.m. UTC | #9
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

--
To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Alex Hung Dec. 22, 2015, 9:03 a.m. UTC | #10
On Mon, Dec 21, 2015 at 11:34 PM, Gabriele Mazzotta
<gabriele.mzt@gmail.com> 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.

Sorry I screw up my mail filter and I wasn't aware of this thread until now.

BIOS sends this additional ACPI event for the systems with hardware
switch so a driver can update its state; therefore this is done only
once and therefore ignoring the ACPI event sent to dell rbtn once
after resume is sufficient.

I actually tried a solution similar to Gabriele's patch above (one
with rbtn_suspend and rbtn_resume) a while ago and it works fine.

If there is a conclusion and there is a patch to be tested, I am happy
to test it on wider range (I should be able to find 5+ Dell systems
that runs on dell-rbtn).

>
> 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.
>
> Thanks,
> Gabriele
>
>>> Has Dell been involved here?
>>
>> Not that I know of.
>>
>> Thanks,
>> Rafael
>>
Pali Rohár Jan. 7, 2016, 10:35 p.m. UTC | #11
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?
Pali Rohár March 11, 2016, 9:45 a.m. UTC | #12
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?
Gabriele Mazzotta March 11, 2016, 11:30 p.m. UTC | #13
2016-03-11 10:45 GMT+01:00 Pali Rohár <pali.rohar@gmail.com>:
> 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?

As far as I know, there was no progress. I'm now going to try what
Rafael suggested and see what I can do.

> --
> Pali Rohár
> pali.rohar@gmail.com
--
To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Pali Rohár March 14, 2016, 11:29 a.m. UTC | #14
On Saturday 12 March 2016 00:30:37 Gabriele Mazzotta wrote:
> 2016-03-11 10:45 GMT+01:00 Pali Rohár <pali.rohar@gmail.com>:
> > Gabriele, Darren, Alex... was this problem fixed? Or what is current state?
> 
> As far as I know, there was no progress. I'm now going to try what
> Rafael suggested and see what I can do.

Ok, thanks for info. If you have some results, let us know as we can
finally fix this problem...
diff mbox

Patch

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",