From nobody Mon Sep 28 04:51:24 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 E1C063F4100; Wed, 26 Aug 2026 11:05:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787742319; cv=none; b=bPLr4m5NCekTCjz8pN86lzKTurJ7BYnb+abhV9Rej5VZmHtTX9O4jW3mpGD5uIzlDDo0cDJSW6b8bOW8tR0lJH50xFGugaMkohi+7Y95/DwVGhsEeJQ3EJyGDGg3YNB2rN/6NKnTXsOPrU1krbFA/ke+cYSk0aVhOURT8s5j2Bo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787742319; c=relaxed/simple; bh=co93x9gmF52N4loh6J3WDmZuu/l1pFl8yHYLhYEJKu8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AJNFeznTp4hb0bQ0l2Iz4fnlbbs/5CeIo3hvRwK9CrEwyMujMVUkm8JVJGFRao6HHEL5CTvR9PEeTUaXsQOtLGljA+AzMDROlSZYLa8KCe/D0nJ6fCxVVAi83AJGqEYlY/KNUek3XE8XHuzeMBXnHjE/Ru2MhrYxdCWy8h+RcIs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jzUWKrvm; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jzUWKrvm" Received: by smtp.kernel.org (Postfix) with ESMTPS id 2E149C2BD04; Wed, 26 Aug 2026 11:05:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1787742318; bh=co93x9gmF52N4loh6J3WDmZuu/l1pFl8yHYLhYEJKu8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=jzUWKrvmrNxZhV9qdyCtbolQhG3Dblve5QDNpqOzQPFHufpxHY0ewZn4GPHOkZhCK ltuq/C4Et++OOlAFDkQcpoiWC6XppCNKmfGvvU41zehaOKrNaVI801nVZm7/vI9pDe ZQWBuo07SGAFCXLAIzxC3+jlr7wlhnMOmRBkuH3zIfaA4D6taGQGZ5NATuTFtRZ6DS kV77vOlSTWL/pxPWmXh3ywoVQBmh1ROe8kp3oIsoCYMc9UImC8J4EkGc5YaO9OFGrT uHP5QxHTC/hxpM6fjebVhAIAoUuy1AvSDTXBeYbUZsoZ86CUDXCJEUzAnRgCphEexx MAyJmPJUw5VTw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 045A0C5DF97; Wed, 26 Aug 2026 11:05:18 +0000 (UTC) From: Pawel Laszczak via B4 Relay Date: Wed, 26 Aug 2026 13:24:36 +0200 Subject: [PATCH v2 1/3] usb: xhci: Add support for eUSB2v2 1024-byte bulk packet size 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260826-eusb2v2-packet-size-v2-1-950f19f38ef0@cadence.com> References: <20260826-eusb2v2-packet-size-v2-0-950f19f38ef0@cadence.com> In-Reply-To: <20260826-eusb2v2-packet-size-v2-0-950f19f38ef0@cadence.com> To: Greg Kroah-Hartman , Mathias Nyman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Pawel Laszczak X-Mailer: b4 0.15.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1787743495; l=9267; i=pawell@cadence.com; h=from:subject:message-id; bh=yO0IkkHAwTAYKxm01qJMuWmSxRRO8IsvCrEFHtmxw7g=; b=KTLdok1RV3qE4ZlvISUystteWtDU/LAKTvHg8izaNVeTgQlzW0Ir7SA9k3oyTCCwPgOdGmLBR hcfTyuBpUu2Cx7p9CIvI6WX1ei41kbPs/z/ONS7i/Z2RJDqaX/KgVjY X-Developer-Key: i=pawell@cadence.com; a=ed25519; pk=EUPBvLO9CDg7j6defeDl2iqi+z5Ivqu4Z46aiqe7dYc= X-Endpoint-Received: by B4 Relay for pawell@cadence.com/default with auth_id=707 X-Original-From: Pawel Laszczak Reply-To: pawell@cadence.com From: Pawel Laszczak The eUSB2 v2 specification (bcdUSB 0x0230) introduces support for 1024-byte maximum packet sizes for Bulk endpoints in High-Speed mode. However, an eUSB2v2 peripheral will revert its internal maximum packet size back to 512 bytes after events like a bus reset, disconnect, or deconfiguration. To support 1024-byte bulk transfers on capable hosts, add a new is_eusb2v2 flag to the usb_bus structure, populated via the HCCPARAMS2 E2V2C capability bit in the xHCI driver. When an eUSB2v2 host configures an eUSB2v2 device, issue a specific SET_FEATURE (USB_DEVICE_BULK_MAX_PACKET_UPDATE) request during device configuration to switch the peripheral to 1024-byte packet mode, and allow the xHCI endpoint initialization to accept up to 1024 bytes for HS bulk endpoints. Signed-off-by: Pawel Laszczak --- Changes in v2: - Removed change in config.c: per eUSB2v2 spec section 5.2, conformant devices always report wMaxPacketSize=3D512 in their descriptor regardless of operating mode, so the warning suppression was unnecessary. - xhci-mem.c: simplified HS bulk clamp - xhci.c: moved is_eusb2v2 assignment into xhci_hcd_init_usb2_data() - eusb_update_max_packet(): changed from void to int; returns error on SET_FEATURE failure. - Added eusb2v2_mps_active flag to struct usb_device to track whether SET_FEATURE(BULK_MAX_PACKET_UPDATE) succeeded. - Added hub.c: usb_reset_and_verify_device() now re-issues SET_FEATURE after bus reset to restore 1KB mode. Failure triggers re-enumeration to prevent a driver from operating with inconsistent MPS state. --- drivers/usb/core/hub.c | 16 ++++++++++ drivers/usb/core/message.c | 74 +++++++++++++++++++++++++++++++++++++++++= +++- drivers/usb/core/usb.h | 2 ++ drivers/usb/host/xhci-mem.c | 18 +++++++++-- drivers/usb/host/xhci.c | 4 +++ include/linux/usb.h | 7 +++++ 6 files changed, 117 insertions(+), 4 deletions(-) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 24960ba9caa9..34cfc44c5df8 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -6252,6 +6252,22 @@ static int usb_reset_and_verify_device(struct usb_de= vice *udev) mutex_unlock(hcd->bandwidth_mutex); goto re_enumerate; } + + /* + * Restore eUSB2v2 1KB bulk mode after reset (device reverts to 512 + * after any bus reset per eUSB2v2 spec section 5.2). + * Only retry if the initial SET_FEATURE had succeeded. + */ + if (udev->eusb2v2_mps_active) { + ret =3D eusb_update_max_packet(udev, udev->actconfig); + if (ret < 0) { + dev_err(&udev->dev, + "eUSB2v2: failed to restore 1KB mode after reset (%d)\n", ret); + mutex_unlock(hcd->bandwidth_mutex); + goto re_enumerate; + } + } + ret =3D usb_control_msg(udev, usb_sndctrlpipe(udev, 0), USB_REQ_SET_CONFIGURATION, 0, udev->actconfig->desc.bConfigurationValue, 0, diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 75e2bfd744a9..18bedc7f91a3 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c @@ -2007,6 +2007,67 @@ int usb_set_wireless_status(struct usb_interface *if= ace, } EXPORT_SYMBOL_GPL(usb_set_wireless_status); =20 +/* + * eusb_update_max_packet - set or restore max packet size + * @udev: target device + * @cp: if NULL restore MPS to 512 else set 1024 + * + * This request is specific to eUSB2v2. + * An eUSB2v2 peripheral will revert the maximum packet size to 512 + * for bulk endpoints after bus reset, disconnect and deconfiguration. + * This function allows updating the max packet size for BULK endpoints + * to 1024 after above events. + */ +int eusb_update_max_packet(struct usb_device *udev, struct usb_host_config= *cp) +{ + struct usb_host_config *config =3D cp ? cp : udev->actconfig; + struct usb_hcd *hcd =3D bus_to_hcd(udev->bus); + struct usb_interface_cache *intfc; + struct usb_host_interface *alt; + struct usb_host_endpoint *ep; + u16 mps =3D 512; + int i, j, a; + int ret; + + if (le16_to_cpu(udev->descriptor.bcdUSB) !=3D 0x0230 || + !hcd->self.is_eusb2v2) + return 0; + + if (cp) { + ret =3D usb_control_msg(udev, usb_sndctrlpipe(udev, 0), + USB_REQ_SET_FEATURE, USB_RECIP_DEVICE, + USB_DEVICE_BULK_MAX_PACKET_UPDATE, 0, NULL, 0, + USB_CTRL_SET_TIMEOUT); + if (ret < 0) { + dev_warn(&udev->dev, "eUSB2v2 1KB update failed: %d\n", ret); + return ret; + } + + mps =3D 1024; + } else if (!udev->actconfig) + return 0; + + for (i =3D 0; i < config->desc.bNumInterfaces; i++) { + intfc =3D config->intf_cache[i]; + + if (!intfc) + continue; + + for (a =3D 0; a < intfc->num_altsetting; a++) { + alt =3D &intfc->altsetting[a]; + + for (j =3D 0; j < alt->desc.bNumEndpoints; j++) { + ep =3D &alt->endpoint[j]; + + if (usb_endpoint_xfer_bulk(&ep->desc)) + ep->desc.wMaxPacketSize =3D cpu_to_le16(mps); + } + } + } + + return 0; +} + /* * usb_set_configuration - Makes a particular device setting be current * @dev: the device whose configuration is being updated @@ -2120,8 +2181,19 @@ int usb_set_configuration(struct usb_device *dev, in= t configuration) /* if it's already configured, clear out old state first. * getting rid of old interfaces means unbinding their drivers. */ - if (dev->state !=3D USB_STATE_ADDRESS) + if (dev->state !=3D USB_STATE_ADDRESS) { + eusb_update_max_packet(dev, NULL); usb_disable_device(dev, 1); /* Skip ep0 */ + } + + ret =3D eusb_update_max_packet(dev, cp); + if (ret < 0) + dev->eusb2v2_mps_active =3D 0; + else if (le16_to_cpu(dev->descriptor.bcdUSB) =3D=3D 0x0230 && + hcd->self.is_eusb2v2) + dev->eusb2v2_mps_active =3D 1; + else + dev->eusb2v2_mps_active =3D 0; =20 /* Get rid of pending async Set-Config requests for this device */ cancel_async_set_config(dev); diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h index a9b37aeb515b..c36fe2a2acea 100644 --- a/drivers/usb/core/usb.h +++ b/drivers/usb/core/usb.h @@ -89,6 +89,8 @@ extern int usb_major_init(void); extern void usb_major_cleanup(void); extern int usb_device_supports_lpm(struct usb_device *udev); extern int usb_port_disable(struct usb_device *udev); +extern int eusb_update_max_packet(struct usb_device *udev, + struct usb_host_config *cp); =20 #ifdef CONFIG_PM =20 diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 997fe90f54e5..8ccbfaf57612 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -1479,10 +1479,22 @@ int xhci_endpoint_init(struct xhci_hcd *xhci, /* Allow 3 retries for everything but isoc, set CErr =3D 3 */ if (!usb_endpoint_xfer_isoc(&ep->desc)) err_count =3D 3; - /* HS bulk max packet should be 512, FS bulk supports 8, 16, 32 or 64 */ + + /* + * HS bulk max packet should be 512 (or 1024 for eUSB2v2), + * FS bulk supports 8, 16, 32 or 64. + */ if (usb_endpoint_xfer_bulk(&ep->desc)) { - if (udev->speed =3D=3D USB_SPEED_HIGH) - max_packet =3D 512; + if (udev->speed =3D=3D USB_SPEED_HIGH) { + if (le16_to_cpu(udev->descriptor.bcdUSB) =3D=3D 0x0230 && + xhci->hcc_params2 & HCC2_E2V2C) { + if (max_packet !=3D 1024) + max_packet =3D 512; + } else { + max_packet =3D 512; + } + } + if (udev->speed =3D=3D USB_SPEED_FULL) { max_packet =3D rounddown_pow_of_two(max_packet); max_packet =3D clamp_val(max_packet, 8, 64); diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index a54f5b57f205..ba3cdc5c732d 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -5371,6 +5371,10 @@ static void xhci_hcd_init_usb2_data(struct xhci_hcd = *xhci, struct usb_hcd *hcd) xhci->usb2_rhub.hcd =3D hcd; hcd->speed =3D HCD_USB2; hcd->self.root_hub->speed =3D USB_SPEED_HIGH; + + if (xhci->hcc_params2 & HCC2_E2V2C) + hcd->self.is_eusb2v2 =3D 1; + /* * USB 2.0 roothub under xHCI has an integrated TT, * (rate matching hub) as opposed to having an OHCI/UHCI diff --git a/include/linux/usb.h b/include/linux/usb.h index 25a203ac7a7e..57fb4c552740 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -464,6 +464,10 @@ struct usb_bus { * the ep queue on a short transfer * with the URB_SHORT_NOT_OK flag set. */ + unsigned is_eusb2v2:1; /* + * true when HC controller supports + * eusb2v2 + */ unsigned no_sg_constraint:1; /* no sg constraint */ unsigned sg_tablesize; /* 0 or largest number of sg list entries */ =20 @@ -625,6 +629,8 @@ struct usb3_lpm_parameters { * @usb2_hw_lpm_allowed: Userspace allows USB 2.0 LPM to be enabled * @usb3_lpm_u1_enabled: USB3 hardware U1 LPM enabled * @usb3_lpm_u2_enabled: USB3 hardware U2 LPM enabled + * @eusb2v2_mps_active: 1024-byte bulk mode is active and must be restored + * after bus reset. * @string_langid: language ID for strings * @product: iProduct string, if present (static) * @manufacturer: iManufacturer string, if present (static) @@ -708,6 +714,7 @@ struct usb_device { unsigned usb2_hw_lpm_allowed:1; unsigned usb3_lpm_u1_enabled:1; unsigned usb3_lpm_u2_enabled:1; + unsigned eusb2v2_mps_active:1; int string_langid; =20 /* static strings from the device */ --=20 2.43.0 From nobody Mon Sep 28 04:51:24 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 E71A53F44F4; Wed, 26 Aug 2026 11:05:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787742319; cv=none; b=LzhRLTI4NqObvoXLOwuLrJR0xgOE+YEwaaKfSYMZpHIPr2ONZZ/fvbaVDlZTssLgka+VSchmt9yD4mp/fXk7z16Auonnt9ZgZnQQ/no7ElG2jSVrbndPmBvYih4tP1zf3WUvf7lB0ounErF0mLRDi7i1kMVuSeh6CToeydt+jao= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787742319; c=relaxed/simple; bh=7/Y9XZ5qIwUjf+u7QQqudzX1t75NIVQ/MCF+ZqoRVR4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cbQZ8SrAZr/JHvwzFbtxOb21raPdXJ3cVOndQ4eVMIG8GWXPSS5DOBiyop6Jw13T2QESBx66znzBe/B3KeYDuP+whG8ciFSzDM1Gd23uJd3+5sEnnaJ82mH7sVSRoI5TSQQ777wcduS0TA9aIZ9nTug9Lv7thMfDXWc0GAwGaxQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HGcOrgIx; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HGcOrgIx" Received: by smtp.kernel.org (Postfix) with ESMTPS id 3CAE3C2BCFF; Wed, 26 Aug 2026 11:05:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1787742318; bh=7/Y9XZ5qIwUjf+u7QQqudzX1t75NIVQ/MCF+ZqoRVR4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=HGcOrgIxFwPBvdMekb0RkTIdq/831EZLYxtU/msUOGQPKAI8HqF7FJBqG8wD8u5qm 5myUcZNXIv9M3pkPlkxEIW8AB98U+rMUF2DxtZOr4pF36Mjkv5IgJEgIlIIHwiU+/2 ZMyDOL/yuo+75wGfvtMQY75VbtLxgh1GR5kep+HPg6PmMLDg1/xRq69HBIYwzgDjI3 uSKzHcbD45ud5cLDNMirAHU/nE9PqZxG3j+jip66E0Xp1Kg69psO9YMINJ537g+WJg pty+327l5Gmz5RLiuyL39WqT7tbFyNvu01qO7rsGdWe9Mp9oy3bjeftXkTwQO2NZXA 70WOppIwpRIug== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18BF6C61DC2; Wed, 26 Aug 2026 11:05:18 +0000 (UTC) From: Pawel Laszczak via B4 Relay Date: Wed, 26 Aug 2026 13:24:37 +0200 Subject: [PATCH v2 2/3] usb: gadget: composite: Support eUSB2v2 bulk MPS update request 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260826-eusb2v2-packet-size-v2-2-950f19f38ef0@cadence.com> References: <20260826-eusb2v2-packet-size-v2-0-950f19f38ef0@cadence.com> In-Reply-To: <20260826-eusb2v2-packet-size-v2-0-950f19f38ef0@cadence.com> To: Greg Kroah-Hartman , Mathias Nyman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Pawel Laszczak X-Mailer: b4 0.15.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1787743495; l=5196; i=pawell@cadence.com; h=from:subject:message-id; bh=+Vgq/zHgap/LYmFpRV7EEJ5RdXoqLEH7MZOSzzbXWI8=; b=dBfN2BXKb9YNLzbz0NF/O5d2ZEEu1SCzk9xxftMLJYdG3BVJBGavzvtCvk9/bAq53TZEP9qPc dCPdWhL1ImRDrcxU6rd/XMxlbP9mzc+cJ5HdMdXSp7KJngmCMJhcwXk X-Developer-Key: i=pawell@cadence.com; a=ed25519; pk=EUPBvLO9CDg7j6defeDl2iqi+z5Ivqu4Z46aiqe7dYc= X-Endpoint-Received: by B4 Relay for pawell@cadence.com/default with auth_id=707 X-Original-From: Pawel Laszczak Reply-To: pawell@cadence.com From: Pawel Laszczak Add support for eUSB2v2 1024-byte Bulk MPS negotiation to the Gadget Composite framework. If 'gadget->is_eusb2v2' is set, force bcdUSB to 0x0230 and bMaxPacketSize0 to 64 bytes. Handle the USB_DEVICE_BULK_MAX_PACKET_UPDATE feature request by introducing eusb2_update_mps_bulk(), which dynamically updates the wMaxPacketSize of all HS Bulk endpoint descriptors to 1024 bytes before the device is configured. Signed-off-by: Pawel Laszczak --- Changes in v2: - composite.c: CLEAR_FEATURE(BULK_MAX_PACKET_UPDATE) is not defined in the eUSB2v2 spec; stall it instead of incorrectly setting 1024-byte mode. - restore MPS in __composite_disconnect --- drivers/usb/gadget/composite.c | 68 ++++++++++++++++++++++++++++++++++++++= ---- include/linux/usb/gadget.h | 2 ++ 2 files changed, 64 insertions(+), 6 deletions(-) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index dc3664374596..f0246e25f2b5 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -924,6 +924,48 @@ static void device_qual(struct usb_composite_dev *cdev) } =20 /*------------------------------------------------------------------------= -*/ +static void eusb2_update_ep_mps(struct usb_descriptor_header *header, __le= 16 mps) +{ + struct usb_endpoint_descriptor *epd; + + if (header->bDescriptorType !=3D USB_DT_ENDPOINT) + return; + + epd =3D (void *)header; + if (usb_endpoint_xfer_bulk(epd)) + epd->wMaxPacketSize =3D mps; +} + +static int eusb2_update_mps_bulk(struct usb_composite_dev *cdev, bool set) +{ + __le16 mps =3D cpu_to_le16(set ? 1024 : 512); + struct usb_gadget *gadget =3D cdev->gadget; + struct usb_configuration *config; + struct usb_function *f; + + if (!gadget->is_eusb2v2) + return -EINVAL; + + if (set && gadget->state >=3D USB_STATE_CONFIGURED) + return -EINVAL; + + list_for_each_entry(config, &cdev->configs, list) { + if (!config->highspeed) + continue; + + list_for_each_entry(f, &config->functions, list) { + struct usb_descriptor_header **desc =3D f->hs_descriptors; + + if (!desc) + continue; + + for (; *desc; desc++) + eusb2_update_ep_mps(*desc, mps); + } + } + + return 0; +} =20 static void reset_config(struct usb_composite_dev *cdev) { @@ -971,8 +1013,10 @@ static int set_config(struct usb_composite_dev *cdev, if (result < 0) goto done; } else { /* Zero configuration value - need to reset the config */ - if (cdev->config) + if (cdev->config) { reset_config(cdev); + eusb2_update_mps_bulk(cdev, false); + } result =3D 0; } =20 @@ -1807,7 +1851,11 @@ composite_setup(struct usb_gadget *gadget, const str= uct usb_ctrlrequest *ctrl) count_configs(cdev, USB_DT_DEVICE); cdev->desc.bMaxPacketSize0 =3D cdev->gadget->ep0->maxpacket; - if (gadget_is_superspeed(gadget)) { + + if (gadget->is_eusb2v2) { + cdev->desc.bcdUSB =3D cpu_to_le16(0x0230); + cdev->desc.bMaxPacketSize0 =3D 64; + } else if (gadget_is_superspeed(gadget)) { if (gadget->speed >=3D USB_SPEED_SUPER) { cdev->desc.bcdUSB =3D cpu_to_le16(0x0320); cdev->desc.bMaxPacketSize0 =3D 9; @@ -2005,12 +2053,19 @@ composite_setup(struct usb_gadget *gadget, const st= ruct usb_ctrlrequest *ctrl) */ case USB_REQ_CLEAR_FEATURE: case USB_REQ_SET_FEATURE: - if (!gadget_is_superspeed(gadget)) - goto unknown; - if (ctrl->bRequestType !=3D (USB_DIR_OUT | USB_RECIP_INTERFACE)) - goto unknown; switch (w_value) { + case USB_DEVICE_BULK_MAX_PACKET_UPDATE: + if (ctrl->bRequestType !=3D (USB_DIR_OUT | USB_RECIP_DEVICE)) + goto unknown; + if (ctrl->bRequest !=3D USB_REQ_SET_FEATURE) + goto unknown; + value =3D eusb2_update_mps_bulk(cdev, true); + break; case USB_INTRF_FUNC_SUSPEND: + if (!gadget_is_superspeed(gadget)) + goto unknown; + if (ctrl->bRequestType !=3D (USB_DIR_OUT | USB_RECIP_INTERFACE)) + goto unknown; if (!cdev->config || intf >=3D MAX_CONFIG_INTERFACES) break; f =3D cdev->config->interface[intf]; @@ -2293,6 +2348,7 @@ static void __composite_disconnect(struct usb_gadget = *gadget) * disconnect callbacks? */ spin_lock_irqsave(&cdev->lock, flags); + eusb2_update_mps_bulk(cdev, false); cdev->suspended =3D 0; if (cdev->config) reset_config(cdev); diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 8285b19a25e0..3c554fe95f87 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -420,6 +420,7 @@ struct usb_gadget_ops { * @wakeup_armed: True if gadget is armed by the host for remote wakeup. * @irq: the interrupt number for device controller. * @id_number: a unique ID number for ensuring that gadget names are disti= nct + * @is_eusb2v2: True if controller is Embedded usb2. * * Gadgets have a mostly-portable "gadget driver" implementing device * functions, handling all usb configurations and interfaces. Gadget @@ -483,6 +484,7 @@ struct usb_gadget { unsigned lpm_capable:1; unsigned wakeup_capable:1; unsigned wakeup_armed:1; + unsigned is_eusb2v2:1; int irq; int id_number; }; --=20 2.43.0 From nobody Mon Sep 28 04:51:24 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 606613D9547; Wed, 26 Aug 2026 11:05:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787742320; cv=none; b=sfIZvsoGkTQ9xtXAs8dVbngwq/daA6QcKU/9Z5/1wakMCeBfJ4cf/WQ4iqoMWCuWQOWopGr+nNEQO6lVTk5iqJ7yWkXR039ASSytl6QSxrMvT6jb/AphCAR6kURjUfhhGgG7qcFDAG6g9rNv1MpUfh9FCGk/8+UELsxDPw4cr9Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787742320; c=relaxed/simple; bh=ath9Jm1YRPO/g0bQeyyBHD15dlZjl85r4pPQ2cZox74=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IVyPqluxlbwQB8ybVkod0HevGJDB0Jtc/GYYE8lvLolVzGArujKwJKVinylyqZFpd785xOmPyUBa1hl4QiUOmqci8ZV+R6fHtHiBoiUMyzmwXN6VrPqOrGH5Td+OvV4hgcnljGqVBI1V80ODYmmvhjM+Yl/akEdAKsFBECH3LU4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RmvwsHVl; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RmvwsHVl" Received: by smtp.kernel.org (Postfix) with ESMTPS id 4A27EC2BCFA; Wed, 26 Aug 2026 11:05:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1787742318; bh=ath9Jm1YRPO/g0bQeyyBHD15dlZjl85r4pPQ2cZox74=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=RmvwsHVlztiw+PIRSKGJR1U7AoAVVLhE1J2m1vTB46jM+/aWQJgl+ZNXmD4Jxkp// Gsmebc7GXkoegCBABZn9RgVkm32bytJl3WrEsSBlCQ42jdjT9thnoeA0Y4szHhCwA5 A3JqaxRfZzVyXyrz6ZBCetrt8V3M2vChiXsD1V948XbRaaJUWYzMZX2lVRg+se1Ckq UQZn77ae7AljvZKwRAqafpfiZuS0Z6FMlMkIZLaqqB5EXT31qKkQXcO9TcH0VK+ZjZ YyeIUnPHcCG2s7wuB7FDagdSfs5zZrpcg3cvxqR524fjD9NY6O38DBOTEl9O06H3RY 4Ru13pQ3j+Q8w== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2CAB9C61DBE; Wed, 26 Aug 2026 11:05:18 +0000 (UTC) From: Pawel Laszczak via B4 Relay Date: Wed, 26 Aug 2026 13:24:38 +0200 Subject: [PATCH v2 3/3] usb: cdns3: cdnsp: Enable eUSB2v2 1KB bulk packet capability 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260826-eusb2v2-packet-size-v2-3-950f19f38ef0@cadence.com> References: <20260826-eusb2v2-packet-size-v2-0-950f19f38ef0@cadence.com> In-Reply-To: <20260826-eusb2v2-packet-size-v2-0-950f19f38ef0@cadence.com> To: Greg Kroah-Hartman , Mathias Nyman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Pawel Laszczak X-Mailer: b4 0.15.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1787743495; l=4597; i=pawell@cadence.com; h=from:subject:message-id; bh=fzuaIRwsep0I/yQ38o8xT1m/qQPyfCzKgU+SbDae//E=; b=/emCebuQHyWB8uZXci9RNMGI7SUDsVxo/gcDTeOPbeayDCSjkfPSsqe7gc/1VP6NFAywCFebt /LGbesGa6tuBAXTpbSV+l1Pe1UT15J2yaG+1Xqs/EFk2EWgkGEERd/w X-Developer-Key: i=pawell@cadence.com; a=ed25519; pk=EUPBvLO9CDg7j6defeDl2iqi+z5Ivqu4Z46aiqe7dYc= X-Endpoint-Received: by B4 Relay for pawell@cadence.com/default with auth_id=707 X-Original-From: Pawel Laszczak Reply-To: pawell@cadence.com From: Pawel Laszczak Implement peripheral-side changes in the Cadence (cdnsp) driver to support eUSB2v2 1024-byte Bulk MaxPacketSize. Check the HCC2_E2V2C bit in HCCPARAMS2 during setup and set 'pdev->gadget.is_eusb2v2 =3D 1' if supported. Update cdnsp_endpoint_init() to allow internal max_packet size allocation up to 1024 bytes for HS Bulk endpoints, and delegate the incoming update setup request from ep0 to the composite layer. Signed-off-by: Pawel Laszczak --- Changes in v2: - cdnsp-mem.c: simplified HS bulk clamp logic to: if (max_packet !=3D 1024) max_packet =3D 512, consistent with xhci-mem.c. --- drivers/usb/cdns3/cdnsp-ep0.c | 2 ++ drivers/usb/cdns3/cdnsp-gadget.c | 4 ++++ drivers/usb/cdns3/cdnsp-gadget.h | 8 ++++++++ drivers/usb/cdns3/cdnsp-mem.c | 10 ++++++++-- drivers/usb/common/debug.c | 2 ++ 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/usb/cdns3/cdnsp-ep0.c b/drivers/usb/cdns3/cdnsp-ep0.c index 5cd9b898ce97..090d20b307ee 100644 --- a/drivers/usb/cdns3/cdnsp-ep0.c +++ b/drivers/usb/cdns3/cdnsp-ep0.c @@ -253,6 +253,8 @@ static int cdnsp_ep0_handle_feature_device(struct cdnsp= _device *pdev, */ cdnsp_enter_test_mode(pdev); break; + case USB_DEVICE_BULK_MAX_PACKET_UPDATE: + return cdnsp_ep0_delegate_req(pdev, ctrl); default: return -EINVAL; } diff --git a/drivers/usb/cdns3/cdnsp-gadget.c b/drivers/usb/cdns3/cdnsp-gad= get.c index a5275c2fb43b..ac1dde43ce1d 100644 --- a/drivers/usb/cdns3/cdnsp-gadget.c +++ b/drivers/usb/cdns3/cdnsp-gadget.c @@ -1853,6 +1853,10 @@ static int cdnsp_gen_setup(struct cdnsp_device *pdev) pdev->hcc_params =3D readl(&pdev->cap_regs->hc_capbase); pdev->hci_version =3D HC_VERSION(pdev->hcc_params); pdev->hcc_params =3D readl(&pdev->cap_regs->hcc_params); + pdev->hcc_params2 =3D readl(&pdev->cap_regs->hcc_params2); + + if (pdev->hcc_params2 & HCC2_E2V2C) + pdev->gadget.is_eusb2v2 =3D 1; =20 /* * Override the APB timeout value to give the controller more time for diff --git a/drivers/usb/cdns3/cdnsp-gadget.h b/drivers/usb/cdns3/cdnsp-gad= get.h index c44bca348a41..75bc3f15bde5 100644 --- a/drivers/usb/cdns3/cdnsp-gadget.h +++ b/drivers/usb/cdns3/cdnsp-gadget.h @@ -89,6 +89,12 @@ struct cdnsp_cap_regs { =20 #define CTX_SIZE(_hcc) (HCC_64BYTE_CONTEXT(_hcc) ? 64 : 32) =20 +/* HCCPARAMS2 - hcc_params2 - bitmasks */ +/* bit 11 - DC support Double BW on a eUSB2 HS ISOC EP */ +#define HCC2_EUSB2_DIC BIT(11) +/* bit 12 - DC support eUSB2V2 capability */ +#define HCC2_E2V2C BIT(12) + /* db_off bitmask - bits 0:1 reserved. */ #define DBOFF_MASK GENMASK(31, 2) =20 @@ -1370,6 +1376,7 @@ struct cdnsp_port { * @rev_cap: Controller Capabilities Registers. * @hcs_params1: Cached register copies of read-only HCSPARAMS1 * @hcc_params: Cached register copies of read-only HCCPARAMS1 + * @hcc_params2: Cached register copies of read-only HCCPARAMS2 * @rtl_revision: Cached controller rtl revision. * @setup: Temporary buffer for setup packet. * @ep0_preq: Internal allocated request used during enumeration. @@ -1425,6 +1432,7 @@ struct cdnsp_device { __u32 hcs_params1; __u32 hcs_params3; __u32 hcc_params; + __u32 hcc_params2; #define RTL_REVISION_NEW_LPM 0x2700 __u32 rtl_revision; /* Lock used in interrupt thread context. */ diff --git a/drivers/usb/cdns3/cdnsp-mem.c b/drivers/usb/cdns3/cdnsp-mem.c index 5d8cdc91927d..e9f205cb1dac 100644 --- a/drivers/usb/cdns3/cdnsp-mem.c +++ b/drivers/usb/cdns3/cdnsp-mem.c @@ -978,8 +978,14 @@ int cdnsp_endpoint_init(struct cdnsp_device *pdev, if (!usb_endpoint_xfer_isoc(pep->endpoint.desc)) err_count =3D 3; if (usb_endpoint_xfer_bulk(pep->endpoint.desc) && - pdev->gadget.speed =3D=3D USB_SPEED_HIGH) - max_packet =3D 512; + pdev->gadget.speed =3D=3D USB_SPEED_HIGH) { + if (!pdev->gadget.is_eusb2v2) + max_packet =3D 512; + else + if (max_packet !=3D 1024) + max_packet =3D 512; + } + /* Controller spec indicates that ctrl ep avg TRB Length should be 8. */ if (usb_endpoint_xfer_control(pep->endpoint.desc)) avg_trb_len =3D 8; diff --git a/drivers/usb/common/debug.c b/drivers/usb/common/debug.c index f204cec8d380..b9696fae7ef5 100644 --- a/drivers/usb/common/debug.c +++ b/drivers/usb/common/debug.c @@ -46,6 +46,8 @@ static const char *usb_decode_device_feature(u16 wValue) return "U2 Enable"; case USB_DEVICE_LTM_ENABLE: return "LTM Enable"; + case USB_DEVICE_BULK_MAX_PACKET_UPDATE: + return "Bulk mps update"; default: return "UNKNOWN"; } --=20 2.43.0