linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] usb: bdc: Updates and fixes to USB BDC driver
@ 2019-06-20 21:09 Al Cooper
  2019-06-20 21:09 ` [PATCH 1/6] usb: bdc: driver runs out of buffer descriptors on large ADB transfers Al Cooper
                   ` (5 more replies)
  0 siblings, 6 replies; 14+ messages in thread
From: Al Cooper @ 2019-06-20 21:09 UTC (permalink / raw)
  To: linux-kernel
  Cc: Al Cooper, devicetree, Felipe Balbi, Greg Kroah-Hartman,
	linux-usb, Luis Chamberlain, Mark Rutland, Rob Herring

This is a series of updates and fixes to the Broadcom USB BDC driver

Al Cooper (6):
  usb: bdc: driver runs out of buffer descriptors on large ADB transfers
  usb: bdc: Cleanup clock support
  usb: bdc: driver may fail to get USB PHY
  usb: bdc: Fix bug causing crash after multiple disconnects
  dt-bindings: usb: bdc: Update compatible strings
  usb: bdc: Update compatible match strings

 Documentation/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(-)

-- 
1.9.0.138.g2de3478


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1/6] usb: bdc: driver runs out of buffer descriptors on large ADB transfers
  2019-06-20 21:09 [PATCH 0/6] usb: bdc: Updates and fixes to USB BDC driver Al Cooper
@ 2019-06-20 21:09 ` Al Cooper
  2019-06-20 21:09 ` [PATCH 2/6] usb: bdc: Cleanup clock support Al Cooper
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 14+ messages in thread
From: Al Cooper @ 2019-06-20 21:09 UTC (permalink / raw)
  To: linux-kernel
  Cc: Al Cooper, devicetree, Felipe Balbi, Greg Kroah-Hartman,
	linux-usb, Luis Chamberlain, Mark Rutland, Rob Herring

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 <alcooperx@gmail.com>
---
 drivers/usb/gadget/udc/bdc/bdc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/bdc/bdc.h b/drivers/usb/gadget/udc/bdc/bdc.h
index 6e1e881dc51e..ac75e25c3b6a 100644
--- a/drivers/usb/gadget/udc/bdc/bdc.h
+++ b/drivers/usb/gadget/udc/bdc/bdc.h
@@ -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
-- 
1.9.0.138.g2de3478


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/6] usb: bdc: Cleanup clock support
  2019-06-20 21:09 [PATCH 0/6] usb: bdc: Updates and fixes to USB BDC driver Al Cooper
  2019-06-20 21:09 ` [PATCH 1/6] usb: bdc: driver runs out of buffer descriptors on large ADB transfers Al Cooper
@ 2019-06-20 21:09 ` Al Cooper
  2019-06-21  5:26   ` Chunfeng Yun
  2019-06-20 21:09 ` [PATCH 3/6] usb: bdc: driver may fail to get USB PHY Al Cooper
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Al Cooper @ 2019-06-20 21:09 UTC (permalink / raw)
  To: linux-kernel
  Cc: Al Cooper, devicetree, Felipe Balbi, Greg Kroah-Hartman,
	linux-usb, Luis Chamberlain, Mark Rutland, Rob Herring

- Fix driver to defer on clk_get defer

Signed-off-by: Al Cooper <alcooperx@gmail.com>
---
 drivers/usb/gadget/udc/bdc/bdc_core.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c
index ccbd1d34eb2a..11a43de6c1c6 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_core.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
@@ -490,8 +490,14 @@ static int bdc_probe(struct platform_device *pdev)
 
 	dev_dbg(dev, "%s()\n", __func__);
 
+	bdc = devm_kzalloc(dev, sizeof(*bdc), GFP_KERNEL);
+	if (!bdc)
+		return -ENOMEM;
+
 	clk = devm_clk_get(dev, "sw_usbd");
 	if (IS_ERR(clk)) {
+		if (PTR_ERR(clk) == -EPROBE_DEFER)
+			return -EPROBE_DEFER;
 		dev_info(dev, "Clock not found in Device Tree\n");
 		clk = NULL;
 	}
