All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: "Carlos R. Mafra" <crmafra2@gmail.com>
Cc: linux-kernel@vger.kernel.org, "Rafael J. Wysocki" <rjw@sisk.pl>,
	linux-input@vger.kernel.org
Subject: Re: [bisected regression] Touchpad "paste" stops working after suspend to RAM
Date: Mon, 12 Oct 2009 20:24:14 -0700	[thread overview]
Message-ID: <20091013032414.GC2887@core.coreip.homeip.net> (raw)
In-Reply-To: <20091012100929.GA4402@Pilar.aei.mpg.de>

On Mon, Oct 12, 2009 at 12:09:29PM +0200, Carlos R. Mafra wrote:
> On Mon 12.Oct'09 at  2:02:24 -0700, Dmitry Torokhov wrote:
> > Still, I am curious to know why we can't simply reinitialize ALPS from
> > the get go, could you please send me a dmesg of resume done with
> > i8042.debug? Thanks!
> 
> The dmesg was too big, so I uploaded the ~5000 lines worth of syslog
> from 2.6.32-rc4 with i8042.debug info with a suspend to RAM to
> 
> http://www.aei.mpg.de/~crmafra/syslog-i8042.debug.txt
> 
> I hope this helps!

Could you please try this patch and let me know if it helps. Anotehr
i8042.dmesg would be much appreciated.

-- 
Dmitry


Input: psmouse - retry reset command if first one fails

From: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Sometimes mice are not ready for a command and respond with 0xfe;
failure to reset mouse can lead to losing the device to let's try
harder and repeat the command after delay.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 drivers/input/mouse/psmouse-base.c |   13 ++++++++++++-
 drivers/input/serio/libps2.c       |   31 +++++++++++++++++--------------
 2 files changed, 29 insertions(+), 15 deletions(-)


diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index 690aed9..52ad50f 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -395,8 +395,19 @@ int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command)
 int psmouse_reset(struct psmouse *psmouse)
 {
 	unsigned char param[2];
+	int error;
+
+	error = ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_RESET_BAT);
+	if (error == -EAGAIN) {
+		/*
+		 * Controller requested us to resend the command.
+		 */
+		msleep(100);
+		error = ps2_command(&psmouse->ps2dev,
+				    param, PSMOUSE_CMD_RESET_BAT);
+	}
 
-	if (ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_RESET_BAT))
+	if (error)
 		return -1;
 
 	if (param[0] != PSMOUSE_RET_BAT && param[1] != PSMOUSE_RET_ID)
diff --git a/drivers/input/serio/libps2.c b/drivers/input/serio/libps2.c
index f3876ac..5201b0c 100644
--- a/drivers/input/serio/libps2.c
+++ b/drivers/input/serio/libps2.c
@@ -39,7 +39,7 @@ MODULE_LICENSE("GPL");
 int ps2_sendbyte(struct ps2dev *ps2dev, unsigned char byte, int timeout)
 {
 	serio_pause_rx(ps2dev->serio);
-	ps2dev->nak = 1;
+	ps2dev->nak = ETIME;
 	ps2dev->flags |= PS2_FLAG_ACK;
 	serio_continue_rx(ps2dev->serio);
 
@@ -187,17 +187,17 @@ int __ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command)
 	int timeout;
 	int send = (command >> 12) & 0xf;
 	int receive = (command >> 8) & 0xf;
-	int rc = -1;
+	int rc;
 	int i;
 
 	if (receive > sizeof(ps2dev->cmdbuf)) {
 		WARN_ON(1);
-		return -1;
+		return -EINVAL;
 	}
 
 	if (send && !param) {
 		WARN_ON(1);
-		return -1;
+		return -EINVAL;
 	}
 
 	serio_pause_rx(ps2dev->serio);
@@ -213,13 +213,16 @@ int __ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command)
 	 * ACKing the reset command, and so it can take a long
 	 * time before the ACK arrrives.
 	 */
