Skip to contentSkip to conversation

usb: cdns3: gadget: Don't manage pullups

PATCH In review Roger Quadros 5 participants 9 messages Oct 23, 2019 – Oct 30, 2019

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

PATCH 1/1 usb: cdns3: gadget: Don't manage pullups

The USB gadget core is supposed to manage pullups of the controller. Don't manage pullups from within the controller driver. Otherwise, function drivers are not able to keep the controller disconnected from the bus till they are ready. (e.g. g_webcam)

---
Hi Greg/Felipe,

This can be used for -rc as it is a bug fix.

cheers,
-roger

 drivers/usb/cdns3/gadget.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/usb/cdns3/gadget.c +0 -4
index 2ca280f4c054..714382d96055 100644
@@ -2324,8 +2324,6 @@ static void cdns3_gadget_config(struct cdns3_device *priv_dev)
 	writel(USB_CONF_CLK2OFFDS | USB_CONF_L1DS, &regs->usb_conf);
 
 	cdns3_configure_dmult(priv_dev, NULL);
-
-	cdns3_gadget_pullup(&priv_dev->gadget, 1);
 }
 
 /**
@@ -2708,8 +2706,6 @@ static int cdns3_gadget_suspend(struct cdns3 *cdns, bool do_wakeup)
 	/* disable interrupt for device */
 	writel(0, &priv_dev->regs->usb_ien);
 
-	cdns3_gadget_pullup(&priv_dev->gadget, 0);
-
 	return 0;
 }
 
Signature · 2 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
maintainer Reviewed-by on v1 1/1
#1 lore raw

Hi,

Regards,
Pawel,

Quoted 43 lines

The USB gadget core is supposed to manage pullups of the controller. Don't manage pullups from within the controller driver. Otherwise, function drivers are not able to keep the controller disconnected from the bus till they are ready. (e.g. g_webcam)

---
Hi Greg/Felipe,

This can be used for -rc as it is a bug fix.

cheers,
-roger

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

1 file changed, 4 deletions(-)
drivers/usb/cdns3/gadget.c +0 -5
index 2ca280f4c054..714382d96055 100644
@@ -2324,8 +2324,6 @@ static void cdns3_gadget_config(struct cdns3_device *priv_dev)
 	writel(USB_CONF_CLK2OFFDS | USB_CONF_L1DS, &regs->usb_conf);
 
 	cdns3_configure_dmult(priv_dev, NULL);
-
-	cdns3_gadget_pullup(&priv_dev->gadget, 1);
 }
 
 /**
@@ -2708,8 +2706,6 @@ static int cdns3_gadget_suspend(struct cdns3 *cdns, bool do_wakeup)
 	/* disable interrupt for device */
 	writel(0, &priv_dev->regs->usb_ien);
 
-	cdns3_gadget_pullup(&priv_dev->gadget, 0);
-
 	return 0;
 }
 
--

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

#2 lore raw
Quoted 3 lines · Pawel Laszczak

Hi,

Hi Roger & Pawel,

Assume gadget function has already enabled, if you switch host mode to device mode, with your changes, where the device mode will be enabled again?

Peter

Quoted 48 lines

Regards,
Pawel,

Quoted 43 lines

The USB gadget core is supposed to manage pullups of the controller. Don't manage pullups from within the controller driver. Otherwise, function drivers are not able to keep the controller disconnected from the bus till they are ready. (e.g. g_webcam)

---
Hi Greg/Felipe,

This can be used for -rc as it is a bug fix.

cheers,
-roger

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

1 file changed, 4 deletions(-)
drivers/usb/cdns3/gadget.c +0 -5
index 2ca280f4c054..714382d96055 100644
@@ -2324,8 +2324,6 @@ static void cdns3_gadget_config(struct cdns3_device *priv_dev)
 	writel(USB_CONF_CLK2OFFDS | USB_CONF_L1DS, &regs->usb_conf);
 
 	cdns3_configure_dmult(priv_dev, NULL);
