From patchwork Thu Feb 9 15:49:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Nocera X-Patchwork-Id: 55026 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp420883wrn; Thu, 9 Feb 2023 08:05:49 -0800 (PST) X-Google-Smtp-Source: AK7set+73rFsC1wdRnPL2WO6Zjpuw3CqNVkEZ8rTNSJEY8bTHaCAvc9I0NZSfcyZ0I9J5aRU4EfN X-Received: by 2002:a05:6a20:1a82:b0:bf:8a97:6e48 with SMTP id ci2-20020a056a201a8200b000bf8a976e48mr9603734pzb.37.1675958748743; Thu, 09 Feb 2023 08:05:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675958748; cv=none; d=google.com; s=arc-20160816; b=KmJIfZnbnHRcu4iqRCM8PSfyWlcCDmXED2FY4Hd/xfkPKarIX/vBW9BtLrHokkifRC DZg1qq5g6Vx48yMO8+xllVFW2M2J92lgEaluckjfMVUT41eeOcWl+lBglRcVqZd5cs9r ONS7wTdjEnj+1dzA9RP/eFqGQUadwksjsXhaqBKb4xbG7/f22CCQ8XEVsaObMZ1oSzPm eKoA6TSyFNlCTWuwXwlDerBNeFK6999QzzneyxJEAA/y+r7bzIVvBczAES2xiuplmnhz GJd2tk5JD93LJngYNze0vmo/MqP0jAOhOyzsaj3M7t7+d3eGRuRr7c8BJELUFanJmHNg 0L2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=+DJUQQ8sA6GgsxDsJ2jBw/02M69PE0TjngcVjM23tbQ=; b=DQ17Q9i1DDu4l5VnN0uPxT0ZMoIZBtHRb9SxwFt6gnbuSX6qyrk0PwGmRbYQajROBf NzL+2ZxCqfzdAwI3Us9Y1+aIvUYfCGJxysFtohCNlW7Liiwa50uzC3D5tD1GnlmFXIok NuwSTaxK91vdJzH1wMJW7EKD3m0ZpFs/023W/xJZdddznDVXyL8HLsts6rCHkQQVKfvk y5KV9lxEyt9pyTV/bbj8UTy/1wC1LxZ56j7kCY2tu9Tm++rXFvkK5JdMYnk1+n5KXfMV hYk+iG+fYbE4beyMj6LOOoyAa31FAVK+/8n3sOPM9xejIFZ/KvTwFGeqh85TjXh/lInb p+2Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l186-20020a6388c3000000b004fb11689cfbsi2170379pgd.546.2023.02.09.08.05.36; Thu, 09 Feb 2023 08:05:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231538AbjBIPtt (ORCPT + 99 others); Thu, 9 Feb 2023 10:49:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231327AbjBIPtk (ORCPT ); Thu, 9 Feb 2023 10:49:40 -0500 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C9F42887C; Thu, 9 Feb 2023 07:49:26 -0800 (PST) Received: (Authenticated sender: hadess@hadess.net) by mail.gandi.net (Postfix) with ESMTPSA id 86D76240005; Thu, 9 Feb 2023 15:49:21 +0000 (UTC) From: Bastien Nocera To: linux-input@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Jiri Kosina , Benjamin Tissoires , "Peter F . Patel-Schneider" , =?utf-8?q?Filipe_La?= =?utf-8?q?=C3=ADns?= , Nestor Lopez Casado Subject: [PATCH v3 1/2] HID: logitech-hidpp: Retry commands when device is busy Date: Thu, 9 Feb 2023 16:49:15 +0100 Message-Id: <20230209154916.462158-1-hadess@hadess.net> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757370121082464511?= X-GMAIL-MSGID: =?utf-8?q?1757370121082464511?= Handle the busy error coming from the device or receiver. The documentation says a busy error can be returned when: " Device (or receiver) cannot answer immediately to this request for any reason i.e: - already processing a request from the same or another SW - pipe full " Signed-off-by: Bastien Nocera --- Use a bounded for loop instead of a goto, to avoid infinite loops. drivers/hid/hid-logitech-hidpp.c | 54 ++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c index 1952d8d3b6b2..ff427d7a0fa0 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c @@ -283,6 +283,7 @@ static int hidpp_send_message_sync(struct hidpp_device *hidpp, struct hidpp_report *response) { int ret; + int max_retries = 3; mutex_lock(&hidpp->send_mutex); @@ -295,34 +296,39 @@ static int hidpp_send_message_sync(struct hidpp_device *hidpp, */ *response = *message; - ret = __hidpp_send_report(hidpp->hid_dev, message); + for (; max_retries != 0; max_retries--) { + ret = __hidpp_send_report(hidpp->hid_dev, message); - if (ret) { - dbg_hid("__hidpp_send_report returned err: %d\n", ret); - memset(response, 0, sizeof(struct hidpp_report)); - goto exit; - } + if (ret) { + dbg_hid("__hidpp_send_report returned err: %d\n", ret); + memset(response, 0, sizeof(struct hidpp_report)); + goto exit; + } - if (!wait_event_timeout(hidpp->wait, hidpp->answer_available, - 5*HZ)) { - dbg_hid("%s:timeout waiting for response\n", __func__); - memset(response, 0, sizeof(struct hidpp_report)); - ret = -ETIMEDOUT; - } + if (!wait_event_timeout(hidpp->wait, hidpp->answer_available, + 5*HZ)) { + dbg_hid("%s:timeout waiting for response\n", __func__); + memset(response, 0, sizeof(struct hidpp_report)); + ret = -ETIMEDOUT; + } - if (response->report_id == REPORT_ID_HIDPP_SHORT && - response->rap.sub_id == HIDPP_ERROR) { - ret = response->rap.params[1]; - dbg_hid("%s:got hidpp error %02X\n", __func__, ret); - goto exit; - } + if (response->report_id == REPORT_ID_HIDPP_SHORT && + response->rap.sub_id == HIDPP_ERROR) { + ret = response->rap.params[1]; + dbg_hid("%s:got hidpp error %02X\n", __func__, ret); + goto exit; + } - if ((response->report_id == REPORT_ID_HIDPP_LONG || - response->report_id == REPORT_ID_HIDPP_VERY_LONG) && - response->fap.feature_index == HIDPP20_ERROR) { - ret = response->fap.params[1]; - dbg_hid("%s:got hidpp 2.0 error %02X\n", __func__, ret); - goto exit; + if ((response->report_id == REPORT_ID_HIDPP_LONG || + response->report_id == REPORT_ID_HIDPP_VERY_LONG) && + response->fap.feature_index == HIDPP20_ERROR) { + ret = response->fap.params[1]; + if (ret != HIDPP20_ERROR_BUSY) { + dbg_hid("%s:got hidpp 2.0 error %02X\n", __func__, ret); + goto exit; + } + dbg_hid("%s:got busy hidpp 2.0 error %02X, retrying\n", __func__, ret); + } } exit: From patchwork Thu Feb 9 15:49:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bastien Nocera X-Patchwork-Id: 55027 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp420908wrn; Thu, 9 Feb 2023 08:05:50 -0800 (PST) X-Google-Smtp-Source: AK7set84F8oMOk1BcP321cFO4Q+L4g5qu9FN0fU7tfoMDBYGzzKRk5CXrxXZAuYQeO5gn+Vl0WHt X-Received: by 2002:a05:6a20:12cc:b0:bc:f665:8655 with SMTP id v12-20020a056a2012cc00b000bcf6658655mr14817046pzg.53.1675958750570; Thu, 09 Feb 2023 08:05:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675958750; cv=none; d=google.com; s=arc-20160816; b=bkrDhuFc840RRY+mtYURLsRh7XliBghzVVb0PelGMdJvETRveISC54psbVpy7Ya4wC lZDlxtYvIwh0dePnQ8qYDZndclqTHhXlyc3CvQifQ+EExB544GsYHiUpFBmKYfIvSw+e lM/A9q4g0XAlxEMcT+6qpVWk+gLlszlLbuN6hgZZBm0OYp4brIezlbzZ415zbfG8CkHa OYiF8AGaG9Bh1z2QOdpLuh3w6yfM1aA7lhl8sNPcnXYxK00/Q1S5OHWtVHZIdscCkagL NGP1fZ5YZAHZHk5TwE0SzJA8yqNLsVB7dtkQ0PZUCeBwPFyVmHounvQ1Sra+H4681WE6 OJjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=kPELrx9/jkYImJ7OvLVWiiVTvUnJG5NQhtwUtpvmp7g=; b=jt/1AkqYEytmMVsSDNborTQwjAgedrZNDvHmAUN/GRdE7TEBng8REyQEM5wwITRhWm 5rC/zjjoc9KssBOOVRsm/9wn8oyIJ1SnDEmzEJzEgVXkUb7F1VWWBLoEpzSNOi+UDFcQ lUaEPvoPDnFxQfKa4IWP5HpIYPOVhjUPjUeZeUofrP0vDEJSu4pyivpEszUvrwP/9s2K S448KOB1f4ZONjDEKB8njE2Gw8DiuCbFhH+Fr1Cd7TEuhuH7Zjqo1Ucbg1DCTvsrXBkd Cb3Xj4MrwLOQoW/huafsSnQa0865qwWWb6j5HGRGWfReH5442CmG8Ws7rZubYUpIe5Cd d6HA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u69-20020a638548000000b004fb456c442bsi2176712pgd.840.2023.02.09.08.05.37; Thu, 09 Feb 2023 08:05:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230202AbjBIPuR (ORCPT + 99 others); Thu, 9 Feb 2023 10:50:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231524AbjBIPtm (ORCPT ); Thu, 9 Feb 2023 10:49:42 -0500 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00C96AD24; Thu, 9 Feb 2023 07:49:28 -0800 (PST) Received: (Authenticated sender: hadess@hadess.net) by mail.gandi.net (Postfix) with ESMTPSA id E022A240002; Thu, 9 Feb 2023 15:49:24 +0000 (UTC) From: Bastien Nocera To: linux-input@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Jiri Kosina , Benjamin Tissoires , "Peter F . Patel-Schneider" , =?utf-8?q?Filipe_La?= =?utf-8?q?=C3=ADns?= , Nestor Lopez Casado Subject: [PATCH v3 2/2] HID: logitech-hidpp: Add myself to authors Date: Thu, 9 Feb 2023 16:49:16 +0100 Message-Id: <20230209154916.462158-2-hadess@hadess.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230209154916.462158-1-hadess@hadess.net> References: <20230209154916.462158-1-hadess@hadess.net> MIME-Version: 1.0 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757370122630623472?= X-GMAIL-MSGID: =?utf-8?q?1757370122630623472?= As discussed with HID maintainer Benjamin Tissoires, add myself to the authors list and MAINTAINERS file. Signed-off-by: Bastien Nocera --- Updated MAINTAINERS file too. MAINTAINERS | 7 +++++++ drivers/hid/hid-logitech-hidpp.c | 1 + 2 files changed, 8 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index fb1471cb5ed3..327679567645 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -9217,6 +9217,13 @@ L: linux-input@vger.kernel.org S: Maintained F: drivers/hid/hid-logitech-* +HID++ LOGITECH DRIVERS +R: Filipe LaĆ­ns +R: Bastien Nocera +L: linux-input@vger.kernel.org +S: Maintained +F: drivers/hid/hid-logitech-hidpp.c + HID PLAYSTATION DRIVER M: Roderick Colenbrander L: linux-input@vger.kernel.org diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c index ff427d7a0fa0..61bad7a50ec7 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c @@ -30,6 +30,7 @@ MODULE_LICENSE("GPL"); MODULE_AUTHOR("Benjamin Tissoires "); MODULE_AUTHOR("Nestor Lopez Casado "); +MODULE_AUTHOR("Bastien Nocera "); static bool disable_tap_to_click; module_param(disable_tap_to_click, bool, 0644);