-	if (ps2_sendbyte(ps2dev, command & 0xff,
-			 command == PS2_CMD_RESET_BAT ? 1000 : 200))
+	rc = ps2_sendbyte(ps2dev, command & 0xff,
+			  command == PS2_CMD_RESET_BAT ? 1000 : 200);
+	if (rc)
 		goto out;
 
-	for (i = 0; i < send; i++)
-		if (ps2_sendbyte(ps2dev, param[i], 200))
+	for (i = 0; i < send; i++) {
+		rc = ps2_sendbyte(ps2dev, param[i], 200);
+		if (rc)
 			goto out;
+	}
 
 	/*
 	 * The reset command takes a long time to execute.
@@ -240,10 +243,10 @@ int __ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command)
 		for (i = 0; i < receive; i++)
 			param[i] = ps2dev->cmdbuf[(receive - 1) - i];
 
-	if (ps2dev->cmdcnt && (command != PS2_CMD_RESET_BAT || ps2dev->cmdcnt != 1))
+	if (ps2dev->cmdcnt && (command != PS2_CMD_RESET_BAT || ps2dev->cmdcnt != 1)) {
+		rc = ETIME;
 		goto out;
-
-	rc = 0;
+	}
 
  out:
 	serio_pause_rx(ps2dev->serio);
@@ -293,13 +296,13 @@ int ps2_handle_ack(struct ps2dev *ps2dev, unsigned char data)
 
 		case PS2_RET_NAK:
 			ps2dev->flags |= PS2_FLAG_NAK;
-			ps2dev->nak = PS2_RET_NAK;
+			ps2dev->nak = EAGAIN;
 			break;
 
 		case PS2_RET_ERR:
 			if (ps2dev->flags & PS2_FLAG_NAK) {
 				ps2dev->flags &= ~PS2_FLAG_NAK;
-				ps2dev->nak = PS2_RET_ERR;
+				ps2dev->nak = EIO;
 				break;
 			}
 
@@ -365,7 +368,7 @@ EXPORT_SYMBOL(ps2_handle_response);
 void ps2_cmd_aborted(struct ps2dev *ps2dev)
 {
 	if (ps2dev->flags & PS2_FLAG_ACK)
-		ps2dev->nak = 1;
+		ps2dev->nak = EIO;
 
 	if (ps2dev->flags & (PS2_FLAG_ACK | PS2_FLAG_CMD))
 		wake_up(&ps2dev->wait);

  reply	other threads:[~2009-10-13  3:25 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-11 16:21 [bisected regression] Touchpad "paste" stops working after suspend to RAM Carlos R. Mafra
2009-10-11 18:01 ` Dmitry Torokhov
2009-10-11 19:31   ` Carlos R. Mafra
2009-10-12  9:02     ` Dmitry Torokhov
2009-10-12  9:35       ` Carlos R. Mafra
2009-10-12  9:51         ` Carlos R. Mafra
2009-10-12 10:09       ` Carlos R. Mafra
2009-10-13  3:24         ` Dmitry Torokhov [this message]
2009-10-13 12:07           ` Carlos R. Mafra
     [not found]           ` <20091013121109.GB4619@Pilar.aei.mpg.de>
     [not found]             ` <20091013182643.GC21593@core.coreip.homeip.net>
     [not found]               ` <20091013190819.GA7555@Pilar.aei.mpg.de>
     [not found]                 ` <20091013194654.GD21593@core.coreip.homeip.net>
     [not found]                   ` <20091013202459.GE21593@core.coreip.homeip.net>
2009-10-13 23:16                     ` Carlos R. Mafra
2009-10-13 23:56                       ` Dmitry Torokhov
2009-10-13 23:57                         ` Dmitry Torokhov
2009-10-14  0:51                           ` Carlos R. Mafra
2009-10-14  2:30                             ` Dmitry Torokhov
2009-10-14 11:13                               ` Carlos R. Mafra
2009-10-15  0:44                                 ` Dmitry Torokhov
2009-10-15 11:08                                   ` Carlos R. Mafra

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=20091013032414.GC2887@core.coreip.homeip.net \
    --to=dmitry.torokhov@gmail.com \
    --cc=crmafra2@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rjw@sisk.pl \
    /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 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.