From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 158F5C4320A for ; Mon, 30 Aug 2021 15:48:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E704861038 for ; Mon, 30 Aug 2021 15:48:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237599AbhH3PtJ (ORCPT ); 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)