usb: bdc: Updates and fixes to the USB BDC driver
Subsystems (3)
Al Cooper
maintainerv2 cover usb: bdc: Updates and fixes to the USB BDC driver
v2 - Fix Signed-off-by issues, remove internal bug reference.
Fix binding document to match 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 | 27 +++++++++++++------ drivers/usb/gadget/udc/bdc/bdc_ep.c | 16 ++++++----- 4 files changed, 32 insertions(+), 17 deletions(-)
Signature · 1 line
2.17.1
Al Cooper
maintainerPATCH v2 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-v2" 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-v2" "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-v2"; reg = <0xf0b02000 0xfc4>; interrupts = <0x0 0x60 0x0>; phys = <&usbphy_0 0x0>;
Signature · 1 line
2.17.1
Re: [PATCH v2 1/7] dt-bindings: usb: bdc: Update compatible strings
Quoted 4 lines · Al Cooper
Remove "brcm,bdc-v0.16" because it was never used on any system. Add "brcm,bdc-udc-v2" which exists for any STB system with BDC.
Signed-off-by Al Cooper <[email protected]>
Signature · 1 line
Florian
Al Cooper
maintainerPATCH v2 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. Remove unused compatible string "brcm,bdc-v0.16".
--- drivers/usb/gadget/udc/bdc/bdc_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/udc/bdc/bdc_core.c +1 -1
@@ -629,7 +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-v0.16" }, + { .compatible ="brcm,bdc-udc-v2" }, { .compatible ="brcm,bdc" }, {/* sentinel */ } };
Signature · 1 line
2.17.1
Re: [PATCH v2 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. Remove unused compatible string "brcm,bdc-v0.16".
Signed-off-by Al Cooper <[email protected]>
Signature · 1 line
Florian
Re: [PATCH v2 2/7] usb: bdc: Add compatible string for new style USB DT nodes
In reply to Al CooperHello!
Quoted 2 lines · Al Cooper
Add compatible string for some newer boards that only have this as there match sting. Remove unused compatible string "brcm,bdc-v0.16".
s/there/their/.
Quoted 1 line
Signed-off-by Al Cooper <[email protected]>
[...]
MBR, Sergei
Al Cooper
maintainerPATCH v2 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.
--- 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 v2 3/7] bdc: Fix bug causing crash after multiple disconnects
Quoted 11 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.
Signed-off-by Sasi Kumar <[email protected]>Signed-off-by Al Cooper <[email protected]>
Signature · 1 line
Florian
Al Cooper
maintainerPATCH v2 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
Re: [PATCH v2 4/7] usb: bdc: Adb shows offline after resuming from S2
Quoted 7 lines · Al Cooper
On 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.
Quoted 6 lines
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.
Signed-off-by Al Cooper <[email protected]>
Signature · 1 line
Florian
Al Cooper
maintainerPATCH v2 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 v2 5/7] usb: bdc: driver runs out of buffer descriptors on large ADB transfers
Quoted 9 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]>
Signature · 1 line
Florian
Al Cooper
maintainerPATCH v2 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
Re: [PATCH v2 6/7] usb: bdc: Halt controller on suspend
Quoted 7 lines · Al Cooper
From: 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.
Quoted 6 lines
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.
Signed-off-by Danesh Petigara <[email protected]>Signed-off-by Al Cooper <[email protected]>
Signature · 1 line
Florian
Al Cooper
maintainerPATCH v2 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