-
-	cdns3_gadget_pullup(&priv_dev->gadget, 1);
 }
 
 /**
@@ -2708,8 +2706,6 @@ static int cdns3_gadget_suspend(struct cdns3 *cdns, bool do_wakeup)
 	/* disable interrupt for device */
 	writel(0, &priv_dev->regs->usb_ien);
 
-	cdns3_gadget_pullup(&priv_dev->gadget, 0);
-
 	return 0;
 }
 
--

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

Signature · 2 lines
Thanks,
Peter Chen
#3 lore raw

Peter,

Quoted 10 lines · Peter Chen
Quoted 3 lines · Pawel Laszczak

Hi,

Hi Roger & Pawel,

Assume gadget function has already enabled, if you switch host mode to device mode, with your changes, where the device mode will be enabled again?

When it switches from device mode to host the UDC is removed. When we switch back from host to device mode the UDC is added, so,

usb_add_gadget_udc_release()-> check_pending_gadget_drivers()-> udc_bind_to_driver()->usb_udc_connect_control()->usb_gadget_connect()-> gadget->ops->pullup()

cheers,
-roger

Quoted 51 lines

Peter

Quoted 48 lines

Regards,
Pawel,

Quoted 43 lines

The USB gadget core is supposed to manage pullups of the controller. Don't manage pullups from within the controller driver. Otherwise, function drivers are not able to keep the controller disconnected from the bus till they are ready. (e.g. g_webcam)

---
Hi Greg/Felipe,

This can be used for -rc as it is a bug fix.

cheers,
-roger

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

1 file changed, 4 deletions(-)
drivers/usb/cdns3/gadget.c +0 -5
index 2ca280f4c054..714382d96055 100644
@@ -2324,8 +2324,6 @@ static void cdns3_gadget_config(struct cdns3_device *priv_dev)
 	writel(USB_CONF_CLK2OFFDS | USB_CONF_L1DS, &regs->usb_conf);
 
 	cdns3_configure_dmult(priv_dev, NULL);
-
-	cdns3_gadget_pullup(&priv_dev->gadget, 1);
 }
 
 /**
@@ -2708,8 +2706,6 @@ static int cdns3_gadget_suspend(struct cdns3 *cdns, bool do_wakeup)
 	/* disable interrupt for device */
 	writel(0, &priv_dev->regs->usb_ien);
 
-	cdns3_gadget_pullup(&priv_dev->gadget, 0);
-
 	return 0;
 }
 
--

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

Signature · 2 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
#4 lore raw

Hi,

Quoted 12 lines · Roger Quadros
Quoted 10 lines · Peter Chen
Quoted 3 lines · Pawel Laszczak

Hi,

Hi Roger & Pawel,

Assume gadget function has already enabled, if you switch host mode to device mode, with your changes, where the device mode will be enabled again?

Quoted 6 lines

When it switches from device mode to host the UDC is removed. When we switch back from host to device mode the UDC is added, so,

usb_add_gadget_udc_release()-> check_pending_gadget_drivers()-> udc_bind_to_driver()->usb_udc_connect_control()->usb_gadget_connect()-> gadget->ops->pullup()

I agree with Roger here. UDC shouldn't try to manage pullups directly. If there are any bugs related to role switch, we should fix it in udc core, so the fix applies to everyone ;-)

Signature · 1 line
balbi
#5 lore raw
In reply to Roger Quadros
Quoted 14 lines · Roger Quadros

Peter,

Quoted 10 lines · Peter Chen
Quoted 3 lines · Pawel Laszczak

Hi,

Hi Roger & Pawel,

Assume gadget function has already enabled, if you switch host mode to device mode, with your changes, where the device mode will be enabled again?

Quoted 6 lines

When it switches from device mode to host the UDC is removed. When we switch back from host to device mode the UDC is added, so,

usb_add_gadget_udc_release()-> check_pending_gadget_drivers()-> udc_bind_to_driver()->usb_udc_connect_control()->usb_gadget_connect()-> gadget->ops->pullup()

Thanks. I have another question how you decide when to store UDC name to /sys/kernel/config/usb_gadget/g1/UDC? Do you have a user daemon program to monitor VBUS or external connector? At host mode, the store operation will fail due to there is NO UDC.