@@ -501,11 +507,6 @@ static int bdc_probe(struct platform_device *pdev)
 		dev_err(dev, "could not enable clock\n");
 		return ret;
 	}
-
-	bdc = devm_kzalloc(dev, sizeof(*bdc), GFP_KERNEL);
-	if (!bdc)
-		return -ENOMEM;
-
 	bdc->clk = clk;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -551,7 +552,7 @@ static int bdc_probe(struct platform_device *pdev)
 	ret = bdc_phy_init(bdc);
 	if (ret) {
 		dev_err(bdc->dev, "BDC phy init failure:%d\n", ret);
-		return ret;
+		goto clk_cleanup;
 	}
 
 	temp = bdc_readl(bdc->regs, BDC_BDCCAP1);
@@ -583,6 +584,8 @@ static int bdc_probe(struct platform_device *pdev)
 	bdc_hw_exit(bdc);
 phycleanup:
 	bdc_phy_exit(bdc);
+clk_cleanup:
+	clk_disable_unprepare(bdc->clk);
 	return ret;
 }
 
-- 
1.9.0.138.g2de3478


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/6] usb: bdc: driver may fail to get USB PHY
  2019-06-20 21:09 [PATCH 0/6] usb: bdc: Updates and fixes to USB BDC driver Al Cooper
  2019-06-20 21:09 ` [PATCH 1/6] usb: bdc: driver runs out of buffer descriptors on large ADB transfers Al Cooper
  2019-06-20 21:09 ` [PATCH 2/6] usb: bdc: Cleanup clock support Al Cooper
@ 2019-06-20 21:09 ` Al Cooper
  2019-06-21  5:39   ` Chunfeng Yun
  2019-06-20 21:09 ` [PATCH 4/6] usb: bdc: Fix bug causing crash after multiple disconnects Al Cooper
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Al Cooper @ 2019-06-20 21:09 UTC (permalink / raw)
  To: linux-kernel
  Cc: Al Cooper, devicetree, Felipe Balbi, Greg Kroah-Hartman,
	linux-usb, Luis Chamberlain, Mark Rutland, Rob Herring

Initialization order is important for the USB PHY and the PHY clients.
The init order is based on the build order of the drivers in the
makefiles and the PHY drivers are built early to help with
dependencies, but the new SCMI based clock subsystem has the side
effect of making some additional drivers DEFER until the clock
is ready. This is causing the USB PHY driver to defer which is causing
some PHY clients to fail when they try to get the PHY. The fix is to have
the client driver return DEFER when it's "get phy" routine returns DEFER.

Signed-off-by: Al Cooper <alcooperx@gmail.com>
---
 drivers/usb/gadget/udc/bdc/bdc_core.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c
index 11a43de6c1c6..c794890d785b 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_core.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
@@ -543,9 +543,13 @@ static int bdc_probe(struct platform_device *pdev)
 			dev, dev->of_node, phy_num);
 		if (IS_ERR(bdc->phys[phy_num])) {
 			ret = PTR_ERR(bdc->phys[phy_num]);
+			if (ret == -EPROBE_DEFER) {
+				dev_dbg(bdc->dev, "DEFER, waiting for PHY\n");
+				return ret;
+			}
 			dev_err(bdc->dev,
 				"BDC phy specified but not found:%d\n", ret);
-			return ret;
+			goto clk_cleanup;
 		}
 	}
 
-- 
1.9.0.138.g2de3478


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 4/6] usb: bdc: Fix bug causing crash after multiple disconnects
  2019-06-20 21:09 [PATCH 0/6] usb: bdc: Updates and fixes to USB BDC driver Al Cooper
                   ` (2 preceding siblings ...)
  2019-06-20 21:09 ` [PATCH 3/6] usb: bdc: driver may fail to get USB PHY Al Cooper
@ 2019-06-20 21:09 ` Al Cooper
  2019-06-20 21:09 ` [PATCH 5/6] dt-bindings: usb: bdc: Update compatible strings Al Cooper
  2019-06-20 21:09 ` [PATCH 6/6] usb: bdc: Update compatible match strings Al Cooper
  5 siblings, 0 replies; 14+ messages in thread
