From patchwork Tue Sep 3 11:14:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Vrastil, Michal" X-Patchwork-Id: 13788537 Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazon11010056.outbound.protection.outlook.com [52.101.69.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C22091A0BF4 for ; Tue, 3 Sep 2024 11:14:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.69.56 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725362086; cv=fail; b=C3qUxnVirOYllVB49bZLR7V+EEfLXxJJtPBNqtjT4aeS+5sXsgEbYqXj0ZoDht9l6yy/pGxJG6W/ocuFo9eJLmZWkOLgl7dakwFlG+SY263db6yffvir5gweEx38MvjDA0kEquCztU8Bdh2Dyr21wNisrDmuMNlUvMuaUQ2Luvc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725362086; c=relaxed/simple; bh=CZEuMUXLU9mjFeIfe7FGjXzMYzCoRUy2hJ2GRzGJEdw=; h=From:To:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=fbrDqaU/c7SNTuihsYMovRfD6A7qs02EBbMhjtfnAa3C52PHZSwHAGuCLrGbDeUymhlKN69fWyTqBaw2mwrHw2F/8aBO+BYWeuC3m39Yk+4ugXG6RsVImm0HtUTBRX6CzyRyPsNi6u+oZEBsCYTiT79j4V5SSOZA7WT6lB2gOVY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=hidglobal.com; spf=pass smtp.mailfrom=hidglobal.com; dkim=pass (2048-bit key) header.d=hidglobal.com header.i=@hidglobal.com header.b=iigifBVP; arc=fail smtp.client-ip=52.101.69.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=hidglobal.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hidglobal.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=hidglobal.com header.i=@hidglobal.com header.b="iigifBVP" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LkcaIIgEAHzyBzGM7tWv1rrH9I/jcGpWq+3JSLInWt8ify4tFLKtCVOHLZ9p+hY9zM4vAgkymvWAGTJs6bgIQmq94gC+xusKeYVoh27mOMBCwWlH9r8eBgdbu3dhsUiGGXKhTPE6Q+qQ06SJ3nlu2Z4ymf6lFOtQzez+uUyo9CvVwfsBMzviHkrst7reo/YtCLQCGa2sOuCo7amVQ1e9dnVRmooj//Oo+1LhJc1ysKtxsuSePdq/Tyuk6vNm7md/6CJFO3Gv9cv5sf4u0ima4E9eIZwBKPwLo9yYMXrpd2w3p/WPLoo73LAs5dCd7Bn2NvRHHCRW5/IqfTKZbZaVVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=CZEuMUXLU9mjFeIfe7FGjXzMYzCoRUy2hJ2GRzGJEdw=; b=Df0oGDCyDq6kPOGJ8/c2fGIs4bcJkaMmUs5oepi2HrZkIWMJHjQHOQeeJwBj8KHuuCJC/J6iUlyCwKfuXs6WEOMNPvCM/64Idx6jpklwdHR/1q4jwevl5uXMcyW6CWLciPbar587nzmN/nwUPu67ICnBbwhlqlaqzvZbASMJGlME7wRmQGYXp9e9WKSBh3aIrN6Yez9++Ch09HFo7pVq56o+76qoLU4XZLf+RQZ1kanN1NnzxhYnSunuvY/+CZqa4RTkztQnIu8qWCWhThx1S+6RodoECLE3cWGTvfUvfokBOf3F0w2VVzxdyGyoViMZeOxcC7T6BOs34CzxuJfzBg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hidglobal.com; dmarc=pass action=none header.from=hidglobal.com; dkim=pass header.d=hidglobal.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hidglobal.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CZEuMUXLU9mjFeIfe7FGjXzMYzCoRUy2hJ2GRzGJEdw=; b=iigifBVPGnKARCJunG8maXFyPd8gxytzYDWd0n72oXoqpZRMQMMjKa6DEfY0s7y4IDuUScscGRA5J4+w32iqvFxaLZUqcqFkE2O6r439FIITRm3fyvZpA0GslZGbdUqb7oQrBghjn+pbN8701sEoknVzjN2G6gIT+JZmLAcWYcWSpcW+MPFR/xDE/QpJ3feUNfMybq4aiWjNHWSWnjhRBLws/G6zUSxX4c7+zkgOvRLIQWMVFPq81fNAoir6nkkbRfp9k8HL2bUD4cKr+MAem4I8L0fmA+ApNlBhfIk+jf+wapVplLZbDUfnYnlaq0r2/bkSlx3t6F+O+kOVMLGt6A== Received: from AS8PR05MB8485.eurprd05.prod.outlook.com (2603:10a6:20b:3cb::12) by AS8PR05MB7720.eurprd05.prod.outlook.com (2603:10a6:20b:258::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.25; Tue, 3 Sep 2024 11:14:40 +0000 Received: from AS8PR05MB8485.eurprd05.prod.outlook.com ([fe80::465f:2e65:bd01:4957]) by AS8PR05MB8485.eurprd05.prod.outlook.com ([fe80::465f:2e65:bd01:4957%3]) with mapi id 15.20.7918.024; Tue, 3 Sep 2024 11:14:40 +0000 From: "Vrastil, Michal" To: "linux-usb@vger.kernel.org" Subject: [PATCH] usb: gadget: composite: fix OS descriptors w_value logic Thread-Topic: [PATCH] usb: gadget: composite: fix OS descriptors w_value logic Thread-Index: Adr95P3kevuPv1sqS4ueTeDDoI+Z7QADSBVw Date: Tue, 3 Sep 2024 11:14:39 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=hidglobal.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AS8PR05MB8485:EE_|AS8PR05MB7720:EE_ x-ms-office365-filtering-correlation-id: eedf46c4-39d1-4f3a-27f0-08dccc099a83 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|1800799024|366016|376014|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?q?a670iPlLSMK3lZiNpmfGWPznn7?= =?iso-8859-1?q?v7mU81opOreD1kOjHyGrs0jS/4+CgfaKL7LfvSx6W8y5xSQK3296JHom3R7n?= =?iso-8859-1?q?KWhJb4QDbuD+2k5qpNr73dx3S8FWN2GB1lV+RjuEuk5ohW0tZFuGEED/6Kvm?= =?iso-8859-1?q?X51qDCnpzRa27mR7LnJjyk3y73+wgG1s7keWQ6YOxaPUJGL6MH4SzDjwANjc?= =?iso-8859-1?q?RA0g7B/uEW4R4BdzbIkOSvGpdyaDcmaRbI9L8YQVnFYa1ZooJX3ZRs/kiw5Z?= =?iso-8859-1?q?hARtyLLtAu2cTuhppnth2FBBisFZE1h5Ff5PCAEAgEVnsDfopcWhuH6JDEfC?= =?iso-8859-1?q?YDMSAwBu13c1D4DQ9AnRNZ8xgy6uPtNEMnBRIl+FZqEWLc4Jm6djHJHQskIZ?= =?iso-8859-1?q?G2mRPOwvI/Nl2jyTB7AkrKx03pvxLtmYLz4MsXAlrtg5HZBgcoSKXemV8bpA?= =?iso-8859-1?q?6tGWtQJN9nqLDCZAwFD25N6OzTzXZ1+q3RGOW4srJ9UpS7W0k/ccVcKkmd9Q?= =?iso-8859-1?q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mLUJozPNKYWsCR6EV8xguyiLh1mX2LjmwdeGkR6dCKC?= =?iso-8859-1?q?jgE/UN01UOsPA9Te5Gueosow=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR05MB8485.eurprd05.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(38070700018);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?oxSHmTsiwNQ/m4a3nLEb0d/?= =?iso-8859-1?q?yxpwgwyBDRL4dmJduNDCfNbvJjGguTdda8OvCdehbL2zoCNSDX0Bp6dcd8Md?= =?iso-8859-1?q?uc1K0SQdcBpBzBHunKo/g2m9LZXdJ0TsAHqrV66FVgn8DB0dynhLOptbf1Un?= =?iso-8859-1?q?1AjSVEOOs29bruZbfSwh0xeW+rf7DsYwSkx+X5uNLkPFYH1XiBzMIruaX4H2?= =?iso-8859-1?q?YtFAkjuWrBCU8KM17BqTyjB8K0IH3QKKaeLYT6A7REt7F7d6jPq4pLm4YAD+?= =?iso-8859-1?q?pHsIXfVKVK7IAhy/pgg/kVv/XhLAOWzP3IJQ9znOehg23ufqg2dKe2Xbtitj?= =?iso-8859-1?q?2mrhZMuO2rNrUexFJHF8JV+5opS6ob5c3Z4//L0PPXopVAgxCqPmICVhQMSh?= =?iso-8859-1?q?fgm5putO7Vft49z0VgU6QyIZvpWLIT5wcBlIsipQf0vyzhAyfPi/xgd+ravw?= =?iso-8859-1?q?x3XBmn89aCcf2o8BZ5ShI9NE1OxMvqcH0HJU2iB48v+y4yHeOfQiGv/7hnY2?= =?iso-8859-1?q?+LMTcff189pjcyDl+MK+oy9e/MbkwQnHIb1LHpYV77GpBKdGV5I+13XvTMLh?= =?iso-8859-1?q?jsklcEV7y+DgTJNjSIl2JS2V39bJEJK2+w6uE3LSoPNCIrJYxd1DjGCnnPdx?= =?iso-8859-1?q?eapLcwgTMMN8qw/721qN8vUOQOrVY0nQ3N+uiWSs2UVgI8zkCLdDgJOq2b3m?= =?iso-8859-1?q?NB31eAkuHua/7IPBKPzp1NdXZ+lxbVG9f02qK+RKrNYgB3lev+kZbWcviWcG?= =?iso-8859-1?q?pxSSeGVng8/qo3cXXTGL8yKNOWRxJvi0ZHb4TVLPdlxnlBujr3jfpdc6QDeX?= =?iso-8859-1?q?N+meslvfAYYNQE/LAS4xJzawpZNZ5rTIxcXXYXWNBPqXkgNnSNURoSFCOz0r?= =?iso-8859-1?q?MORXBfHFv5VC0fnIz0U9XOJ/Ah/gFX5kSDzy/MCJ+F34QrzgsYz74UEkzQeR?= =?iso-8859-1?q?oC9EDNG838NjW2WpxOf9M3DjGDo9xZj9tvzeqnwSEGfX7If94w+epcndqKwL?= =?iso-8859-1?q?xrh1jA9O2ccuRiD81pwBxpry4pF+qx1Si06uScMDYRJd74esnq8x+2a+z+Ir?= =?iso-8859-1?q?tu2sguL5G592RG7JCG4khjamD3E6WnzghHm9RUK69JDoBKylTZASOhyn046r?= =?iso-8859-1?q?uNZ2rSIXg+b6NMmmY8R3qq/D6JCl9bNBbxB0psDrIJH4IjDO6KWWnmdgeDKE?= =?iso-8859-1?q?ktZpySSsppV2W6ULGJ/TyUMlXDv08OBuulrJ8owNWx8luJ2VFcoS4oh0bjFW?= =?iso-8859-1?q?aoMoce2AuZdt79rgD2vTGS/qB0uY6NhHhBnIrwEMqu0HAIP32nGlMRVodi+r?= =?iso-8859-1?q?k5iDh9vvkohYS6JEs9nNO1sWABxSbykf4jTIJ5U6yDdakOZlhGaLVx2/BDVG?= =?iso-8859-1?q?zjT5SNNLwgmED5PCmNa0+lfa8DwizOa1g9vtuXBghlRN+ZTeLy67Yevo9ouH?= =?iso-8859-1?q?ujkOPgo1lcC9edj+dWEgnJApU9AEX1WBvRQDSsCDOPX0GcyFSomfG1NkKYNr?= =?iso-8859-1?q?si9WHIR45Koga9A0eCDqvztdHaGjFDF6le2C2vEyWU37q+PzcOA3JV+pRFQj?= =?iso-8859-1?q?1CKB+yOiW1r+WbQAKGm+9CY8pVpW+lvK7kfT6LKbd524bjHDJfXJwe5zII8s?= =?iso-8859-1?q?frOm64c0KBcAKpNlkGIhCO4d3+NFW2PgMtTdFZA=3D=3D?= Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-OriginatorOrg: hidglobal.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AS8PR05MB8485.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: eedf46c4-39d1-4f3a-27f0-08dccc099a83 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Sep 2024 11:14:39.8362 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f0bdc1c9-5148-4f86-ac40-edd976e1814c X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: weprGYPLMC58sMNJ5d0Q6U8V9xnEnDLJ77T3jsDgmlL/c5wKGGToZQa///Ay86G3mxNoog4hZh5YaZ6R2OQXUpQwnDnO62YWdZyrWBO7HGA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR05MB7720 From 118f8c8b72d633c0daa65e564e48cbf4964977ab Mon Sep 17 00:00:00 2001 From: Michal Vrastil Date: Tue, 3 Sep 2024 10:55:15 +0200 Subject: [PATCH] Revert "usb: gadget: composite: fix OS descriptors w_value logic" This reverts commit ec6ce7075ef879b91a8710829016005dc8170f17. Fix install of WinUSB dsriver using OS descriptors. Without the fix the drivers are not installed correctly and the property 'DeviceInterfaceGUID' is missing on host side. The original change was based on assumption that the interface number is in the high byte of wValue but it is in the low byte, instead. Unfortunately, the fix is based on MS documentation which is also wrong. The actual USB request for OS descriptors (using USB analyzer) looks like: Offset  0   1   2   3   4   5   6   7 0x000   C1  A1  02  00  05  00  0A  00 C1: bmRequestType (device to host, vendor, interface) A1: nas magic number 0002: wValue (2: nas interface) 0005: wIndex (5: get extended property i.e. nas interface GUID) 008E: wLength (142) The fix was tested on Windows 10 and Windows 11. Signed-off-by: Michal Vrastil --- drivers/usb/gadget/composite.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 17ae3b394469..a3106b179562 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -1925,7 +1925,7 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)                                                buf[5] = 0x01;                                                switch (ctrl->bRequestType & USB_RECIP_MASK) {                                                case USB_RECIP_DEVICE: -                                                              if (w_index != 0x4 || (w_value & 0xff)) +                                                             if (w_index != 0x4 || (w_value >> 8))                                                                                break;                                                                buf[6] = w_index;                                                                /* Number of ext compat interfaces */ @@ -1941,9 +1941,9 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)                                                                }                                                                break;                                                case USB_RECIP_INTERFACE: -                                                              if (w_index != 0x5 || (w_value & 0xff)) +                                                             if (w_index != 0x5 || (w_value >> 8))                                                                                break; -                                                              interface = w_value >> 8; +                                                             interface = w_value & 0xFF;                                                                if (interface >= MAX_CONFIG_INTERFACES ||                                                                    !os_desc_cfg->interface[interface])                                                                                break;