All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/6] usb: gadget: udc: renesas_usb3: fix some major issues
@ 2018-04-10  5:38 Yoshihiro Shimoda
  2018-04-10  5:38   ` [v2,1/6] " Yoshihiro Shimoda
                   ` (6 more replies)
  0 siblings, 7 replies; 26+ messages in thread
From: Yoshihiro Shimoda @ 2018-04-10  5:38 UTC (permalink / raw)
  To: balbi; +Cc: gregkh, linux-usb, linux-renesas-soc, stable, Yoshihiro Shimoda

This patch set is based on v4.16.

Changes from v1:
 - Add Reviewed-by in patch 1, 2, 3 and 4.
 - Revise typo in patch 4.
 - Add new patches as patch 5 and 6.

Yoshihiro Shimoda (6):
  usb: gadget: udc: renesas_usb3: fix double phy_put()
  usb: gadget: udc: renesas_usb3: should remove debugfs
  usb: gadget: udc: renesas_usb3: should call pm_runtime_enable() before
    add udc
  usb: gadget: udc: renesas_usb3: should call devm_phy_get() before add
    udc
  usb: gadget: udc: renesas_usb3: should fail if devm_phy_get() returns
    error
  usb: gadget: udc: renesas_usb3: disable the controller's irqs for
    reconnecting

 drivers/usb/gadget/udc/renesas_usb3.c | 37 +++++++++++++++++++++++------------
 1 file changed, 25 insertions(+), 12 deletions(-)

-- 
1.9.1

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

* [PATCH v2 1/6] usb: gadget: udc: renesas_usb3: fix double phy_put()
@ 2018-04-10  5:38   ` Yoshihiro Shimoda
  0 siblings, 0 replies; 26+ messages in thread
From: Yoshihiro Shimoda @ 2018-04-10  5:38 UTC (permalink / raw)
  To: balbi; +Cc: gregkh, linux-usb, linux-renesas-soc, stable, Yoshihiro Shimoda

This patch fixes an issue that this driver cause double phy_put()
calling. This driver must not call phy_put() in the remove because
the driver calls devm_phy_get() in the probe.

Fixes: 279d4bc64060 ("usb: gadget: udc: renesas_usb3: add support for generic phy")
Cc: <stable@vger.kernel.org> # v4.15+
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
---
Changes from v1:
 - Add Reviewed-by.

 drivers/usb/gadget/udc/renesas_usb3.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
index 409cde4..78a12a5 100644
--- a/drivers/usb/gadget/udc/renesas_usb3.c
+++ b/drivers/usb/gadget/udc/renesas_usb3.c
@@ -2408,8 +2408,6 @@ static int renesas_usb3_remove(struct platform_device *pdev)
 	renesas_usb3_dma_free_prd(usb3, &pdev->dev);
 
 	__renesas_usb3_ep_free_request(usb3->ep0_req);
-	if (usb3->phy)
-		phy_put(usb3->phy);
 	pm_runtime_disable(&pdev->dev);
 
 	return 0;
-- 
1.9.1

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

* [v2,1/6] usb: gadget: udc: renesas_usb3: fix double phy_put()
@ 2018-04-10  5:38   ` Yoshihiro Shimoda
  0 siblings, 0 replies; 26+ messages in thread
From: Yoshihiro Shimoda @ 2018-04-10  5:38 UTC (permalink / raw)
  To: balbi; +Cc: gregkh, linux-usb, linux-renesas-soc, stable, Yoshihiro Shimoda

This patch fixes an issue that this driver cause double phy_put()
calling. This driver must not call phy_put() in the remove because
the driver calls devm_phy_get() in the probe.

Fixes: 279d4bc64060 ("usb: gadget: udc: renesas_usb3: add support for generic phy")
Cc: <stable@vger.kernel.org> # v4.15+
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
---
Changes from v1:
 - Add Reviewed-by.

 drivers/usb/gadget/udc/renesas_usb3.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
index 409cde4..78a12a5 100644
--- a/drivers/usb/gadget/udc/renesas_usb3.c
+++ b/drivers/usb/gadget/udc/renesas_usb3.c
@@ -2408,8 +2408,6 @@ static int renesas_usb3_remove(struct platform_device *pdev)
 	renesas_usb3_dma_free_prd(usb3, &pdev->dev);
 
 	__renesas_usb3_ep_free_request(usb3->ep0_req);
-	if (usb3->phy)
-		phy_put(usb3->phy);
 	pm_runtime_disable(&pdev->dev);
 
 	return 0;

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

* [PATCH v2 2/6] usb: gadget: udc: renesas_usb3: should remove debugfs
@ 2018-04-10  5:38   ` Yoshihiro Shimoda
  0 siblings, 0 replies; 26+ messages in thread
From: Yoshihiro Shimoda @ 2018-04-10  5:38 UTC (permalink / raw)
  To: balbi; +Cc: gregkh, linux-usb, linux-renesas-soc, stable, Yoshihiro Shimoda

This patch fixes an issue that this driver doesn't remove its debugfs.

Fixes: 43ba968b00ea ("usb: gadget: udc: renesas_usb3: add debugfs to set the b-device mode")
Cc: <stable@vger.kernel.org> # v4.14+
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
---
Changes from v1:
 - Add Reviewed-by.

 drivers/usb/gadget/udc/renesas_usb3.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
index 78a12a5..1c54a77 100644
--- a/drivers/usb/gadget/udc/renesas_usb3.c
+++ b/drivers/usb/gadget/udc/renesas_usb3.c
@@ -333,6 +333,7 @@ struct renesas_usb3 {
 	struct extcon_dev *extcon;
 	struct work_struct extcon_work;
 	struct phy *phy;
+	struct dentry *dentry;
 
 	struct renesas_usb3_ep *usb3_ep;
 	int num_usb3_eps;
@@ -2393,8 +2394,12 @@ static void renesas_usb3_debugfs_init(struct renesas_usb3 *usb3,
 
 	file = debugfs_create_file("b_device", 0644, root, usb3,
 				   &renesas_usb3_b_device_fops);
-	if (!file)
+	if (!file) {
 		dev_info(dev, "%s: Can't create debugfs mode\n", __func__);
+		debugfs_remove_recursive(root);
+	} else {
+		usb3->dentry = root;
+	}
 }
 
 /*------- platform_driver ------------------------------------------------*/
@@ -2402,6 +2407,7 @@ static int renesas_usb3_remove(struct platform_device *pdev)
 {
 	struct renesas_usb3 *usb3 = platform_get_drvdata(pdev);
 
+	debugfs_remove_recursive(usb3->dentry);
 	device_remove_file(&pdev->dev, &dev_attr_role);
 
 	usb_del_gadget_udc(&usb3->gadget);
-- 
1.9.1

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

* [v2,2/6] usb: gadget: udc: renesas_usb3: should remove debugfs
@ 2018-04-10  5:38   ` Yoshihiro Shimoda
  0 siblings, 0 replies; 26+ messages in thread
From: Yoshihiro Shimoda @ 2018-04-10  5:38 UTC (permalink / raw)
  To: balbi; +Cc: gregkh, linux-usb, linux-renesas-soc, stable, Yoshihiro Shimoda

This patch fixes an issue that this driver doesn't remove its debugfs.

Fixes: 43ba968b00ea ("usb: gadget: udc: renesas_usb3: add debugfs to set the b-device mode")
Cc: <stable@vger.kernel.org> # v4.14+
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
---
Changes from v1:
 - Add Reviewed-by.

 drivers/usb/gadget/udc/renesas_usb3.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
