Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp238721ybi; Wed, 29 May 2019 20:24:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqzdZYt6sOM13npxh53x1F8V/4zYwTXfzsmzXuolmiuqUoKSv9J6dv3yPxxZhpV2nF+RGYKh X-Received: by 2002:a63:1844:: with SMTP id 4mr1565409pgy.402.1559186689084; Wed, 29 May 2019 20:24:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559186689; cv=none; d=google.com; s=arc-20160816; b=On+jN+Nd/QN2ZK/DJm2OYfbQjxvTdLK17qDFQdsBTQKX70aDvjzmkzSjasrWp1c+I5 1g+hqAOOLg/IMoACsg3IkcO6NSFUTFdcU8iej384Q9gbYzOC2J20GSqqvvSaA6c0DWAQ CyLHyc+thVzWdstRMfBsOcggw7jSBa5tEu7xFZghY+QuBJdc8Z7JQcKDU/yAmiXGR0Ba eVSBbFUOyfGn42bb43mXEjZX5FjopRhfCjY9GRo9U0wpVQWJwcTh0DbIxrU8bkxbLncp y3K1FNg2KSHwNtwKvzjZaxEyTSziney2Kbhsa/hRP8D0DaAdWwRUkm8gfyauqWj8g5MZ vsXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tPTwtp8hEaDA444/cBQcW4x58j1YuZ50XgnxPoeVdNY=; b=iw7W1ARBktCHWu4uVSl6ALcCTSOvTcroOrULGvTG3wL8806H8Y9C5UPz65efxKaebf aMpCH8cWdxtR9ENrUrnvGRsynZjIC1BNE87aqSKEkuNi4hzKVaT3ZtwO7HX9Dut64Gfr NvLV89s+X2aKKlJjtteafkUUGAb88q9xIF1i3WJ7KdgjpiJX3XZRQoOE8OK/2yLgcsSn 3PE/ST9QZjLvFDvSlT33bXhOS6aP6JvKbuw50fPxnWlHknkUZDQbIjP2BPBT3ZWZQV/Y voe32bb4NU00o+KvDHBPiwRD+T4Ic1tKdvZ+Ffoxh+jEWiwseOoIzGov8Rm5aq9EULMM eEfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yWvQf0uG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l1si2019017pgi.278.2019.05.29.20.24.32; Wed, 29 May 2019 20:24:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yWvQf0uG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732918AbfE3DWs (ORCPT + 99 others); Wed, 29 May 2019 23:22:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:44798 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729570AbfE3DRD (ORCPT ); Wed, 29 May 2019 23:17:03 -0400 Received: from localhost (ip67-88-213-2.z213-88-67.customer.algx.net [67.88.213.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2C9DB24659; Thu, 30 May 2019 03:17:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186222; bh=Jreunv7bFqYQlkJmwWSbG9zeX9kycS4RnC4UXcnC4Qc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yWvQf0uGxHadgqTeYyhLR8lyvRXbd2n+ma0fnQAZ1wm2yAO17OPS0iorRdVjXyGkP x/XgZmzhSqNBBkS9SPlYzAslIVbSeVYxHhctL0XqEJNDS2bj6WbtaFGnhrDoBpYh4g UB2iKpFyjW1Coxwl1vObGB6Se1QkljnpxRX+3rr4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hans de Goede , Benjamin Tissoires , Sasha Levin Subject: [PATCH 4.19 115/276] HID: logitech-hidpp: use RAP instead of FAP to get the protocol version Date: Wed, 29 May 2019 20:04:33 -0700 Message-Id: <20190530030533.121068301@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030523.133519668@linuxfoundation.org> References: <20190530030523.133519668@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 096377525cdb8251e4656085efc988bdf733fb4c ] According to the logitech_hidpp_2.0_specification_draft_2012-06-04.pdf doc: https://lekensteyn.nl/files/logitech/logitech_hidpp_2.0_specification_draft_2012-06-04.pdf We should use a register-access-protocol request using the short input / output report ids. This is necessary because 27MHz HID++ receivers have a max-packetsize on their HIP++ endpoint of 8, so they cannot support long reports. Using a feature-access-protocol request (which is always long or very-long) with these will cause a timeout error, followed by the hidpp driver treating the device as not being HID++ capable. This commit fixes this by switching to using a rap request to get the protocol version. Besides being tested with a (046d:c517) 27MHz receiver with various 27MHz keyboards and mice, this has also been tested to not cause regressions on a non-unifying dual-HID++ nano receiver (046d:c534) with k270 and m185 HID++-2.0 devices connected and on a unifying/dj receiver (046d:c52b) with a HID++-2.0 Logitech Rechargeable Touchpad T650. Signed-off-by: Hans de Goede Signed-off-by: Benjamin Tissoires Signed-off-by: Sasha Levin --- drivers/hid/hid-logitech-hidpp.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c index 8425d3548a414..edf224ad13369 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c @@ -725,13 +725,16 @@ static int hidpp_root_get_feature(struct hidpp_device *hidpp, u16 feature, static int hidpp_root_get_protocol_version(struct hidpp_device *hidpp) { + const u8 ping_byte = 0x5a; + u8 ping_data[3] = { 0, 0, ping_byte }; struct hidpp_report response; int ret; - ret = hidpp_send_fap_command_sync(hidpp, + ret = hidpp_send_rap_command_sync(hidpp, + REPORT_ID_HIDPP_SHORT, HIDPP_PAGE_ROOT_IDX, CMD_ROOT_GET_PROTOCOL_VERSION, - NULL, 0, &response); + ping_data, sizeof(ping_data), &response); if (ret == HIDPP_ERROR_INVALID_SUBID) { hidpp->protocol_major = 1; @@ -751,8 +754,14 @@ static int hidpp_root_get_protocol_version(struct hidpp_device *hidpp) if (ret) return ret; - hidpp->protocol_major = response.fap.params[0]; - hidpp->protocol_minor = response.fap.params[1]; + if (response.rap.params[2] != ping_byte) { + hid_err(hidpp->hid_dev, "%s: ping mismatch 0x%02x != 0x%02x\n", + __func__, response.rap.params[2], ping_byte); + return -EPROTO; + } + + hidpp->protocol_major = response.rap.params[0]; + hidpp->protocol_minor = response.rap.params[1]; return ret; } -- 2.20.1