Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp3708946pxb; Mon, 30 Aug 2021 08:50:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymZ+5FfRy/C3smU70HToBJXUgjJnyi6KukYkn9QeuDk8VkzV/UF65gMKTBDBPLlodfakl7 X-Received: by 2002:a17:907:174b:: with SMTP id lf11mr25901637ejc.35.1630338625093; Mon, 30 Aug 2021 08:50:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630338625; cv=none; d=google.com; s=arc-20160816; b=RL9K2h3DF716hFYS7G7ix2qNvlhEgQqJK4OsjeQ6Ps8V8lD0dou1CFDm9+Zr6Wst7p VoTFPC+dGTXeBu1F1qVk7gUlosnLbmAx5XOFknOB78HSKlVoPHVfSDahKaiOrsqEV0mj NIOTU7JIYFIWci2aQu1S0rmAFhVrU5R0HjBgG2YPuaHDuoiBoRV3MbzePIFCEPXCyeeK 0gPHW65OuhcC+xPiZYQvxqFMkaoa8RAvv3zy3uwFOWch1KeE3nzglPLtxhUkpoF7AtvT E9p3OPr++xaTkQJOM1JC5E/AWOOKfJJXBeO96U5EpLHXHsRwLALM7nez2xTcLBl5RPeo tPFA== 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 :dkim-signature; bh=W6OwYTHqyMN6IxAME1ujn3yNsxUf4Dt4pjg5xjlW1no=; b=JyBngpXDYQQf3V6cZnMiYiiJzJCB4rXGTawrgzHmvNt4bNsqWtKeai9eoQDUhR+oQ1 demAITRC34zqbxaakVSYrpzEIrrYW9DB1AFfnHGW0CKQnqhJp1wzoVR6GgloT0gV6I2w XIkwW12+RbnznrfnJ0+eYPWTKteXSj6DwMAIJ1DTsQ99x6lNDO0u1sj4isEIr2Mk0Xvt Wf5QeZLGikkUTVLDwbG4Z1xnHmNmp2EK0OhPSaStQsHYQjhlRX7aa5v1GJlmOAWTIquy O6WMGw3Y2KlOyyiqw1LIYj77qvU6tm7jkSuEtHID00xYORiYYaektvGfguNxnwz40iCr NcQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@natalenko.name header.s=dkim-20170712 header.b=BbsNq347; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=natalenko.name Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h7si14966568ede.265.2021.08.30.08.49.56; Mon, 30 Aug 2021 08:50:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@natalenko.name header.s=dkim-20170712 header.b=BbsNq347; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=natalenko.name Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237590AbhH3PtJ (ORCPT + 99 others); Mon, 30 Aug 2021 11:49:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237526AbhH3PtI (ORCPT ); Mon, 30 Aug 2021 11:49:08 -0400 Received: from vulcan.natalenko.name (vulcan.natalenko.name [IPv6:2001:19f0:6c00:8846:5400:ff:fe0c:dfa0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 503B5C061575 for ; Mon, 30 Aug 2021 08:48:14 -0700 (PDT) Received: from spock.localnet (unknown [151.237.229.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by vulcan.natalenko.name (Postfix) with ESMTPSA id 14F33BC3384; Mon, 30 Aug 2021 17:48:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=natalenko.name; s=dkim-20170712; t=1630338491; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=W6OwYTHqyMN6IxAME1ujn3yNsxUf4Dt4pjg5xjlW1no=; b=BbsNq347OIy9el2IFdXZ6v3xjHcOwTyAi+oP+ssH7qBfIzK461d+u3WvmlWP4hy5Nn0w9K Vq3w+d/QFDEEoru2z6IVnxxhbGsqSZgNrxtrcLwxzf4YWn93SIdLJCwCPO5/dv3AcyQ/2K lgRASMCEX+wHkpXkWlqCDb4NEVPf8Yk= From: Oleksandr Natalenko To: Alan Stern , Michal Kubecek Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Kosina , Benjamin Tissoires Subject: Re: [REGRESSION][BISECTED] flood of "hid-generic ... control queue full" since v5.14-rc1 Date: Mon, 30 Aug 2021 17:48:09 +0200 Message-ID: <1954573.0n35tlyJVE@natalenko.name> In-Reply-To: <20210816191249.7g2mk5thwpio7cfc@lion.mk-sys.cz> References: <20210816130059.3yxtdvu2r7wo4uu3@lion.mk-sys.cz> <20210816143856.GA121345@rowland.harvard.edu> <20210816191249.7g2mk5thwpio7cfc@lion.mk-sys.cz> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello. On pond=C4=9Bl=C3=AD 16. srpna 2021 21:12:49 CEST Michal Kubecek wrote: > On Mon, Aug 16, 2021 at 10:38:56AM -0400, Alan Stern wrote: > > On Mon, Aug 16, 2021 at 04:13:47PM +0200, Michal Kubecek wrote: > > > Looking at the code, the primary problem seems to be that the "else" > > > branch in hid_submit_ctrl() recalculates transfer_buffer_length to > > > a rounded up value but assigns the original length to wLength. > >=20 > > Looks like you found the bug. Fixing it might be as simple as setting > > len =3D padlen in that "else" branch. You could then combine the > > transfer_buffer_length assignment with the one in the "if" branch and > > hoist them out after the entire "if" statement. >=20 > With the patch below, there are no errors and the UPS communication > works correctly and so do other HID devices. But I would prefere someone > familiar with HID code to confirm that this is what we want and what > would be the right way to handle usb_submit_urb() errors. >=20 > Michal >=20 > diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c > index 06130dc431a0..ef240ef63a66 100644 > --- a/drivers/hid/usbhid/hid-core.c > +++ b/drivers/hid/usbhid/hid-core.c > @@ -377,27 +377,26 @@ static int hid_submit_ctrl(struct hid_device *hid) > len =3D hid_report_len(report); > if (dir =3D=3D USB_DIR_OUT) { > usbhid->urbctrl->pipe =3D usb_sndctrlpipe(hid_to_usb_dev(hid),=20 0); > - usbhid->urbctrl->transfer_buffer_length =3D len; > if (raw_report) { > memcpy(usbhid->ctrlbuf, raw_report, len); > kfree(raw_report); > usbhid->ctrl[usbhid->ctrltail].raw_report =3D NULL; > } > } else { > - int maxpacket, padlen; > + int maxpacket; >=20 > usbhid->urbctrl->pipe =3D usb_rcvctrlpipe(hid_to_usb_dev(hid),=20 0); > maxpacket =3D usb_maxpacket(hid_to_usb_dev(hid), > usbhid->urbctrl->pipe, 0); > if (maxpacket > 0) { > - padlen =3D DIV_ROUND_UP(len, maxpacket); > - padlen *=3D maxpacket; > - if (padlen > usbhid->bufsize) > - padlen =3D usbhid->bufsize; > + len =3D DIV_ROUND_UP(len, maxpacket); > + len *=3D maxpacket; > + if (len > usbhid->bufsize) > + len =3D usbhid->bufsize; > } else > - padlen =3D 0; > - usbhid->urbctrl->transfer_buffer_length =3D padlen; > + len =3D 0; > } > + usbhid->urbctrl->transfer_buffer_length =3D len; > usbhid->urbctrl->dev =3D hid_to_usb_dev(hid); >=20 > usbhid->cr->bRequestType =3D USB_TYPE_CLASS | USB_RECIP_INTERFACE | dir; Any luck with moving this forward please? I've got a similar issue with APC= =20 UPS and v5.14 kernel, and this patch also solves the connectivity issue for= =20 me. Thanks. =2D-=20 Oleksandr Natalenko (post-factum)