From: Al Cooper @ 2019-06-20 21:09 UTC (permalink / raw)
  To: linux-kernel
  Cc: Al Cooper, devicetree, Felipe Balbi, Greg Kroah-Hartman,
	linux-usb, Luis Chamberlain, Mark Rutland, Rob Herring

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: Al Cooper <alcooperx@gmail.com>
---
 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(-)

diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c
index c794890d785b..15e28790142d 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_core.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
@@ -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 */
diff --git a/drivers/usb/gadget/udc/bdc/bdc_ep.c b/drivers/usb/gadget/udc/bdc/bdc_ep.c
index a4d9b5e1e50e..3f34d10939d0 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_ep.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_ep.c
@@ -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);
-- 
1.9.0.138.g2de3478


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 5/6] dt-bindings: usb: bdc: Update compatible strings
  2019-06-20 21:09 [PATCH 0/6] usb: bdc: Updates and fixes to USB BDC driver Al Cooper
                   ` (3 preceding siblings ...)
  2019-06-20 21:09 ` [PATCH 4/6] usb: bdc: Fix bug causing crash after multiple disconnects Al Cooper
@ 2019-06-20 21:09 ` Al Cooper
  2019-07-09 20:14   ` Rob Herring
  2019-06-20 21:09 ` [PATCH 6/6] usb: bdc: Update compatible match strings Al Cooper
  5 siblings, 1 reply; 14+ messages in thread
From: Al Cooper @ 2019-06-20 21:09 UTC (permalink / raw)
  To: linux-kernel
  Cc: Al Cooper, devicetree, Felipe Balbi, Greg Kroah-Hartman,
	linux-usb, Luis Chamberlain, Mark Rutland, Rob Herring

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.

Signed-off-by: Al Cooper <alcooperx@gmail.com>
---
 Documentation/devicetree/bindings/usb/brcm,bdc.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/brcm,bdc.txt b/Documentation/devicetree/bindings/usb/brcm,bdc.txt
index 63e63af3bf59..597f3902d857 100644
--- a/Documentation/devicetree/bindings/usb/brcm,bdc.txt
+++ b/Documentation/devicetree/bindings/usb/brcm,bdc.txt
@@ -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>;
-- 
1.9.0.138.g2de3478


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 6/6] usb: bdc: Update compatible match strings
  2019-06-20 21:09 [PATCH 0/6] usb: bdc: Updates and fixes to USB BDC driver Al Cooper
                   ` (4 preceding siblings ...)
  2019-06-20 21:09 ` [PATCH 5/6] dt-bindings: usb: bdc: Update compatible strings Al Cooper
@ 2019-06-20 21:09 ` Al Cooper
  2019-06-21  8:28   ` Sergei Shtylyov
  5 siblings, 1 reply; 14+ messages in thread
From: Al Cooper @ 2019-06-20 21:09 UTC (permalink / raw)
  To: linux-kernel
  Cc: Al Cooper, devicetree, Felipe Balbi, Greg Kroah-Hartman,
	linux-usb, Luis Chamberlain, Mark Rutland, Rob Herring

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.

Signed-off-by: Al Cooper <alcooperx@gmail.com>
---
 drivers/usb/gadget/udc/bdc/bdc_core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c
index 15e28790142d..e2b2628925e6 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_core.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
@@ -644,6 +644,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-v3.1" },
 	{ .compatible = "brcm,bdc-v0.16" },
 	{ .compatible = "brcm,bdc" },
 	{ /* sentinel */ }
-- 
1.9.0.138.g2de3478


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/6] usb: bdc: Cleanup clock support
  2019-06-20 21:09 ` [PATCH 2/6] usb: bdc: Cleanup clock support Al Cooper
@ 2019-06-21  5:26   ` Chunfeng Yun
  2019-06-21 13:44     ` Alan Cooper
  0 siblings, 1 reply; 14+ messages in thread
From: Chunfeng Yun @ 2019-06-21  5:26 UTC (permalink / raw)
  To: Al Cooper
  Cc: linux-kernel, devicetree, Felipe Balbi, Greg Kroah-Hartman,
	linux-usb, Luis Chamberlain, Mark Rutland, Rob Herring

