Skip to contentSkip to conversation

usb: cdns3: gadget: Configure speed in udc_start

PATCH In review Ravi Gunasekaran 3 participants 5 messages Jul 19, 2023 – Jul 22, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: cdns3: gadget: Configure speed in udc_start

When one of the functions does not support super speed, the composite driver forces the gadget to high speed. But the speed is never configured in the cdns3 gadget driver. So configure the speed in cdns3_gadget_udc_start just like in the kernel.

---
 drivers/usb/cdns3/gadget.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/usb/cdns3/gadget.c +4 -0
index fcaeab9cc1..cae570cf59 100644
@@ -82,6 +82,9 @@ static int __cdns3_gadget_ep_queue(struct usb_ep *ep,
 				   struct usb_request *request,
 				   gfp_t gfp_flags);
 
+static void cdns3_gadget_udc_set_speed(struct usb_gadget *gadget,
+				       enum usb_device_speed speed);
+
 /**
  * cdns3_set_register_bit - set bit in given register.
  * @ptr: address of device controller register to be read and changed
@@ -2341,6 +2344,7 @@ static int cdns3_gadget_udc_start(struct usb_gadget *gadget,
 
 	spin_lock_irqsave(&priv_dev->lock, flags);
 	priv_dev->gadget_driver = driver;
+	cdns3_gadget_udc_set_speed(gadget, gadget->max_speed);
 	cdns3_gadget_config(priv_dev);
 	spin_unlock_irqrestore(&priv_dev->lock, flags);
 	return 0;

base-commit: 76c61f29d63163d178b1584ecc9fc2c96c538ff0

Signature · 1 line
2.17.1
#1 lore raw
Quoted 6 lines · Ravi Gunasekaran

When one of the functions does not support super speed, the composite driver forces the gadget to high speed. But the speed is never configured in the cdns3 gadget driver. So configure the speed in cdns3_gadget_udc_start just like in the kernel.

Is this a patch picked from the kernel ?
Is there a matching kernel commit ID ?

Quoted 27 lines
---
  drivers/usb/cdns3/gadget.c | 4 ++++
  1 file changed, 4 insertions(+)
drivers/usb/cdns3/gadget.c +4 -0
index fcaeab9cc1..cae570cf59 100644
@@ -82,6 +82,9 @@ static int __cdns3_gadget_ep_queue(struct usb_ep *ep,
  				   struct usb_request *request,
  				   gfp_t gfp_flags);
 
+static void cdns3_gadget_udc_set_speed(struct usb_gadget *gadget,
+				       enum usb_device_speed speed);
+
  /**
   * cdns3_set_register_bit - set bit in given register.
   * @ptr: address of device controller register to be read and changed
@@ -2341,6 +2344,7 @@ static int cdns3_gadget_udc_start(struct usb_gadget *gadget,
 
  	spin_lock_irqsave(&priv_dev->lock, flags);
  	priv_dev->gadget_driver = driver;
+	cdns3_gadget_udc_set_speed(gadget, gadget->max_speed);
  	cdns3_gadget_config(priv_dev);
  	spin_unlock_irqrestore(&priv_dev->lock, flags);
  	return 0;
Quoted 1 line

base-commit: 76c61f29d63163d178b1584ecc9fc2c96c538ff0

Where did this ^ come from ?

#2 lore raw
Quoted 10 lines · Marek Vasut
Quoted 6 lines · Ravi Gunasekaran

When one of the functions does not support super speed, the composite driver forces the gadget to high speed. But the speed is never configured in the cdns3 gadget driver. So configure the speed in cdns3_gadget_udc_start just like in the kernel.

Is this a patch picked from the kernel ?
Is there a matching kernel commit ID ?

The commit 4df50f89f5 ("usb: composite: force gadget to be USB2 for HS only function") in u-boot, forces the gadget's max speed to high speed and had a mention in the commit description that the gadget's udc_start would configure itself in USB 2.0.

I checked the cdns3 gadget driver in kernel, and the cdns3_gadget_udc_start() configures speed. So this is not a patch picked directly from the kernel. I used kernel code for reference.

Quoted 26 lines
Quoted 26 lines

---
  drivers/usb/cdns3/gadget.c | 4 ++++

  1 file changed, 4 insertions(+)
drivers/usb/cdns3/gadget.c +3 -0
index fcaeab9cc1..cae570cf59 100644
@@ -82,6 +82,9 @@ static int __cdns3_gadget_ep_queue(struct usb_ep *ep,
                      struct usb_request *request,
                      gfp_t gfp_flags);
   +static void cdns3_gadget_udc_set_speed(struct usb_gadget *gadget,
+                       enum usb_device_speed speed);
+
   /**
    * cdns3_set_register_bit - set bit in given register.
    * @ptr: address of device controller register to be read and changed
@@ -2341,6 +2344,7 @@ static int cdns3_gadget_udc_start(struct usb_gadget *gadget,
         spin_lock_irqsave(&priv_dev->lock, flags);
       priv_dev->gadget_driver = driver;
+    cdns3_gadget_udc_set_speed(gadget, gadget->max_speed);
       cdns3_gadget_config(priv_dev);
       spin_unlock_irqrestore(&priv_dev->lock, flags);
       return 0;
 
Quoted 3 lines
Quoted 1 line

base-commit: 76c61f29d63163d178b1584ecc9fc2c96c538ff0

Where did this ^ come from ?

I'm based on origin/next. Please let me know if I should base on origin/master?

Signature · 2 lines
Regards,
Ravi
Reviewed-by
#3 lore raw
Quoted 14 lines · Ravi Gunasekaran
Quoted 10 lines · Marek Vasut
Quoted 6 lines · Ravi Gunasekaran

When one of the functions does not support super speed, the composite driver forces the gadget to high speed. But the speed is never configured in the cdns3 gadget driver. So configure the speed in cdns3_gadget_udc_start just like in the kernel.

Is this a patch picked from the kernel ?
Is there a matching kernel commit ID ?

Quoted 7 lines

The commit 4df50f89f5 ("usb: composite: force gadget to be USB2 for HS only function") in u-boot, forces the gadget's max speed to high speed and had a mention in the commit description that the gadget's udc_start would configure itself in USB 2.0.

I checked the cdns3 gadget driver in kernel, and the cdns3_gadget_udc_start() configures speed. So this is not a patch picked directly from the kernel. I used kernel code for reference.

Thanks for clarification.