lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211220163823.2.Id022caf53d01112188308520915798f08a33cd3e@changeid>
Date:   Mon, 20 Dec 2021 16:43:45 -0700
From:   Raul E Rangel <rrangel@...omium.org>
To:     linux-kernel@...r.kernel.org
Cc:     mario.limonciello@....com, linux-input@...r.kernel.org,
        dianders@...omium.org, Raul E Rangel <rrangel@...omium.org>,
        Dmitry Torokhov <dmitry.torokhov@...il.com>,
        "jingle.wu" <jingle.wu@....com.tw>
Subject: [PATCH 2/3] Input: elan_i2c - Use PM subsystem to manage wake irq

The Elan I2C touchpad driver is currently manually managing the wake
IRQ. When a device is managed by device tree or ACPI it is expected that
those subsystems manage defining the wake pin and manage enabling it.

This change removes the explicit enable_irq_wake/disable_irq_wake and
relies on the PM subsystem. See device_wakeup_arm_wake_irqs.

It also registers the IRQ using dev_pm_set_wake_irq only in the case
where the device isn't DT or ACPI managed. This should preserve the
existing behavior. I'm not sure how we actually get into this state
though.

I tested this with an ACPI device that has a `_PRW` method that uses a
GPE was the wake event. I no longer see the GPIO controller being called
to enable the wake pin. This results in the GPE correctly being marked
as the wake source.

Signed-off-by: Raul E Rangel <rrangel@...omium.org>
---

 drivers/input/mouse/elan_i2c_core.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c
index 47af62c12267..58f056ee0747 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;
@@ -1368,11 +1367,13 @@ static int elan_probe(struct i2c_client *client,
 	}
 
 	/*
-	 * Systems using device tree should set up wakeup via DTS,
+	 * Systems using device tree or ACPI should set up wakeup via DTS/ACPI,
 	 * the rest will configure device as wakeup source by default.
 	 */
-	if (!dev->of_node)
+	if (!dev->of_node && !ACPI_COMPANION(dev)) {
 		device_init_wakeup(dev, true);
+		dev_pm_set_wake_irq(dev, client->irq);
+	}
 
 	return 0;
 }
@@ -1394,13 +1395,10 @@ static int __maybe_unused elan_suspend(struct device *dev)
 
 	disable_irq(client->irq);
 
-	if (device_may_wakeup(dev)) {
+	if (device_may_wakeup(dev))
 		ret = elan_sleep(data);
-		/* Enable wake from IRQ */
-		data->irq_wake = (enable_irq_wake(client->irq) == 0);
-	} else {
+	else
 		ret = elan_disable_power(data);
-	}
 
 	mutex_unlock(&data->sysfs_mutex);
 	return ret;
@@ -1412,11 +1410,6 @@ static int __maybe_unused elan_resume(struct device *dev)
 	struct elan_tp_data *data = i2c_get_clientdata(client);
 	int error;
 
-	if (device_may_wakeup(dev) && data->irq_wake) {
-		disable_irq_wake(client->irq);
-		data->irq_wake = false;
-	}
-
 	error = elan_enable_power(data);
 	if (error) {
 		dev_err(dev, "power up when resuming failed: %d\n", error);
-- 
2.34.1.307.g9b7440fafd-goog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