public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Jonathan Denose <jdenose@chromium.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	jefferymiller@google.com, Jonathan Denose <jdenose@google.com>,
	Raul Rangel <rrangel@chromium.org>,
	linux-input@vger.kernel.org
Subject: Re: [PATCH] Input: psmouse - add resync_on_resume dmi check
Date: Tue, 5 Mar 2024 10:47:17 -0800	[thread overview]
Message-ID: <ZedotW8Yu6tJ2yYL@google.com> (raw)
In-Reply-To: <CALNJtpWwhen2H9OT1-rZ4bt+huwXPOPz6qVDJ5g+emE1wRSLsw@mail.gmail.com>

On Mon, Mar 04, 2024 at 11:17:31AM -0600, Jonathan Denose wrote:
> I disabled the ideapad driver by rebuilding the kernel without the
> ideapad_laptop module. That does fix the suspend/resume issue!
> 
> Attached are the logs. Is there a way to make this permanent?

Could you please try the patch below? Thanks!

---

diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index 9fbb8d31575a..2f0c143c3137 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -127,6 +127,7 @@ MODULE_PARM_DESC(unmask_kbd_data, "Unconditional enable (may reveal sensitive da
 #endif
 
 static bool i8042_present;
+static bool i8042_ready;
 static bool i8042_bypass_aux_irq_test;
 static char i8042_kbd_firmware_id[128];
 static char i8042_aux_firmware_id[128];
@@ -190,6 +191,26 @@ void i8042_unlock_chip(void)
 }
 EXPORT_SYMBOL(i8042_unlock_chip);
 
+int i8042_device_link_add(struct device *consumer)
+{
+	if (!i8042_present)
+		return -ENODEV;
+
+	if (!i8042_platform_device || !i8042_ready)
+		return -EPROBE_DEFER;
+
+	return device_link_add(consumer, &i8042_platform_device->dev,
+			       DL_FLAG_STATELESS) != NULL;
+}
+EXPORT_SYMBOL(i8042_device_link_add);
+
+void i8042_device_link_remove(struct device *consumer)
+{
+	if (i8042_platform_device)
+		device_link_remove(consumer, &i8042_platform_device->dev);
+}
+EXPORT_SYMBOL(i8042_device_link_remove);
+
 int i8042_install_filter(bool (*filter)(unsigned char data, unsigned char str,
 					struct serio *serio))
 {
@@ -1574,6 +1595,7 @@ static int i8042_probe(struct platform_device *dev)
  */
 	i8042_register_ports();
 
+	i8042_ready = true;
 	return 0;
 
  out_fail:
diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
index ac037540acfc..d4d1bccbe882 100644
--- a/drivers/platform/x86/ideapad-laptop.c
+++ b/drivers/platform/x86/ideapad-laptop.c
@@ -1842,6 +1842,13 @@ static int ideapad_acpi_add(struct platform_device *pdev)
 			ideapad_register_rfkill(priv, i);
 
 	ideapad_sync_rfk_state(priv);
+
+	err = i8042_device_link_add(&pdev->dev);
+	if (err) {
+		dev_err(&pdev->dev, "failed to link with 8042 controller :%d", err);
+		goto i8042_link_failed;
+	}
+
 	ideapad_sync_touchpad_state(priv, false);
 
 	err = ideapad_dytc_profile_init(priv);
@@ -1882,7 +1889,9 @@ static int ideapad_acpi_add(struct platform_device *pdev)
 
 backlight_failed:
 	ideapad_dytc_profile_exit(priv);
+	i8042_device_link_remove(&pdev->dev);
 
+i8042_link_failed:
 	for (i = 0; i < IDEAPAD_RFKILL_DEV_NUM; i++)
 		ideapad_unregister_rfkill(priv, i);
 
@@ -1909,6 +1918,7 @@ static void ideapad_acpi_remove(struct platform_device *pdev)
 
 	ideapad_backlight_exit(priv);
 	ideapad_dytc_profile_exit(priv);
+	i8042_device_link_remove(&pdev->dev);
 
 	for (i = 0; i < IDEAPAD_RFKILL_DEV_NUM; i++)
 		ideapad_unregister_rfkill(priv, i);
diff --git a/include/linux/i8042.h b/include/linux/i8042.h
index 95b07f8b77fe..ce45569f5246 100644
--- a/include/linux/i8042.h
+++ b/include/linux/i8042.h
@@ -52,12 +52,15 @@
 #define I8042_CTR_AUXDIS	0x20
 #define I8042_CTR_XLATE		0x40
 
+struct device;
 struct serio;
 
 #if defined(CONFIG_SERIO_I8042) || defined(CONFIG_SERIO_I8042_MODULE)
 
 void i8042_lock_chip(void);
 void i8042_unlock_chip(void);
+int i8042_device_link_add(struct device *dev);
+void i8042_device_link_remove(struct device *dev);
 int i8042_command(unsigned char *param, int command);
 int i8042_install_filter(bool (*filter)(unsigned char data, unsigned char str,
 					struct serio *serio));
@@ -74,6 +77,15 @@ static inline void i8042_unlock_chip(void)
 {
 }
 
+int i8042_device_link_add(struct device *dev)
+{
+	return -ENODEV;
+}
+
+void i8042_device_link_remove(struct device *dev)
+{
+}
+
 static inline int i8042_command(unsigned char *param, int command)
 {
 	return -ENODEV;



Thanks.

-- 
Dmitry

  reply	other threads:[~2024-03-05 18:47 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-02 12:52 [PATCH] Input: psmouse - add resync_on_resume dmi check Jonathan Denose
2024-02-06 22:04 ` Dmitry Torokhov
2024-02-07 16:39   ` Jonathan Denose
2024-02-09 19:01     ` Dmitry Torokhov
2024-02-12 20:57       ` Jonathan Denose
2024-02-29 18:23         ` Dmitry Torokhov
2024-03-04 17:17           ` Jonathan Denose
2024-03-05 18:47             ` Dmitry Torokhov [this message]
2024-03-05 21:48               ` Jonathan Denose
2024-03-05 23:17                 ` Dmitry Torokhov
2024-03-06 16:43                   ` Jonathan Denose
2024-03-07 18:29             ` Dmitry Torokhov
2024-08-05 14:18               ` Hans de Goede
2024-08-05 16:52                 ` Dmitry Torokhov
2024-08-09 15:35                   ` Jonathan Denose
2024-08-10 12:59                     ` Hans de Goede

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=ZedotW8Yu6tJ2yYL@google.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=jdenose@chromium.org \
    --cc=jdenose@google.com \
    --cc=jefferymiller@google.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rrangel@chromium.org \
    /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