From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 637F0175A6C for ; Sun, 28 Jun 2026 17:22:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782667331; cv=none; b=jsmN08wKCZcyCGzsREMSpL9JczJZ0vrhsyrkB+aom3OK1/FhjUewRMTxZ74JObuxVfQGtflNebpu88iA/Co2XEH0vtrqhKchgxOiPlKLSahSLll6KhC/eidMbaXST9gnzjIOGRNpTUYocabCU0cuph5AUrtzxtPx68dr8Ou8P1E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782667331; c=relaxed/simple; bh=K3EOnm1FTPPIVgm7ZBKpbKmC5oI+YrXDEzBB1/dVpHY=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QEaJdRcdubIgkEbixU8ZTbOZx7KLzlDsXCjXFrMdsVCdHV3rQB6E4/26sNRYNDwi1I2QU2VGxzozEF6F6lNpnaLDDw75agMFbmssZ2RZyHDRMRE2q8BQMqeETmZAFAoZeF4Al5r7O5tGCpRYtqCoHrjNA+UhsO7hXkgYoSMgNHs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=p9ZMZPeK; arc=none smtp.client-ip=209.85.221.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="p9ZMZPeK" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-472a14c9965so533123f8f.1 for ; Sun, 28 Jun 2026 10:22:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782667328; x=1783272128; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=BBABlV/y3tcVRj6J4pCvx1ErOlS8DPYAimesttySdoE=; b=p9ZMZPeKYklW9y9bTUWZv3xL6SxinrYKC5qxU3P6Z7EqCWdR8yfWyWcsx4c4uga1cS aqSPWK32B7VKgYG0SbA1DKqWFF4SvPv9n+/PKDkyEzkHFDjPJ3IsmHjP/OZhmjsyLmYC /kGnBW3J+e62qCJiqiTZ/KOPwYF6x+P8OLWnJKDqDpYhglZp68xomAami1etPoSCVcs3 AEH4SIKd70Sv8N0g6Csgxpi6OY4yn+VBPMprnCVb7DoJI+FIbJEAZ24qSCFhw7cqUbSB +95cB+MjtzRMKa4aDrWNVLpo+LRybZd1wwMXxcx2zaoaiOA0RhvbBQgyZegVuyJ7uygk oLCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782667328; x=1783272128; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=BBABlV/y3tcVRj6J4pCvx1ErOlS8DPYAimesttySdoE=; b=DX3zB95Cz3CUYKeaNYUx8kSEm2sfek3fMUBKbtZmhi2Y4u5Ur6x8RA5gdXziU3tEep OxC/9EcfDb6OaIXsLcYsfc88CjmZGEUeHfInZmh109eC/JtY+YLaziXMZEkhONE/gDam ZOR6C51k6zEhD3Ai+ME37yIuID/haGMvx2DmnqeQTA2xh5uN4MZ6JJ6BHry6WbhyDGGt BgC5IxXiJRyjQ7FogkpokZPOIm8vtzbMivPtfNCUp5nLbv9aWVChh9BP+Zyk0XWFfDUW ZoXYHlAyHKHgRn7DybP2flBqUXNQ2oXHXd4Yo4camznirseWiqfXoTUIy4z0Us1Vq7Y8 I6Xw== X-Forwarded-Encrypted: i=1; AHgh+Rovlcru4lOYH32flQaSZ82zeCNolOJK7WwRip/tCoEDZ9Bj1LyvPp0R/mN7kzqTT56fsXw75vtdlEAo8dY=@vger.kernel.org X-Gm-Message-State: AOJu0YwdYVkg22ttsYb8OyCLERehxGdgqwbwO3l4b7xa+Pi9oQF5fRfi gUyEpcuFDSiYQ1hEImCrNSDo9A/sOg6cuRVThFbzzFdjj3AivJrWHMcR X-Gm-Gg: AfdE7cmw0a5mgMwgMraW6H4ta3s+z3Ja2iFgeSgxUUy/mk7FGTi5tuf9MZ1cITZCOp/ e1G+Ufu5vQq5gmM2EULutrDf4YCQOcmhFQsiuf49jQHr7SpRM4WSFpSppsZu7vvXVICcsYI7Poa +0zi4C66P05GoYhrw+RKP+QQRrLMIkbwZWhfkU4jtJoc9mon+1zoRDsdt4t/12vgaVf9nFR8p54 FzdYFQHrbUMr4TSPZPK1REQnzQSVmr19y2s29gc8T6LuEZIBbQPRkwe9Hk7R+xi5v6QRQ1xWqv6 7MWrCKP1w7Mjk2eHlvPGWF+/IFgIYBzaGqFd9ObHKvmjiJWFFpqeSTXbP/u/Re3TLLGs9oLhZlz A5AWSlWmBm16MlhOQAXZgu7QrZXNJldf70BaJhywHGNjwhqs8MywWtQOOSXdPDzFBqt7DO6YKSL AXFp5BFdhyjgAMxSNXdDOeWlcy X-Received: by 2002:a05:6000:1867:b0:46d:8695:f49d with SMTP id ffacd0b85a97d-46dc2a1614cmr23514992f8f.34.1782667327708; Sun, 28 Jun 2026 10:22:07 -0700 (PDT) Received: from foxbook (bgu190.neoplus.adsl.tpnet.pl. [83.28.84.190]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-472c7bec9c2sm7927088f8f.12.2026.06.28.10.22.06 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Sun, 28 Jun 2026 10:22:07 -0700 (PDT) Date: Sun, 28 Jun 2026 19:22:03 +0200 From: Michal Pecio To: Alan Stern Cc: Nikhil Solanke , linux-usb@vger.kernel.org, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, corbet@lwn.net, skhan@linuxfoundation.org, linux-doc@vger.kernel.org Subject: Re: [PATCH v2] usbcore: Add quirk for 255-bytes initial config read Message-ID: <20260628192203.5fb9daac.michal.pecio@gmail.com> In-Reply-To: <20260628190201.00afdccf.michal.pecio@gmail.com> References: <20260623161035.5792-1-nikhilsolanke5@gmail.com> <567e8866-4308-4e5f-819c-fe778dbf74f8@rowland.harvard.edu> <5159fd69-dddf-4073-a8e7-95fa77de0b7f@rowland.harvard.edu> <02060df3-b8c5-4a86-b3ab-3a28eea8a562@rowland.harvard.edu> <20260628165040.76fd608d.michal.pecio@gmail.com> <62e1fab3-1045-41f3-bc74-4c7624011619@rowland.harvard.edu> <20260628190201.00afdccf.michal.pecio@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit I really think it could (and should) be a simple patch. This is what I wrote a few weeks ago. It's an unconditional change for all devices, but it would be easy to turn it into a quirk. --- a/drivers/usb/core/config.c +++ b/drivers/usb/core/config.c @@ -938,15 +938,14 @@ int usb_get_configuration(struct usb_device *dev) if (!dev->rawdescriptors) return -ENOMEM; - desc = kmalloc(USB_DT_CONFIG_SIZE, GFP_KERNEL); + desc = kmalloc(255, GFP_KERNEL); if (!desc) return -ENOMEM; for (cfgno = 0; cfgno < ncfg; cfgno++) { - /* We grab just the first descriptor so we know how long - * the whole configuration is */ + /* Try 255 bytes first because that's what Windows does */ result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, - desc, USB_DT_CONFIG_SIZE); + desc, 255); if (result < 0) { dev_err(ddev, "unable to read config index %d " "descriptor/%s: %d\n", cfgno, "start", result); @@ -975,8 +974,12 @@ int usb_get_configuration(struct usb_device *dev) if (dev->quirks & USB_QUIRK_DELAY_INIT) msleep(200); - result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, - bigbuffer, length); + /* Don't bother if we already have it all */ + if (length <= result) + memcpy(bigbuffer, desc, length); + else + result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, + bigbuffer, length); if (result < 0) { dev_err(ddev, "unable to read config index %d " "descriptor/%s\n", cfgno, "all");