All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Input: psmouse - set up dependency between PS/2 and SMBus companions
@ 2022-02-15 20:42 Dmitry Torokhov
  2022-02-15 20:53 ` Thorsten Leemhuis
  0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Torokhov @ 2022-02-15 20:42 UTC (permalink / raw)
  To: linux-input
  Cc: Benjamin Tissoires, Rafael J. Wysocki, Rajat Jain, Wolfram Sang,
	Jarkko Nikula, Hugh Dickins, Thorsten Leemhuis, linux-kernel

When we switch from emulated PS/2 to native (RMI4 or Elan) protocols, we
create SMBus companion devices that are attached to I2C/SMBus controllers.
However, when suspending and resuming, we also need to make sure that we
take into account the PS/2 device they are associated with, so that PS/2
device is suspended after the companion and resumed before it, otherwise
companions will not work properly. Before I2C devices were marked for
asynchronous suspend/resume, this ordering happened naturally, but now we
need to enforce it by establishing device links, with PS/2 devices being
suppliers and SMBus companions being consumers.

Fixes: 172d931910e1 ("i2c: enable async suspend/resume on i2c client devices")
Reported-and-tested-by: Hugh Dickins <hughd@google.com>
Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/mouse/psmouse-smbus.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/input/mouse/psmouse-smbus.c b/drivers/input/mouse/psmouse-smbus.c
index a472489ccbad..164f6c757f6b 100644
--- a/drivers/input/mouse/psmouse-smbus.c
+++ b/drivers/input/mouse/psmouse-smbus.c
@@ -75,6 +75,8 @@ static void psmouse_smbus_detach_i2c_client(struct i2c_client *client)
 				    "Marking SMBus companion %s as gone\n",
 				    dev_name(&smbdev->client->dev));
 			smbdev->dead = true;
+			device_link_remove(&smbdev->client->dev,
+					   &smbdev->psmouse->ps2dev.serio->dev);
 			serio_rescan(smbdev->psmouse->ps2dev.serio);
 		} else {
 			list_del(&smbdev->node);
@@ -174,6 +176,8 @@ static void psmouse_smbus_disconnect(struct psmouse *psmouse)
 		kfree(smbdev);
 	} else {
 		smbdev->dead = true;
+		device_link_remove(&smbdev->client->dev,
+				   &psmouse->ps2dev.serio->dev);
 		psmouse_dbg(smbdev->psmouse,
 			    "posting removal request for SMBus companion %s\n",
 			    dev_name(&smbdev->client->dev));
@@ -270,6 +274,12 @@ int psmouse_smbus_init(struct psmouse *psmouse,
 
 	if (smbdev->client) {
 		/* We have our companion device */
+		if (!device_link_add(&smbdev->client->dev,
+				     &psmouse->ps2dev.serio->dev,
+				     DL_FLAG_STATELESS))
+			psmouse_warn(psmouse,
+				     "failed to set up link with iSMBus companion %s\n",
+				     dev_name(&smbdev->client->dev));
 		return 0;
 	}
 
-- 
2.35.1.265.g69c8d7142f-goog


-- 
Dmitry

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Input: psmouse - set up dependency between PS/2 and SMBus companions
  2022-02-15 20:42 [PATCH] Input: psmouse - set up dependency between PS/2 and SMBus companions Dmitry Torokhov
@ 2022-02-15 20:53 ` Thorsten Leemhuis
  0 siblings, 0 replies; 2+ messages in thread
From: Thorsten Leemhuis @ 2022-02-15 20:53 UTC (permalink / raw)
  To: Dmitry Torokhov, linux-input
  Cc: Benjamin Tissoires, Rafael J. Wysocki, Rajat Jain, Wolfram Sang,
	Jarkko Nikula, Hugh Dickins, linux-kernel



On 15.02.22 21:42, Dmitry Torokhov wrote:
> When we switch from emulated PS/2 to native (RMI4 or Elan) protocols, we
> create SMBus companion devices that are attached to I2C/SMBus controllers.
> However, when suspending and resuming, we also need to make sure that we
> take into account the PS/2 device they are associated with, so that PS/2
> device is suspended after the companion and resumed before it, otherwise
> companions will not work properly. Before I2C devices were marked for
> asynchronous suspend/resume, this ordering happened naturally, but now we
> need to enforce it by establishing device links, with PS/2 devices being
> suppliers and SMBus companions being consumers.
> 
> Fixes: 172d931910e1 ("i2c: enable async suspend/resume on i2c client devices")
> Reported-and-tested-by: Hugh Dickins <hughd@google.com>
> Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

If you respin or commit this patch, could you please add the link to the
report, as explained in 'Documentation/process/submitting-patches.rst'
and 'Documentation/process/5.Posting.rst':

Link:
https://lore.kernel.org/r/89456fcd-a113-4c82-4b10-a9bcaefac68f@google.com

This would be helpful for me, as this is a regression tracked by
regzbot, my Linux kernel regression tracking bot, which then is able to
assign threads like this with the regression report and mark the
regression as resolved once the fix lands in the appropriate tree. tia!

Ciao, Thorsten

#regzbot ^backmonitor:
https://lore.kernel.org/r/89456fcd-a113-4c82-4b10-a9bcaefac68f@google.com


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-02-15 20:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-15 20:42 [PATCH] Input: psmouse - set up dependency between PS/2 and SMBus companions Dmitry Torokhov
2022-02-15 20:53 ` Thorsten Leemhuis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.