On Thu, 2019-06-20 at 17:09 -0400, Al Cooper wrote:
> - Fix driver to defer on clk_get defer
> 
> Signed-off-by: Al Cooper <alcooperx@gmail.com>
> ---
>  drivers/usb/gadget/udc/bdc/bdc_core.c | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c
> index ccbd1d34eb2a..11a43de6c1c6 100644
> --- a/drivers/usb/gadget/udc/bdc/bdc_core.c
> +++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
> @@ -490,8 +490,14 @@ static int bdc_probe(struct platform_device *pdev)
>  
>  	dev_dbg(dev, "%s()\n", __func__);
>  
> +	bdc = devm_kzalloc(dev, sizeof(*bdc), GFP_KERNEL);
> +	if (!bdc)
> +		return -ENOMEM;
> +
>  	clk = devm_clk_get(dev, "sw_usbd");
>  	if (IS_ERR(clk)) {
> +		if (PTR_ERR(clk) == -EPROBE_DEFER)
> +			return -EPROBE_DEFER;
what about using devm_clk_get_optional()?

>  		dev_info(dev, "Clock not found in Device Tree\n");
>  		clk = NULL;
>  	}
> @@ -501,11 +507,6 @@ static int bdc_probe(struct platform_device *pdev)
>  		dev_err(dev, "could not enable clock\n");
>  		return ret;
>  	}
> -
> -	bdc = devm_kzalloc(dev, sizeof(*bdc), GFP_KERNEL);
> -	if (!bdc)
> -		return -ENOMEM;
> -
>  	bdc->clk = clk;
>  
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> @@ -551,7 +552,7 @@ static int bdc_probe(struct platform_device *pdev)
>  	ret = bdc_phy_init(bdc);
>  	if (ret) {
>  		dev_err(bdc->dev, "BDC phy init failure:%d\n", ret);
> -		return ret;
> +		goto clk_cleanup;
>  	}
>  
>  	temp = bdc_readl(bdc->regs, BDC_BDCCAP1);
> @@ -583,6 +584,8 @@ static int bdc_probe(struct platform_device *pdev)
>  	bdc_hw_exit(bdc);
>  phycleanup:
>  	bdc_phy_exit(bdc);
> +clk_cleanup:
> +	clk_disable_unprepare(bdc->clk);
>  	return ret;
>  }
>  



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/6] usb: bdc: driver may fail to get USB PHY
  2019-06-20 21:09 ` [PATCH 3/6] usb: bdc: driver may fail to get USB PHY Al Cooper
@ 2019-06-21  5:39   ` Chunfeng Yun
  2019-06-21 13:39     ` Alan Cooper
  0 siblings, 1 reply; 14+ messages in thread
From: Chunfeng Yun @ 2019-06-21  5:39 UTC (permalink / raw)
  To: Al Cooper
  Cc: linux-kernel, devicetree, Felipe Balbi, Greg Kroah-Hartman,
	linux-usb, Luis Chamberlain, Mark Rutland, Rob Herring

On Thu, 2019-06-20 at 17:09 -0400, Al Cooper wrote:
> Initialization order is important for the USB PHY and the PHY clients.
> The init order is based on the build order of the drivers in the
> makefiles and the PHY drivers are built early to help with
> dependencies, but the new SCMI based clock subsystem has the side
> effect of making some additional drivers DEFER until the clock
> is ready. This is causing the USB PHY driver to defer which is causing
> some PHY clients to fail when they try to get the PHY. The fix is to have
> the client driver return DEFER when it's "get phy" routine returns DEFER.
> 
> Signed-off-by: Al Cooper <alcooperx@gmail.com>
> ---
>  drivers/usb/gadget/udc/bdc/bdc_core.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c
> index 11a43de6c1c6..c794890d785b 100644
> --- a/drivers/usb/gadget/udc/bdc/bdc_core.c
> +++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
> @@ -543,9 +543,13 @@ static int bdc_probe(struct platform_device *pdev)
>  			dev, dev->of_node, phy_num);
>  		if (IS_ERR(bdc->phys[phy_num])) {
>  			ret = PTR_ERR(bdc->phys[phy_num]);
> +			if (ret == -EPROBE_DEFER) {
> +				dev_dbg(bdc->dev, "DEFER, waiting for PHY\n");
why not disable clock here? when re-probe, will enable clock again.
to me, no need check -EPROBE_DEFFER.
> +				return ret;
> +			}

>  			dev_err(bdc->dev,
>  				"BDC phy specified but not found:%d\n", ret);
> -			return ret;
> +			goto clk_cleanup;
>  		}
>  	}
>  



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 6/6] usb: bdc: Update compatible match strings
  2019-06-20 21:09 ` [PATCH 6/6] usb: bdc: Update compatible match strings Al Cooper
