[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJZ5v0gS6U6v-CEPNhgoj=f5E3q1T_Z8vOe2qokyHw4qeVhTsQ@mail.gmail.com>
Date: Wed, 31 Aug 2022 20:42:36 +0200
From: "Rafael J. Wysocki" <rafael@...nel.org>
To: Raul Rangel <rrangel@...omium.org>
Cc: "Rafael J. Wysocki" <rafael@...nel.org>,
ACPI Devel Maling List <linux-acpi@...r.kernel.org>,
linux-input <linux-input@...r.kernel.org>,
Hans de Goede <hdegoede@...hat.com>,
Mario Limonciello <mario.limonciello@....com>,
Tim Van Patten <timvp@...gle.com>,
Dmitry Torokhov <dmitry.torokhov@...il.com>,
"jingle.wu" <jingle.wu@....com.tw>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Tony Lindgren <tony@...mide.com>
Subject: Re: [PATCH 1/8] Input: elan_i2c - Use PM subsystem to manage wake irq
On Wed, Aug 31, 2022 at 8:14 PM Raul Rangel <rrangel@...omium.org> wrote:
>
> On Wed, Aug 31, 2022 at 12:01 PM Rafael J. Wysocki <rafael@...nel.org> wrote:
> >
> > On Wed, Aug 31, 2022 at 1:16 AM Raul E Rangel <rrangel@...omium.org> wrote:
> > >
> > > The Elan I2C touchpad driver is currently manually managing the wake
> > > IRQ. This change removes the explicit enable_irq_wake/disable_irq_wake
> > > and instead relies on the PM subsystem. This is done by calling
> > > dev_pm_set_wake_irq.
> > >
> > > i2c_device_probe already calls dev_pm_set_wake_irq when using device
> > > tree, so it's only required when using ACPI. The net result is that this
> > > change should be a no-op. i2c_device_remove also already calls
> > > dev_pm_clear_wake_irq, so we don't need to do that in this driver.
> > >
> > > I tested this on an ACPI system where the touchpad doesn't have _PRW
> > > defined. I verified I can still wake the system and that the wake source
> > > was the touchpad IRQ GPIO.
> > >
> > > Signed-off-by: Raul E Rangel <rrangel@...omium.org>
> >
>
>
> > I like this a lot, but the assumption in the wakeirq code is that the
> > IRQ in question will be dedicated for signaling wakeup. Does it hold
> > here?
>
> The wakeirq code defines two methods: `dev_pm_set_wake_irq` and
> `dev_pm_set_dedicated_wake_irq`.
> The latter is used when you have a dedicated wakeup signal. In this
> driver it's currently assumed
> that the IRQ and the wake IRQ are the same, so I used `dev_pm_set_wake_irq`.
>
> This change in theory also fixes a bug where you define a dedicated
> wake irq in DT, but
> then the driver enables the `client->irq` as a wake source. In
> practice this doesn't happen
> since the elan touchpads only have a single IRQ line.
OK, thanks!
Please feel free to add
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@...el.com>
to the patch.
> >
> > > ---
> > >
> > > drivers/input/mouse/elan_i2c_core.c | 12 ++++--------
> > > 1 file changed, 4 insertions(+), 8 deletions(-)
> > >
> > > diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c
> > > index e1758d5ffe4218..7d997d2b56436b 100644
> > > --- a/drivers/input/mouse/elan_i2c_core.c
> > > +++ b/drivers/input/mouse/elan_i2c_core.c
> > > @@ -33,6 +33,7 @@
> > > #include <linux/jiffies.h>
> > > #include <linux/completion.h>
> > > #include <linux/of.h>
> > > +#include <linux/pm_wakeirq.h>
> > > #include <linux/property.h>
> > > #include <linux/regulator/consumer.h>
> > > #include <asm/unaligned.h>
> > > @@ -86,8 +87,6 @@ struct elan_tp_data {
> > > u16 fw_page_size;
> > > u32 fw_signature_address;
> > >
> > > - bool irq_wake;
> > > -
> > > u8 min_baseline;
> > > u8 max_baseline;
> > > bool baseline_ready;
> > > @@ -1337,8 +1336,10 @@ static int elan_probe(struct i2c_client *client,
> > > * Systems using device tree should set up wakeup via DTS,
> > > * the rest will configure device as wakeup source by default.
> > > */
> > > - if (!dev->of_node)
> > > + if (!dev->of_node) {
> > > device_init_wakeup(dev, true);
> > > + dev_pm_set_wake_irq(dev, client->irq);
> > > + }
> > >
> > > return 0;
> > > }
> > > @@ -1362,8 +1363,6 @@ static int __maybe_unused elan_suspend(struct device *dev)
> > >
> > > if (device_may_wakeup(dev)) {
> > > ret = elan_sleep(data);
> > > - /* Enable wake from IRQ */
> > > - data->irq_wake = (enable_irq_wake(client->irq) == 0);
> > > } else {
> > > ret = elan_set_power(data, false);
> > > if (ret)
> > > @@ -1394,9 +1393,6 @@ static int __maybe_unused elan_resume(struct device *dev)
> > > dev_err(dev, "error %d enabling regulator\n", error);
> > > goto err;
> > > }
> > > - } else if (data->irq_wake) {
> > > - disable_irq_wake(client->irq);
> > > - data->irq_wake = false;
> > > }
> > >
> > > error = elan_set_power(data, true);
> > > --
> > > 2.37.2.672.g94769d06f0-goog
> > >
Powered by blists - more mailing lists