usb: bdc: Updates and fixes to the USB BDC driver
Subsystems (3)
Al Cooper
maintainercover usb: bdc: Updates and fixes to the USB BDC driver
Updates and fixes to the Broadcom USB BDC driver.
Al Cooper (4):
dt-bindings: usb: bdc: Update compatible strings
usb: bdc: Add compatible string for new style USB DT nodes
usb: bdc: Adb shows offline after resuming from S2
usb: bdc: driver runs out of buffer descriptors on large ADB transfers
Danesh Petigara (1):
usb: bdc: Halt controller on suspend
Florian Fainelli (1):
usb: bdc: Use devm_clk_get_optional()
Sasi Kumar (1):
bdc: Fix bug causing crash after multiple disconnects
.../devicetree/bindings/usb/brcm,bdc.txt | 4 +-- drivers/usb/gadget/udc/bdc/bdc.h | 2 +- drivers/usb/gadget/udc/bdc/bdc_core.c | 26 ++++++++++++++----- drivers/usb/gadget/udc/bdc/bdc_ep.c | 16 +++++++----- 4 files changed, 32 insertions(+), 16 deletions(-)
Signature · 1 line
2.17.1
Al Cooper
maintainerPATCH 1/7 dt-bindings: usb: bdc: Update compatible strings
Remove "brcm,bdc-v0.16" because it was never used on any system. Add "brcm,bdc-udc-v3.1" which exists for any STB system with BDC.
--- Documentation/devicetree/bindings/usb/brcm,bdc.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/usb/brcm,bdc.txt +2 -2
@@ -4,7 +4,7 @@ Broadcom USB Device Controller (BDC) Required properties: - compatible: must be one of: - "brcm,bdc-v0.16" + "brcm,bdc-udc-v3.1" "brcm,bdc" - reg: the base register address and length - interrupts: the interrupt line for this controller
@@ -21,7 +21,7 @@ On Broadcom STB platforms, these properties are required: Example: bdc@f0b02000 { - compatible = "brcm,bdc-v0.16"; + compatible = "brcm,bdc-udc-v3.1"; reg = <0xf0b02000 0xfc4>; interrupts = <0x0 0x60 0x0>; phys = <&usbphy_0 0x0>;
Signature · 1 line
2.17.1
Al Cooper
maintainerPATCH 2/7 usb: bdc: Add compatible string for new style USB DT nodes
In reply to Al CooperAdd compatible string for some newer boards that only have this as there match sting.
--- drivers/usb/gadget/udc/bdc/bdc_core.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/gadget/udc/bdc/bdc_core.c +1 -0
@@ -629,6 +629,7 @@ static SIMPLE_DEV_PM_OPS(bdc_pm_ops, bdc_suspend, bdc_resume);static const struct of_device_id bdc_of_match[] = { + { .compatible ="brcm,bdc-udc-v2" }, { .compatible ="brcm,bdc-v0.16" }, { .compatible ="brcm,bdc" }, {/* sentinel */ }
Signature · 1 line
2.17.1
Re: [PATCH 2/7] usb: bdc: Add compatible string for new style USB DT nodes
Quoted 4 lines · Al Cooper
Add compatible string for some newer boards that only have this as there match sting.
Signed-off-by Al Cooper <[email protected]>
This looks good to me, however you should also include it in the binding document.
Signature · 1 line
Florian
Al Cooper
maintainerPATCH 3/7 bdc: Fix bug causing crash after multiple disconnects
In reply to Al CooperFrom: Sasi Kumar <[email protected]>
Multiple connects/disconnects can cause a crash on the second disconnect. The driver had a problem where it would try to send endpoint commands after it was disconnected which is not allowed by the hardware. The fix is to only allow the endpoint commands when the endpoint is connected. This will also fix issues that showed up when using configfs to create gadgets.
refs #SWLINUX-5477
--- drivers/usb/gadget/udc/bdc/bdc_core.c | 4 ++++ drivers/usb/gadget/udc/bdc/bdc_ep.c | 16 ++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-)
drivers/usb/gadget/udc/bdc/bdc_core.c +4 -0
@@ -282,6 +282,7 @@ static void bdc_mem_init(struct bdc *bdc, bool reinit)* in that case reinit is passed as 1 */ if (reinit) { +int i;/* Enable interrupts */ temp =bdc_readl (bdc->regs,BDC_BDCSC ); temp |=BDC_GIE ;
@@ -291,6 +292,9 @@ static void bdc_mem_init(struct bdc *bdc, bool reinit)/* Initialize SRR to 0 */ memset (bdc->srr.sr_bds,0 ,NUM_SR_ENTRIES *sizeof (struct bdc_bd )); +/* clear ep flags to avoid post disconnect stops/deconfigs */ +for (i =1 ; i < bdc->num_eps; ++i) + bdc->bdc_ep_array[i]->flags =0 ; }else {/* One time initiaization only */ /* Enable status report function pointers */
drivers/usb/gadget/udc/bdc/bdc_ep.c +10 -6
@@ -615,7 +615,6 @@ int bdc_ep_enable(struct bdc_ep *ep) }bdc_dbg_bd_list (bdc, ep);/* only for ep0: config ep is called for ep0 from connect event */ - ep->flags |=BDC_EP_ENABLED ;if (ep->ep_num ==1 )return ret;
@@ -759,10 +758,13 @@ static int ep_dequeue(struct bdc_ep *ep, struct bdc_req *req) __func__, ep->name, start_bdi, end_bdi);dev_dbg (bdc->dev,"ep_dequeue ep=%p ep->desc=%p\n" , ep, (void *)ep->usb_ep.desc); -/* Stop the ep to see where the HW is ? */ - ret =bdc_stop_ep (bdc, ep->ep_num); -/* if there is an issue with stopping ep, then no need to go further */ -if (ret) +/* if still connected, stop the ep to see where the HW is ? */ +if (!(bdc_readl (bdc->regs,BDC_USPC ) &BDC_PST_MASK )) { + ret =bdc_stop_ep (bdc, ep->ep_num); +/* if there is an issue, then no need to go further */ +if (ret) +return 0 ; + }else return 0 ;/*
@@ -1911,7 +1913,9 @@ static int bdc_gadget_ep_disable(struct usb_ep *_ep) __func__, ep->name, ep->flags);if (!(ep->flags &BDC_EP_ENABLED )) { -dev_warn (bdc->dev,"%s is already disabled\n" , ep->name); +if (bdc->gadget.speed !=USB_SPEED_UNKNOWN ) +dev_warn (bdc->dev,"%s is already disabled\n" , + ep->name);return 0 ; }spin_lock_irqsave (&bdc->lock, flags);
Signature · 1 line
2.17.1
Re: [PATCH 3/7] bdc: Fix bug causing crash after multiple disconnects
Quoted 10 lines · Al Cooper
From: Sasi Kumar <[email protected]>
Multiple connects/disconnects can cause a crash on the second disconnect. The driver had a problem where it would try to send endpoint commands after it was disconnected which is not allowed by the hardware. The fix is to only allow the endpoint commands when the endpoint is connected. This will also fix issues that showed up when using configfs to create gadgets.
refs #SWLINUX-5477
This internal reference should be removed and maybe we should be providing a Fixes tag as well since this is a bug fix?
Signature · 1 line
Florian
Al Cooper
maintainerPATCH 4/7 usb: bdc: Adb shows offline after resuming from S2
In reply to Al CooperOn Android systems, After temporarily putting device to S2 by short pressing the power button on the remote, the display turns off. Then press the power button to turn the display back up. Adb devices would show the devices is offline. It needs a physical disconnect of the usb cable or power cycle to bring the device back online. The device is operational otherwise.
The problem is that during S2 resume, the ADB gadget driver could not link back with the BDC driver because the endpoint flags were cleared. The fix is to clear the endpoint flags for the disconnect case only and not for S2 exit.
--- drivers/usb/gadget/udc/bdc/bdc_core.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/usb/gadget/udc/bdc/bdc_core.c +7 -3
@@ -292,9 +292,13 @@ static void bdc_mem_init(struct bdc *bdc, bool reinit)/* Initialize SRR to 0 */ memset (bdc->srr.sr_bds,0 ,NUM_SR_ENTRIES *sizeof (struct bdc_bd )); -/* clear ep flags to avoid post disconnect stops/deconfigs */ -for (i =1 ; i < bdc->num_eps; ++i) - bdc->bdc_ep_array[i]->flags =0 ; +/* +* clear ep flags to avoid post disconnect stops/deconfigs but +* not during S2 exit +*/ +if (!bdc->gadget.speed) +for (i =1 ; i < bdc->num_eps; ++i) + bdc->bdc_ep_array[i]->flags =0 ; }else {/* One time initiaization only */ /* Enable status report function pointers */
Signature · 1 line
2.17.1
Al Cooper
maintainerPATCH 5/7 usb: bdc: driver runs out of buffer descriptors on large ADB transfers
In reply to Al CooperVersion v1.0.40 of the Android host ADB software increased maximum transfer sizes from 256K to 1M. Since the STB ADB gadget driver requests only 16K at a time, the BDC driver ran out of buffer descriptors (BDs) if the queuing happens faster than the incoming 16K transfers. This issue is fixed by doubling the number of BDs that can be queued so that the entire 1M request can be queued without running out of buffers.
--- drivers/usb/gadget/udc/bdc/bdc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/udc/bdc/bdc.h +1 -1
@@ -44,7 +44,7 @@#define NUM_SR_ENTRIES 64/* Num of bds per table */ -#define NUM_BDS_PER_TABLE 32 +#define NUM_BDS_PER_TABLE 64/* Num of tables in bd list for control,bulk and Int ep */ #define NUM_TABLES 2
Signature · 1 line
2.17.1
Re: [PATCH 5/7] usb: bdc: driver runs out of buffer descriptors on large ADB transfers
Quoted 10 lines · Al Cooper
Version v1.0.40 of the Android host ADB software increased maximum transfer sizes from 256K to 1M. Since the STB ADB gadget driver requests only 16K at a time, the BDC driver ran out of buffer descriptors (BDs) if the queuing happens faster than the incoming 16K transfers. This issue is fixed by doubling the number of BDs that can be queued so that the entire 1M request can be queued without running out of buffers.
Signed-off-by Al Cooper <[email protected]>Signed-off-by Florian Fainelli <[email protected]>
You can certainly remove my SoB here, since you are carrying your own patch, thanks!
Signature · 1 line
Florian
Al Cooper
maintainerPATCH 6/7 usb: bdc: Halt controller on suspend
In reply to Al CooperFrom: Danesh Petigara <[email protected]>
GISB bus error kernel panics have been observed during S2 transition tests on the 7271t platform. The errors are a result of the BDC interrupt handler trying to access BDC register space after the system's suspend callbacks have completed.
Adding a suspend hook to the BDC driver that halts the controller before S2 entry thus preventing unwanted access to the BDC register space during this transition.
--- drivers/usb/gadget/udc/bdc/bdc_core.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/usb/gadget/udc/bdc/bdc_core.c +7 -2
@@ -607,9 +607,14 @@ static int bdc_remove(struct platform_device *pdev)static int bdc_suspend (struct device *dev) {struct bdc *bdc =dev_get_drvdata (dev); +int ret; -clk_disable_unprepare (bdc->clk); -return 0 ; +/* Halt the controller */ + ret =bdc_stop (bdc); +if (!ret) +clk_disable_unprepare (bdc->clk); + +return ret; }static int bdc_resume (struct device *dev)
Signature · 1 line
2.17.1
Al Cooper
maintainerPATCH 7/7 usb: bdc: Use devm_clk_get_optional()
In reply to Al CooperFrom: Florian Fainelli <[email protected]>
The BDC clock is optional and we may get an -EPROBE_DEFER error code which would not be propagated correctly, fix this by using devm_clk_get_optional().
--- drivers/usb/gadget/udc/bdc/bdc_core.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/usb/gadget/udc/bdc/bdc_core.c +3 -5
@@ -497,11 +497,9 @@ static int bdc_probe(struct platform_device *pdev)dev_dbg (dev,"%s()\n" , __func__); - clk =devm_clk_get (dev,"sw_usbd" ); -if (IS_ERR (clk)) { -dev_info (dev,"Clock not found in Device Tree\n" ); - clk =NULL ; - } + clk =devm_clk_get_optional (dev,"sw_usbd" ); +if (IS_ERR (clk)) +return PTR_ERR (clk); ret =clk_prepare_enable (clk);if (ret) {
Signature · 1 line
2.17.1
Re: [PATCH 7/7] usb: bdc: Use devm_clk_get_optional()
Quoted 7 lines · Al Cooper
From: Florian Fainelli <[email protected]>
The BDC clock is optional and we may get an -EPROBE_DEFER error code which would not be propagated correctly, fix this by using
devm_clk_get_optional().Signed-off-by Florian Fainelli <[email protected]>
Since you are carrying this patch on my behalf your Signed-off-by should also be present, if you don't mind, I would like my gmail.com address to be used here for consistency with all submissions done throughout my tenure at broadcom, thanks!
Signature · 1 line
Florian
Hi,
Quoted 8 lines · Al Cooper
Updates and fixes to the Broadcom USB BDC driver.
Al Cooper (4):
dt-bindings: usb: bdc: Update compatible strings
usb: bdc: Add compatible string for new style USB DT nodes
usb: bdc: Adb shows offline after resuming from S2
usb: bdc: driver runs out of buffer descriptors on large ADB transfers
Quoted 8 lines
Danesh Petigara (1):
usb: bdc: Halt controller on suspendFlorian Fainelli (1):
usb: bdc: Usedevm_clk_get_optional()Sasi Kumar (1):
bdc: Fix bug causing crash after multiple disconnects
What should we do here? There are few comments which seem unresolved. Are we getting a new version?
Signature · 1 line
balbi
Alan Cooper
maintainerQuoted 16 lines · Felipe Balbi
Hi,
Quoted 11 lines · Al Cooper
Updates and fixes to the Broadcom USB BDC driver.
Al Cooper (4):
dt-bindings: usb: bdc: Update compatible strings
usb: bdc: Add compatible string for new style USB DT nodes
usb: bdc: Adb shows offline after resuming from S2
usb: bdc: driver runs out of buffer descriptors on large ADB transfersDanesh Petigara (1):
usb: bdc: Halt controller on suspend
Quoted 8 lines
Quoted 5 lines
Florian Fainelli (1):
usb: bdc: Usedevm_clk_get_optional()Sasi Kumar (1):
bdc: Fix bug causing crash after multiple disconnectsWhat should we do here? There are few comments which seem unresolved. Are we getting a new version?
I'm resolving the comments and submitting v2 today.
Thanks
Al
Quoted 3 lines
--
balbi