@ 2019-06-21  8:28   ` Sergei Shtylyov
  2019-06-21 13:47     ` Alan Cooper
  0 siblings, 1 reply; 14+ messages in thread
From: Sergei Shtylyov @ 2019-06-21  8:28 UTC (permalink / raw)
  To: Al Cooper, linux-kernel
  Cc: devicetree, Felipe Balbi, Greg Kroah-Hartman, linux-usb,
	Luis Chamberlain, Mark Rutland, Rob Herring

Hello!

On 21.06.2019 0:09, Al Cooper wrote:

> Remove "brcm,bdc-v0.16" because it was never used on any system.

    You're not really removing it, are you?

> Add "brcm,bdc-udc-v3.1" which exists for any STB system with BDC.
> 
> Signed-off-by: Al Cooper <alcooperx@gmail.com>
> ---
>   drivers/usb/gadget/udc/bdc/bdc_core.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c
> index 15e28790142d..e2b2628925e6 100644
> --- a/drivers/usb/gadget/udc/bdc/bdc_core.c
> +++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
> @@ -644,6 +644,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-v3.1" },
>   	{ .compatible = "brcm,bdc-v0.16" },
>   	{ .compatible = "brcm,bdc" },
>   	{ /* sentinel */ }

MBR, Sergei

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/6] usb: bdc: driver may fail to get USB PHY
  2019-06-21  5:39   ` Chunfeng Yun
@ 2019-06-21 13:39     ` Alan Cooper
  0 siblings, 0 replies; 14+ messages in thread
From: Alan Cooper @ 2019-06-21 13:39 UTC (permalink / raw)
  To: Chunfeng Yun
  Cc: : Linux Kernel Mailing List, DTML, Felipe Balbi,
	Greg Kroah-Hartman, USB list, Luis Chamberlain, Mark Rutland,
	Rob Herring

It's been very useful to have the DEFER debug message so I'd like to
leave in the check for DEFER. I should not be skipping the clock
disable, so I'll "goto clk_cleanup" for both cases.

Thanks
Al

On Fri, Jun 21, 2019 at 1:39 AM Chunfeng Yun <chunfeng.yun@mediatek.com> wrote:
>
> On Thu, 2019-06-20 at 17:09 -0400, Al Cooper wrote:
> > Initialization order is important for the USB PHY and the PHY clients.
> > The init order is based on the build order of the drivers in the
> > makefiles and the PHY drivers are built early to help with
> > dependencies, but the new SCMI based clock subsystem has the side
> > effect of making some additional drivers DEFER until the clock
> > is ready. This is causing the USB PHY driver to defer which is causing
> > some PHY clients to fail when they try to get the PHY. The fix is to have
> > the client driver return DEFER when it's "get phy" routine returns DEFER.
> >
> > Signed-off-by: Al Cooper <alcooperx@gmail.com>
> > ---
> >  drivers/usb/gadget/udc/bdc/bdc_core.c | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c
> > index 11a43de6c1c6..c794890d785b 100644
> > --- a/drivers/usb/gadget/udc/bdc/bdc_core.c
> > +++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
> > @@ -543,9 +543,13 @@ static int bdc_probe(struct platform_device *pdev)
> >                       dev, dev->of_node, phy_num);
> >               if (IS_ERR(bdc->phys[phy_num])) {
> >                       ret = PTR_ERR(bdc->phys[phy_num]);
> > +                     if (ret == -EPROBE_DEFER) {
> > +                             dev_dbg(bdc->dev, "DEFER, waiting for PHY\n");
> why not disable clock here? when re-probe, will enable clock again.
> to me, no need check -EPROBE_DEFFER.
> > +                             return ret;
> > +                     }
>
> >                       dev_err(bdc->dev,
> >                               "BDC phy specified but not found:%d\n", ret);
> > -                     return ret;
> > +                     goto clk_cleanup;
> >               }
> >       }
> >
>
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/6] usb: bdc: Cleanup clock support
  2019-06-21  5:26   ` Chunfeng Yun
@ 2019-06-21 13:44     ` Alan Cooper
  0 siblings, 0 replies; 14+ messages in thread
