From patchwork Sat Nov 1 23:25:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 5210051 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 862A3C11AC for ; Sat, 1 Nov 2014 23:33:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 786C82012F for ; Sat, 1 Nov 2014 23:33:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 86C6A200E3 for ; Sat, 1 Nov 2014 23:33:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750939AbaKAXdm (ORCPT ); Sat, 1 Nov 2014 19:33:42 -0400 Received: from mail-wi0-f171.google.com ([209.85.212.171]:46316 "EHLO mail-wi0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750864AbaKAXdm (ORCPT ); Sat, 1 Nov 2014 19:33:42 -0400 Received: by mail-wi0-f171.google.com with SMTP id q5so3865471wiv.4 for ; Sat, 01 Nov 2014 16:33:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=6cDOsAyl07Gjk+fY2pRIbgfHftgAkIL/INrK7tSBUrQ=; b=SwVq85DknEPWi6zxbjEjqHowveCoM7xFk7hhBCKswak2GUwTD4HxNsAlVhZQZigLny P1pdQVqgxhlOnUsVUFDEjrjEeSyPcjijCZ96mmABuWprW1Q+H/mXJc5e9X66+nh5o+9K JlZXFl/NcO7Ld2O5EFVH+JB2HQwu+A2yVi+UZxpNw8XJu9OWogyuICRZEe40OiVvLHNd 0+9ak3MhtjJYzd6Twvq1LXiwE/yn/ub5fHWz7lX225AEx58Lem3YRFiVVXc7UO0rE7f9 DmvePAKvvMG4sV6aQSe1jL/LFpHWHOFqx2MS5atCXqfLe8SqoIcDUdfFtd8FFVwJcadm XABA== X-Received: by 10.180.77.170 with SMTP id t10mr6459903wiw.57.1414884356130; Sat, 01 Nov 2014 16:25:56 -0700 (PDT) Received: from Pali-Latitude.kolej.mff.cuni.cz (pali.kolej.mff.cuni.cz. [78.128.193.202]) by mx.google.com with ESMTPSA id ei1sm3315398wib.20.2014.11.01.16.25.55 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 01 Nov 2014 16:25:55 -0700 (PDT) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Dmitry Torokhov , Hans de Goede , Yunkang Tang , Tommy Will Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= Subject: [PATCH v3 1/4] input: alps: Do not try to parse data as 3 bytes packet when driver is out of sync Date: Sun, 2 Nov 2014 00:25:07 +0100 Message-Id: <1414884310-19842-2-git-send-email-pali.rohar@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1414884310-19842-1-git-send-email-pali.rohar@gmail.com> References: <1412329392-5580-1-git-send-email-pali.rohar@gmail.com> <1414884310-19842-1-git-send-email-pali.rohar@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 5th and 6th byte of ALPS trackstick V3 protocol match condition for first byte of PS/2 3 bytes packet. When driver enters out of sync state and ALPS trackstick is sending data then driver match 5th, 6th and next 1st bytes as PS/2. It basically means if user is using trackstick when driver is in out of sync state driver will never resync. Processing these bytes as 3 bytes PS/2 data cause total mess (random cursor movements, random clicks) and make trackstick unusable until psmouse driver decide to do full device reset. Lot of users reported problems with ALPS devices on Dell Latitude E6440, E6540 and E7440 laptops. ALPS device or Dell EC for unknown reason send some invalid ALPS PS/2 bytes which cause driver out of sync. It looks like that i8042 and psmouse/alps driver always receive group of 6 bytes packets so there are no missing bytes and no bytes were inserted between valid once. This patch does not fix root of problem with ALPS devices found in Dell Latitude laptops but it does not allow to process some (invalid) subsequence of 6 bytes ALPS packets as 3 bytes PS/2 when driver is out of sync. So with this patch trackstick input device does not report bogus data when also driver is out of sync, so trackstick should be usable on those machines. Unknown is also information which ALPS devices send 3 bytes packets and why ALPS driver needs to handle also bare PS/2 packets. According to git (and plus historic tree from bitkeeper) code for processing 3 bytes bare PS/2 packets is there since first version of alps.c existence (since 2.6.9-rc2). We do not want to break some older ALPS devices. And disabling processing bare PS/2 packets when driver is out of sync should not break it. Signed-off-by: Pali Rohár Tested-by: Pali Rohár Cc: stable@vger.kernel.org --- drivers/input/mouse/alps.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c index 2b0ae8c..a772745 100644 --- a/drivers/input/mouse/alps.c +++ b/drivers/input/mouse/alps.c @@ -1156,7 +1156,9 @@ static psmouse_ret_t alps_process_byte(struct psmouse *psmouse) { struct alps_data *priv = psmouse->private; - if ((psmouse->packet[0] & 0xc8) == 0x08) { /* PS/2 packet */ + /* FIXME: Could we receive bare PS/2 packets from DualPoint devices?? */ + if (!psmouse->out_of_sync_cnt && + (psmouse->packet[0] & 0xc8) == 0x08) { /* PS/2 packet */ if (psmouse->pktcnt == 3) { alps_report_bare_ps2_packet(psmouse, psmouse->packet, true);