Signature · 2 lines
Thanks,
Peter Chen
#6 lore raw
Quoted 18 lines · Peter Chen
Quoted 17 lines · Roger Quadros

Peter,

Quoted 10 lines · Peter Chen
Quoted 3 lines · Pawel Laszczak

Hi,

Hi Roger & Pawel,

Assume gadget function has already enabled, if you switch host mode to device mode, with your changes, where the device mode will be enabled again?

When it switches from device mode to host the UDC is removed. When we switch back from host to device mode the UDC is added, so,

Quoted 9 lines
Quoted 3 lines

usb_add_gadget_udc_release()-> check_pending_gadget_drivers()-> udc_bind_to_driver()->usb_udc_connect_control()->usb_gadget_connect()-> gadget->ops->pullup()

Thanks. I have another question how you decide when to store UDC name to /sys/kernel/config/usb_gadget/g1/UDC? Do you have a user daemon program to monitor VBUS or external connector? At host mode, the store operation will fail due to there is NO UDC.

Yes, user space needs to monitor /sys/class/usb_role/6000000.usb-role-switch/role

When it becomes "device" the UDC is available and it can prepare to configure the UDC.

Could you please give your Ack for this patch if it is OK? Thanks.

cheers,
-roger

Signature · 2 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
#7 lore raw

Hi,

Quoted 29 lines · Roger Quadros
Quoted 18 lines · Peter Chen
Quoted 17 lines · Roger Quadros

Peter,

Quoted 10 lines · Peter Chen
Quoted 3 lines · Pawel Laszczak

Hi,

Hi Roger & Pawel,

Assume gadget function has already enabled, if you switch host mode to device mode, with your changes, where the device mode will be enabled again?

When it switches from device mode to host the UDC is removed. When we switch back from host to device mode the UDC is added, so,

Quoted 9 lines
Quoted 3 lines

usb_add_gadget_udc_release()-> check_pending_gadget_drivers()-> udc_bind_to_driver()->usb_udc_connect_control()->usb_gadget_connect()-> gadget->ops->pullup()

Thanks. I have another question how you decide when to store UDC name to /sys/kernel/config/usb_gadget/g1/UDC? Do you have a user daemon program to monitor VBUS or external connector? At host mode, the store operation will fail due to there is NO UDC.

Quoted 6 lines

Yes, user space needs to monitor /sys/class/usb_role/6000000.usb-role-switch/role

When it becomes "device" the UDC is available and it can prepare to configure the UDC.

Could you please give your Ack for this patch if it is OK? Thanks.

this is already in its way to Linus' tree:

https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/commit/?h=usb-linus&id=f3fb802efaef3662744a2215a51294d52a7cfc0e

Signature · 1 line
balbi
Acked-by
#8 lore raw
In reply to Roger Quadros
Quoted 31 lines · Roger Quadros
Quoted 18 lines · Peter Chen
Quoted 17 lines · Roger Quadros

Peter,

Quoted 10 lines · Peter Chen
Quoted 3 lines · Pawel Laszczak

Hi,

Hi Roger & Pawel,

Assume gadget function has already enabled, if you switch host mode to device mode, with your changes, where the device mode will be enabled again?

When it switches from device mode to host the UDC is removed. When we switch back from host to device mode the UDC is added, so,

Quoted 9 lines
Quoted 3 lines

usb_add_gadget_udc_release()-> check_pending_gadget_drivers()-> udc_bind_to_driver()->usb_udc_connect_control()->usb_gadget_connect()-> gadget->ops->pullup()

Thanks. I have another question how you decide when to store UDC name to /sys/kernel/config/usb_gadget/g1/UDC? Do you have a user daemon program to monitor VBUS or external connector? At host mode, the store operation will fail due to there is NO UDC.

Quoted 7 lines

Yes, user space needs to monitor /sys/class/usb_role/6000000.usb-role-switch/role

When it becomes "device" the UDC is available and it can prepare to configure the UDC.

Could you please give your Ack for this patch if it is OK? Thanks.

Signature · 2 lines
Thanks,
Peter Chen