index 78a12a5..1c54a77 100644
--- a/drivers/usb/gadget/udc/renesas_usb3.c
+++ b/drivers/usb/gadget/udc/renesas_usb3.c
@@ -333,6 +333,7 @@ struct renesas_usb3 {
 	struct extcon_dev *extcon;
 	struct work_struct extcon_work;
 	struct phy *phy;
+	struct dentry *dentry;
 
 	struct renesas_usb3_ep *usb3_ep;
 	int num_usb3_eps;
@@ -2393,8 +2394,12 @@ static void renesas_usb3_debugfs_init(struct renesas_usb3 *usb3,
 
 	file = debugfs_create_file("b_device", 0644, root, usb3,
 				   &renesas_usb3_b_device_fops);
-	if (!file)
+	if (!file) {
 		dev_info(dev, "%s: Can't create debugfs mode\n", __func__);
+		debugfs_remove_recursive(root);
+	} else {
+		usb3->dentry = root;
+	}
 }
 
 /*------- platform_driver ------------------------------------------------*/
@@ -2402,6 +2407,7 @@ static int renesas_usb3_remove(struct platform_device *pdev)
 {
 	struct renesas_usb3 *usb3 = platform_get_drvdata(pdev);
 
+	debugfs_remove_recursive(usb3->dentry);
 	device_remove_file(&pdev->dev, &dev_attr_role);
 
 	usb_del_gadget_udc(&usb3->gadget);

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

* [PATCH v2 3/6] usb: gadget: udc: renesas_usb3: should call pm_runtime_enable() before add udc
@ 2018-04-10  5:38   ` Yoshihiro Shimoda
  0 siblings, 0 replies; 26+ messages in thread
From: Yoshihiro Shimoda @ 2018-04-10  5:38 UTC (permalink / raw)
  To: balbi; +Cc: gregkh, linux-usb, linux-renesas-soc, stable, Yoshihiro Shimoda

This patch fixes an issue that this driver causes panic if a gadget
driver is already loaded because usb_add_gadget_udc() might call
renesas_usb3_start() via .udc_start, and then pm_runtime_get_sync()
in renesas_usb3_start() doesn't work correctly.
Note that the usb3_to_dev() macro should not be called at this timing
because the macro uses the gadget structure.

Fixes: cf06df3fae28 ("usb: gadget: udc: renesas_usb3: move pm_runtime_{en,dis}able()")
Cc: <stable@vger.kernel.org> # v4.15+
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
---
Changes from v1:
 - Add Reviewed-by.

 drivers/usb/gadget/udc/renesas_usb3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
index 1c54a77..738b734 100644
--- a/drivers/usb/gadget/udc/renesas_usb3.c
+++ b/drivers/usb/gadget/udc/renesas_usb3.c
@@ -2632,6 +2632,7 @@ static int renesas_usb3_probe(struct platform_device *pdev)
 	if (ret < 0)
 		goto err_alloc_prd;
 
+	pm_runtime_enable(&pdev->dev);
 	ret = usb_add_gadget_udc(&pdev->dev, &usb3->gadget);
 	if (ret < 0)
 		goto err_add_udc;
@@ -2653,7 +2654,6 @@ static int renesas_usb3_probe(struct platform_device *pdev)
 	renesas_usb3_debugfs_init(usb3, &pdev->dev);
 
 	dev_info(&pdev->dev, "probed%s\n", usb3->phy ? " with phy" : "");
-	pm_runtime_enable(usb3_to_dev(usb3));
 
 	return 0;
 
-- 
1.9.1

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

* [v2,3/6] usb: gadget: udc: renesas_usb3: should call pm_runtime_enable() before add udc
@ 2018-04-10  5:38   ` Yoshihiro Shimoda
  0 siblings, 0 replies; 26+ messages in thread
From: Yoshihiro Shimoda @ 2018-04-10  5:38 UTC (permalink / raw)
  To: balbi; +Cc: gregkh, linux-usb, linux-renesas-soc, stable, Yoshihiro Shimoda

This patch fixes an issue that this driver causes panic if a gadget
driver is already loaded because usb_add_gadget_udc() might call
renesas_usb3_start() via .udc_start, and then pm_runtime_get_sync()
in renesas_usb3_start() doesn't work correctly.
Note that the usb3_to_dev() macro should not be called at this timing
because the macro uses the gadget structure.

Fixes: cf06df3fae28 ("usb: gadget: udc: renesas_usb3: move pm_runtime_{en,dis}able()")
Cc: <stable@vger.kernel.org> # v4.15+
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
---
Changes from v1:
 - Add Reviewed-by.

 drivers/usb/gadget/udc/renesas_usb3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
index 1c54a77..738b734 100644
--- a/drivers/usb/gadget/udc/renesas_usb3.c
+++ b/drivers/usb/gadget/udc/renesas_usb3.c
@@ -2632,6 +2632,7 @@ static int renesas_usb3_probe(struct platform_device *pdev)
 	if (ret < 0)
 		goto err_alloc_prd;
 
+	pm_runtime_enable(&pdev->dev);
 	ret = usb_add_gadget_udc(&pdev->dev, &usb3->gadget);
 	if (ret < 0)
 		goto err_add_udc;
@@ -2653,7 +2654,6 @@ static int renesas_usb3_probe(struct platform_device *pdev)
 	renesas_usb3_debugfs_init(usb3, &pdev->dev);
 
 	dev_info(&pdev->dev, "probed%s\n", usb3->phy ? " with phy" : "");
-	pm_runtime_enable(usb3_to_dev(usb3));
 
 	return 0;
 

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

* [PATCH v2 4/6] usb: gadget: udc: renesas_usb3: should call devm_phy_get() before add udc
@ 2018-04-10  5:38   ` Yoshihiro Shimoda
  0 siblings, 0 replies; 26+ messages in thread
From: Yoshihiro Shimoda @ 2018-04-10  5:38 UTC (permalink / raw)
  To: balbi; +Cc: gregkh, linux-usb, linux-renesas-soc, stable, Yoshihiro Shimoda

This patch fixes an issue that this driver cannot call phy_init()
if a gadget driver is alreadly loaded because usb_add_gadget_udc()
might call renesas_usb3_start() via .udc_start.
This patch also revises the typo (s/an optional/optional/).

Fixes: 279d4bc64060 ("usb: gadget: udc: renesas_usb3: add support for generic phy")
Cc: <stable@vger.kernel.org> # v4.15+
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
---
Changes from v1:
 - Add Reviewed-by.
 - Revise typo in the comment.

 drivers/usb/gadget/udc/renesas_usb3.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
index 738b734..233bc04 100644
--- a/drivers/usb/gadget/udc/renesas_usb3.c
+++ b/drivers/usb/gadget/udc/renesas_usb3.c
@@ -2632,6 +2632,14 @@ static int renesas_usb3_probe(struct platform_device *pdev)
 	if (ret < 0)
 		goto err_alloc_prd;
 
+	/*
+	 * This is optional. So, if this driver cannot get a phy,
+	 * this driver will not handle a phy anymore.
+	 */
+	usb3->phy = devm_phy_get(&pdev->dev, "usb");
+	if (IS_ERR(usb3->phy))
+		usb3->phy = NULL;
+
 	pm_runtime_enable(&pdev->dev);
 	ret = usb_add_gadget_udc(&pdev->dev, &usb3->gadget);
 	if (ret < 0)
@@ -2641,14 +2649,6 @@ static int renesas_usb3_probe(struct platform_device *pdev)
 	if (ret < 0)
 		goto err_dev_create;
 
-	/*
-	 * This is an optional. So, if this driver cannot get a phy,
-	 * this driver will not handle a phy anymore.
-	 */
-	usb3->phy = devm_phy_get(&pdev->dev, "usb");
-	if (IS_ERR(usb3->phy))
-		usb3->phy = NULL;
-
 	usb3->workaround_for_vbus = priv->workaround_for_vbus;
 
 	renesas_usb3_debugfs_init(usb3, &pdev->dev);
-- 
1.9.1

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

* [v2,4/6] usb: gadget: udc: renesas_usb3: should call devm_phy_get() before add udc
@ 2018-04-10  5:38   ` Yoshihiro Shimoda
  0 siblings, 0 replies; 26+ messages in thread
From: Yoshihiro Shimoda @ 2018-04-10  5:38 UTC (permalink / raw)
  To: balbi; +Cc: gregkh, linux-usb, linux-renesas-soc, stable, Yoshihiro Shimoda

This patch fixes an issue that this driver cannot call phy_init()
if a gadget driver is alreadly loaded because usb_add_gadget_udc()
might call renesas_usb3_start() via .udc_start.
This patch also revises the typo (s/an optional/optional/).

Fixes: 279d4bc64060 ("usb: gadget: udc: renesas_usb3: add support for generic phy")
Cc: <stable@vger.kernel.org> # v4.15+
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
---
Changes from v1:
 - Add Reviewed-by.
 - Revise typo in the comment.

 drivers/usb/gadget/udc/renesas_usb3.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
index 738b734..233bc04 100644
--- a/drivers/usb/gadget/udc/renesas_usb3.c
+++ b/drivers/usb/gadget/udc/renesas_usb3.c
@@ -2632,6 +2632,14 @@ static int renesas_usb3_probe(struct platform_device *pdev)
 	if (ret < 0)
 		goto err_alloc_prd;
 
+	/*
+	 * This is optional. So, if this driver cannot get a phy,
+	 * this driver will not handle a phy anymore.
+	 */
+	usb3->phy = devm_phy_get(&pdev->dev, "usb");
+	if (IS_ERR(usb3->phy))
+		usb3->phy = NULL;
+
 	pm_runtime_enable(&pdev->dev);
 	ret = usb_add_gadget_udc(&pdev->dev, &usb3->gadget);
 	if (ret < 0)
@@ -2641,14 +2649,6 @@ static int renesas_usb3_probe(struct platform_device *pdev)
 	if (ret < 0)
 		goto err_dev_create;
 
-	/*
-	 * This is an optional. So, if this driver cannot get a phy,
-	 * this driver will not handle a phy anymore.
-	 */
-	usb3->phy = devm_phy_get(&pdev->dev, "usb");
-	if (IS_ERR(usb3->phy))
-		usb3->phy = NULL;
-
 	usb3->workaround_for_vbus = priv->workaround_for_vbus;
 
 	renesas_usb3_debugfs_init(usb3, &pdev->dev);

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

* [PATCH v2 5/6] usb: gadget: udc: renesas_usb3: should fail if devm_phy_get() returns error
@ 2018-04-10  5:38   ` Yoshihiro Shimoda
  0 siblings, 0 replies; 26+ messages in thread
From: Yoshihiro Shimoda @ 2018-04-10  5:38 UTC (permalink / raw)
  To: balbi; +Cc: gregkh, linux-usb, linux-renesas-soc, stable, Yoshihiro Shimoda

This patch fixes an issue that this driver ignores errors other than
the non-existence of the device, f.e. a memory allocation failure
in devm_phy_get(). So, this patch replaces devm_phy_get() with
devm_phy_optional_get().

Reported-by: Simon Horman <horms+renesas@verge.net.au>
Fixes: 279d4bc64060 ("usb: gadget: udc: renesas_usb3: add support for generic phy")
Cc: <stable@vger.kernel.org> # v4.15+
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
Remarks:
 - A new file in v2

 drivers/usb/gadget/udc/renesas_usb3.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
index 233bc04..0e70163 100644
--- a/drivers/usb/gadget/udc/renesas_usb3.c
+++ b/drivers/usb/gadget/udc/renesas_usb3.c
@@ -2636,9 +2636,11 @@ static int renesas_usb3_probe(struct platform_device *pdev)
 	 * This is optional. So, if this driver cannot get a phy,
 	 * this driver will not handle a phy anymore.
 	 */
-	usb3->phy = devm_phy_get(&pdev->dev, "usb");
-	if (IS_ERR(usb3->phy))
-		usb3->phy = NULL;
+	usb3->phy = devm_phy_optional_get(&pdev->dev, "usb");
+	if (IS_ERR(usb3->phy)) {
+		ret = PTR_ERR(usb3->phy);
+		goto err_add_udc;
+	}
 
 	pm_runtime_enable(&pdev->dev);
 	ret = usb_add_gadget_udc(&pdev->dev, &usb3->gadget);
-- 
1.9.1

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

* [v2,5/6] usb: gadget: udc: renesas_usb3: should fail if devm_phy_get() returns error
@ 2018-04-10  5:38   ` Yoshihiro Shimoda
  0 siblings, 0 replies; 26+ messages in thread
From: Yoshihiro Shimoda @ 2018-04-10  5:38 UTC (permalink / raw)
  To: balbi; +Cc: gregkh, linux-usb, linux-renesas-soc, stable, Yoshihiro Shimoda

This patch fixes an issue that this driver ignores errors other than
the non-existence of the device, f.e. a memory allocation failure
in devm_phy_get(). So, this patch replaces devm_phy_get() with
devm_phy_optional_get().

Reported-by: Simon Horman <horms+renesas@verge.net.au>
Fixes: 279d4bc64060 ("usb: gadget: udc: renesas_usb3: add support for generic phy")
Cc: <stable@vger.kernel.org> # v4.15+
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
Remarks:
 - A new file in v2

 drivers/usb/gadget/udc/renesas_usb3.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
index 233bc04..0e70163 100644
--- a/drivers/usb/gadget/udc/renesas_usb3.c
+++ b/drivers/usb/gadget/udc/renesas_usb3.c
@@ -2636,9 +2636,11 @@ static int renesas_usb3_probe(struct platform_device *pdev)
 	 * This is optional. So, if this driver cannot get a phy,
 	 * this driver will not handle a phy anymore.
 	 */
-	usb3->phy = devm_phy_get(&pdev->dev, "usb");
-	if (IS_ERR(usb3->phy))
-		usb3->phy = NULL;
+	usb3->phy = devm_phy_optional_get(&pdev->dev, "usb");
+	if (IS_ERR(usb3->phy)) {
+		ret = PTR_ERR(usb3->phy);
+		goto err_add_udc;
+	}
 
 	pm_runtime_enable(&pdev->dev);
 	ret = usb_add_gadget_udc(&pdev->dev, &usb3->gadget);

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

* [PATCH v2 6/6] usb: gadget: udc: renesas_usb3: disable the controller's irqs for reconnecting
@ 2018-04-10  5:38   ` Yoshihiro Shimoda
  0 siblings, 0 replies; 26+ messages in thread
From: Yoshihiro Shimoda @ 2018-04-10  5:38 UTC (permalink / raw)
  To: balbi; +Cc: gregkh, linux-usb, linux-renesas-soc, stable, Yoshihiro Shimoda

This patch fixes an issue that reconnection is possible to fail
because unexpected state handling happens by the irqs. To fix the issue,
the driver disables the controller's irqs when disconnected.

Fixes: 746bfe63bba3 ("usb: gadget: renesas_usb3: add support for Renesas USB3.0 peripheral controller")
Cc: <stable@vger.kernel.org> # v4.5+
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---

Remarks:
 - A new file in v2

 drivers/usb/gadget/udc/renesas_usb3.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
index 0e70163..5caf78b 100644
--- a/drivers/usb/gadget/udc/renesas_usb3.c
+++ b/drivers/usb/gadget/udc/renesas_usb3.c
@@ -623,6 +623,13 @@ static void usb3_disconnect(struct renesas_usb3 *usb3)
 	usb3_usb2_pullup(usb3, 0);
 	usb3_clear_bit(usb3, USB30_CON_B3_CONNECT, USB3_USB30_CON);
 	usb3_reset_epc(usb3);
+	usb3_disable_irq_1(usb3, USB_INT_1_B2_RSUM | USB_INT_1_B3_PLLWKUP |
+			   USB_INT_1_B3_LUPSUCS | USB_INT_1_B3_DISABLE |
+			   USB_INT_1_SPEED | USB_INT_1_B3_WRMRST |
+			   USB_INT_1_B3_HOTRST | USB_INT_1_B2_SPND |
+			   USB_INT_1_B2_L1SPND | USB_INT_1_B2_USBRST);
+	usb3_clear_bit(usb3, USB_COM_CON_SPD_MODE, USB3_USB_COM_CON);
+	usb3_init_epc_registers(usb3);
 
 	if (usb3->driver)
 		usb3->driver->disconnect(&usb3->gadget);
-- 
1.9.1

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

* [v2,6/6] usb: gadget: udc: renesas_usb3: disable the controller's irqs for reconnecting
@ 2018-04-10  5:38   ` Yoshihiro Shimoda
  0 siblings, 0 replies; 26+ messages in thread
From: Yoshihiro Shimoda @ 2018-04-10  5:38 UTC (permalink / raw)
  To: balbi; +Cc: gregkh, linux-usb, linux-renesas-soc, stable, Yoshihiro Shimoda

This patch fixes an issue that reconnection is possible to fail
because unexpected state handling happens by the irqs. To fix the issue,
the driver disables the controller's irqs when disconnected.

Fixes: 746bfe63bba3 ("usb: gadget: renesas_usb3: add support for Renesas USB3.0 peripheral controller")
Cc: <stable@vger.kernel.org> # v4.5+
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---

Remarks:
 - A new file in v2

 drivers/usb/gadget/udc/renesas_usb3.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
index 0e70163..5caf78b 100644
--- a/drivers/usb/gadget/udc/renesas_usb3.c
+++ b/drivers/usb/gadget/udc/renesas_usb3.c
@@ -623,6 +623,13 @@ static void usb3_disconnect(struct renesas_usb3 *usb3)
 	usb3_usb2_pullup(usb3, 0);
 	usb3_clear_bit(usb3, USB30_CON_B3_CONNECT, USB3_USB30_CON);
 	usb3_reset_epc(usb3);
+	usb3_disable_irq_1(usb3, USB_INT_1_B2_RSUM | USB_INT_1_B3_PLLWKUP |
+			   USB_INT_1_B3_LUPSUCS | USB_INT_1_B3_DISABLE |
+			   USB_INT_1_SPEED | USB_INT_1_B3_WRMRST |
+			   USB_INT_1_B3_HOTRST | USB_INT_1_B2_SPND |
+			   USB_INT_1_B2_L1SPND | USB_INT_1_B2_USBRST);
+	usb3_clear_bit(usb3, USB_COM_CON_SPD_MODE, USB3_USB_COM_CON);
+	usb3_init_epc_registers(usb3);
 
 	if (usb3->driver)
 		usb3->driver->disconnect(&usb3->gadget);

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

* Re: [PATCH v2 6/6] usb: gadget: udc: renesas_usb3: disable the controller's irqs for reconnecting
@ 2018-04-10  9:34     ` Simon Horman
  0 siblings, 0 replies; 26+ messages in thread
From: Simon Horman @ 2018-04-10  9:34 UTC (permalink / raw)
  To: Yoshihiro Shimoda; +Cc: balbi, gregkh, linux-usb, linux-renesas-soc, stable

On Tue, Apr 10, 2018 at 02:38:54PM +0900, Yoshihiro Shimoda wrote:
> This patch fixes an issue that reconnection is possible to fail
> because unexpected state handling happens by the irqs. To fix the issue,
> the driver disables the controller's irqs when disconnected.
> 
> Fixes: 746bfe63bba3 ("usb: gadget: renesas_usb3: add support for Renesas USB3.0 peripheral controller")
> Cc: <stable@vger.kernel.org> # v4.5+
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

Reviewed-by: Simon Horman <horms+renesas@verge.net.au>

> ---
> 
> Remarks:
>  - A new file in v2
> 
>  drivers/usb/gadget/udc/renesas_usb3.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
> index 0e70163..5caf78b 100644
> --- a/drivers/usb/gadget/udc/renesas_usb3.c
> +++ b/drivers/usb/gadget/udc/renesas_usb3.c
> @@ -623,6 +623,13 @@ static void usb3_disconnect(struct renesas_usb3 *usb3)
>  	usb3_usb2_pullup(usb3, 0);
>  	usb3_clear_bit(usb3, USB30_CON_B3_CONNECT, USB3_USB30_CON);
>  	usb3_reset_epc(usb3);
> +	usb3_disable_irq_1(usb3, USB_INT_1_B2_RSUM | USB_INT_1_B3_PLLWKUP |
> +			   USB_INT_1_B3_LUPSUCS | USB_INT_1_B3_DISABLE |
> +			   USB_INT_1_SPEED | USB_INT_1_B3_WRMRST |
> +			   USB_INT_1_B3_HOTRST | USB_INT_1_B2_SPND |
> +			   USB_INT_1_B2_L1SPND | USB_INT_1_B2_USBRST);
> +	usb3_clear_bit(usb3, USB_COM_CON_SPD_MODE, USB3_USB_COM_CON);
> +	usb3_init_epc_registers(usb3);
>  
>  	if (usb3->driver)
>  		usb3->driver->disconnect(&usb3->gadget);
> -- 
> 1.9.1
> 

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

* [v2,6/6] usb: gadget: udc: renesas_usb3: disable the controller's irqs for reconnecting
@ 2018-04-10  9:34     ` Simon Horman
  0 siblings, 0 replies; 26+ messages in thread
From: Simon Horman @ 2018-04-10  9:34 UTC (permalink / raw)
  To: Yoshihiro Shimoda; +Cc: balbi, gregkh, linux-usb, linux-renesas-soc, stable

On Tue, Apr 10, 2018 at 02:38:54PM +0900, Yoshihiro Shimoda wrote:
> This patch fixes an issue that reconnection is possible to fail
> because unexpected state handling happens by the irqs. To fix the issue,
> the driver disables the controller's irqs when disconnected.
> 
> Fixes: 746bfe63bba3 ("usb: gadget: renesas_usb3: add support for Renesas USB3.0 peripheral controller")
> Cc: <stable@vger.kernel.org> # v4.5+
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

Reviewed-by: Simon Horman <horms+renesas@verge.net.au>

> ---
> 
> Remarks:
>  - A new file in v2
> 
>  drivers/usb/gadget/udc/renesas_usb3.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
> index 0e70163..5caf78b 100644
> --- a/drivers/usb/gadget/udc/renesas_usb3.c
> +++ b/drivers/usb/gadget/udc/renesas_usb3.c
> @@ -623,6 +623,13 @@ static void usb3_disconnect(struct renesas_usb3 *usb3)
>  	usb3_usb2_pullup(usb3, 0);
>  	usb3_clear_bit(usb3, USB30_CON_B3_CONNECT, USB3_USB30_CON);
>  	usb3_reset_epc(usb3);
> +	usb3_disable_irq_1(usb3, USB_INT_1_B2_RSUM | USB_INT_1_B3_PLLWKUP |
> +			   USB_INT_1_B3_LUPSUCS | USB_INT_1_B3_DISABLE |
> +			   USB_INT_1_SPEED | USB_INT_1_B3_WRMRST |
> +			   USB_INT_1_B3_HOTRST | USB_INT_1_B2_SPND |
> +			   USB_INT_1_B2_L1SPND | USB_INT_1_B2_USBRST);
> +	usb3_clear_bit(usb3, USB_COM_CON_SPD_MODE, USB3_USB_COM_CON);
> +	usb3_init_epc_registers(usb3);
>  
>  	if (usb3->driver)
>  		usb3->driver->disconnect(&usb3->gadget);
> -- 
> 1.9.1
>
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v2 5/6] usb: gadget: udc: renesas_usb3: should fail if devm_phy_get() returns error
@ 2018-04-10  9:35     ` Simon Horman
  0 siblings, 0 replies; 26+ messages in thread
From: Simon Horman @ 2018-04-10  9:35 UTC (permalink / raw)
  To: Yoshihiro Shimoda; +Cc: balbi, gregkh, linux-usb, linux-renesas-soc, stable

On Tue, Apr 10, 2018 at 02:38:53PM +0900, Yoshihiro Shimoda wrote:
> This patch fixes an issue that this driver ignores errors other than
> the non-existence of the device, f.e. a memory allocation failure
> in devm_phy_get(). So, this patch replaces devm_phy_get() with
> devm_phy_optional_get().
> 
> Reported-by: Simon Horman <horms+renesas@verge.net.au>
> Fixes: 279d4bc64060 ("usb: gadget: udc: renesas_usb3: add support for generic phy")
> Cc: <stable@vger.kernel.org> # v4.15+
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

Reviewed-by: Simon Horman <horms+renesas@verge.net.au>

> ---
> Remarks:
>  - A new file in v2
> 
>  drivers/usb/gadget/udc/renesas_usb3.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
> index 233bc04..0e70163 100644
> --- a/drivers/usb/gadget/udc/renesas_usb3.c
> +++ b/drivers/usb/gadget/udc/renesas_usb3.c
> @@ -2636,9 +2636,11 @@ static int renesas_usb3_probe(struct platform_device *pdev)
>  	 * This is optional. So, if this driver cannot get a phy,
>  	 * this driver will not handle a phy anymore.
>  	 */
> -	usb3->phy = devm_phy_get(&pdev->dev, "usb");
> -	if (IS_ERR(usb3->phy))
> -		usb3->phy = NULL;
> +	usb3->phy = devm_phy_optional_get(&pdev->dev, "usb");
> +	if (IS_ERR(usb3->phy)) {
> +		ret = PTR_ERR(usb3->phy);
> +		goto err_add_udc;
> +	}
>  
>  	pm_runtime_enable(&pdev->dev);
>  	ret = usb_add_gadget_udc(&pdev->dev, &usb3->gadget);
> -- 
> 1.9.1
> 

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

* [v2,5/6] usb: gadget: udc: renesas_usb3: should fail if devm_phy_get() returns error
@ 2018-04-10  9:35     ` Simon Horman
  0 siblings, 0 replies; 26+ messages in thread
From: Simon Horman @ 2018-04-10  9:35 UTC (permalink / raw)
  To: Yoshihiro Shimoda; +Cc: balbi, gregkh, linux-usb, linux-renesas-soc, stable

On Tue, Apr 10, 2018 at 02:38:53PM +0900, Yoshihiro Shimoda wrote:
> This patch fixes an issue that this driver ignores errors other than
> the non-existence of the device, f.e. a memory allocation failure
> in devm_phy_get(). So, this patch replaces devm_phy_get() with
> devm_phy_optional_get().
> 
> Reported-by: Simon Horman <horms+renesas@verge.net.au>
> Fixes: 279d4bc64060 ("usb: gadget: udc: renesas_usb3: add support for generic phy")
> Cc: <stable@vger.kernel.org> # v4.15+
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

Reviewed-by: Simon Horman <horms+renesas@verge.net.au>

> ---
> Remarks:
>  - A new file in v2
> 
>  drivers/usb/gadget/udc/renesas_usb3.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
> index 233bc04..0e70163 100644
> --- a/drivers/usb/gadget/udc/renesas_usb3.c
> +++ b/drivers/usb/gadget/udc/renesas_usb3.c
> @@ -2636,9 +2636,11 @@ static int renesas_usb3_probe(struct platform_device *pdev)
>  	 * This is optional. So, if this driver cannot get a phy,
>  	 * this driver will not handle a phy anymore.
>  	 */
> -	usb3->phy = devm_phy_get(&pdev->dev, "usb");
> -	if (IS_ERR(usb3->phy))
> -		usb3->phy = NULL;
> +	usb3->phy = devm_phy_optional_get(&pdev->dev, "usb");
> +	if (IS_ERR(usb3->phy)) {
> +		ret = PTR_ERR(usb3->phy);
> +		goto err_add_udc;
> +	}
>  
>  	pm_runtime_enable(&pdev->dev);
>  	ret = usb_add_gadget_udc(&pdev->dev, &usb3->gadget);
> -- 
> 1.9.1
>
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* RE: [PATCH v2 0/6] usb: gadget: udc: renesas_usb3: fix some major issues
  2018-04-10  5:38 [PATCH v2 0/6] usb: gadget: udc: renesas_usb3: fix some major issues Yoshihiro Shimoda
                   ` (5 preceding siblings ...)
  2018-04-10  5:38   ` [v2,6/6] " Yoshihiro Shimoda
@ 2018-05-10  7:25 ` Yoshihiro Shimoda
  6 siblings, 0 replies; 26+ messages in thread
From: Yoshihiro Shimoda @ 2018-05-10  7:25 UTC (permalink / raw)
  To: balbi; +Cc: gregkh, linux-usb, linux-renesas-soc, stable

Hi Felipe,

> From: Yoshihiro Shimoda, Sent: Tuesday, April 10, 2018 2:39 PM
> 
> This patch set is based on v4.16.

Would you review this patch set?
I checked this is able to be applied on your testing/fixes branch.

Best regards,
Yoshihiro Shimoda

> Changes from v1:
>  - Add Reviewed-by in patch 1, 2, 3 and 4.
>  - Revise typo in patch 4.
>  - Add new patches as patch 5 and 6.
> 
> Yoshihiro Shimoda (6):
>   usb: gadget: udc: renesas_usb3: fix double phy_put()
>   usb: gadget: udc: renesas_usb3: should remove debugfs
>   usb: gadget: udc: renesas_usb3: should call pm_runtime_enable() before
>     add udc
>   usb: gadget: udc: renesas_usb3: should call devm_phy_get() before add
>     udc
>   usb: gadget: udc: renesas_usb3: should fail if devm_phy_get() returns
>     error
>   usb: gadget: udc: renesas_usb3: disable the controller's irqs for
>     reconnecting
> 
>  drivers/usb/gadget/udc/renesas_usb3.c | 37 +++++++++++++++++++++++------------
>  1 file changed, 25 insertions(+), 12 deletions(-)
> 
> --
> 1.9.1

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

* Re: [PATCH v2 5/6] usb: gadget: udc: renesas_usb3: should fail if devm_phy_get() returns error
@ 2018-05-15  7:31     ` Simon Horman
  0 siblings, 0 replies; 26+ messages in thread
From: Simon Horman @ 2018-05-15  7:31 UTC (permalink / raw)
  To: Yoshihiro Shimoda; +Cc: balbi, gregkh, linux-usb, linux-renesas-soc, stable

On Tue, Apr 10, 2018 at 02:38:53PM +0900, Yoshihiro Shimoda wrote:
> This patch fixes an issue that this driver ignores errors other than
> the non-existence of the device, f.e. a memory allocation failure
> in devm_phy_get(). So, this patch replaces devm_phy_get() with
> devm_phy_optional_get().
> 
> Reported-by: Simon Horman <horms+renesas@verge.net.au>
> Fixes: 279d4bc64060 ("usb: gadget: udc: renesas_usb3: add support for generic phy")
> Cc: <stable@vger.kernel.org> # v4.15+
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

Reviewed-by: Simon Horman <horms+renesas@verge.net.au>

> ---
> Remarks:
>  - A new file in v2
> 
>  drivers/usb/gadget/udc/renesas_usb3.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
> index 233bc04..0e70163 100644
> --- a/drivers/usb/gadget/udc/renesas_usb3.c
> +++ b/drivers/usb/gadget/udc/renesas_usb3.c
> @@ -2636,9 +2636,11 @@ static int renesas_usb3_probe(struct platform_device *pdev)
>  	 * This is optional. So, if this driver cannot get a phy,
>  	 * this driver will not handle a phy anymore.
>  	 */
> -	usb3->phy = devm_phy_get(&pdev->dev, "usb");
> -	if (IS_ERR(usb3->phy))
> -		usb3->phy = NULL;
> +	usb3->phy = devm_phy_optional_get(&pdev->dev, "usb");
> +	if (IS_ERR(usb3->phy)) {
> +		ret = PTR_ERR(usb3->phy);
> +		goto err_add_udc;
> +	}
>  
>  	pm_runtime_enable(&pdev->dev);
>  	ret = usb_add_gadget_udc(&pdev->dev, &usb3->gadget);
> -- 
> 1.9.1
> 

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

* [v2,5/6] usb: gadget: udc: renesas_usb3: should fail if devm_phy_get() returns error
@ 2018-05-15  7:31     ` Simon Horman
  0 siblings, 0 replies; 26+ messages in thread
From: Simon Horman @ 2018-05-15  7:31 UTC (permalink / raw)
  To: Yoshihiro Shimoda; +Cc: balbi, gregkh, linux-usb, linux-renesas-soc, stable

On Tue, Apr 10, 2018 at 02:38:53PM +0900, Yoshihiro Shimoda wrote:
> This patch fixes an issue that this driver ignores errors other than
> the non-existence of the device, f.e. a memory allocation failure
> in devm_phy_get(). So, this patch replaces devm_phy_get() with
> devm_phy_optional_get().
> 
> Reported-by: Simon Horman <horms+renesas@verge.net.au>
> Fixes: 279d4bc64060 ("usb: gadget: udc: renesas_usb3: add support for generic phy")
> Cc: <stable@vger.kernel.org> # v4.15+
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

Reviewed-by: Simon Horman <horms+renesas@verge.net.au>

> ---
> Remarks:
>  - A new file in v2
> 
>  drivers/usb/gadget/udc/renesas_usb3.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
> index 233bc04..0e70163 100644
> --- a/drivers/usb/gadget/udc/renesas_usb3.c
> +++ b/drivers/usb/gadget/udc/renesas_usb3.c
> @@ -2636,9 +2636,11 @@ static int renesas_usb3_probe(struct platform_device *pdev)
>  	 * This is optional. So, if this driver cannot get a phy,
>  	 * this driver will not handle a phy anymore.
>  	 */
> -	usb3->phy = devm_phy_get(&pdev->dev, "usb");
> -	if (IS_ERR(usb3->phy))
> -		usb3->phy = NULL;
> +	usb3->phy = devm_phy_optional_get(&pdev->dev, "usb");
> +	if (IS_ERR(usb3->phy)) {
> +		ret = PTR_ERR(usb3->phy);
> +		goto err_add_udc;
> +	}
>  
>  	pm_runtime_enable(&pdev->dev);
>  	ret = usb_add_gadget_udc(&pdev->dev, &usb3->gadget);
> -- 
> 1.9.1
>
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v2 6/6] usb: gadget: udc: renesas_usb3: disable the controller's irqs for reconnecting
@ 2018-05-15  7:35     ` Simon Horman
  0 siblings, 0 replies; 26+ messages in thread
From: Simon Horman @ 2018-05-15  7:35 UTC (permalink / raw)
  To: Yoshihiro Shimoda; +Cc: balbi, gregkh, linux-usb, linux-renesas-soc, stable

On Tue, Apr 10, 2018 at 02:38:54PM +0900, Yoshihiro Shimoda wrote:
> This patch fixes an issue that reconnection is possible to fail
> because unexpected state handling happens by the irqs. To fix the issue,
> the driver disables the controller's irqs when disconnected.
> 
> Fixes: 746bfe63bba3 ("usb: gadget: renesas_usb3: add support for Renesas USB3.0 peripheral controller")
> Cc: <stable@vger.kernel.org> # v4.5+
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> ---
> 
> Remarks:
>  - A new file in v2
> 
>  drivers/usb/gadget/udc/renesas_usb3.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
> index 0e70163..5caf78b 100644
> --- a/drivers/usb/gadget/udc/renesas_usb3.c
> +++ b/drivers/usb/gadget/udc/renesas_usb3.c
> @@ -623,6 +623,13 @@ static void usb3_disconnect(struct renesas_usb3 *usb3)
>  	usb3_usb2_pullup(usb3, 0);
>  	usb3_clear_bit(usb3, USB30_CON_B3_CONNECT, USB3_USB30_CON);
>  	usb3_reset_epc(usb3);
> +	usb3_disable_irq_1(usb3, USB_INT_1_B2_RSUM | USB_INT_1_B3_PLLWKUP |
> +			   USB_INT_1_B3_LUPSUCS | USB_INT_1_B3_DISABLE |
> +			   USB_INT_1_SPEED | USB_INT_1_B3_WRMRST |
> +			   USB_INT_1_B3_HOTRST | USB_INT_1_B2_SPND |
> +			   USB_INT_1_B2_L1SPND | USB_INT_1_B2_USBRST);

Hi Shimoda-san,

is it intentional that USB_INT_1_VBUS_CNG is not disabled above?

> +	usb3_clear_bit(usb3, USB_COM_CON_SPD_MODE, USB3_USB_COM_CON);
> +	usb3_init_epc_registers(usb3);
>  
>  	if (usb3->driver)
>  		usb3->driver->disconnect(&usb3->gadget);
> -- 
> 1.9.1
> 

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

* [v2,6/6] usb: gadget: udc: renesas_usb3: disable the controller's irqs for reconnecting
@ 2018-05-15  7:35     ` Simon Horman
  0 siblings, 0 replies; 26+ messages in thread
From: Simon Horman @ 2018-05-15  7:35 UTC (permalink / raw)
  To: Yoshihiro Shimoda; +Cc: balbi, gregkh, linux-usb, linux-renesas-soc, stable

On Tue, Apr 10, 2018 at 02:38:54PM +0900, Yoshihiro Shimoda wrote:
> This patch fixes an issue that reconnection is possible to fail
> because unexpected state handling happens by the irqs. To fix the issue,
> the driver disables the controller's irqs when disconnected.
> 
> Fixes: 746bfe63bba3 ("usb: gadget: renesas_usb3: add support for Renesas USB3.0 peripheral controller")
> Cc: <stable@vger.kernel.org> # v4.5+
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> ---
> 
> Remarks:
>  - A new file in v2
> 
>  drivers/usb/gadget/udc/renesas_usb3.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
> index 0e70163..5caf78b 100644
> --- a/drivers/usb/gadget/udc/renesas_usb3.c
> +++ b/drivers/usb/gadget/udc/renesas_usb3.c
> @@ -623,6 +623,13 @@ static void usb3_disconnect(struct renesas_usb3 *usb3)
>  	usb3_usb2_pullup(usb3, 0);
>  	usb3_clear_bit(usb3, USB30_CON_B3_CONNECT, USB3_USB30_CON);
>  	usb3_reset_epc(usb3);
> +	usb3_disable_irq_1(usb3, USB_INT_1_B2_RSUM | USB_INT_1_B3_PLLWKUP |
> +			   USB_INT_1_B3_LUPSUCS | USB_INT_1_B3_DISABLE |
> +			   USB_INT_1_SPEED | USB_INT_1_B3_WRMRST |
> +			   USB_INT_1_B3_HOTRST | USB_INT_1_B2_SPND |
> +			   USB_INT_1_B2_L1SPND | USB_INT_1_B2_USBRST);

Hi Shimoda-san,

is it intentional that USB_INT_1_VBUS_CNG is not disabled above?

> +	usb3_clear_bit(usb3, USB_COM_CON_SPD_MODE, USB3_USB_COM_CON);
> +	usb3_init_epc_registers(usb3);
>  
>  	if (usb3->driver)
>  		usb3->driver->disconnect(&usb3->gadget);
> -- 
> 1.9.1
>
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* RE: [PATCH v2 6/6] usb: gadget: udc: renesas_usb3: disable the controller's irqs for reconnecting
@ 2018-05-15  7:49       ` Yoshihiro Shimoda
  0 siblings, 0 replies; 26+ messages in thread
From: Yoshihiro Shimoda @ 2018-05-15  7:49 UTC (permalink / raw)
  To: Simon Horman; +Cc: balbi, gregkh, linux-usb, linux-renesas-soc, stable

Hi Simon-san,

Thank you for your review!

> From: Simon Horman, Sent: Tuesday, May 15, 2018 4:35 PM
> 
> On Tue, Apr 10, 2018 at 02:38:54PM +0900, Yoshihiro Shimoda wrote:
> > This patch fixes an issue that reconnection is possible to fail
> > because unexpected state handling happens by the irqs. To fix the issue,
> > the driver disables the controller's irqs when disconnected.
> >
> > Fixes: 746bfe63bba3 ("usb: gadget: renesas_usb3: add support for Renesas USB3.0 peripheral controller")
> > Cc: <stable@vger.kernel.org> # v4.5+
> > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> > ---
> >
> > Remarks:
> >  - A new file in v2
> >
> >  drivers/usb/gadget/udc/renesas_usb3.c | 7 +++++++
> >  1 file changed, 7 insertions(+)
> >
> > diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
> > index 0e70163..5caf78b 100644
> > --- a/drivers/usb/gadget/udc/renesas_usb3.c
> > +++ b/drivers/usb/gadget/udc/renesas_usb3.c
> > @@ -623,6 +623,13 @@ static void usb3_disconnect(struct renesas_usb3 *usb3)
> >  	usb3_usb2_pullup(usb3, 0);
> >  	usb3_clear_bit(usb3, USB30_CON_B3_CONNECT, USB3_USB30_CON);
> >  	usb3_reset_epc(usb3);
> > +	usb3_disable_irq_1(usb3, USB_INT_1_B2_RSUM | USB_INT_1_B3_PLLWKUP |
> > +			   USB_INT_1_B3_LUPSUCS | USB_INT_1_B3_DISABLE |
> > +			   USB_INT_1_SPEED | USB_INT_1_B3_WRMRST |
> > +			   USB_INT_1_B3_HOTRST | USB_INT_1_B2_SPND |
> > +			   USB_INT_1_B2_L1SPND | USB_INT_1_B2_USBRST);
> 
> Hi Shimoda-san,
> 
> is it intentional that USB_INT_1_VBUS_CNG is not disabled above?

Yes, because the USB_INT_1_VBUS_CNG is enabled in usb3_init_epc_registers() below.

> > +	usb3_clear_bit(usb3, USB_COM_CON_SPD_MODE, USB3_USB_COM_CON);
> > +	usb3_init_epc_registers(usb3);

Best regards,
Yoshihiro Shimoda

> >  	if (usb3->driver)
> >  		usb3->driver->disconnect(&usb3->gadget);
> > --
> > 1.9.1
> >

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

* [v2,6/6] usb: gadget: udc: renesas_usb3: disable the controller's irqs for reconnecting
@ 2018-05-15  7:49       ` Yoshihiro Shimoda
  0 siblings, 0 replies; 26+ messages in thread
From: Yoshihiro Shimoda @ 2018-05-15  7:49 UTC (permalink / raw)
  To: Simon Horman; +Cc: balbi, gregkh, linux-usb, linux-renesas-soc, stable

Hi Simon-san,

Thank you for your review!

> From: Simon Horman, Sent: Tuesday, May 15, 2018 4:35 PM
> 
> On Tue, Apr 10, 2018 at 02:38:54PM +0900, Yoshihiro Shimoda wrote:
> > This patch fixes an issue that reconnection is possible to fail
> > because unexpected state handling happens by the irqs. To fix the issue,
> > the driver disables the controller's irqs when disconnected.
> >
> > Fixes: 746bfe63bba3 ("usb: gadget: renesas_usb3: add support for Renesas USB3.0 peripheral controller")
> > Cc: <stable@vger.kernel.org> # v4.5+
> > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> > ---
> >
> > Remarks:
> >  - A new file in v2
> >
> >  drivers/usb/gadget/udc/renesas_usb3.c | 7 +++++++
> >  1 file changed, 7 insertions(+)
> >
> > diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
> > index 0e70163..5caf78b 100644
> > --- a/drivers/usb/gadget/udc/renesas_usb3.c
> > +++ b/drivers/usb/gadget/udc/renesas_usb3.c
> > @@ -623,6 +623,13 @@ static void usb3_disconnect(struct renesas_usb3 *usb3)
> >  	usb3_usb2_pullup(usb3, 0);
> >  	usb3_clear_bit(usb3, USB30_CON_B3_CONNECT, USB3_USB30_CON);
> >  	usb3_reset_epc(usb3);
> > +	usb3_disable_irq_1(usb3, USB_INT_1_B2_RSUM | USB_INT_1_B3_PLLWKUP |
> > +			   USB_INT_1_B3_LUPSUCS | USB_INT_1_B3_DISABLE |
> > +			   USB_INT_1_SPEED | USB_INT_1_B3_WRMRST |
> > +			   USB_INT_1_B3_HOTRST | USB_INT_1_B2_SPND |
> > +			   USB_INT_1_B2_L1SPND | USB_INT_1_B2_USBRST);
> 
> Hi Shimoda-san,
> 
> is it intentional that USB_INT_1_VBUS_CNG is not disabled above?

Yes, because the USB_INT_1_VBUS_CNG is enabled in usb3_init_epc_registers() below.

> > +	usb3_clear_bit(usb3, USB_COM_CON_SPD_MODE, USB3_USB_COM_CON);
> > +	usb3_init_epc_registers(usb3);

Best regards,
Yoshihiro Shimoda

> >  	if (usb3->driver)
> >  		usb3->driver->disconnect(&usb3->gadget);
> > --
> > 1.9.1
> >
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v2 6/6] usb: gadget: udc: renesas_usb3: disable the controller's irqs for reconnecting
@ 2018-05-15  7:55         ` Simon Horman
  0 siblings, 0 replies; 26+ messages in thread
From: Simon Horman @ 2018-05-15  7:55 UTC (permalink / raw)
  To: Yoshihiro Shimoda; +Cc: balbi, gregkh, linux-usb, linux-renesas-soc, stable

On Tue, May 15, 2018 at 07:49:44AM +0000, Yoshihiro Shimoda wrote:
> Hi Simon-san,
> 
> Thank you for your review!
> 
> > From: Simon Horman, Sent: Tuesday, May 15, 2018 4:35 PM
> > 
> > On Tue, Apr 10, 2018 at 02:38:54PM +0900, Yoshihiro Shimoda wrote:
> > > This patch fixes an issue that reconnection is possible to fail
> > > because unexpected state handling happens by the irqs. To fix the issue,
> > > the driver disables the controller's irqs when disconnected.
> > >
> > > Fixes: 746bfe63bba3 ("usb: gadget: renesas_usb3: add support for Renesas USB3.0 peripheral controller")
> > > Cc: <stable@vger.kernel.org> # v4.5+
> > > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> > > ---
> > >
> > > Remarks:
> > >  - A new file in v2
> > >
> > >  drivers/usb/gadget/udc/renesas_usb3.c | 7 +++++++
> > >  1 file changed, 7 insertions(+)
> > >
> > > diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
> > > index 0e70163..5caf78b 100644
> > > --- a/drivers/usb/gadget/udc/renesas_usb3.c
> > > +++ b/drivers/usb/gadget/udc/renesas_usb3.c
> > > @@ -623,6 +623,13 @@ static void usb3_disconnect(struct renesas_usb3 *usb3)
> > >  	usb3_usb2_pullup(usb3, 0);
> > >  	usb3_clear_bit(usb3, USB30_CON_B3_CONNECT, USB3_USB30_CON);
> > >  	usb3_reset_epc(usb3);
> > > +	usb3_disable_irq_1(usb3, USB_INT_1_B2_RSUM | USB_INT_1_B3_PLLWKUP |
> > > +			   USB_INT_1_B3_LUPSUCS | USB_INT_1_B3_DISABLE |
> > > +			   USB_INT_1_SPEED | USB_INT_1_B3_WRMRST |
> > > +			   USB_INT_1_B3_HOTRST | USB_INT_1_B2_SPND |
> > > +			   USB_INT_1_B2_L1SPND | USB_INT_1_B2_USBRST);
> > 
> > Hi Shimoda-san,
> > 
> > is it intentional that USB_INT_1_VBUS_CNG is not disabled above?
> 
> Yes, because the USB_INT_1_VBUS_CNG is enabled in usb3_init_epc_registers() below.

Thanks for the clarification,

Reviewed-by: Simon Horman <horms+renesas@verge.net.au>

> 
> > > +	usb3_clear_bit(usb3, USB_COM_CON_SPD_MODE, USB3_USB_COM_CON);
> > > +	usb3_init_epc_registers(usb3);
> 
> Best regards,
> Yoshihiro Shimoda
> 
> > >  	if (usb3->driver)
> > >  		usb3->driver->disconnect(&usb3->gadget);
> > > --
> > > 1.9.1
> > >
> 

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

* [v2,6/6] usb: gadget: udc: renesas_usb3: disable the controller's irqs for reconnecting
@ 2018-05-15  7:55         ` Simon Horman
  0 siblings, 0 replies; 26+ messages in thread
From: Simon Horman @ 2018-05-15  7:55 UTC (permalink / raw)
  To: Yoshihiro Shimoda; +Cc: balbi, gregkh, linux-usb, linux-renesas-soc, stable

On Tue, May 15, 2018 at 07:49:44AM +0000, Yoshihiro Shimoda wrote:
> Hi Simon-san,
> 
> Thank you for your review!
> 
> > From: Simon Horman, Sent: Tuesday, May 15, 2018 4:35 PM
> > 
> > On Tue, Apr 10, 2018 at 02:38:54PM +0900, Yoshihiro Shimoda wrote:
> > > This patch fixes an issue that reconnection is possible to fail
> > > because unexpected state handling happens by the irqs. To fix the issue,
> > > the driver disables the controller's irqs when disconnected.
> > >
> > > Fixes: 746bfe63bba3 ("usb: gadget: renesas_usb3: add support for Renesas USB3.0 peripheral controller")
> > > Cc: <stable@vger.kernel.org> # v4.5+
> > > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> > > ---
> > >
> > > Remarks:
> > >  - A new file in v2
> > >
> > >  drivers/usb/gadget/udc/renesas_usb3.c | 7 +++++++
> > >  1 file changed, 7 insertions(+)
> > >
> > > diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
> > > index 0e70163..5caf78b 100644
> > > --- a/drivers/usb/gadget/udc/renesas_usb3.c
> > > +++ b/drivers/usb/gadget/udc/renesas_usb3.c
> > > @@ -623,6 +623,13 @@ static void usb3_disconnect(struct renesas_usb3 *usb3)
> > >  	usb3_usb2_pullup(usb3, 0);
> > >  	usb3_clear_bit(usb3, USB30_CON_B3_CONNECT, USB3_USB30_CON);
> > >  	usb3_reset_epc(usb3);
> > > +	usb3_disable_irq_1(usb3, USB_INT_1_B2_RSUM | USB_INT_1_B3_PLLWKUP |
> > > +			   USB_INT_1_B3_LUPSUCS | USB_INT_1_B3_DISABLE |
> > > +			   USB_INT_1_SPEED | USB_INT_1_B3_WRMRST |
> > > +			   USB_INT_1_B3_HOTRST | USB_INT_1_B2_SPND |
> > > +			   USB_INT_1_B2_L1SPND | USB_INT_1_B2_USBRST);
> > 
> > Hi Shimoda-san,
> > 
> > is it intentional that USB_INT_1_VBUS_CNG is not disabled above?
> 
> Yes, because the USB_INT_1_VBUS_CNG is enabled in usb3_init_epc_registers() below.

Thanks for the clarification,

Reviewed-by: Simon Horman <horms+renesas@verge.net.au>

> 
> > > +	usb3_clear_bit(usb3, USB_COM_CON_SPD_MODE, USB3_USB_COM_CON);
> > > +	usb3_init_epc_registers(usb3);
> 
> Best regards,
> Yoshihiro Shimoda
> 
> > >  	if (usb3->driver)
> > >  		usb3->driver->disconnect(&usb3->gadget);
> > > --
> > > 1.9.1
> > >
>
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2018-05-15  7:56 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-10  5:38 [PATCH v2 0/6] usb: gadget: udc: renesas_usb3: fix some major issues Yoshihiro Shimoda
2018-04-10  5:38 ` [PATCH v2 1/6] usb: gadget: udc: renesas_usb3: fix double phy_put() Yoshihiro Shimoda
2018-04-10  5:38   ` [v2,1/6] " Yoshihiro Shimoda
2018-04-10  5:38 ` [PATCH v2 2/6] usb: gadget: udc: renesas_usb3: should remove debugfs Yoshihiro Shimoda
2018-04-10  5:38   ` [v2,2/6] " Yoshihiro Shimoda
2018-04-10  5:38 ` [PATCH v2 3/6] usb: gadget: udc: renesas_usb3: should call pm_runtime_enable() before add udc Yoshihiro Shimoda
2018-04-10  5:38   ` [v2,3/6] " Yoshihiro Shimoda
2018-04-10  5:38 ` [PATCH v2 4/6] usb: gadget: udc: renesas_usb3: should call devm_phy_get() " Yoshihiro Shimoda
2018-04-10  5:38   ` [v2,4/6] " Yoshihiro Shimoda
2018-04-10  5:38 ` [PATCH v2 5/6] usb: gadget: udc: renesas_usb3: should fail if devm_phy_get() returns error Yoshihiro Shimoda
2018-04-10  5:38   ` [v2,5/6] " Yoshihiro Shimoda
2018-04-10  9:35   ` [PATCH v2 5/6] " Simon Horman
2018-04-10  9:35     ` [v2,5/6] " Simon Horman
2018-05-15  7:31   ` [PATCH v2 5/6] " Simon Horman
2018-05-15  7:31     ` [v2,5/6] " Simon Horman
2018-04-10  5:38 ` [PATCH v2 6/6] usb: gadget: udc: renesas_usb3: disable the controller's irqs for reconnecting Yoshihiro Shimoda
2018-04-10  5:38   ` [v2,6/6] " Yoshihiro Shimoda
2018-04-10  9:34   ` [PATCH v2 6/6] " Simon Horman
2018-04-10  9:34     ` [v2,6/6] " Simon Horman
2018-05-15  7:35   ` [PATCH v2 6/6] " Simon Horman
2018-05-15  7:35     ` [v2,6/6] " Simon Horman
2018-05-15  7:49     ` [PATCH v2 6/6] " Yoshihiro Shimoda
2018-05-15  7:49       ` [v2,6/6] " Yoshihiro Shimoda
2018-05-15  7:55       ` [PATCH v2 6/6] " Simon Horman
2018-05-15  7:55         ` [v2,6/6] " Simon Horman
2018-05-10  7:25 ` [PATCH v2 0/6] usb: gadget: udc: renesas_usb3: fix some major issues Yoshihiro Shimoda

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.