From: Alan Cooper @ 2019-06-21 13:44 UTC (permalink / raw)
  To: Chunfeng Yun
  Cc: : Linux Kernel Mailing List, DTML, Felipe Balbi,
	Greg Kroah-Hartman, USB list, Luis Chamberlain, Mark Rutland,
	Rob Herring

> > diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c
> > index ccbd1d34eb2a..11a43de6c1c6 100644
> > --- a/drivers/usb/gadget/udc/bdc/bdc_core.c
> > +++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
> > @@ -490,8 +490,14 @@ static int bdc_probe(struct platform_device *pdev)
> >
> >       dev_dbg(dev, "%s()\n", __func__);
> >
> > +     bdc = devm_kzalloc(dev, sizeof(*bdc), GFP_KERNEL);
> > +     if (!bdc)
> > +             return -ENOMEM;
> > +
> >       clk = devm_clk_get(dev, "sw_usbd");
> >       if (IS_ERR(clk)) {
> > +             if (PTR_ERR(clk) == -EPROBE_DEFER)
> > +                     return -EPROBE_DEFER;
> what about using devm_clk_get_optional()?

Good suggestion.
Thanks
Al


On Fri, Jun 21, 2019 at 1:26 AM Chunfeng Yun <chunfeng.yun@mediatek.com> wrote:
>
> On Thu, 2019-06-20 at 17:09 -0400, Al Cooper wrote:
> > - Fix driver to defer on clk_get defer
> >
> > Signed-off-by: Al Cooper <alcooperx@gmail.com>
> > ---
> >  drivers/usb/gadget/udc/bdc/bdc_core.c | 15 +++++++++------
> >  1 file changed, 9 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c
> > index ccbd1d34eb2a..11a43de6c1c6 100644
> > --- a/drivers/usb/gadget/udc/bdc/bdc_core.c
> > +++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
> > @@ -490,8 +490,14 @@ static int bdc_probe(struct platform_device *pdev)
> >
> >       dev_dbg(dev, "%s()\n", __func__);
> >
> > +     bdc = devm_kzalloc(dev, sizeof(*bdc), GFP_KERNEL);
> > +     if (!bdc)
> > +             return -ENOMEM;
> > +
> >       clk = devm_clk_get(dev, "sw_usbd");
> >       if (IS_ERR(clk)) {
> > +             if (PTR_ERR(clk) == -EPROBE_DEFER)
> > +                     return -EPROBE_DEFER;
> what about using devm_clk_get_optional()?
>
> >               dev_info(dev, "Clock not found in Device Tree\n");
> >               clk = NULL;
> >       }
> > @@ -501,11 +507,6 @@ static int bdc_probe(struct platform_device *pdev)
> >               dev_err(dev, "could not enable clock\n");
> >               return ret;
> >       }
> > -
> > -     bdc = devm_kzalloc(dev, sizeof(*bdc), GFP_KERNEL);
> > -     if (!bdc)
> > -             return -ENOMEM;
> > -
> >       bdc->clk = clk;
> >
> >       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > @@ -551,7 +552,7 @@ static int bdc_probe(struct platform_device *pdev)
> >       ret = bdc_phy_init(bdc);
> >       if (ret) {
> >               dev_err(bdc->dev, "BDC phy init failure:%d\n", ret);
> > -             return ret;
> > +             goto clk_cleanup;
> >       }
> >
> >       temp = bdc_readl(bdc->regs, BDC_BDCCAP1);
> > @@ -583,6 +584,8 @@ static int bdc_probe(struct platform_device *pdev)
> >       bdc_hw_exit(bdc);
> >  phycleanup:
> >       bdc_phy_exit(bdc);
> > +clk_cleanup:
> > +     clk_disable_unprepare(bdc->clk);
> >       return ret;
> >  }
> >
>
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 6/6] usb: bdc: Update compatible match strings
  2019-06-21  8:28   ` Sergei Shtylyov
@ 2019-06-21 13:47     ` Alan Cooper
  0 siblings, 0 replies; 14+ messages in thread
