From patchwork Sat Nov 1 23:25:09 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: 5210031 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 EB3C0C11AC for ; Sat, 1 Nov 2014 23:26:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 190BF20117 for ; Sat, 1 Nov 2014 23:26:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 34A16200D5 for ; Sat, 1 Nov 2014 23:26:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752127AbaKAX0n (ORCPT ); Sat, 1 Nov 2014 19:26:43 -0400 Received: from mail-wg0-f42.google.com ([74.125.82.42]:57786 "EHLO mail-wg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751506AbaKAX0G (ORCPT ); Sat, 1 Nov 2014 19:26:06 -0400 Received: by mail-wg0-f42.google.com with SMTP id k14so8776585wgh.29 for ; Sat, 01 Nov 2014 16:26:05 -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=GBLZe133URbD06UGg1LwhA9kKsqj9OKW45PFqgq4lpc=; b=BDXFvImWzf8U5/TIWOZlBfQHezSm9MhgeGFgs9u+D5+b0K5D1ry6TCUF4mVjBP48iX A3DI4vMr8VwHMNkKBPyHURX+aBMZGc0O753Nj4/WDKTVBB3PbD15YTLiLfsZlLl5OMhG DoP9U0tz/5xcZ/2QNFy8M6Iz9pLa8swV5KkQqyDjxC1S8pI8NxP5QlsfHt17zcEORgXS 9lA7ubRI5945QqjNRUrlbuv8iFdhpoZ+fHyDSMZrnTmbsA+aLQ/uPzWJhI/eHp6UieYn LOI8hmeqMJOEqD1eLwwSbjBqpSNx3B1ZC2of6bugjT1S411T4eWyo7Qyo/LZ3w2p59qm KQYg== X-Received: by 10.180.74.201 with SMTP id w9mr6279103wiv.17.1414884365196; Sat, 01 Nov 2014 16:26:05 -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.26.03 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 01 Nov 2014 16:26:04 -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 3/4] input: alps: For protocol V3, do not process data when last packet's bit7 is set Date: Sun, 2 Nov 2014 00:25:09 +0100 Message-Id: <1414884310-19842-4-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 Sometimes on Dell Latitude laptops psmouse/alps driver receive invalid ALPS protocol V3 packets with bit7 set in last byte. More often it can be reproduced on Dell Latitude E6440 or E7440 with closed lid and pushing cover above touchpad. If bit7 in last packet byte is set then it is not valid ALPS packet. I was told that ALPS devices never send these packets. It is not know yet who send those packets, it could be Dell EC, bug in BIOS and also bug in touchpad firmware... With this patch alps driver does not process those invalid packets and drops it with PSMOUSE_FULL_PACKET so psmouse driver does not enter to out of sync state. This patch fix problem when psmouse driver still resetting ALPS device when laptop lid is closed because of receiving invalid packets in out of sync state. Signed-off-by: Pali Rohár Tested-by: Pali Rohár Cc: stable@vger.kernel.org --- drivers/input/mouse/alps.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c index 7c47e97..e802d28 100644 --- a/drivers/input/mouse/alps.c +++ b/drivers/input/mouse/alps.c @@ -1181,6 +1181,16 @@ static psmouse_ret_t alps_process_byte(struct psmouse *psmouse) return PSMOUSE_BAD_DATA; } + if (priv->proto_version == ALPS_PROTO_V3 && psmouse->pktcnt == psmouse->pktsize) { + // For protocol V3, do not process data when last packet's bit7 is set + if (psmouse->packet[psmouse->pktcnt - 1] & 0x80) { + psmouse_dbg(psmouse, "v3 discard packet[%i] = %x\n", + psmouse->pktcnt - 1, + psmouse->packet[psmouse->pktcnt - 1]); + return PSMOUSE_FULL_PACKET; + } + } + /* Bytes 2 - pktsize should have 0 in the highest bit */ if ((priv->proto_version < ALPS_PROTO_V5) && psmouse->pktcnt >= 2 && psmouse->pktcnt <= psmouse->pktsize &&