USB: Extend usb_device_speed with new value USB_SPEED_SUPER_PLUS_BY2
Subsystems (18)
PATCH v3 1/1 USB: Extend usb_device_speed with new value USB_SPEED_SUPER_PLUS_BY2
Currently there are there major generations when speaking of USB_SPEED_SUPER_PLUS devices. However, they actually stands for different physical speeds. GEN_2x2 means 20Gbps, while the others mean 10Gbps. So in order to confirm 20Gbps, both speed and generation need ti be checked. This causes a trouble for ioctl USBDEVFS_GET_SPEED since it can only return speed value to userspace.
In order not to add a new ioctl to get ssp generation, extending usb_device_speed is a good option. The side effect is that USB_SPEED_SUPER_PLUS has been used in lots of places and it also takes some effort to go through all of them and check whether the new speed should be used too.
Besides, as suggested by Alen, ssp_rate is not a proper name, change it to ssp_gen. And change all functions/struct fileds ended with ssp_rate to ssp_gen. And there is also some code refactor to reduce duplicate definition of strings and increase the utilization of commonly defined utilities.
--- drivers/bluetooth/btusb.c | 1 + drivers/media/usb/uvc/uvc_video.c | 1 + drivers/net/usb/r8152.c | 1 + drivers/net/usb/usbnet.c | 1 + .../broadcom/brcm80211/brcmfmac/usb.c | 21 +++-- drivers/phy/tegra/xusb.c | 2 +- drivers/usb/cdns3/cdnsp-gadget.c | 3 + drivers/usb/cdns3/cdnsp-mem.c | 4 +- drivers/usb/common/common.c | 85 ++++++++++++++++--- drivers/usb/core/config.c | 2 + drivers/usb/core/devices.c | 14 ++- drivers/usb/core/hcd.c | 8 +- drivers/usb/core/hub.c | 32 ++++--- drivers/usb/core/sysfs.c | 24 ++---- drivers/usb/core/urb.c | 3 +- drivers/usb/dwc3/core.c | 18 ++-- drivers/usb/dwc3/core.h | 4 +- drivers/usb/dwc3/gadget.c | 58 +++++++------ drivers/usb/gadget/composite.c | 12 ++- drivers/usb/gadget/configfs.c | 22 ++--- drivers/usb/gadget/function/f_fs.c | 1 + drivers/usb/gadget/function/f_sourcesink.c | 1 + drivers/usb/gadget/function/f_uac2.c | 14 +-- drivers/usb/gadget/udc/core.c | 4 +- drivers/usb/host/xhci-mem.c | 17 ++-- drivers/usb/host/xhci-mtk-sch.c | 1 + drivers/usb/host/xhci.c | 7 +- drivers/usb/host/xhci.h | 5 +- drivers/usb/mtu3/mtu3_core.c | 2 + drivers/usb/mtu3/mtu3_gadget.c | 1 + include/linux/usb.h | 2 +- include/linux/usb/ch9.h | 14 +-- include/linux/usb/gadget.h | 8 +- include/uapi/linux/usb/ch9.h | 13 ++- sound/usb/card.c | 15 ++-- sound/usb/helper.c | 1 + sound/usb/midi.c | 1 + tools/usb/testusb.c | 6 +- 38 files changed, 258 insertions(+), 171 deletions(-)
drivers/bluetooth/btusb.c +1 -0
@@ -1298,6 +1298,7 @@ static int btusb_submit_intr_urb(struct hci_dev *hdev, gfp_t mem_flags)* force_poll_sync changes. */ switch (urb->dev->speed) { +case USB_SPEED_SUPER_PLUS_BY2 :case USB_SPEED_SUPER_PLUS :case USB_SPEED_SUPER :/* units are 125us */ data->intr_interval =usecs_to_jiffies (urb->interval *125 );
drivers/media/usb/uvc/uvc_video.c +1 -0
@@ -1791,6 +1791,7 @@ u16 uvc_endpoint_max_bpi(struct usb_device *dev, struct usb_host_endpoint *ep)switch (dev->speed) {case USB_SPEED_SUPER :case USB_SPEED_SUPER_PLUS : +case USB_SPEED_SUPER_PLUS_BY2 :return le16_to_cpu (ep->ss_ep_comp.wBytesPerInterval);default : psize =usb_endpoint_maxp (&ep->desc);
drivers/net/usb/r8152.c +1 -0
@@ -7066,6 +7066,7 @@ static void r8153_init(struct r8152 *tp)switch (tp->udev->speed) {case USB_SPEED_SUPER :case USB_SPEED_SUPER_PLUS : +case USB_SPEED_SUPER_PLUS_BY2 : tp->coalesce =COALESCE_SUPER ;break ;case USB_SPEED_HIGH :
drivers/net/usb/usbnet.c +1 -0
@@ -366,6 +366,7 @@ void usbnet_update_max_qlen(struct usbnet *dev)break ;case USB_SPEED_SUPER :case USB_SPEED_SUPER_PLUS : +case USB_SPEED_SUPER_PLUS_BY2 :/* * Not take default 5ms qlen for super speed HC to * save memory, and iperf tests show 2.5ms qlen can
drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c +13 -8
@@ -1427,14 +1427,19 @@ brcmf_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) devinfo->ifnum = desc->bInterfaceNumber; -if (usb->speed ==USB_SPEED_SUPER_PLUS ) -brcmf_dbg (USB ,"Broadcom super speed plus USB WLAN interface detected\n" ); -else if (usb->speed ==USB_SPEED_SUPER ) -brcmf_dbg (USB ,"Broadcom super speed USB WLAN interface detected\n" ); -else if (usb->speed ==USB_SPEED_HIGH ) -brcmf_dbg (USB ,"Broadcom high speed USB WLAN interface detected\n" ); -else -brcmf_dbg (USB ,"Broadcom full speed USB WLAN interface detected\n" ); +switch (usb->speed) { +case USB_SPEED_SUPER_PLUS_BY2 : +case USB_SPEED_SUPER_PLUS : +case USB_SPEED_SUPER : +case USB_SPEED_HIGH : +brcmf_dbg (USB ,"Broadcom %s USB WLAN interface detected\n" , +usb_speed_string (usb->speed)); +break ; +default : +brcmf_dbg (USB ,"Broadcom %s USB WLAN interface detected\n" , +usb_speed_string (USB_SPEED_FULL )); +break ; + } ret =brcmf_usb_probe_cb (devinfo, id->driver_info);if (ret)
drivers/phy/tegra/xusb.c +1 -1
@@ -977,7 +977,7 @@ static int tegra_xusb_usb3_port_parse_dt(struct tegra_xusb_usb3_port *usb3) maximum_speed =usb_get_maximum_speed (&port->dev);if (maximum_speed ==USB_SPEED_SUPER ) usb3->disable_gen2 = true; -else if (maximum_speed ==USB_SPEED_SUPER_PLUS ) +else if (maximum_speed >=USB_SPEED_SUPER_PLUS ) usb3->disable_gen2 = false;else return -EINVAL ;
drivers/usb/cdns3/cdnsp-gadget.c +3 -0
@@ -1250,6 +1250,7 @@ static int cdnsp_run(struct cdnsp_device *pdev, temp =readl (&pdev->port3x_regs->mode_addr);switch (speed) { +case USB_SPEED_SUPER_PLUS_BY2 :case USB_SPEED_SUPER_PLUS : temp |=CFG_3XPORT_SSP_SUPPORT ;break ;
@@ -1745,6 +1746,7 @@ void cdnsp_irq_reset(struct cdnsp_device *pdev)spin_lock (&pdev->lock);switch (pdev->gadget.speed) { +case USB_SPEED_SUPER_PLUS_BY2 :case USB_SPEED_SUPER_PLUS :case USB_SPEED_SUPER : cdnsp_gadget_ep0_desc.wMaxPacketSize =cpu_to_le16 (512 );
@@ -1873,6 +1875,7 @@ static int __cdnsp_gadget_init(struct cdns *cdns)case USB_SPEED_HIGH :case USB_SPEED_SUPER :case USB_SPEED_SUPER_PLUS : +case USB_SPEED_SUPER_PLUS_BY2 :break ;default :dev_err (cdns->dev,"invalid speed parameter %d\n" , max_speed);
drivers/usb/cdns3/cdnsp-mem.c +3 -1
@@ -736,6 +736,7 @@ int cdnsp_setup_addressable_priv_dev(struct cdnsp_device *pdev) slot_ctx->dev_info |=cpu_to_le32 (LAST_CTX (1 ));switch (pdev->gadget.speed) { +case USB_SPEED_SUPER_PLUS_BY2 :case USB_SPEED_SUPER_PLUS : slot_ctx->dev_info |=cpu_to_le32 (SLOT_SPEED_SSP ); max_packets =MAX_PACKET (512 );
@@ -833,8 +834,9 @@ static unsigned int cdnsp_get_endpoint_interval(struct usb_gadget *g,switch (g->speed) {case USB_SPEED_HIGH : -case USB_SPEED_SUPER_PLUS :case USB_SPEED_SUPER : +case USB_SPEED_SUPER_PLUS : +case USB_SPEED_SUPER_PLUS_BY2 :if (usb_endpoint_xfer_int (pep->endpoint.desc) ||usb_endpoint_xfer_isoc (pep->endpoint.desc)) interval =cdnsp_parse_exponent_interval (g, pep);
drivers/usb/common/common.c +72 -13
135 lines not on this page · raw message
drivers/usb/core/config.c +2 -0
@@ -323,6 +323,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,if (usb_endpoint_xfer_int (d)) { i =1 ;switch (udev->speed) { +case USB_SPEED_SUPER_PLUS_BY2 :case USB_SPEED_SUPER_PLUS :case USB_SPEED_SUPER :case USB_SPEED_HIGH :
@@ -433,6 +434,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,break ;case USB_SPEED_SUPER :case USB_SPEED_SUPER_PLUS : +case USB_SPEED_SUPER_PLUS_BY2 : maxpacket_maxes = super_speed_maxpacket_maxes;break ; }
drivers/usb/core/devices.c +6 -8
@@ -395,7 +395,8 @@ static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes,int chix;int ret, cnt =0 ;int parent_devnum =0 ; -char *pages_start, *data_end, *speed; +char *pages_start, *data_end; +const char *speed;unsigned int length;ssize_t total_written =0 ;struct usb_device *childdev =NULL ;
@@ -419,19 +420,16 @@ static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes,* plugged into the root hub has a parent of 0. */ switch (usbdev->speed) { -case USB_SPEED_LOW : - speed ="1.5" ;break ;case USB_SPEED_UNKNOWN :/* usb 1.1 root hub code */ -case USB_SPEED_FULL : speed ="12" ;break ; +case USB_SPEED_LOW : +case USB_SPEED_FULL :case USB_SPEED_HIGH : - speed ="480" ;break ;case USB_SPEED_SUPER : - speed ="5000" ;break ;case USB_SPEED_SUPER_PLUS : - speed ="10000" ;break ; +case USB_SPEED_SUPER_PLUS_BY2 :default : - speed ="??" ; + speed =usb_speed_value (usbdev->speed);break ; } data_end = pages_start + sprintf(pages_start, format_topo, bus->busnum, level, parent_devnum,
drivers/usb/core/hcd.c +4 -4
@@ -2865,7 +2865,7 @@ int usb_add_hcd(struct usb_hcd *hcd, rhdev->rx_lanes =1 ; rhdev->tx_lanes =1 ; - rhdev->ssp_rate =USB_SSP_GEN_UNKNOWN ; + rhdev->ssp_gen =USB_SSP_GEN_UNKNOWN ;switch (hcd->speed) {case HCD_USB11 :
@@ -2880,11 +2880,11 @@ int usb_add_hcd(struct usb_hcd *hcd,case HCD_USB32 : rhdev->rx_lanes =2 ; rhdev->tx_lanes =2 ; - rhdev->ssp_rate = USB_SSP_GEN_2x2; - rhdev->speed =USB_SPEED_SUPER_PLUS ; + rhdev->ssp_gen = USB_SSP_GEN_2x2; + rhdev->speed =USB_SPEED_SUPER_PLUS_BY2 ;break ;case HCD_USB31 : - rhdev->ssp_rate = USB_SSP_GEN_2x1; + rhdev->ssp_gen = USB_SSP_GEN_2x1; rhdev->speed =USB_SPEED_SUPER_PLUS ;break ;default :
drivers/usb/core/hub.c +15 -17
@@ -2693,16 +2693,16 @@ int usb_authorize_device(struct usb_device *usb_dev) }/** -* get_port_ssp_rate - Match the extended port status to SSP rate +* get_port_ssp_gen - Match the extended port status to SSP generation * @hdev: The hub device * @ext_portstatus: extended port status * * Match the extended port status speed id to the SuperSpeed Plus sublink speed * capability attributes. Base on the number of connected lanes and speed, -* return the corresponding enum usb_ssp_rate. +* return the corresponding enum usb_ssp_gen. */ -static enum usb_ssp_rate get_port_ssp_rate (struct usb_device *hdev, -u32 ext_portstatus) +static enum usb_ssp_gen get_port_ssp_gen (struct usb_device *hdev, +u32 ext_portstatus) {struct usb_ssp_cap_descriptor *ssp_cap = hdev->bos->ssp_cap;u32 attr;
@@ -2913,13 +2913,15 @@ static int hub_port_wait_reset(struct usb_hub *hub, int port1,/* extended portstatus Rx and Tx lane count are zero based */ udev->rx_lanes =USB_EXT_PORT_RX_LANES (ext_portstatus) +1 ; udev->tx_lanes =USB_EXT_PORT_TX_LANES (ext_portstatus) +1 ; - udev->ssp_rate =get_port_ssp_rate (hub->hdev, ext_portstatus); + udev->ssp_gen =get_port_ssp_gen (hub->hdev, ext_portstatus); }else { udev->rx_lanes =1 ; udev->tx_lanes =1 ; - udev->ssp_rate =USB_SSP_GEN_UNKNOWN ; + udev->ssp_gen =USB_SSP_GEN_UNKNOWN ; } -if (udev->ssp_rate !=USB_SSP_GEN_UNKNOWN ) +if (udev->ssp_gen == USB_SSP_GEN_2x2) + udev->speed =USB_SPEED_SUPER_PLUS_BY2 ; +else if (udev->ssp_gen !=USB_SSP_GEN_UNKNOWN ) udev->speed =USB_SPEED_SUPER_PLUS ;else if (hub_is_superspeed (hub->hdev)) udev->speed =USB_SPEED_SUPER ;
@@ -4830,6 +4832,7 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1,* it's fixed size except for full speed devices. */ switch (udev->speed) { +case USB_SPEED_SUPER_PLUS_BY2 :case USB_SPEED_SUPER_PLUS :case USB_SPEED_SUPER : udev->ep0.desc.wMaxPacketSize =cpu_to_le16 (512 );
@@ -4960,16 +4963,11 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1,if (udev->speed >=USB_SPEED_SUPER ) { devnum = udev->devnum;dev_info (&udev->dev, -"%s SuperSpeed%s%s USB device number %d using %s\n" , - (udev->config) ?"reset" :"new" , - (udev->speed ==USB_SPEED_SUPER_PLUS ) ? -" Plus" :"" , - (udev->ssp_rate == USB_SSP_GEN_2x2) ? -" Gen 2x2" : - (udev->ssp_rate == USB_SSP_GEN_2x1) ? -" Gen 2x1" : - (udev->ssp_rate == USB_SSP_GEN_1x2) ? -" Gen 1x2" :"" , +"%s %s USB device number %d using %s\n" , + (udev->config) ?"reset" :"new" , + (udev->speed ==USB_SPEED_SUPER ) ? +usb_speed_string (USB_SPEED_SUPER ) : +usb_ssp_gen_name (udev->ssp_gen), devnum, driver_name); }
drivers/usb/core/sysfs.c +6 -18
@@ -146,32 +146,21 @@ static ssize_t speed_show(struct device *dev, struct device_attribute *attr, char *buf) {struct usb_device *udev; -char *speed; +const char *speed; udev =to_usb_device (dev);switch (udev->speed) { -case USB_SPEED_LOW : - speed ="1.5" ; -break ;case USB_SPEED_UNKNOWN : + speed ="12" ;break ; +case USB_SPEED_LOW :case USB_SPEED_FULL : - speed ="12" ; -break ;case USB_SPEED_HIGH : - speed ="480" ; -break ;case USB_SPEED_SUPER : - speed ="5000" ; -break ;case USB_SPEED_SUPER_PLUS : -if (udev->ssp_rate == USB_SSP_GEN_2x2) - speed ="20000" ; -else - speed ="10000" ; -break ; +case USB_SPEED_SUPER_PLUS_BY2 :default : - speed ="unknown" ; + speed =usb_speed_value (udev->speed);break ; }return sysfs_emit (buf,"%s\n" , speed); }
@@ -656,8 +645,7 @@ static int add_power_attributes(struct device *dev)if (udev->usb2_hw_lpm_capable ==1 ) rc =sysfs_merge_group (&dev->kobj, &usb2_hardware_lpm_attr_group); -if ((udev->speed ==USB_SPEED_SUPER || - udev->speed ==USB_SPEED_SUPER_PLUS ) && +if (udev->speed >=USB_SPEED_SUPER && udev->lpm_capable ==1 ) rc =sysfs_merge_group (&dev->kobj, &usb3_hardware_lpm_attr_group);
drivers/usb/core/urb.c +2 -1
@@ -459,7 +459,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) max *= mult; } -if (dev->speed ==USB_SPEED_SUPER_PLUS && +if (dev->speed >=USB_SPEED_SUPER_PLUS &&USB_SS_SSP_ISOC_COMP (ep->ss_ep_comp.bmAttributes)) {struct usb_ssp_isoc_ep_comp_descriptor *isoc_ep_comp;
@@ -544,6 +544,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)/* too big? */ switch (dev->speed) { +case USB_SPEED_SUPER_PLUS_BY2 :case USB_SPEED_SUPER_PLUS :case USB_SPEED_SUPER :/* units are 125us */ /* Handle up to 2^(16-1) microframes */
drivers/usb/dwc3/core.c +10 -8
@@ -1408,7 +1408,7 @@ static void dwc3_get_properties(struct dwc3 *dwc) tx_fifo_resize_max_num =6 ; dwc->maximum_speed =usb_get_maximum_speed (dev); - dwc->max_ssp_rate =usb_get_maximum_ssp_rate (dev); + dwc->max_ssp_gen =usb_get_maximum_ssp_gen (dev); dwc->dr_mode =usb_get_dr_mode (dev); dwc->hsphy_mode =of_usb_get_phy_mode (dev->of_node);
@@ -1575,6 +1575,7 @@ static void dwc3_check_params(struct dwc3 *dwc)dev_warn (dev,"UDC doesn't support Gen 1\n" );break ;case USB_SPEED_SUPER_PLUS : +case USB_SPEED_SUPER_PLUS_BY2 : if ((DWC3_IP_IS(DWC32) && hwparam_gen == DWC3_GHWPARAMS3_SSPHY_IFC_DIS) || (!DWC3_IP_IS(DWC32) &&
@@ -1613,8 +1614,8 @@ static void dwc3_check_params(struct dwc3 *dwc)* set the default to support dual-lane for DWC_usb32 and single-lane * for DWC_usb31 for super-speed-plus. */ -if (dwc->maximum_speed ==USB_SPEED_SUPER_PLUS ) { -switch (dwc->max_ssp_rate) { +if (dwc->maximum_speed >=USB_SPEED_SUPER_PLUS ) { +switch (dwc->max_ssp_gen) {case USB_SSP_GEN_2x1:if (hwparam_gen ==DWC3_GHWPARAMS3_SSPHY_IFC_GEN1 )dev_warn (dev,"UDC only supports Gen 1\n" );
@@ -1628,14 +1629,15 @@ static void dwc3_check_params(struct dwc3 *dwc)default :switch (hwparam_gen) {case DWC3_GHWPARAMS3_SSPHY_IFC_GEN2 : -if (DWC3_IP_IS (DWC32 )) - dwc->max_ssp_rate = USB_SSP_GEN_2x2; -else - dwc->max_ssp_rate = USB_SSP_GEN_2x1; +if (DWC3_IP_IS (DWC32 )) { + dwc->max_ssp_gen = USB_SSP_GEN_2x2; + dwc->maximum_speed =USB_SPEED_SUPER_PLUS_BY2 ; + }else + dwc->max_ssp_gen = USB_SSP_GEN_2x1;break ;case DWC3_GHWPARAMS3_SSPHY_IFC_GEN1 :if (DWC3_IP_IS (DWC32 )) - dwc->max_ssp_rate = USB_SSP_GEN_1x2; + dwc->max_ssp_gen = USB_SSP_GEN_1x2;break ; }break ;
drivers/usb/dwc3/core.h +2 -2
@@ -1194,8 +1194,8 @@ struct dwc3 {u32 u1u2;u32 maximum_speed;u32 gadget_max_speed; -enum usb_ssp_rate max_ssp_rate; -enum usb_ssp_rate gadget_ssp_rate; +enum usb_ssp_gen max_ssp_gen; +enum usb_ssp_gen gadget_ssp_gen;u32 ip;
drivers/usb/dwc3/gadget.c +34 -24
140 lines not on this page · raw message
drivers/usb/gadget/composite.c +8 -4
@@ -71,6 +71,7 @@ function_descriptors(struct usb_function *f,*/ switch (speed) { +case USB_SPEED_SUPER_PLUS_BY2 :case USB_SPEED_SUPER_PLUS : descriptors = f->ssp_descriptors;if (descriptors)
@@ -169,6 +170,7 @@ int config_ep_by_speed_and_alt(struct usb_gadget *g,/* select desired speed */ switch (g->speed) { +case USB_SPEED_SUPER_PLUS_BY2 :case USB_SPEED_SUPER_PLUS :if (f->ssp_descriptors) { speed_desc = f->ssp_descriptors;
@@ -650,6 +652,7 @@ static int config_desc(struct usb_composite_dev *cdev, unsigned w_value) check_config:/* ignore configs that won't work at this speed */ switch (speed) { +case USB_SPEED_SUPER_PLUS_BY2 :case USB_SPEED_SUPER_PLUS :if (!c->superspeed_plus)continue ;
@@ -688,8 +691,9 @@ static int count_configs(struct usb_composite_dev *cdev, unsigned type) hs =1 ;if (gadget->speed ==USB_SPEED_SUPER ) ss =1 ; -if (gadget->speed ==USB_SPEED_SUPER_PLUS ) +if (gadget->speed >=USB_SPEED_SUPER_PLUS ) ssp =1 ; +if (type ==USB_DT_DEVICE_QUALIFIER ) hs = !hs; }
@@ -803,7 +807,7 @@ static int bos_desc(struct usb_composite_dev *cdev)u8 ssic;int i; -if (cdev->gadget->max_ssp_rate == USB_SSP_GEN_2x2) +if (cdev->gadget->max_ssp_gen == USB_SSP_GEN_2x2) ssac =3 ;/*
@@ -850,8 +854,8 @@ static int bos_desc(struct usb_composite_dev *cdev) ssid = i >>1 ; -if (cdev->gadget->max_ssp_rate == USB_SSP_GEN_2x1 || - cdev->gadget->max_ssp_rate ==USB_SSP_GEN_UNKNOWN ) +if (cdev->gadget->max_ssp_gen == USB_SSP_GEN_2x1 || + cdev->gadget->max_ssp_gen ==USB_SSP_GEN_UNKNOWN ) mantissa =10 ;else mantissa =5 << ssid;
drivers/usb/gadget/configfs.c +11 -11
@@ -327,18 +327,18 @@ static ssize_t gadget_dev_desc_max_speed_store(struct config_item *item,if (gi->composite.gadget_driver.udc_name) goto err; -if (strncmp (page,"super-speed-plus" ,16 ) ==0 ) - gi->composite.max_speed =USB_SPEED_SUPER_PLUS ; -else if (strncmp (page,"super-speed" ,11 ) ==0 ) - gi->composite.max_speed =USB_SPEED_SUPER ; -else if (strncmp (page,"high-speed" ,10 ) ==0 ) - gi->composite.max_speed =USB_SPEED_HIGH ; -else if (strncmp (page,"full-speed" ,10 ) ==0 ) - gi->composite.max_speed =USB_SPEED_FULL ; -else if (strncmp (page,"low-speed" ,9 ) ==0 ) - gi->composite.max_speed =USB_SPEED_LOW ; -else + gi->composite.max_speed =usb_speed_from_name (page); +switch (gi->composite.max_speed) { +case USB_SPEED_SUPER_PLUS_BY2 : +case USB_SPEED_SUPER_PLUS : +case USB_SPEED_SUPER : +case USB_SPEED_HIGH : +case USB_SPEED_FULL : +case USB_SPEED_LOW : +break ; +default : goto err; + } gi->composite.gadget_driver.max_speed = gi->composite.max_speed;
drivers/usb/gadget/function/f_fs.c +1 -0
@@ -1321,6 +1321,7 @@ static long ffs_epfile_ioctl(struct file *file, unsigned code,switch (epfile->ffs->gadget->speed) {case USB_SPEED_SUPER :case USB_SPEED_SUPER_PLUS : +case USB_SPEED_SUPER_PLUS_BY2 : desc_idx =2 ;break ;case USB_SPEED_HIGH :
drivers/usb/gadget/function/f_sourcesink.c +1 -0
@@ -582,6 +582,7 @@ static int source_sink_start_ep(struct f_sourcesink *ss, bool is_in,if (is_iso) {switch (speed) { +case USB_SPEED_SUPER_PLUS_BY2 :case USB_SPEED_SUPER_PLUS :case USB_SPEED_SUPER : size = ss->isoc_maxpacket *
drivers/usb/gadget/function/f_uac2.c +2 -12
@@ -124,16 +124,6 @@ static struct usb_string strings_fn[] = { { }, }; -static const char *const speed_names[] = { - [USB_SPEED_UNKNOWN ] ="UNKNOWN" , - [USB_SPEED_LOW ] ="LS" , - [USB_SPEED_FULL ] ="FS" , - [USB_SPEED_HIGH ] ="HS" , - [USB_SPEED_WIRELESS ] ="W" , - [USB_SPEED_SUPER ] ="SS" , - [USB_SPEED_SUPER_PLUS ] ="SS+" , -}; -static struct usb_gadget_strings str_fn = { .language =0x0409 ,/* en-us */ .strings = strings_fn,
@@ -763,11 +753,11 @@ static int set_ep_max_packet_size_bint(struct device *dev, const struct f_uac2_oif (max_size_bw <= max_size_ep)dev_dbg (dev,"%s %s: Would use wMaxPacketSize %d and bInterval %d\n" , - speed_names[speed], dir, max_size_bw, bint); +usb_speed_string (speed), dir, max_size_bw, bint);else {dev_warn (dev,"%s %s: Req. wMaxPacketSize %d at bInterval %d > max ISOC %d, may drop data!\n" , - speed_names[speed], dir, max_size_bw, bint, max_size_ep); +usb_speed_string (speed), dir, max_size_bw, bint, max_size_ep); max_size_bw = max_size_ep; }
drivers/usb/gadget/udc/core.c +2 -2
@@ -1266,8 +1266,8 @@ static inline void usb_gadget_udc_set_speed(struct usb_udc *udc,else s =min (speed, gadget->max_speed); -if (s ==USB_SPEED_SUPER_PLUS && gadget->ops->udc_set_ssp_rate) - gadget->ops->udc_set_ssp_rate (gadget, gadget->max_ssp_rate); +if (s >=USB_SPEED_SUPER_PLUS && gadget->ops->udc_set_ssp_gen) + gadget->ops->udc_set_ssp_gen (gadget, gadget->max_ssp_gen);else if (gadget->ops->udc_set_speed) gadget->ops->udc_set_speed (gadget, s); }
drivers/usb/host/xhci-mem.c +12 -5
@@ -1087,25 +1087,31 @@ int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *ud/* 3) Only the control endpoint is valid - one endpoint context */ slot_ctx->dev_info |=cpu_to_le32 (LAST_CTX (1 ) | udev->route);switch (udev->speed) { +case USB_SPEED_SUPER_PLUS_BY2 :case USB_SPEED_SUPER_PLUS : - slot_ctx->dev_info |=cpu_to_le32 (SLOT_SPEED_SSP ); + slot_ctx->dev_info |= (xhci->hci_version <0x120 ) ? +cpu_to_le32 (SLOT_SPEED_SSP ) :0 ; max_packets =MAX_PACKET (512 );break ;case USB_SPEED_SUPER : - slot_ctx->dev_info |=cpu_to_le32 (SLOT_SPEED_SS ); + slot_ctx->dev_info |= (xhci->hci_version <0x120 ) ? +cpu_to_le32 (SLOT_SPEED_SS ) :0 ; max_packets =MAX_PACKET (512 );break ;case USB_SPEED_HIGH : - slot_ctx->dev_info |=cpu_to_le32 (SLOT_SPEED_HS ); + slot_ctx->dev_info |= (xhci->hci_version <0x120 ) ? +cpu_to_le32 (SLOT_SPEED_HS ) :0 ; max_packets =MAX_PACKET (64 );break ;/* USB core guesses at a 64-byte max packet first for FS devices */ case USB_SPEED_FULL : - slot_ctx->dev_info |=cpu_to_le32 (SLOT_SPEED_FS ); + slot_ctx->dev_info |= (xhci->hci_version <0x120 ) ? +cpu_to_le32 (SLOT_SPEED_FS ) :0 ; max_packets =MAX_PACKET (64 );break ;case USB_SPEED_LOW : - slot_ctx->dev_info |=cpu_to_le32 (SLOT_SPEED_LS ); + slot_ctx->dev_info |= (xhci->hci_version <0x120 ) ? +cpu_to_le32 (SLOT_SPEED_LS ) :0 ; max_packets =MAX_PACKET (8 );break ;default :
@@ -1276,6 +1282,7 @@ static unsigned int xhci_get_endpoint_interval(struct usb_device *udev, } fallthrough;/* SS and HS isoc/int have same decoding */ +case USB_SPEED_SUPER_PLUS_BY2 :case USB_SPEED_SUPER_PLUS :case USB_SPEED_SUPER : if (usb_endpoint_xfer_int(&ep->desc) ||
drivers/usb/host/xhci-mtk-sch.c +1 -0
@@ -89,6 +89,7 @@ static u32 get_bw_boundary(enum usb_device_speed speed)u32 boundary;switch (speed) { +case USB_SPEED_SUPER_PLUS_BY2 :case USB_SPEED_SUPER_PLUS : boundary =SSP_BW_BOUNDARY ;break ;
drivers/usb/host/xhci.c +4 -3
@@ -2192,6 +2192,7 @@ static unsigned int xhci_get_block_size(struct usb_device *udev)return HS_BLOCK ;case USB_SPEED_SUPER :case USB_SPEED_SUPER_PLUS : +case USB_SPEED_SUPER_PLUS_BY2 :return SS_BLOCK ;case USB_SPEED_UNKNOWN :default :
@@ -5102,15 +5103,15 @@ static void xhci_hcd_init_usb3_data(struct xhci_hcd *xhci, struct usb_hcd *hcd)switch (minor_rev) {case 2 : hcd->speed =HCD_USB32 ; - hcd->self.root_hub->speed =USB_SPEED_SUPER_PLUS ; + hcd->self.root_hub->speed =USB_SPEED_SUPER_PLUS_BY2 ; hcd->self.root_hub->rx_lanes =2 ; hcd->self.root_hub->tx_lanes =2 ; - hcd->self.root_hub->ssp_rate = USB_SSP_GEN_2x2; + hcd->self.root_hub->ssp_gen = USB_SSP_GEN_2x2;break ;case 1 : hcd->speed =HCD_USB31 ; hcd->self.root_hub->speed =USB_SPEED_SUPER_PLUS ; - hcd->self.root_hub->ssp_rate = USB_SSP_GEN_2x1; + hcd->self.root_hub->ssp_gen = USB_SSP_GEN_2x1;break ; } xhci_info(xhci, "Host supports USB 3.%x %sSuperSpeed\n",
drivers/usb/host/xhci.h +4 -1
@@ -345,7 +345,10 @@ struct xhci_op_regs {#define DEV_SUPERSPEED_ANY (p) (((p) & DEV_SPEED_MASK) >= XDEV_SS)#define DEV_PORT_SPEED (p) (((p) >> 10) & 0x0f) -/* Bits 20:23 in the Slot Context are the speed for the device */ +/* Bits 20:23 in the Slot Context are the speed for the device. +* This field has been deprecated since xHCI spec revision 1.2 +* and shall be reserved. +*/ #define SLOT_SPEED_FS (XDEV_FS << 10)#define SLOT_SPEED_LS (XDEV_LS << 10)#define SLOT_SPEED_HS (XDEV_HS << 10)
drivers/usb/mtu3/mtu3_core.c +2 -0
@@ -254,6 +254,7 @@ static void mtu3_set_speed(struct mtu3 *mtu, enum usb_device_speed speed) SSUSB_U3_PORT_SSP_SPEED);break ;case USB_SPEED_SUPER_PLUS : +case USB_SPEED_SUPER_PLUS_BY2 :mtu3_setbits (mbase,U3D_POWER_MANAGEMENT ,HS_ENABLE );mtu3_setbits (mtu->ippc_base,SSUSB_U3_CTRL (0 ),SSUSB_U3_PORT_SSP_SPEED );
@@ -831,6 +832,7 @@ static void mtu3_check_params(struct mtu3 *mtu)case USB_SPEED_HIGH :case USB_SPEED_SUPER :case USB_SPEED_SUPER_PLUS : +case USB_SPEED_SUPER_PLUS_BY2 :break ;default : dev_err(mtu->dev, "invalid max_speed: %s\n",
drivers/usb/mtu3/mtu3_gadget.c +1 -0
@@ -74,6 +74,7 @@ static int mtu3_ep_enable(struct mtu3_ep *mep)switch (mtu->g.speed) {case USB_SPEED_SUPER :case USB_SPEED_SUPER_PLUS : +case USB_SPEED_SUPER_PLUS_BY2 :if (usb_endpoint_xfer_int (desc) ||usb_endpoint_xfer_isoc (desc)) { interval = desc->bInterval;
include/linux/usb.h +1 -1
@@ -657,7 +657,7 @@ struct usb_device {enum usb_device_speed speed;unsigned int rx_lanes;unsigned int tx_lanes; -enum usb_ssp_rate ssp_rate; +enum usb_ssp_gen ssp_gen;struct usb_tt *tt;int ttport;
include/linux/usb/ch9.h +4 -10
@@ -32,21 +32,15 @@#include <uapi/linux/usb/ch9.h> -/* USB 3.2 SuperSpeed Plus phy signaling rate generation and lane count */ - -enum usb_ssp_rate { -USB_SSP_GEN_UNKNOWN =0 , - USB_SSP_GEN_2x1, - USB_SSP_GEN_1x2, - USB_SSP_GEN_2x2, -}; -struct device ;extern const char *usb_ep_type_string (int ep_type);extern const char *usb_speed_string (enum usb_device_speed speed); +extern const char *usb_speed_value (enum usb_device_speed speed); +extern const char *usb_ssp_gen_name (enum usb_ssp_gen gen); +extern enum usb_device_speed usb_speed_from_name (const char *speed_name);extern enum usb_device_speed usb_get_maximum_speed (struct device *dev); -extern enum usb_ssp_rate usb_get_maximum_ssp_rate (struct device *dev); +extern enum usb_ssp_gen usb_get_maximum_ssp_gen (struct device *dev);extern const char *usb_state_string (enum usb_device_state state);unsigned int usb_decode_interval (const struct usb_endpoint_descriptor *epd,enum usb_device_speed speed);
include/linux/usb/gadget.h +4 -4
@@ -324,8 +324,8 @@ struct usb_gadget_ops { struct usb_gadget_driver *);int (*udc_stop)(struct usb_gadget *);void (*udc_set_speed)(struct usb_gadget *,enum usb_device_speed ); -void (*udc_set_ssp_rate)(struct usb_gadget *gadget, -enum usb_ssp_rate rate); +void (*udc_set_ssp_gen)(struct usb_gadget *gadget, +enum usb_ssp_gen gen);void (*udc_async_callbacks)(struct usb_gadget *gadget,bool enable); struct usb_ep *(*match_ep)(struct usb_gadget *, struct usb_endpoint_descriptor *,
@@ -420,8 +420,8 @@ struct usb_gadget {enum usb_device_speed max_speed;/* USB SuperSpeed Plus only */ -enum usb_ssp_rate ssp_rate; -enum usb_ssp_rate max_ssp_rate; +enum usb_ssp_gen ssp_gen; +enum usb_ssp_gen max_ssp_gen;enum usb_device_state state;const char *name;
include/uapi/linux/usb/ch9.h +11 -2
@@ -1181,10 +1181,19 @@ enum usb_device_speed {USB_SPEED_LOW ,USB_SPEED_FULL ,/* usb 1.1 */ USB_SPEED_HIGH ,/* usb 2.0 */ USB_SPEED_WIRELESS ,/* wireless (usb 2.5) */ -USB_SPEED_SUPER ,/* usb 3.0 */ - USB_SPEED_SUPER_PLUS, /* usb 3.1 */ +USB_SPEED_SUPER ,/* usb 3.0 5Gbps */ +USB_SPEED_SUPER_PLUS ,/* usb 3.1 10Gbps */ + USB_SPEED_SUPER_PLUS_BY2, /* usb 3.2 20Gbps */ }; +/* USB 3.2 SuperSpeed Plus phy signaling generation and lane count */ + +enum usb_ssp_gen { +USB_SSP_GEN_UNKNOWN =0 , + USB_SSP_GEN_2x1, + USB_SSP_GEN_1x2, + USB_SSP_GEN_2x2, +}; enum usb_device_state {/* NOTATTACHED isn't in the USB spec, and this state acts
sound/usb/card.c +6 -9
@@ -571,19 +571,15 @@ static void usb_audio_make_longname(struct usb_device *dev,switch (snd_usb_get_speed (dev)) {case USB_SPEED_LOW : -strlcat (card->longname,", low speed" ,sizeof (card->longname)); -break ;case USB_SPEED_FULL : -strlcat (card->longname,", full speed" ,sizeof (card->longname)); -break ;case USB_SPEED_HIGH : -strlcat (card->longname,", high speed" ,sizeof (card->longname)); -break ;case USB_SPEED_SUPER : -strlcat (card->longname,", super speed" ,sizeof (card->longname)); -break ;case USB_SPEED_SUPER_PLUS : -strlcat (card->longname,", super speed plus" ,sizeof (card->longname)); +case USB_SPEED_SUPER_PLUS_BY2 : +strlcat (card->longname,", " ,sizeof (card->longname)); +strlcat (card->longname, +usb_speed_string (snd_usb_get_speed (dev)), +sizeof (card->longname));break ;default :break ;
@@ -612,6 +608,7 @@ static int snd_usb_audio_create(struct usb_interface *intf,case USB_SPEED_HIGH :case USB_SPEED_SUPER :case USB_SPEED_SUPER_PLUS : +case USB_SPEED_SUPER_PLUS_BY2 :break ;default :dev_err (&dev->dev,"unknown device speed %d\n" ,snd_usb_get_speed (dev));
sound/usb/helper.c +1 -0
@@ -110,6 +110,7 @@ unsigned char snd_usb_parse_datainterval(struct snd_usb_audio *chip,case USB_SPEED_HIGH :case USB_SPEED_SUPER :case USB_SPEED_SUPER_PLUS : +case USB_SPEED_SUPER_PLUS_BY2 :if (get_endpoint (alts,0 )->bInterval >=1 &&get_endpoint (alts,0 )->bInterval <=4 )return get_endpoint (alts,0 )->bInterval -1 ;
sound/usb/midi.c +1 -0
@@ -897,6 +897,7 @@ static void snd_usbmidi_us122l_output(struct snd_usb_midi_out_endpoint *ep,case USB_SPEED_HIGH :case USB_SPEED_SUPER :case USB_SPEED_SUPER_PLUS : +case USB_SPEED_SUPER_PLUS_BY2 : count =1 ;break ;default :
tools/usb/testusb.c +4 -2
@@ -98,8 +98,9 @@ enum usb_device_speed {USB_SPEED_LOW ,USB_SPEED_FULL ,/* usb 1.1 */ USB_SPEED_HIGH ,/* usb 2.0 */ USB_SPEED_WIRELESS ,/* wireless (usb 2.5) */ -USB_SPEED_SUPER ,/* usb 3.0 */ - USB_SPEED_SUPER_PLUS, /* usb 3.1 */ +USB_SPEED_SUPER ,/* usb 3.0 5Gbps */ +USB_SPEED_SUPER_PLUS ,/* usb 3.1 10Gbps */ + USB_SPEED_SUPER_PLUS_BY2, /* usb 3.2 20Gbps */ };/*-------------------------------------------------------------------------*/
@@ -114,6 +115,7 @@ static char *speed (enum usb_device_speed s)case USB_SPEED_WIRELESS :return "wireless" ;case USB_SPEED_SUPER :return "super" ;case USB_SPEED_SUPER_PLUS :return "super-plus" ; +case USB_SPEED_SUPER_PLUS_BY2 :return "super-plus-by2" ;default :return "??" ; } }
Signature · 1 line
2.25.1
Thinh Nguyen
maintainerHi,
Please Cc me for changes related to dwc3.
Quoted 14 lines · Dingyan Li
Currently there are there major generations when speaking of
USB_SPEED_SUPER_PLUSdevices. However, they actually stands for different physical speeds.GEN_2x2means 20Gbps, while the others mean 10Gbps. So in order to confirm 20Gbps, both speed and generation need ti be checked. This causes a trouble for ioctlUSBDEVFS_GET_SPEEDsince it can only return speed value to userspace.In order not to add a new ioctl to get ssp generation, extending
usb_device_speedis a good option. The side effect is thatUSB_SPEED_SUPER_PLUShas been used in lots of places and it also takes some effort to go through all of them and check whether the new speed should be used too.
Quoted 7 lines
Besides, as suggested by Alen,
ssp_rateis not a proper name, change it tossp_gen. And change all functions/struct fileds ended withssp_ratetossp_gen. And there is also some code refactor to reduce duplicate definition of strings and increase the utilization of commonly defined utilities.Signed-off-by Dingyan Li <[email protected]>
Why not spell out the whole thing instead of USB_SPEED_SUPER_PLUS_BY2 (ie. USB_SPEED_SUPER_PLUS_GEN_2x2) as you intended instead of just the lane count.
There are SuperSpeed Plus generation _and_ lane count. That's why I didn't name "usb_ssp_gen" that only reflects the generation and not the lane count. Also, I didn't extend usb_device_speed because gen XxY are all a single speed: SuperSpeed Plus.
If you're planning to do it this way, why not add the other speeds (such as gen 1x2) to usb_device_speed enum too? Then we can drop the usb_ssp_rate enum. If we're going to check multiple enum for SuperSpeed Plus, we probably need a usb_device_is_superspeed_plus() function.
Now we need to audit all the greater/lesser speed checks that use < or > to make sure that they are used how they were intended to.
Since these changes are not simple and will touch on multiple places, please split this patch out.
Thanks,
Thinh
Thinh Nguyen
maintainerHi,
Please Cc me for changes related to dwc3.
Quoted 14 lines · Dingyan Li
Currently there are there major generations when speaking of
USB_SPEED_SUPER_PLUSdevices. However, they actually stands for different physical speeds.GEN_2x2means 20Gbps, while the others mean 10Gbps. So in order to confirm 20Gbps, both speed and generation need ti be checked. This causes a trouble for ioctlUSBDEVFS_GET_SPEEDsince it can only return speed value to userspace.In order not to add a new ioctl to get ssp generation, extending
usb_device_speedis a good option. The side effect is thatUSB_SPEED_SUPER_PLUShas been used in lots of places and it also takes some effort to go through all of them and check whether the new speed should be used too.
Quoted 8 lines
Besides, as suggested by Alen,
ssp_rateis not a proper name, change it tossp_gen. And change all functions/struct fileds ended withssp_ratetossp_gen. And there is also some code refactor to reduce duplicate definition of strings and increase the utilization of commonly defined utilities.Signed-off-by Dingyan Li <[email protected]>---
Can we spell out the whole thing instead of USB_SPEED_SUPER_PLUS_BY2 (ie. USB_SPEED_SUPER_PLUS_GEN_2x2 as you intended) instead of just the lane count.
There are SuperSpeed Plus generation _and_ lane count. That's why I didn't name "usb_ssp_gen" that only reflects the generation and not the lane count. Also, I didn't extend usb_device_speed because gen XxY are all a single speed: SuperSpeed Plus.
If you're planning to do it this way, why not add the other speeds (such as gen 1x2) to usb_device_speed enum too? Then we can drop the usb_ssp_rate enum. If we're going to check multiple enum for SuperSpeed Plus, we probably need a usb_device_is_superspeed_plus() function.
Now we need to audit all the greater/lesser speed checks that use < or > to make sure that they are used how they were intended to.
Since these changes are not simple and will touch on multiple places, please split this patch out.
Thanks,
Thinh
Quoted 4 lines · Thinh Nguyen
Hi,
Please Cc me for changes related to dwc3.
Sure, thanks for letting me know.
Quoted 21 lines · Dingyan Li
Quoted 20 lines
Currently there are there major generations when speaking of
USB_SPEED_SUPER_PLUSdevices. However, they actually stands for different physical speeds.GEN_2x2means 20Gbps, while the others mean 10Gbps. So in order to confirm 20Gbps, both speed and generation need ti be checked. This causes a trouble for ioctlUSBDEVFS_GET_SPEEDsince it can only return speed value to userspace.In order not to add a new ioctl to get ssp generation, extending
usb_device_speedis a good option. The side effect is thatUSB_SPEED_SUPER_PLUShas been used in lots of places and it also takes some effort to go through all of them and check whether the new speed should be used too.Besides, as suggested by Alen,
ssp_rateis not a proper name, change it tossp_gen. And change all functions/struct fileds ended withssp_ratetossp_gen. And there is also some code refactor to reduce duplicate definition of strings and increase the utilization of commonly defined utilities.
Quoted 7 lines
Quoted 2 lines
Signed-off-by Dingyan Li <[email protected]>---
Can we spell out the whole thing instead of
USB_SPEED_SUPER_PLUS_BY2(ie.USB_SPEED_SUPER_PLUS_GEN_2x2as you intended) instead of just the lane count.
Here is a little bit more context at
https://lore.kernel.org/lkml/[email protected]/
What I'm trying to do is that in enum usb_device_speed, we only care about overall speed instead of stuff like lanes. For example, GEN_1x2 and GEN_2X1 are both 10Gbps, so we can use USB_SPEED_SUPER_PLUS
to represent 10Gbps. GEN_2x2 represent 20Gbps, we can use USB_SPEED_SUPER_PLUS_BY2. There is no need to append generation and lane info when we only want to talk about overall speed. By the way, Apple also uses a similar way to declare speed enums and the new speed name is kind of borrowed from it.
Quoted 3 lines
There are SuperSpeed Plus generation _and_ lane count. That's why I didn't name "
usb_ssp_gen" that only reflects the generation and not the
Still, I think "usb_ssp_gen" is slightly better than "usb_ssp_rate". As for the lanes, I think it's OK to not mention it in the name since there are already comments to explain what this enum is for. Besides, the word "rate" is kind of like "speed", which should be covered by usb_device_speed instead of in the enum for generation and lanes.
Quoted 3 lines
lane count. Also, I didn't extend
usb_device_speedbecause gen XxY are all a single speed: SuperSpeed Plus.
Again, I think it depends on what we really mean when speaking of speed. Clearly GEN_2x2 and GEN_2x1 have different overall speed. Let's not hide the fact under SuperSpeed Plus.
Quoted 3 lines
If you're planning to do it this way, why not add the other speeds (such as gen 1x2) to
usb_device_speedenum too? Then we can drop the
Like I said above, if we only care about the overall speed, there is no need to tell GEN_1x2 from GEN_2x1 since both are 10Gbps. But like in dwc3 code, there are some different behaviors based on generation and lanes, so the enum still needs to be kept.
Quoted 6 lines
usb_ssp_rateenum. If we're going to check multiple enum for SuperSpeed Plus, we probably need ausb_device_is_superspeed_plus()function.Now we need to audit all the greater/lesser speed checks that use < or > to make sure that they are used how they were intended to.
After going through all places where USB_SPEED_SUPER_PLUS is used, for switch statements, I choose to add an extra case. For if statement, change "==" to ">=". But I'm not completely sure they are all correct, which need to be further checked by maintainers.
Quoted 3 lines
Since these changes are not simple and will touch on multiple places, please split this patch out.
Okay, I can try to split the patch once we reach an agreement on how to handle SSP speed and generation. Besides, there is almost one file for each different module and it's not good to send one patch for each of them, right? There would be many in this way.
Regards,
Dingyan
Thinh Nguyen
maintainerQuoted 36 lines · Dingyan Li
Quoted 4 lines · Thinh Nguyen
Hi,
Please Cc me for changes related to dwc3.
Sure, thanks for letting me know.
Quoted 21 lines · Dingyan Li
Quoted 20 lines
Currently there are there major generations when speaking of
USB_SPEED_SUPER_PLUSdevices. However, they actually stands for different physical speeds.GEN_2x2means 20Gbps, while the others mean 10Gbps. So in order to confirm 20Gbps, both speed and generation need ti be checked. This causes a trouble for ioctlUSBDEVFS_GET_SPEEDsince it can only return speed value to userspace.In order not to add a new ioctl to get ssp generation, extending
usb_device_speedis a good option. The side effect is thatUSB_SPEED_SUPER_PLUShas been used in lots of places and it also takes some effort to go through all of them and check whether the new speed should be used too.Besides, as suggested by Alen,
ssp_rateis not a proper name, change it tossp_gen. And change all functions/struct fileds ended withssp_ratetossp_gen. And there is also some code refactor to reduce duplicate definition of strings and increase the utilization of commonly defined utilities.Quoted 7 lines
Quoted 2 lines
Signed-off-by Dingyan Li <[email protected]>---
Can we spell out the whole thing instead of
USB_SPEED_SUPER_PLUS_BY2(ie.USB_SPEED_SUPER_PLUS_GEN_2x2as you intended) instead of just the lane count.
Quoted 10 lines
Here is a little bit more context at
https://urldefense.com/v3/__https://lore.kernel.org/lkml/[email protected]/__;!!A4F2R9G_pg!be_iVrJNFXagks2td2lrjlK6RvWnQ8P8wXkBJwQULZNbVDKcLDOBw_45IPNVe8Lm_i-CU3eq0D4hkPWUNTatmVJIVQ$
What I'm trying to do is that in enumusb_device_speed, we only care about overall speed instead of stuff like lanes. For example,GEN_1x2andGEN_2X1are both 10Gbps, so we can useUSB_SPEED_SUPER_PLUS
to represent 10Gbps.GEN_2x2represent 20Gbps, we can useUSB_SPEED_SUPER_PLUS_BY2. There is no need to append generation and lane info when we only want to talk about overall speed. By the way, Apple also uses a similar way to declare speed enums and the new speed name is kind of borrowed from it.
The USB speed naming convention is already confusing as is. Now if you introduce a new version of calling SuperSpeed Plus Gen 2x2 as USB_SPEED_SUPER_PLUS_BY2, it's even more confusing.
Probably most class/function drivers don't care about the Gen or lane count. However, the controller drivers use that to properly configure the controller and report the speeds. If you really don't care about the gen and the lane count, we may as well report everything as SuperSpeed Plus. But that's not the case right? Your use case is that you only care about 10Gbps or 20Gbps. Why limit to only your use case?
Quoted 9 lines
Quoted 4 lines
There are SuperSpeed Plus generation _and_ lane count. That's why I didn't name "
usb_ssp_gen" that only reflects the generation and not theStill, I think "
usb_ssp_gen" is slightly better than "usb_ssp_rate". As for the lanes, I think it's OK to not mention it in the name since there are already comments to explain what this enum is for. Besides, the word "rate" is kind of like "speed", which should be covered byusb_device_speedinstead of in the enum for generation and lanes.
Sure, but we could argue that it shares how the usb spec indicates Gen XxY as where X is the "rate" of signaling on the wire.
But then again, I had trouble coming up with a better name. :/
Quoted 7 lines
Quoted 4 lines
lane count. Also, I didn't extend
usb_device_speedbecause gen XxY are all a single speed: SuperSpeed Plus.Again, I think it depends on what we really mean when speaking of speed. Clearly
GEN_2x2andGEN_2x1have different overall speed. Let's not hide the fact under SuperSpeed Plus.
Well, the fact is that the current enum USB_SPEED_SUPER_PLUS can no longer represent just Gen2x1. If we keep this enum USB_SPEED_SUPER_PLUS in usb_device_speed, then this remains unclear, and you're hiding all the Gen XxY under the same enum.
We attempted to extend and introduce usb_ssp_rate to help get around this obscurity.
Quoted 8 lines
Quoted 4 lines
If you're planning to do it this way, why not add the other speeds (such as gen 1x2) to
usb_device_speedenum too? Then we can drop theLike I said above, if we only care about the overall speed, there is no need to tell
GEN_1x2fromGEN_2x1since both are 10Gbps. But like in dwc3 code, there are some different behaviors based on generation and lanes, so the enum still needs to be kept.
As I've mentioned, if you plan to do it this way, then introduce all the Gen XxY to usb_device_speed. Otherwise, we now duplicating what the usb_ssp_rate/gen enum was intended for.
Quoted 11 lines
Quoted 7 lines
usb_ssp_rateenum. If we're going to check multiple enum for SuperSpeed Plus, we probably need ausb_device_is_superspeed_plus()function.Now we need to audit all the greater/lesser speed checks that use < or > to make sure that they are used how they were intended to.
After going through all places where
USB_SPEED_SUPER_PLUSis used, for switch statements, I choose to add an extra case. For if statement, change "==" to ">=". But I'm not completely sure they are all correct, which need to be further checked by maintainers.
The downside to introducing these enums to usb_device_speed is that we need to audit all the drivers that checks for USB_SPEED_SUPER_PLUS.
Quoted 9 lines
Quoted 4 lines
Since these changes are not simple and will touch on multiple places, please split this patch out.
Okay, I can try to split the patch once we reach an agreement on how to handle SSP speed and generation. Besides, there is almost one file for each different module and it's not good to send one patch for each of them, right? There would be many in this way.
Why is it not good? If you separate these changes, then
* You can keep the Acks for the patches that are already reviewed
* The maintainers don't have to review the large patch over and over
* We can keep track of the small changes
* If there's an issue, we don't have to revert the entire thing
Thanks,
Thinh