From: Alan Cooper @ 2019-06-21 13:47 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: : Linux Kernel Mailing List, DTML, Felipe Balbi,
	Greg Kroah-Hartman, USB list, Luis Chamberlain, Mark Rutland,
	Rob Herring

> > Remove "brcm,bdc-v0.16" because it was never used on any system.
>
>     You're not really removing it, are you?

Whoops, it was supposed to be removed.
Thanks
Al

On Fri, Jun 21, 2019 at 4:28 AM Sergei Shtylyov
<sergei.shtylyov@cogentembedded.com> wrote:
>
> Hello!
>
> On 21.06.2019 0:09, Al Cooper wrote:
>
> > Remove "brcm,bdc-v0.16" because it was never used on any system.
>
>     You're not really removing it, are you?
>
> > Add "brcm,bdc-udc-v3.1" which exists for any STB system with BDC.
> >
> > Signed-off-by: Al Cooper <alcooperx@gmail.com>
> > ---
> >   drivers/usb/gadget/udc/bdc/bdc_core.c | 1 +
> >   1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c
> > index 15e28790142d..e2b2628925e6 100644
> > --- a/drivers/usb/gadget/udc/bdc/bdc_core.c
> > +++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
> > @@ -644,6 +644,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-v3.1" },
> >       { .compatible = "brcm,bdc-v0.16" },
> >       { .compatible = "brcm,bdc" },
> >       { /* sentinel */ }
>
> MBR, Sergei

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 5/6] dt-bindings: usb: bdc: Update compatible strings
  2019-06-20 21:09 ` [PATCH 5/6] dt-bindings: usb: bdc: Update compatible strings Al Cooper
@ 2019-07-09 20:14   ` Rob Herring
  0 siblings, 0 replies; 14+ messages in thread
From: Rob Herring @ 2019-07-09 20:14 UTC (permalink / raw)
  To: Al Cooper
  Cc: linux-kernel, Al Cooper, devicetree, Felipe Balbi,
	Greg Kroah-Hartman, linux-usb, Luis Chamberlain, Mark Rutland

On Thu, 20 Jun 2019 17:09:50 -0400, Al Cooper wrote:
> 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.
> 
> Signed-off-by: Al Cooper <alcooperx@gmail.com>
> ---
>  Documentation/devicetree/bindings/usb/brcm,bdc.txt | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 

Reviewed-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2019-07-09 20:14 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-20 21:09 [PATCH 0/6] usb: bdc: Updates and fixes to USB BDC driver Al Cooper
2019-06-20 21:09 ` [PATCH 1/6] usb: bdc: driver runs out of buffer descriptors on large ADB transfers Al Cooper
2019-06-20 21:09 ` [PATCH 2/6] usb: bdc: Cleanup clock support Al Cooper
2019-06-21  5:26   ` Chunfeng Yun
2019-06-21 13:44     ` Alan Cooper
2019-06-20 21:09 ` [PATCH 3/6] usb: bdc: driver may fail to get USB PHY Al Cooper
2019-06-21  5:39   ` Chunfeng Yun
2019-06-21 13:39     ` Alan Cooper
2019-06-20 21:09 ` [PATCH 4/6] usb: bdc: Fix bug causing crash after multiple disconnects Al Cooper
2019-06-20 21:09 ` [PATCH 5/6] dt-bindings: usb: bdc: Update compatible strings Al Cooper
2019-07-09 20:14   ` Rob Herring
2019-06-20 21:09 ` [PATCH 6/6] usb: bdc: Update compatible match strings Al Cooper
2019-06-21  8:28   ` Sergei Shtylyov
2019-06-21 13:47     ` Alan Cooper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).